Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri on 2015-07-19
Status: Superseded
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-12
Diff against target: 231 lines (+47/-37)
2 files modified
src/plugin/folderlistmodel/filesystemaction.cpp (+40/-30)
src/plugin/folderlistmodel/filesystemaction.h (+7/-7)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-13
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing on 2015-07-19
Ubuntu File Manager Developers 2015-07-19 Pending
Review via email: mp+265212@code.launchpad.net

This proposal has been superseded by a proposal from 2015-07-21.

Commit message

Some DirItemInfo objects created by targetLocation in Actions
QFile is no longer used in Actions, instead the abstract LocationItemFile is created by the suitable Location object

Description of the change

All QFile usage replaced by LocationItemFile

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
2--- src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-19 16:36:55 +0000
3+++ src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-19 16:36:55 +0000
4@@ -40,7 +40,7 @@
5 #include "location.h"
6 #include "locationsfactory.h"
7 #include "locationitemdiriterator.h"
8-
9+#include "locationitemfile.h"
10
11 #if defined(Q_OS_UNIX)
12 #include <sys/statvfs.h>
13@@ -669,7 +669,9 @@
14 }
15 else
16 {
17- m_cancelCurrentAction = !QFile::remove(fi.absoluteFilePath());
18+ LocationItemFile *qFile = m_curAction->sourceLocation->newFile(fi.absoluteFilePath());
19+ m_cancelCurrentAction = !qFile->remove();
20+ delete qFile;
21 }
22 #if DEBUG_REMOVE
23 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();
24@@ -743,14 +745,17 @@
25 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
26 QString orig = fi.absoluteFilePath();
27 QString target = targetFrom(orig, entry);
28+#if DEBUG_MESSAGES
29+ qDebug() << "orig:" << orig << "target:" << target;
30+#endif
31 QString path(target);
32 // do this here to allow progress send right item number, copySingleFile will emit progress()
33 m_curAction->currItem++;
34 //--
35 if (fi.isFile() || fi.isSymLink())
36 {
37- DirItemInfo t(target);
38- path = t.path();
39+ QScopedPointer <DirItemInfo> t(m_curAction->targetLocation->newItemInfo(target));
40+ path = t->path();
41 }
42 //check if the main item in the entry is a directory
43 //if so it needs to appear on any attached view
44@@ -763,7 +768,7 @@
45 QDir entryDirObj(entryDir);
46 if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))
47 {
48- QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(entryDir));
49+ QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));
50 entry->added = true;
51 notifyActionOnItem(*item, ItemAdded);
52 }
53@@ -789,8 +794,10 @@
54 else
55 if (fi.isDir())
56 {
57+ LocationItemFile *qFile = m_curAction->targetLocation->newFile(target);
58 m_cancelCurrentAction = !
59- QFile(target).setPermissions(fi.permissions());
60+ qFile->setPermissions(fi.permissions());
61+ delete qFile;
62 if (m_cancelCurrentAction)
63 {
64 m_errorTitle = QObject::tr("Could not set permissions to dir");
65@@ -803,7 +810,7 @@
66 {
67 qint64 needsSize = 0;
68 m_curAction->copyFile.clear();
69- m_curAction->copyFile.source = new QFile(orig);
70+ m_curAction->copyFile.source = m_curAction->sourceLocation->newFile(orig);
71 m_cancelCurrentAction = !m_curAction->copyFile.source->open(QFile::ReadOnly);
72 if (m_cancelCurrentAction)
73 {
74@@ -814,7 +821,7 @@
75 {
76 needsSize = m_curAction->copyFile.source->size();
77 //create destination
78- m_curAction->copyFile.target = new QFile(target);
79+ m_curAction->copyFile.target = m_curAction->targetLocation->newFile(target);
80 m_curAction->copyFile.targetName = target;
81 //first open it read-only to get its size if exists
82 if (m_curAction->copyFile.target->open(QFile::ReadOnly))
83@@ -823,7 +830,7 @@
84 m_curAction->copyFile.target->close();
85 }
86 //check if there is disk space to copy source to target
87- if (needsSize > 0 && !m_locationsFactory->currentLocation()->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
88+ if (needsSize > 0 && !m_curAction->targetLocation->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
89 {
90 m_cancelCurrentAction = true;
91 m_errorTitle = QObject::tr("There is no space to copy");
92@@ -848,7 +855,7 @@
93 //depending on the file size it may take longer, the view needs to be informed
94 if (m_curAction->copyFile.isEntryItem && !m_cancelCurrentAction)
95 {
96- QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(target));
97+ QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(target));
98 if (!entry->alreadyExists)
99 {
100 entry->added = true;
101@@ -877,9 +884,7 @@
102 * \param entry
103 */
104 void FileSystemAction::moveEntry(ActionEntry *entry)
105-{
106- QFile file;
107-
108+{
109 for(; !m_cancelCurrentAction &&
110 entry->currStep < STEP_FILES &&
111 m_curAction->currItem < m_curAction->totalItems &&
112@@ -889,36 +894,38 @@
113
114 {
115 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
116- file.setFileName(fi.absoluteFilePath());
117- DirItemInfo targetInfo(entry->itemPaths.target());
118+ QScopedPointer<LocationItemFile> file(m_curAction->sourceLocation->newFile(fi.absoluteFilePath()));
119+ QScopedPointer<DirItemInfo> targetInfo(m_curAction->targetLocation->newItemInfo(entry->itemPaths.target()));
120 //rename will fail
121- if (targetInfo.exists())
122+ if (targetInfo->exists())
123 {
124 //will not emit removed() neither added()
125 entry->added = true;
126- if (targetInfo.isFile() || targetInfo.isSymLink())
127+ if (targetInfo->isFile() || targetInfo->isSymLink())
128 {
129- if (!QFile::remove(targetInfo.absoluteFilePath()))
130+ QScopedPointer<LocationItemFile>
131+ targetFile(m_curAction->sourceLocation->newFile(targetInfo->absoluteFilePath()));
132+ if (!targetFile->remove())
133 {
134 m_cancelCurrentAction = true;
135 m_errorTitle = QObject::tr("Could not remove the directory/file ") +
136- targetInfo.absoluteFilePath();
137+ targetInfo->absoluteFilePath();
138 m_errorMsg = ::strerror(errno);
139 }
140 }
141- else
142- if (targetInfo.isDir())
143+ else //only for local disk operations
144+ if (targetInfo->isDir() && !m_curAction->isRemote())
145 {
146 //move target to /tmp and remove it later by creating an Remove action
147 //this will emit removed()
148- moveDirToTempAndRemoveItLater(targetInfo.absoluteFilePath());
149+ moveDirToTempAndRemoveItLater(targetInfo->absoluteFilePath());
150 }
151 }
152- if (!m_cancelCurrentAction && !file.rename(entry->itemPaths.target()))
153+ if (!m_cancelCurrentAction && !file->rename(entry->itemPaths.target()))
154 {
155 m_cancelCurrentAction = true;
156 m_errorTitle = QObject::tr("Could not move the directory/file ") +
157- targetInfo.absoluteFilePath();
158+ targetInfo->absoluteFilePath();
159 m_errorMsg = ::strerror(errno);
160 }
161 }//for
162@@ -1386,7 +1393,10 @@
163 #if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)
164 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;
165 #endif
166- if (QFile::rename(dir, tempDir))
167+ LocationItemFile *qFile = m_curAction->targetLocation->newFile(dir);
168+ bool removed = qFile->rename(tempDir);
169+ delete qFile;
170+ if (removed)
171 {
172 if (m_curAction->auxAction == 0)
173 { // this new action as Remove will remove all dirs
174@@ -1424,7 +1434,7 @@
175 {
176 const DirItemInfo& fi =
177 entry->reversedOrder.at(entry->reversedOrder.count() -1);
178- DirItemInfo backuped;
179+ QScopedPointer<DirItemInfo> backuped(m_curAction->targetLocation->newItemInfo(QLatin1String(0)));
180 int counter=0;
181 QString name;
182 do
183@@ -1447,12 +1457,12 @@
184 }
185 }
186 name.insert(pos,copy);
187- backuped.setFile(fi.absolutePath(), name);
188- } while (backuped.exists() && counter < 100);
189+ backuped->setFile(fi.absolutePath(), name);
190+ } while (backuped->exists() && counter < 100);
191 if (counter < 100)
192 {
193- entry->newName = new QString(backuped.fileName());
194- entry->itemPaths.setTargetFullName( backuped.absoluteFilePath() );
195+ entry->newName = new QString(backuped->fileName());
196+ entry->itemPaths.setTargetFullName( backuped->absoluteFilePath() );
197 ret = true;
198 }
199 }
200
201=== modified file 'src/plugin/folderlistmodel/filesystemaction.h'
202--- src/plugin/folderlistmodel/filesystemaction.h 2015-07-19 16:36:55 +0000
203+++ src/plugin/folderlistmodel/filesystemaction.h 2015-07-19 16:36:55 +0000
204@@ -49,7 +49,7 @@
205 #define AMOUNT_COPIED_TO_REFRESH_ITEM_INFO 50000000
206
207 class DirModelMimeData;
208-class QFile;
209+class LocationItemFile;
210 class QTemporaryFile;
211 class Location;
212 class LocationsFactory;
213@@ -157,12 +157,12 @@
214 CopyFile();
215 ~CopyFile();
216 void clear();
217- qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress
218- QFile * source;
219- QFile * target;
220- QString targetName;
221- bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation
222- qint64 amountSavedToRefresh;
223+ qint64 bytesWritten; // set 0 when reach bytesToNotify, notify progress
224+ LocationItemFile * source;
225+ LocationItemFile * target;
226+ QString targetName;
227+ bool isEntryItem; //true when the file being copied is at toplevel of the copy/cut operation
228+ qint64 amountSavedToRefresh;
229 };
230
231 /*!

Subscribers

People subscribed via source and target branches