diff options
-rw-r--r-- | qt-ui/modeldelegates.cpp | 8 | ||||
-rw-r--r-- | qt-ui/models.cpp | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 87629bd1b..2adaaebc7 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -15,14 +15,16 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o QVariant value = index.model()->data(index, Qt::DisplayRole); + if(option.state & QStyle::State_Selected) + painter->fillRect(option.rect, option.palette.highlight()); + else + painter->fillRect(option.rect, index.model()->data(index, Qt::BackgroundRole).value<QBrush>()); + if (!value.isValid()) return; int rating = value.toInt(); - if(option.state & QStyle::State_Selected) - painter->fillRect(option.rect, option.palette.highlight()); - painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 5c7fc7a8b..373770404 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -7,6 +7,8 @@ #include "models.h" #include <QCoreApplication> #include <QDebug> +#include <QColor> +#include <QBrush> extern struct tank_info tank_info[100]; @@ -599,6 +601,8 @@ QVariant DiveTripModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); + if (role == Qt::BackgroundRole) + return QBrush(QColor(index.row() % 2 ? Qt::white : QColor(Qt::lightGray).lighter(120))); TreeItemDT* item = static_cast<TreeItemDT*>(index.internalPointer()); |