Patch - Make dirk happy by sorting the model & load the model when loading a file from the menu.
Tomaz Canabrava
tcanabrava at kde.org
Thu Apr 25 18:15:09 PDT 2013
Well, let's see if I get this straigth. ;p
trying to use git request-pull here....
----------------------------------------------------------------
Tomaz Canabrava (1):
Make dirk happy by enabling sort in the model.
qt-ui/mainwindow.cpp | 14 ++++++++++----
qt-ui/mainwindow.h | 2 ++
qt-ui/mainwindow.ui | 8 ++++++--
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index b0b56a4..8cdc601 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -11,6 +11,7 @@
#include <QMessageBox>
#include <QtDebug>
#include <QDateTime>
+#include <QSortFilterProxyModel>
#include "divelistview.h"
#include "starwidget.h"
@@ -22,13 +23,14 @@
MainWindow::MainWindow() : ui(new Ui::MainWindow()),
- model(new DiveTripModel(this))
+ model(new DiveTripModel(this)),
+ sortModel(new QSortFilterProxyModel())
{
ui->setupUi(this);
- ui->ListWidget->setModel(model);
- setWindowIcon(QIcon(":subsurface-icon"));
- // Just to test the star widgets, can be safely removed.
+ sortModel->setSourceModel(model);
+ ui->ListWidget->setModel(sortModel);
+ setWindowIcon(QIcon(":subsurface-icon"));
}
void MainWindow::on_actionNew_triggered()
@@ -63,6 +65,10 @@ void MainWindow::on_actionOpen_triggered()
report_dives(FALSE, FALSE);
ui->InfoWidget->reload();
+
+ model->deleteLater();
+ model = new DiveTripModel(this);
+ sortModel->setSourceModel(model);
}
void MainWindow::on_actionSave_triggered()
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 43ebde7..fdb100c 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -9,6 +9,7 @@
#include <QMainWindow>
+class QSortFilterProxyModel;
class DiveTripModel;
namespace Ui
@@ -68,6 +69,7 @@ private Q_SLOTS:
private:
Ui::MainWindow *ui;
DiveTripModel *model;
+ QSortFilterProxyModel *sortModel;
QString filter();
bool askSaveChanges();
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index 6ece13f..3d3f0ec 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -27,7 +27,11 @@
<widget class="MainTab" name="InfoWidget" native="true"/>
<widget class="QGraphicsView" name="ProfileWidget"/>
</widget>
- <widget class="DiveListView" name="ListWidget"/>
+ <widget class="DiveListView" name="ListWidget">
+ <property name="sortingEnabled">
+ <bool>true</bool>
+ </property>
+ </widget>
</widget>
</item>
<item>
@@ -45,7 +49,7 @@
<x>0</x>
<y>0</y>
<width>763</width>
- <height>20</height>
+ <height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130425/74a815f9/attachment-0001.html>
More information about the subsurface
mailing list