on xenial help sign in
added refresh buttom to tree output
827f9f9Nick Dedekind
Panel/Indicators/client/IndicatorsTree.qml+27−3
@@ -21,12 +21,12 @@ import QtQuick 2.0
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
22import Unity.Indicators 0.1 as Indicators
23import QMenuModel 0.1
23import QMenuModel 0.1
24+import Ubuntu.Components.ListItems 0.1 as ListItem
24
25
25Page {
26Page {
26 id: page
27 id: page
27 anchors.fill: parent
28 anchors.fill: parent
28
29
29−
30 property alias busType: menuModel.busType
30 property alias busType: menuModel.busType
31 property alias busName: menuModel.busName
31 property alias busName: menuModel.busName
32 property string actionsObjectPath
32 property string actionsObjectPath
@@ -48,11 +48,20 @@ Page {
48 id: printer
48 id: printer
49 model: menuModel
49 model: menuModel
50
50
51+ onSourceChanged: page.refresh()
52+ }
53+
54+ function refresh() {
51− onSourceChanged: all_data.text = printer.getString()
55+ all_data.text = printer.getString();
52 }
56 }
53
57
54 Flickable {
58 Flickable {
55− anchors.fill: parent
59+ anchors {
60+ top: parent.top
61+ left: parent.left
62+ right: parent.right
63+ bottom: button.top
64+ }
56 contentHeight: all_data.height
65 contentHeight: all_data.height
57 clip:true
66 clip:true
58 Text {
67 Text {
@@ -60,4 +69,19 @@ Page {
60 color: "white"
69 color: "white"
61 }
70 }
62 }
71 }
72+
73+ ListItem.Standard {
74+ id: button
75+ anchors {
76+ left: parent.left
77+ right: parent.right
78+ bottom: parent.bottom
79+ }
80+
81+ text: ""
82+ control: Button {
83+ text: "Refresh"
84+ onClicked: page.refresh()
85+ }
86+ }
63}
87}
plugins/Unity/Indicators/modelprinter.cpp+4−8
@@ -28,20 +28,17 @@ ModelPrinter::ModelPrinter(QObject *parent)
28
28
29void ModelPrinter::setSourceModel(QAbstractItemModel * sourceModel)
29void ModelPrinter::setSourceModel(QAbstractItemModel * sourceModel)
30{
30{
31− if (m_model != NULL)
31+ if (m_model != NULL) {
32− {
33 disconnect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
32 disconnect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
34 disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
33 disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
35 disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
34 disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
36 }
35 }
37− if (m_model != sourceModel)
36+ if (m_model != sourceModel) {
38− {
39 m_model = sourceModel;
37 m_model = sourceModel;
40 Q_EMIT modelChanged();
38 Q_EMIT modelChanged();
41 Q_EMIT sourceChanged();
39 Q_EMIT sourceChanged();
42 }
40 }
43− if (m_model != NULL)
41+ if (m_model != NULL) {
44− {
45 connect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
42 connect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
46 connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
43 connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
47 connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
44 connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
@@ -89,8 +86,7 @@ QString ModelPrinter::recurse_string(const QModelIndex& index, int level) const
89
86
90 int rowCount = m_model->rowCount(index);
87 int rowCount = m_model->rowCount(index);
91 stream << tabify(level) << "child count" << ": " << rowCount << endl;
88 stream << tabify(level) << "child count" << ": " << rowCount << endl;
92− for (int i = 0; i < rowCount; i++)
89+ for (int i = 0; i < rowCount; i++) {
93− {
94 QModelIndex child = m_model->index(i, 0, index);
90 QModelIndex child = m_model->index(i, 0, index);
95 str += recurse_string(child, level+1);
91 str += recurse_string(child, level+1);
96 }
92 }