mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fixed loading the stars when opening with file as argv. minor cleanup
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
2f4d6bbe53
commit
0be521bb25
5 changed files with 4 additions and 10 deletions
|
@ -11,4 +11,5 @@
|
||||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent)
|
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent)
|
||||||
{
|
{
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
|
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ void MainWindow::on_actionOpen_triggered()
|
||||||
model->deleteLater();
|
model->deleteLater();
|
||||||
model = new DiveTripModel(this);
|
model = new DiveTripModel(this);
|
||||||
sortModel->setSourceModel(model);
|
sortModel->setSourceModel(model);
|
||||||
ui->ListWidget->setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
|
ui->ListWidget->sortByColumn(0, Qt::DescendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSave_triggered()
|
void MainWindow::on_actionSave_triggered()
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
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;
|
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)
|
if (option.state & QStyle::State_Selected)
|
||||||
painter->fillRect(option.rect, option.palette.highlight());
|
painter->fillRect(option.rect, option.palette.highlight());
|
||||||
|
|
|
@ -496,13 +496,6 @@ QVariant DiveTripModel::data(const QModelIndex &index, int role) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (role == DelegatesRole){
|
|
||||||
switch(index.column()){
|
|
||||||
case RATING:
|
|
||||||
retVal = item->diveRating();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ class DiveTripModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
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);
|
DiveTripModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue