summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
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 /qt-ui/mainwindow.cpp
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>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp42
1 files changed, 6 insertions, 36 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;