aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/divelistview.cpp1
-rw-r--r--qt-ui/mainwindow.cpp2
-rw-r--r--qt-ui/modeldelegates.cpp3
-rw-r--r--qt-ui/models.cpp7
-rw-r--r--qt-ui/models.h1
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);