mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Show extra data in separate tab on MainTab
This way any extra data probided by the dive computer is visible to the user (without other processing). This data cannot be edited by the user as it reflects the information given by the dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4ccddf95d7
commit
45251ec724
5 changed files with 149 additions and 8 deletions
|
@ -32,6 +32,7 @@
|
||||||
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
weightModel(new WeightModel(this)),
|
weightModel(new WeightModel(this)),
|
||||||
cylindersModel(CylindersModel::instance()),
|
cylindersModel(CylindersModel::instance()),
|
||||||
|
extraDataModel(new ExtraDataModel(this)),
|
||||||
editMode(NONE),
|
editMode(NONE),
|
||||||
divePictureModel(DivePictureModel::instance()),
|
divePictureModel(DivePictureModel::instance()),
|
||||||
currentTrip(0),
|
currentTrip(0),
|
||||||
|
@ -47,6 +48,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui.weights->setModel(weightModel);
|
ui.weights->setModel(weightModel);
|
||||||
ui.photosView->setModel(divePictureModel);
|
ui.photosView->setModel(divePictureModel);
|
||||||
connect(ui.photosView, SIGNAL(photoDoubleClicked(QString)), this, SLOT(photoDoubleClicked(QString)));
|
connect(ui.photosView, SIGNAL(photoDoubleClicked(QString)), this, SLOT(photoDoubleClicked(QString)));
|
||||||
|
ui.extraData->setModel(extraDataModel);
|
||||||
closeMessage();
|
closeMessage();
|
||||||
|
|
||||||
QAction *action = new QAction(tr("Save"), this);
|
QAction *action = new QAction(tr("Save"), this);
|
||||||
|
@ -473,6 +475,7 @@ void MainTab::updateDiveInfo(bool clear)
|
||||||
ui.equipmentTab->setEnabled(true);
|
ui.equipmentTab->setEnabled(true);
|
||||||
cylindersModel->updateDive();
|
cylindersModel->updateDive();
|
||||||
weightModel->updateDive();
|
weightModel->updateDive();
|
||||||
|
extraDataModel->updateDive();
|
||||||
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
|
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
|
||||||
ui.tagWidget->setText(QString(buf));
|
ui.tagWidget->setText(QString(buf));
|
||||||
}
|
}
|
||||||
|
@ -899,6 +902,7 @@ void MainTab::rejectChanges()
|
||||||
weightModel->changed = false;
|
weightModel->changed = false;
|
||||||
cylindersModel->updateDive();
|
cylindersModel->updateDive();
|
||||||
weightModel->updateDive();
|
weightModel->updateDive();
|
||||||
|
extraDataModel->updateDive();
|
||||||
}
|
}
|
||||||
#undef EDIT_TEXT2
|
#undef EDIT_TEXT2
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
class WeightModel;
|
class WeightModel;
|
||||||
class CylindersModel;
|
class CylindersModel;
|
||||||
|
class ExtraDataModel;
|
||||||
class QCompleter;
|
class QCompleter;
|
||||||
|
|
||||||
struct Completers {
|
struct Completers {
|
||||||
|
@ -94,6 +95,7 @@ private:
|
||||||
Ui::MainTab ui;
|
Ui::MainTab ui;
|
||||||
WeightModel *weightModel;
|
WeightModel *weightModel;
|
||||||
CylindersModel *cylindersModel;
|
CylindersModel *cylindersModel;
|
||||||
|
ExtraDataModel *extraDataModel;
|
||||||
EditMode editMode;
|
EditMode editMode;
|
||||||
BuddyCompletionModel buddyModel;
|
BuddyCompletionModel buddyModel;
|
||||||
DiveMasterCompletionModel diveMasterModel;
|
DiveMasterCompletionModel diveMasterModel;
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>662</width>
|
<width>668</width>
|
||||||
<height>642</height>
|
<height>658</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
@ -336,8 +336,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>662</width>
|
<width>100</width>
|
||||||
<height>642</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
@ -416,8 +416,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>662</width>
|
<width>668</width>
|
||||||
<height>642</height>
|
<height>658</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
@ -745,8 +745,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>662</width>
|
<width>342</width>
|
||||||
<height>642</height>
|
<height>167</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_7">
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
@ -953,6 +953,57 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Extra data</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>341</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Additional data from dive computer</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QScrollArea" name="scrollArea_5">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>661</width>
|
||||||
|
<height>641</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents_5">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>659</width>
|
||||||
|
<height>639</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QTableView" name="extraData">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>641</width>
|
||||||
|
<height>621</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -2660,3 +2660,69 @@ void MultiFilterSortModel::removeFilterModel(MultiFilterInterface *model)
|
||||||
models.removeAll(model);
|
models.removeAll(model);
|
||||||
disconnect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
|
disconnect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent),
|
||||||
|
rows(0)
|
||||||
|
{
|
||||||
|
//enum Column {KEY, VALUE};
|
||||||
|
setHeaderDataStrings(QStringList() << tr("Key") << tr("Value"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtraDataModel::clear()
|
||||||
|
{
|
||||||
|
if (rows > 0) {
|
||||||
|
beginRemoveRows(QModelIndex(), 0, rows - 1);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ExtraDataModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
QVariant ret;
|
||||||
|
struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
|
||||||
|
int i = -1;
|
||||||
|
while (ed && ++i < index.row())
|
||||||
|
ed = ed->next;
|
||||||
|
if (!ed)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case Qt::FontRole:
|
||||||
|
ret = defaultModelFont();
|
||||||
|
break;
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
ret = int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
break;
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
switch (index.column()) {
|
||||||
|
case KEY:
|
||||||
|
ret = QString(ed->key);
|
||||||
|
break;
|
||||||
|
case VALUE:
|
||||||
|
ret = QString(ed->value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ExtraDataModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtraDataModel::updateDive()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
rows = 0;
|
||||||
|
struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
|
||||||
|
while (ed) {
|
||||||
|
rows++;
|
||||||
|
ed = ed->next;
|
||||||
|
}
|
||||||
|
if (rows > 0) {
|
||||||
|
beginInsertRows(QModelIndex(), 0, rows - 1);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -165,6 +165,24 @@ private:
|
||||||
int rows;
|
int rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* extra data model for additional dive computer data */
|
||||||
|
class ExtraDataModel : public CleanerTableModel {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum Column {
|
||||||
|
KEY,
|
||||||
|
VALUE
|
||||||
|
};
|
||||||
|
explicit ExtraDataModel(QObject *parent = 0);
|
||||||
|
/*reimp*/ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
/*reimp*/ int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void updateDive();
|
||||||
|
private:
|
||||||
|
int rows;
|
||||||
|
};
|
||||||
|
|
||||||
/*! An AbstractItemModel for recording dive trip information such as a list of dives.
|
/*! An AbstractItemModel for recording dive trip information such as a list of dives.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue