diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-04-28 08:45:22 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-04-28 08:45:22 -0300 |
commit | 0be521bb25cf6210ad47e42eb7a8eb7638c32442 (patch) | |
tree | e80f0700fe80ca9a669e6a2abf92f72501d2417b /qt-ui | |
parent | 2f4d6bbe535a195046b4746fd3a771087ee4a6c4 (diff) | |
download | subsurface-0be521bb25cf6210ad47e42eb7a8eb7638c32442.tar.gz |
Fixed loading the stars when opening with file as argv. minor cleanup
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
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 4c4143e98..f4538db22 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); |