Merge branch 'RenderStarsOnTable' of https://github.com/tcanabrava/subsurface into Qt

This commit is contained in:
Dirk Hohndel 2013-04-28 13:10:20 -07:00
commit 0794f03b5e
5 changed files with 4 additions and 10 deletions

View file

@ -11,4 +11,5 @@
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent)
{
setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
}

View file

@ -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()

View file

@ -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());

View file

@ -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;
}

View file

@ -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);