aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-08-25 15:46:08 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-25 13:57:28 -0700
commit2fe1dfe83ad2c9f55010bef5bad48c4fd4b04bea (patch)
tree13343656bbb3414d1a2a6a538be531efd26f510e
parent537b42e3f7922e41cf3851b297033cc1f07fb922 (diff)
downloadsubsurface-2fe1dfe83ad2c9f55010bef5bad48c4fd4b04bea.tar.gz
Remove a lot of non-necessary boilerplate code.
We used to have a very sad way of controlling the statistics, now we will create the model when there's a need for it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/mainwindow.cpp42
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/statistics/statisticswidget.cpp5
-rw-r--r--qt-ui/statistics/statisticswidget.h12
4 files changed, 23 insertions, 38 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index af8bc705c..d253d5e05 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -43,6 +43,7 @@
#include "updatemanager.h"
#include "planner.h"
#include "configuredivecomputerdialog.h"
+#include "statistics/statisticswidget.h"
#ifndef NO_PRINTING
#include <QPrintDialog>
#include "printdialog.h"
@@ -61,8 +62,6 @@ MainWindow::MainWindow() : QMainWindow(),
actionNextDive(0),
actionPreviousDive(0),
helpView(0),
- yearlyStats(0),
- yearlyStatsModel(0),
state(VIEWALL),
updateManager(0),
survey(0)
@@ -174,12 +173,6 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
ui.ListWidget->setEnabled(true);
ui.ListWidget->setFocus();
WSInfoModel::instance()->updateInfo();
- // refresh the yearly stats if the window has an instance
- if (yearlyStats) {
- delete yearlyStatsModel;
- yearlyStatsModel = new YearlyStatisticsModel();
- yearlyStats->setModel(yearlyStatsModel);
- }
if (amount_selected == 0)
cleanUpEmpty();
}
@@ -551,28 +544,11 @@ void MainWindow::on_actionAutoGroup_triggered()
void MainWindow::on_actionYearlyStatistics_triggered()
{
- // create the widget only once
- if (!yearlyStats) {
- yearlyStats = new QTreeView();
- yearlyStats->setWindowModality(Qt::NonModal);
- yearlyStats->setMinimumWidth(600);
- yearlyStats->setWindowTitle(tr("Yearly statistics"));
- yearlyStats->setWindowIcon(QIcon(":subsurface-icon"));
- QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), yearlyStats, 0, 0, Qt::WidgetShortcut);
- connect(closeKey, SIGNAL(activated()), yearlyStats, SLOT(close()));
- closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), yearlyStats, 0, 0, Qt::WidgetShortcut);
- connect(closeKey, SIGNAL(activated()), yearlyStats, SLOT(close()));
- QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), yearlyStats, 0, 0, Qt::WidgetShortcut);
- connect(quitKey, SIGNAL(activated()), this, SLOT(close()));
- }
- /* problem here is that without more MainWindow variables or a separate YearlyStatistics
- * class the user needs to close the window/widget and re-open it for it to update.
- */
- delete yearlyStatsModel;
- yearlyStatsModel = new YearlyStatisticsModel();
- yearlyStats->setModel(yearlyStatsModel);
- yearlyStats->raise();
- yearlyStats->show();
+ QDialog d;
+ YearlyStatisticsWidget *s = new YearlyStatisticsWidget();
+ QVBoxLayout *l = new QVBoxLayout(&d);
+ l->addWidget(s);
+ d.exec();
}
#define BEHAVIOR QList<int>()
@@ -910,12 +886,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
}
#endif
- if (yearlyStats && yearlyStats->isVisible()) {
- yearlyStats->close();
- yearlyStats->deleteLater();
- yearlyStatsModel->deleteLater();
- }
-
if (unsaved_changes() && (askSaveChanges() == false)) {
event->ignore();
return;
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 100eac6cb..1ae717a34 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -169,8 +169,6 @@ private:
QAction *actionNextDive;
QAction *actionPreviousDive;
UserManual *helpView;
- QTreeView *yearlyStats;
- QAbstractItemModel *yearlyStatsModel;
CurrentState state;
QString filter();
static MainWindow *m_Instance;
diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp
index e69de29bb..71ac7843e 100644
--- a/qt-ui/statistics/statisticswidget.cpp
+++ b/qt-ui/statistics/statisticswidget.cpp
@@ -0,0 +1,5 @@
+#include "statisticswidget.h"
+
+YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent): QGraphicsView(parent)
+{
+}
diff --git a/qt-ui/statistics/statisticswidget.h b/qt-ui/statistics/statisticswidget.h
index e69de29bb..b01f2ee17 100644
--- a/qt-ui/statistics/statisticswidget.h
+++ b/qt-ui/statistics/statisticswidget.h
@@ -0,0 +1,12 @@
+#ifndef YEARLYSTATISTICSWIDGET_H
+#define YEARLYSTATISTICSWIDGET_H
+
+#include <QGraphicsView>
+
+class YearlyStatisticsWidget : public QGraphicsView {
+ Q_OBJECT
+public:
+ YearlyStatisticsWidget(QWidget *parent = 0);
+};
+
+#endif \ No newline at end of file