summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-22 12:14:06 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-22 12:14:06 -0700
commit63b6f7d5a25967f003a734d2058a73b4b13e8387 (patch)
tree0f5d68199afacaa04bd2bac7029fc08e42db18c5 /qt-ui/models.cpp
parent9c3b512701c59955350f317eb6d19e6fdc93f546 (diff)
parent134e20bdc27f63c73ef8257dc357ae05642fece8 (diff)
downloadsubsurface-63b6f7d5a25967f003a734d2058a73b4b13e8387.tar.gz
Merge branch 'comboBoxDelegate' of https://github.com/tcanabrava/subsurface
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index ee1ae78ac..3bbc79f72 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -67,7 +67,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
cylinder_t *cyl = &current->cylinder[index.row()];
- if (role == Qt::DisplayRole) {
+ if (role == Qt::DisplayRole || role==Qt::EditRole) {
switch(index.column()) {
case TYPE:
ret = QString(cyl->type.description);
@@ -160,7 +160,7 @@ int CylindersModel::rowCount(const QModelIndex& parent) const
return rows;
}
-void CylindersModel::add(cylinder_t* cyl)
+void CylindersModel::add()
{
if (rows >= MAX_CYLINDERS) {
return;
@@ -168,14 +168,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();
@@ -266,7 +258,7 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
weightsystem_t *ws = &current_dive->weightsystem[index.row()];
- if (role == Qt::DisplayRole) {
+ if (role == Qt::DisplayRole || role == Qt::EditRole) {
switch(index.column()) {
case TYPE:
ret = QString(ws->description);
@@ -331,18 +323,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 = &current->weightsystem[row];
-
- ws->description = weight->description;
- ws->weight.grams = weight->weight.grams;
-
beginInsertRows(QModelIndex(), row, row);
rows++;
endInsertRows();