Merge lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri on 2015-11-02
Status: Merged
Approved by: Arto Jalkanen on 2015-11-03
Approved revision: 495
Merged at revision: 496
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-02
Diff against target: 106 lines (+71/-0)
2 files modified
src/plugin/folderlistmodel/dirmodel.cpp (+40/-0)
src/plugin/folderlistmodel/dirmodel.h (+31/-0)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03
Reviewer Review Type Date Requested Status
Arto Jalkanen 2015-11-02 Approve on 2015-11-03
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-11-02
Jenkins Bot continuous-integration Approve on 2015-11-02
Review via email: mp+276446@code.launchpad.net

Commit message

implemented a set of high level download functions.

Description of the change

implemented a set of high level download functions.

To post a comment you must log in.
review: Approve (continuous-integration)
review: Approve (continuous-integration)
Arto Jalkanen (ajalkane) :
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-10-01 00:04:00 +0000
3+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-11-02 19:19:16 +0000
4@@ -149,6 +149,9 @@
5 connect(m_fsAction, SIGNAL(recopy(QStringList,QString)),
6 mClipboard, SLOT(copy(QStringList,QString)));
7
8+ connect(m_fsAction, SIGNAL(downloadTemporaryComplete(QString)),
9+ this, SIGNAL(downloadTemporaryComplete(QString)));
10+
11 setCompareAndReorder();
12
13 if (QIcon::themeName().isEmpty() && !FMUtil::hasTriedThemeName())
14@@ -1825,6 +1828,43 @@
15 }
16
17
18+
19+bool DirModel::download(int index)
20+{
21+ bool ret = false;
22+ if (IS_VALID_ROW(index))
23+ {
24+ QString outputFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) +
25+ QDir::separator() + mDirectoryContents.at(index).fileName());
26+ ret = downloadAndSaveAs(index, outputFile);
27+ }
28+ return ret;
29+}
30+
31+
32+bool DirModel::downloadAndSaveAs(int index, const QString &filename)
33+{
34+ bool ret = false;
35+ if (IS_VALID_ROW(index))
36+ {
37+ ret = m_fsAction->downloadAndSaveAs(mDirectoryContents.at(index),
38+ filename);
39+ }
40+ return ret;
41+}
42+
43+
44+bool DirModel::downloadAsTemporaryFile(int index)
45+{
46+ bool ret = false;
47+ if (IS_VALID_ROW(index))
48+ {
49+ ret = m_fsAction->downloadAsTemporaryFile(mDirectoryContents.at(index));
50+ }
51+ return ret;
52+}
53+
54+
55 #ifndef DO_NOT_USE_TAG_LIB
56 QVariant DirModel::getAudioMetaData(const QFileInfo& fi, int role) const
57 {
58
59=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
60--- src/plugin/folderlistmodel/dirmodel.h 2015-09-20 20:28:26 +0000
61+++ src/plugin/folderlistmodel/dirmodel.h 2015-11-02 19:19:16 +0000
62@@ -317,6 +317,31 @@
63 const QString& password,
64 bool savePassword);
65
66+ //download functions
67+ //
68+ /*! \brief download(int index) download file pointed by \a index into standard Download location
69+ *
70+ * \return true if the download could be started, othewise false
71+ */
72+ Q_INVOKABLE bool download(int index);
73+
74+ /*! \brief downloadAndSaveAs(int index, const QString& filename) download file pointed by \a index and save it as \a filename
75+ *
76+ * \return true if the download could be started, othewise false
77+ *
78+ */
79+ Q_INVOKABLE bool downloadAndSaveAs(int index, const QString& filename);
80+
81+ /*! \brief downloadAsTemporaryFile(int index) save download as temporary, useful to open remote files
82+ *
83+ * At the end if download is OK the signal downloadTemporaryComplete(const QString& fullpathname) is emitted
84+ *
85+ * \return true if the download could be started, othewise false
86+ *
87+ */
88+ Q_INVOKABLE bool downloadAsTemporaryFile(int index);
89+
90+
91 public slots:
92 /*!
93 * \brief copySelection() copy selected items to the clipboard
94@@ -470,6 +495,12 @@
95 void clipboardChanged();
96 void enabledExternalFSWatcherChanged(bool);
97
98+ /*!
99+ * \brief downloadTemporaryComplete() says that download has been completed and
100+ * the \a filename is ready to be used, filename is a full pathname
101+ */
102+ void downloadTemporaryComplete(const QString& filename);
103+
104 private slots:
105 void onItemRemoved(const DirItemInfo&);
106 void onItemAdded(const DirItemInfo&);

Subscribers

People subscribed via source and target branches