KCategoryDrawer Class
The category drawing is performed by this class. More...
Header: | #include <KCategoryDrawer> |
CMake: | find_package(KF6 REQUIRED COMPONENTS ItemViews) target_link_libraries(mytarget PRIVATE KF6::ItemViews) |
Inherits: | QObject |
Public Functions
(since 5.0) | KCategoryDrawer(KCategorizedView *view) |
virtual int | categoryHeight(const QModelIndex &index, const QStyleOption &option) const |
virtual void | drawCategory(const QModelIndex &index, int sortRole, const QStyleOption &option, QPainter *painter) const |
(since 4.4) virtual int | leftMargin() const |
(since 4.4) virtual int | rightMargin() const |
KCategorizedView * | view() const |
Signals
void | actionRequested(int action, const QModelIndex &index) |
void | collapseOrExpandClicked(const QModelIndex &index) |
Protected Functions
virtual void | mouseButtonDoubleClicked(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event) |
virtual void | mouseButtonPressed(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event) |
virtual void | mouseButtonReleased(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event) |
virtual void | mouseLeft(const QModelIndex &index, const QRect &blockRect) |
virtual void | mouseMoved(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event) |
Detailed Description
It also gives information about the category height and margins.
Member Function Documentation
[since 5.0]
KCategoryDrawer::KCategoryDrawer(KCategorizedView *view)
Construct a category drawer for a given view
This function was introduced in 5.0.
[signal]
void KCategoryDrawer::actionRequested(int action, const QModelIndex &index)
Emit this signal on your subclass implementation to notify that something happened. Usually this will be triggered when you have received an event, and its position matched some "hot spot".
You give this action the integer you want, and having connected this signal to your code, the connected slot can perform the needed changes (view, model, selection model, delegate...)
[virtual]
int KCategoryDrawer::categoryHeight(const QModelIndex &index, const QStyleOption &option) const
Returns the category height for the category represented by index index with style options option.
[signal]
void KCategoryDrawer::collapseOrExpandClicked(const QModelIndex &index)
This signal becomes emitted when collapse or expand has been clicked.
[virtual]
void KCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, const QStyleOption &option, QPainter *painter) const
This method purpose is to draw a category represented by the given index with the given sortRole sorting role
Note: This method will be called one time per category, always with the first element in that category
[virtual, since 4.4]
int KCategoryDrawer::leftMargin() const
Note: 0 by default
This function was introduced in 4.4.
[virtual protected]
void KCategoryDrawer::mouseButtonDoubleClicked(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
Method called when the mouse button has been double clicked.
index The representative index of the block of items.
blockRect The rect occupied by the block of items.
event The mouse event.
Warning: You explicitly have to determine whether the event has been accepted or not. You have to call event->accept() or event->ignore() at all possible case branches in your code.
[virtual protected]
void KCategoryDrawer::mouseButtonPressed(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
Method called when the mouse button has been pressed.
index The representative index of the block of items.
blockRect The rect occupied by the block of items.
event The mouse event.
Warning: You explicitly have to determine whether the event has been accepted or not. You have to call event->accept() or event->ignore() at all possible case branches in your code.
[virtual protected]
void KCategoryDrawer::mouseButtonReleased(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
Method called when the mouse button has been released.
index The representative index of the block of items.
blockRect The rect occupied by the block of items.
event The mouse event.
Warning: You explicitly have to determine whether the event has been accepted or not. You have to call event->accept() or event->ignore() at all possible case branches in your code.
[virtual protected]
void KCategoryDrawer::mouseLeft(const QModelIndex &index, const QRect &blockRect)
Method called when the mouse button has left this block.
index The representative index of the block of items.
blockRect The rect occupied by the block of items.
[virtual protected]
void KCategoryDrawer::mouseMoved(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
Method called when the mouse has been moved.
index The representative index of the block of items.
blockRect The rect occupied by the block of items.
event The mouse event.
[virtual, since 4.4]
int KCategoryDrawer::rightMargin() const
Note: 0 by default
This function was introduced in 4.4.
KCategorizedView *KCategoryDrawer::view() const
Returns the view this category drawer is associated with.