diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-04-28 13:10:20 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-28 13:10:20 -0700 |
commit | 0794f03b5e9dd1ba55e16b10b11cd6d61530b5b8 (patch) | |
tree | 28a712ce3b167887ed3f035b2d4a66b130bcb425 /qt-ui | |
parent | 4c665be05f7128a5a259fb3b71f3d65019639b1d (diff) | |
parent | 0be521bb25cf6210ad47e42eb7a8eb7638c32442 (diff) | |
download | subsurface-0794f03b5e9dd1ba55e16b10b11cd6d61530b5b8.tar.gz |
Merge branch 'RenderStarsOnTable' of https://github.com/tcanabrava/subsurface into Qt
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/divelistview.cpp | 1 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 3 | ||||
-rw-r--r-- | qt-ui/models.cpp | 7 | ||||
-rw-r--r-- | qt-ui/models.h | 1 |
5 files changed, 4 insertions, 10 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index e8a3d2311..fb19a7060 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -11,4 +11,5 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent) { setUniformRowHeights(true); + setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); } diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 71ba70525..9901e4186 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -69,7 +69,7 @@ void MainWindow::on_actionOpen_triggered() model->deleteLater(); model = new DiveTripModel(this); sortModel->setSourceModel(model); - ui->ListWidget->setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); + ui->ListWidget->sortByColumn(0, Qt::DescendingOrder); } void MainWindow::on_actionSave_triggered() diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 1bbf1061b..1ac2f46c6 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -6,6 +6,7 @@ #include <QtDebug> #include <QPainter> +#include <QSortFilterProxyModel> void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { @@ -13,7 +14,7 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o return; } - int rating = index.model()->data(index, DiveTripModel::DelegatesRole).toInt(); + int rating = index.model()->data(index, Qt::DisplayRole).toInt(); if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 0944fe3e3..23eea3e48 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -496,13 +496,6 @@ QVariant DiveTripModel::data(const QModelIndex &index, int role) const break; } } - if (role == DelegatesRole){ - switch(index.column()){ - case RATING: - retVal = item->diveRating(); - break; - } - } return retVal; } diff --git a/qt-ui/models.h b/qt-ui/models.h index f4d9c8d3b..9e4666dc7 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -79,7 +79,6 @@ class DiveTripModel : public QAbstractItemModel { public: enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; - enum { DelegatesRole = Qt::UserRole }; DiveTripModel(QObject *parent = 0); |