← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-15 into lp:ubuntu-filemanager-app

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-15 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-14 as a prerequisite.

Commit message:
Qt QDir object is no longer used in Actions nor in DirModel class, instead inherited LocationItemDir classes are 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-15/+merge/265214

Qt QDir object is no longer used in Actions nor in DirModel class, instead inherited LocationItemDir classes are used
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-15 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp	2015-07-19 16:40:43 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp	2015-07-19 16:40:43 +0000
@@ -40,6 +40,7 @@
 #include "disklocation.h"
 #include "trashlocation.h"
 #include "netauthenticationdata.h"
+#include "locationitemdir.h"
 
 
 #ifndef DO_NOT_USE_TAG_LIB
@@ -64,6 +65,7 @@
 #include <QMimeType>
 #include <QStandardPaths>
 #include <QList>
+#include <QScopedPointer>
 
 #if defined(REGRESSION_TEST_FOLDERLISTMODEL)
 # include <QColor>
@@ -642,22 +644,26 @@
     return retval;
 }
 
-void DirModel::mkdir(const QString &newDir)
+
+bool DirModel::mkdir(const QString &newDir)
 {
-    if (!allowAccess(mCurrentDir)) {
-        qDebug() << Q_FUNC_INFO << "Access denied in current path" << mCurrentDir;
-        return;
-    }
-
-    QDir dir(mCurrentDir);
-    bool retval = dir.mkdir(newDir);
+    LocationItemDir *dir = mCurLocation->newDir(mCurrentDir);
+    bool retval = dir->mkdir(newDir);
     if (!retval) {
         const char *errorStr = strerror(errno);
         qDebug() << Q_FUNC_INFO << this << "Error creating new directory: " << errno << " (" << errorStr << ")";
         emit error(QObject::tr("Error creating new folder"), errorStr);
     } else {
-        onItemAdded(dir.filePath(newDir));
+        DirItemInfo *subItem = mCurLocation->newItemInfo(newDir);
+        if (subItem->isRelative())
+        {
+            subItem->setFile(mCurrentDir, newDir);
+        }
+        onItemAdded(*subItem);
+        delete subItem;
     }
+    delete dir;
+    return retval;
 }
 
 bool DirModel::showDirectories() const
@@ -728,19 +734,18 @@
 
 QString DirModel::parentPath() const
 {
-    QDir dir(mCurrentDir);
-    if (dir.isRoot()) {
+    const DirItemInfo *dir = mCurLocation->info();
+    if (dir->isRoot()) {
         qDebug() << Q_FUNC_INFO << this << "already at root";
         return mCurrentDir;
     }
 
-    bool success = dir.cdUp();
-    if (!success) {
+    if (!canReadDir(dir->absolutePath())) {
         qWarning() << Q_FUNC_INFO << this << "Failed to to go to parent of " << mCurrentDir;
         return mCurrentDir;
     }
-    qDebug() << Q_FUNC_INFO << this << "returning" << dir.absolutePath();
-    return dir.absolutePath();
+    qDebug() << Q_FUNC_INFO << this << "returning" << dir->absolutePath();
+    return dir->absolutePath();
 }
 
 QString DirModel::homePath() const
@@ -1259,6 +1264,14 @@
     return dirFilter;
 }
 
+/*!
+ * \brief DirModel::dirItems() Gets a Dir number of Items, used only for Local Disk
+ *
+ *    For remote Locations this function is not used
+ *
+ * \param fi
+ * \return A string saying how many items a directory has
+ */
 QString DirModel::dirItems(const DirItemInfo& fi) const
 {
     int counter = 0;

=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
--- src/plugin/folderlistmodel/dirmodel.h	2015-07-19 16:40:43 +0000
+++ src/plugin/folderlistmodel/dirmodel.h	2015-07-19 16:40:43 +0000
@@ -132,7 +132,7 @@
     Q_INVOKABLE bool rename(const QString& oldName, const QString& newName);
     Q_INVOKABLE bool rename(int row, const QString &newName);
 
-    Q_INVOKABLE void mkdir(const QString &newdir);
+    Q_INVOKABLE bool mkdir(const QString &newdir);
 
     Q_PROPERTY(bool filterDirectories READ filterDirectories WRITE setFilterDirectories NOTIFY filterDirectoriesChanged)
     bool filterDirectories() const;
@@ -436,14 +436,15 @@
     void     needsAuthentication(const QString& user, const QString& urlPath);
     
     /*!
-     * \brief insertedItem()
+     * \brief insertedRow()
      *
      *  It happens when a new file is inserted in an existent view,
      *  for example from  \ref mkdir() or \ref paste()
      *
      *  It can be used to make the new row visible to the user doing a scroll to
-     */
+     */    
     void  insertedRow(int row);
+
     /*!
      * \brief progress()
      *  Sends status about recursive and multi-items remove/move/copy

=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
--- src/plugin/folderlistmodel/filesystemaction.cpp	2015-07-19 16:40:43 +0000
+++ src/plugin/folderlistmodel/filesystemaction.cpp	2015-07-19 16:40:43 +0000
@@ -41,6 +41,7 @@
 #include "locationsfactory.h"
 #include "locationitemdiriterator.h"
 #include "locationitemfile.h"
+#include "locationitemdir.h"
 
 #if defined(Q_OS_UNIX)
 #include <sys/statvfs.h>
@@ -651,8 +652,7 @@
  * \param entry
  */
 void FileSystemAction::removeEntry(ActionEntry *entry)
-{
-    QDir dir;
+{   
     //do one step at least
     for(; !m_cancelCurrentAction                          &&
           entry->currStep       < STEP_FILES              &&
@@ -665,7 +665,9 @@
         const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
         if (fi.isDir() && !fi.isSymLink())
         {
-            m_cancelCurrentAction = !dir.rmdir(fi.absoluteFilePath());
+            LocationItemDir * dir = m_curAction->sourceLocation->newDir();
+            m_cancelCurrentAction = !dir->rmdir(fi.absoluteFilePath());
+            delete dir;
         }
         else
         {
@@ -765,16 +767,16 @@
            )
         {
             QString entryDir = targetFrom(entry->reversedOrder.last().absoluteFilePath(), entry);
-            QDir entryDirObj(entryDir);
-            if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))
+            QScopedPointer<LocationItemDir> entryDirObj(m_curAction->targetLocation->newDir(entryDir));
+            if (!entryDirObj->exists() && entryDirObj->mkpath(entryDir))
             {
                 QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));
                 entry->added = true;
                 notifyActionOnItem(*item, ItemAdded);
-            }
-        }
-        QDir d(path);
-        if (!d.exists() && !d.mkpath(path))
+            }           
+        }      
+        QScopedPointer<LocationItemDir> d(m_curAction->targetLocation->newDir(path));
+        if (!d->exists() && !d->mkpath(path))
         {
             m_cancelCurrentAction = true;
             m_errorTitle = QObject::tr("Could not create the directory");


Follow ups