]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
When you view the context menu of a file/folder and shift is pressed (and the delete...
[dolphin.git] / src / dolphinmainwindow.cpp
index 73f89455482f1663ef7122113a76c9a193ac3c34..6f407a84a5e54f154779d9ebed51776bae2b89d2 100644 (file)
@@ -114,8 +114,8 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_actionHandler(0),
     m_remoteEncoding(0),
     m_settingsDialog(0),
-    m_captionStatJob(0),
-    m_lastHandleUrlStatJob(0)
+    m_lastHandleUrlStatJob(0),
+    m_keyInfo(new KModifierKeyInfo)
 {
     setObjectName("Dolphin#");
 
@@ -1158,14 +1158,6 @@ void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
     }
 }
 
-void DolphinMainWindow::slotCaptionStatFinished(KJob* job)
-{
-    m_captionStatJob = 0;
-    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
-    const QString name = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
-    setCaption(name);
-}
-
 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
 {
     newFileMenu()->setEnabled(isFolderWritable);
@@ -1176,6 +1168,12 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item,
                                         const QList<QAction*>& customActions)
 {
     DolphinContextMenu contextMenu(this, item, url);
+
+    if(m_keyInfo.isKeyPressed(Qt::Key_Shift) || m_keyInfo.isKeyLatched(Qt::Key_Shift)) {
+        contextMenu.setShiftIsPressed(true);
+    }
+
+    connect(&m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)), &contextMenu, SLOT(deleteOrTrashMenuEntry(Qt::Key, bool)));
     contextMenu.setCustomActions(customActions);
     contextMenu.open();
 }
@@ -1778,26 +1776,18 @@ QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) co
 
 void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
 {
-    delete m_captionStatJob;
-    m_captionStatJob = 0;
-
-    if (url.protocol() == QLatin1String("file")) {
-        QString caption;
-        if (url.equals(KUrl("file:///"))) {
-            caption = '/';
-        } else {
-            caption = url.fileName();
-            if (caption.isEmpty()) {
-                caption = url.protocol();
-            }
+    QString caption;
+    if (!url.isLocalFile()) {
+        caption.append(url.protocol() + " - ");
+        if (url.hasHost()) {
+            caption.append(url.host() + " - ");
         }
-
-        setCaption(caption);
-    } else {
-        m_captionStatJob = KIO::stat(url, KIO::HideProgressInfo);
-        connect(m_captionStatJob, SIGNAL(result(KJob*)),
-                this, SLOT(slotCaptionStatFinished(KJob*)));
     }
+
+    const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+    caption.append(fileName);
+
+    setCaption(caption);
 }
 
 QString DolphinMainWindow::squeezedText(const QString& text) const