┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/dolphinmainwindow.cpp2
-rw-r--r--src/search/dolphinsearchbox.cpp (renamed from src/dolphinsearchbox.cpp)37
-rw-r--r--src/search/dolphinsearchbox.h (renamed from src/dolphinsearchbox.h)7
-rw-r--r--src/search/dolphinsearchcommands.desktop (renamed from src/dolphinsearchcommands.desktop)0
5 files changed, 30 insertions, 20 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3186489b4..180170fbd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -105,7 +105,6 @@ set(dolphin_SRCS
dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinviewcontainer.cpp
- dolphinsearchbox.cpp
dolphindirlister.cpp
dolphincontextmenu.cpp
filterbar.cpp
@@ -122,6 +121,7 @@ set(dolphin_SRCS
panels/folders/treeviewcontextmenu.cpp
panels/folders/folderspanel.cpp
panels/folders/paneltreeview.cpp
+ search/dolphinsearchbox.cpp
settings/behaviorsettingspage.cpp
settings/columnviewsettingspage.cpp
settings/contextmenusettingspage.cpp
@@ -256,7 +256,7 @@ install(TARGETS kcm_dolphingeneral DESTINATION ${PLUGIN_INSTALL_DIR} )
install( FILES dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES settings/dolphin_directoryviewpropertysettings.kcfg settings/dolphin_generalsettings.kcfg settings/dolphin_columnmodesettings.kcfg settings/dolphin_iconsmodesettings.kcfg settings/dolphin_detailsmodesettings.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
-install( FILES dolphinsearchcommands.desktop DESTINATION ${DATA_INSTALL_DIR}/dolphin )
+install( FILES search/dolphinsearchcommands.desktop DESTINATION ${DATA_INSTALL_DIR}/dolphin )
install( FILES kcm/kcmdolphinviewmodes.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES kcm/kcmdolphinnavigation.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES kcm/kcmdolphinservices.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index f491ea8e0..6134632ae 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -27,9 +27,9 @@
#include "dolphinapplication.h"
#include "dolphinnewmenu.h"
+#include "search/dolphinsearchbox.h"
#include "settings/dolphinsettings.h"
#include "settings/dolphinsettingsdialog.h"
-#include "dolphinsearchbox.h"
#include "dolphinviewcontainer.h"
#include "panels/folders/folderspanel.h"
#include "panels/places/placespanel.h"
diff --git a/src/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index d9a82ccd6..d224575ea 100644
--- a/src/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -40,8 +40,7 @@
#ifdef HAVE_NEPOMUK
#include <Nepomuk/ResourceManager>
#include <Nepomuk/Tag>
-#endif //HAVE_NEPOMUK
-
+#endif
DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
QObject(0),
@@ -51,10 +50,6 @@ DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
m_wordStart(-1),
m_wordEnd(-1)
{
-}
-
-void DolphinSearchCompleter::init()
-{
m_completionModel = new QStandardItemModel(this);
#ifdef HAVE_NEPOMUK
@@ -73,7 +68,7 @@ void DolphinSearchCompleter::init()
}
#endif //HAVE_NEPOMUK
- //load the completions stored in the desktop file
+ // load the completions stored in the desktop file
KDesktopFile file(KStandardDirs::locate("data", "dolphin/dolphinsearchcommands.desktop"));
foreach (const QString &group, file.groupList()) {
KConfigGroup cg(&file, group);
@@ -139,7 +134,7 @@ void DolphinSearchCompleter::findText(int* wordStart, int* wordEnd, QString* new
*wordStart = -1;
*wordEnd = -1;
- //the word might contain "" and thus maybe spaces
+ // the word might contain "" and thus maybe spaces
if (input.contains('\"')) {
int tempStart = -1;
int tempEnd = -1;
@@ -264,13 +259,13 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
m_searchInput->setClearButtonShown(true);
m_searchInput->setMinimumWidth(150);
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(returnPressed()),
this, SLOT(emitSearchSignal()));
- m_completer = new DolphinSearchCompleter(m_searchInput);
- m_completer->init();
-
m_searchButton = new QToolButton(this);
m_searchButton->setAutoRaise(true);
m_searchButton->setIcon(KIcon("edit-find"));
@@ -282,7 +277,6 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
DolphinSearchBox::~DolphinSearchBox()
{
- delete m_completer;
}
bool DolphinSearchBox::event(QEvent* event)
@@ -297,9 +291,28 @@ bool DolphinSearchBox::event(QEvent* event)
return QWidget::event(event);
}
+bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
+{
+ if ((watched == m_searchInput) && (event->type() == QEvent::FocusIn)) {
+ // Postpone the creation of the search completer until
+ // the search box is used. This decreases the startup time
+ // of Dolphin.
+ Q_ASSERT(m_completer == 0);
+ m_completer = new DolphinSearchCompleter(m_searchInput);
+ m_searchInput->removeEventFilter(this);
+ }
+
+ return QWidget::eventFilter(watched, event);
+}
+
+
void DolphinSearchBox::emitSearchSignal()
{
emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
}
+void DolphinSearchBox::slotTextEdited(const QString& text)
+{
+}
+
#include "dolphinsearchbox.moc"
diff --git a/src/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index c518d6a1d..93c033bb8 100644
--- a/src/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -40,8 +40,6 @@ class DolphinSearchCompleter : public QObject
public:
DolphinSearchCompleter(KLineEdit *linedit);
- void init();
-
public slots:
void highlighted(const QModelIndex& index);
void activated(const QModelIndex& index);
@@ -74,6 +72,7 @@ public:
protected:
virtual bool event(QEvent* event);
+ virtual bool eventFilter(QObject* watched, QEvent* event);
signals:
/**
@@ -85,9 +84,7 @@ signals:
private slots:
void emitSearchSignal();
-
-
-
+ void slotTextEdited(const QString& text);
private:
KLineEdit* m_searchInput;
diff --git a/src/dolphinsearchcommands.desktop b/src/search/dolphinsearchcommands.desktop
index 303f8d0cf..303f8d0cf 100644
--- a/src/dolphinsearchcommands.desktop
+++ b/src/search/dolphinsearchcommands.desktop