← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-02 as a prerequisite.

Commit message:
implemented a set of high level download functions.

Requested reviews:
  Jenkins Bot (ubuntu-core-apps-jenkins-bot): continuous-integration
  Ubuntu File Manager Developers (ubuntu-filemanager-dev)

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03/+merge/276446

implemented a set of high level download functions.
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/open-remote-files-03 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp	2015-10-01 00:04:00 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp	2015-11-02 19:19:16 +0000
@@ -149,6 +149,9 @@
     connect(m_fsAction, SIGNAL(recopy(QStringList,QString)),
             mClipboard, SLOT(copy(QStringList,QString)));
 
+    connect(m_fsAction, SIGNAL(downloadTemporaryComplete(QString)),
+            this,       SIGNAL(downloadTemporaryComplete(QString)));
+
     setCompareAndReorder();
 
     if (QIcon::themeName().isEmpty() && !FMUtil::hasTriedThemeName())
@@ -1825,6 +1828,43 @@
 }
 
 
+
+bool DirModel::download(int index)
+{
+    bool ret = false;
+    if (IS_VALID_ROW(index))
+    {
+        QString outputFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) +
+                            QDir::separator() + mDirectoryContents.at(index).fileName());
+        ret = downloadAndSaveAs(index, outputFile);
+    }
+    return ret;
+}
+
+
+bool DirModel::downloadAndSaveAs(int index, const QString &filename)
+{
+    bool ret = false;
+    if (IS_VALID_ROW(index))
+    {
+        ret = m_fsAction->downloadAndSaveAs(mDirectoryContents.at(index),
+                                            filename);
+    }
+    return ret;
+}
+
+
+bool DirModel::downloadAsTemporaryFile(int index)
+{
+    bool ret = false;
+    if (IS_VALID_ROW(index))
+    {
+        ret = m_fsAction->downloadAsTemporaryFile(mDirectoryContents.at(index));
+    }
+    return ret;
+}
+
+
 #ifndef DO_NOT_USE_TAG_LIB
 QVariant DirModel::getAudioMetaData(const QFileInfo& fi, int role) const
 {

=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
--- src/plugin/folderlistmodel/dirmodel.h	2015-09-20 20:28:26 +0000
+++ src/plugin/folderlistmodel/dirmodel.h	2015-11-02 19:19:16 +0000
@@ -317,6 +317,31 @@
                                                  const QString& password,
                                                  bool  savePassword);
 
+    //download functions
+    //
+    /*! \brief download(int index) download file pointed by \a index into standard Download location
+     *
+     * \return true if the download could be started, othewise false
+     */
+    Q_INVOKABLE  bool download(int index);
+
+    /*! \brief downloadAndSaveAs(int index, const QString& filename) download file pointed by \a index and save it as \a filename
+     *
+     * \return true if the download could be started, othewise false
+     *
+     */
+    Q_INVOKABLE  bool downloadAndSaveAs(int index, const QString& filename);
+
+    /*! \brief downloadAsTemporaryFile(int index)  save download as temporary, useful to open remote files
+     *
+     *  At the end if download is OK the signal downloadTemporaryComplete(const QString& fullpathname) is emitted
+     *
+     * \return true if the download could be started, othewise false
+     *
+     */
+    Q_INVOKABLE  bool downloadAsTemporaryFile(int index);
+
+
 public slots:
   /*!
      * \brief copySelection() copy selected items to the clipboard
@@ -470,6 +495,12 @@
     void     clipboardChanged();
     void     enabledExternalFSWatcherChanged(bool);
 
+    /*!
+     * \brief downloadTemporaryComplete() says that download has been completed and
+     *    the \a filename is ready to be used, filename is a full pathname
+     */
+    void     downloadTemporaryComplete(const QString& filename);
+
 private slots:    
     void onItemRemoved(const DirItemInfo&);  
     void onItemAdded(const DirItemInfo&);