]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
krazy fixes
[dolphin.git] / src / dolphinmainwindow.cpp
index 697fba85fcb8a2ac823a74ee506e7935dfce8c6a..f6688ddcec9b24cdb3b51879521601f05cfaa950 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "dolphinmainwindow.h"
 #include "dolphinviewactionhandler.h"
+#include "dolphinremoteencoding.h"
 
 #include <config-nepomuk.h>
 
@@ -65,7 +66,7 @@
 #include <kmenu.h>
 #include <kmenubar.h>
 #include <kmessagebox.h>
-#include <konq_fileitemcapabilities.h>
+#include <kfileitemlistproperties.h>
 #include <konqmimedata.h>
 #include <kprotocolinfo.h>
 #include <krun.h>
 #include <kurlnavigator.h>
 #include <kurl.h>
 #include <kurlcombobox.h>
+#include <ktoolinvocation.h>
 
 #include <QDBusMessage>
 #include <QKeyEvent>
 #include <QClipboard>
-#include <QLineEdit>
 #include <QSplitter>
 #include <QDockWidget>
+#include <kacceleratormanager.h>
+
+/*
+ * Remembers the tab configuration if a tab has been closed.
+ * Each closed tab can be restored by the menu
+ * "Go -> Recently Closed Tabs".
+ */
+struct ClosedTab
+{
+    KUrl primaryUrl;
+    KUrl secondaryUrl;
+    bool isSplit;
+};
+Q_DECLARE_METATYPE(ClosedTab)
 
 DolphinMainWindow::DolphinMainWindow(int id) :
     KXmlGuiWindow(0),
@@ -98,6 +113,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_tabIndex(0),
     m_viewTab(),
     m_actionHandler(0),
+    m_remoteEncoding(0),
     m_settingsDialog(0)
 {
     setObjectName("Dolphin#");
@@ -219,10 +235,12 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
         updateEditActions();
         updateViewActions();
         updateGoActions();
-        setCaption(url.fileName());
+        setUrlAsCaption(url);
         if (m_viewTab.count() > 1) {
             m_tabBar->setTabText(m_tabIndex, tabName(url));
         }
+        const QString iconName = KMimeType::iconNameForUrl(url);
+        m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName));
         emit urlChanged(url);
     }
 }
@@ -256,11 +274,6 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
         compareFilesAction->setEnabled(false);
     }
 
-#if defined(QUICK_VIEW)
-    const bool activeViewHasSelection = (activeViewContainer()->view()->selectedItemsCount() > 0);
-    actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection);
-#endif
-
     m_activeViewContainer->updateStatusBar();
 
     emit selectionChanged(selection);
@@ -322,17 +335,19 @@ void DolphinMainWindow::openNewTab()
 
 void DolphinMainWindow::openNewTab(const KUrl& url)
 {
+    const KIcon icon = KIcon(KMimeType::iconNameForUrl(m_activeViewContainer->url()));
     if (m_viewTab.count() == 1) {
         // Only one view is open currently and hence no tab is shown at
         // all. Before creating a tab for 'url', provide a tab for the current URL.
-        m_tabBar->addTab(KIcon("folder"), tabName(m_activeViewContainer->url()));
+        m_tabBar->addTab(icon, tabName(m_activeViewContainer->url()));
         m_tabBar->blockSignals(false);
     }
 
-    m_tabBar->addTab(KIcon("folder"), tabName(url));
+    m_tabBar->addTab(icon, tabName(url));
 
     ViewTab viewTab;
     viewTab.splitter = new QSplitter(this);
+    viewTab.splitter->setChildrenCollapsible(false);
     viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
     viewTab.primaryView->setActive(false);
     connectViewSignals(viewTab.primaryView);
@@ -354,7 +369,7 @@ void DolphinMainWindow::openNewTab(const KUrl& url)
 
 void DolphinMainWindow::activateNextTab()
 {
-    if (m_viewTab.count() == 1 || m_tabBar->count() < 2) {
+    if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
         return;
     }
 
@@ -364,7 +379,7 @@ void DolphinMainWindow::activateNextTab()
 
 void DolphinMainWindow::activatePrevTab()
 {
-    if (m_viewTab.count() == 1 || m_tabBar->count() < 2) {
+    if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
         return;
     }
 
@@ -412,6 +427,50 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
 {
     DolphinSettings& settings = DolphinSettings::instance();
     GeneralSettings* generalSettings = settings.generalSettings();
+
+    if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs()) {
+        // Ask the user if he really wants to quit and close all tabs.
+        // Open a confirmation dialog with 3 buttons:
+        // KDialog::Yes    -> Quit
+        // KDialog::No     -> Close only the current tab
+        // KDialog::Cancel -> do nothing
+        KDialog *dialog = new KDialog(this, Qt::Dialog);
+        dialog->setCaption(i18nc("@title:window", "Confirmation"));
+        dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
+        dialog->setModal(true);
+        dialog->showButtonSeparator(true);
+        dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
+        dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
+        dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
+        dialog->setDefaultButton(KDialog::Yes);
+
+        bool doNotAskAgainCheckboxResult = false;
+
+        const int result = KMessageBox::createKMessageBox(dialog,
+            QMessageBox::Warning,
+            i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
+            QStringList(),
+            i18n("Do not ask again"),
+            &doNotAskAgainCheckboxResult,
+            KMessageBox::Notify);
+
+        if (doNotAskAgainCheckboxResult) {
+            generalSettings->setConfirmClosingMultipleTabs(false);
+        }
+
+        switch (result) {
+            case KDialog::Yes:
+                // Quit
+                break;
+            case KDialog::No:
+                // Close only the current tab
+             closeTab();
+            default:
+                event->ignore();
+                return;
+        }
+    }
+
     generalSettings->setFirstRun(false);
 
     settings.save();
@@ -421,46 +480,61 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
 
 void DolphinMainWindow::saveProperties(KConfigGroup& group)
 {
-    // TODO: remember tabs
-    DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
-    group.writeEntry("Primary Url", cont->url().url());
-    group.writeEntry("Primary Editable Url", cont->isUrlEditable());
+    const int tabCount = m_viewTab.count();
+    group.writeEntry("Tab Count", tabCount);
+    group.writeEntry("Active Tab Index", m_tabBar->currentIndex());
 
-    cont = m_viewTab[m_tabIndex].secondaryView;
-    if (cont != 0) {
-        group.writeEntry("Secondary Url", cont->url().url());
-        group.writeEntry("Secondary Editable Url", cont->isUrlEditable());
+    for (int i = 0; i < tabCount; ++i) {
+        const DolphinViewContainer* cont = m_viewTab[i].primaryView;
+        group.writeEntry(tabProperty("Primary URL", i), cont->url().url());
+        group.writeEntry(tabProperty("Primary Editable", i), cont->isUrlEditable());
+
+        cont = m_viewTab[i].secondaryView;
+        if (cont != 0) {
+            group.writeEntry(tabProperty("Secondary URL", i), cont->url().url());
+            group.writeEntry(tabProperty("Secondary Editable", i), cont->isUrlEditable());
+        }
     }
 }
 
 void DolphinMainWindow::readProperties(const KConfigGroup& group)
 {
-    // TODO: read tabs
-    DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
+    const int tabCount = group.readEntry("Tab Count", 1);
+    for (int i = 0; i < tabCount; ++i) {
+        DolphinViewContainer* cont = m_viewTab[i].primaryView;
 
-    cont->setUrl(group.readEntry("Primary Url"));
-    bool editable = group.readEntry("Primary Editable Url", false);
-    cont->urlNavigator()->setUrlEditable(editable);
+        cont->setUrl(group.readEntry(tabProperty("Primary URL", i)));
+        const bool editable = group.readEntry(tabProperty("Primary Editable", i), false);
+        cont->urlNavigator()->setUrlEditable(editable);
 
-    cont = m_viewTab[m_tabIndex].secondaryView;
-    const QString secondaryUrl = group.readEntry("Secondary Url");
-    if (!secondaryUrl.isEmpty()) {
-        if (cont == 0) {
-            // a secondary view should be shown, but no one is available
-            // currently -> create a new view
+        cont = m_viewTab[i].secondaryView;
+        const QString secondaryUrl = group.readEntry(tabProperty("Secondary URL", i));
+        if (!secondaryUrl.isEmpty()) {
+            if (cont == 0) {
+                // a secondary view should be shown, but no one is available
+                // currently -> create a new view
+                toggleSplitView();
+                cont = m_viewTab[i].secondaryView;
+                Q_ASSERT(cont != 0);
+            }
+
+            cont->setUrl(secondaryUrl);
+            const bool editable = group.readEntry(tabProperty("Secondary Editable", i), false);
+            cont->urlNavigator()->setUrlEditable(editable);
+        } else if (cont != 0) {
+            // no secondary view should be shown, but the default setting shows
+            // one already -> close the view
             toggleSplitView();
-            cont = m_viewTab[m_tabIndex].secondaryView;
-            Q_ASSERT(cont != 0);
         }
 
-        cont->setUrl(secondaryUrl);
-        bool editable = group.readEntry("Secondary Editable Url", false);
-        cont->urlNavigator()->setUrlEditable(editable);
-    } else if (cont != 0) {
-        // no secondary view should be shown, but the default setting shows
-        // one already -> close the view
-        toggleSplitView();
+        // openNewTab() needs to be called only tabCount - 1 times
+        if (i != tabCount - 1) {
+             openNewTab();
+        }
     }
+
+    const int index = group.readEntry("Active Tab Index", 0);
+    m_tabBar->setCurrentIndex(index);
 }
 
 void DolphinMainWindow::updateNewMenu()
@@ -469,6 +543,12 @@ void DolphinMainWindow::updateNewMenu()
     m_newMenu->setPopupFiles(activeViewContainer()->url());
 }
 
+void DolphinMainWindow::createDirectory()
+{
+    m_newMenu->setPopupFiles(activeViewContainer()->url());
+    m_newMenu->createDirectory();
+}
+
 void DolphinMainWindow::quit()
 {
     close();
@@ -490,6 +570,35 @@ void DolphinMainWindow::slotUndoAvailable(bool available)
     }
 }
 
+void DolphinMainWindow::restoreClosedTab(QAction* action)
+{
+    if (action->data().toBool()) {
+        // clear all actions except the "Empty Recently Closed Tabs"
+        // action and the separator
+        QList<QAction*> actions = m_recentTabsMenu->menu()->actions();
+        const int count = actions.size();
+        for (int i = 2; i < count; ++i) {
+            m_recentTabsMenu->menu()->removeAction(actions.at(i));
+        }
+    } else {
+        const ClosedTab closedTab = action->data().value<ClosedTab>();
+        openNewTab(closedTab.primaryUrl);
+        m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+
+        if (closedTab.isSplit) {
+            // create secondary view
+            toggleSplitView();
+            m_viewTab[m_tabIndex].secondaryView->setUrl(closedTab.secondaryUrl);
+        }
+
+        m_recentTabsMenu->removeAction(action);
+    }
+
+    if (m_recentTabsMenu->menu()->actions().count() == 2) {
+        m_recentTabsMenu->setEnabled(false);
+    }
+}
+
 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
 {
     QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
@@ -695,24 +804,28 @@ void DolphinMainWindow::compareFiles()
     KRun::runCommand(command, "Kompare", "kompare", this);
 }
 
-void DolphinMainWindow::quickView()
-{
-    const KUrl::List urls = activeViewContainer()->view()->selectedUrls();
-    Q_ASSERT(urls.count() > 0);
-
-    QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile");
-    foreach (const KUrl& url, urls) {
-        msg.setArguments(QList<QVariant>() << url.prettyUrl());
-        QDBusConnection::sessionBus().send(msg);
-    }
-}
-
 void DolphinMainWindow::toggleShowMenuBar()
 {
     const bool visible = menuBar()->isVisible();
     menuBar()->setVisible(!visible);
 }
 
+void DolphinMainWindow::openTerminal()
+{
+    QString dir(QDir::homePath());
+
+    // If the given directory is not local, it can still be the URL of an
+    // ioslave using UDS_LOCAL_PATH which to be converted first.
+    KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+
+    //If the URL is local after the above conversion, set the directory.
+    if (url.isLocalFile()) {
+        dir = url.toLocalFile();
+    }
+
+    KToolInvocation::invokeTerminal(QString(), dir);
+}
+
 void DolphinMainWindow::editSettings()
 {
     if (m_settingsDialog == 0) {
@@ -769,7 +882,7 @@ void DolphinMainWindow::closeTab(int index)
     Q_ASSERT(index >= 0);
     Q_ASSERT(index < m_viewTab.count());
     if (m_viewTab.count() == 1) {
-          // the last tab may never get closed
+        // the last tab may never get closed
         return;
     }
 
@@ -778,6 +891,7 @@ void DolphinMainWindow::closeTab(int index)
         // previous tab before closing the tab.
         m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
     }
+    rememberClosedTab(index);
 
     // delete tab
     m_viewTab[index].primaryView->deleteLater();
@@ -816,7 +930,6 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
 
     QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
     closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
-
     QAction* selectedAction = menu.exec(pos);
     if (selectedAction == newTabAction) {
         const ViewTab& tab = m_viewTab[index];
@@ -858,6 +971,11 @@ void DolphinMainWindow::searchItems(const KUrl& url)
     m_activeViewContainer->setUrl(url);
 }
 
+void DolphinMainWindow::slotTabMoved(int from, int to)
+{
+    m_viewTab.move(from, to);
+    m_tabIndex = m_tabBar->currentIndex();
+}
 
 void DolphinMainWindow::init()
 {
@@ -874,13 +992,15 @@ void DolphinMainWindow::init()
     setAcceptDrops(true);
 
     m_viewTab[m_tabIndex].splitter = new QSplitter(this);
+    m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
 
     setupActions();
 
     const KUrl& homeUrl = generalSettings->homeUrl();
-    setCaption(homeUrl.fileName());
+    setUrlAsCaption(homeUrl);
     m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
     connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
+    connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
     ViewProperties props(homeUrl);
     m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
                                                                  m_viewTab[m_tabIndex].splitter,
@@ -893,11 +1013,16 @@ void DolphinMainWindow::init()
     m_activeViewContainer->show();
     m_actionHandler->setCurrentView(view);
 
+    m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
+    connect(this, SIGNAL(urlChanged(const KUrl&)),
+            m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
+
     m_tabBar = new KTabBar(this);
-    m_tabBar->setCloseButtonEnabled(true);
+    m_tabBar->setMovable(true);
+    m_tabBar->setTabsClosable(true);
     connect(m_tabBar, SIGNAL(currentChanged(int)),
             this, SLOT(setActiveTab(int)));
-    connect(m_tabBar, SIGNAL(closeRequest(int)),
+    connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
             this, SLOT(closeTab(int)));
     connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
             this, SLOT(openTabContextMenu(int, const QPoint&)));
@@ -909,6 +1034,8 @@ void DolphinMainWindow::init()
            this, SLOT(slotWheelMoved(int)));
     connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
             this, SLOT(closeTab(int)));
+    connect(m_tabBar, SIGNAL(tabMoved(int, int)),
+            this, SLOT(slotTabMoved(int, int)));
 
     m_tabBar->blockSignals(true);  // signals get unblocked after at least 2 tabs are open
 
@@ -979,9 +1106,10 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain
     updateGoActions();
 
     const KUrl& url = m_activeViewContainer->url();
-    setCaption(url.fileName());
-    if (m_viewTab.count() > 1) {
+    setUrlAsCaption(url);
+    if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) {
         m_tabBar->setTabText(m_tabIndex, tabName(url));
+        m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url)));
     }
 
     emit urlChanged(url);
@@ -1009,7 +1137,7 @@ void DolphinMainWindow::setupActions()
     newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
     connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
 
-    QAction* closeTab = actionCollection()->addAction("close_tab");
+    KAction* closeTab = actionCollection()->addAction("close_tab");
     closeTab->setIcon(KIcon("tab-close"));
     closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
     closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
@@ -1077,6 +1205,19 @@ void DolphinMainWindow::setupActions()
     backShortcut.setAlternate(Qt::Key_Backspace);
     backAction->setShortcut(backShortcut);
 
+    m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
+    m_recentTabsMenu->setIcon(KIcon("edit-undo"));
+    actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
+    connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)),
+            this, SLOT(restoreClosedTab(QAction *)));
+
+    QAction* action = new QAction("Empty Recently Closed Tabs", m_recentTabsMenu);
+    action->setIcon(KIcon("edit-clear-list"));
+    action->setData(QVariant::fromValue(true));
+    m_recentTabsMenu->addAction(action);
+    m_recentTabsMenu->addSeparator();
+    m_recentTabsMenu->setEnabled(false);
+
     KStandardAction::forward(this, SLOT(goForward()), actionCollection());
     KStandardAction::up(this, SLOT(goUp()), actionCollection());
     KStandardAction::home(this, SLOT(goHome()), actionCollection());
@@ -1098,15 +1239,11 @@ void DolphinMainWindow::setupActions()
     compareFiles->setEnabled(false);
     connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
 
-    // disabled Quick View
-#if defined(QUICK_VIEW)
-    KAction* quickView = actionCollection()->addAction("quick_view");
-    quickView->setText(i18nc("@action:inmenu Tools", "Quick View"));
-    quickView->setIcon(KIcon("view-preview"));
-    quickView->setShortcut(Qt::CTRL + Qt::Key_Return);
-    quickView->setEnabled(false);
-    connect(quickView, SIGNAL(triggered()), this, SLOT(quickView()));
-#endif
+    KAction* openTerminal = actionCollection()->addAction("open_terminal");
+    openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
+    openTerminal->setIcon(KIcon("terminal"));
+    openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
+    connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
 
     // setup 'Settings' menu
     m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
@@ -1257,7 +1394,7 @@ void DolphinMainWindow::updateEditActions()
         QAction* cutAction         = col->action(KStandardAction::name(KStandardAction::Cut));
         QAction* deleteWithTrashShortcut = col->action("delete_shortcut"); // see DolphinViewActionHandler
 
-        KonqFileItemCapabilities capabilities(list);
+        KFileItemListProperties capabilities(list);
         const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
 
         renameAction->setEnabled(capabilities.supportsMoving());
@@ -1290,6 +1427,47 @@ void DolphinMainWindow::updateGoActions()
     goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
 }
 
+void DolphinMainWindow::rememberClosedTab(int index)
+{
+    KMenu* tabsMenu = m_recentTabsMenu->menu();
+
+    const QString primaryPath = m_viewTab[index].primaryView->url().path();
+    const QString iconName = KMimeType::iconNameForUrl(primaryPath);
+
+    const QFontMetrics fm = fontMetrics();
+    const QString actionText = fm.elidedText(primaryPath, Qt::ElideMiddle, fm.maxWidth() * 20);
+
+    QAction* action = new QAction(actionText, tabsMenu);
+
+    ClosedTab closedTab;
+    closedTab.primaryUrl = m_viewTab[index].primaryView->url();
+
+    if (m_viewTab[index].secondaryView != 0) {
+        closedTab.secondaryUrl = m_viewTab[index].secondaryView->url();
+        closedTab.isSplit = true;
+    } else {
+        closedTab.isSplit = false;
+    }
+
+    action->setData(QVariant::fromValue(closedTab));
+    action->setIcon(KIcon(iconName));
+
+    // add the closed tab menu entry after the separator and
+    // "Empty Recently Closed Tabs" entry
+    if (tabsMenu->actions().size() == 2) {
+        tabsMenu->addAction(action);
+    } else {
+        tabsMenu->insertAction(tabsMenu->actions().at(2), action);
+    }
+
+    // assure that only up to 8 closed tabs are shown in the menu
+    if (tabsMenu->actions().size() > 8) {
+        tabsMenu->removeAction(tabsMenu->actions().last());
+    }
+    actionCollection()->action("closed_tabs")->setEnabled(true);
+    KAcceleratorManager::manage(tabsMenu);
+}
+
 void DolphinMainWindow::clearStatusBar()
 {
     m_activeViewContainer->statusBar()->clear();
@@ -1340,7 +1518,7 @@ QString DolphinMainWindow::tabName(const KUrl& url) const
 {
     QString name;
     if (url.equals(KUrl("file:///"))) {
-        name = "/";
+        name = '/';
     } else {
         name = url.fileName();
         if (name.isEmpty()) {
@@ -1382,6 +1560,26 @@ void DolphinMainWindow::createSecondaryView(int tabIndex)
     m_viewTab[tabIndex].secondaryView->show();
 }
 
+QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) const
+{
+    return "Tab " + QString::number(tabIndex) + ' ' + property;
+}
+
+void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
+{
+    QString caption;
+    if (url.equals(KUrl("file:///"))) {
+        caption = '/';
+    } else {
+        caption = url.fileName();
+        if (caption.isEmpty()) {
+            caption = url.protocol();
+       }
+    }
+    
+    setCaption(caption);
+}
+
 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
     KIO::FileUndoManager::UiInterface()
 {