]> cloud.milkyroute.net Git - dolphin.git/commitdiff
add A search options widget, which later on will include Adam Kidder's search prototy...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 17 Oct 2009 19:24:05 +0000 (19:24 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 17 Oct 2009 19:24:05 +0000 (19:24 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1036776

src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/search/dolphinsearchbox.cpp
src/search/dolphinsearchbox.h
src/search/dolphinsearchoptionsconfigurator.cpp [new file with mode: 0644]
src/search/dolphinsearchoptionsconfigurator.h [new file with mode: 0644]

index 180170fbdd320baed2130743b24d3ce9ddb24a9a..429695f5ded64ebf2be072fd21e30b2123f74a83 100644 (file)
@@ -122,6 +122,7 @@ set(dolphin_SRCS
     panels/folders/folderspanel.cpp
     panels/folders/paneltreeview.cpp
     search/dolphinsearchbox.cpp
+    search/dolphinsearchoptionsconfigurator.cpp
     settings/behaviorsettingspage.cpp
     settings/columnviewsettingspage.cpp
     settings/contextmenusettingspage.cpp
index 6134632aecaecb47223299016df6b9fdb1a737e0..b16fb7f2a9c259030b779628ca3ae0987abd4537 100644 (file)
@@ -28,6 +28,7 @@
 #include "dolphinapplication.h"
 #include "dolphinnewmenu.h"
 #include "search/dolphinsearchbox.h"
+#include "search/dolphinsearchoptionsconfigurator.h"
 #include "settings/dolphinsettings.h"
 #include "settings/dolphinsettingsdialog.h"
 #include "dolphinviewcontainer.h"
@@ -109,6 +110,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_activeViewContainer(0),
     m_centralWidgetLayout(0),
     m_searchBox(0),
+    m_searchOptionsConfigurator(0),
     m_id(id),
     m_tabIndex(0),
     m_viewTab(),
@@ -983,6 +985,11 @@ void DolphinMainWindow::slotTabMoved(int from, int to)
     m_tabIndex = m_tabBar->currentIndex();
 }
 
+void DolphinMainWindow::slotSearchBoxTextChanged(const QString& text)
+{
+    m_searchOptionsConfigurator->setVisible(!text.isEmpty());
+}
+
 void DolphinMainWindow::init()
 {
     DolphinSettings& settings = DolphinSettings::instance();
@@ -1023,6 +1030,9 @@ void DolphinMainWindow::init()
     connect(this, SIGNAL(urlChanged(const KUrl&)),
             m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
 
+    m_searchOptionsConfigurator = new DolphinSearchOptionsConfigurator(this);
+    m_searchOptionsConfigurator->hide();
+
     m_tabBar = new KTabBar(this);
     m_tabBar->setMovable(true);
     m_tabBar->setTabsClosable(true);
@@ -1049,8 +1059,9 @@ void DolphinMainWindow::init()
     m_centralWidgetLayout = new QVBoxLayout(centralWidget);
     m_centralWidgetLayout->setSpacing(0);
     m_centralWidgetLayout->setMargin(0);
+    m_centralWidgetLayout->addWidget(m_searchOptionsConfigurator);
     m_centralWidgetLayout->addWidget(m_tabBar);
-    m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
+    m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
 
     setCentralWidget(centralWidget);
     setupDockWidgets();
@@ -1060,6 +1071,8 @@ void DolphinMainWindow::init()
 
     m_searchBox->setParent(toolBar("searchToolBar"));
     m_searchBox->show();
+    connect(m_searchBox, SIGNAL(textChanged(const QString&)),
+            this, SLOT(slotSearchBoxTextChanged(const QString&)));
 
     stateChanged("new_file");
 
index d5bd1c59bfee2de3d7da8624802ce1cc68f5bcd3..223b0cb3fc985809baff856e0e94a9ab33b398b6 100644 (file)
@@ -41,6 +41,7 @@ class KAction;
 class DolphinViewActionHandler;
 class DolphinApplication;
 class DolphinSearchBox;
+class DolphinSearchOptionsConfigurator;
 class DolphinSettingsDialog;
 class DolphinViewContainer;
 class DolphinRemoteEncoding;
@@ -381,6 +382,13 @@ private slots:
      */
     void slotTabMoved(int from, int to);
 
+    /**
+     * Is connected to the searchbox signal 'textEdited' and
+     * takes care to make the search options configurator visible
+     * if a search text has been entered.
+     */
+    void slotSearchBoxTextChanged(const QString& text);
+
 private:
     DolphinMainWindow(int id);
     void init();
@@ -463,6 +471,7 @@ private:
     DolphinViewContainer* m_activeViewContainer;
     QVBoxLayout* m_centralWidgetLayout;
     DolphinSearchBox* m_searchBox;
+    DolphinSearchOptionsConfigurator* m_searchOptionsConfigurator;
     int m_id;
 
     struct ViewTab
index d224575eab301c52071f9f485433b065522cc10a..312bfb1cb718f60eacd01efa1647232ee6611f08 100644 (file)
@@ -261,8 +261,8 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     m_searchInput->setClickMessage(i18nc("@label:textbox", "Search..."));
     m_searchInput->installEventFilter(this);
     hLayout->addWidget(m_searchInput);
-    connect(m_searchInput, SIGNAL(textEdited(const QString&)),
-            this, SLOT(slotTextEdited(const QString&)));
+    connect(m_searchInput, SIGNAL(textChanged(const QString&)),
+            this, SIGNAL(textChanged(const QString&)));
     connect(m_searchInput, SIGNAL(returnPressed()),
             this, SLOT(emitSearchSignal()));
 
@@ -311,8 +311,4 @@ void DolphinSearchBox::emitSearchSignal()
     emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
 }
 
-void DolphinSearchBox::slotTextEdited(const QString& text)
-{
-}
-
 #include "dolphinsearchbox.moc"
index 93c033bb8e6caef48fea249ed55e76aeb9dcc5f0..2e4c6b85a37c9d9dae98f88373b0f9576aea83c6 100644 (file)
@@ -37,26 +37,27 @@ class QToolButton;
 class DolphinSearchCompleter : public QObject
 {
     Q_OBJECT
-    public:
-        DolphinSearchCompleter(KLineEdit *linedit);
-
-    public slots:
-        void highlighted(const QModelIndex& index);
-        void activated(const QModelIndex& index);
-        void slotTextEdited(const QString &text);
-
-    private:
-        void addCompletionItem(const QString& displayed, const QString& usedForCompletition, const QString& description = QString(), const QString& toolTip = QString(), const KIcon& icon = KIcon());
-
-        void findText(int* wordStart, int* wordEnd, QString* newWord, int cursorPos, const QString &input);
-
-    private:
-        KLineEdit* q;
-        QCompleter* m_completer;
-        QStandardItemModel* m_completionModel;
-        QString m_userText;
-        int m_wordStart;
-        int m_wordEnd;
+
+public:
+    DolphinSearchCompleter(KLineEdit *linedit);
+
+public slots:
+    void highlighted(const QModelIndex& index);
+    void activated(const QModelIndex& index);
+    void slotTextEdited(const QString &text);
+
+private:
+    void addCompletionItem(const QString& displayed, const QString& usedForCompletition, const QString& description = QString(), const QString& toolTip = QString(), const KIcon& icon = KIcon());
+
+    void findText(int* wordStart, int* wordEnd, QString* newWord, int cursorPos, const QString &input);
+
+private:
+    KLineEdit* q;
+    QCompleter* m_completer;
+    QStandardItemModel* m_completionModel;
+    QString m_userText;
+    int m_wordStart;
+    int m_wordEnd;
 };
 
 /**
@@ -82,9 +83,13 @@ signals:
      */
     void search(const KUrl& url);
 
+    /**
+     * Is emitted if the text of the searchbox has been changed.
+     */
+    void textChanged(const QString& text);
+
 private slots:
     void emitSearchSignal();
-    void slotTextEdited(const QString& text);
 
 private:
     KLineEdit* m_searchInput;
diff --git a/src/search/dolphinsearchoptionsconfigurator.cpp b/src/search/dolphinsearchoptionsconfigurator.cpp
new file mode 100644 (file)
index 0000000..5e270d5
--- /dev/null
@@ -0,0 +1,73 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "dolphinsearchoptionsconfigurator.h"
+
+#include <kcombobox.h>
+#include <klocale.h>
+
+#include <QButtonGroup>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* parent) :
+    QWidget(parent)
+{
+    QVBoxLayout* vBoxLayout = new QVBoxLayout(this);
+
+    // add "search" configuration
+    QLabel* searchLabel = new QLabel(i18nc("@label", "Search:"));
+
+    KComboBox* searchFromBox = new KComboBox();
+    searchFromBox->addItem(i18nc("label", "Everywhere"));
+    searchFromBox->addItem(i18nc("label", "From Here"));
+
+    // add "what" configuration
+    QLabel* whatLabel = new QLabel(i18nc("@label", "What:"));
+
+    KComboBox* searchWhatBox = new KComboBox();
+    searchWhatBox->addItem(i18nc("label", "All"));
+    searchWhatBox->addItem(i18nc("label", "Images"));
+    searchWhatBox->addItem(i18nc("label", "Texts"));
+    searchWhatBox->addItem(i18nc("label", "File Names"));
+
+    QWidget* filler = new QWidget();
+
+    // add button "Save"
+    QPushButton* saveButton = new QPushButton();
+    saveButton->setText(i18nc("@action:button", "Save"));
+
+    QHBoxLayout* hBoxLayout = new QHBoxLayout(this);
+    hBoxLayout->addWidget(searchLabel);
+    hBoxLayout->addWidget(searchFromBox);
+    hBoxLayout->addWidget(whatLabel);
+    hBoxLayout->addWidget(searchWhatBox);
+    hBoxLayout->addWidget(filler, 1);
+    hBoxLayout->addWidget(saveButton);
+
+    vBoxLayout->addLayout(hBoxLayout);
+}
+
+DolphinSearchOptionsConfigurator::~DolphinSearchOptionsConfigurator()
+{
+}
+
+#include "dolphinsearchoptionsconfigurator.moc"
diff --git a/src/search/dolphinsearchoptionsconfigurator.h b/src/search/dolphinsearchoptionsconfigurator.h
new file mode 100644 (file)
index 0000000..9b5a70b
--- /dev/null
@@ -0,0 +1,34 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef DOLPHINSEARCHOPTIONSCONFIGURATOR_H
+#define DOLPHINSEARCHOPTIONSCONFIGURATOR_H
+
+#include <QWidget>
+
+class DolphinSearchOptionsConfigurator : public QWidget
+{
+    Q_OBJECT
+
+public:
+    DolphinSearchOptionsConfigurator(QWidget* parent = 0);
+    virtual ~DolphinSearchOptionsConfigurator();
+};
+
+#endif