Merge lp:~tiagosh/dee-qt/dee-qt-local-models into lp:dee-qt/0.2

Proposed by Tiago Salem Herrmann on 2012-01-31
Status: Merged
Approved by: Albert Astals Cid on 2012-02-13
Approved revision: 67
Merged at revision: 62
Proposed branch: lp:~tiagosh/dee-qt/dee-qt-local-models
Merge into: lp:dee-qt/0.2
Diff against target: 98 lines (+39/-2)
2 files modified
deelistmodel.cpp (+37/-2)
deelistmodel.h (+2/-0)
To merge this branch: bzr merge lp:~tiagosh/dee-qt/dee-qt-local-models
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve on 2012-02-13
Gerry Boland 2012-01-31 Needs Fixing on 2012-02-03
Michal Hruby (community) Needs Fixing on 2012-02-03
Review via email: mp+90897@code.launchpad.net

Description of the Change

This MR implements a new method that makes libqtdee able to handle local models.
This is needed by unity-2d, as the new Home Lens implementation uses a local model instead of a remote/shared one.

To post a comment you must log in.
62. By Tiago Salem Herrmann on 2012-01-31

remove white space and change void by DeeModel for setModel()

63. By Tiago Salem Herrmann on 2012-01-31

remove wrong casting

64. By Tiago Salem Herrmann on 2012-01-31

fix DeeModel forward declaration

Michal Hruby (mhr3) wrote :

28 - g_object_unref(m_deeModel);
29 + if (!m_isLocal)
30 + g_object_unref(m_deeModel);

Please don't do that, take a reference on the model even if it's a local model.

46 + m_deeModel = model;

Looks like here is a good place to do that ("m_deeModel = (DeeModel*)g_object_ref (model);")

review: Needs Fixing
Gerry Boland (gerboland) wrote :

I'm getting critical warnings of the form:

[CRITICAL] dee: dee_model_get_first_iter: assertion `DEE_IS_MODEL (self)' failed
[CRITICAL] dee: dee_model_get_last_iter: assertion `DEE_IS_MODEL (self)' failed
[CRITICAL] dee: dee_sequence_model_set_row: assertion `iter != NULL' failed

when using the local models lens. Some incorrect data seems to be coming out also.

I'm compiling against libdee-1.0-4 version 1.0.0+bzr340ubuntu0+224

This backtrace might help: https://pastebin.canonical.com/59428/ (got with G_DEBUG=fatal_criticals gdb unity-2d-shell)

I've had a little chat with Michal (mhr3) about it, but nothing obvious wrong struck him unfortunately.

review: Needs Fixing
65. By Tiago Salem Herrmann on 2012-02-03

take the model reference

66. By Tiago Salem Herrmann on 2012-02-07

rename roles for local model too and emit proper signals

Albert Astals Cid (aacid) wrote :

Should we on DeeListModel::setModel(DeeModel *model) disconnect from model even if the new one is null?

review: Needs Fixing
Tiago Salem Herrmann (tiagosh) wrote :

yes, you are right, just updated the branch.
Thanks.

67. By Tiago Salem Herrmann on 2012-02-10

disconnect from the previous model if the new model is NULL

Albert Astals Cid (aacid) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deelistmodel.cpp'
2--- deelistmodel.cpp 2012-01-04 23:52:05 +0000
3+++ deelistmodel.cpp 2012-02-10 13:29:16 +0000
4@@ -71,6 +71,7 @@
5 ~DeeListModelPrivate();
6
7 void connectToDeeModel();
8+ void connectToDeeModel(DeeModel *model);
9 void disconnectFromDeeModel();
10 void createRoles();
11
12@@ -84,9 +85,10 @@
13 DeeModel* m_deeModel;
14 QString m_name;
15 int m_count;
16+ bool m_isLocal;
17 };
18
19-DeeListModelPrivate::DeeListModelPrivate(DeeListModel* parent) : m_parent(parent), m_deeModel(NULL), m_count(0)
20+DeeListModelPrivate::DeeListModelPrivate(DeeListModel* parent) : m_parent(parent), m_deeModel(NULL), m_count(0), m_isLocal(false)
21 {
22 }
23
24@@ -124,6 +126,24 @@
25 g_signal_connect(m_deeModel, "row-removed", G_CALLBACK(onRowRemoved), m_parent);
26 g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent);
27 }
28+ m_isLocal = false;
29+}
30+
31+void
32+DeeListModelPrivate::connectToDeeModel(DeeModel *model)
33+{
34+ disconnectFromDeeModel();
35+
36+ m_deeModel = (DeeModel*)g_object_ref (model);
37+ g_signal_connect(m_deeModel, "row-added", G_CALLBACK(onRowAdded), m_parent);
38+ g_signal_connect(m_deeModel, "row-removed", G_CALLBACK(onRowRemoved), m_parent);
39+ g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent);
40+ m_isLocal = true;
41+ createRoles();
42+ m_count = dee_model_get_n_rows(m_deeModel);
43+ m_parent->reset();
44+ Q_EMIT m_parent->countChanged();
45+
46 }
47
48 void
49@@ -251,13 +271,28 @@
50 }
51 }
52
53+void
54+DeeListModel::setModel(DeeModel *model)
55+{
56+ if (model != NULL) {
57+ d->connectToDeeModel(model);
58+ } else {
59+ d->disconnectFromDeeModel();
60+ }
61+}
62+
63+
64 bool
65 DeeListModel::synchronized() const
66 {
67 if (d->m_deeModel == NULL) {
68 return false;
69 } else {
70- return dee_shared_model_is_synchronized(DEE_SHARED_MODEL(d->m_deeModel));
71+ if (d->m_isLocal) {
72+ return true;
73+ } else {
74+ return dee_shared_model_is_synchronized(DEE_SHARED_MODEL(d->m_deeModel));
75+ }
76 }
77 }
78
79
80=== modified file 'deelistmodel.h'
81--- deelistmodel.h 2011-07-27 22:16:14 +0000
82+++ deelistmodel.h 2012-02-10 13:29:16 +0000
83@@ -23,6 +23,7 @@
84 #include <QtCore/QAbstractListModel>
85
86 class DeeListModelPrivate;
87+typedef struct _DeeModel DeeModel;
88 class __attribute__ ((visibility ("default"))) DeeListModel : public QAbstractListModel
89 {
90 friend class DeeListModelPrivate;
91@@ -50,6 +51,7 @@
92
93 /* setters */
94 void setName(const QString& name);
95+ void setModel(DeeModel* model);
96
97 Q_SIGNALS:
98 void nameChanged(const QString&);

Subscribers

People subscribed via source and target branches