|
FougTools
0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
|
Provides buttons integrated to items displayed by QAbstractItemView. More...
#include <item_view_buttons.h>
Public Types | |
| enum | ItemSide { ItemLeftSide, ItemRightSide } |
| enum | DisplayMode { DisplayOnDetection = 0x01, DisplayPermanent = 0x02, DisplayWhenItemSelected = 0x04 } |
| typedef QFlags< DisplayMode > | DisplayModes |
Public Slots | |
| void | reset () |
Signals | |
| void | buttonClicked (int btnId, const QModelIndex &index) |
| This signal is emitted when a button previously added with addButton() is clicked (i.e. pressed down then released while the mouse cursor is inside the button) More... | |
Public Member Functions | |
| ItemViewButtons (QAbstractItemView *view, QObject *parent=NULL) | |
| ~ItemViewButtons () | |
| QAbstractItemView * | itemView () const |
| bool | eventFilter (QObject *object, QEvent *event) Q_DECL_OVERRIDE |
| void | paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| void | addButton (int btnId, const QIcon &icon=QIcon(), const QString &toolTip=QString()) |
| Add a button to be furthered configured with setButtonXxx() functions. More... | |
| void | copyButtonProperties (int srcBtnId, int dstBtnId) |
| Copy all properties of a button into another. More... | |
| int | buttonDetectionMatchRole (int btnId) const |
| The role used when matching item data for button detection. More... | |
| QVariant | buttonDetectionMatchData (int btnId) const |
| The data to be matched for button detection. More... | |
| void | setButtonDetection (int btnId, int matchRole, const QVariant &matchData) |
| ItemViewButtons::setButtonDetection. More... | |
| int | buttonDisplayColumn (int btnId) const |
| Index of the view column where the button is displayed (when detected) More... | |
| void | setButtonDisplayColumn (int btnId, int col=-1) |
| int | buttonItemSide (int btnId) const |
| Side in the item's cell where the button is displayed. More... | |
| void | setButtonItemSide (int btnId, ItemSide side) |
| DisplayModes | buttonDisplayModes (int btnId) const |
| Display modes of the button. More... | |
| void | setButtonDisplayModes (int btnId, DisplayModes modes) |
| QIcon | buttonIcon (int btnId) const |
| Icon of the button. More... | |
| void | setButtonIcon (int btnId, const QIcon &icon) |
| QSize | buttonIconSize (int btnId) const |
| Icon size of the button. More... | |
| void | setButtonIconSize (int btnId, const QSize &size) |
| QString | buttonToolTip (int btnId) const |
| Tool-tip of the button. More... | |
| void | setButtonToolTip (int btnId, const QString &toolTip) |
| void | installDefaultItemDelegate () |
| QStyledItemDelegate * | createProxyItemDelegate (QStyledItemDelegate *sourceDelegate, QObject *parent=NULL) const |
Protected Member Functions | |
| virtual int | buttonAtModelIndex (const QModelIndex &index) const |
Provides buttons integrated to items displayed by QAbstractItemView.
qtgui::ItemViewButtons allows to add buttons inside any QAbstractItemView without subclassing the item-view class.
It only requires that its paint() method is called whenever any view item has to be drawn. If you have a custom delegate (eg. a subclass of QStyledItemDelegate) then just call at some point qtgui::ItemViewButtons::paint() inside the delegate's paint() method :
If you do not want to modify your delegate class then createProxyItemDelegate() might be the right option : this will create a new delegate around yours with the paint() method correctly called.
If the item-view does not use any delegate then just call installDefaultItemDelegate()
ItemViewButtons notifies any button click with signal buttonClicked()
| typedef QFlags<DisplayMode> qtgui::ItemViewButtons::DisplayModes |
| qtgui::ItemViewButtons::ItemViewButtons | ( | QAbstractItemView * | view, |
| QObject * | parent = NULL |
||
| ) |
| qtgui::ItemViewButtons::~ItemViewButtons | ( | ) |
| void qtgui::ItemViewButtons::addButton | ( | int | btnId, |
| const QIcon & | icon = QIcon(), |
||
| const QString & | toolTip = QString() |
||
| ) |
Add a button to be furthered configured with setButtonXxx() functions.
| btnId | Index of the button (used later to reference the button) |
| icon | Icon of the button (ItemViewButtons supports QIcon::Active which can be used to display an highlighted pixmap when the mouse is hovering the button) |
| toolTip | Tool-tip to be displayed when the mouse stays over the button |
Does nothing if button index btnId is already used by some other button.
|
protectedvirtual |
|
signal |
This signal is emitted when a button previously added with addButton() is clicked (i.e. pressed down then released while the mouse cursor is inside the button)
| btnId | Identifier of the button clicked (this is the id that was passed to addButton()) |
| index | Index of the item model where the button click occured |
| QVariant qtgui::ItemViewButtons::buttonDetectionMatchData | ( | int | btnId | ) | const |
The data to be matched for button detection.
| btnId | Index of the button |
| int qtgui::ItemViewButtons::buttonDetectionMatchRole | ( | int | btnId | ) | const |
The role used when matching item data for button detection.
| btnId | Index of the button |
| int qtgui::ItemViewButtons::buttonDisplayColumn | ( | int | btnId | ) | const |
Index of the view column where the button is displayed (when detected)
| btnId | Index of the button |
| ItemViewButtons::DisplayModes qtgui::ItemViewButtons::buttonDisplayModes | ( | int | btnId | ) | const |
Display modes of the button.
| btnId | Index of the button |
| QIcon qtgui::ItemViewButtons::buttonIcon | ( | int | btnId | ) | const |
Icon of the button.
| btnId | Index of the button |
| QSize qtgui::ItemViewButtons::buttonIconSize | ( | int | btnId | ) | const |
Icon size of the button.
| btnId | Index of the button |
| int qtgui::ItemViewButtons::buttonItemSide | ( | int | btnId | ) | const |
Side in the item's cell where the button is displayed.
| btnId | Index of the button |
| QString qtgui::ItemViewButtons::buttonToolTip | ( | int | btnId | ) | const |
Tool-tip of the button.
| btnId | Index of the button |
| void qtgui::ItemViewButtons::copyButtonProperties | ( | int | srcBtnId, |
| int | dstBtnId | ||
| ) |
Copy all properties of a button into another.
| srcBtnId | Index of the source button |
| dstBtnId | Index of the destination button |
| QStyledItemDelegate * qtgui::ItemViewButtons::createProxyItemDelegate | ( | QStyledItemDelegate * | sourceDelegate, |
| QObject * | parent = NULL |
||
| ) | const |
Create a proxy delegate around sourceDelegate to be further installed with QAbstractItemView::setItemDelegate()
This is useful when you have a delegate for an item view but for some reason don't want to modify it to integrate with ItemViewButtons
| bool qtgui::ItemViewButtons::eventFilter | ( | QObject * | object, |
| QEvent * | event | ||
| ) |
| void qtgui::ItemViewButtons::installDefaultItemDelegate | ( | ) |
Install a delegate for the attached view item, allowing the button mechanism to work
| QAbstractItemView * qtgui::ItemViewButtons::itemView | ( | ) | const |
| void qtgui::ItemViewButtons::paint | ( | QPainter * | painter, |
| const QStyleOptionViewItem & | option, | ||
| const QModelIndex & | index | ||
| ) | const |
|
slot |
| void qtgui::ItemViewButtons::setButtonDetection | ( | int | btnId, |
| int | matchRole, | ||
| const QVariant & | matchData | ||
| ) |
ItemViewButtons::setButtonDetection.
| btnId | Index of the button |
| matchRole | The role used when matching item data for button detection. In case the button has to be displayed no matter the item, then set matchRole to -1 |
| matchData | The data to be matched for button detection |
| void qtgui::ItemViewButtons::setButtonDisplayColumn | ( | int | btnId, |
| int | col = -1 |
||
| ) |
| void qtgui::ItemViewButtons::setButtonDisplayModes | ( | int | btnId, |
| DisplayModes | modes | ||
| ) |
| void qtgui::ItemViewButtons::setButtonIcon | ( | int | btnId, |
| const QIcon & | icon | ||
| ) |
| void qtgui::ItemViewButtons::setButtonIconSize | ( | int | btnId, |
| const QSize & | size | ||
| ) |
| void qtgui::ItemViewButtons::setButtonItemSide | ( | int | btnId, |
| ItemSide | side | ||
| ) |
| void qtgui::ItemViewButtons::setButtonToolTip | ( | int | btnId, |
| const QString & | toolTip | ||
| ) |
1.8.8