diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-01 14:30:34 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-01 14:43:07 -0700 |
commit | 04e59a0e1cdb32c5091fc4bc0d692f00821ab849 (patch) | |
tree | ed0c673ab4b680d236d67e961a28390fe31f0a5c /qt-ui | |
parent | 5c2ce0ac200cbf4b37a9765148b78d3091b5cd9f (diff) | |
download | subsurface-04e59a0e1cdb32c5091fc4bc0d692f00821ab849.tar.gz |
Hook up adding a weightsystem
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 17 | ||||
-rw-r--r-- | qt-ui/maintab.h | 3 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 6 | ||||
-rw-r--r-- | qt-ui/models.cpp | 16 | ||||
-rw-r--r-- | qt-ui/models.h | 2 |
5 files changed, 34 insertions, 10 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7d60db5c2..f8c69ed9c 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -83,6 +83,23 @@ void MainTab::on_delCylinder_clicked() { } +void MainTab::on_addWeight_clicked() +{ + /* this needs a dialog - right now we just fill in a dummy */ + weightsystem_t *newWeightsystem = (weightsystem_t *) malloc(sizeof(weightsystem_t)); + newWeightsystem->description = "Just testing"; + newWeightsystem->weight.grams = 15000; + weightModel->add(newWeightsystem); +} + +void MainTab::on_editWeight_clicked() +{ +} + +void MainTab::on_delWeight_clicked() +{ +} + void MainTab::reload() { cylindersModel->update(); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 44815fafc..cf83e0dfe 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -31,6 +31,9 @@ public Q_SLOTS: void on_addCylinder_clicked(); void on_editCylinder_clicked(); void on_delCylinder_clicked(); + void on_addWeight_clicked(); + void on_editWeight_clicked(); + void on_delWeight_clicked(); private: Ui::MainTab *ui; diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 7edbf5837..a99b0aed7 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -152,14 +152,14 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> - <widget class="QPushButton" name="pushButton_4"> + <widget class="QPushButton" name="editWeight"> <property name="text"> <string>Edit</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_5"> + <widget class="QPushButton" name="addWeight"> <property name="text"> <string>Add</string> </property> @@ -179,7 +179,7 @@ </spacer> </item> <item> - <widget class="QPushButton" name="pushButton_6"> + <widget class="QPushButton" name="delWeight"> <property name="text"> <string>Delete</string> </property> diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 4583c36cd..6756002e2 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -186,13 +186,15 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r return ret; } - switch(section) { - case TYPE: - ret = tr("Type"); - break; - case WEIGHT: - ret = tr("Weight"); - break; + if (role == Qt::DisplayRole) { + switch(section) { + case TYPE: + ret = tr("Type"); + break; + case WEIGHT: + ret = tr("Weight"); + break; + } } return ret; } diff --git a/qt-ui/models.h b/qt-ui/models.h index 46da9e51b..9a4602f18 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -56,6 +56,8 @@ private: /* Encapsulation of the Weight Model, that represents * the current weights on a dive. */ class WeightModel : public QAbstractTableModel { +Q_OBJECT +public: enum Column {TYPE, WEIGHT}; /*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; /*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const; |