[PATCH 4/4] Profile: prevent a bug when switching views

Lubomir I. Ivanov neolit123 at gmail.com
Fri Jul 5 05:33:51 PDT 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

While in zoomed mode and when resizing the splitters or
switching views the profile tooltip can end up being at the
wrong location and also the zoom state becomes corrupt,
so perhaps the entire transformation needs to be reset.
To prevent the bug we listen for relevent to the profile
splitter resize event, view changes and clear()/plot() the
entire profile graphics.

This is an slow/expensive solution and perhaps there are
cheaper alternatives e.g. updating only the scene rectangle
and tooltip, somehow.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qt-ui/mainwindow.cpp      | 10 +++++++++-
 qt-ui/mainwindow.h        |  1 +
 qt-ui/profilegraphics.cpp |  1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 5bf190e..c0cdc9e 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -81,7 +81,7 @@ void MainWindow::current_dive_changed(int divenr)
 
 void MainWindow::redrawProfile()
 {
-	ui->ProfileWidget->plot(get_dive(selected_dive));
+	ui->ProfileWidget->refresh();
 }
 
 void MainWindow::on_actionNew_triggered()
@@ -316,10 +316,16 @@ void MainWindow::on_actionYearlyStatistics_triggered()
 	view->show();
 }
 
+void MainWindow::on_mainSplitter_splitterMoved(int pos, int idx)
+{
+	redrawProfile();
+}
+
 void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx)
 {
 	/* always update the floating plus sign icons in the equipment tab */
 	ui->InfoWidget->equipmentPlusUpdate();
+	redrawProfile();
 }
 
 /**
@@ -345,6 +351,7 @@ void MainWindow::on_actionViewProfile_triggered()
 {
 	ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
 	ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
+	redrawProfile();
 }
 
 void MainWindow::on_actionViewInfo_triggered()
@@ -370,6 +377,7 @@ void MainWindow::on_actionViewAll_triggered()
 
 	// half and half?
 	ui->mainSplitter->setSizes( QList<int>() << 1 << 1);
+	redrawProfile();
 }
 
 void MainWindow::on_actionPreviousDC_triggered()
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index a9f2eca..2009740 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -92,6 +92,7 @@ private slots:
 	void on_actionDivePlanner_triggered();
 
 	/* monitor resize of the info-profile splitter */
+	void on_mainSplitter_splitterMoved(int pos, int idx);
 	void on_infoProfileSplitter_splitterMoved(int pos, int idx);
 
 	void current_dive_changed(int divenr);
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 43562f5..264e02d 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -185,6 +185,7 @@ void ProfileGraphicsView::clear()
 
 void ProfileGraphicsView::refresh()
 {
+	clear();
 	plot(current_dive, TRUE);
 }
 
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list