on xenial help sign in
We have an isRoot property in departments now
a277802Albert Astals
qml/Dash/DashDepartmentsList.qml+3−4
@@ -25,7 +25,6 @@ Item {
25 signal allDepartmentClicked()
25 signal allDepartmentClicked()
26
26
27 readonly property int itemHeight: units.gu(5)
27 readonly property int itemHeight: units.gu(5)
28− readonly property bool isRoot: department && department.departmentId == ""
29 implicitHeight: flickable.contentHeight
28 implicitHeight: flickable.contentHeight
30
29
31 Rectangle {
30 Rectangle {
@@ -52,14 +51,14 @@ Item {
52
51
53 anchors.fill: parent
52 anchors.fill: parent
54
53
55− readonly property int nItems: department && department.loaded ? (department.count + (isRoot ? 0 : 2)) : 0
54+ readonly property int nItems: department && department.loaded ? (department.count + (department.isRoot ? 0 : 2)) : 0
56 contentHeight: nItems * root.itemHeight
55 contentHeight: nItems * root.itemHeight
57 contentWidth: width
56 contentWidth: width
58
57
59 AbstractButton {
58 AbstractButton {
60 id: backButton
59 id: backButton
61 width: parent.width
60 width: parent.width
62− visible: department && !isRoot
61+ visible: department && !department.isRoot
63 height: itemHeight
62 height: itemHeight
64
63
65 onClicked: root.goBackToParentClicked();
64 onClicked: root.goBackToParentClicked();
@@ -129,7 +128,7 @@ Item {
129 delegate: AbstractButton {
128 delegate: AbstractButton {
130 height: root.itemHeight
129 height: root.itemHeight
131 width: root.width
130 width: root.width
132− y: ((isRoot ? 0 : 2) + index) * root.itemHeight
131+ y: ((department.isRoot ? 0 : 2) + index) * root.itemHeight
133
132
134 onClicked: root.enterDepartment(departmentId, hasChildren)
133 onClicked: root.enterDepartment(departmentId, hasChildren)
135
134
tests/mocks/Unity/fake_department.cpp+5
@@ -75,6 +75,11 @@ int Department::count() const
75 return rowCount();
75 return rowCount();
76}
76}
77
77
78+bool Department::isRoot() const
79+{
80+ return m_departmentId == "root";
81+}
82+
78int Department::rowCount(const QModelIndex & /*parent*/) const
83int Department::rowCount(const QModelIndex & /*parent*/) const
79{
84{
80 if (m_departmentId.startsWith("child"))
85 if (m_departmentId.startsWith("child"))
tests/mocks/Unity/fake_department.h+3
@@ -32,6 +32,7 @@ class Department : public QAbstractListModel
32 Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
32 Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
33 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
33 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
34 Q_PROPERTY(int count READ count NOTIFY countChanged)
34 Q_PROPERTY(int count READ count NOTIFY countChanged)
35+ Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
35 // roles: string departmentId, string label, bool hasChildren, bool isActive
36 // roles: string departmentId, string label, bool hasChildren, bool isActive
36
37
37public:
38public:
@@ -51,6 +52,7 @@ public:
51 QString parentLabel() const;
52 QString parentLabel() const;
52 bool loaded() const;
53 bool loaded() const;
53 int count() const;
54 int count() const;
55+ bool isRoot() const;
54
56
55 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
57 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
56 QHash<int, QByteArray> roleNames() const;
58 QHash<int, QByteArray> roleNames() const;
@@ -67,6 +69,7 @@ Q_SIGNALS:
67 void parentLabelChanged(const QString&);
69 void parentLabelChanged(const QString&);
68 void loadedChanged(bool);
70 void loadedChanged(bool);
69 void countChanged(int);
71 void countChanged(int);
72+ void isRootChanged(bool);
70
73
71private Q_SLOTS:
74private Q_SLOTS:
72 void slotLoaded();
75 void slotLoaded();