mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
QML UI: add downloaded dives to dive list
This already takes into account which of those dives were selected. Right now all we have is select all or none - this needs actual support in the UI, but once that's there, it will just work (famous last words). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
84b1b63d46
commit
3f0d21046e
5 changed files with 31 additions and 5 deletions
|
@ -123,11 +123,11 @@ Kirigami.Page {
|
|||
text: qsTr("Accept")
|
||||
enabled: false
|
||||
onClicked: {
|
||||
manager.appendTextToLog("Save downloaded dives")
|
||||
for (var i = 0; i < importModel.rowCount(); i++) {
|
||||
// figure out which ones are selected
|
||||
// save the selected dive to the diveTable
|
||||
}
|
||||
manager.appendTextToLog("Save downloaded dives that were selected")
|
||||
importModel.recordDives()
|
||||
manager.saveChangesLocal()
|
||||
diveModel.clear()
|
||||
diveModel.addAllDives()
|
||||
stackView.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,6 +143,17 @@ void DiveImportedModel::repopulate()
|
|||
setImportedDivesIndexes(0, diveTable->nr-1);
|
||||
}
|
||||
|
||||
void DiveImportedModel::recordDives()
|
||||
{
|
||||
for (int i = 0; i < rowCount(); i++) {
|
||||
if (diveTable->dives[i] && checkStates[i]) {
|
||||
record_dive(diveTable->dives[i]);
|
||||
diveTable->dives[i] = NULL;
|
||||
}
|
||||
}
|
||||
diveTable->nr = 0;
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
|
||||
static QHash<int, QByteArray> roles = {
|
||||
{ DateTime, "datetime"},
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
void clearTable();
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
Q_INVOKABLE void repopulate();
|
||||
Q_INVOKABLE void recordDives();
|
||||
public
|
||||
slots:
|
||||
void changeSelected(QModelIndex clickedIndex);
|
||||
|
|
|
@ -25,6 +25,18 @@ int DiveListSortModel::getIdxForId(int id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void DiveListSortModel::clear()
|
||||
{
|
||||
DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
|
||||
mySourceModel->clear();
|
||||
}
|
||||
|
||||
void DiveListSortModel::addAllDives()
|
||||
{
|
||||
DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
|
||||
mySourceModel->addAllDives();
|
||||
}
|
||||
|
||||
DiveListModel *DiveListModel::m_instance = NULL;
|
||||
|
||||
DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent)
|
||||
|
|
|
@ -14,6 +14,8 @@ class DiveListSortModel : public QSortFilterProxyModel
|
|||
Q_OBJECT
|
||||
public:
|
||||
DiveListSortModel(QObject *parent = 0);
|
||||
Q_INVOKABLE void addAllDives();
|
||||
Q_INVOKABLE void clear();
|
||||
public slots:
|
||||
int getDiveId(int idx);
|
||||
int getIdxForId(int id);
|
||||
|
|
Loading…
Reference in a new issue