mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Better handling of default sizes on the Cylinder and Weight widgets
Better handling of default sizes on the Cylinder and weight widgets, the weigth widget didn't had a CSS applied so it looked odd compared to the cylinder one, also the default behavior for the combobox delegate didn't worked very well with the css applied, being too small. this patch fixes that. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
349a084496
commit
f9b4c6b889
6 changed files with 57 additions and 4 deletions
|
@ -79,12 +79,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex)));
|
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex)));
|
||||||
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
|
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
|
||||||
|
|
||||||
|
QFontMetrics metrics(defaultModelFont());
|
||||||
|
|
||||||
ui->cylinders->setColumnWidth(CylindersModel::REMOVE, 24);
|
ui->cylinders->setColumnWidth(CylindersModel::REMOVE, 24);
|
||||||
ui->cylinders->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
|
||||||
ui->cylinders->horizontalHeader()->setResizeMode(CylindersModel::REMOVE, QHeaderView::Fixed);
|
ui->cylinders->horizontalHeader()->setResizeMode(CylindersModel::REMOVE, QHeaderView::Fixed);
|
||||||
|
ui->cylinders->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
|
||||||
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
||||||
ui->weights->setColumnWidth(WeightModel::REMOVE, 24);
|
ui->weights->setColumnWidth(WeightModel::REMOVE, 24);
|
||||||
ui->weights->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
ui->weights->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
||||||
|
ui->weights->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
|
||||||
ui->weights->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
|
ui->weights->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<string>TabWidget</string>
|
<string>TabWidget</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="notesTab">
|
<widget class="QWidget" name="notesTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -202,7 +202,39 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="weights"/>
|
<widget class="QTableView" name="weights">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"> QTableView {
|
||||||
|
show-decoration-selected: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableView::item {
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-top-color: transparent;
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableView::item:hover {
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
|
||||||
|
border: 1px solid #bfcde4;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableView::item:selected {
|
||||||
|
border: 1px solid #567dbc;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableView::item:selected:active{
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableView::item:selected:!active {
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
|
||||||
|
}
|
||||||
|
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -76,6 +76,17 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI
|
||||||
return comboDelegate;
|
return comboDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComboBoxDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
QRect defaultRect = option.rect;
|
||||||
|
defaultRect.setX( defaultRect.x() -1);
|
||||||
|
defaultRect.setY( defaultRect.y() -1);
|
||||||
|
defaultRect.setWidth( defaultRect.width() + 2);
|
||||||
|
defaultRect.setHeight( defaultRect.height() + 2);
|
||||||
|
editor->setGeometry(defaultRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const
|
void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const
|
||||||
{
|
{
|
||||||
QComboBox *c = qobject_cast<QComboBox*>(editor);
|
QComboBox *c = qobject_cast<QComboBox*>(editor);
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
|
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
|
||||||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
||||||
|
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
protected:
|
protected:
|
||||||
QAbstractItemModel *model;
|
QAbstractItemModel *model;
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,7 +68,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
ret = defaultModelFont();
|
ret = defaultModelFont();
|
||||||
break;
|
break;
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
ret = Qt::AlignRight;
|
ret = Qt::AlignHCenter;
|
||||||
break;
|
break;
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
|
@ -656,6 +656,10 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
if (role == Qt::FontRole){
|
||||||
|
return defaultModelFont();
|
||||||
|
}
|
||||||
|
|
||||||
struct tank_info *info = &tank_info[index.row()];
|
struct tank_info *info = &tank_info[index.row()];
|
||||||
|
|
||||||
int ml = info->ml;
|
int ml = info->ml;
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
#include "../divelist.h"
|
#include "../divelist.h"
|
||||||
|
|
||||||
|
QFont defaultModelFont();
|
||||||
|
|
||||||
/* Encapsulates the tank_info global variable
|
/* Encapsulates the tank_info global variable
|
||||||
* to show on Qt's Model View System.*/
|
* to show on Qt's Model View System.*/
|
||||||
class TankInfoModel : public QAbstractTableModel {
|
class TankInfoModel : public QAbstractTableModel {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue