Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-02 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 387
Merged at revision: 396
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-02
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-01
Diff against target: 177 lines (+49/-61)
2 files modified
src/plugin/folderlistmodel/dirmodel.cpp (+48/-60)
src/plugin/folderlistmodel/dirmodel.h (+1/-1)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-02
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+252217@code.launchpad.net

Commit message

Some DirItemInfo::isDir() changed by DirItemInfo::isBrowasable()
Renamed DirModel::cdInto() to DirModel::cdIntoItem()
Improved DirModel::cdIntoIndex() and DirModel::cdIntoPath()

Description of the change

Some DirItemInfo::isDir() changed by DirItemInfo::isBrowasable()
Renamed DirModel::cdInto() to DirModel::cdIntoItem()
Improved DirModel::cdIntoIndex() and DirModel::cdIntoPath()

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: Needs Information
Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Please see inlined comment with my question

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

The code already in place prevents this by setting the last item to null before parsing a new url/path, see http://bazaar.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-02/view/head:/src/plugin/folderlistmodel/locationsfactory.cpp#L109 and http://bazaar.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-02/view/head:/src/plugin/folderlistmodel/locationsfactory.cpp#L181.

The idea of LocationsFactory::lastValidFileInfo() is: Every time a new url/path is entered in DirModel::setPath() it is parsed by LocationsFactory, when it is browsable (it is a directory or host or workgroup) it is opened and items are fetched, when it is not browsable but exits it is saved and it is active until next url/path be parsed.
I think this does not change the behaviour of the current version, except that it will try to open files while ubuntu filemanager uses content hub to open files, I thought about creating a flag/property "openFiles" which defaults to "false" and it will be checked before trying to open files. Let me know if you agree with this so I can add this.

I tested that use case again to make sure it does not happen.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

I do not understand this, but I trust your explanation. I will approve it now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
2--- src/plugin/folderlistmodel/dirmodel.cpp 2015-03-08 12:04:13 +0000
3+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-03-08 12:04:13 +0000
4@@ -881,13 +881,9 @@
5 bool DirModel::cdIntoIndex(int row)
6 {
7 bool ret = false;
8- if (IS_VALID_ROW(row) &&
9- mDirectoryContents.at(row).isDir() &&
10- mDirectoryContents.at(row).isContentReadable())
11+ if (IS_VALID_ROW(row))
12 {
13- mCurLocation->setInfoItem(mDirectoryContents.at(row));
14- setPathFromCurrentLocation();
15- ret = true;
16+ ret = cdIntoItem(mDirectoryContents.at(row));
17 }
18 else
19 {
20@@ -896,42 +892,29 @@
21 return ret;
22 }
23
24-
25+/*!
26+ * \brief DirModel::cdIntoPath() It is used to go into an item from the current path or to a absolute path
27+ * \param filename
28+ * \return
29+ */
30 bool DirModel::cdIntoPath(const QString &filename)
31 {
32- bool ret = false;
33- DirItemInfo fi(filename);
34- if (fi.isValid())
35- {
36- if (fi.isRelative())
37- {
38- fi.setFile(mCurrentDir, filename);
39- }
40- ret = cdInto(fi);
41- }
42- return ret;
43+ return openPath(filename);
44 }
45
46
47-bool DirModel::cdInto(const DirItemInfo &fi)
48+bool DirModel::cdIntoItem(const DirItemInfo &fi)
49 {
50 bool ret = false;
51- if (canReadDir(fi.diskFileInfo()))
52- {
53- if (fi.isRelative())
54- {
55- QDir childDir(mCurrentDir);
56- if ( childDir.cd(fi.fileName()) )
57- {
58- setPath(childDir.absolutePath());
59- ret = true;
60- }
61- }
62- else
63- {
64+ if (fi.isBrowsable())
65+ {
66+ if (fi.isContentReadable())
67+ {
68+ mCurLocation->setInfoItem(fi);
69+ setPathFromCurrentLocation();
70 ret = true;
71- setPath(fi.absoluteFilePath());
72 }
73+
74 }
75 return ret;
76 }
77@@ -1282,7 +1265,7 @@
78 bool ret = false;
79 if (IS_VALID_ROW(row))
80 {
81- if (mDirectoryContents.at(row).isDir())
82+ if (mDirectoryContents.at(row).isBrowsable())
83 {
84 ret = cdIntoIndex(row);
85 }
86@@ -1298,27 +1281,35 @@
87 return ret;
88 }
89
90+
91 bool DirModel::openPath(const QString &filename)
92 {
93 bool ret = false;
94- //first void any relative path when is root
95- if ( !(mCurLocation && mCurLocation->isRoot() && filename.startsWith(QLatin1String(".."))) )
96+ QString myFilename(filename.trimmed());
97+ //first avoid any relative path when is root
98+ if ( !(mCurLocation && mCurLocation->isRoot() && myFilename.startsWith(QLatin1String(".."))) )
99 {
100- Location *location = mLocationFactory->setNewPath(filename);
101- if (location)
102+ if (myFilename == QLatin1String("..") || myFilename == QLatin1String("../"))
103 {
104- mCurLocation = location;
105- setPathFromCurrentLocation();
106- ret = true;
107+ ret = cdUp();
108 }
109 else
110 {
111- const DirItemInfo *item = mLocationFactory->lastValidFileInfo();
112- // DirItemInfo fi(setParentIfRelative(filename));
113- if (item && item->isFile())
114- {
115- ret = openItem(*item);
116- }
117+ Location *location = mLocationFactory->setNewPath(myFilename);
118+ if (location)
119+ {
120+ mCurLocation = location;
121+ setPathFromCurrentLocation();
122+ ret = true;
123+ }
124+ else
125+ {
126+ const DirItemInfo *item = mLocationFactory->lastValidFileInfo();
127+ if (item && item->isFile())
128+ {
129+ ret = openItem(*item);
130+ }
131+ }
132 }
133 }
134 return ret;
135@@ -1332,19 +1323,16 @@
136 bool DirModel::openItem(const DirItemInfo &fi)
137 {
138 bool ret = false;
139- if (fi.isLocal())
140- {
141- if (canReadDir(fi.diskFileInfo()))
142- {
143- ret = cdInto(fi.diskFileInfo());
144- }
145- else
146- {
147- //TODO open executables
148- if (canReadFile(fi.diskFileInfo()))
149- {
150- ret = QDesktopServices::openUrl(QUrl::fromLocalFile(fi.absoluteFilePath()));
151- }
152+ if (fi.isBrowsable())
153+ {
154+ ret = cdIntoItem(fi);
155+ }
156+ else
157+ {
158+ //TODO open executables
159+ if (fi.isLocal() && fi.isReadable())
160+ {
161+ ret = QDesktopServices::openUrl(QUrl::fromLocalFile(fi.absoluteFilePath()));
162 }
163 }
164 return ret;
165
166=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
167--- src/plugin/folderlistmodel/dirmodel.h 2015-03-08 12:04:13 +0000
168+++ src/plugin/folderlistmodel/dirmodel.h 2015-03-08 12:04:13 +0000
169@@ -459,7 +459,7 @@
170 int rowOfItem(const DirItemInfo& fi);
171 QDir::Filter currentDirFilter() const;
172 QString dirItems(const DirItemInfo& fi) const;
173- bool cdInto(const DirItemInfo& fi);
174+ bool cdIntoItem(const DirItemInfo& fi);
175 bool openItem(const DirItemInfo& fi);
176 bool canReadDir(const QFileInfo& d) const;
177 bool canReadFile(const QFileInfo& f) const;

Subscribers

People subscribed via source and target branches