]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
allow to restrict the search results by the current folder (including all sub folders)
[dolphin.git] / src / dolphinmainwindow.cpp
index 5d990ab554693b167e7348bf33ff8d7a2b164a0b..5e08a9e2e5d292c922dac15b64ca2fed6d5f8f81 100644 (file)
@@ -24,6 +24,9 @@
 #include "dolphinremoteencoding.h"
 
 #include <config-nepomuk.h>
+#ifdef HAVE_NEPOMUK
+#include "search/dolphinsearchoptionsconfigurator.h"
+#endif
 
 #include "dolphinapplication.h"
 #include "dolphinnewmenu.h"
@@ -109,7 +112,9 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_activeViewContainer(0),
     m_centralWidgetLayout(0),
     m_searchBox(0),
+#ifdef HAVE_NEPOMUK
     m_searchOptionsConfigurator(0),
+#endif
     m_id(id),
     m_tabIndex(0),
     m_viewTab(),
@@ -548,12 +553,14 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group)
 
 void DolphinMainWindow::updateNewMenu()
 {
+    m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
     m_newMenu->slotCheckUpToDate();
     m_newMenu->setPopupFiles(activeViewContainer()->url());
 }
 
 void DolphinMainWindow::createDirectory()
 {
+    m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
     m_newMenu->setPopupFiles(activeViewContainer()->url());
     m_newMenu->createDirectory();
 }
@@ -753,6 +760,32 @@ void DolphinMainWindow::goUp()
     m_activeViewContainer->urlNavigator()->goUp();
 }
 
+void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
+{
+    // The default case (left button pressed) is handled in goBack().
+    if (buttons == Qt::MidButton) {
+        KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+        openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() + 1));
+    }
+}
+
+void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
+{
+    // The default case (left button pressed) is handled in goForward().
+    if (buttons == Qt::MidButton) {
+        KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+        openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() - 1));
+    }
+}
+
+void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
+{
+    // The default case (left button pressed) is handled in goUp().
+    if (buttons == Qt::MidButton) {
+        openNewTab(activeViewContainer()->url().upUrl());
+    }
+}
+
 void DolphinMainWindow::goHome()
 {
     clearStatusBar();
@@ -975,9 +1008,12 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can
     canDecode = KUrl::List::canDecode(event->mimeData());
 }
 
-void DolphinMainWindow::searchItems(const KUrl& url)
+void DolphinMainWindow::searchItems()
 {
-    m_activeViewContainer->setUrl(url);
+#ifdef HAVE_NEPOMUK
+    const KUrl nepomukSearchUrl = m_searchOptionsConfigurator->nepomukSearchUrl();
+    m_activeViewContainer->setUrl(nepomukSearchUrl);
+#endif
 }
 
 void DolphinMainWindow::slotTabMoved(int from, int to)
@@ -986,9 +1022,11 @@ void DolphinMainWindow::slotTabMoved(int from, int to)
     m_tabIndex = m_tabBar->currentIndex();
 }
 
-void DolphinMainWindow::slotSearchBoxTextChanged(const QString& text)
+void DolphinMainWindow::showSearchOptions()
 {
-    m_searchOptionsConfigurator->setVisible(!text.isEmpty());
+#ifdef HAVE_NEPOMUK
+    m_searchOptionsConfigurator->show();
+#endif
 }
 
 void DolphinMainWindow::init()
@@ -1031,8 +1069,13 @@ void DolphinMainWindow::init()
     connect(this, SIGNAL(urlChanged(const KUrl&)),
             m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
 
+#ifdef HAVE_NEPOMUK
     m_searchOptionsConfigurator = new DolphinSearchOptionsConfigurator(this);
     m_searchOptionsConfigurator->hide();
+    connect(m_searchOptionsConfigurator, SIGNAL(searchOptionsChanged()),
+            this, SLOT(searchItems()));
+    connect(this, SIGNAL(urlChanged(KUrl)), m_searchOptionsConfigurator, SLOT(setDirectory(KUrl)));
+#endif
 
     m_tabBar = new KTabBar(this);
     m_tabBar->setMovable(true);
@@ -1060,7 +1103,9 @@ void DolphinMainWindow::init()
     m_centralWidgetLayout = new QVBoxLayout(centralWidget);
     m_centralWidgetLayout->setSpacing(0);
     m_centralWidgetLayout->setMargin(0);
+#ifdef HAVE_NEPOMUK
     m_centralWidgetLayout->addWidget(m_searchOptionsConfigurator);
+#endif
     m_centralWidgetLayout->addWidget(m_tabBar);
     m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
 
@@ -1072,8 +1117,12 @@ void DolphinMainWindow::init()
 
     m_searchBox->setParent(toolBar("searchToolBar"));
     m_searchBox->show();
-    connect(m_searchBox, SIGNAL(textChanged(const QString&)),
-            this, SLOT(slotSearchBoxTextChanged(const QString&)));
+    connect(m_searchBox, SIGNAL(requestSearchOptions()),
+            this, SLOT(showSearchOptions()));
+#ifdef HAVE_NEPOMUK
+    connect(m_searchBox, SIGNAL(searchTextChanged(QString)),
+            m_searchOptionsConfigurator, SLOT(setCustomSearchQuery(QString)));
+#endif
 
     stateChanged("new_file");
 
@@ -1226,6 +1275,7 @@ void DolphinMainWindow::setupActions()
 
     // setup 'Go' menu
     KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
+    connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
     KShortcut backShortcut = backAction->shortcut();
     backShortcut.setAlternate(Qt::Key_Backspace);
     backAction->setShortcut(backShortcut);
@@ -1243,8 +1293,12 @@ void DolphinMainWindow::setupActions()
     m_recentTabsMenu->addSeparator();
     m_recentTabsMenu->setEnabled(false);
 
-    KStandardAction::forward(this, SLOT(goForward()), actionCollection());
-    KStandardAction::up(this, SLOT(goUp()), actionCollection());
+    KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
+    connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
+
+    KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
+    connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
+
     KStandardAction::home(this, SLOT(goHome()), actionCollection());
 
     // setup 'Tools' menu
@@ -1301,7 +1355,7 @@ void DolphinMainWindow::setupActions()
 
     // 'Search' toolbar
     m_searchBox = new DolphinSearchBox(this);
-    connect(m_searchBox, SIGNAL(search(KUrl)), this, SLOT(searchItems(KUrl)));
+    connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(searchItems()));
 
     KAction* search = new KAction(this);
     actionCollection()->addAction("search_bar", search);
@@ -1317,6 +1371,7 @@ void DolphinMainWindow::setupDockWidgets()
     infoDock->setObjectName("infoDock");
     infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     Panel* infoPanel = new InformationPanel(infoDock);
+    connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
     infoDock->setWidget(infoPanel);
 
     QAction* infoAction = infoDock->toggleViewAction();
@@ -1602,10 +1657,20 @@ void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
             caption = url.protocol();
        }
     }
-    
+
     setCaption(caption);
 }
 
+void DolphinMainWindow::handleUrl(const KUrl& url)
+{
+    if (KProtocolManager::supportsListing(url)) {
+        activeViewContainer()->setUrl(url);
+    }
+    else {
+        new KRun(url, this);
+    }
+}
+
 QString DolphinMainWindow::squeezedText(const QString& text) const
 {
     const QFontMetrics fm = fontMetrics();