]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Middle-clicking on tabs will now close them.
[dolphin.git] / src / dolphinpart.cpp
index 45fc9911593e93de654f8ab51558bd396818cb83..41930221d5499f5499d11e3bae61818ddd07ce34 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "dolphinpart.h"
+#include <kdebug.h>
 #include "dolphinviewactionhandler.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphinview.h"
@@ -61,12 +62,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
 
     m_dirLister = new KDirLister;
     m_dirLister->setAutoUpdate(true);
-    m_dirLister->setMainWindow(parentWidget->window());
+    if (parentWidget) {
+        m_dirLister->setMainWindow(parentWidget->window());
+    }
     m_dirLister->setDelayedMimeTypes(true);
 
     //connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotStarted()));
     connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
     connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
+    connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int)));
 
     m_dolphinModel = new DolphinModel(this);
     m_dolphinModel->setDirLister(m_dirLister);
@@ -100,12 +104,21 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
             this, SLOT(slotSelectionChanged(KFileItemList)));
     connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
             this, SLOT(slotRequestItemInfo(KFileItem)));
-    connect(m_view, SIGNAL(urlChanged(KUrl)),
-            this, SLOT(slotUrlChanged(KUrl)));
     connect(m_view, SIGNAL(requestUrlChange(KUrl)),
             this, SLOT(slotRequestUrlChange(KUrl)));
     connect(m_view, SIGNAL(modeChanged()),
             this, SIGNAL(viewModeChanged())); // relay signal
+    connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
+            this, SLOT(slotRedirection(KUrl, KUrl)));
+
+    // Watch for changes that should result in updates to the
+    // status bar text.
+    connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
+            this, SLOT(updateStatusBar()));
+    connect(m_dirLister, SIGNAL(clear()),
+            this, SLOT(updateStatusBar()));
+    connect(m_view,  SIGNAL(selectionChanged(const KFileItemList)),
+            this, SLOT(updateStatusBar()));
 
     m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
     m_actionHandler->setCurrentView(m_view);
@@ -293,6 +306,11 @@ void DolphinPart::slotErrorMessage(const QString& msg)
 void DolphinPart::slotRequestItemInfo(const KFileItem& item)
 {
     emit m_extension->mouseOverInfo(item);
+    if (item.isNull()) {
+        updateStatusBar();
+    } else {
+        ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
+    }
 }
 
 void DolphinPart::slotItemTriggered(const KFileItem& item)
@@ -379,6 +397,13 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
         if (addDel)
             editActions.append(actionCollection()->action("delete"));
         actionGroups.insert("editactions", editActions);
+
+        // Normally KonqPopupMenu only shows the "Create new" subdir in the current view
+        // since otherwise the created file would not be visible.
+        // But in treeview mode we should allow it.
+        if (m_view->itemsExpandable())
+            popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
+
     }
 
     // TODO: We should change the signature of the slots (and signals) for being able
@@ -393,11 +418,14 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
                                 actionGroups);
 }
 
-void DolphinPart::slotUrlChanged(const KUrl& url)
+void DolphinPart::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
 {
-    KParts::ReadOnlyPart::setUrl(url);
-    QString prettyUrl = url.pathOrUrl();
-    emit m_extension->setLocationBarUrl(prettyUrl);
+    //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
+    if (oldUrl == url()) {
+        KParts::ReadOnlyPart::setUrl(newUrl);
+        const QString prettyUrl = newUrl.pathOrUrl();
+        emit m_extension->setLocationBarUrl(prettyUrl);
+    }
 }
 
 void DolphinPart::slotRequestUrlChange(const KUrl& url)
@@ -488,4 +516,14 @@ void DolphinPart::updateNewMenu()
     m_newMenu->setPopupFiles(url());
 }
 
+void DolphinPart::updateStatusBar()
+{
+    emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());
+}
+
+void DolphinPart::updateProgress(int percent)
+{
+    m_extension->loadingProgress(percent);
+}
+
 #include "dolphinpart.moc"