From 3e51476d8757752ccfa908d54b4f2425d908c839 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 22 May 2013 14:25:37 -0300 Subject: Removed unused debug, and set the correct data on the delegates. Signed-off-by: Tomaz Canabrava --- qt-ui/models.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qt-ui/models.cpp') diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 360058dfd..78763d11b 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -66,7 +66,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const cylinder_t *cyl = ¤t->cylinder[index.row()]; - if (role == Qt::DisplayRole) { + if (role == Qt::DisplayRole || role==Qt::EditRole) { switch(index.column()) { case TYPE: ret = QString(cyl->type.description); @@ -261,7 +261,7 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const weightsystem_t *ws = ¤t_dive->weightsystem[index.row()]; - if (role == Qt::DisplayRole) { + if (role == Qt::DisplayRole || role == Qt::EditRole) { switch(index.column()) { case TYPE: ret = QString(ws->description); -- cgit v1.2.3-70-g09d2 From 134e20bdc27f63c73ef8257dc357ae05642fece8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 22 May 2013 14:52:38 -0300 Subject: Removed the unused add cylinder and add weigthsystem dialogs. Signed-off-by: Tomaz Canabrava --- Makefile | 4 - qt-ui/addcylinderdialog.cpp | 56 -------- qt-ui/addcylinderdialog.h | 33 ----- qt-ui/addcylinderdialog.ui | 303 ---------------------------------------- qt-ui/addweightsystemdialog.cpp | 39 ------ qt-ui/addweightsystemdialog.h | 30 ---- qt-ui/addweightsystemdialog.ui | 109 --------------- qt-ui/maintab.cpp | 34 +---- qt-ui/models.cpp | 18 +-- qt-ui/models.h | 4 +- 10 files changed, 6 insertions(+), 624 deletions(-) delete mode 100644 qt-ui/addcylinderdialog.cpp delete mode 100644 qt-ui/addcylinderdialog.h delete mode 100644 qt-ui/addcylinderdialog.ui delete mode 100644 qt-ui/addweightsystemdialog.cpp delete mode 100644 qt-ui/addweightsystemdialog.h delete mode 100644 qt-ui/addweightsystemdialog.ui (limited to 'qt-ui/models.cpp') diff --git a/Makefile b/Makefile index 9b0e2ba9c..1cc26a007 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,6 @@ EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) HEADERS = \ - qt-ui/addcylinderdialog.h \ - qt-ui/addweightsystemdialog.h \ qt-ui/divelistview.h \ qt-ui/maintab.h \ qt-ui/mainwindow.h \ @@ -66,8 +64,6 @@ SOURCES = \ time.c \ libdivecomputer.c \ qt-gui.cpp \ - qt-ui/addcylinderdialog.cpp \ - qt-ui/addweightsystemdialog.cpp \ qt-ui/divelistview.cpp \ qt-ui/maintab.cpp \ qt-ui/mainwindow.cpp \ diff --git a/qt-ui/addcylinderdialog.cpp b/qt-ui/addcylinderdialog.cpp deleted file mode 100644 index 5b91617ed..000000000 --- a/qt-ui/addcylinderdialog.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * addcylinderdialog.cpp - * - * classes for the add cylinder dialog of Subsurface - * - */ -#include "addcylinderdialog.h" -#include "ui_addcylinderdialog.h" -#include -#include -#include "../conversions.h" -#include "models.h" - -AddCylinderDialog::AddCylinderDialog(QWidget *parent) : ui(new Ui::AddCylinderDialog()) -, tankInfoModel(new TankInfoModel()) -{ - ui->setupUi(this); - ui->cylinderType->setModel(tankInfoModel); -} - -void AddCylinderDialog::setCylinder(cylinder_t *cylinder) -{ - double volume, pressure; - int index; - - currentCylinder = cylinder; - convert_volume_pressure(cylinder->type.size.mliter, cylinder->type.workingpressure.mbar, &volume, &pressure); - - index = ui->cylinderType->findText(QString(cylinder->type.description)); - ui->cylinderType->setCurrentIndex(index); - ui->size->setValue(volume); - ui->pressure->setValue(pressure); - - ui->o2percent->setValue(cylinder->gasmix.o2.permille / 10.0); - ui->hepercent->setValue(cylinder->gasmix.he.permille / 10.0); - - convert_pressure(cylinder->start.mbar, &pressure); - ui->start->setValue(pressure); - - convert_pressure(cylinder->end.mbar, &pressure); - ui->end->setValue(pressure); -} - -void AddCylinderDialog::updateCylinder() -{ - QByteArray description = ui->cylinderType->currentText().toLocal8Bit(); - - currentCylinder->type.description = description.data(); - currentCylinder->type.size.mliter = ui->size->value(); - currentCylinder->type.workingpressure.mbar = ui->pressure->value(); - currentCylinder->gasmix.o2.permille = ui->o2percent->value(); - currentCylinder->gasmix.he.permille = ui->hepercent->value(); - currentCylinder->start.mbar = ui->start->value(); - currentCylinder->end.mbar = ui->end->value(); -} - diff --git a/qt-ui/addcylinderdialog.h b/qt-ui/addcylinderdialog.h deleted file mode 100644 index fc68faa72..000000000 --- a/qt-ui/addcylinderdialog.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * addcylinderdialog.h - * - * header file for the add cylinder dialog of Subsurface - * - */ -#ifndef ADDCYLINDERDIALOG_H -#define ADDCYLINDERDIALOG_H - -#include -#include "../dive.h" - -namespace Ui{ - class AddCylinderDialog; -} - -class TankInfoModel; - -class AddCylinderDialog : public QDialog{ - Q_OBJECT -public: - explicit AddCylinderDialog(QWidget* parent = 0); - void setCylinder(cylinder_t *cylinder); - void updateCylinder(); - -private: - Ui::AddCylinderDialog *ui; - cylinder_t *currentCylinder; - TankInfoModel *tankInfoModel; -}; - - -#endif diff --git a/qt-ui/addcylinderdialog.ui b/qt-ui/addcylinderdialog.ui deleted file mode 100644 index 8bb0428b7..000000000 --- a/qt-ui/addcylinderdialog.ui +++ /dev/null @@ -1,303 +0,0 @@ - - - AddCylinderDialog - - - - 0 - 0 - 408 - 298 - - - - Dialog - - - - - - Cylinder - - - - QFormLayout::ExpandingFieldsGrow - - - - - Type - - - - - - - - 0 - 0 - - - - - - - - Size - - - - - - - - 0 - 0 - - - - - - - - Pressure - - - - - - - - 0 - 0 - - - - - - - - - - - Pressure - - - - - - Start - - - - - - - End - - - - - - - false - - - - 0 - 0 - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - - - - - - - - - Gas Mix - - - - - - O2% - - - - - - - false - - - - 0 - 0 - - - - - - - - He% - - - - - - - false - - - - 0 - 0 - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - AddCylinderDialog - accept() - - - 248 - 269 - - - 157 - 260 - - - - - buttonBox - rejected() - AddCylinderDialog - reject() - - - 290 - 269 - - - 286 - 260 - - - - - checkBox - clicked(bool) - start - setEnabled(bool) - - - 216 - 46 - - - 280 - 66 - - - - - checkBox - clicked(bool) - end - setEnabled(bool) - - - 226 - 48 - - - 268 - 100 - - - - - checkBox_2 - clicked(bool) - o2percent - setEnabled(bool) - - - 214 - 165 - - - 260 - 190 - - - - - checkBox_2 - clicked(bool) - hepercent - setEnabled(bool) - - - 228 - 165 - - - 262 - 216 - - - - - diff --git a/qt-ui/addweightsystemdialog.cpp b/qt-ui/addweightsystemdialog.cpp deleted file mode 100644 index 48a399de9..000000000 --- a/qt-ui/addweightsystemdialog.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * addweightsystemdialog.cpp - * - * classes for the add weightsystem dialog of Subsurface - * - */ -#include "addweightsystemdialog.h" -#include "ui_addweightsystemdialog.h" -#include -#include -#include "../conversions.h" -#include "models.h" - -AddWeightsystemDialog::AddWeightsystemDialog(QWidget *parent) : ui(new Ui::AddWeightsystemDialog()) -{ - ui->setupUi(this); - currentWeightsystem = NULL; -} - -void AddWeightsystemDialog::setWeightsystem(weightsystem_t *ws) -{ - currentWeightsystem = ws; - - ui->description->insert(QString(ws->description)); - if (get_units()->weight == units::KG) - ui->weight->setValue(ws->weight.grams / 1000); - else - ui->weight->setValue(grams_to_lbs(ws->weight.grams)); -} - -void AddWeightsystemDialog::updateWeightsystem() -{ - currentWeightsystem->description = strdup(ui->description->text().toUtf8().data()); - if (get_units()->weight == units::KG) - currentWeightsystem->weight.grams = ui->weight->value() * 1000; - else - currentWeightsystem->weight.grams = lbs_to_grams(ui->weight->value()); -} - diff --git a/qt-ui/addweightsystemdialog.h b/qt-ui/addweightsystemdialog.h deleted file mode 100644 index e99dc08d8..000000000 --- a/qt-ui/addweightsystemdialog.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * addweightsystemdialog.h - * - * header file for the add weightsystem dialog of Subsurface - * - */ -#ifndef ADDWEIGHTSYSTEMDIALOG_H -#define ADDWEIGHTSYSTEMDIALOG_H - -#include -#include "../dive.h" - -namespace Ui{ - class AddWeightsystemDialog; -} - -class AddWeightsystemDialog : public QDialog{ - Q_OBJECT -public: - explicit AddWeightsystemDialog(QWidget* parent = 0); - void setWeightsystem(weightsystem_t *ws); - void updateWeightsystem(); - -private: - Ui::AddWeightsystemDialog *ui; - weightsystem_t *currentWeightsystem; -}; - - -#endif diff --git a/qt-ui/addweightsystemdialog.ui b/qt-ui/addweightsystemdialog.ui deleted file mode 100644 index 11e60d562..000000000 --- a/qt-ui/addweightsystemdialog.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - AddWeightsystemDialog - - - - 0 - 0 - 408 - 186 - - - - Dialog - - - - - - Weightsystem - - - - QFormLayout::ExpandingFieldsGrow - - - - - Description - - - - - - - Weight - - - - - - - - 0 - 0 - - - - Qt::ImhFormattedNumbersOnly - - - true - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - AddWeightsystemDialog - accept() - - - 248 - 269 - - - 157 - 260 - - - - - buttonBox - rejected() - AddWeightsystemDialog - reject() - - - 290 - 269 - - - 286 - 260 - - - - - diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index c172deeea..4be27426c 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -6,8 +6,6 @@ */ #include "maintab.h" #include "ui_maintab.h" -#include "addcylinderdialog.h" -#include "addweightsystemdialog.h" #include "mainwindow.h" #include "../helpers.h" #include "../statistics.h" @@ -290,21 +288,7 @@ void MainTab::updateDiveInfo(int dive) void MainTab::addCylinder_clicked() { - if (cylindersModel->rowCount() >= MAX_CYLINDERS) - return; - - AddCylinderDialog dialog(this); - cylinder_t newCylinder; - newCylinder.type.description = ""; - - dialog.setCylinder(&newCylinder); - int result = dialog.exec(); - if (result == QDialog::Rejected) { - return; - } - - dialog.updateCylinder(); - cylindersModel->add(&newCylinder); + cylindersModel->add(); } void MainTab::on_editCylinder_clicked() @@ -317,21 +301,7 @@ void MainTab::on_delCylinder_clicked() void MainTab::addWeight_clicked() { - if (weightModel->rowCount() >= MAX_WEIGHTSYSTEMS) - return; - - AddWeightsystemDialog dialog(this); - weightsystem_t newWeightsystem; - newWeightsystem.description = ""; - newWeightsystem.weight.grams = 0; - - dialog.setWeightsystem(&newWeightsystem); - int result = dialog.exec(); - if (result == QDialog::Rejected) - return; - - dialog.updateWeightsystem(); - weightModel->add(&newWeightsystem); + weightModel->add(); } void MainTab::on_editWeight_clicked() diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 78763d11b..51e6f6d49 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -159,7 +159,7 @@ int CylindersModel::rowCount(const QModelIndex& parent) const return rows; } -void CylindersModel::add(cylinder_t* cyl) +void CylindersModel::add() { if (rows >= MAX_CYLINDERS) { return; @@ -167,14 +167,6 @@ void CylindersModel::add(cylinder_t* cyl) int row = rows; - cylinder_t& cylinder = current->cylinder[row]; - - cylinder.end.mbar = cyl->end.mbar; - cylinder.start.mbar = cyl->start.mbar; - cylinder.type.description = strdup(cyl->type.description); - cylinder.type.size = cyl->type.size; - cylinder.type.workingpressure = cyl->type.workingpressure; - beginInsertRows(QModelIndex(), row, row); rows++; endInsertRows(); @@ -326,18 +318,12 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r return ret; } -void WeightModel::add(weightsystem_t* weight) +void WeightModel::add() { if (rows >= MAX_WEIGHTSYSTEMS) return; int row = rows; - - weightsystem_t *ws = ¤t->weightsystem[row]; - - ws->description = weight->description; - ws->weight.grams = weight->weight.grams; - beginInsertRows(QModelIndex(), row, row); rows++; endInsertRows(); diff --git a/qt-ui/models.h b/qt-ui/models.h index ded612bb9..b207ff0fd 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -48,7 +48,7 @@ public: /*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(); void clear(); void update(); void setDive(struct dive *d); @@ -73,7 +73,7 @@ public: /*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(); void clear(); void update(); void setDive(struct dive *d); -- cgit v1.2.3-70-g09d2