mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
* move classes for searching into an own folder (new classes will be added soon)
* Postpone the creation of the searchcompleter, until the editor gets focused. This improves the startup time of Dolphin (reading all available tags is an expensive operation). svn path=/trunk/KDE/kdebase/apps/; revision=1036658
This commit is contained in:
parent
e1dde0669f
commit
5e123c68d7
|
@ -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} )
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk/Tag>
|
||||
#endif //HAVE_NEPOMUK
|
||||
|
||||
#endif
|
||||
|
||||
DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
|
||||
QObject(0),
|
||||
|
@ -50,10 +49,6 @@ DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
|
|||
m_completionModel(0),
|
||||
m_wordStart(-1),
|
||||
m_wordEnd(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void DolphinSearchCompleter::init()
|
||||
{
|
||||
m_completionModel = new QStandardItemModel(this);
|
||||
|
||||
|
@ -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"
|
|
@ -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;
|
Loading…
Reference in a new issue