Changeset 03e7710 in subsurface


Ignore:
Timestamp:
Jun 4, 2017, 7:11:01 AM (4 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
3775f45
Parents:
78ee3f4
git-author:
Tomaz Canabrava <tcanabrava@…> (06/04/17 05:40:25)
git-committer:
Dirk Hohndel <dirk@…> (06/04/17 07:11:01)
Message:

QML UI: show selection box on the Download from DC list

QML and C++ model don't interact too much, a new Rule
should be created and used on the QML

Signed-off-by: Tomaz Canabrava <tcanabrava@…>
Signed-off-by: Dirk Hohndel <dirk@…>

Files:
4 edited

Legend:

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

    r782caf5 r03e7710  
    117117                                duration: model.duration
    118118                                depth: model.depth
     119                                selected: model.selected
    119120
    120121                                backgroundColor: selectAll ? Kirigami.Theme.highlightColor : Kirigami.Theme.viewBackgroundColor
  • mobile-widgets/qml/DownloadedDiveDelegate.qml

    r1de1a85 r03e7710  
    1313        property string datetime
    1414        property string duration
     15        property bool selected
    1516
    1617        enabled: true
     
    3132                        NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 }
    3233                }
     34                CheckBox {
     35                        id: diveIsSelected
     36                        checked: innerListItem.selected;
     37                        width: childrenRect.heigh - Kirigami.Units.smallSpacing;
     38                        height: childrenRect.heigh - Kirigami.Units.smallSpacing;
     39                }
    3340                Item {
    3441                        id: diveListEntry
    35                         width: parent.width - Kirigami.Units.gridUnit * (innerListItem.deleteButtonVisible ? 3 : 1)
     42                        width: parent.width - diveIsSelected.width - Kirigami.Units.gridUnit * (innerListItem.deleteButtonVisible ? 3 : 1)
    3643                        height: childrenRect.height - Kirigami.Units.smallSpacing
    3744
  • qt-models/diveimportedmodel.cpp

    r52e07a6 r03e7710  
    6868        // widgets access the model via index.column(), qml via role.
    6969        int column = index.column();
    70         if (role == DateTime || role == Duration || role == Depth) {
     70        if (role >= DateTime) {
    7171                column = role - DateTime;
    7272                role = Qt::DisplayRole;
     
    8181                case 2:
    8282                        return QVariant(get_depth_string(d->maxdepth.mm, true, false));
     83                case 3:
     84                        return checkStates[index.row()];
    8385                }
    8486        }
     
    9395{
    9496        checkStates[clickedIndex.row()] = !checkStates[clickedIndex.row()];
    95         dataChanged(index(clickedIndex.row(), 0), index(clickedIndex.row(), 0), QVector<int>() << Qt::CheckStateRole);
     97        dataChanged(index(clickedIndex.row(), 0), index(clickedIndex.row(), 0), QVector<int>() << Qt::CheckStateRole << Selected);
    9698}
    9799
     
    99101{
    100102        memset(checkStates, true, lastIndex - firstIndex + 1);
    101         dataChanged(index(0, 0), index(lastIndex - firstIndex, 0), QVector<int>() << Qt::CheckStateRole);
     103        dataChanged(index(0, 0), index(lastIndex - firstIndex, 0), QVector<int>() << Qt::CheckStateRole << Selected);
    102104}
    103105
     
    105107{
    106108        checkStates[row] = !checkStates[row];
    107         dataChanged(index(row, 0), index(row, 0));
     109        dataChanged(index(row, 0), index(row, 0), QVector<int>() << Qt::CheckStateRole << Selected);
    108110}
    109111
     
    111113{
    112114        memset(checkStates, false, lastIndex - firstIndex + 1);
    113         dataChanged(index(0, 0), index(lastIndex - firstIndex,0 ), QVector<int>() << Qt::CheckStateRole);
     115        dataChanged(index(0, 0), index(lastIndex - firstIndex,0 ), QVector<int>() << Qt::CheckStateRole << Selected);
    114116}
    115117
     
    177179                { Depth, "depth"},
    178180                { Duration, "duration"},
     181                { Selected, "selected"}
    179182        };
    180183        return roles;
  • qt-models/diveimportedmodel.h

    r52e07a6 r03e7710  
    99        Q_OBJECT
    1010public:
    11         enum roleTypes { DateTime = Qt::UserRole + 1, Duration, Depth};
     11        enum roleTypes { DateTime = Qt::UserRole + 1, Duration, Depth, Selected};
    1212
    1313        DiveImportedModel(QObject *parent = 0);
Note: See TracChangeset for help on using the changeset viewer.