diff options
-rw-r--r-- | equipment.c | 12 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 4 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 1 | ||||
-rw-r--r-- | qt-ui/models.cpp | 18 | ||||
-rw-r--r-- | qt-ui/models.h | 1 |
5 files changed, 34 insertions, 2 deletions
diff --git a/equipment.c b/equipment.c index cd3984c86..b9001a85c 100644 --- a/equipment.c +++ b/equipment.c @@ -473,11 +473,21 @@ void add_cylinder_description(cylinder_type_t *type) void add_weightsystem_description(weightsystem_t *weightsystem) { const char *desc; + int i; desc = weightsystem->description; if (!desc) return; - /* now do something with it... */ + for (i = 0; i < 100 && ws_info[i].name != NULL; i++) { + if (strcmp(ws_info[i].name, desc) == 0) { + ws_info[i].grams = weightsystem->weight.grams; + return; + } + } + if (i < 100) { + ws_info[i].name = desc; + ws_info[i].grams = weightsystem->weight.grams; + } } #endif /* USE_GTK_UI */ diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4eead9616..f2f95897a 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -744,6 +744,8 @@ void MainWindow::importFiles(const QStringList fileNames) ui->globe->reload(); ui->ListWidget->reload(DiveTripModel::TREE); ui->ListWidget->setFocus(); + WSInfoModel *wsim = WSInfoModel::instance(); + wsim->updateInfo(); } void MainWindow::loadFiles(const QStringList fileNames) @@ -769,4 +771,6 @@ void MainWindow::loadFiles(const QStringList fileNames) ui->globe->reload(); ui->ListWidget->reload(DiveTripModel::TREE); ui->ListWidget->setFocus(); + WSInfoModel *wsim = WSInfoModel::instance(); + wsim->updateInfo(); } diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 3549625f3..13201e436 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -238,7 +238,6 @@ void WSInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, co } mymodel->setData(IDX(WeightModel::TYPE), v, Qt::EditRole); mymodel->passInData(IDX(WeightModel::WEIGHT), grams); - qDebug() << "Fixme, every weight is 0.0 grams. see:" << grams; } WSInfoDelegate::WSInfoDelegate(QObject* parent): ComboBoxDelegate(WSInfoModel::instance(), parent) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 25429154f..1e5f15f0c 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -650,6 +650,24 @@ WSInfoModel::WSInfoModel() : QAbstractTableModel(), rows(-1) } } +void WSInfoModel::updateInfo() +{ + struct ws_info *info = ws_info; + beginRemoveRows(QModelIndex(), 0, this->rows); + endRemoveRows(); + for (info = ws_info; info->name; info++, rows++){ + QString wsInfoName(info->name); + if( wsInfoName.count() > biggerEntry.count()){ + biggerEntry = wsInfoName; + } + } + + if (rows > -1) { + beginInsertRows(QModelIndex(), 0, rows); + endInsertRows(); + } +} + void WSInfoModel::update() { if (rows > -1) { diff --git a/qt-ui/models.h b/qt-ui/models.h index 22cfe4b7e..c60856478 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -59,6 +59,7 @@ public: const QString& biggerString() const; void clear(); void update(); + void updateInfo(); private: int rows; QString biggerEntry; |