Merge lp:~carlos-mazieri/ubuntu-filemanager-app/plugin-goback-feature into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Carlos Jose Mazieri
Approved revision: 267
Merged at revision: 276
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/plugin-goback-feature
Merge into: lp:ubuntu-filemanager-app
Diff against target: 118 lines (+39/-3)
5 files modified
src/plugin/folderlistmodel/dirmodel.cpp (+23/-1)
src/plugin/folderlistmodel/dirmodel.h (+8/-0)
src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp (+1/-0)
src/plugin/test_folderlistmodel/simpleUI/simplelist.ui (+1/-1)
src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp (+6/-1)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/plugin-goback-feature
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+233283@code.launchpad.net

Commit message

Just implemented a goBack() navigation feature

Description of the change

Just implemented a goBack() navigation feature, it differs from cdUp().

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 :

Looks proper.

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 2014-08-09 19:57:42 +0000
3+++ src/plugin/folderlistmodel/dirmodel.cpp 2014-09-03 22:28:01 +0000
4@@ -433,6 +433,12 @@
5 Location *location = mLocationFactory->setNewPath(pathName);
6 if (location == 0)
7 {
8+ // perhaps a goBack() operation to a folder/location that was removed,
9+ // in this case we remove that folder/location from the list
10+ if (mPathList.count() > 0 && mPathList.last() == pathName)
11+ {
12+ mPathList.removeLast();
13+ }
14 emit error(tr("path or url may not exist or cannot be read"), pathName);
15 qDebug() << Q_FUNC_INFO << this << "path or url may not exist or cannot be read:" << pathName;
16 return;
17@@ -459,11 +465,27 @@
18
19 mCurLocation->fetchItems(currentDirFilter(), mIsRecursive);
20
21- mCurrentDir = mCurLocation->urlPath();
22+ mCurrentDir = mCurLocation->urlPath();
23+ if (mPathList.count() == 0 || mPathList.last() != mCurrentDir)
24+ {
25+ mPathList.append(mCurrentDir);
26+ }
27 emit pathChanged(mCurLocation->urlPath());
28 }
29
30
31+void DirModel::goBack()
32+{
33+ if (mPathList.count() > 1 && !mAwaitingResults)
34+ {
35+ mPathList.removeLast();
36+#if DEBUG_MESSAGES
37+ qDebug() << Q_FUNC_INFO << this << "changing to" << mPathList.last();
38+#endif
39+ setPath(mPathList.last());
40+ }
41+}
42+
43 void DirModel::onItemsFetched() {
44 if (mAwaitingResults) {
45 #if DEBUG_MESSAGES
46
47=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
48--- src/plugin/folderlistmodel/dirmodel.h 2014-08-09 19:31:32 +0000
49+++ src/plugin/folderlistmodel/dirmodel.h 2014-09-03 22:28:01 +0000
50@@ -351,6 +351,13 @@
51 void goTrash();
52
53 /*!
54+ * \brief goBack() goes to the previous folder if available
55+ *
56+ */
57+ void goBack();
58+
59+
60+ /*!
61 * \brief cdUp() sets the parent directory as current directory
62 *
63 * It can work as a back function if there is no user input path
64@@ -457,6 +464,7 @@
65 DirSelection * mSelection;
66 LocationsFactory * mLocationFactory;
67 Location * mCurLocation;
68+ QStringList mPathList; //!< it will be used for goBack()
69
70 private:
71 FileSystemAction * m_fsAction; //!< it does file system recursive remove/copy/move
72
73=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp'
74--- src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp 2014-08-13 15:25:21 +0000
75+++ src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp 2014-09-03 22:28:01 +0000
76@@ -123,6 +123,7 @@
77 this, SLOT(onPathChanged(QString)));
78
79 connect(ui->toolButtonUp, SIGNAL(clicked()), m_model, SLOT(cdUp()));
80+ connect(ui->toolButtonBack, SIGNAL(clicked()), m_model, SLOT(goBack()));
81 connect(ui->actionCopy, SIGNAL(triggered()), m_model, SLOT(copySelection()));
82 connect(ui->actionCut, SIGNAL(triggered()), m_model, SLOT(cutSelection()));
83 connect(ui->actionDelete, SIGNAL(triggered()), m_model, SLOT(removeSelection()));
84
85=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simplelist.ui'
86--- src/plugin/test_folderlistmodel/simpleUI/simplelist.ui 2014-08-13 15:25:21 +0000
87+++ src/plugin/test_folderlistmodel/simpleUI/simplelist.ui 2014-09-03 22:28:01 +0000
88@@ -20,7 +20,7 @@
89 <item>
90 <widget class="QToolButton" name="toolButtonBack">
91 <property name="enabled">
92- <bool>false</bool>
93+ <bool>true</bool>
94 </property>
95 <property name="text">
96 <string>back</string>
97
98=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp'
99--- src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp 2014-08-13 15:25:21 +0000
100+++ src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp 2014-09-03 22:28:01 +0000
101@@ -133,11 +133,16 @@
102
103 void SimpleList::onPathChanged(QString path)
104 {
105- if (ui->comboBoxPath->findText(path) == -1)
106+ int index = ui->comboBoxPath->findText(path);
107+ if (index == -1)
108 {
109 ui->comboBoxPath->insertItem(0, path);
110 ui->comboBoxPath->setCurrentIndex(0);
111 }
112+ else
113+ {
114+ ui->comboBoxPath->setCurrentIndex(index);
115+ }
116 this->setWindowTitle(path);
117 allowTrashActions(false);
118 }

Subscribers

People subscribed via source and target branches