libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiListView Class Reference

Scrollable list of items with keyboard and mouse navigation. More...

#include <listview.h>

Inheritance diagram for TuiListView:
Collaboration diagram for TuiListView:

Public Member Functions

 TuiListView (ObjectBase *parent=nullptr)
 
void addItem (const String &item)
 
void insertItem (int index, const String &item)
 
void setItems (const StringList &items)
 
void clear ()
 
int currentIndex () const
 
void setCurrentIndex (int index)
 
String currentItem () const
 
int count () const
 
int scrollOffset () const
 Returns the current scroll offset.
 
void scrollBy (int delta)
 Scrolls the viewport by the given number of items.
 
void ensureVisible (int index)
 Adjusts the scroll offset so that the given index is visible.
 
Size2Di32 sizeHint () const override
 Returns the preferred size. Override in subclasses.
 
- Public Member Functions inherited from TuiWidget
 TuiWidget (ObjectBase *parent=nullptr)
 Constructs a TuiWidget.
 
virtual ~TuiWidget ()
 Destructor.
 
const Rect2Di32geometry () const
 Returns the geometry relative to parent.
 
void setGeometry (const Rect2Di32 &rect)
 Sets the geometry.
 
int x () const
 Returns the X coordinate relative to parent.
 
int y () const
 Returns the Y coordinate relative to parent.
 
int width () const
 Returns the width.
 
int height () const
 Returns the height.
 
Size2Di32 size () const
 Returns the size.
 
const Size2Di32minimumSize () const
 Returns the minimum size constraint.
 
void setMinimumSize (const Size2Di32 &size)
 Sets the minimum size constraint.
 
const Size2Di32maximumSize () const
 Returns the maximum size constraint.
 
void setMaximumSize (const Size2Di32 &size)
 Sets the maximum size constraint.
 
TuiSizePolicy sizePolicy () const
 Returns the size policy.
 
void setSizePolicy (TuiSizePolicy policy)
 Sets the size policy.
 
bool isVisible () const
 Returns true if the widget's own visibility flag is set.
 
bool isEffectivelyVisible () const
 Returns true if the widget and all its ancestors are visible.
 
void show ()
 Shows the widget.
 
void hide ()
 Hides the widget.
 
void setVisible (bool visible)
 Sets visibility.
 
bool isEnabled () const
 Returns true if the widget is enabled.
 
void setEnabled (bool enabled)
 Sets enabled state.
 
TuiFocusPolicy focusPolicy () const
 Returns the focus policy.
 
void setFocusPolicy (TuiFocusPolicy policy)
 Sets the focus policy.
 
bool hasFocus () const
 Returns true if this widget has focus.
 
void setFocus ()
 Requests focus for this widget.
 
void update ()
 Marks the widget as needing a repaint.
 
bool isDirty () const
 Returns true if the widget needs repainting.
 
void clearDirty ()
 Clears the dirty flag.
 
TuiLayoutlayout () const
 Returns the layout, if one is set.
 
void setLayout (TuiLayout *layout)
 Sets the layout for this widget.
 
Point2Di32 mapToParent (const Point2Di32 &p) const
 Maps a local point to the parent's coordinate system.
 
Point2Di32 mapFromParent (const Point2Di32 &p) const
 Maps a parent point to local coordinates.
 
Point2Di32 mapToGlobal (const Point2Di32 &p) const
 Maps a local point to global (screen) coordinates.
 
Point2Di32 mapFromGlobal (const Point2Di32 &p) const
 Maps a global (screen) point to local coordinates.
 
virtual Size2Di32 minimumSizeHint () const
 Returns the minimum size hint. Override in subclasses.
 
- Public Member Functions inherited from ObjectBase
 ObjectBase (ObjectBase *p=nullptr)
 Default ObjectBase constructor.
 
virtual ~ObjectBase ()
 Destructor. Emits aboutToDestroy, detaches from parent, and destroys children.
 
ObjectBaseparent () const
 Returns the parent object, if one. nullptr if none.
 
void setParent (ObjectBase *p)
 Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one.
 
const ObjectBaseListchildList () const
 Returns a list of children of this object.
 
template<typename... Args>
int registerSlot (Slot< Args... > *slot)
 Registers a slot with this object and assigns it an ID.
 
EventLoopeventLoop () const
 Returns the EventLoop this object is affiliated with.
 
void moveToThread (EventLoop *loop)
 Changes the EventLoop affinity of this object.
 
int startTimer (unsigned int intervalMs, bool singleShot=false)
 Starts a timer on this object's EventLoop.
 
void stopTimer (int timerId)
 Stops a timer previously started with startTimer().
 
template<typename... Args>
PROMEKI_NAMESPACE_BEGIN void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 

Protected Member Functions

void paintEvent (TuiPaintEvent *e) override
 Called to paint the widget. Override in subclasses.
 
void keyEvent (KeyEvent *e) override
 Called on keyboard input. Override in subclasses.
 
void mouseEvent (MouseEvent *e) override
 Called on mouse input. Override in subclasses.
 
- Protected Member Functions inherited from TuiWidget
virtual void resizeEvent (TuiResizeEvent *e)
 Called when the widget is resized. Override in subclasses.
 
virtual void focusInEvent (Event *e)
 Called when the widget gains focus.
 
virtual void focusOutEvent (Event *e)
 Called when the widget loses focus.
 
void event (Event *e) override
 Event dispatch override.
 
- Protected Member Functions inherited from ObjectBase
ObjectBasesignalSender ()
 Returns the ObjectBase that emitted the signal currently being handled.
 
virtual void timerEvent (TimerEvent *e)
 Called when a timer fires for this object.
 

Additional Inherited Members

- Public Types inherited from ObjectBase
using SlotVariantFunc = std::function< void(const VariantList &)>
 Function type for invoking a slot with a list of Variants.
 
- Static Public Member Functions inherited from ObjectBase
static const MetaInfometaInfo ()
 Returns the MetaInfo for the ObjectBase class.
 
template<typename... Args>
static void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object
 
- Public Attributes inherited from ObjectBase
Signal< ObjectBase * > aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName)
 
- Static Public Attributes inherited from ObjectBase
static constexpr const charaboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")"
 
static SignalMeta aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName)
 

Detailed Description

Scrollable list of items with keyboard and mouse navigation.

Supports single selection via keyboard (Up/Down/PageUp/PageDown/Home/End) and mouse (click to select, double-click to activate). Mouse wheel and scrollbar interaction scroll the viewport independently of the selection. The Enter key activates the current item via the itemActivated signal.

Member Function Documentation

◆ ensureVisible()

void TuiListView::ensureVisible ( int  index)

Adjusts the scroll offset so that the given index is visible.

Parameters
indexThe item index to make visible.

◆ keyEvent()

void TuiListView::keyEvent ( KeyEvent e)
overrideprotectedvirtual

Called on keyboard input. Override in subclasses.

Reimplemented from TuiWidget.

◆ mouseEvent()

void TuiListView::mouseEvent ( MouseEvent e)
overrideprotectedvirtual

Called on mouse input. Override in subclasses.

Reimplemented from TuiWidget.

◆ paintEvent()

void TuiListView::paintEvent ( TuiPaintEvent e)
overrideprotectedvirtual

Called to paint the widget. Override in subclasses.

Reimplemented from TuiWidget.

◆ scrollBy()

void TuiListView::scrollBy ( int  delta)

Scrolls the viewport by the given number of items.

Moves only the viewport scroll offset without changing the current selection (following Qt convention). The current index may end up off-screen after scrolling; use ensureVisible() to bring it back into view if needed.

Parameters
deltaNumber of items to scroll (positive = down, negative = up).

◆ sizeHint()

Size2Di32 TuiListView::sizeHint ( ) const
overridevirtual

Returns the preferred size. Override in subclasses.

Reimplemented from TuiWidget.


The documentation for this class was generated from the following file: