mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
537b42e3f7
commit
2fe1dfe83a
4 changed files with 23 additions and 38 deletions
|
@ -43,6 +43,7 @@
|
||||||
#include "updatemanager.h"
|
#include "updatemanager.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "configuredivecomputerdialog.h"
|
#include "configuredivecomputerdialog.h"
|
||||||
|
#include "statistics/statisticswidget.h"
|
||||||
#ifndef NO_PRINTING
|
#ifndef NO_PRINTING
|
||||||
#include <QPrintDialog>
|
#include <QPrintDialog>
|
||||||
#include "printdialog.h"
|
#include "printdialog.h"
|
||||||
|
@ -61,8 +62,6 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
actionNextDive(0),
|
actionNextDive(0),
|
||||||
actionPreviousDive(0),
|
actionPreviousDive(0),
|
||||||
helpView(0),
|
helpView(0),
|
||||||
yearlyStats(0),
|
|
||||||
yearlyStatsModel(0),
|
|
||||||
state(VIEWALL),
|
state(VIEWALL),
|
||||||
updateManager(0),
|
updateManager(0),
|
||||||
survey(0)
|
survey(0)
|
||||||
|
@ -174,12 +173,6 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
|
||||||
ui.ListWidget->setEnabled(true);
|
ui.ListWidget->setEnabled(true);
|
||||||
ui.ListWidget->setFocus();
|
ui.ListWidget->setFocus();
|
||||||
WSInfoModel::instance()->updateInfo();
|
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)
|
if (amount_selected == 0)
|
||||||
cleanUpEmpty();
|
cleanUpEmpty();
|
||||||
}
|
}
|
||||||
|
@ -551,28 +544,11 @@ void MainWindow::on_actionAutoGroup_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionYearlyStatistics_triggered()
|
void MainWindow::on_actionYearlyStatistics_triggered()
|
||||||
{
|
{
|
||||||
// create the widget only once
|
QDialog d;
|
||||||
if (!yearlyStats) {
|
YearlyStatisticsWidget *s = new YearlyStatisticsWidget();
|
||||||
yearlyStats = new QTreeView();
|
QVBoxLayout *l = new QVBoxLayout(&d);
|
||||||
yearlyStats->setWindowModality(Qt::NonModal);
|
l->addWidget(s);
|
||||||
yearlyStats->setMinimumWidth(600);
|
d.exec();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BEHAVIOR QList<int>()
|
#define BEHAVIOR QList<int>()
|
||||||
|
@ -910,12 +886,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (yearlyStats && yearlyStats->isVisible()) {
|
|
||||||
yearlyStats->close();
|
|
||||||
yearlyStats->deleteLater();
|
|
||||||
yearlyStatsModel->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unsaved_changes() && (askSaveChanges() == false)) {
|
if (unsaved_changes() && (askSaveChanges() == false)) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -169,8 +169,6 @@ private:
|
||||||
QAction *actionNextDive;
|
QAction *actionNextDive;
|
||||||
QAction *actionPreviousDive;
|
QAction *actionPreviousDive;
|
||||||
UserManual *helpView;
|
UserManual *helpView;
|
||||||
QTreeView *yearlyStats;
|
|
||||||
QAbstractItemModel *yearlyStatsModel;
|
|
||||||
CurrentState state;
|
CurrentState state;
|
||||||
QString filter();
|
QString filter();
|
||||||
static MainWindow *m_Instance;
|
static MainWindow *m_Instance;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "statisticswidget.h"
|
||||||
|
|
||||||
|
YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent): QGraphicsView(parent)
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef YEARLYSTATISTICSWIDGET_H
|
||||||
|
#define YEARLYSTATISTICSWIDGET_H
|
||||||
|
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
class YearlyStatisticsWidget : public QGraphicsView {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
YearlyStatisticsWidget(QWidget *parent = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue