#include "dolphinsearchbox.h"
#include "dolphin_searchsettings.h"
+#include "dolphinsearchinformation.h"
-#include <kicon.h>
-#include <klineedit.h>
-#include <klocale.h>
+#include <KIcon>
+#include <KLineEdit>
+#include <KLocale>
#include <kseparator.h>
#include <QButtonGroup>
#include <QKeyEvent>
#include <QLabel>
#include <QPushButton>
+#include <QScrollArea>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
#include <config-nepomuk.h>
#ifdef HAVE_NEPOMUK
- #include <nepomuk/andterm.h>
- #include <nepomuk/filequery.h>
- #include <nepomuk/literalterm.h>
- #include <nepomuk/query.h>
- #include <nepomuk/queryparser.h>
- #include <nepomuk/resourcemanager.h>
- #include <nepomuk/resourcetypeterm.h>
- #include <nepomuk/comparisonterm.h>
- #include <nepomuk/nfo.h>
+ #include <Nepomuk/Query/AndTerm>
+ #include <Nepomuk/Query/FileQuery>
+ #include <Nepomuk/Query/LiteralTerm>
+ #include <Nepomuk/Query/Query>
+ #include <Nepomuk/Query/QueryParser>
+ #include <Nepomuk/Query/ResourceTypeTerm>
+ #include <Nepomuk/Query/ComparisonTerm>
+ #include <Nepomuk/ResourceManager>
+ #include <Nepomuk/Vocabulary/NFO>
#endif
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
KUrl DolphinSearchBox::urlForSearching() const
{
KUrl url;
- if (m_nepomukActivated && isSearchPathIndexed()) {
+ const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
+ if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(url)) {
url = nepomukUrlForSearching();
} else {
url.setProtocol("filenamesearch");
optionsLayout->addWidget(m_everywhereButton);
optionsLayout->addStretch(1);
+ // Put the options into a QScrollArea. This prevents increasing the view width
+ // in case that not enough width for the options is available.
+ QWidget* optionsContainer = new QWidget(this);
+ optionsContainer->setLayout(optionsLayout);
+ QScrollArea* optionsScrollArea = new QScrollArea(this);
+ optionsScrollArea->setFrameShape(QFrame::NoFrame);
+ optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height());
+ optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optionsScrollArea->setWidget(optionsContainer);
+ optionsScrollArea->setWidgetResizable(true);
+
m_topLayout = new QVBoxLayout(this);
m_topLayout->addLayout(searchInputLayout);
- m_topLayout->addLayout(optionsLayout);
+ m_topLayout->addWidget(optionsScrollArea);
searchLabel->setBuddy(m_searchInput);
loadSettings();
connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchSignal()));
}
-bool DolphinSearchBox::isSearchPathIndexed() const
-{
-#ifdef HAVE_NEPOMUK
- const QString path = m_searchPath.path();
-
- const KConfig strigiConfig("nepomukstrigirc");
- const QStringList indexedFolders = strigiConfig.group("General").readPathEntry("folders", QStringList());
-
- // Check whether the current search path is part of an indexed folder
- bool isIndexed = false;
- foreach (const QString& indexedFolder, indexedFolders) {
- if (path.startsWith(indexedFolder)) {
- isIndexed = true;
- break;
- }
- }
-
- if (isIndexed) {
- // The current search path is part of an indexed folder. Check whether no
- // excluded folder is part of the search path.
- const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList());
- foreach (const QString& excludedFolder, excludedFolders) {
- if (path.startsWith(excludedFolder)) {
- isIndexed = false;
- break;
- }
- }
- }
-
- return isIndexed;
-#else
- return false;
-#endif
-}
-
KUrl DolphinSearchBox::nepomukUrlForSearching() const
{
#ifdef HAVE_NEPOMUK