so, this whole set of patches does: almost nothing, it's the beginning of the work for the new statistics pane. It's *safe* to merge, won't break anything, it will actually clear quite a bit of code. the new white part of the statistics widget is the new one that I'm working with, the bottom part is the old one.
From b6b99f80eb07398026b6813b70d9f4e4d9db1a0e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 14:52:45 -0300 Subject: [PATCH 1/9] Added initial skeleton for the Statistics Redesign
The statistics widget is a beast, one of the parts that I dislike most on the current subsurface implementation. This is the initial work to change that to something amazing. This first commit adds the first bunch of files that I think are needed, and the correct setup for the qmake and cmake buildsystems. Signed-off-by: Tomaz Canabrava <[email protected]> --- CMakeLists.txt | 11 +++++++++++ qt-ui/statistics/monthstatistics.cpp | 0 qt-ui/statistics/monthstatistics.h | 0 qt-ui/statistics/statisticsbar.cpp | 0 qt-ui/statistics/statisticsbar.h | 0 qt-ui/statistics/statisticswidget.cpp | 0 qt-ui/statistics/statisticswidget.h | 0 qt-ui/statistics/yearstatistics.cpp | 0 qt-ui/statistics/yearstatistics.h | 0 subsurface.pro | 12 ++++++++++-- 10 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 qt-ui/statistics/monthstatistics.cpp create mode 100644 qt-ui/statistics/monthstatistics.h create mode 100644 qt-ui/statistics/statisticsbar.cpp create mode 100644 qt-ui/statistics/statisticsbar.h create mode 100644 qt-ui/statistics/statisticswidget.cpp create mode 100644 qt-ui/statistics/statisticswidget.h create mode 100644 qt-ui/statistics/yearstatistics.cpp create mode 100644 qt-ui/statistics/yearstatistics.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 44fa134..2eef2d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,14 @@ SET(SUBSURFACE_PROFILE_LIB_SRCS qt-ui/profile/tankitem.cpp ) +#the yearly statistics widget. +SET(SUBSURFACE_STATISTICS_LIB_SRCS + qt-ui/statistics/statisticswidget.cpp + qt-ui/statistics/yearstatistics.cpp + qt-ui/statistics/statisticsbar.cpp + qt-ui/statistics/monthstatistics.cpp +) + #the main app. SET(SUBSURFACE_APP main.cpp @@ -182,6 +190,7 @@ ENDIF() ADD_LIBRARY(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} ) ADD_LIBRARY(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS}) +ADD_LIBRARY(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS}) ADD_LIBRARY(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS}) ADD_LIBRARY(subsurface_interface STATIC ${SUBSURFACE_INTERFACE}) ADD_EXECUTABLE(subsurface ${SUBSURFACE_APP} ${SUBSURFACE_QRC_HRDS} ) @@ -190,6 +199,7 @@ target_link_libraries( subsurface subsurface_generated_ui subsurface_interface subsurface_profile + subsurface_statistics subsurface_corelib ${QT_LIBRARIES} ${MARBLE_LIBRARIES} @@ -198,6 +208,7 @@ target_link_libraries( subsurface -lzip ) +ADD_DEPENDENCIES(subsurface_statistics subsurface_generated_ui) ADD_DEPENDENCIES(subsurface_profile subsurface_generated_ui) ADD_DEPENDENCIES(subsurface_interface subsurface_generated_ui) ADD_DEPENDENCIES(subsurface_generated_ui version) diff --git a/qt-ui/statistics/monthstatistics.cpp b/qt-ui/statistics/monthstatistics.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/monthstatistics.h b/qt-ui/statistics/monthstatistics.h new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/statisticsbar.cpp b/qt-ui/statistics/statisticsbar.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/statisticsbar.h b/qt-ui/statistics/statisticsbar.h new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/statisticswidget.h b/qt-ui/statistics/statisticswidget.h new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/yearstatistics.cpp b/qt-ui/statistics/yearstatistics.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qt-ui/statistics/yearstatistics.h b/qt-ui/statistics/yearstatistics.h new file mode 100644 index 0000000..e69de29 diff --git a/subsurface.pro b/subsurface.pro index 4ce0eba..5fa9686 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -94,7 +94,11 @@ HEADERS = \ qt-ui/configuredivecomputerdialog.h \ configuredivecomputer.h \ configuredivecomputerthreads.h \ - devicedetails.h + devicedetails.h \ + qt-ui/statistics/monthstatistics.h \ + qt-ui/statistics/statisticswidget.h \ + qt-ui/statistics/statisticsbar.h \ + qt-ui/statistics/yearstatistics.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -178,7 +182,11 @@ SOURCES = \ qt-ui/configuredivecomputerdialog.cpp \ configuredivecomputer.cpp \ configuredivecomputerthreads.cpp \ - devicedetails.cpp + devicedetails.cpp \ + qt-ui/statistics/statisticswidget.cpp \ + qt-ui/statistics/yearstatistics.cpp \ + qt-ui/statistics/statisticsbar.cpp \ + qt-ui/statistics/monthstatistics.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c -- 2.1.0
From 65b5bcffbc1b32efd12b5d0c4ad81a8f8535a63e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 15:46:08 -0300 Subject: [PATCH 2/9] Removed 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 <[email protected]> --- qt-ui/mainwindow.cpp | 42 +++++------------------------------ qt-ui/mainwindow.h | 2 -- qt-ui/statistics/statisticswidget.cpp | 5 +++++ qt-ui/statistics/statisticswidget.h | 12 ++++++++++ 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4c70f5c..f73a2dd 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>() @@ -908,12 +884,6 @@ void MainWindow::closeEvent(QCloseEvent *event) helpView->deleteLater(); } - 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 100eac6..1ae717a 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 e69de29..71ac784 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 e69de29..b01f2ee 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 -- 2.1.0
From 2dcb0910335a02c939959a8dc94a56c191b28be6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 15:48:26 -0300 Subject: [PATCH 3/9] Added the old Statistics to have a reference view while programming Added the old statistics panel at the botton of the new one to have a reference view of the statistics while programming the new one. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index f73a2dd..e1a3ed0 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -548,6 +548,10 @@ void MainWindow::on_actionYearlyStatistics_triggered() YearlyStatisticsWidget *s = new YearlyStatisticsWidget(); QVBoxLayout *l = new QVBoxLayout(&d); l->addWidget(s); + YearlyStatisticsModel *m = new YearlyStatisticsModel(); + QTreeView *view = new QTreeView(); + view->setModel(m); + l->addWidget(view); d.exec(); } -- 2.1.0
From 25b4f8802a3a3d874a9498347637582c212d9b46 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:10:47 -0300 Subject: [PATCH 4/9] Create Stub Methods and connects the model with the new Statistics Connects the YearlyStatistics model with the YearlyStatisticsWidget nothing is shown right now, mostly because I need to do everything but now it's easyer to add the things that are missing. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 5 +++-- qt-ui/statistics/statisticswidget.cpp | 31 +++++++++++++++++++++++++++++++ qt-ui/statistics/statisticswidget.h | 10 ++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index e1a3ed0..25da67d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -545,12 +545,13 @@ void MainWindow::on_actionAutoGroup_triggered() void MainWindow::on_actionYearlyStatistics_triggered() { QDialog d; - YearlyStatisticsWidget *s = new YearlyStatisticsWidget(); + YearlyStatisticsWidget *newView = new YearlyStatisticsWidget(); QVBoxLayout *l = new QVBoxLayout(&d); - l->addWidget(s); + l->addWidget(newView); YearlyStatisticsModel *m = new YearlyStatisticsModel(); QTreeView *view = new QTreeView(); view->setModel(m); + newView->setModel(m); l->addWidget(view); d.exec(); } diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 71ac784..8ac8d1c 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -1,5 +1,36 @@ #include "statisticswidget.h" +#include "models.h" +#include <QModelIndex> YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent): QGraphicsView(parent) { } + +void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m) +{ + m_model = m; + connect(m, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(modelDataChanged(QModelIndex,QModelIndex))); + connect(m, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(modelRowsRemoved(QModelIndex,int,int))); + connect(m, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(modelRowsInserted(QModelIndex,int,int))); + + modelRowsRemoved(QModelIndex(),0,m_model->rowCount()-1); + modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1); +} + +void YearlyStatisticsWidget::modelRowsInserted(const QModelIndex &index, int first, int last) +{ + // stub +} + +void YearlyStatisticsWidget::modelRowsRemoved(const QModelIndex &index, int first, int last) +{ + // stub +} + +void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight) +{ + // stub +} diff --git a/qt-ui/statistics/statisticswidget.h b/qt-ui/statistics/statisticswidget.h index b01f2ee..0042ce6 100644 --- a/qt-ui/statistics/statisticswidget.h +++ b/qt-ui/statistics/statisticswidget.h @@ -3,10 +3,20 @@ #include <QGraphicsView> +class YearlyStatisticsModel; +class QModelIndex; + class YearlyStatisticsWidget : public QGraphicsView { Q_OBJECT public: YearlyStatisticsWidget(QWidget *parent = 0); + void setModel(YearlyStatisticsModel *m); +public slots: + void modelRowsInserted(const QModelIndex& index, int first, int last); + void modelRowsRemoved(const QModelIndex& index, int first, int last); + void modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); +private: + YearlyStatisticsModel *m_model; }; #endif \ No newline at end of file -- 2.1.0
From e6bc1afabce0113a76a549ebe5d799aa48c624d1 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:29:06 -0300 Subject: [PATCH 5/9] Set the flags and hints to the QGraphicsScene on the Statistics Widget Set the flags and hints to the QGraphicsScene on the Statistics Widget the size will always be 0,0,100,100 so it's easy to make percentage calculations. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/statistics/statisticswidget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 8ac8d1c..254cbcc 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -4,6 +4,15 @@ YearlyStatisticsWidget::YearlyStatisticsWidget(QWidget *parent): QGraphicsView(parent) { + setScene(new QGraphicsScene()); + scene()->setSceneRect(0, 0, 100, 100); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scene()->setItemIndexMethod(QGraphicsScene::NoIndex); + setOptimizationFlags(QGraphicsView::DontSavePainterState); + setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); + setMouseTracking(true); } void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m) -- 2.1.0
From aefc0ed129aec2cf9d5a9b434fd5c94e72dfc6dd Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:31:05 -0300 Subject: [PATCH 6/9] Implement the resizeEvent to make the statistics always visible. Implement the resizeEvent to make the statistics always visible by always fiting the whole scene in the view. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/statistics/statisticswidget.cpp | 6 ++++++ qt-ui/statistics/statisticswidget.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 254cbcc..5145094 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -43,3 +43,9 @@ void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const { // stub } + +void YearlyStatisticsWidget::resizeEvent(QResizeEvent *event) +{ + QGraphicsView::resizeEvent(event); + fitInView(sceneRect(), Qt::IgnoreAspectRatio); +} diff --git a/qt-ui/statistics/statisticswidget.h b/qt-ui/statistics/statisticswidget.h index 0042ce6..4e62a10 100644 --- a/qt-ui/statistics/statisticswidget.h +++ b/qt-ui/statistics/statisticswidget.h @@ -11,6 +11,8 @@ class YearlyStatisticsWidget : public QGraphicsView { public: YearlyStatisticsWidget(QWidget *parent = 0); void setModel(YearlyStatisticsModel *m); +protected: + virtual void resizeEvent(QResizeEvent *event); public slots: void modelRowsInserted(const QModelIndex& index, int first, int last); void modelRowsRemoved(const QModelIndex& index, int first, int last); -- 2.1.0
From 7ef687b19ea4583abf1185c2e970fda93b9556fa Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:32:24 -0300 Subject: [PATCH 7/9] Use aboutToBeRemoved instead of removed If we used removed to then remove things from the interface we could hit a dangling pointer, so first delete the items, then let the system delete the rows. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/statistics/statisticswidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 5145094..6f39124 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -20,7 +20,7 @@ void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m) m_model = m; connect(m, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged(QModelIndex,QModelIndex))); - connect(m, SIGNAL(rowsRemoved(QModelIndex,int,int)), + connect(m, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelRowsRemoved(QModelIndex,int,int))); connect(m, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelRowsInserted(QModelIndex,int,int))); -- 2.1.0
From 3bf0161be33dc2ee93e8a8ebe4deaf2518b2d317 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:39:11 -0300 Subject: [PATCH 8/9] Use scene()->clear() instead of manually clearing the scene. When there's a rowsAboutToBeRemoevd, remove all items from the scene() by calling scene()->clear(), instead of creating a method just for that. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/statistics/statisticswidget.cpp | 8 +------- qt-ui/statistics/statisticswidget.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 6f39124..86ab5ce 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -21,11 +21,10 @@ void YearlyStatisticsWidget::setModel(YearlyStatisticsModel *m) connect(m, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged(QModelIndex,QModelIndex))); connect(m, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(modelRowsRemoved(QModelIndex,int,int))); + scene(), SLOT(clear())); connect(m, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelRowsInserted(QModelIndex,int,int))); - modelRowsRemoved(QModelIndex(),0,m_model->rowCount()-1); modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1); } @@ -34,11 +33,6 @@ void YearlyStatisticsWidget::modelRowsInserted(const QModelIndex &index, int fir // stub } -void YearlyStatisticsWidget::modelRowsRemoved(const QModelIndex &index, int first, int last) -{ - // stub -} - void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight) { // stub diff --git a/qt-ui/statistics/statisticswidget.h b/qt-ui/statistics/statisticswidget.h index 4e62a10..ae98829 100644 --- a/qt-ui/statistics/statisticswidget.h +++ b/qt-ui/statistics/statisticswidget.h @@ -15,7 +15,6 @@ protected: virtual void resizeEvent(QResizeEvent *event); public slots: void modelRowsInserted(const QModelIndex& index, int first, int last); - void modelRowsRemoved(const QModelIndex& index, int first, int last); void modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); private: YearlyStatisticsModel *m_model; -- 2.1.0
From ab263490e2993740a592182bff9a6d3a580630cf Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 25 Aug 2014 16:55:26 -0300 Subject: [PATCH 9/9] Implement the modelDataChanged to repopulate the widget on Statistics The modelDataChanged method will remove all items and recreate everything *right* now we will never use it, because we are not triggering any changes on the model, but simply deleting and recreating it everytime we open the dialog. to be changed in the future. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/statistics/statisticswidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qt-ui/statistics/statisticswidget.cpp b/qt-ui/statistics/statisticswidget.cpp index 86ab5ce..4adb122 100644 --- a/qt-ui/statistics/statisticswidget.cpp +++ b/qt-ui/statistics/statisticswidget.cpp @@ -35,7 +35,10 @@ void YearlyStatisticsWidget::modelRowsInserted(const QModelIndex &index, int fir void YearlyStatisticsWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex& bottomRight) { - // stub + Q_UNUSED(topLeft); + Q_UNUSED(bottomRight); + scene()->clear(); + modelRowsInserted(QModelIndex(),0,m_model->rowCount()-1); } void YearlyStatisticsWidget::resizeEvent(QResizeEvent *event) -- 2.1.0
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
