]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Reload the view if a previously unmounted device is mounted again
[dolphin.git] / src / dolphinviewcontainer.cpp
index 71dc5fd7b50808731992cf1f0d7a3679497ea863..c8fc757ba700252a9fc141a0e14ef7235132a0af 100644 (file)
@@ -68,7 +68,9 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     m_statusBar(0),
     m_statusBarTimer(0),
     m_statusBarTimestamp(),
-    m_autoGrabFocus(true)
+    m_autoGrabFocus(true),
+    m_dropDestination(),
+    m_dropEvent(0)
 #ifdef KActivities_FOUND
     , m_activityResourceInstance(0)
 #endif
@@ -96,6 +98,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
 
     m_searchBox = new DolphinSearchBox(this);
     m_searchBox->hide();
+    connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
     connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
     connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
     connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
@@ -193,6 +196,7 @@ KUrl DolphinViewContainer::url() const
 
 void DolphinViewContainer::setActive(bool active)
 {
+    m_searchBox->setActive(active);
     m_urlNavigator->setActive(active);
     m_view->setActive(active);
 
@@ -368,6 +372,10 @@ void DolphinViewContainer::setUrl(const KUrl& newUrl)
 {
     if (newUrl != m_urlNavigator->locationUrl()) {
         m_urlNavigator->setLocationUrl(newUrl);
+    } else if (m_view->itemsCount() == 0) {
+        // Maybe a previously unmounted device has been mounted again.
+        // Let's reload the view to be safe (see https://bugs.kde.org/show_bug.cgi?id=161385).
+        m_view->reload();
     }
 
     #ifdef KActivities_FOUND
@@ -597,11 +605,37 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
 
 void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
 {
+    m_dropDestination = destination;
+
+    const QMimeData* mimeData = event->mimeData();
+    QMimeData* mimeDataCopy = new QMimeData;
+    foreach (const QString& format, mimeData->formats()) {
+        mimeDataCopy->setData(format, mimeData->data(format));
+    }
+
+    m_dropEvent.reset(new QDropEvent(event->pos(),
+                                     event->possibleActions(),
+                                     mimeDataCopy,
+                                     event->mouseButtons(),
+                                     event->keyboardModifiers()));
+
+    QTimer::singleShot(0, this, SLOT(dropUrlsDelayed()));
+}
+
+void DolphinViewContainer::dropUrlsDelayed()
+{
+    if (m_dropEvent.isNull()) {
+        return;
+    }
+
     QString error;
-    DragAndDropHelper::dropUrls(KFileItem(), destination, event, error);
+    DragAndDropHelper::dropUrls(KFileItem(), m_dropDestination, m_dropEvent.data(), error);
     if (!error.isEmpty()) {
         showMessage(error, Error);
     }
+
+    delete m_dropEvent->mimeData();
+    m_dropEvent.reset();
 }
 
 void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)