QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskListView.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_LIST_VIEW_H
7#define QSK_LIST_VIEW_H
8
9#include "QskScrollView.h"
10#include "QskTextOptions.h"
11
12class QSK_EXPORT QskListView : public QskScrollView
13{
14 Q_OBJECT
15
16 Q_PROPERTY( SelectionMode selectionMode READ selectionMode
17 WRITE setSelectionMode NOTIFY selectionModeChanged FINAL )
18
19 Q_PROPERTY( int selectedRow READ selectedRow
20 WRITE setSelectedRow NOTIFY selectedRowChanged USER true FINAL )
21
22 Q_PROPERTY( QskTextOptions textOptions READ textOptions
23 WRITE setTextOptions RESET resetTextOptions
24 NOTIFY textOptionsChanged FINAL )
25
26 Q_PROPERTY( bool preferredWidthFromColumns READ preferredWidthFromColumns
27 WRITE setPreferredWidthFromColumns NOTIFY preferredWidthFromColumnsChanged() )
28
30
31 public:
32 QSK_SUBCONTROLS( Cell, Text, Graphic )
33 QSK_STATES( Selected )
34
35 enum SelectionMode
36 {
37 NoSelection,
38 SingleSelection,
39 MultiSelection // not implemented yet
40 };
41 Q_ENUM( SelectionMode )
42
43 QskListView( QQuickItem* parent = nullptr );
44 ~QskListView() override;
45
46 void setPreferredWidthFromColumns( bool );
47 bool preferredWidthFromColumns() const;
48
49 void setSelectionMode( SelectionMode );
50 SelectionMode selectionMode() const;
51
52 void setTextOptions( const QskTextOptions& textOptions );
53 void resetTextOptions();
54 QskTextOptions textOptions() const;
55
56 Q_INVOKABLE int selectedRow() const;
57 QskAspect::States rowStates( int ) const;
58
59 virtual int rowCount() const = 0;
60 virtual int columnCount() const = 0;
61
62 virtual qreal columnWidth( int col ) const = 0;
63 virtual qreal rowHeight() const = 0;
64
65 Q_INVOKABLE virtual QVariant valueAt( int row, int col ) const = 0;
66
67 QRectF focusIndicatorRect() const override;
68
69 public Q_SLOTS:
70 void setSelectedRow( int row );
71
72 Q_SIGNALS:
73 void selectedRowChanged( int row );
74
75 void selectionModeChanged();
76 void preferredWidthFromColumnsChanged();
77 void textOptionsChanged();
78
79 protected:
80 void changeEvent( QEvent* ) override;
81
82 void keyPressEvent( QKeyEvent* ) override;
83 void keyReleaseEvent( QKeyEvent* ) override;
84
85 void mousePressEvent( QMouseEvent* ) override;
86 void mouseReleaseEvent( QMouseEvent* ) override;
87 void mouseUngrabEvent() override;
88
89 void hoverEnterEvent( QHoverEvent* ) override;
90 void hoverMoveEvent( QHoverEvent* ) override;
91 void hoverLeaveEvent( QHoverEvent* ) override;
92
93#ifndef QT_NO_WHEELEVENT
94 virtual QPointF scrollOffset( const QWheelEvent* ) const override;
95#endif
96
97 void updateScrollableSize();
98
99 void componentComplete() override;
100
101 private:
102 class PrivateData;
103 std::unique_ptr< PrivateData > m_data;
104};
105
106#endif
virtual QRectF focusIndicatorRect() const
virtual void changeEvent(QEvent *)
Definition QskItem.cpp:859
void componentComplete() override
Definition QskItem.cpp:272