summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/maintab.cpp5
-rw-r--r--qt-ui/maintab.ui36
-rw-r--r--qt-ui/modeldelegates.cpp11
-rw-r--r--qt-ui/modeldelegates.h1
-rw-r--r--qt-ui/models.cpp6
-rw-r--r--qt-ui/models.h2
6 files changed, 57 insertions, 4 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index ea1687a33..6f63b3574 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -79,12 +79,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->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->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
ui->cylinders->horizontalHeader()->setResizeMode(CylindersModel::REMOVE, QHeaderView::Fixed);
+ ui->cylinders->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
ui->weights->setColumnWidth(WeightModel::REMOVE, 24);
ui->weights->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
+ ui->weights->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
ui->weights->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
}
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 733a605ea..d792edce0 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -14,7 +14,7 @@
<string>TabWidget</string>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="notesTab">
<attribute name="title">
@@ -202,7 +202,39 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<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>
</layout>
</widget>
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index d201337b4..01f5197ce 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -76,6 +76,17 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI
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
{
QComboBox *c = qobject_cast<QComboBox*>(editor);
diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h
index 00436d874..a33fc891b 100644
--- a/qt-ui/modeldelegates.h
+++ b/qt-ui/modeldelegates.h
@@ -19,6 +19,7 @@ public:
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, 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:
QAbstractItemModel *model;
};
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 21c89ee15..dd8bac078 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -68,7 +68,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
ret = defaultModelFont();
break;
case Qt::TextAlignmentRole:
- ret = Qt::AlignRight;
+ ret = Qt::AlignHCenter;
break;
case Qt::DisplayRole:
case Qt::EditRole:
@@ -656,6 +656,10 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
if (!index.isValid()) {
return ret;
}
+ if (role == Qt::FontRole){
+ return defaultModelFont();
+ }
+
struct tank_info *info = &tank_info[index.row()];
int ml = info->ml;
diff --git a/qt-ui/models.h b/qt-ui/models.h
index a012ec6bd..09a2c6a68 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -14,6 +14,8 @@
#include "../dive.h"
#include "../divelist.h"
+QFont defaultModelFont();
+
/* Encapsulates the tank_info global variable
* to show on Qt's Model View System.*/
class TankInfoModel : public QAbstractTableModel {