on xenial help sign in
added refresh buttom to tree output
commit827f9f9b2faf0384d47b3070589e6e477a263184 authorNick Dedekind <nicholas.dedekind@gmail.com> dateTue 16 Jul 2013, 22:17 (13 years ago) parent031898f
2 files changed+31−11
Panel/Indicators/client/IndicatorsTree.qml+27−3 plugins/Unity/Indicators/modelprinter.cpp+4−8
Panel/Indicators/client/IndicatorsTree.qml+27−3
@@ -21,12 +21,12 @@ import QtQuick 2.0
2121import Ubuntu.Components 0.1
2222import Unity.Indicators 0.1 as Indicators
2323import QMenuModel 0.1
24+import Ubuntu.Components.ListItems 0.1 as ListItem
2425
2526Page {
2627 id: page
2728 anchors.fill: parent
2829
29−
3030 property alias busType: menuModel.busType
3131 property alias busName: menuModel.busName
3232 property string actionsObjectPath
@@ -48,11 +48,20 @@ Page {
4848 id: printer
4949 model: menuModel
5050
51− onSourceChanged: all_data.text = printer.getString()
51+ onSourceChanged: page.refresh()
52+ }
53+
54+ function refresh() {
55+ all_data.text = printer.getString();
5256 }
5357
5458 Flickable {
55− anchors.fill: parent
59+ anchors {
60+ top: parent.top
61+ left: parent.left
62+ right: parent.right
63+ bottom: button.top
64+ }
5665 contentHeight: all_data.height
5766 clip:true
5867 Text {
@@ -60,4 +69,19 @@ Page {
6069 color: "white"
6170 }
6271 }
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+ }
6387}
plugins/Unity/Indicators/modelprinter.cpp+4−8
@@ -28,20 +28,17 @@ ModelPrinter::ModelPrinter(QObject *parent)
2828
2929void ModelPrinter::setSourceModel(QAbstractItemModel * sourceModel)
3030{
31− if (m_model != NULL)
32− {
31+ if (m_model != NULL) {
3332 disconnect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
3433 disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
3534 disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
3635 }
37− if (m_model != sourceModel)
38− {
36+ if (m_model != sourceModel) {
3937 m_model = sourceModel;
4038 Q_EMIT modelChanged();
4139 Q_EMIT sourceChanged();
4240 }
43− if (m_model != NULL)
44− {
41+ if (m_model != NULL) {
4542 connect(m_model, SIGNAL(modelReset()), this, SIGNAL(sourceChanged()));
4643 connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(sourceChanged()));
4744 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
8986
9087 int rowCount = m_model->rowCount(index);
9188 stream << tabify(level) << "child count" << ": " << rowCount << endl;
92− for (int i = 0; i < rowCount; i++)
93− {
89+ for (int i = 0; i < rowCount; i++) {
9490 QModelIndex child = m_model->index(i, 0, index);
9591 str += recurse_string(child, level+1);
9692 }