Definition at line 24 of file ItemViewOverlayButtons.h.
|
using | FnGetActions = std::function< QList< QAction * >(const QModelIndex &, bool)> |
|
|
bool | eventFilter (QObject *obj, QEvent *event) override |
|
◆ FnGetActions
◆ ItemViewOverlayButtons()
ItemViewOverlayButtons::ItemViewOverlayButtons |
( |
QObject * |
parent | ) |
|
|
private |
◆ eventFilter()
bool ItemViewOverlayButtons::eventFilter |
( |
QObject * |
obj, |
|
|
QEvent * |
event |
|
) |
| |
|
overrideprotected |
Definition at line 180 of file ItemViewOverlayButtons.cpp.
185 if (event->type() == QEvent::KeyPress) {
186 auto* keyEvent =
dynamic_cast<QKeyEvent*
>(event);
187 if (keyEvent->key() == Qt::Key_F2) {
188 QModelIndex ci =
m_view->currentIndex();
189 if (ci.isValid() && ci.flags().testFlag(Qt::ItemIsEditable))
190 m_view->setIndexWidget(ci,
nullptr);
193 return QObject::eventFilter(obj, event);
References m_view.
◆ install()
void ItemViewOverlayButtons::install |
( |
QAbstractItemView * |
view, |
|
|
FnGetActions |
fnGetActions |
|
) |
| |
|
static |
◆ installOverlay()
void ItemViewOverlayButtons::installOverlay |
( |
const QModelIndex & |
index | ) |
|
|
private |
Definition at line 229 of file ItemViewOverlayButtons.cpp.
231 const auto permanentActions =
m_getActions(index,
false);
234 if (permanentActions.isEmpty() && hoverActions.isEmpty())
237 auto* w =
new ItemViewOverlayWidget(
m_view, index);
239 const auto setAlignment = [&](
const QList<QAction*> actions) {
240 w->setHorizontalAlignment(Qt::AlignRight);
241 if (actions.first() ==
nullptr && actions.last() ==
nullptr)
242 w->setHorizontalAlignment(Qt::AlignCenter);
243 else if (actions.first() !=
nullptr && actions.last() ==
nullptr)
244 w->setHorizontalAlignment(Qt::AlignLeft);
247 if (!permanentActions.isEmpty()) {
248 setAlignment(permanentActions);
249 w->addActions(permanentActions);
251 }
else if (!hoverActions.isEmpty()) {
252 setAlignment(hoverActions);
253 w->addActions(hoverActions);
258 m_view->setIndexWidget(index, w);
References m_getActions, and m_view.
Referenced by updateRecursive().
◆ update()
void ItemViewOverlayButtons::update |
( |
| ) |
|
|
private |
◆ updateRecursive()
void ItemViewOverlayButtons::updateRecursive |
( |
const QModelIndex & |
index | ) |
|
|
private |
Definition at line 201 of file ItemViewOverlayButtons.cpp.
203 const auto hoverIfNecessary = [&](QModelIndex index) {
204 QPoint viewPortCoordinatesOfMouse =
m_view->mapFromGlobal(QCursor::pos());
205 if (
m_view->indexAt(viewPortCoordinatesOfMouse) == index)
206 if (
auto* w =
dynamic_cast<ItemViewOverlayWidget*
>(
m_view->indexWidget(index)))
210 if (
m_view->indexWidget(index) ==
nullptr)
212 hoverIfNecessary(index);
214 auto* m =
m_view->model();
215 for (
int childRow = 0; childRow < m->rowCount(index); childRow++)
References installOverlay(), and m_view.
Referenced by update().
◆ m_getActions
◆ m_view
QAbstractItemView* ItemViewOverlayButtons::m_view |
|
private |
The documentation for this class was generated from the following files: