Merge lp:~carlos-mazieri/ubuntu-filemanager-app/app-devel-pre3 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: David Planella
Approved revision: 171
Merged at revision: 181
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/app-devel-pre3
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/app-devel-pre2
Diff against target: 194 lines (+79/-25)
2 files modified
src/plugin/folderlistmodel/iorequest.cpp (+37/-12)
src/plugin/folderlistmodel/iorequest.h (+42/-13)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/app-devel-pre3
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+218039@code.launchpad.net

Description of the change

Disk loading classes modified to allow reusing code for Trash:

* introduced class IORequestLoader
* add ExternalFileSystemChangesWorker::compareItems()
* comparing moved from ExternalFileSystemChangesWorker::run() to ExternalFileSystemChangesWorker::compareItems()

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

I've asked Michael Spencer to take a look at this and the other related branches and review. If he has difficulty with that I've asked him to get back to me so we can find another reviewer.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/iorequest.cpp'
2--- src/plugin/folderlistmodel/iorequest.cpp 2014-02-05 15:31:44 +0000
3+++ src/plugin/folderlistmodel/iorequest.cpp 2014-05-02 10:51:28 +0000
4@@ -30,6 +30,7 @@
5 */
6
7 #include "iorequest.h"
8+#include "diriteminfo.h"
9
10 #include <QDirIterator>
11 #include <QDebug>
12@@ -48,11 +49,22 @@
13 return m_type;
14 }
15
16-
17+//----------------------------------------------------------------------------------
18+IORequestLoader::IORequestLoader(const QString &pathName,
19+ QDir::Filter filter,
20+ bool isRecursive)
21+ : IORequest()
22+ , mLoaderType(NormalLoader)
23+ , mPathName(pathName)
24+ , mFilter(filter)
25+ , mIsRecursive(isRecursive)
26+{
27+
28+}
29+
30+//-----------------------------------------------------------------------------------------------
31 DirListWorker::DirListWorker(const QString &pathName, QDir::Filter filter, const bool isRecursive)
32- : mPathName(pathName)
33- , mFilter(filter)
34- , mIsRecursive(isRecursive)
35+ : IORequestLoader(pathName, filter, isRecursive)
36 {
37
38 }
39@@ -71,8 +83,12 @@
40 emit workerFinished();
41 }
42
43+DirItemInfoList IORequestLoader::getContents()
44+{
45+ return getNormalContent();
46+}
47
48-DirItemInfoList DirListWorker::getContents()
49+DirItemInfoList IORequestLoader::getNormalContent()
50 {
51 #if DEBUG_EXT_FS_WATCHER
52 qDebug() << "[exfsWatcher]" << QDateTime::currentDateTime().toString("hh:mm:ss.zzz")
53@@ -83,10 +99,9 @@
54 return directoryContents;
55 }
56
57-
58-DirItemInfoList DirListWorker::add(const QString &pathName,
59+DirItemInfoList IORequestLoader::add(const QString &pathName,
60 QDir::Filter filter,
61- const bool isRecursive,
62+ bool isRecursive,
63 DirItemInfoList directoryContents)
64 {
65 QDir tmpDir = QDir(pathName, QString(), QDir::NoSort, filter);
66@@ -133,21 +148,28 @@
67 void ExternalFileSystemChangesWorker::run()
68 {
69 DirItemInfoList directoryContents = getContents();
70+ int remainingitemsCounter = compareItems(directoryContents);
71+ emit finished(remainingitemsCounter);
72+}
73+
74+
75+int ExternalFileSystemChangesWorker::compareItems(const DirItemInfoList& contentNew)
76+{
77 int addedCounter=0;
78 int removedCounter=0;
79 #if DEBUG_EXT_FS_WATCHER
80 qDebug() << "[exfsWatcher]" << QDateTime::currentDateTime().toString("hh:mm:ss.zzz")
81 << Q_FUNC_INFO
82 << "m_curContent.count():" << m_curContent.count()
83- << "directoryContents.count():" << directoryContents.count();
84+ << "contentNew.count():" << contentNew.count();
85 #endif
86- int counter = directoryContents.count();
87+ int counter = contentNew.count();
88 if (counter > 0)
89 {
90 int tmpCounter = counter;
91 while (tmpCounter--)
92 {
93- const DirItemInfo& originalItem = directoryContents.at(tmpCounter);
94+ const DirItemInfo& originalItem = contentNew.at(tmpCounter);
95 const DirItemInfo existItem = m_curContent.value(originalItem.absoluteFilePath());
96 if ( existItem.exists() )
97 {
98@@ -181,5 +203,8 @@
99 << "addedCounter:" << addedCounter
100 << "removedCounter:" << removedCounter;
101 #endif
102- emit finished(counter);
103+
104+ return counter;
105 }
106+
107+
108
109=== modified file 'src/plugin/folderlistmodel/iorequest.h'
110--- src/plugin/folderlistmodel/iorequest.h 2014-02-05 15:31:44 +0000
111+++ src/plugin/folderlistmodel/iorequest.h 2014-05-02 10:51:28 +0000
112@@ -62,28 +62,50 @@
113
114
115
116-class DirListWorker : public IORequest
117+class IORequestLoader : public IORequest
118 {
119- Q_OBJECT
120+ Q_OBJECT
121 public:
122- explicit DirListWorker(const QString &pathName, QDir::Filter filter, const bool isRecursive);
123- void run();
124+ enum LoaderType
125+ {
126+ NormalLoader,
127+ TrashLoader
128+ };
129+
130+ IORequestLoader( const QString &pathName,
131+ QDir::Filter filter,
132+ bool isRecursive
133+ );
134+ DirItemInfoList getContents();
135+
136 signals:
137 void itemsAdded(const DirItemInfoList &files);
138- void workerFinished();
139-
140-protected:
141- DirItemInfoList getContents();
142
143 private:
144+ DirItemInfoList getNormalContent();
145 DirItemInfoList add(const QString &pathName, QDir::Filter filter,
146- const bool isRecursive, DirItemInfoList directoryContents);
147-private:
148+ bool isRecursive, DirItemInfoList directoryContents);
149+protected:
150+ LoaderType mLoaderType;
151 QString mPathName;
152 QDir::Filter mFilter;
153- bool mIsRecursive;
154-};
155-
156+ bool mIsRecursive;
157+};
158+
159+
160+
161+
162+class DirListWorker : public IORequestLoader
163+{
164+ Q_OBJECT
165+public:
166+ explicit DirListWorker(const QString &pathName, QDir::Filter filter, const bool isRecursive);
167+ void run();
168+protected:
169+signals:
170+ void workerFinished();
171+
172+};
173
174
175 class ExternalFileSystemChangesWorker : public DirListWorker
176@@ -95,6 +117,10 @@
177 QDir::Filter filter,
178 const bool isRecursive);
179 void run();
180+
181+protected:
182+ int compareItems(const DirItemInfoList& contentNew);
183+
184 signals:
185 void removed(const DirItemInfo&);
186 void changed(const DirItemInfo&);
187@@ -106,4 +132,7 @@
188
189
190
191+
192+
193+
194 #endif // IOREQUEST_H

Subscribers

People subscribed via source and target branches