Hook up adding a weightsystem

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-05-01 14:30:34 -07:00
parent 5c2ce0ac20
commit 04e59a0e1c
5 changed files with 34 additions and 10 deletions

View file

@ -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() void MainTab::reload()
{ {
cylindersModel->update(); cylindersModel->update();

View file

@ -31,6 +31,9 @@ public Q_SLOTS:
void on_addCylinder_clicked(); void on_addCylinder_clicked();
void on_editCylinder_clicked(); void on_editCylinder_clicked();
void on_delCylinder_clicked(); void on_delCylinder_clicked();
void on_addWeight_clicked();
void on_editWeight_clicked();
void on_delWeight_clicked();
private: private:
Ui::MainTab *ui; Ui::MainTab *ui;

View file

@ -152,14 +152,14 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QPushButton" name="pushButton_4"> <widget class="QPushButton" name="editWeight">
<property name="text"> <property name="text">
<string>Edit</string> <string>Edit</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_5"> <widget class="QPushButton" name="addWeight">
<property name="text"> <property name="text">
<string>Add</string> <string>Add</string>
</property> </property>
@ -179,7 +179,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_6"> <widget class="QPushButton" name="delWeight">
<property name="text"> <property name="text">
<string>Delete</string> <string>Delete</string>
</property> </property>

View file

@ -186,13 +186,15 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r
return ret; return ret;
} }
switch(section) { if (role == Qt::DisplayRole) {
case TYPE: switch(section) {
ret = tr("Type"); case TYPE:
break; ret = tr("Type");
case WEIGHT: break;
ret = tr("Weight"); case WEIGHT:
break; ret = tr("Weight");
break;
}
} }
return ret; return ret;
} }

View file

@ -56,6 +56,8 @@ private:
/* Encapsulation of the Weight Model, that represents /* Encapsulation of the Weight Model, that represents
* the current weights on a dive. */ * the current weights on a dive. */
class WeightModel : public QAbstractTableModel { class WeightModel : public QAbstractTableModel {
Q_OBJECT
public:
enum Column {TYPE, WEIGHT}; enum Column {TYPE, WEIGHT};
/*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;