mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
Merge branch 'randomFixes' of https://github.com/tcanabrava/subsurface
This commit is contained in:
commit
9946fe97c0
8 changed files with 207 additions and 155 deletions
BIN
plus.png
Normal file
BIN
plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -56,7 +56,7 @@ void KMessageWidgetPrivate::init(KMessageWidget* q_ptr)
|
||||||
QObject::connect(textLabel, SIGNAL(linkHovered(const QString&)), q, SIGNAL(linkHovered(const QString&)));
|
QObject::connect(textLabel, SIGNAL(linkHovered(const QString&)), q, SIGNAL(linkHovered(const QString&)));
|
||||||
|
|
||||||
QAction* closeAction = new QAction(QObject::tr("Close"), q);
|
QAction* closeAction = new QAction(QObject::tr("Close"), q);
|
||||||
q->connect(closeAction, SIGNAL(toggled(bool)), q, SLOT(animatedHide()));
|
q->connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide()));
|
||||||
|
|
||||||
closeButton = new QToolButton(content);
|
closeButton = new QToolButton(content);
|
||||||
closeButton->setAutoRaise(true);
|
closeButton->setAutoRaise(true);
|
||||||
|
|
|
@ -61,8 +61,50 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
if (label)
|
if (label)
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignHCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Thid couldn't be done on the ui file because element
|
||||||
|
is floating, instead of being fixed on the layout. */
|
||||||
|
QIcon plusIcon(":plus");
|
||||||
|
addCylinder = new QPushButton(plusIcon, QString(), ui->cylindersGroup);
|
||||||
|
addCylinder->setFlat(true);
|
||||||
|
addCylinder->setToolTip(tr("Add Cylinder"));
|
||||||
|
connect(addCylinder, SIGNAL(clicked(bool)), this, SLOT(addCylinder_clicked()));
|
||||||
|
addCylinder->setEnabled(false);
|
||||||
|
addWeight = new QPushButton(plusIcon, QString(), ui->weightGroup);
|
||||||
|
addWeight->setFlat(true);
|
||||||
|
addWeight->setToolTip(tr("Add Weight System"));
|
||||||
|
connect(addWeight, SIGNAL(clicked(bool)), this, SLOT(addWeight_clicked()));
|
||||||
|
addWeight->setEnabled(false);
|
||||||
|
|
||||||
|
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex)));
|
||||||
|
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
|
||||||
|
|
||||||
|
ui->cylinders->setColumnWidth( CylindersModel::REMOVE, 24);
|
||||||
|
ui->cylinders->horizontalHeader()->setResizeMode (CylindersModel::REMOVE , QHeaderView::Fixed);
|
||||||
|
ui->weights->setColumnWidth( WeightModel::REMOVE, 24);
|
||||||
|
ui->cylinders->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to manually position the 'plus' on cylinder and weight.
|
||||||
|
void MainTab::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
if (ui->cylindersGroup->isVisible())
|
||||||
|
addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24);
|
||||||
|
|
||||||
|
if (ui->weightGroup->isVisible())
|
||||||
|
addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24);
|
||||||
|
|
||||||
|
QTabWidget::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainTab::showEvent(QShowEvent* event)
|
||||||
|
{
|
||||||
|
QTabWidget::showEvent(event);
|
||||||
|
addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24);
|
||||||
|
addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MainTab::eventFilter(QObject* object, QEvent* event)
|
bool MainTab::eventFilter(QObject* object, QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::FocusIn) {
|
if (event->type() == QEvent::FocusIn) {
|
||||||
|
@ -204,6 +246,8 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
ui->shortestAllText->setText(get_time_string(stats_selection.shortest_time.seconds, 0));
|
ui->shortestAllText->setText(get_time_string(stats_selection.shortest_time.seconds, 0));
|
||||||
cylindersModel->setDive(d);
|
cylindersModel->setDive(d);
|
||||||
weightModel->setDive(d);
|
weightModel->setDive(d);
|
||||||
|
addCylinder->setEnabled(true);
|
||||||
|
addWeight->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
/* make the fields read-only */
|
/* make the fields read-only */
|
||||||
ui->location->setReadOnly(true);
|
ui->location->setReadOnly(true);
|
||||||
|
@ -230,6 +274,8 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
ui->airPressureText->clear();
|
ui->airPressureText->clear();
|
||||||
cylindersModel->clear();
|
cylindersModel->clear();
|
||||||
weightModel->clear();
|
weightModel->clear();
|
||||||
|
addCylinder->setEnabled(false);
|
||||||
|
addWeight->setEnabled(false);
|
||||||
}
|
}
|
||||||
/* statisticsTab*/
|
/* statisticsTab*/
|
||||||
/* we can access the stats_selection struct, but how do we ensure the relevant dives are selected
|
/* we can access the stats_selection struct, but how do we ensure the relevant dives are selected
|
||||||
|
@ -240,7 +286,7 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
// qDebug("min temp %u",stats_selection.min_temp);
|
// qDebug("min temp %u",stats_selection.min_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_addCylinder_clicked()
|
void MainTab::addCylinder_clicked()
|
||||||
{
|
{
|
||||||
if (cylindersModel->rowCount() >= MAX_CYLINDERS)
|
if (cylindersModel->rowCount() >= MAX_CYLINDERS)
|
||||||
return;
|
return;
|
||||||
|
@ -267,7 +313,7 @@ void MainTab::on_delCylinder_clicked()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_addWeight_clicked()
|
void MainTab::addWeight_clicked()
|
||||||
{
|
{
|
||||||
if (weightModel->rowCount() >= MAX_WEIGHTSYSTEMS)
|
if (weightModel->rowCount() >= MAX_WEIGHTSYSTEMS)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -38,12 +38,14 @@ public:
|
||||||
void reload();
|
void reload();
|
||||||
|
|
||||||
bool eventFilter(QObject* , QEvent*);
|
bool eventFilter(QObject* , QEvent*);
|
||||||
|
virtual void resizeEvent(QResizeEvent* );
|
||||||
|
virtual void showEvent(QShowEvent* );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void on_addCylinder_clicked();
|
void addCylinder_clicked();
|
||||||
void on_editCylinder_clicked();
|
void on_editCylinder_clicked();
|
||||||
void on_delCylinder_clicked();
|
void on_delCylinder_clicked();
|
||||||
void on_addWeight_clicked();
|
void addWeight_clicked();
|
||||||
void on_editWeight_clicked();
|
void on_editWeight_clicked();
|
||||||
void on_delWeight_clicked();
|
void on_delWeight_clicked();
|
||||||
void updateDiveInfo(int dive);
|
void updateDiveInfo(int dive);
|
||||||
|
@ -63,6 +65,8 @@ private:
|
||||||
CylindersModel *cylindersModel;
|
CylindersModel *cylindersModel;
|
||||||
NotesBackup notesBackup;
|
NotesBackup notesBackup;
|
||||||
struct dive* currentDive;
|
struct dive* currentDive;
|
||||||
|
QPushButton *addCylinder;
|
||||||
|
QPushButton *addWeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
180
qt-ui/maintab.ui
180
qt-ui/maintab.ui
|
@ -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">
|
||||||
|
@ -78,22 +78,22 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<layout class="QHBoxLayout" name="ratingVisibilityLabels">
|
<layout class="QHBoxLayout" name="ratingVisibilityLabels">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_14">
|
<widget class="QLabel" name="label_14">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Rating</string>
|
<string>Rating</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="visibilityLabel">
|
<widget class="QLabel" name="visibilityLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Visibility</string>
|
<string>Visibility</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QLabel" name="label_19">
|
<widget class="QLabel" name="label_19">
|
||||||
|
@ -110,14 +110,14 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<layout class="QHBoxLayout" name="ratingVisibilityWidgets">
|
<layout class="QHBoxLayout" name="ratingVisibilityWidgets">
|
||||||
<item>
|
<item>
|
||||||
<widget class="StarWidget" name="rating" native="true"/>
|
<widget class="StarWidget" name="rating" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="StarWidget" name="visibility" native="true"/>
|
<widget class="StarWidget" name="visibility" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QPushButton" name="editReset">
|
<widget class="QPushButton" name="editReset">
|
||||||
|
@ -151,55 +151,17 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="cylindersGroup">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Cylinders</string>
|
<string>Cylinders</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="cylinders"/>
|
<widget class="QTableView" name="cylinders"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="editCylinder">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addCylinder">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="delCylinder">
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="weightGroup">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Weight</string>
|
<string>Weight</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -207,44 +169,6 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="weights"/>
|
<widget class="QTableView" name="weights"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="editWeight">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addWeight">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="delWeight">
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -271,24 +195,15 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="diveInfoUpperGridLayout">
|
<layout class="QGridLayout" name="diveInfoUpperGridLayout">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>15</number>
|
<number>15</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="sacLabel">
|
<widget class="QLabel" name="sacLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -386,16 +301,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="diveInfoLowerGridLayout">
|
<layout class="QGridLayout" name="diveInfoLowerGridLayout">
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
@ -598,16 +504,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="statsUpperGridLayout">
|
<layout class="QGridLayout" name="statsUpperGridLayout">
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
@ -750,16 +647,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="statsLowerGridLayout">
|
<layout class="QGridLayout" name="statsLowerGridLayout">
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
|
108
qt-ui/models.cpp
108
qt-ui/models.cpp
|
@ -11,6 +11,7 @@
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
extern struct tank_info tank_info[100];
|
extern struct tank_info tank_info[100];
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, in
|
||||||
|
|
||||||
int CylindersModel::columnCount(const QModelIndex& parent) const
|
int CylindersModel::columnCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return 7;
|
return COLUMNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
|
@ -102,9 +103,57 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (role == Qt::DecorationRole){
|
||||||
|
if (index.column() == REMOVE){
|
||||||
|
ret = QIcon(":trash");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||||
|
{
|
||||||
|
cylinder_t *cyl = ¤t->cylinder[index.row()];
|
||||||
|
switch(index.column()){
|
||||||
|
case TYPE:{
|
||||||
|
QByteArray desc = value.toByteArray();
|
||||||
|
cyl->type.description = strdup(desc.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SIZE:
|
||||||
|
// we can't use get_volume_string because the idiotic imperial tank
|
||||||
|
// sizes take working pressure into account...
|
||||||
|
if (cyl->type.size.mliter) {
|
||||||
|
if (prefs.units.volume == prefs.units.CUFT) {
|
||||||
|
double liters = cuft_to_l(value.toDouble());
|
||||||
|
cyl->type.size.mliter = liters * 1000.0;
|
||||||
|
} else {
|
||||||
|
cyl->type.size.mliter = value.toDouble() * 1000.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MAXPRESS:
|
||||||
|
cyl->type.workingpressure.mbar = value.toInt();
|
||||||
|
break;
|
||||||
|
case START:
|
||||||
|
cyl->start.mbar = value.toInt();
|
||||||
|
break;
|
||||||
|
case END:
|
||||||
|
cyl->end.mbar = value.toInt();
|
||||||
|
break;
|
||||||
|
case O2:
|
||||||
|
cyl->gasmix.o2.permille = value.toInt() * 10 - 5;
|
||||||
|
break;
|
||||||
|
case HE:
|
||||||
|
cyl->gasmix.he.permille = value.toInt() * 10 - 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QAbstractItemModel::setData(index, value, role);
|
||||||
|
}
|
||||||
|
|
||||||
int CylindersModel::rowCount(const QModelIndex& parent) const
|
int CylindersModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return rows;
|
return rows;
|
||||||
|
@ -164,6 +213,33 @@ void CylindersModel::setDive(dive* d)
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags CylindersModel::flags(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
if (index.column() == REMOVE)
|
||||||
|
return Qt::ItemIsEnabled;
|
||||||
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CylindersModel::remove(const QModelIndex& index)
|
||||||
|
{
|
||||||
|
if (index.column() != REMOVE){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
||||||
|
// Remove code should be here.
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeightModel::remove(const QModelIndex& index)
|
||||||
|
{
|
||||||
|
if (index.column() != REMOVE){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
beginRemoveRows(QModelIndex(), index.row(), index.row()); // yah, know, ugly.
|
||||||
|
// Remove code should be here.
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
void WeightModel::clear()
|
void WeightModel::clear()
|
||||||
{
|
{
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
|
@ -174,7 +250,7 @@ void WeightModel::clear()
|
||||||
|
|
||||||
int WeightModel::columnCount(const QModelIndex& parent) const
|
int WeightModel::columnCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return 2;
|
return COLUMNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant WeightModel::data(const QModelIndex& index, int role) const
|
QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
|
@ -195,9 +271,37 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (role == Qt::DecorationRole){
|
||||||
|
if (index.column() == REMOVE){
|
||||||
|
ret = QIcon(":trash");
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||||
|
{
|
||||||
|
weightsystem_t *ws = ¤t_dive->weightsystem[index.row()];
|
||||||
|
switch(index.column()) {
|
||||||
|
case TYPE:{
|
||||||
|
QByteArray desc = value.toByteArray();
|
||||||
|
ws->description = strdup(desc.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEIGHT:
|
||||||
|
ws->weight.grams = value.toInt() *1000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags WeightModel::flags(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
if (index.column() == REMOVE)
|
||||||
|
return Qt::ItemIsEnabled;
|
||||||
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
|
}
|
||||||
|
|
||||||
int WeightModel::rowCount(const QModelIndex& parent) const
|
int WeightModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return rows;
|
return rows;
|
||||||
|
|
|
@ -38,18 +38,22 @@ private:
|
||||||
class CylindersModel : public QAbstractTableModel {
|
class CylindersModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Column {TYPE, SIZE, MAXPRESS, START, END, O2, HE};
|
enum Column {REMOVE, TYPE, SIZE, MAXPRESS, START, END, O2, HE, COLUMNS};
|
||||||
|
|
||||||
explicit CylindersModel(QObject* parent = 0);
|
explicit CylindersModel(QObject* parent = 0);
|
||||||
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
|
/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
|
/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
|
|
||||||
void add(cylinder_t *cyl);
|
void add(cylinder_t *cyl);
|
||||||
void clear();
|
void clear();
|
||||||
void update();
|
void update();
|
||||||
void setDive(struct dive *d);
|
void setDive(struct dive *d);
|
||||||
|
public slots:
|
||||||
|
void remove(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *current;
|
struct dive *current;
|
||||||
|
@ -61,16 +65,20 @@ private:
|
||||||
class WeightModel : public QAbstractTableModel {
|
class WeightModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Column {TYPE, WEIGHT};
|
enum Column {REMOVE, TYPE, WEIGHT, COLUMNS};
|
||||||
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
|
/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
|
/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
|
|
||||||
void add(weightsystem_t *weight);
|
void add(weightsystem_t *weight);
|
||||||
void clear();
|
void clear();
|
||||||
void update();
|
void update();
|
||||||
void setDive(struct dive *d);
|
void setDive(struct dive *d);
|
||||||
|
public slots:
|
||||||
|
void remove(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct dive *current;
|
struct dive *current;
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
<qresource>
|
<qresource>
|
||||||
<file alias="star">star.svg</file>
|
<file alias="star">star.svg</file>
|
||||||
<file alias="subsurface-icon">subsurface-icon.png</file>
|
<file alias="subsurface-icon">subsurface-icon.png</file>
|
||||||
|
<file alias="plus">plus.png</file>
|
||||||
|
<file alias="trash">trash.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in a new issue