[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam] /: remove KIO support in Showfoto
From:       Gilles Caulier <caulier.gilles () gmail ! com>
Date:       2016-04-30 16:53:58
Message-ID: E1awY9W-0006Rm-Ui () scm ! kde ! org
[Download RAW message or body]

Git commit 8b1280aa9b372a5ea975a6732f20fc561374047e by Gilles Caulier.
Committed on 30/04/2016 at 16:53.
Pushed by cgilles into branch 'master'.

remove KIO support in Showfoto

M  +42   -118  showfoto/main/showfoto.cpp
M  +0    -3    showfoto/main/showfoto.h
M  +0    -6    showfoto/main/showfoto_p.h
M  +0    -7    showfoto/setup/showfotosetupmisc.cpp
M  +0    -52   utilities/kdesupport/kio/kiowrapper.cpp
M  +1    -31   utilities/kdesupport/kio/kiowrapper.h

http://commits.kde.org/digikam/8b1280aa9b372a5ea975a6732f20fc561374047e

diff --git a/showfoto/main/showfoto.cpp b/showfoto/main/showfoto.cpp
index 85b24b2..3f45099 100644
--- a/showfoto/main/showfoto.cpp
+++ b/showfoto/main/showfoto.cpp
@@ -116,7 +116,6 @@ extern "C"
 #include "showfotocategorizedview.h"
 #include "showfotosettings.h"
 #include "showfoto_p.h"
-#include "kiowrapper.h"
 #include "dexpanderbox.h"
 
 namespace ShowFoto
@@ -210,11 +209,6 @@ ShowFoto::ShowFoto(const QList<QUrl>& urlList)
 
 ShowFoto::~ShowFoto()
 {
-    if (!d->tempFilePath.isEmpty())
-    {
-        QFile::remove(d->tempFilePath);
-    }
-
     unLoadImagePlugins();
 
     delete m_canvas;
@@ -229,7 +223,6 @@ ShowFoto::~ShowFoto()
     delete d->thumbBar;
     delete d->rightSideBar;
     delete d->thumbLoadThread;
-    delete d->kioWrapper;
     delete d;
 }
 
@@ -476,19 +469,8 @@ void ShowFoto::applySettings()
         qApp->setStyle(newStyle);
     }
 
-    // Current image deleted go to trash ?
-    d->deleteItem2Trash = d->settings->getDeleteItem2Trash();
-
-    if (d->deleteItem2Trash)
-    {
-        m_fileDeleteAction->setIcon(QIcon::fromTheme(QLatin1String("user-trash")));
-        m_fileDeleteAction->setText(i18nc("Non-pluralized", "Move to Trash"));
-    }
-    else
-    {
-        m_fileDeleteAction->setIcon(QIcon::fromTheme(QLatin1String("edit-delete")));
-        m_fileDeleteAction->setText(i18n("Delete File"));
-    }
+    m_fileDeleteAction->setIcon(QIcon::fromTheme(QLatin1String("edit-delete")));
+    m_fileDeleteAction->setText(i18n("Delete File"));
 
     d->thumbBar->setToolTipEnabled(d->settings->getShowToolTip());
 
@@ -502,7 +484,7 @@ void ShowFoto::slotOpenFile()
         return;
     }
 
-    QList<QUrl> urls = Digikam::ImageDialog::getImageURLs(this, \
d->lastOpenedDirectory);     +    QList<QUrl> urls = \
Digikam::ImageDialog::getImageURLs(this, d->lastOpenedDirectory);  openUrls(urls);
 }
 
@@ -571,19 +553,12 @@ void ShowFoto::slotOpenUrl(const ShowfotoItemInfo& info)
     }
     else
     {
-        if (!d->tempFilePath.isEmpty())
-        {
-            QFile::remove(d->tempFilePath);
-        }
-
-        QTemporaryFile tmpFile;
-        tmpFile.setAutoRemove(false);
-        tmpFile.open();
-
-        localFile       = tmpFile.fileName();
-        d->tempFilePath = localFile;
-
-        KIOWrapper::fileCopy(info.url, QUrl::fromLocalFile(localFile), true, this);
+        QMessageBox::critical(this, i18n("Error Loading File"),
+                              i18n("Failed to load file: %1\n"
+                                   "Remote file handling is not supported",
+                                   info.url.fileName())
+                             );
+        return;
     }
 
     d->currentLoadedUrl = info.url;
@@ -888,17 +863,13 @@ void ShowFoto::slotSavingStarted(const QString& filename)
 void ShowFoto::moveFile()
 {
     /*
-     *            / -> moveLocalFile()                           \
-     * moveFile()                                                 ->     \
                movingSaveFileFinished()
-     *            \ -> KIOWrapper::move() -> slotKioMoveFinished /        |          \
                |
-     *
-     *                                                          finishSaving(true)  \
save...IsComplete() +     * moveFile() -> moveLocalFile() ->  \
movingSaveFileFinished() +     *                                     |               \
| +     *                            finishSaving(true)  save...IsComplete()
      */
 
     qCDebug(DIGIKAM_SHOWFOTO_LOG) << m_savingContext.destinationURL << \
m_savingContext.destinationURL.isLocalFile();  
-    // how to move a file depends on if the file is on a local system or not.
-
     if (m_savingContext.destinationURL.isLocalFile())
     {
         qCDebug(DIGIKAM_SHOWFOTO_LOG) << "moving a local file";
@@ -906,38 +877,11 @@ void ShowFoto::moveFile()
     }
     else
     {
-        // for remote destinations use kio to move the temp file over there
-        // do not care for versioning here, atm not supported
-
-        qCDebug(DIGIKAM_SHOWFOTO_LOG) << "moving a remote file via KIO";
-
-        delete d->kioWrapper;
-        d->kioWrapper = new KIOWrapper();
-
-        if (DMetadata::hasSidecar(m_savingContext.saveTempFileName))
-        {
-            d->kioWrapper->move(DMetadata::sidecarUrl(m_savingContext.saveTempFileName),
                
-                                \
                DMetadata::sidecarUrl(m_savingContext.destinationURL)
-            );
-        }
-
-        d->kioWrapper->move(QUrl::fromLocalFile(m_savingContext.saveTempFileName),
-                            m_savingContext.destinationURL);
-
-        connect(d->kioWrapper, SIGNAL(signalError(QString)),
-                this, SLOT(slotKioMoveFinished(QString)));
-    }
-}
-
-void ShowFoto::slotKioMoveFinished(const QString &errMsg)
-{
-    if (!errMsg.isEmpty())
-    {
         QMessageBox::critical(this, i18n("Error Saving File"),
-                              i18n("Failed to save file: %1", errMsg));
+                              i18n("Failed to save file: %1",
+                              i18n("Remote file handling is not supported")
+                            ));
     }
-
-    movingSaveFileFinished(!errMsg.isEmpty());
 }
 
 void ShowFoto::finishSaving(bool success)
@@ -1033,63 +977,43 @@ void ShowFoto::slotDeleteCurrentItem()
 {
     QUrl urlCurrent(d->thumbBar->currentUrl());
 
-    if (!d->deleteItem2Trash)
-    {
-        QString warnMsg(i18n("About to delete file \"%1\"\nAre you sure?",
-                             urlCurrent.fileName()));
-
-        if (QMessageBox::warning(this, qApp->applicationName(), warnMsg, \
                QMessageBox::Apply | QMessageBox::Abort)
-            !=  QMessageBox::Apply)
-        {
-            return;
-        }
-        else
-        {
-            delete d->kioWrapper;
-            d->kioWrapper = new KIOWrapper();
-            d->kioWrapper->del(urlCurrent);
+    QString warnMsg(i18n("About to delete file \"%1\"\nAre you sure?",
+                         urlCurrent.fileName()));
 
-            connect(d->kioWrapper, SIGNAL(signalError(QString)),
-                    this, SLOT(slotDeleteCurrentItemResult(QString)));
-        }
+    if (QMessageBox::warning(this, qApp->applicationName(), warnMsg, \
QMessageBox::Apply | QMessageBox::Abort) +        !=  QMessageBox::Apply)
+    {
+        return;
     }
     else
     {
-        delete d->kioWrapper;
-        d->kioWrapper = new KIOWrapper();
-        d->kioWrapper->trash(urlCurrent);
+        bool ret = QFile::remove(urlCurrent.toLocalFile());
 
-        connect(d->kioWrapper, SIGNAL(signalError(QString)),
-                this, SLOT(slotDeleteCurrentItemResult(QString)));
-    }
-}
-
-void ShowFoto::slotDeleteCurrentItemResult(const QString& errMsg)
-{
-    if (!errMsg.isEmpty())
-    {
-        QMessageBox::critical(this, qApp->applicationName(), errMsg);
-        return;
-    }
+        if (!ret)
+        {
+            QMessageBox::critical(this, qApp->applicationName(), i18n("Cannot delete \
\"%1\"", urlCurrent.fileName())); +            return;
+        }
 
-    // No error, remove item in thumbbar.
-    d->model->removeIndex(d->thumbBar->currentIndex());
+        // No error, remove item in thumbbar.
+        d->model->removeIndex(d->thumbBar->currentIndex());
 
-    // Disable menu actions and SideBar if no current image.
+        // Disable menu actions and SideBar if no current image.
 
-    d->itemsNb = d->thumbBar->showfotoItemInfos().size();
+        d->itemsNb = d->thumbBar->showfotoItemInfos().size();
 
-    if ( d->itemsNb == 0 )
-    {
-        slotUpdateItemInfo();
-        toggleActions(false);
-        m_canvas->load(QString(), m_IOFileSettings);
-    }
-    else
-    {
-        // If there is an image after the deleted one, make that selected.
+        if ( d->itemsNb == 0 )
+        {
+            slotUpdateItemInfo();
+            toggleActions(false);
+            m_canvas->load(QString(), m_IOFileSettings);
+        }
+        else
+        {
+            // If there is an image after the deleted one, make that selected.
 
-        slotOpenUrl(d->thumbBar->currentInfo());
+            slotOpenUrl(d->thumbBar->currentInfo());
+        }
     }
 }
 
diff --git a/showfoto/main/showfoto.h b/showfoto/main/showfoto.h
index 5ff50f9..8d7306a 100644
--- a/showfoto/main/showfoto.h
+++ b/showfoto/main/showfoto.h
@@ -117,13 +117,10 @@ private Q_SLOTS:
     void slotOpenFilesInFolder();
     void slotDroppedUrls(const QList<QUrl>& droppedUrls);
     void slotDeleteCurrentItem();
-    void slotKioMoveFinished(const QString& errMsg);
 
     void slotChanged();
     void slotUpdateItemInfo();
 
-    void slotDeleteCurrentItemResult(const QString &errMsg);
-
     void slotPrepareToLoad();
     void slotLoadingStarted(const QString& filename);
     void slotLoadingFinished(const QString& filename, bool success);
diff --git a/showfoto/main/showfoto_p.h b/showfoto/main/showfoto_p.h
index 22ab741..62908df 100644
--- a/showfoto/main/showfoto_p.h
+++ b/showfoto/main/showfoto_p.h
@@ -40,7 +40,6 @@
 #include "showfotodelegate.h"
 #include "showfotosettings.h"
 #include "showfotodragdrophandler.h"
-#include "kiowrapper.h"
 
 namespace ShowFoto
 {
@@ -50,7 +49,6 @@ class ShowFoto::Private
 public:
 
     Private() :
-        deleteItem2Trash(true),
         validIccPath(true),
         droppedUrls(false),
         imagePluginsLoaded(false),
@@ -63,7 +61,6 @@ public:
         dDHandler(0),
         filterModel(0),
         thumbLoadThread(0),
-        kioWrapper(0),
         thumbBar(0),
         thumbBarDock(0),
         normalDelegate(0),
@@ -73,7 +70,6 @@ public:
     {
     }
 
-    bool                             deleteItem2Trash;
     bool                             validIccPath;
     bool                             droppedUrls;
     bool                             imagePluginsLoaded;
@@ -84,7 +80,6 @@ public:
     QAction*                         fileOpenAction;
     QUrl                             currentLoadedUrl;
     QUrl                             lastOpenedDirectory;
-    QString                          tempFilePath;
     QAction*                         openFilesInFolderAction;
     QAction*                         first;
     QDir                             dir;
@@ -94,7 +89,6 @@ public:
     ShowfotoDragDropHandler*         dDHandler;
     ShowfotoFilterModel*             filterModel;
     Digikam::ThumbnailLoadThread*    thumbLoadThread;
-    Digikam::KIOWrapper*             kioWrapper;
     ShowfotoThumbnailBar*            thumbBar;
     Digikam::ThumbBarDock*           thumbBarDock;
     ShowfotoNormalDelegate*          normalDelegate;
diff --git a/showfoto/setup/showfotosetupmisc.cpp \
b/showfoto/setup/showfotosetupmisc.cpp index 3671658..67c02ec 100644
--- a/showfoto/setup/showfotosetupmisc.cpp
+++ b/showfoto/setup/showfotosetupmisc.cpp
@@ -64,7 +64,6 @@ public:
         showMimeOverImage(0),
         showCoordinates(0),
         sortReverse(0),
-        useTrash(0),
         sidebarType(0),
         sortOrderComboBox(0),
         applicationStyle(0),
@@ -82,7 +81,6 @@ public:
     QCheckBox*           showMimeOverImage;
     QCheckBox*           showCoordinates;
     QCheckBox*           sortReverse;
-    QCheckBox*           useTrash;
 
     QComboBox*           sidebarType;
     QComboBox*           sortOrderComboBox;
@@ -111,7 +109,6 @@ SetupMisc::SetupMisc(QWidget* const parent)
     QGroupBox* const miscOptionsGroup = new QGroupBox(i18n("Behavior"), panel);
     QVBoxLayout* const gLayout5       = new QVBoxLayout();
 
-    d->useTrash          = new QCheckBox(i18n("&Deleted items should go to the \
                trash"), miscOptionsGroup);
     d->itemCenter        = new QCheckBox(i18n("Scroll current item to center of \
                thumbbar"), miscOptionsGroup);
     d->showSplash        = new QCheckBox(i18n("&Show splash screen at startup"), \
                miscOptionsGroup);
     d->showMimeOverImage = new QCheckBox(i18n("&Show image Format"), \
miscOptionsGroup); @@ -167,8 +164,6 @@ SetupMisc::SetupMisc(QWidget* const parent)
         }
     }
 
-
-    gLayout5->addWidget(d->useTrash);
     gLayout5->addWidget(d->itemCenter);
     gLayout5->addWidget(d->showSplash);
     gLayout5->addWidget(d->showMimeOverImage);
@@ -222,7 +217,6 @@ void SetupMisc::readSettings()
 {
     d->settings = ShowfotoSettings::instance();
 
-    d->useTrash->setChecked(d->settings->getDeleteItem2Trash());
     d->itemCenter->setChecked(d->settings->getItemCenter());
     d->showSplash->setChecked(d->settings->getShowSplash());
     d->showMimeOverImage->setChecked(d->settings->getShowFormatOverThumbnail());
@@ -236,7 +230,6 @@ void SetupMisc::readSettings()
 
 void SetupMisc::applySettings()
 {
-    d->settings->setDeleteItem2Trash(d->useTrash->isChecked());
     d->settings->setItemCenter(d->itemCenter->isChecked());
     d->settings->setShowSplash(d->showSplash->isChecked());
     d->settings->setShowFormatOverThumbnail(d->showMimeOverImage->isChecked());
diff --git a/utilities/kdesupport/kio/kiowrapper.cpp \
b/utilities/kdesupport/kio/kiowrapper.cpp index f6512f3..dde206f 100644
--- a/utilities/kdesupport/kio/kiowrapper.cpp
+++ b/utilities/kdesupport/kio/kiowrapper.cpp
@@ -42,58 +42,6 @@
 namespace Digikam
 {
 
-KIOWrapper::KIOWrapper()
-{
-}
-
-bool KIOWrapper::fileCopy(const QUrl& src, const QUrl& dest, bool withKJobWidget, \
                QWidget* const widget)
-{
-    KIO::FileCopyJob* const fileCopyJob = KIO::file_copy(src, dest, KIO::Overwrite);
-
-    if (withKJobWidget)
-    {
-        KJobWidgets::setWindow(fileCopyJob, widget);
-    }
-
-    return fileCopyJob->exec();
-}
-
-void KIOWrapper::move(const QUrl& src, const QUrl& dest)
-{
-    KIO::Job* const job = KIO::move(src, dest);
-
-    connect(job, SIGNAL(result(KJob*)),
-            this, SLOT(slotKioJobResult(KJob*)));
-}
-
-void KIOWrapper::del(const QUrl& url)
-{
-    KIO::Job* const job = KIO::del(url);
-
-    connect(job, SIGNAL(result(KJob*)),
-            this, SLOT(slotKioJobResult(KJob*)));
-}
-
-void KIOWrapper::trash(const QUrl& url)
-{
-    KIO::Job* const job = KIO::trash(url);
-
-    connect(job, SIGNAL(result(KJob*)),
-            this, SLOT(slotKioJobResult(KJob*)) );
-}
-
-void KIOWrapper::slotKioJobResult(KJob* job)
-{
-    if (job->error() != 0)
-    {
-        emit signalError(job->errorString());
-    }
-    else
-    {
-        emit signalError(QString());
-    }
-}
-
 bool KIOWrapper::run(const KService& service, const QList<QUrl>& urls, QWidget* \
const window)  {
 #if KIO_VERSION < QT_VERSION_CHECK(5,6,0)
diff --git a/utilities/kdesupport/kio/kiowrapper.h \
b/utilities/kdesupport/kio/kiowrapper.h index 0e61708..c1d1666 100644
--- a/utilities/kdesupport/kio/kiowrapper.h
+++ b/utilities/kdesupport/kio/kiowrapper.h
@@ -38,46 +38,16 @@
 
 #include "digikam_export.h"
 
-class KJob;
 class KService;
 
 namespace Digikam
 {
 
-class DIGIKAM_EXPORT KIOWrapper : public QObject
+class DIGIKAM_EXPORT KIOWrapper
 {
-    Q_OBJECT
 
 public:
 
-    // Only used by Showfoto.cpp
-    //TODO : how to drop these one ?
-
-    KIOWrapper();
-
-    void move(const QUrl& src, const QUrl& dest);
-    void del(const QUrl& url);
-    void trash(const QUrl& url);
-
-Q_SIGNALS:
-
-    // Emitted by slotKioJobResult()
-    void signalError(const QString& errMsg);
-
-private Q_SLOTS:
-
-    // Used by move, del, trash methods
-    void slotKioJobResult(KJob* job);
-
-public: // ------------------------------------------------------------------------------------------------------------
                
-
-    // TODO : find non KIO equivalents.
-
-    // Used by showfoto.cpp
-    static bool fileCopy(const QUrl& src, const QUrl& dest, bool withKJobWidget = \
                false, QWidget* const widget = 0);
-
-public: // ------------------------------------------------------------------------------------------------------------
                
-
     // TODO: Move these methods in a specific Desktop service wrapper.
     // Typically, found equivalent methods to run service under OSX and Windows \
without to use KDE API.  // Probably we will need native implementations instead.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic