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

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 436
Merged at revision: 440
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-05
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-04
Diff against target: 134 lines (+59/-14)
3 files modified
src/plugin/folderlistmodel/trash/qtrashdir.cpp (+2/-2)
src/plugin/folderlistmodel/trash/qtrashutilinfo.cpp (+27/-10)
src/plugin/folderlistmodel/trash/trashiteminfo.cpp (+30/-2)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-actions-05
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+265196@code.launchpad.net

Commit message

Improved TrashItemInfo creator to identify which is the Trash Root part

Description of the change

Actions on Trash were performed using Qt QFileInfo object, the TrashItemInfo class was improved to be used instead.

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) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugin/folderlistmodel/trash/qtrashdir.cpp'
--- src/plugin/folderlistmodel/trash/qtrashdir.cpp 2014-05-02 12:22:11 +0000
+++ src/plugin/folderlistmodel/trash/qtrashdir.cpp 2015-07-18 21:48:42 +0000
@@ -248,8 +248,8 @@
248QString QTrashDir::getSuitableTopTrashDir(const QString &mountPoint) const248QString QTrashDir::getSuitableTopTrashDir(const QString &mountPoint) const
249{249{
250 QString trashDir(getSharedTopTrashDir(mountPoint));250 QString trashDir(getSharedTopTrashDir(mountPoint));
251 //if previous shared mountPoint/Trash/$uid failed251 //if previous shared mountPoint/.Trash/$uid failed
252 //try mountPoint/Trash-$uid252 //try mountPoint/.Trash-$uid
253 if (trashDir.isEmpty())253 if (trashDir.isEmpty())
254 {254 {
255 trashDir = getSingleTopTrashDir(mountPoint, true);255 trashDir = getSingleTopTrashDir(mountPoint, true);
256256
=== modified file 'src/plugin/folderlistmodel/trash/qtrashutilinfo.cpp'
--- src/plugin/folderlistmodel/trash/qtrashutilinfo.cpp 2014-05-02 12:22:11 +0000
+++ src/plugin/folderlistmodel/trash/qtrashutilinfo.cpp 2015-07-18 21:48:42 +0000
@@ -20,13 +20,23 @@
20 */20 */
2121
22#include "qtrashutilinfo.h"22#include "qtrashutilinfo.h"
2323#include <unistd.h>
24#include <sys/types.h>
24#include <QDir>25#include <QDir>
25#include <QSettings>26#include <QSettings>
26#include <QDateTime>27#include <QDateTime>
2728
28QLatin1String filesDirString("files");29namespace
29QLatin1String infoDirString("info");30{
31 QLatin1String filesDirString("files");
32 QLatin1String infoDirString("info");
33 uint userId = ::getuid();
34 QStringList trashes = QStringList()
35 << QLatin1String("/Trash/files")
36 << QString( QString("/.Trash-") + QString::number(userId) + QLatin1String("/files"))
37 << QString( QString("/.Trash/") + QString::number(userId) + QLatin1String("/files"));
38}
39
3040
31void QTrashUtilInfo::clear()41void QTrashUtilInfo::clear()
32{42{
@@ -55,16 +65,23 @@
5565
56void QTrashUtilInfo::setInfoFromTrashItem(const QString &absTrashItem)66void QTrashUtilInfo::setInfoFromTrashItem(const QString &absTrashItem)
57{67{
58 valid = false;68 clear();
59 QFileInfo item(absTrashItem);69 //try to guess which is the Trash directory
60 if (item.absolutePath().endsWith(filesDirString))70 int trashPathIndex = -1;
71 int counter = 0;
72 for (; trashPathIndex == -1 && counter < trashes.count(); ++counter)
61 {73 {
62 QFileInfo filesUnderRoot(item.absolutePath());74 trashPathIndex = absTrashItem.indexOf(trashes.at(counter));
63 QTrashUtilInfo::setInfo(filesUnderRoot.absolutePath(), absTrashItem);
64 }75 }
65 else76 if (trashPathIndex != -1) //counter -1 points to the item found
66 {77 {
67 clear();78 trashPathIndex += trashes.at(counter-1).length();
79 // it is something under "files/" directory
80 if (trashPathIndex < absTrashItem.length() && absTrashItem.at(trashPathIndex) == QDir::separator())
81 {
82 trashPathIndex -= 6; // 6 is the length of "files/", we want to get the Trash root dir
83 QTrashUtilInfo::setInfo(absTrashItem.left(trashPathIndex), absTrashItem);
84 }
68 }85 }
69}86}
7087
7188
=== modified file 'src/plugin/folderlistmodel/trash/trashiteminfo.cpp'
--- src/plugin/folderlistmodel/trash/trashiteminfo.cpp 2014-05-17 09:58:10 +0000
+++ src/plugin/folderlistmodel/trash/trashiteminfo.cpp 2015-07-18 21:48:42 +0000
@@ -20,9 +20,15 @@
20 */20 */
2121
22#include "trashiteminfo.h"22#include "trashiteminfo.h"
23#include "qtrashutilinfo.h"
23#include "locationurl.h"24#include "locationurl.h"
2425#include <QDebug>
2526
27/*!
28 * \brief TrashItemInfo::TrashItemInfo() This constructor does not receive the Trash path
29 *
30 * \param urlPath the full pathname starting with th \a trashPath as "/home/devubuntu/.local/share/Trash/files/test.txt"
31 */
26TrashItemInfo::TrashItemInfo(const QString &urlPath)32TrashItemInfo::TrashItemInfo(const QString &urlPath)
27 : DirItemInfo() 33 : DirItemInfo()
28{ 34{
@@ -33,6 +39,22 @@
33 {39 {
34 setRoot();40 setRoot();
35 }41 }
42 else
43 {
44 QTrashUtilInfo trashInfo;
45 trashInfo.setInfoFromTrashItem(urlPath);
46 //try to guess the Trash path
47 if (trashInfo.isValid() && !trashInfo.filesDir.isEmpty())
48 {
49 //Trash path found
50 init(trashInfo.filesDir);
51 }
52 QFileInfo maybeDiskUrl(urlPath);
53 if (maybeDiskUrl.exists())
54 {
55 d_ptr->setFileInfo(maybeDiskUrl);
56 }
57 }
36}58}
3759
3860
@@ -42,6 +64,12 @@
42}64}
4365
4466
67/*!
68 * \brief TrashItemInfo::TrashItemInfo()
69 *
70 * \param trashPath the trash PATH finished with "files" like as "/home/user/.local/share/Trash/files"
71 * \param urlPath the full pathname starting with th \a trashPath as "/home/user/.local/share/Trash/files/test.txt"
72 */
45TrashItemInfo::TrashItemInfo(const QString& trashPath, const QString &urlPath)73TrashItemInfo::TrashItemInfo(const QString& trashPath, const QString &urlPath)
46 : DirItemInfo(urlPath) 74 : DirItemInfo(urlPath)
47{75{

Subscribers

People subscribed via source and target branches