mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Test the CSS for styling the TableView
This is a test and I shouldn't be taken seriously. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f9c97ff97d
commit
82b1b04920
5 changed files with 99 additions and 8 deletions
|
@ -7,6 +7,8 @@
|
|||
#include "divelistview.h"
|
||||
#include "models.h"
|
||||
#include "modeldelegates.h"
|
||||
#include <QApplication>
|
||||
#include <QHeaderView>
|
||||
|
||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent)
|
||||
{
|
||||
|
|
|
@ -28,9 +28,86 @@
|
|||
<widget class="QGraphicsView" name="ProfileWidget"/>
|
||||
</widget>
|
||||
<widget class="DiveListView" name="ListWidget">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"> QTreeView {
|
||||
show-decoration-selected: 1;
|
||||
}
|
||||
|
||||
QTreeView::item {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
QTreeView::item:hover {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
|
||||
border: 1px solid #bfcde4;
|
||||
}
|
||||
|
||||
QTreeView::item:selected {
|
||||
border: 1px solid #567dbc;
|
||||
}
|
||||
|
||||
QTreeView::item:selected:active{
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
|
||||
}
|
||||
|
||||
QTreeView::item:selected:!active {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
QTreeView::branch {
|
||||
background: palette(base);
|
||||
}
|
||||
|
||||
QTreeView::branch:has-siblings:!adjoins-item {
|
||||
background: cyan;
|
||||
}
|
||||
|
||||
QTreeView::branch:has-siblings:adjoins-item {
|
||||
background: red;
|
||||
}
|
||||
|
||||
QTreeView::branch:!has-children:!has-siblings:adjoins-item {
|
||||
background: blue;
|
||||
}
|
||||
|
||||
QTreeView::branch:closed:has-children:has-siblings {
|
||||
background: pink;
|
||||
}
|
||||
|
||||
QTreeView::branch:has-children:!has-siblings:closed {
|
||||
background: gray;
|
||||
}
|
||||
|
||||
QTreeView::branch:open:has-children:has-siblings {
|
||||
background: magenta;
|
||||
}
|
||||
|
||||
QTreeView::branch:open:has-children:!has-siblings {
|
||||
background: green;
|
||||
}
|
||||
*/
|
||||
</string>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -42,7 +119,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>763</width>
|
||||
<height>20</height>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -7,9 +7,21 @@
|
|||
#include <QtDebug>
|
||||
#include <QPainter>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QColor>
|
||||
#include <QBrush>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
|
||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
|
||||
QStyledItemDelegate(parent),
|
||||
parentWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
|
@ -20,8 +32,6 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
|
|||
|
||||
int rating = value.toInt();
|
||||
|
||||
if(option.state & QStyle::State_Selected)
|
||||
painter->fillRect(option.rect, option.palette.highlight());
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#ifndef MODELDELEGATES_H
|
||||
#define MODELDELEGATES_H
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class StarWidgetsDelegate : public QAbstractItemDelegate {
|
||||
class StarWidgetsDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StarWidgetsDelegate(QWidget* parent = 0);
|
||||
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
private:
|
||||
QWidget *parentWidget;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "models.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QColor>
|
||||
#include <QBrush>
|
||||
|
||||
extern struct tank_info tank_info[100];
|
||||
|
||||
|
@ -598,9 +600,6 @@ QVariant DiveTripModel::data(const QModelIndex& index, int role) const
|
|||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
TreeItemDT* item = static_cast<TreeItemDT*>(index.internalPointer());
|
||||
|
||||
return item->data(index.column(), role);
|
||||
|
|
Loading…
Add table
Reference in a new issue