Mouse Over Interval List to Highlight

.. same as hovering over the interval in the ride view
   hovering over it in the tree list now triggers the
   event.
This commit is contained in:
Mark Liversedge
2014-03-18 16:21:49 +00:00
parent 41561a2403
commit ad4c2a8c6a
3 changed files with 22 additions and 3 deletions

View File

@@ -18,6 +18,8 @@
#include "IntervalTreeView.h"
#include "IntervalItem.h"
#include "RideItem.h"
#include "RideFile.h"
#include "Context.h"
@@ -29,7 +31,22 @@ IntervalTreeView::IntervalTreeView(Context *context) : context(context)
#ifdef Q_OS_MAC
setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
setStyleSheet("QTreeView::item:hover { background: lightGray; }");
setMouseTracking(true);
invisibleRootItem()->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(this, SIGNAL(itemEntered(QTreeWidgetItem*,int)), this, SLOT(mouseHover(QTreeWidgetItem*,int)));
}
void
IntervalTreeView::mouseHover(QTreeWidgetItem *item, int column)
{
int index = invisibleRootItem()->indexOfChild(item);
if (index >=0 && context->rideItem() && context->rideItem()->ride() &&
context->rideItem()->ride()->intervals().count() > index) {
context->notifyIntervalHover(context->rideItem()->ride()->intervals()[index]);
}
}
void