Changeset 3f0d210 in subsurface


Ignore:
Timestamp:
May 28, 2017, 11:54:33 AM (6 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
8d42d33
Parents:
84b1b63
git-author:
Dirk Hohndel <dirk@…> (05/28/17 11:48:30)
git-committer:
Dirk Hohndel <dirk@…> (05/28/17 11:54:33)
Message:

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@…>

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mobile-widgets/qml/DownloadFromDiveComputer.qml

    r057f46f r3f0d210  
    124124                                enabled: false
    125125                                onClicked: {
    126                                         manager.appendTextToLog("Save downloaded dives")
    127                                         for (var i = 0; i < importModel.rowCount(); i++) {
    128                                                 // figure out which ones are selected
    129                                                 // save the selected dive to the diveTable
    130                                         }
     126                                        manager.appendTextToLog("Save downloaded dives that were selected")
     127                                        importModel.recordDives()
     128                                        manager.saveChangesLocal()
     129                                        diveModel.clear()
     130                                        diveModel.addAllDives()
    131131                                        stackView.pop();
    132132                                }
  • qt-models/diveimportedmodel.cpp

    r38e24512 r3f0d210  
    144144}
    145145
     146void DiveImportedModel::recordDives()
     147{
     148        for (int i = 0; i < rowCount(); i++) {
     149                if (diveTable->dives[i] && checkStates[i]) {
     150                        record_dive(diveTable->dives[i]);
     151                        diveTable->dives[i] = NULL;
     152                }
     153        }
     154        diveTable->nr = 0;
     155}
     156
    146157QHash<int, QByteArray> DiveImportedModel::roleNames() const {
    147158        static QHash<int, QByteArray> roles = {
  • qt-models/diveimportedmodel.h

    r38e24512 r3f0d210  
    2222        QHash<int, QByteArray> roleNames() const;
    2323        Q_INVOKABLE void repopulate();
     24        Q_INVOKABLE void recordDives();
    2425public
    2526slots:
  • qt-models/divelistmodel.cpp

    r5372f12 r3f0d210  
    2424        }
    2525        return -1;
     26}
     27
     28void DiveListSortModel::clear()
     29{
     30        DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
     31        mySourceModel->clear();
     32}
     33
     34void DiveListSortModel::addAllDives()
     35{
     36        DiveListModel *mySourceModel = qobject_cast<DiveListModel *>(sourceModel());
     37        mySourceModel->addAllDives();
    2638}
    2739
  • qt-models/divelistmodel.h

    r5372f12 r3f0d210  
    1515public:
    1616        DiveListSortModel(QObject *parent = 0);
     17        Q_INVOKABLE void addAllDives();
     18        Q_INVOKABLE void clear();
    1719public slots:
    1820        int getDiveId(int idx);
Note: See TracChangeset for help on using the changeset viewer.