]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Provide a search box for the nepomuksearch:/ KIO slave. This is just an initial proto...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 19 Jan 2009 13:17:33 +0000 (13:17 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 19 Jan 2009 13:17:33 +0000 (13:17 +0000)
CCMAIL: sebastian@trueg.de

svn path=/trunk/KDE/kdebase/apps/; revision=913451

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinui.rc

index c0212a6f123b7b1df6567939223cbce878d1df94..24e1a1f97d0bfea7b32dd3b9e39cfd252df12be9 100644 (file)
@@ -53,6 +53,8 @@
 #include <kfiledialog.h>
 #include <kfileplacesmodel.h>
 #include <kglobal.h>
+#include <klineedit.h>
+#include <ktoolbar.h>
 #include <kicon.h>
 #include <kiconloader.h>
 #include <kio/netaccess.h>
@@ -90,6 +92,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_tabBar(0),
     m_activeViewContainer(0),
     m_centralWidgetLayout(0),
+    m_searchBar(0),
     m_id(id),
     m_tabIndex(0),
     m_viewTab(),
@@ -840,6 +843,13 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can
     canDecode = KUrl::List::canDecode(event->mimeData());
 }
 
+void DolphinMainWindow::searchItems()
+{
+    const QString nepomukString = "nepomuksearch:/" + m_searchBar->text();
+    m_activeViewContainer->setUrl(KUrl(nepomukString));
+}
+
+
 void DolphinMainWindow::init()
 {
     DolphinSettings& settings = DolphinSettings::instance();
@@ -901,6 +911,10 @@ void DolphinMainWindow::init()
 
     setupGUI(Keys | Save | Create | ToolBar);
 
+    m_searchBar->setParent(toolBar("searchToolBar"));
+    m_searchBar->setFont(KGlobalSettings::generalFont());
+    m_searchBar->show();
+
     stateChanged("new_file");
 
     QClipboard* clipboard = QApplication::clipboard();
@@ -1055,6 +1069,11 @@ void DolphinMainWindow::setupActions()
     KStandardAction::home(this, SLOT(goHome()), actionCollection());
 
     // setup 'Tools' menu
+    KToggleAction* showSearchBar = actionCollection()->add<KToggleAction>("show_search_bar");
+    showSearchBar->setText(i18nc("@action:inmenu Tools", "Show Search Bar"));
+    showSearchBar->setShortcut(Qt::CTRL | Qt::Key_S);
+    connect(showSearchBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
+
     KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
     showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
     showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
@@ -1103,6 +1122,18 @@ void DolphinMainWindow::setupActions()
     openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
     openInNewWindow->setIcon(KIcon("window-new"));
     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()));
+
+    KAction* search = new KAction(this);
+    actionCollection()->addAction("search_bar", search);
+    search->setText(i18nc("@action:inmenu", "Search Bar"));
+    search->setDefaultWidget(m_searchBar);
+    search->setShortcutConfigurable(false);
 }
 
 void DolphinMainWindow::setupDockWidgets()
index 336b163632701760f317244500f231c5043fdb18..9939117b7b1582417718b2b12f23f7a8a97b5289 100644 (file)
@@ -41,6 +41,7 @@ class DolphinViewActionHandler;
 class DolphinApplication;
 class DolphinSettingsDialog;
 class DolphinViewContainer;
+class KLineEdit;
 class KNewMenu;
 class KTabBar;
 class KUrl;
@@ -360,6 +361,11 @@ private slots:
      */
     void slotTestCanDecode(const QDragMoveEvent* event, bool& accept);
 
+    /**
+     * Searchs items that match to the text entered in the search bar.
+     */
+    void searchItems();
+
 private:
     DolphinMainWindow(int id);
     void init();
@@ -420,6 +426,7 @@ private:
     KTabBar* m_tabBar;
     DolphinViewContainer* m_activeViewContainer;
     QVBoxLayout* m_centralWidgetLayout;
+    KLineEdit* m_searchBar;
     int m_id;
 
     struct ViewTab
index 5500ddabba7889175dc6cf0f2436f7ee1dea632f..566393e6b7223356934ffc57397d24c9bad94144 100644 (file)
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphin" version="7">
+<kpartgui name="dolphin" version="8">
     <MenuBar>
         <Menu name="file">
             <Action name="create_new" />
         <Action name="show_preview" />
         <Action name="split_view" />
     </ToolBar>
+    <ToolBar iconText="icononly" name="searchToolBar" newline="false">
+        <text context="@title:menu">Search Toolbar</text>
+        <Action name="search_bar" />
+    </ToolBar>
 </kpartgui>