summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp4
-rw-r--r--qt-ui/modeldelegates.cpp1
-rw-r--r--qt-ui/models.cpp34
-rw-r--r--qt-ui/models.h1
4 files changed, 31 insertions, 9 deletions
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..479f58582 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -549,7 +549,7 @@ bool WSInfoModel::insertRows(int row, int count, const QModelIndex& parent)
bool WSInfoModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
- struct ws_info *info = &ws_info[index.row()];
+ struct ws_info_t *info = &ws_info[index.row()];
switch(index.column()) {
case DESCRIPTION:
info->name = strdup(value.toByteArray().data());
@@ -577,7 +577,7 @@ QVariant WSInfoModel::data(const QModelIndex& index, int role) const
if (!index.isValid()) {
return ret;
}
- struct ws_info *info = &ws_info[index.row()];
+ struct ws_info_t *info = &ws_info[index.row()];
int gr = info->grams;
switch(role){
@@ -636,7 +636,25 @@ const QString& WSInfoModel::biggerString() const
WSInfoModel::WSInfoModel() : QAbstractTableModel(), rows(-1)
{
- struct ws_info *info = ws_info;
+ struct ws_info_t *info = ws_info;
+ 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::updateInfo()
+{
+ struct ws_info_t *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()){
@@ -657,7 +675,7 @@ void WSInfoModel::update()
endRemoveRows();
rows = -1;
}
- struct ws_info *info = ws_info;
+ struct ws_info_t *info = ws_info;
for (info = ws_info; info->name; info++, rows++);
if (rows > -1) {
@@ -687,7 +705,7 @@ bool TankInfoModel::insertRows(int row, int count, const QModelIndex& parent)
bool TankInfoModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
- struct tank_info *info = &tank_info[index.row()];
+ struct tank_info_t *info = &tank_info[index.row()];
switch(index.column()) {
case DESCRIPTION:
info->name = strdup(value.toByteArray().data());
@@ -722,7 +740,7 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
return defaultModelFont();
}
if (role == Qt::DisplayRole || role == Qt::EditRole) {
- struct tank_info *info = &tank_info[index.row()];
+ struct tank_info_t *info = &tank_info[index.row()];
int ml = info->ml;
double bar = (info->psi) ? psi_to_bar(info->psi) : info->bar;
@@ -779,7 +797,7 @@ int TankInfoModel::rowCount(const QModelIndex& parent) const
TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
{
- struct tank_info *info = tank_info;
+ struct tank_info_t *info = tank_info;
for (info = tank_info; info->name; info++, rows++){
QString infoName(info->name);
if (infoName.count() > biggerEntry.count()){
@@ -800,7 +818,7 @@ void TankInfoModel::update()
endRemoveRows();
rows = -1;
}
- struct tank_info *info = tank_info;
+ struct tank_info_t *info = tank_info;
for (info = tank_info; info->name; info++, rows++);
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;