KCategorizedView
#include <KCategorizedView>

Protected Slots | |
virtual void | rowsInsertedArtifficial (const QModelIndex &parent, int start, int end) |
virtual void | rowsRemoved (const QModelIndex &parent, int start, int end) |
virtual void | slotLayoutChanged () |
Protected Member Functions | |
virtual void | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) override |
virtual void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >()) override |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dragMoveEvent (QDragMoveEvent *event) override |
void | dropEvent (QDropEvent *event) override |
void | leaveEvent (QEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
virtual QModelIndex | moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override |
void | paintEvent (QPaintEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
virtual void | rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override |
virtual void | rowsInserted (const QModelIndex &parent, int start, int end) override |
virtual void | setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags flags) override |
void | startDrag (Qt::DropActions supportedActions) override |
void | updateGeometries () override |
![]() | |
virtual bool | event (QEvent *e) override |
virtual int | horizontalOffset () const const override |
virtual bool | isIndexHidden (const QModelIndex &index) const const override |
QRect | rectForIndex (const QModelIndex &index) const const |
virtual QModelIndexList | selectedIndexes () const const override |
virtual void | selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override |
void | setPositionForIndex (const QPoint &position, const QModelIndex &index) |
virtual void | timerEvent (QTimerEvent *e) override |
virtual int | verticalOffset () const const override |
virtual QStyleOptionViewItem | viewOptions () const const override |
virtual QSize | viewportSizeHint () const const override |
virtual QRegion | visualRegionForSelection (const QItemSelection &selection) const const override |
virtual void | wheelEvent (QWheelEvent *e) override |
![]() | |
virtual void | closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint) |
virtual void | commitData (QWidget *editor) |
QPoint | dirtyRegionOffset () const const |
QAbstractItemView::DropIndicatorPosition | dropIndicatorPosition () const const |
virtual bool | edit (const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event) |
virtual void | editorDestroyed (QObject *editor) |
virtual bool | eventFilter (QObject *object, QEvent *event) override |
void | executeDelayedItemsLayout () |
virtual void | focusInEvent (QFocusEvent *event) override |
virtual bool | focusNextPrevChild (bool next) override |
virtual void | focusOutEvent (QFocusEvent *event) override |
int | horizontalStepsPerItem () const const |
virtual void | inputMethodEvent (QInputMethodEvent *event) override |
virtual void | keyPressEvent (QKeyEvent *event) override |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | scheduleDelayedItemsLayout () |
void | scrollDirtyRegion (int dx, int dy) |
virtual QItemSelectionModel::SelectionFlags | selectionCommand (const QModelIndex &index, const QEvent *event) const const |
void | setDirtyRegion (const QRegion ®ion) |
void | setHorizontalStepsPerItem (int steps) |
void | setState (QAbstractItemView::State state) |
void | setVerticalStepsPerItem (int steps) |
QAbstractItemView::State | state () const const |
int | verticalStepsPerItem () const const |
virtual bool | viewportEvent (QEvent *event) override |
![]() | |
virtual void | contextMenuEvent (QContextMenuEvent *e) override |
virtual void | scrollContentsBy (int dx, int dy) |
void | setViewportMargins (const QMargins &margins) |
void | setViewportMargins (int left, int top, int right, int bottom) |
QMargins | viewportMargins () const const |
![]() | |
virtual void | changeEvent (QEvent *ev) override |
void | initStyleOption (QStyleOptionFrame *option) const const |
![]() | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window, bool initializeWindow, bool destroyOldWindow) |
void | destroy (bool destroyWindow, bool destroySubWindows) |
virtual void | enterEvent (QEvent *event) |
bool | focusNextChild () |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
virtual void | initPainter (QPainter *painter) const const override |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual int | metric (QPaintDevice::PaintDeviceMetric m) const const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
void | updateMicroFocus () |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
Additional Inherited Members | |
![]() | |
enum | Flow |
enum | LayoutMode |
enum | Movement |
enum | ResizeMode |
enum | ViewMode |
![]() | |
enum | CursorAction |
enum | DragDropMode |
enum | DropIndicatorPosition |
enum | EditTrigger |
enum | ScrollHint |
enum | ScrollMode |
enum | SelectionBehavior |
enum | SelectionMode |
enum | State |
![]() | |
enum | SizeAdjustPolicy |
![]() | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
![]() | |
enum | RenderFlag |
![]() | |
enum | PaintDeviceMetric |
![]() | |
QWidget * | createWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags) |
QWidget * | find (WId id) |
QWidget * | keyboardGrabber () |
QWidget * | mouseGrabber () |
void | setTabOrder (QWidget *first, QWidget *second) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
Adjust | |
Batched | |
Fixed | |
Free | |
IconMode | |
LeftToRight | |
ListMode | |
SinglePass | |
Snap | |
Static | |
TopToBottom | |
![]() | |
AboveItem | |
AllEditTriggers | |
AnimatingState | |
AnyKeyPressed | |
BelowItem | |
CollapsingState | |
ContiguousSelection | |
CurrentChanged | |
DoubleClicked | |
DragDrop | |
DraggingState | |
DragOnly | |
DragSelectingState | |
DropOnly | |
EditingState | |
EditKeyPressed | |
typedef | EditTriggers |
EnsureVisible | |
ExpandingState | |
ExtendedSelection | |
InternalMove | |
MoveDown | |
MoveEnd | |
MoveHome | |
MoveLeft | |
MoveNext | |
MovePageDown | |
MovePageUp | |
MovePrevious | |
MoveRight | |
MoveUp | |
MultiSelection | |
NoDragDrop | |
NoEditTriggers | |
NoSelection | |
NoState | |
OnItem | |
OnViewport | |
PositionAtBottom | |
PositionAtCenter | |
PositionAtTop | |
ScrollPerItem | |
ScrollPerPixel | |
SelectColumns | |
SelectedClicked | |
SelectItems | |
SelectRows | |
SingleSelection | |
![]() | |
AdjustIgnored | |
AdjustToContents | |
AdjustToContentsOnFirstShow | |
![]() | |
Box | |
HLine | |
NoFrame | |
Panel | |
Plain | |
Raised | |
Shadow_Mask | |
Shape_Mask | |
StyledPanel | |
Sunken | |
VLine | |
WinPanel | |
![]() | |
DrawChildren | |
DrawWindowBackground | |
IgnoreMask | |
typedef | RenderFlags |
![]() | |
typedef | QObjectList |
![]() | |
PdmDepth | |
PdmDevicePixelRatio | |
PdmDevicePixelRatioScaled | |
PdmDpiX | |
PdmDpiY | |
PdmHeight | |
PdmHeightMM | |
PdmNumColors | |
PdmPhysicalDpiX | |
PdmPhysicalDpiY | |
PdmWidth | |
PdmWidthMM | |
Detailed Description
Item view for listing items in a categorized fashion optionally.
KCategorizedView basically has the same functionality as QListView, only that it also lets you layout items in a way that they are categorized visually.
For it to work you will need to set a KCategorizedSortFilterProxyModel and a KCategoryDrawer with methods setModel() and setCategoryDrawer() respectively. Also, the model will need to be flagged as categorized with KCategorizedSortFilterProxyModel::setCategorizedModel(true).
The way it works (if categorization enabled):
- When sorting, it does more things than QListView does. It will ask the model for the special role CategorySortRole (@see KCategorizedSortFilterProxyModel). This can return a QString or an int in order to tell the view the order of categories. In this sense, for instance, if we are sorting by name ascending, "A" would be before than "B". If we are sorting by size ascending, 512 bytes would be before 1024 bytes. This way categories are also sorted. - When the view has to paint, it will ask the model with the role CategoryDisplayRole (@see KCategorizedSortFilterProxyModel). It will for instance return "F" for "foo.pdf" if we are sorting by name ascending, or "Small" if a certain item has 100 bytes, for example.
For drawing categories, KCategoryDrawer will be used. You can inherit this class to do your own drawing.
- Note
- All examples cited before talk about filesystems and such, but have present that this is a completely generic class, and it can be used for whatever your purpose is. For instance when talking about animals, you can separate them by "Mammal" and "Oviparous". In this very case, for example, the CategorySortRole and the CategoryDisplayRole could be the same ("Mammal" and "Oviparous").
- There is a really performance boost if CategorySortRole returns an int instead of a QString. Have present that this role is asked (n * log n) times when sorting and compared. Comparing ints is always faster than comparing strings, without mattering how fast the string comparison is. Consider thinking of a way of returning ints instead of QStrings if your model can contain a high number of items.
- Warning
- Note that for really drawing items in blocks you will need some things to be done:
- The model set to this view has to be (or inherit if you want to do special stuff in it) KCategorizedSortFilterProxyModel.
- This model needs to be set setCategorizedModel to true.
- Set a category drawer by calling setCategoryDrawer.
Definition at line 68 of file kcategorizedview.h.
Member Function Documentation
◆ alternatingBlockColors()
bool KCategorizedView::alternatingBlockColors | ( | ) | const |
- Returns
- Whether blocks should be drawn with alternating colors.
- Since
- 4.4
◆ block() [1/2]
QModelIndexList KCategorizedView::block | ( | const QModelIndex & | representative | ) |
- Returns
- Block of indexes that are represented by
representative
.
- Since
- 4.5
Definition at line 683 of file kcategorizedview.cpp.
◆ block() [2/2]
QModelIndexList KCategorizedView::block | ( | const QString & | category | ) |
- Returns
- Block of indexes that are into
category
.
- Since
- 4.5
Definition at line 665 of file kcategorizedview.cpp.
◆ categoryDrawer()
KCategoryDrawer * KCategorizedView::categoryDrawer | ( | ) | const |
Returns the current category drawer.
Definition at line 610 of file kcategorizedview.cpp.
◆ categorySpacing()
int KCategorizedView::categorySpacing | ( | ) | const |
- Returns
- Category spacing. The spacing between categories.
- Since
- 4.4
◆ collapsibleBlocks()
bool KCategorizedView::collapsibleBlocks | ( | ) | const |
- Returns
- Whether blocks can be collapsed or not.
- Since
- 4.4
◆ currentChanged()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1412 of file kcategorizedview.cpp.
◆ dataChanged()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1417 of file kcategorizedview.cpp.
◆ dragEnterEvent()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QAbstractItemView.
Definition at line 1063 of file kcategorizedview.cpp.
◆ dragLeaveEvent()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1068 of file kcategorizedview.cpp.
◆ dragMoveEvent()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1057 of file kcategorizedview.cpp.
◆ dropEvent()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1073 of file kcategorizedview.cpp.
◆ indexAt()
|
overridevirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 688 of file kcategorizedview.cpp.
◆ leaveEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QWidget.
Definition at line 1035 of file kcategorizedview.cpp.
◆ mouseMoveEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QListView.
Definition at line 919 of file kcategorizedview.cpp.
◆ mousePressEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QAbstractItemView.
Definition at line 978 of file kcategorizedview.cpp.
◆ mouseReleaseEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QListView.
Definition at line 1008 of file kcategorizedview.cpp.
◆ moveCursor()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1080 of file kcategorizedview.cpp.
◆ paintEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QListView.
Definition at line 761 of file kcategorizedview.cpp.
◆ reset()
|
overridevirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QAbstractItemView.
Definition at line 755 of file kcategorizedview.cpp.
◆ resizeEvent()
|
overrideprotectedvirtual |
Reimplemented from QWidget.
Reimplemented from QListView.
Definition at line 870 of file kcategorizedview.cpp.
◆ rowsAboutToBeRemoved()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1193 of file kcategorizedview.cpp.
◆ rowsInserted()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1448 of file kcategorizedview.cpp.
◆ rowsInsertedArtifficial
|
protectedvirtualslot |
- Deprecated:
- Since 4.4.
Definition at line 1461 of file kcategorizedview.cpp.
◆ rowsRemoved
|
protectedvirtualslot |
- Deprecated:
- Since 4.4.
Definition at line 1470 of file kcategorizedview.cpp.
◆ setAlternatingBlockColors()
void KCategorizedView::setAlternatingBlockColors | ( | bool | enable | ) |
Sets whether blocks should be drawn with alternating colors.
- Since
- 4.4
Definition at line 650 of file kcategorizedview.cpp.
◆ setCategoryDrawer()
void KCategorizedView::setCategoryDrawer | ( | KCategoryDrawer * | categoryDrawer | ) |
The category drawer that will be used for drawing categories.
Definition at line 615 of file kcategorizedview.cpp.
◆ setCategorySpacing()
void KCategorizedView::setCategorySpacing | ( | int | categorySpacing | ) |
Stablishes the category spacing.
This is the spacing between categories.
- Since
- 4.4
Definition at line 631 of file kcategorizedview.cpp.
◆ setCollapsibleBlocks()
void KCategorizedView::setCollapsibleBlocks | ( | bool | enable | ) |
Sets whether blocks can be collapsed or not.
- Since
- 4.4
Definition at line 660 of file kcategorizedview.cpp.
◆ setGridSize()
void KCategorizedView::setGridSize | ( | const QSize & | size | ) |
Calls to setGridSizeOwn().
Definition at line 519 of file kcategorizedview.cpp.
◆ setGridSizeOwn()
void KCategorizedView::setGridSizeOwn | ( | const QSize & | size | ) |
- Warning
- note that setGridSize is not virtual in the base class (QListView), so if you are calling to this method, make sure you have a KCategorizedView pointer around. This means that something like: lv->setGridSize(mySize);
will not call to the expected setGridSize method. Instead do something like this:
- Note
- this method will call to QListView::setGridSize among other operations.
- Since
- 4.4
Definition at line 524 of file kcategorizedview.cpp.
◆ setModel()
|
overridevirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QAbstractItemView.
Definition at line 493 of file kcategorizedview.cpp.
◆ setSelection()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 876 of file kcategorizedview.cpp.
◆ slotLayoutChanged
|
protectedvirtualslot |
Reposition items as needed.
Definition at line 1478 of file kcategorizedview.cpp.
◆ startDrag()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1052 of file kcategorizedview.cpp.
◆ updateGeometries()
|
overrideprotectedvirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 1313 of file kcategorizedview.cpp.
◆ visualRect()
|
overridevirtual |
Reimplemented from QAbstractItemView.
Reimplemented from QListView.
Definition at line 530 of file kcategorizedview.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Nov 28 2023 04:11:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.