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

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 447
Merged at revision: 454
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-15
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-14
Diff against target: 236 lines (+53/-45)
3 files modified
src/plugin/folderlistmodel/dirmodel.cpp (+27/-16)
src/plugin/folderlistmodel/dirmodel.h (+4/-3)
src/plugin/folderlistmodel/filesystemaction.cpp (+22/-26)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-15
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+265214@code.launchpad.net

Commit message

Qt QDir object is no longer used in Actions nor in DirModel class, instead inherited LocationItemDir classes are used

Description of the change

Qt QDir object is no longer used in Actions nor in DirModel class, instead inherited LocationItemDir classes are used

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
Arto Jalkanen (ajalkane) wrote :

One diff comment

review: Approve
Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

I was using QScopedPointer where it was really necessary, some new/delete were kept due to performance. I will change both dirmodel.cpp and filesystemaction.cpp to use only QScopedPointer instead of new/delete.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
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
Arto Jalkanen (ajalkane) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp 2015-07-25 19:25:40 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-08-16 15:16:28 +0000
@@ -40,6 +40,7 @@
40#include "disklocation.h"40#include "disklocation.h"
41#include "trashlocation.h"41#include "trashlocation.h"
42#include "netauthenticationdata.h"42#include "netauthenticationdata.h"
43#include "locationitemdir.h"
4344
4445
45#ifndef DO_NOT_USE_TAG_LIB46#ifndef DO_NOT_USE_TAG_LIB
@@ -64,6 +65,7 @@
64#include <QMimeType>65#include <QMimeType>
65#include <QStandardPaths>66#include <QStandardPaths>
66#include <QList>67#include <QList>
68#include <QScopedPointer>
6769
68#if defined(REGRESSION_TEST_FOLDERLISTMODEL)70#if defined(REGRESSION_TEST_FOLDERLISTMODEL)
69# include <QColor>71# include <QColor>
@@ -642,22 +644,24 @@
642 return retval;644 return retval;
643}645}
644646
645void DirModel::mkdir(const QString &newDir)647
648bool DirModel::mkdir(const QString &newDir)
646{649{
647 if (!allowAccess(mCurrentDir)) {650 QScopedPointer<LocationItemDir> dir(mCurLocation->newDir(mCurrentDir));
648 qDebug() << Q_FUNC_INFO << "Access denied in current path" << mCurrentDir;651 bool retval = dir->mkdir(newDir);
649 return;
650 }
651
652 QDir dir(mCurrentDir);
653 bool retval = dir.mkdir(newDir);
654 if (!retval) {652 if (!retval) {
655 const char *errorStr = strerror(errno);653 const char *errorStr = strerror(errno);
656 qDebug() << Q_FUNC_INFO << this << "Error creating new directory: " << errno << " (" << errorStr << ")";654 qDebug() << Q_FUNC_INFO << this << "Error creating new directory: " << errno << " (" << errorStr << ")";
657 emit error(QObject::tr("Error creating new folder"), errorStr);655 emit error(QObject::tr("Error creating new folder"), errorStr);
658 } else {656 } else {
659 onItemAdded(dir.filePath(newDir));657 QScopedPointer<DirItemInfo> subItem(mCurLocation->newItemInfo(newDir));
660 }658 if (subItem->isRelative())
659 {
660 subItem->setFile(mCurrentDir, newDir);
661 }
662 onItemAdded(*subItem);
663 }
664 return retval;
661}665}
662666
663bool DirModel::showDirectories() const667bool DirModel::showDirectories() const
@@ -728,19 +732,18 @@
728732
729QString DirModel::parentPath() const733QString DirModel::parentPath() const
730{734{
731 QDir dir(mCurrentDir);735 const DirItemInfo *dir = mCurLocation->info();
732 if (dir.isRoot()) {736 if (dir->isRoot()) {
733 qDebug() << Q_FUNC_INFO << this << "already at root";737 qDebug() << Q_FUNC_INFO << this << "already at root";
734 return mCurrentDir;738 return mCurrentDir;
735 }739 }
736740
737 bool success = dir.cdUp();741 if (!canReadDir(dir->absolutePath())) {
738 if (!success) {
739 qWarning() << Q_FUNC_INFO << this << "Failed to to go to parent of " << mCurrentDir;742 qWarning() << Q_FUNC_INFO << this << "Failed to to go to parent of " << mCurrentDir;
740 return mCurrentDir;743 return mCurrentDir;
741 }744 }
742 qDebug() << Q_FUNC_INFO << this << "returning" << dir.absolutePath();745 qDebug() << Q_FUNC_INFO << this << "returning" << dir->absolutePath();
743 return dir.absolutePath();746 return dir->absolutePath();
744}747}
745748
746QString DirModel::homePath() const749QString DirModel::homePath() const
@@ -1259,6 +1262,14 @@
1259 return dirFilter;1262 return dirFilter;
1260}1263}
12611264
1265/*!
1266 * \brief DirModel::dirItems() Gets a Dir number of Items, used only for Local Disk
1267 *
1268 * For remote Locations this function is not used
1269 *
1270 * \param fi
1271 * \return A string saying how many items a directory has
1272 */
1262QString DirModel::dirItems(const DirItemInfo& fi) const1273QString DirModel::dirItems(const DirItemInfo& fi) const
1263{1274{
1264 int counter = 0;1275 int counter = 0;
12651276
=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
--- src/plugin/folderlistmodel/dirmodel.h 2015-07-13 17:29:25 +0000
+++ src/plugin/folderlistmodel/dirmodel.h 2015-08-16 15:16:28 +0000
@@ -132,7 +132,7 @@
132 Q_INVOKABLE bool rename(const QString& oldName, const QString& newName);132 Q_INVOKABLE bool rename(const QString& oldName, const QString& newName);
133 Q_INVOKABLE bool rename(int row, const QString &newName);133 Q_INVOKABLE bool rename(int row, const QString &newName);
134134
135 Q_INVOKABLE void mkdir(const QString &newdir);135 Q_INVOKABLE bool mkdir(const QString &newdir);
136136
137 Q_PROPERTY(bool filterDirectories READ filterDirectories WRITE setFilterDirectories NOTIFY filterDirectoriesChanged)137 Q_PROPERTY(bool filterDirectories READ filterDirectories WRITE setFilterDirectories NOTIFY filterDirectoriesChanged)
138 bool filterDirectories() const;138 bool filterDirectories() const;
@@ -436,14 +436,15 @@
436 void needsAuthentication(const QString& user, const QString& urlPath);436 void needsAuthentication(const QString& user, const QString& urlPath);
437 437
438 /*!438 /*!
439 * \brief insertedItem()439 * \brief insertedRow()
440 *440 *
441 * It happens when a new file is inserted in an existent view,441 * It happens when a new file is inserted in an existent view,
442 * for example from \ref mkdir() or \ref paste()442 * for example from \ref mkdir() or \ref paste()
443 *443 *
444 * It can be used to make the new row visible to the user doing a scroll to444 * It can be used to make the new row visible to the user doing a scroll to
445 */445 */
446 void insertedRow(int row);446 void insertedRow(int row);
447
447 /*!448 /*!
448 * \brief progress()449 * \brief progress()
449 * Sends status about recursive and multi-items remove/move/copy450 * Sends status about recursive and multi-items remove/move/copy
450451
=== modified file 'src/plugin/folderlistmodel/filesystemaction.cpp'
--- src/plugin/folderlistmodel/filesystemaction.cpp 2015-08-16 15:16:28 +0000
+++ src/plugin/folderlistmodel/filesystemaction.cpp 2015-08-16 15:16:28 +0000
@@ -41,6 +41,7 @@
41#include "locationsfactory.h"41#include "locationsfactory.h"
42#include "locationitemdiriterator.h"42#include "locationitemdiriterator.h"
43#include "locationitemfile.h"43#include "locationitemfile.h"
44#include "locationitemdir.h"
4445
45#if defined(Q_OS_UNIX)46#if defined(Q_OS_UNIX)
46#include <sys/statvfs.h>47#include <sys/statvfs.h>
@@ -371,16 +372,15 @@
371 //ActionMove will perform a rename, so no Directory expanding is necessary372 //ActionMove will perform a rename, so no Directory expanding is necessary
372 if (entry->type != ActionMove && info->isDir() && !info->isSymLink())373 if (entry->type != ActionMove && info->isDir() && !info->isSymLink())
373 {374 {
374 LocationItemDirIterator *it =375 QScopedPointer<LocationItemDirIterator>
375 action->sourceLocation->newDirIterator(info->absoluteFilePath(),376 it (action->sourceLocation->newDirIterator(info->absoluteFilePath(),
376 QDir::AllEntries | QDir::System |377 QDir::AllEntries | QDir::System |
377 QDir::NoDotAndDotDot | QDir::Hidden,378 QDir::NoDotAndDotDot | QDir::Hidden,
378 QDirIterator::Subdirectories);379 QDirIterator::Subdirectories));
379 while (it->hasNext() && !it->next().isEmpty())380 while (it->hasNext() && !it->next().isEmpty())
380 {381 {
381 entry->reversedOrder.prepend(it->fileInfo());382 entry->reversedOrder.prepend(it->fileInfo());
382 }383 }
383 delete it;
384 }384 }
385#if DEBUG_MESSAGES385#if DEBUG_MESSAGES
386 for (int counter = 0; counter < entry->reversedOrder.count(); counter++)386 for (int counter = 0; counter < entry->reversedOrder.count(); counter++)
@@ -651,8 +651,7 @@
651 * \param entry651 * \param entry
652 */652 */
653void FileSystemAction::removeEntry(ActionEntry *entry)653void FileSystemAction::removeEntry(ActionEntry *entry)
654{654{
655 QDir dir;
656 //do one step at least655 //do one step at least
657 for(; !m_cancelCurrentAction &&656 for(; !m_cancelCurrentAction &&
658 entry->currStep < STEP_FILES &&657 entry->currStep < STEP_FILES &&
@@ -665,13 +664,13 @@
665 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);664 const DirItemInfo &fi = entry->reversedOrder.at(entry->currItem);
666 if (fi.isDir() && !fi.isSymLink())665 if (fi.isDir() && !fi.isSymLink())
667 {666 {
668 m_cancelCurrentAction = !dir.rmdir(fi.absoluteFilePath());667 QScopedPointer<LocationItemDir> dir(m_curAction->sourceLocation->newDir());
668 m_cancelCurrentAction = !dir->rmdir(fi.absoluteFilePath());
669 }669 }
670 else670 else
671 {671 {
672 LocationItemFile *qFile = m_curAction->sourceLocation->newFile(fi.absoluteFilePath());672 QScopedPointer<LocationItemFile> qFile(m_curAction->sourceLocation->newFile(fi.absoluteFilePath()));
673 m_cancelCurrentAction = !qFile->remove();673 m_cancelCurrentAction = !qFile->remove();
674 delete qFile;
675 }674 }
676#if DEBUG_REMOVE675#if DEBUG_REMOVE
677 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();676 qDebug() << Q_FUNC_INFO << "remove ret=" << !m_cancelCurrentAction << fi.absoluteFilePath();
@@ -765,16 +764,16 @@
765 )764 )
766 {765 {
767 QString entryDir = targetFrom(entry->reversedOrder.last().absoluteFilePath(), entry);766 QString entryDir = targetFrom(entry->reversedOrder.last().absoluteFilePath(), entry);
768 QDir entryDirObj(entryDir);767 QScopedPointer<LocationItemDir> entryDirObj(m_curAction->targetLocation->newDir(entryDir));
769 if (!entryDirObj.exists() && entryDirObj.mkpath(entryDir))768 if (!entryDirObj->exists() && entryDirObj->mkpath(entryDir))
770 {769 {
771 QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));770 QScopedPointer <DirItemInfo> item(m_curAction->targetLocation->newItemInfo(entryDir));
772 entry->added = true;771 entry->added = true;
773 notifyActionOnItem(*item, ItemAdded);772 notifyActionOnItem(*item, ItemAdded);
774 }773 }
775 }774 }
776 QDir d(path);775 QScopedPointer<LocationItemDir> d(m_curAction->targetLocation->newDir(path));
777 if (!d.exists() && !d.mkpath(path))776 if (!d->exists() && !d->mkpath(path))
778 {777 {
779 m_cancelCurrentAction = true;778 m_cancelCurrentAction = true;
780 m_errorTitle = QObject::tr("Could not create the directory");779 m_errorTitle = QObject::tr("Could not create the directory");
@@ -794,10 +793,8 @@
794 else793 else
795 if (fi.isDir())794 if (fi.isDir())
796 {795 {
797 LocationItemFile *qFile = m_curAction->targetLocation->newFile(target);796 QScopedPointer<LocationItemFile> qFile(m_curAction->targetLocation->newFile(target));
798 m_cancelCurrentAction = !797 m_cancelCurrentAction = !qFile->setPermissions(fi.permissions());
799 qFile->setPermissions(fi.permissions());
800 delete qFile;
801 if (m_cancelCurrentAction)798 if (m_cancelCurrentAction)
802 {799 {
803 m_errorTitle = QObject::tr("Could not set permissions to dir");800 m_errorTitle = QObject::tr("Could not set permissions to dir");
@@ -1393,9 +1390,8 @@
1393#if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)1390#if defined(DEBUG_MESSAGES) || defined(REGRESSION_TEST_FOLDERLISTMODEL)
1394 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;1391 qDebug() << Q_FUNC_INFO << dir << "being moved to" << tempDir;
1395#endif1392#endif
1396 LocationItemFile *qFile = m_curAction->targetLocation->newFile(dir);1393 QScopedPointer<LocationItemFile> qFile(m_curAction->targetLocation->newFile(dir));
1397 bool removed = qFile->rename(tempDir);1394 bool removed = qFile->rename(tempDir);
1398 delete qFile;
1399 if (removed)1395 if (removed)
1400 {1396 {
1401 if (m_curAction->auxAction == 0)1397 if (m_curAction->auxAction == 0)

Subscribers

People subscribed via source and target branches