Ubuntu Pastebin

Paste from cimi at Wed, 11 Feb 2015 15:35:53 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
=== modified file 'tests/mocks/Unity/fake_previewmodel.cpp'
--- tests/mocks/Unity/fake_previewmodel.cpp	2014-08-11 09:57:29 +0000
+++ tests/mocks/Unity/fake_previewmodel.cpp	2015-02-11 15:34:56 +0000
@@ -22,18 +22,21 @@
 #include "fake_previewmodel.h"
 
 // local
+#include "fake_scope.h"
 #include "fake_previewwidgetmodel.h"
 
 // Qt
 #include <QDebug>
 
-PreviewModel::PreviewModel(QObject* parent)
+PreviewModel::PreviewModel(Scope* parent)
  : unity::shell::scopes::PreviewModelInterface(parent)
  , m_loaded(true)
 {
     // we have one column by default
     PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
     m_previewWidgetModels.append(columnModel);
+    connect(this, SIGNAL(triggered(QString const&, QString const&, QVariantMap const&)),
+            this, SLOT(triggeredSlot(QString const&, QString const&, QVariantMap const&)));
 }
 
 void PreviewModel::setWidgetColumnCount(int count)
@@ -80,3 +83,10 @@
         Q_EMIT loadedChanged();
     }
 }
+
+void PreviewModel::triggeredSlot(QString const&, QString const&, QVariantMap const&) {
+    //open scope here
+    qWarning("triggeredSlot not implemented");
+    Scopes *scopes = dynamic_cast<Scopes*>(parent());
+    scopes->addTempScope(scopes->getScopeFromAll("MockScope9"));
+}

=== modified file 'tests/mocks/Unity/fake_previewmodel.h'
--- tests/mocks/Unity/fake_previewmodel.h	2014-08-11 09:57:29 +0000
+++ tests/mocks/Unity/fake_previewmodel.h	2015-02-11 15:31:43 +0000
@@ -25,12 +25,14 @@
 
 class PreviewWidgetModel;
 
+class Scope;
+
 class PreviewModel : public unity::shell::scopes::PreviewModelInterface
 {
     Q_OBJECT
 
 public:
-    explicit PreviewModel(QObject* parent = 0);
+    explicit PreviewModel(Scope* parent = 0);
 
     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -42,6 +44,9 @@
 
     Q_INVOKABLE void setLoaded(bool); // Only available for testing
 
+private Q_SLOTS:
+    void triggeredSlot(QString const&, QString const&, QVariantMap const&);
+
 private:
     QList<PreviewWidgetModel*> m_previewWidgetModels;
     bool m_loaded;

=== modified file 'tests/mocks/Unity/fake_previewstack.cpp'
--- tests/mocks/Unity/fake_previewstack.cpp	2014-05-19 11:10:58 +0000
+++ tests/mocks/Unity/fake_previewstack.cpp	2015-02-11 15:31:17 +0000
@@ -21,7 +21,7 @@
 #include "fake_previewmodel.h"
 #include "fake_scope.h"
 
-PreviewStack::PreviewStack(QObject* parent)
+PreviewStack::PreviewStack(Scope* parent)
  : unity::shell::scopes::PreviewStackInterface(parent)
 {
     m_previews << new PreviewModel(this);

=== modified file 'tests/mocks/Unity/fake_previewstack.h'
--- tests/mocks/Unity/fake_previewstack.h	2014-05-19 11:10:58 +0000
+++ tests/mocks/Unity/fake_previewstack.h	2015-02-11 15:31:37 +0000
@@ -25,12 +25,14 @@
 
 class PreviewModel;
 
+class Scope;
+
 class PreviewStack : public unity::shell::scopes::PreviewStackInterface
 {
     Q_OBJECT
 
 public:
-    explicit PreviewStack(QObject* parent = 0);
+    explicit PreviewStack(Scope* parent = 0);
     virtual ~PreviewStack();
 
     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;

=== modified file 'tests/mocks/Unity/fake_previewwidgetmodel.cpp'
--- tests/mocks/Unity/fake_previewwidgetmodel.cpp	2014-05-14 08:36:42 +0000
+++ tests/mocks/Unity/fake_previewwidgetmodel.cpp	2015-02-11 11:44:53 +0000
@@ -53,6 +53,17 @@
         PreviewData* preview_data = new PreviewData(QString("widget-%1").arg(i), QString("text"), attributes);
         m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
     }
+
+    QVariantMap attributes;
+    QVariantMap buttonData;
+    buttonData["label"] = "Button";
+    buttonData["id"] = "open_click";
+    QVariantList buttons;
+    buttons << buttonData << buttonData << buttonData;
+    attributes["actions"] = QVariant::fromValue(buttons);
+    PreviewData* preview_data = new PreviewData(QString("widget-21"), QString("actions"), attributes);
+    m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
+
     endResetModel();
 
 }

=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp	2015-02-04 11:04:43 +0000
+++ tests/mocks/Unity/fake_scope.cpp	2015-02-11 14:50:33 +0000
@@ -185,6 +185,7 @@
     if (result.toString() == "Result.2.2") {
         Scopes *scopes = dynamic_cast<Scopes*>(parent());
         m_openScope = scopes->getScopeFromAll("MockScope9");
+        scopes->addTempScope(m_openScope);
         Q_EMIT openScope(m_openScope);
     }
 }
@@ -198,7 +199,7 @@
     } else {
         // This probably leaks, do we don't care
         // it's a  test after all
-        return new PreviewStack;
+        return new PreviewStack(this);
     }
 }
 
@@ -208,6 +209,10 @@
 
 void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
 {
+    Scopes *scopes = dynamic_cast<Scopes*>(parent());
+    if (scopes) {
+        return scopes->closeScope(scope);
+    }
 }
 
 QString Scope::currentNavigationId() const

=== modified file 'tests/mocks/Unity/fake_scopes.cpp'
--- tests/mocks/Unity/fake_scopes.cpp	2015-02-04 11:04:43 +0000
+++ tests/mocks/Unity/fake_scopes.cpp	2015-02-11 11:44:29 +0000
@@ -23,6 +23,7 @@
 // TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
 
 // Qt
+#include <QDebug>
 #include <QTimer>
 
 Scopes::Scopes(QObject *parent)
@@ -179,15 +180,19 @@
 
 void Scopes::addTempScope(unity::shell::scopes::ScopeInterface* scope)
 {
+    qDebug() << "Called add temp on scope" << scope->id();
     if (!m_tempScopes.contains(scope)) {
+        qDebug() << "Adding" << scope->id();
         m_tempScopes.insert(scope);
     }
 }
 
 void Scopes::closeScope(unity::shell::scopes::ScopeInterface* scope)
 {
+    qDebug() << "Called close scope on scope" << scope->id();
     if (m_tempScopes.remove(scope)) {
-        scope->deleteLater();
+        qDebug() << "Deleting" << scope->id();
+        //scope->deleteLater();
     }
 }
 
Download as text