mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix mouse interaction with the Location List
paint methods should be used only to paint, not to trigger other widget behaviours ( we could got ourselves into a bad recursion bug from that ). Also, enabled mouse tracking to correctly track the mouse movement inside the widget. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
56240cff5b
commit
0a473b3a2a
4 changed files with 21 additions and 12 deletions
|
@ -373,6 +373,15 @@ void GlobeGPS::resizeEvent(QResizeEvent *event)
|
|||
messageWidget->setGeometry(5, 5, size - 10, 0);
|
||||
messageWidget->setMaximumHeight(500);
|
||||
}
|
||||
|
||||
void GlobeGPS::centerOnIndex(const QModelIndex& idx)
|
||||
{
|
||||
struct dive_site *ds = get_dive_site_by_uuid(idx.model()->index(idx.row(), 0).data().toInt());
|
||||
if (!ds || !dive_site_has_gps_location(ds))
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
|
||||
else
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(ds);
|
||||
}
|
||||
#else
|
||||
|
||||
GlobeGPS::GlobeGPS(QWidget *parent)
|
||||
|
@ -398,4 +407,7 @@ void GlobeGPS::endGetDiveCoordinates()
|
|||
void GlobeGPS::reload()
|
||||
{
|
||||
}
|
||||
void GlobeGPS::centerOnIndex(const QModelIndex& idx)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -52,6 +52,7 @@ slots:
|
|||
void prepareForGetDiveCoordinates();
|
||||
void endGetDiveCoordinates();
|
||||
void centerOnDiveSite(struct dive_site *ds);
|
||||
void centerOnIndex(const QModelIndex& idx);
|
||||
};
|
||||
|
||||
#else // NO_MARBLE
|
||||
|
@ -65,6 +66,7 @@ public:
|
|||
void reload();
|
||||
void repopulateLabels();
|
||||
void centerOnDiveSite(uint32_t uuid);
|
||||
void centerOnIndex(const QModelIndex& idx);
|
||||
void centerOnCurrentDive();
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
public
|
||||
|
|
|
@ -67,7 +67,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
completer->setCompletionColumn(LocationInformationModel::NAME);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completerListview->setItemDelegate(new LocationFilterDelegate());
|
||||
|
||||
completerListview->setMouseTracking(true);
|
||||
locationManagementEditHelper = new LocationManagementEditHelper();
|
||||
connect(locationManagementEditHelper, &LocationManagementEditHelper::setLineEditText,
|
||||
ui.location, &QLineEdit::setText);
|
||||
|
@ -453,6 +453,12 @@ void MainTab::showLocation()
|
|||
|
||||
void MainTab::updateDiveInfo(bool clear)
|
||||
{
|
||||
// I don't like this code here - but globe() wasn't initialized on the constructor.
|
||||
{
|
||||
QListView *completerListview = qobject_cast<QListView*>(ui.location->completer()->popup());
|
||||
connect(completerListview, SIGNAL(entered(QModelIndex)), MainWindow::instance()->globe(), SLOT(centerOnIndex(QModelIndex)), Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
EditMode rememberEM = editMode;
|
||||
// don't execute this while adding / planning a dive
|
||||
if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE || MainWindow::instance()->graphics()->isPlanner())
|
||||
|
|
|
@ -540,17 +540,6 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||
free( (void*) gpsCoords);
|
||||
}
|
||||
|
||||
#ifndef NO_MARBLE
|
||||
if ((option.state & QStyle::State_HasFocus)) {
|
||||
// show either the GPS location of the currently focused dive site or
|
||||
// the gps data for the displayed dive site (even if that has no GPS -> zoom out)
|
||||
if (dive_site_has_gps_location(ds))
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(ds);
|
||||
else
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dive_site_has_gps_location(ds) && dive_site_has_gps_location(&displayed_dive_site)) {
|
||||
// so we are showing a completion and both the current dive site and the completion
|
||||
// have a GPS fix... so let's show the distance
|
||||
|
|
Loading…
Add table
Reference in a new issue