Implement the context menu a different way

It seems that this is the way this is supposed to be done - instead of
manually looking at what kind of click we get, Qt decides when to create
a context menu for us - this way things like the Windows Menu button
will work automagically.

As an example I also implemented the "remove dive from trip"
functionality, which exposes some other bugs (like the fact that the
dive that isn't part of a trip ends up being sorted at the very end of
the dive list).

This commit contains a "testSlot" implementation to remind me how to
figure out which dive / trip we are on.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-06-06 09:06:42 +09:00
parent 235833b93e
commit cd7488491f
2 changed files with 43 additions and 9 deletions

View file

@ -28,21 +28,25 @@ public:
bool eventFilter(QObject* , QEvent* );
void unselectDives();
void selectDive(struct dive *, bool scrollto = false);
void mousePressEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
public slots:
void toggleColumnVisibilityByIndex();
void reloadHeaderActions();
void headerClicked(int);
void showSearchEdit();
void removeFromTrip();
void testSlot();
Q_SIGNALS:
void currentDiveChanged(int divenr);
private:
bool mouseClickSelection;
int currentHeaderClicked;
DiveTripModel::Layout currentLayout;
QLineEdit *searchBox;
QModelIndex contextMenuIndex;
};
#endif // DIVELISTVIEW_H