]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.cpp
Merge branch 'master' into frameworks
[dolphin.git] / src / panels / places / placespanel.cpp
index a84c474809770c5e286423b92cb1e3559530ba69..5618cee2162a534fb6031eb4850319d85c8fd0da 100644 (file)
@@ -30,6 +30,7 @@
 #include <KDirNotify>
 #include <QIcon>
 #include <KIO/Job>
+#include <KIO/DropJob>
 #include <KIO/EmptyTrashJob>
 #include <KIO/JobUiDelegate>
 #include <KJobWidgets>
@@ -117,7 +118,7 @@ void PlacesPanel::showEvent(QShowEvent* event)
         m_controller->setSelectionBehavior(KItemListController::SingleSelection);
         m_controller->setSingleClickActivationEnforced(true);
 
-       readSettings();
+        readSettings();
 
         connect(m_controller, &KItemListController::itemActivated, this, &PlacesPanel::slotItemActivated);
         connect(m_controller, &KItemListController::itemMiddleClicked, this, &PlacesPanel::slotItemMiddleClicked);
@@ -285,8 +286,10 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
                 editEntry(index);
             } else if (action == removeAction) {
                 m_model->removeItem(index);
+                m_model->saveBookmarks();
             } else if (action == hideAction) {
                 item->setHidden(hideAction->isChecked());
+                m_model->saveBookmarks();
             } else if (action == openInNewTabAction) {
                 // TriggerItem does set up the storage first and then it will
                 // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton.
@@ -375,11 +378,7 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
                          event->buttons(),
                          event->modifiers());
 
-    QString error;
-    DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent, error);
-    if (!error.isEmpty()) {
-        emit errorMessage(error);
-    }
+    slotUrlsDropped(destUrl, &dropEvent, this);
 }
 
 void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
@@ -390,12 +389,7 @@ void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
     if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) {
         if (success) {
             QUrl destUrl = m_model->placesItem(index)->url();
-
-            QString error;
-            DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent, error);
-            if (!error.isEmpty()) {
-                emit errorMessage(error);
-            }
+            slotUrlsDropped(destUrl, m_itemDropEvent, this);
         }
 
         delete m_itemDropEventMimeData;
@@ -410,17 +404,15 @@ void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
 void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
 {
     m_model->dropMimeDataBefore(index, event->mimeData());
+    m_model->saveBookmarks();
 }
 
 void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
 {
-    Q_UNUSED(parent);
-    QString error;
-    DragAndDropHelper::dropUrls(KFileItem(), dest, event, error);
-    if (!error.isEmpty()) {
-        emit errorMessage(error);
+    KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent);
+    if (job) {
+        connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); });
     }
-
 }
 
 void PlacesPanel::slotTrashUpdated(KJob* job)
@@ -474,6 +466,7 @@ void PlacesPanel::addEntry()
     if (dialog->exec() == QDialog::Accepted) {
         PlacesItem* item = m_model->createPlacesItem(dialog->text(), dialog->url(), dialog->icon());
         m_model->appendItemToGroup(item);
+        m_model->saveBookmarks();
     }
 
     delete dialog;
@@ -495,6 +488,7 @@ void PlacesPanel::editEntry(int index)
             oldItem->setText(dialog->text());
             oldItem->setUrl(dialog->url());
             oldItem->setIcon(dialog->icon());
+            m_model->saveBookmarks();
         }
     }
 
@@ -538,5 +532,3 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
         }
     }
 }
-
-