Merge lp:~carlos-mazieri/ubuntu-filemanager-app/new-protocols-support-02 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri on 2015-12-12
Status: Merged
Approved by: Carlos Jose Mazieri on 2016-01-15
Approved revision: 514
Merged at revision: 515
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/new-protocols-support-02
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/new-protocols-support-01
Diff against target: 371 lines (+154/-58)
9 files modified
src/plugin/folderlistmodel/disk/disklocation.cpp (+3/-1)
src/plugin/folderlistmodel/disk/disklocation.h (+2/-1)
src/plugin/folderlistmodel/location.h (+3/-1)
src/plugin/folderlistmodel/locationitemdiriterator.cpp (+53/-13)
src/plugin/folderlistmodel/locationitemdiriterator.h (+41/-8)
src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp (+28/-24)
src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h (+19/-7)
src/plugin/folderlistmodel/smb/smblocation.cpp (+3/-2)
src/plugin/folderlistmodel/smb/smblocation.h (+2/-1)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/new-protocols-support-02
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve on 2016-01-15
Arto Jalkanen 2015-12-12 Approve on 2016-01-10
Review via email: mp+280388@code.launchpad.net

Commit message

LocationItemDirIterator descendants classes now perform the loading inside the constructor according to the new constructor flag LocationItemDirIterator::LoadMode.
LocationItemDirIterator::LoadLater allows LocationItemDirIterator::load() be called later, that is how Network Locations should put the loading inside the secondary thread specific for loading.
For Disk loading, that means in DiskLocationItemDirIterator class it was not implemented because QDir is used directly inside the secondary thread.

Description of the change

LocationItemDirIterator descendants classes now perform the loading inside the constructor according to the new constructor flag LocationItemDirIterator::LoadMode.
LocationItemDirIterator::LoadLater allows LocationItemDirIterator::load() be called later, that is how Network Locations should put the loading inside the secondary thread specific for loading.
For Disk loading, that means in DiskLocationItemDirIterator class it was not implemented because QDir is used directly inside the secondary thread.

To post a comment you must log in.
review: Approve (continuous-integration)
Arto Jalkanen (ajalkane) wrote :

Some spelling mistakes in comments

review: Approve

I will fix that, thanks.

FAILED: Autolanding.
Unapproved changes made after approval.
https://core-apps-jenkins.ubuntu.com/job/filemanager-app-autolanding/22/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1444/console

review: Needs Fixing (continuous-integration)
review: Approve (continuous-integration)

FAILED: Autolanding.
Approved revid is not set in launchpad. This is most likely a launchpad issue and re-approve should fix it. There is also a chance (although a very small one) this is a permission problem of the ps-jenkins bot.
https://core-apps-jenkins.ubuntu.com/job/filemanager-app-autolanding/23/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1445/console

review: Needs Fixing (continuous-integration)
review: Needs Fixing (continuous-integration)
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/disk/disklocation.cpp'
2--- src/plugin/folderlistmodel/disk/disklocation.cpp 2015-12-08 16:55:41 +0000
3+++ src/plugin/folderlistmodel/disk/disklocation.cpp 2016-01-11 22:26:42 +0000
4@@ -192,8 +192,10 @@
5 LocationItemDirIterator *
6 DiskLocation::newDirIterator(const QString &path,
7 QDir::Filters filters,
8- QDirIterator::IteratorFlags flags)
9+ QDirIterator::IteratorFlags flags,
10+ LocationItemDirIterator::LoadMode loadmode)
11 {
12+ Q_UNUSED(loadmode);
13 return new DiskLocationItemDirIterator(path, filters, flags);
14 }
15
16
17=== modified file 'src/plugin/folderlistmodel/disk/disklocation.h'
18--- src/plugin/folderlistmodel/disk/disklocation.h 2015-12-08 16:55:41 +0000
19+++ src/plugin/folderlistmodel/disk/disklocation.h 2016-01-11 22:26:42 +0000
20@@ -65,7 +65,8 @@
21 const bool isRecursive);
22 virtual LocationItemDirIterator * newDirIterator(const QString & path,
23 QDir::Filters filters,
24- QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags);
25+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
26+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
27 virtual LocationItemFile * newFile(const QString & path);
28 virtual LocationItemDir * newDir(const QString & dir = QLatin1String(0));
29 virtual bool isThereDiskSpace(const QString& pathname, qint64 requiredSize);
30
31=== modified file 'src/plugin/folderlistmodel/location.h'
32--- src/plugin/folderlistmodel/location.h 2015-12-08 16:55:41 +0000
33+++ src/plugin/folderlistmodel/location.h 2016-01-11 22:26:42 +0000
34@@ -23,6 +23,7 @@
35 #define LOCATION_H
36
37 #include "diriteminfo.h"
38+#include "locationitemdiriterator.h"
39
40 #include <QObject>
41 #include <QDirIterator>
42@@ -124,7 +125,8 @@
43 */
44 virtual LocationItemDirIterator * newDirIterator(const QString & path,
45 QDir::Filters filters,
46- QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags) = 0;
47+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
48+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor) = 0;
49 /*!
50 * \brief newFile() creates a LocationItemFile object which is similar to Qt QFile object
51 *
52
53=== modified file 'src/plugin/folderlistmodel/locationitemdiriterator.cpp'
54--- src/plugin/folderlistmodel/locationitemdiriterator.cpp 2015-03-01 15:32:42 +0000
55+++ src/plugin/folderlistmodel/locationitemdiriterator.cpp 2016-01-11 22:26:42 +0000
56@@ -21,19 +21,40 @@
57
58 #include "locationitemdiriterator.h"
59
60-LocationItemDirIterator::LocationItemDirIterator(const QString &, const QStringList &, QDir::Filters, QDirIterator::IteratorFlags )
61-{
62-}
63-
64-
65-LocationItemDirIterator::LocationItemDirIterator(const QString &, QDir::Filters , QDirIterator::IteratorFlags)
66-{
67-
68-}
69-
70-LocationItemDirIterator::LocationItemDirIterator(const QString &, QDirIterator::IteratorFlags )
71-{
72-
73+LocationItemDirIterator::LocationItemDirIterator(const QString &path,
74+ const QStringList &nameFilters,
75+ QDir::Filters filters,
76+ QDirIterator::IteratorFlags flags,
77+ LocationItemDirIterator::LoadMode loadmode)
78+ : m_path(path)
79+ , m_nameFilters(nameFilters)
80+ , m_filters(filters)
81+ , m_flags(flags)
82+
83+{
84+ Q_UNUSED(loadmode);
85+}
86+
87+
88+LocationItemDirIterator::LocationItemDirIterator(const QString &path,
89+ QDir::Filters filters,
90+ QDirIterator::IteratorFlags flags,
91+ LocationItemDirIterator::LoadMode loadmode)
92+ : m_path(path)
93+ , m_filters(filters)
94+ , m_flags(flags)
95+{
96+ Q_UNUSED(loadmode);
97+}
98+
99+LocationItemDirIterator::LocationItemDirIterator(const QString &path,
100+ QDirIterator::IteratorFlags flags,
101+ LocationItemDirIterator::LoadMode loadmode)
102+ : m_path(path)
103+ , m_filters(QDir::NoFilter)
104+ , m_flags(flags)
105+{
106+ Q_UNUSED(loadmode);
107 }
108
109 LocationItemDirIterator::~LocationItemDirIterator()
110@@ -42,3 +63,22 @@
111 }
112
113
114+QDirIterator::IteratorFlags LocationItemDirIterator::flags() const
115+{
116+ return m_flags;
117+}
118+
119+QDir::Filters LocationItemDirIterator::filters() const
120+{
121+ return m_filters;
122+}
123+
124+QString LocationItemDirIterator::path() const
125+{
126+ return m_path;
127+}
128+
129+void LocationItemDirIterator::load()
130+{
131+ //default implementation does nothing
132+}
133
134=== modified file 'src/plugin/folderlistmodel/locationitemdiriterator.h'
135--- src/plugin/folderlistmodel/locationitemdiriterator.h 2015-03-01 15:32:42 +0000
136+++ src/plugin/folderlistmodel/locationitemdiriterator.h 2016-01-11 22:26:42 +0000
137@@ -29,14 +29,22 @@
138 * \brief The LocationItemDirIterator class is an abstract similar to Qt QDirIterator
139 *
140 * Different protocols supported by filemanager (different Locations) must provide a class like that.
141+ *
142+ * The \ref LoadLater can used in the constructor to indicate to the constructor to NOT load the path/url, instead \ref load() can called later to do that.
143 */
144
145 class LocationItemDirIterator
146 {
147 public:
148+ enum LoadMode
149+ {
150+ LoadOnConstructor, //!< loads the entire directory or url in the constructor as Qt QDirIterator does
151+ LoadLater //!< do NOT load the entire directory or url, \ref load() method should be responsible to do that.
152+ };
153+
154 virtual ~LocationItemDirIterator();
155 public:
156- virtual bool hasNext() const = 0;
157+ virtual bool hasNext() const = 0;
158 virtual QString next() = 0;
159
160 virtual DirItemInfo fileInfo() const = 0;
161@@ -50,18 +58,43 @@
162 * \brief filePath()
163 * \return the full pathname of the current item
164 */
165- virtual QString filePath() const = 0;
166+ virtual QString filePath() const = 0;
167
168 /*!
169 * \brief path()
170 * \return the base directory of the iterator path (not the current item)
171 */
172- virtual QString path() const = 0;
173-
174-protected:
175- LocationItemDirIterator(const QString & path, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags);
176- LocationItemDirIterator(const QString & path, QDir::Filters filters, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags);
177- LocationItemDirIterator(const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags);
178+ virtual QString path() const;
179+
180+ /*!
181+ * \brief load() responsible to load the entire directory or url when \ref LoadLater is passed to the constructor
182+ */
183+ virtual void load() ;
184+
185+ QDir::Filters filters() const;
186+ QDirIterator::IteratorFlags flags() const;
187+
188+protected:
189+ LocationItemDirIterator(const QString & path,
190+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
191+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
192+
193+ LocationItemDirIterator(const QString & path,
194+ QDir::Filters filters,
195+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
196+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
197+
198+ LocationItemDirIterator(const QString & path,
199+ const QStringList & nameFilters,
200+ QDir::Filters filters = QDir::NoFilter,
201+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
202+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
203+
204+protected:
205+ QString m_path;
206+ QStringList m_nameFilters;
207+ QDir::Filters m_filters;
208+ QDirIterator::IteratorFlags m_flags;
209 };
210
211
212
213=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp'
214--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 2015-07-13 20:41:48 +0000
215+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 2016-01-11 22:26:42 +0000
216@@ -32,35 +32,44 @@
217 const QStringList &nameFilters,
218 QDir::Filters filters,
219 QDirIterator::IteratorFlags flags,
220- Const_SmbUtil_Ptr smb)
221- : LocationItemDirIterator(path, nameFilters, filters, flags)
222+ Const_SmbUtil_Ptr smb,
223+ LocationItemDirIterator::LoadMode loadmode)
224+ : LocationItemDirIterator(path, nameFilters, filters, flags, loadmode)
225 , INIT_ATTR(path, smb)
226 {
227- bool recursive = flags == QDirIterator::Subdirectories ? true : false;
228- m_urlItems = smbObj()->listContent(path, recursive, filters, nameFilters);
229+ if (loadmode == LocationItemDirIterator::LoadOnConstructor)
230+ {
231+ load();
232+ }
233 }
234
235
236 SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
237 QDir::Filters filters,
238 QDirIterator::IteratorFlags flags,
239- Const_SmbUtil_Ptr smb)
240- : LocationItemDirIterator(path,filters,flags)
241+ Const_SmbUtil_Ptr smb,
242+ LocationItemDirIterator::LoadMode loadmode)
243+ : LocationItemDirIterator(path,filters,flags, loadmode)
244 , INIT_ATTR(path, smb)
245 {
246- bool recursive = flags == QDirIterator::Subdirectories ? true : false;
247- m_urlItems = smbObj()->listContent(path, recursive, filters);
248+ if (loadmode == LocationItemDirIterator::LoadOnConstructor)
249+ {
250+ load();
251+ }
252 }
253
254
255 SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
256 QDirIterator::IteratorFlags flags,
257- Const_SmbUtil_Ptr smb)
258- : LocationItemDirIterator(path,flags)
259+ Const_SmbUtil_Ptr smb,
260+ LocationItemDirIterator::LoadMode loadmode)
261+ : LocationItemDirIterator(path,flags, loadmode)
262 , INIT_ATTR(path, smb)
263 {
264- bool recursive = flags == QDirIterator::Subdirectories ? true : false;
265- m_urlItems = smbObj()->listContent(path, recursive, QDir::NoFilter);
266+ if (loadmode == LocationItemDirIterator::LoadOnConstructor)
267+ {
268+ load();
269+ }
270 }
271
272
273@@ -113,18 +122,6 @@
274 }
275
276
277-QString SmbLocationDirIterator::path() const
278-{
279- QString ret;
280- QStringList separated = UrlItemInfo::separatePathFilename(cleanUrl());
281- if (separated.count() > 0)
282- {
283- ret = separated.at(0);
284- }
285- return ret;
286-}
287-
288-
289 QString SmbLocationDirIterator::filePath() const
290 {
291 QString fullpathname;
292@@ -134,3 +131,10 @@
293 }
294 return fullpathname;
295 }
296+
297+
298+void SmbLocationDirIterator::load()
299+{
300+ bool recursive = m_flags == QDirIterator::Subdirectories ? true : false;
301+ m_urlItems = smbObj()->listContent(path(), recursive, m_filters, m_nameFilters);
302+}
303
304=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h'
305--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 2015-05-20 16:18:07 +0000
306+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 2016-01-11 22:26:42 +0000
307@@ -32,14 +32,26 @@
308 public:
309 virtual DirItemInfo fileInfo() const;
310 virtual QString fileName() const;
311- virtual QString filePath() const;
312- virtual bool hasNext() const;
313- virtual QString next() ;
314- virtual QString path() const;
315+ virtual QString filePath() const;
316+ virtual bool hasNext() const;
317+ virtual QString next() ;
318+ virtual void load();
319 public:
320- SmbLocationDirIterator(const QString & path, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
321- SmbLocationDirIterator(const QString & path, QDir::Filters filters, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
322- SmbLocationDirIterator(const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
323+ SmbLocationDirIterator(const QString & path,
324+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
325+ Const_SmbUtil_Ptr smb = 0,
326+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
327+
328+ SmbLocationDirIterator(const QString & path, QDir::Filters filters,
329+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
330+ Const_SmbUtil_Ptr smb = 0,
331+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
332+
333+ SmbLocationDirIterator(const QString & path, const QStringList & nameFilters,
334+ QDir::Filters filters = QDir::NoFilter,
335+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
336+ Const_SmbUtil_Ptr smb = 0,
337+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
338 private:
339 QStringList m_urlItems;
340 int m_curItem;
341
342=== modified file 'src/plugin/folderlistmodel/smb/smblocation.cpp'
343--- src/plugin/folderlistmodel/smb/smblocation.cpp 2015-12-08 16:55:41 +0000
344+++ src/plugin/folderlistmodel/smb/smblocation.cpp 2016-01-11 22:26:42 +0000
345@@ -111,9 +111,10 @@
346 LocationItemDirIterator *
347 SmbLocation::newDirIterator(const QString &path,
348 QDir::Filters filters,
349- QDirIterator::IteratorFlags flags)
350+ QDirIterator::IteratorFlags flags,
351+ LocationItemDirIterator::LoadMode loadmode)
352 {
353- return new SmbLocationDirIterator(path, filters, flags, m_smb);
354+ return new SmbLocationDirIterator(path, filters, flags, m_smb, loadmode);
355 }
356
357
358
359=== modified file 'src/plugin/folderlistmodel/smb/smblocation.h'
360--- src/plugin/folderlistmodel/smb/smblocation.h 2015-12-08 16:55:41 +0000
361+++ src/plugin/folderlistmodel/smb/smblocation.h 2016-01-11 22:26:42 +0000
362@@ -41,7 +41,8 @@
363 const bool isRecursive);
364 virtual LocationItemDirIterator * newDirIterator(const QString & path,
365 QDir::Filters filters,
366- QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags);
367+ QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags,
368+ LocationItemDirIterator::LoadMode loadmode = LocationItemDirIterator::LoadOnConstructor);
369 virtual LocationItemFile * newFile(const QString & path);
370 virtual LocationItemDir * newDir(const QString & dir = QLatin1String(0));
371 virtual bool isThereDiskSpace(const QString& pathname, qint64 requiredSize);

Subscribers

People subscribed via source and target branches