ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #03647
[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-04 into lp:ubuntu-filemanager-app
Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-04 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-03 as a prerequisite.
Commit message:
FileSystemAction needs to interact with Locations, it now depends from LocationsFactory and Locations classes.
The following methods were removed because the Location where the Action was performed needs to create its DirIteminfo for its items:
* Removed signals FileSystemAction::added(QString) and FileSystemAction::removed(QString)
* Removed slots DirModel::onItemAdded(QString) and DirModel::onItemRemoved(QString)
FileSystemAction::isThereDiskSpace() was removed and Location::isThereDiskSpace() is used.
Requested reviews:
Ubuntu File Manager Developers (ubuntu-filemanager-dev)
For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-actions-04/+merge/265195
Preparing FileSystemAction class to work based on Locations
--
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-04 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp 2015-07-18 21:41:28 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-07-18 21:41:28 +0000
@@ -114,7 +114,7 @@
, mAuthData(NetAuthenticationDataList::getInstance(this))
, mLocationFactory(new LocationsFactory(this))
, mCurLocation(0)
- , m_fsAction(new FileSystemAction(this) )
+ , m_fsAction(new FileSystemAction(mLocationFactory,this) )
{
mNameFilters = QStringList() << "*";
@@ -126,15 +126,9 @@
connect(m_fsAction, SIGNAL(added(DirItemInfo)),
this, SLOT(onItemAdded(DirItemInfo)));
- connect(m_fsAction, SIGNAL(added(QString)),
- this, SLOT(onItemAdded(QString)));
-
connect(m_fsAction, SIGNAL(removed(DirItemInfo)),
this, SLOT(onItemRemoved(DirItemInfo)));
- connect(m_fsAction, SIGNAL(removed(QString)),
- this, SLOT(onItemRemoved(QString)));
-
connect(m_fsAction, SIGNAL(error(QString,QString)),
this, SIGNAL(error(QString,QString)));
@@ -960,16 +954,6 @@
return ret;
}
-/*!
- * \brief DirModel::onItemRemoved()
- * \param pathname full pathname of removed file
- */
-void DirModel::onItemRemoved(const QString &pathname)
-{
- DirItemInfo info(pathname);
- onItemRemoved(info);
-}
-
void DirModel::onItemRemoved(const DirItemInfo &fi)
{
@@ -993,17 +977,6 @@
}
-/*!
- * \brief DirModel::onItemAdded()
- * \param pathname full pathname of the added file
- */
-void DirModel::onItemAdded(const QString &pathname)
-{
- DirItemInfo info(pathname);
- onItemAdded(info);
-}
-
-
void DirModel::onItemAdded(const DirItemInfo &fi)
{
int newRow = addItem(fi);
@@ -1516,7 +1489,7 @@
bool DirModel::canReadDir(const QString &folderName) const
{
DirItemInfo d = setParentIfRelative(folderName);
- return d.isDir() && d.isReadable();
+ return d.isDir() && d.isReadable() && d.isExecutable();
}
=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
--- src/plugin/folderlistmodel/dirmodel.h 2015-07-18 21:41:28 +0000
+++ src/plugin/folderlistmodel/dirmodel.h 2015-07-18 21:41:28 +0000
@@ -461,10 +461,8 @@
void clipboardChanged();
void enabledExternalFSWatcherChanged(bool);
-private slots:
- void onItemRemoved(const QString&);
- void onItemRemoved(const DirItemInfo&);
- void onItemAdded(const QString&);
+private slots:
+ void onItemRemoved(const DirItemInfo&);
void onItemAdded(const DirItemInfo&);
void onItemChanged(const DirItemInfo&);
=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
--- src/plugin/folderlistmodel/filesystemaction.cpp 2014-12-29 11:29:21 +0000
+++ src/plugin/folderlistmodel/filesystemaction.cpp 2015-07-18 21:41:28 +0000
@@ -37,6 +37,9 @@
#include "filesystemaction.h"
#include "clipboard.h"
#include "qtrashutilinfo.h"
+#include "location.h"
+#include "locationsfactory.h"
+
#if defined(Q_OS_UNIX)
#include <sys/statvfs.h>
@@ -51,6 +54,7 @@
#include <QDir>
#include <QThread>
#include <QTemporaryFile>
+#include <QScopedPointer>
/*!
* number of the files to work on a step, when this number is reached a signal is emitted
@@ -177,14 +181,16 @@
//===============================================================================================
/*!
* \brief FileSystemAction::FileSystemAction
+ * \param LocationsFactory locationsFactory
* \param parent
*/
-FileSystemAction::FileSystemAction(QObject *parent) :
+FileSystemAction::FileSystemAction(LocationsFactory *locationsFactory, QObject *parent) :
QObject(parent)
, m_curAction(0)
, m_cancelCurrentAction(false)
, m_busy(false)
, m_clipboardChanged(false)
+ , m_locationsFactory(locationsFactory)
#if defined(REGRESSION_TEST_FOLDERLISTMODEL) //used in Unit/Regression tests
, m_forceUsingOtherFS(false)
#endif
@@ -475,7 +481,7 @@
{
removeTrashInfoFileFromEntry(curEntry);
}
- emit removed(mainItem);
+ notifyActionOnItem(mainItem, ItemRemoved);
}
else
{
@@ -487,21 +493,24 @@
//it is necessary to remove also (file).trashinfo file
removeTrashInfoFileFromEntry(curEntry);
}
- emit removed(mainItem);
+ notifyActionOnItem(mainItem, ItemRemoved);
break;
case ActionHardMoveRemove: // nothing to do
break;
case ActionHardMoveCopy:
case ActionCopy: // ActionHardMoveCopy is lso checked here
case ActionMove:
- if (!curEntry->added && !curEntry->alreadyExists)
- {
- emit added(curEntry->itemPaths.target());
- curEntry->added = true;
- }
- else
- {
- emit changed(DirItemInfo(curEntry->itemPaths.target()));
+ {
+ QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(curEntry->itemPaths.target()));
+ if (!curEntry->added && !curEntry->alreadyExists)
+ {
+ curEntry->added = true;
+ notifyActionOnItem(*item, ItemAdded);
+ }
+ else
+ {
+ notifyActionOnItem(*item, ItemChanged);
+ }
}
if (curEntry->type == ActionHardMoveCopy)
{
@@ -674,8 +683,9 @@
QDir entryDirObj(entryDir);
if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))
{
- emit added(entryDir);
+ QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(entryDir));
entry->added = true;
+ notifyActionOnItem(*item, ItemAdded);
}
}
QDir d(path);
@@ -732,11 +742,11 @@
needsSize -= m_curAction->copyFile.target->size();
m_curAction->copyFile.target->close();
}
- //check if there is disk space to copy source to target
- if (needsSize > 0 && !isThereDiskSpace(entry, needsSize ))
+ //check if there is disk space to copy source to target
+ if (needsSize > 0 && !m_locationsFactory->currentLocation()->isThereDiskSpace(entry->itemPaths.targetPath(), needsSize))
{
m_cancelCurrentAction = true;
- m_errorTitle = QObject::tr("There is no space on disk to copy");
+ m_errorTitle = QObject::tr("There is no space to copy");
m_errorMsg = m_curAction->copyFile.target->fileName();
}
}
@@ -758,14 +768,15 @@
//depending on the file size it may take longer, the view needs to be informed
if (m_curAction->copyFile.isEntryItem && !m_cancelCurrentAction)
{
+ QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(target));
if (!entry->alreadyExists)
- {
- emit added(target);
+ {
entry->added = true;
+ notifyActionOnItem(*item, ItemAdded);
}
else
- {
- emit changed(DirItemInfo(target));
+ {
+ notifyActionOnItem(*item, ItemChanged);
}
}
}
@@ -1143,8 +1154,9 @@
m_curAction->copyFile.target->close();
}
if (m_curAction->copyFile.target->remove())
- {
- emit removed(m_curAction->copyFile.targetName);
+ {
+ QScopedPointer<DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(m_curAction->copyFile.targetName));
+ notifyActionOnItem(*item, ItemRemoved);
}
}
m_curAction->copyFile.clear();
@@ -1172,8 +1184,9 @@
notifyProgress();
if (m_curAction->copyFile.isEntryItem && m_curAction->copyFile.amountSavedToRefresh <= 0)
{
+ QScopedPointer <DirItemInfo> item(m_locationsFactory->currentLocation()->newItemInfo(m_curAction->copyFile.targetName));
m_curAction->copyFile.amountSavedToRefresh = AMOUNT_COPIED_TO_REFRESH_ITEM_INFO;
- emit changed(DirItemInfo(m_curAction->copyFile.targetName));
+ notifyActionOnItem(*item, ItemChanged);
}
scheduleSlot(SLOT(processCopySingleFile()));
}
@@ -1415,21 +1428,6 @@
return ret;
}
-//==================================================================
-bool FileSystemAction::isThereDiskSpace(const ActionEntry *entry, qint64 requiredSize)
-{
- bool ret = true;
-#if defined(Q_OS_UNIX)
- struct statvfs vfs;
- if ( ::statvfs( QFile::encodeName(entry->itemPaths.targetPath()).constData(), &vfs) == 0 )
- {
- qint64 free = vfs.f_bsize * vfs.f_bfree;
- ret = free > requiredSize;
- }
-#endif
- return ret;
-}
-
//==================================================================
/*!
@@ -1508,3 +1506,16 @@
m_errorMsg = trashUtil.absInfo;
}
}
+
+
+void FileSystemAction::notifyActionOnItem(const DirItemInfo& item, ActionNotification action)
+{
+ switch(action)
+ {
+ case ItemAdded: emit added(item); break;
+ case ItemRemoved: emit removed(item); break;
+ case ItemChanged: emit changed(item); break;
+ default: break;
+ }
+}
+
=== modified file 'src/plugin/folderlistmodel/filesystemaction.h'
--- src/plugin/folderlistmodel/filesystemaction.h 2014-06-17 20:42:35 +0000
+++ src/plugin/folderlistmodel/filesystemaction.h 2015-07-18 21:41:28 +0000
@@ -51,7 +51,8 @@
class DirModelMimeData;
class QFile;
class QTemporaryFile;
-
+class Location;
+class LocationsFactory;
/*!
* \brief The FileSystemAction class does file system operations copy/cut/paste/remove items
@@ -95,7 +96,7 @@
{
Q_OBJECT
public:
- explicit FileSystemAction(QObject *parent = 0);
+ explicit FileSystemAction(LocationsFactory *locationsFactory, QObject *parent = 0);
~FileSystemAction();
public:
@@ -116,9 +117,7 @@
signals:
void error(const QString& errorTitle, const QString &errorMessage);
- void removed(const QString& item);
void removed(const DirItemInfo&);
- void added(const QString& );
void added(const DirItemInfo& );
void changed(const DirItemInfo&);
void progress(int curItem, int totalItems, int percent);
@@ -131,6 +130,13 @@
bool processCopySingleFile();
private:
+ enum ActionNotification
+ {
+ ItemAdded,
+ ItemRemoved,
+ ItemChanged
+ };
+
enum ActionType
{
ActionRemove,
@@ -213,6 +219,7 @@
QString m_errorTitle;
QString m_errorMsg;
bool m_clipboardChanged; //!< this is set to false in \ref moveIntoCurrentPath() and \ref copyIntoCurrentPath();
+ LocationsFactory * m_locationsFactory;
private:
@@ -232,10 +239,10 @@
void moveDirToTempAndRemoveItLater(const QString& dir);
bool makeBackupNameForCurrentItem(ActionEntry *entry);
bool endCopySingleFile();
- bool isThereDiskSpace(const ActionEntry *entry, qint64 requiredSize);
void queueAction(Action *myAction);
void createTrashInfoFileFromEntry(ActionEntry *entry);
void removeTrashInfoFileFromEntry(ActionEntry *entry);
+ void notifyActionOnItem(const DirItemInfo& item, ActionNotification action);
#if defined(REGRESSION_TEST_FOLDERLISTMODEL) //used in Unit/Regression tests
bool m_forceUsingOtherFS;
=== modified file 'src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp'
--- src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp 2015-07-18 21:41:28 +0000
+++ src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp 2015-07-18 21:41:28 +0000
@@ -74,9 +74,7 @@
TestDirModel();
~TestDirModel();
-protected slots:
- void slotFileAdded(const QString& s) {m_filesAdded.append(s); }
- void slotFileRemoved(const QString& s) {m_filesRemoved.append(s); }
+protected slots:
void slotFileAdded(const DirItemInfo& f) {m_filesAdded.append(f.absoluteFilePath()); }
void slotFileRemoved(const DirItemInfo& f) {m_filesRemoved.append(f.absoluteFilePath()); }
void slotPathChamged(QString path) { m_currentPath = path;}
@@ -211,17 +209,13 @@
};
-TestDirModel::TestDirModel() : m_deepDir_01(0)
+TestDirModel::TestDirModel() : fsAction(new LocationsFactory(this), this)
+ ,m_deepDir_01(0)
,m_deepDir_02(0)
,m_deepDir_03(0)
,m_dirModel_01(0)
,m_dirModel_02(0)
-{
- connect(&fsAction, SIGNAL(added(QString)),
- this, SLOT(slotFileAdded(QString)) );
- connect(&fsAction, SIGNAL(removed(QString)),
- this, SLOT(slotFileRemoved(QString)) );
-
+{
connect(&fsAction, SIGNAL(added(DirItemInfo)),
this, SLOT(slotFileAdded(DirItemInfo)));
connect(&fsAction, SIGNAL(removed(DirItemInfo)),
@@ -401,19 +395,11 @@
m_dirModel_01 = new DirModel();
m_dirModel_02 = new DirModel();
- connect(m_dirModel_01->m_fsAction, SIGNAL(added(QString)),
- this, SLOT(slotFileAdded(QString)) );
- connect(m_dirModel_01->m_fsAction, SIGNAL(removed(QString)),
- this, SLOT(slotFileRemoved(QString)) );
connect(m_dirModel_01->m_fsAction, SIGNAL(added(DirItemInfo)),
this, SLOT(slotFileAdded(DirItemInfo)));
connect(m_dirModel_01->m_fsAction, SIGNAL(removed(DirItemInfo)),
this, SLOT(slotFileRemoved(DirItemInfo)));
- connect(m_dirModel_02->m_fsAction, SIGNAL(added(QString)),
- this, SLOT(slotFileAdded(QString)) );
- connect(m_dirModel_02->m_fsAction, SIGNAL(removed(QString)),
- this, SLOT(slotFileRemoved(QString)) );
connect(m_dirModel_02->m_fsAction, SIGNAL(added(DirItemInfo)),
this, SLOT(slotFileAdded(DirItemInfo)));
connect(m_dirModel_02->m_fsAction, SIGNAL(removed(DirItemInfo)),
Follow ups