]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
* Use Nepomuk for getting the meta data instead of KFileMetaInfo.
[dolphin.git] / src / dolphinmainwindow.cpp
index 24e1a1f97d0bfea7b32dd3b9e39cfd252df12be9..697fba85fcb8a2ac823a74ee506e7935dfce8c6a 100644 (file)
@@ -28,6 +28,7 @@
 #include "dolphinnewmenu.h"
 #include "settings/dolphinsettings.h"
 #include "settings/dolphinsettingsdialog.h"
+#include "dolphinsearchbox.h"
 #include "dolphinstatusbar.h"
 #include "dolphinviewcontainer.h"
 #include "panels/folders/folderspanel.h"
@@ -92,7 +93,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_tabBar(0),
     m_activeViewContainer(0),
     m_centralWidgetLayout(0),
-    m_searchBar(0),
+    m_searchBox(0),
     m_id(id),
     m_tabIndex(0),
     m_viewTab(),
@@ -265,6 +266,15 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
     emit selectionChanged(selection);
 }
 
+void DolphinMainWindow::slotWheelMoved(int wheelDelta)
+{
+    if (wheelDelta > 0) {
+        activatePrevTab();
+    } else {
+        activateNextTab();
+    }
+}
+
 void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
 {
     emit requestItemInfo(item);
@@ -843,10 +853,9 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can
     canDecode = KUrl::List::canDecode(event->mimeData());
 }
 
-void DolphinMainWindow::searchItems()
+void DolphinMainWindow::searchItems(const KUrl& url)
 {
-    const QString nepomukString = "nepomuksearch:/" + m_searchBar->text();
-    m_activeViewContainer->setUrl(KUrl(nepomukString));
+    m_activeViewContainer->setUrl(url);
 }
 
 
@@ -896,6 +905,11 @@ void DolphinMainWindow::init()
             this, SLOT(openNewTab()));
     connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
             this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
+    connect(m_tabBar, SIGNAL(wheelDelta(int)),
+           this, SLOT(slotWheelMoved(int)));
+    connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
+            this, SLOT(closeTab(int)));
+
     m_tabBar->blockSignals(true);  // signals get unblocked after at least 2 tabs are open
 
     QWidget* centralWidget = new QWidget(this);
@@ -911,9 +925,8 @@ void DolphinMainWindow::init()
 
     setupGUI(Keys | Save | Create | ToolBar);
 
-    m_searchBar->setParent(toolBar("searchToolBar"));
-    m_searchBar->setFont(KGlobalSettings::generalFont());
-    m_searchBar->show();
+    m_searchBox->setParent(toolBar("searchToolBar"));
+    m_searchBox->show();
 
     stateChanged("new_file");
 
@@ -993,7 +1006,7 @@ void DolphinMainWindow::setupActions()
     KAction* newTab = actionCollection()->addAction("new_tab");
     newTab->setIcon(KIcon("tab-new"));
     newTab->setText(i18nc("@action:inmenu File", "New Tab"));
-    newTab->setShortcut(KShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N, Qt::CTRL | Qt::Key_T));
+    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");
@@ -1124,15 +1137,13 @@ void DolphinMainWindow::setupActions()
     connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
 
     // 'Search' toolbar
-    m_searchBar = new KLineEdit(this);
-    m_searchBar->setMinimumWidth(150);
-    m_searchBar->setClearButtonShown(true);
-    connect(m_searchBar, SIGNAL(returnPressed()), this, SLOT(searchItems()));
+    m_searchBox = new DolphinSearchBox(this);
+    connect(m_searchBox, SIGNAL(search(KUrl)), this, SLOT(searchItems(KUrl)));
 
     KAction* search = new KAction(this);
     actionCollection()->addAction("search_bar", search);
     search->setText(i18nc("@action:inmenu", "Search Bar"));
-    search->setDefaultWidget(m_searchBar);
+    search->setDefaultWidget(m_searchBox);
     search->setShortcutConfigurable(false);
 }
 
@@ -1334,6 +1345,10 @@ QString DolphinMainWindow::tabName(const KUrl& url) const
         name = url.fileName();
         if (name.isEmpty()) {
             name = url.protocol();
+        } else {
+            // Make sure that a '&' inside the directory name is displayed correctly
+            // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
+            name.replace('&', "&&");
         }
     }
     return name;