mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Code Cleanup: Merged the three TableViews shared code
Merged the shared code for the three table views into one code, this way less code is needed if we need to construct another tableview in the future. I still need to clean some of the models too. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
430e7ab132
commit
5666f6573e
8 changed files with 91 additions and 237 deletions
2
Makefile
2
Makefile
|
@ -57,6 +57,7 @@ HEADERS = \
|
||||||
qt-ui/printoptions.h \
|
qt-ui/printoptions.h \
|
||||||
qt-ui/printlayout.h \
|
qt-ui/printlayout.h \
|
||||||
qt-ui/completionmodels.h \
|
qt-ui/completionmodels.h \
|
||||||
|
qt-ui/tableview.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
|
@ -102,6 +103,7 @@ SOURCES = \
|
||||||
qt-ui/printoptions.cpp \
|
qt-ui/printoptions.cpp \
|
||||||
qt-ui/printlayout.cpp \
|
qt-ui/printlayout.cpp \
|
||||||
qt-ui/completionmodels.cpp \
|
qt-ui/completionmodels.cpp \
|
||||||
|
qt-ui/tableview.cpp \
|
||||||
$(RESFILE)
|
$(RESFILE)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "modeldelegates.h"
|
#include "modeldelegates.h"
|
||||||
#include "ui_diveplanner.h"
|
#include "ui_diveplanner.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "tableview.h"
|
||||||
|
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
#include "../divelist.h"
|
#include "../divelist.h"
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QTableView>
|
||||||
|
|
||||||
#define TIME_INITIAL_MAX 30
|
#define TIME_INITIAL_MAX 30
|
||||||
|
|
||||||
|
@ -827,10 +829,10 @@ void Button::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f), ui(new Ui::DivePlanner())
|
DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f), ui(new Ui::DivePlanner())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tablePoints->setModel(DivePlannerPointsModel::instance());
|
ui->tableWidget->setTitle(tr("Dive Planner Points"));
|
||||||
ui->tablePoints->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
|
ui->tableWidget->setModel(DivePlannerPointsModel::instance());
|
||||||
|
ui->tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
|
||||||
connect(ui->tablePoints, SIGNAL(clicked(QModelIndex)), plannerModel, SLOT(removePoint(const QModelIndex)));
|
connect(ui->tableWidget->view(), SIGNAL(clicked(QModelIndex)), plannerModel, SLOT(removePoint(const QModelIndex)));
|
||||||
connect(ui->startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
|
connect(ui->startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
|
||||||
connect(ui->ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
|
connect(ui->ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
|
||||||
connect(ui->bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString)));
|
connect(ui->bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString)));
|
||||||
|
@ -839,46 +841,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
|
||||||
connect(ui->lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
|
connect(ui->lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
|
||||||
connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
|
connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
|
||||||
connect(ui->lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
|
connect(ui->lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
|
||||||
|
|
||||||
QFile cssFile(":table-css");
|
|
||||||
cssFile.open(QIODevice::ReadOnly);
|
|
||||||
QTextStream reader(&cssFile);
|
|
||||||
QString css = reader.readAll();
|
|
||||||
|
|
||||||
ui->tablePoints->setStyleSheet(css);
|
|
||||||
QFontMetrics metrics(defaultModelFont());
|
|
||||||
|
|
||||||
ui->tablePoints->horizontalHeader()->setResizeMode(DivePlannerPointsModel::REMOVE, QHeaderView::Fixed);
|
|
||||||
ui->tablePoints->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
|
|
||||||
initialUiSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerWidget::hideEvent(QHideEvent* event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup("DivePlanner");
|
|
||||||
s.beginGroup("PointTables");
|
|
||||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
|
||||||
s.setValue(QString("colwidth%1").arg(i), ui->tablePoints->columnWidth(i));
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
s.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DivePlannerWidget::initialUiSetup()
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup("DivePlanner");
|
|
||||||
s.beginGroup("PointTables");
|
|
||||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
|
||||||
QVariant width = s.value(QString("colwidth%1").arg(i));
|
|
||||||
if (width.isValid())
|
|
||||||
ui->tablePoints->setColumnWidth(i, width.toInt());
|
|
||||||
else
|
|
||||||
ui->tablePoints->resizeColumnToContents(i);
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
}
|
|
||||||
void DivePlannerWidget::startTimeChanged(const QTime& time)
|
void DivePlannerWidget::startTimeChanged(const QTime& time)
|
||||||
{
|
{
|
||||||
plannerModel->setStartTime(time);
|
plannerModel->setStartTime(time);
|
||||||
|
@ -930,11 +894,14 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
|
||||||
case GAS: return strForAir(p);
|
case GAS: return strForAir(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (role == Qt::DecorationRole){
|
else if (role == Qt::DecorationRole){
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
case REMOVE : return QIcon(":trash");
|
case REMOVE : return QIcon(":trash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (role == Qt::FontRole){
|
||||||
|
return defaultModelFont();
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,6 +938,9 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
|
||||||
case CCSETPOINT: return tr("CC Set Point");
|
case CCSETPOINT: return tr("CC Set Point");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (role == Qt::FontRole){
|
||||||
|
return defaultModelFont();
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1044,7 @@ divedatapoint DivePlannerPointsModel::at(int row)
|
||||||
return divepoints.at(row);
|
return divepoints.at(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::removePoint(const QModelIndex& index)
|
void DivePlannerPointsModel::remove(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (index.column() != REMOVE)
|
if (index.column() != REMOVE)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public slots:
|
||||||
void setStartTime(const QTime& t);
|
void setStartTime(const QTime& t);
|
||||||
void setLastStop6m(bool value);
|
void setLastStop6m(bool value);
|
||||||
void createPlan();
|
void createPlan();
|
||||||
void removePoint(const QModelIndex& index);
|
void remove(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DivePlannerPointsModel(QObject* parent = 0);
|
explicit DivePlannerPointsModel(QObject* parent = 0);
|
||||||
|
@ -189,7 +189,6 @@ private:
|
||||||
|
|
||||||
class DivePlannerWidget : public QWidget {
|
class DivePlannerWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
void initialUiSetup();
|
|
||||||
public:
|
public:
|
||||||
explicit DivePlannerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
explicit DivePlannerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
|
@ -201,8 +200,6 @@ public slots:
|
||||||
void gflowChanged(const QString& gflow);
|
void gflowChanged(const QString& gflow);
|
||||||
void gfhighChanged(const QString& gfhigh);
|
void gfhighChanged(const QString& gfhigh);
|
||||||
void lastStopChanged(bool checked);
|
void lastStopChanged(bool checked);
|
||||||
protected:
|
|
||||||
virtual void hideEvent(QHideEvent* );
|
|
||||||
private:
|
private:
|
||||||
Ui::DivePlanner *ui;
|
Ui::DivePlanner *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="decoStopSAC"/>
|
<widget class="QLineEdit" name="decoStopSAC"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLineEdit" name="lowGF"/>
|
||||||
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -44,9 +47,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QLineEdit" name="lowGF"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -54,6 +54,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLineEdit" name="bottomSAC"/>
|
||||||
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -61,6 +64,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLineEdit" name="highGF"/>
|
||||||
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -68,12 +74,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLineEdit" name="bottomSAC"/>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QLineEdit" name="highGF"/>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QCheckBox" name="lastStop">
|
<widget class="QCheckBox" name="lastStop">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -81,9 +81,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
|
||||||
<widget class="QTableView" name="tablePoints"/>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
|
@ -91,8 +88,26 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="TableView" name="tableWidget" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>TableView</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>tableview.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QTextStream>
|
#include <QTableView>
|
||||||
#include <QFile>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
|
@ -66,37 +65,19 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
if (label)
|
if (label)
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignHCenter);
|
||||||
}
|
}
|
||||||
|
ui->cylinders->setTitle(tr("Cylinders"));
|
||||||
|
ui->cylinders->setBtnToolTip(tr("Add Cylinder"));
|
||||||
|
connect(ui->cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked()));
|
||||||
|
|
||||||
/*Thid couldn't be done on the ui file because element
|
ui->weights->setTitle(tr("Weights"));
|
||||||
is floating, instead of being fixed on the layout. */
|
ui->weights->setBtnToolTip(tr("Add Weight System"));
|
||||||
QIcon plusIcon(":plus");
|
connect(ui->weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked()));
|
||||||
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->cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
|
||||||
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
|
connect(ui->weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex)));
|
||||||
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
|
|
||||||
connect(ui->weights, SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex)));
|
|
||||||
|
|
||||||
QFontMetrics metrics(defaultModelFont());
|
ui->cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
||||||
|
ui->weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
|
||||||
ui->cylinders->horizontalHeader()->setResizeMode(CylindersModel::REMOVE, QHeaderView::Fixed);
|
|
||||||
ui->cylinders->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
|
|
||||||
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
|
||||||
|
|
||||||
ui->weights->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
|
||||||
ui->weights->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
|
|
||||||
ui->weights->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
|
|
||||||
|
|
||||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
|
||||||
|
|
||||||
completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui->buddy);
|
completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui->buddy);
|
||||||
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui->divemaster);
|
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui->divemaster);
|
||||||
|
@ -106,44 +87,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui->divemaster->setCompleter(completers.divemaster);
|
ui->divemaster->setCompleter(completers.divemaster);
|
||||||
ui->location->setCompleter(completers.location);
|
ui->location->setCompleter(completers.location);
|
||||||
ui->suit->setCompleter(completers.suit);
|
ui->suit->setCompleter(completers.suit);
|
||||||
|
|
||||||
QFile cssFile(":table-css");
|
|
||||||
cssFile.open(QIODevice::ReadOnly);
|
|
||||||
QTextStream reader(&cssFile);
|
|
||||||
QString css = reader.readAll();
|
|
||||||
|
|
||||||
ui->cylinders->setStyleSheet(css);
|
|
||||||
ui->weights->setStyleSheet(css);
|
|
||||||
initialUiSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to manually position the 'plus' on cylinder and weight.
|
|
||||||
void MainTab::resizeEvent(QResizeEvent* event)
|
|
||||||
{
|
|
||||||
equipmentPlusUpdate();
|
|
||||||
QTabWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainTab::showEvent(QShowEvent* event)
|
|
||||||
{
|
|
||||||
QTabWidget::showEvent(event);
|
|
||||||
equipmentPlusUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainTab::tabChanged(int idx)
|
|
||||||
{
|
|
||||||
/* if the current tab has become of index 1 (i.e. the equipment tab) call update
|
|
||||||
* for the plus signs */
|
|
||||||
if (idx == 1)
|
|
||||||
equipmentPlusUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainTab::equipmentPlusUpdate()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::enableEdition()
|
void MainTab::enableEdition()
|
||||||
|
@ -199,13 +142,12 @@ void MainTab::clearStats()
|
||||||
ui->timeLimits->clear();
|
ui->timeLimits->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UPDATE_TEXT(d, field) \
|
#define UPDATE_TEXT(d, field) \
|
||||||
if (!d || !d->field) \
|
if (!d || !d->field) \
|
||||||
ui->field->setText(""); \
|
ui->field->setText(""); \
|
||||||
else \
|
else \
|
||||||
ui->field->setText(d->field)
|
ui->field->setText(d->field)
|
||||||
|
|
||||||
|
|
||||||
void MainTab::updateDiveInfo(int dive)
|
void MainTab::updateDiveInfo(int dive)
|
||||||
{
|
{
|
||||||
// This method updates ALL tabs whenever a new dive or trip is
|
// This method updates ALL tabs whenever a new dive or trip is
|
||||||
|
@ -315,8 +257,6 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
ui->timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
|
ui->timeLimits->setMinimum(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);
|
||||||
|
@ -343,8 +283,6 @@ 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);
|
|
||||||
ui->depthLimits->clear();
|
ui->depthLimits->clear();
|
||||||
ui->sacLimits->clear();
|
ui->sacLimits->clear();
|
||||||
ui->divesAllText->clear();
|
ui->divesAllText->clear();
|
||||||
|
@ -530,56 +468,14 @@ void MainTab::on_visibility_valueChanged(int value)
|
||||||
currentDive->visibility = value;
|
currentDive->visibility = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::hideEvent(QHideEvent* event)
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup("MainTab");
|
|
||||||
s.beginGroup("Cylinders");
|
|
||||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
|
||||||
s.setValue(QString("colwidth%1").arg(i), ui->cylinders->columnWidth(i));
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
s.beginGroup("Weights");
|
|
||||||
for (int i = 0; i < WeightModel::COLUMNS; i++) {
|
|
||||||
s.setValue(QString("colwidth%1").arg(i), ui->weights->columnWidth(i));
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
s.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainTab::initialUiSetup()
|
|
||||||
{
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup("MainTab");
|
|
||||||
s.beginGroup("Cylinders");
|
|
||||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
|
||||||
QVariant width = s.value(QString("colwidth%1").arg(i));
|
|
||||||
if (width.isValid())
|
|
||||||
ui->cylinders->setColumnWidth(i, width.toInt());
|
|
||||||
else
|
|
||||||
ui->cylinders->resizeColumnToContents(i);
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
s.beginGroup("Weights");
|
|
||||||
for (int i = 0; i < WeightModel::COLUMNS; i++) {
|
|
||||||
QVariant width = s.value(QString("colwidth%1").arg(i));
|
|
||||||
if (width.isValid())
|
|
||||||
ui->weights->setColumnWidth(i, width.toInt());
|
|
||||||
else
|
|
||||||
ui->weights->resizeColumnToContents(i);
|
|
||||||
}
|
|
||||||
s.endGroup();
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainTab::editCylinderWidget(const QModelIndex& index)
|
void MainTab::editCylinderWidget(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (index.column() != CylindersModel::REMOVE)
|
if (index.isValid() && index.column() != CylindersModel::REMOVE)
|
||||||
ui->cylinders->edit(index);
|
ui->cylinders->edit(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::editWeigthWidget(const QModelIndex& index)
|
void MainTab::editWeigthWidget(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (index.column() != WeightModel::REMOVE)
|
if (index.isValid() && index.column() != WeightModel::REMOVE)
|
||||||
ui->weights->edit(index);
|
ui->weights->edit(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,9 @@ public:
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void clearEquipment();
|
void clearEquipment();
|
||||||
void reload();
|
void reload();
|
||||||
|
|
||||||
bool eventFilter(QObject* , QEvent*);
|
bool eventFilter(QObject* , QEvent*);
|
||||||
virtual void resizeEvent(QResizeEvent*);
|
|
||||||
virtual void showEvent(QShowEvent*);
|
|
||||||
virtual void hideEvent(QHideEvent* );
|
|
||||||
|
|
||||||
void initialUiSetup();
|
void initialUiSetup();
|
||||||
void equipmentPlusUpdate();
|
void equipmentPlusUpdate();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addCylinder_clicked();
|
void addCylinder_clicked();
|
||||||
void addWeight_clicked();
|
void addWeight_clicked();
|
||||||
|
@ -68,7 +61,6 @@ public slots:
|
||||||
void on_notes_textChanged();
|
void on_notes_textChanged();
|
||||||
void on_rating_valueChanged(int value);
|
void on_rating_valueChanged(int value);
|
||||||
void on_visibility_valueChanged(int value);
|
void on_visibility_valueChanged(int value);
|
||||||
void tabChanged(int idx);
|
|
||||||
void editCylinderWidget(const QModelIndex& index);
|
void editCylinderWidget(const QModelIndex& index);
|
||||||
void editWeigthWidget(const QModelIndex& index);
|
void editWeigthWidget(const QModelIndex& index);
|
||||||
|
|
||||||
|
@ -78,8 +70,6 @@ private:
|
||||||
CylindersModel *cylindersModel;
|
CylindersModel *cylindersModel;
|
||||||
NotesBackup notesBackup;
|
NotesBackup notesBackup;
|
||||||
struct dive* currentDive;
|
struct dive* currentDive;
|
||||||
QPushButton *addCylinder;
|
|
||||||
QPushButton *addWeight;
|
|
||||||
enum { NONE, DIVE, TRIP } editMode;
|
enum { NONE, DIVE, TRIP } editMode;
|
||||||
Completers completers;
|
Completers completers;
|
||||||
void enableEdition();
|
void enableEdition();
|
||||||
|
|
|
@ -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">
|
||||||
|
@ -147,53 +147,33 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter_2">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="orientation">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<enum>Qt::Vertical</enum>
|
<property name="spacing">
|
||||||
</property>
|
<number>0</number>
|
||||||
<widget class="QGroupBox" name="cylindersGroup">
|
|
||||||
<property name="title">
|
|
||||||
<string>Cylinders</string>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<property name="leftMargin">
|
||||||
<item>
|
<number>0</number>
|
||||||
<widget class="QTableView" name="cylinders">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="showGrid">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<attribute name="verticalHeaderVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QGroupBox" name="weightGroup">
|
|
||||||
<property name="title">
|
|
||||||
<string>Weight</string>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<property name="topMargin">
|
||||||
<item>
|
<number>0</number>
|
||||||
<widget class="QTableView" name="weights">
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="rightMargin">
|
||||||
<string notr="true"/>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="showGrid">
|
<property name="bottomMargin">
|
||||||
<bool>false</bool>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="verticalHeaderVisible">
|
<item>
|
||||||
<bool>false</bool>
|
<widget class="QSplitter" name="splitter">
|
||||||
</attribute>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Vertical</enum>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<widget class="TableView" name="cylinders" native="true"/>
|
||||||
</widget>
|
<widget class="TableView" name="weights" native="true"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -546,6 +526,12 @@
|
||||||
<header>simplewidgets.h</header>
|
<header>simplewidgets.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>TableView</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>tableview.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -326,8 +326,6 @@ void MainWindow::on_mainSplitter_splitterMoved(int pos, int idx)
|
||||||
|
|
||||||
void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx)
|
void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx)
|
||||||
{
|
{
|
||||||
/* always update the floating plus sign icons in the equipment tab */
|
|
||||||
ui->InfoWidget->equipmentPlusUpdate();
|
|
||||||
redrawProfile();
|
redrawProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue