dolphinsearchbox.cpp 18.2 KB
Newer Older
1
/***************************************************************************
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
*    Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com>            *
*                                                                         *
*    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           *
* **************************************************************************/
19

20
#include "global.h"
21
22
#include "dolphinsearchbox.h"

23
#include "dolphin_searchsettings.h"
24
#include "dolphinfacetswidget.h"
25
#include "dolphinquery.h"
Roman Inflianskas's avatar
Roman Inflianskas committed
26
#include "panels/places/placesitemmodel.h"
27

Laurent Montel's avatar
Laurent Montel committed
28
#include <KLocalizedString>
29
#include <KNS3/KMoreToolsMenuFactory>
Roman Inflianskas's avatar
Roman Inflianskas committed
30
31
32
33
34
35
#include <KSeparator>
#include <config-baloo.h>
#ifdef HAVE_BALOO
#include <Baloo/Query>
#include <Baloo/IndexerConfig>
#endif
36

37
38
#include <QButtonGroup>
#include <QDir>
Roman Inflianskas's avatar
Roman Inflianskas committed
39
#include <QFontDatabase>
40
#include <QHBoxLayout>
Roman Inflianskas's avatar
Roman Inflianskas committed
41
#include <QIcon>
Antonio Rojas's avatar
Antonio Rojas committed
42
#include <QKeyEvent>
43
#include <QLabel>
Roman Inflianskas's avatar
Roman Inflianskas committed
44
#include <QLineEdit>
45
#include <QScrollArea>
Antonio Rojas's avatar
Antonio Rojas committed
46
#include <QShowEvent>
47
#include <QTimer>
48
#include <QToolButton>
49
#include <QUrlQuery>
50

51
52
53
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
    QWidget(parent),
    m_startedSearching(false),
54
    m_active(true),
Kevin Funk's avatar
Kevin Funk committed
55
56
57
58
59
60
61
62
63
64
    m_topLayout(nullptr),
    m_searchInput(nullptr),
    m_saveSearchAction(nullptr),
    m_optionsScrollArea(nullptr),
    m_fileNameButton(nullptr),
    m_contentButton(nullptr),
    m_separator(nullptr),
    m_fromHereButton(nullptr),
    m_everywhereButton(nullptr),
    m_facetsWidget(nullptr),
65
    m_searchPath(),
Kevin Funk's avatar
Kevin Funk committed
66
    m_startSearchTimer(nullptr)
67
68
69
{
}

70
DolphinSearchBox::~DolphinSearchBox()
71
{
72
73
    saveSettings();
}
74

Peter Penz's avatar
Peter Penz committed
75
76
77
78
79
void DolphinSearchBox::setText(const QString& text)
{
    m_searchInput->setText(text);
}

80
81
82
83
QString DolphinSearchBox::text() const
{
    return m_searchInput->text();
}
84

Lukáš Tinkl's avatar
Lukáš Tinkl committed
85
void DolphinSearchBox::setSearchPath(const QUrl& url)
86
{
87
88
89
90
    if (url == m_searchPath) {
        return;
    }

91
92
93
94
95
96
97
98
99
100
101
102
103
    const QUrl cleanedUrl = url.adjusted(QUrl::RemoveUserInfo | QUrl::StripTrailingSlash);

    if (cleanedUrl.path() == QDir::homePath()) {
        m_fromHereButton->setChecked(false);
        m_everywhereButton->setChecked(true);
        if (!m_searchPath.isEmpty()) {
            return;
        }
    } else {
        m_everywhereButton->setChecked(false);
        m_fromHereButton->setChecked(true);
    }

104
    m_searchPath = url;
105
106

    QFontMetrics metrics(m_fromHereButton->font());
107
    const int maxWidth = metrics.height() * 8;
108

109
    QString location = cleanedUrl.fileName();
110
    if (location.isEmpty()) {
111
112
        location = cleanedUrl.toString(QUrl::PreferLocalFile);
    }
113
114
    const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth);
    m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation));
115
    m_fromHereButton->setToolTip(i18nc("action:button", "Limit search to '%1' and its subfolders", cleanedUrl.toString(QUrl::PreferLocalFile)));
116
117
}

Lukáš Tinkl's avatar
Lukáš Tinkl committed
118
QUrl DolphinSearchBox::searchPath() const
119
{
120
    return m_everywhereButton->isChecked() ? QUrl::fromLocalFile(QDir::homePath()) : m_searchPath;
121
}
122

Lukáš Tinkl's avatar
Lukáš Tinkl committed
123
QUrl DolphinSearchBox::urlForSearching() const
124
{
Lukáš Tinkl's avatar
Lukáš Tinkl committed
125
    QUrl url;
126
127

    if (isIndexingEnabled()) {
Vishesh Handa's avatar
Vishesh Handa committed
128
        url = balooUrlForSearching();
129
    } else {
130
        url.setScheme(QStringLiteral("filenamesearch"));
131
132

        QUrlQuery query;
133
        query.addQueryItem(QStringLiteral("search"), m_searchInput->text());
134
        if (m_contentButton->isChecked()) {
135
            query.addQueryItem(QStringLiteral("checkContent"), QStringLiteral("yes"));
136
        }
137

138
        query.addQueryItem(QStringLiteral("url"), searchPath().url());
139
        query.addQueryItem(QStringLiteral("title"), queryTitle(m_searchInput->text()));
140
141

        url.setQuery(query);
142
143
    }

144
145
    return url;
}
146

Lukáš Tinkl's avatar
Lukáš Tinkl committed
147
void DolphinSearchBox::fromSearchUrl(const QUrl& url)
148
{
149
    if (url.scheme() == QLatin1String("baloosearch")) {
150
151
        const DolphinQuery query = DolphinQuery::fromBalooSearchUrl(url);
        updateFromQuery(query);
152
    } else if (url.scheme() == QLatin1String("filenamesearch")) {
153
        const QUrlQuery query(url);
154
        setText(query.queryItemValue(QStringLiteral("search")));
155
156
157
        if (m_searchPath.scheme() != url.scheme()) {
            m_searchPath = QUrl();
        }
158
159
        setSearchPath(QUrl::fromUserInput(query.queryItemValue(QStringLiteral("url")), QString(), QUrl::AssumeLocalFile));
        m_contentButton->setChecked(query.queryItemValue(QStringLiteral("checkContent")) == QLatin1String("yes"));
160
161
    } else {
        setText(QString());
162
        m_searchPath = QUrl();
163
        setSearchPath(url);
164
    }
165

166
    updateFacetsVisible();
167
168
}

169
void DolphinSearchBox::selectAll()
170
{
171
    m_searchInput->selectAll();
172
173
}

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
void DolphinSearchBox::setActive(bool active)
{
    if (active != m_active) {
        m_active = active;

        if (active) {
            emit activated();
        }
    }
}

bool DolphinSearchBox::isActive() const
{
    return m_active;
}

190
191
192
193
bool DolphinSearchBox::event(QEvent* event)
{
    if (event->type() == QEvent::Polish) {
        init();
194
    }
195
196
    return QWidget::event(event);
}
197

198
199
200
201
202
void DolphinSearchBox::showEvent(QShowEvent* event)
{
    if (!event->spontaneous()) {
        m_searchInput->setFocus();
        m_startedSearching = false;
203
    }
204
}
205

206
207
void DolphinSearchBox::hideEvent(QHideEvent* event)
{
208
    Q_UNUSED(event)
209
210
211
212
    m_startedSearching = false;
    m_startSearchTimer->stop();
}

213
214
215
void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event)
{
    QWidget::keyReleaseEvent(event);
Peter Penz's avatar
Peter Penz committed
216
    if (event->key() == Qt::Key_Escape) {
217
218
219
220
221
        if (m_searchInput->text().isEmpty()) {
            emit closeRequest();
        } else {
            m_searchInput->clear();
        }
222
    }
223
224
225
    else if (event->key() == Qt::Key_Down) {
        emit focusViewRequest();
    }
226
}
227

228
229
230
231
bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event)
{
    switch (event->type()) {
    case QEvent::FocusIn:
232
233
234
        // #379135: we get the FocusIn event when we close a tab but we don't want to emit
        // the activated() signal before the removeTab() call in DolphinTabWidget::closeTab() returns.
        // To avoid this issue, we delay the activation of the search box.
Elvis Angelaccio's avatar
Elvis Angelaccio committed
235
236
237
238
239
240
241
242
        // We also don't want to schedule the activation process if we are already active,
        // otherwise we can enter in a loop of FocusIn/FocusOut events with the searchbox of another tab.
        if (!isActive()) {
            QTimer::singleShot(0, this, [this] {
                setActive(true);
                setFocus();
            });
        }
243
244
245
246
247
248
249
250
251
        break;

    default:
        break;
    }

    return QObject::eventFilter(obj, event);
}

Peter Penz's avatar
Peter Penz committed
252
void DolphinSearchBox::emitSearchRequest()
253
{
254
    m_startSearchTimer->stop();
255
    m_startedSearching = true;
256
    m_saveSearchAction->setEnabled(true);
Peter Penz's avatar
Peter Penz committed
257
    emit searchRequest();
258
}
259

Peter Penz's avatar
Peter Penz committed
260
void DolphinSearchBox::emitCloseRequest()
Peter Penz's avatar
Peter Penz committed
261
{
Peter Penz's avatar
Peter Penz committed
262
263
    m_startSearchTimer->stop();
    m_startedSearching = false;
264
    m_saveSearchAction->setEnabled(false);
Peter Penz's avatar
Peter Penz committed
265
    emit closeRequest();
Peter Penz's avatar
Peter Penz committed
266
267
}

268
269
void DolphinSearchBox::slotConfigurationChanged()
{
Peter Penz's avatar
Peter Penz committed
270
    saveSettings();
271
    if (m_startedSearching) {
Peter Penz's avatar
Peter Penz committed
272
        emitSearchRequest();
273
274
275
    }
}

276
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
277
{
278

Peter Penz's avatar
Peter Penz committed
279
280
281
282
283
    if (text.isEmpty()) {
        m_startSearchTimer->stop();
    } else {
        m_startSearchTimer->start();
    }
284
285
286
    emit searchTextChanged(text);
}

287
void DolphinSearchBox::slotReturnPressed()
288
{
Peter Penz's avatar
Peter Penz committed
289
    emitSearchRequest();
290
    emit focusViewRequest();
291
292
}

Peter Penz's avatar
Peter Penz committed
293
294
295
296
297
298
299
void DolphinSearchBox::slotFacetChanged()
{
    m_startedSearching = true;
    m_startSearchTimer->stop();
    emit searchRequest();
}

300
301
302
303
304
305
void DolphinSearchBox::slotSearchSaved()
{
    const QUrl searchURL = urlForSearching();
    if (searchURL.isValid()) {
        PlacesItemModel model;
        const QString label = i18n("Search for %1 in %2", text(), searchPath().fileName());
306
307
308
        model.createPlacesItem(label,
                               searchURL,
                               QStringLiteral("folder-saved-search-symbolic"));
309
310
311
    }
}

312
void DolphinSearchBox::initButton(QToolButton* button)
313
{
314
    button->installEventFilter(this);
315
    button->setAutoExclusive(true);
316
    button->setAutoRaise(true);
317
    button->setCheckable(true);
318
    connect(button, &QToolButton::clicked, this, &DolphinSearchBox::slotConfigurationChanged);
319
}
320

321
322
323
324
325
326
327
void DolphinSearchBox::loadSettings()
{
    if (SearchSettings::location() == QLatin1String("Everywhere")) {
        m_everywhereButton->setChecked(true);
    } else {
        m_fromHereButton->setChecked(true);
    }
328

329
330
331
332
    if (SearchSettings::what() == QLatin1String("Content")) {
        m_contentButton->setChecked(true);
    } else {
        m_fileNameButton->setChecked(true);
333
    }
334

335
    updateFacetsVisible();
336
}
337

338
339
void DolphinSearchBox::saveSettings()
{
340
341
    SearchSettings::setLocation(m_fromHereButton->isChecked() ? QStringLiteral("FromHere") : QStringLiteral("Everywhere"));
    SearchSettings::setWhat(m_fileNameButton->isChecked() ? QStringLiteral("FileName") : QStringLiteral("Content"));
Laurent Montel's avatar
Laurent Montel committed
342
    SearchSettings::self()->save();
343
344
}

345
void DolphinSearchBox::init()
346
{
347
348
349
    // Create close button
    QToolButton* closeButton = new QToolButton(this);
    closeButton->setAutoRaise(true);
350
    closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
351
    closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
352
    connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
353
354

    // Create search box
Emmanuel Pescosta's avatar
Emmanuel Pescosta committed
355
    m_searchInput = new QLineEdit(this);
356
    m_searchInput->setPlaceholderText(i18n("Search..."));
357
    m_searchInput->installEventFilter(this);
Emmanuel Pescosta's avatar
Emmanuel Pescosta committed
358
    m_searchInput->setClearButtonEnabled(true);
Laurent Montel's avatar
Laurent Montel committed
359
    m_searchInput->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
Emmanuel Pescosta's avatar
Emmanuel Pescosta committed
360
    connect(m_searchInput, &QLineEdit::returnPressed,
361
            this, &DolphinSearchBox::slotReturnPressed);
Emmanuel Pescosta's avatar
Emmanuel Pescosta committed
362
    connect(m_searchInput, &QLineEdit::textChanged,
363
            this, &DolphinSearchBox::slotSearchTextChanged);
364
    setFocusProxy(m_searchInput);
365

366
367
368
369
370
371
372
373
    // Add "Save search" button inside search box
    m_saveSearchAction = new QAction(this);
    m_saveSearchAction->setIcon (QIcon::fromTheme(QStringLiteral("document-save-symbolic")));
    m_saveSearchAction->setText(i18nc("action:button", "Save this search to quickly access it again in the future"));
    m_saveSearchAction->setEnabled(false);
    m_searchInput->addAction(m_saveSearchAction, QLineEdit::TrailingPosition);
    connect(m_saveSearchAction, &QAction::triggered, this, &DolphinSearchBox::slotSearchSaved);

374
375
    // Apply layout for the search input
    QHBoxLayout* searchInputLayout = new QHBoxLayout();
Laurent Montel's avatar
Laurent Montel committed
376
    searchInputLayout->setContentsMargins(0, 0, 0, 0);
377
378
379
380
    searchInputLayout->addWidget(closeButton);
    searchInputLayout->addWidget(m_searchInput);

    // Create "Filename" and "Content" button
381
    m_fileNameButton = new QToolButton(this);
382
383
384
    m_fileNameButton->setText(i18nc("action:button", "Filename"));
    initButton(m_fileNameButton);

385
    m_contentButton = new QToolButton();
386
    m_contentButton->setText(i18nc("action:button", "Content"));
387
    initButton(m_contentButton);
388
389
390
391
392

    QButtonGroup* searchWhatGroup = new QButtonGroup(this);
    searchWhatGroup->addButton(m_fileNameButton);
    searchWhatGroup->addButton(m_contentButton);

393
394
    m_separator = new KSeparator(Qt::Vertical, this);

395
    // Create "From Here" and "Your files" buttons
396
    m_fromHereButton = new QToolButton(this);
397
398
399
    m_fromHereButton->setText(i18nc("action:button", "From Here"));
    initButton(m_fromHereButton);

400
    m_everywhereButton = new QToolButton(this);
401
402
403
404
    m_everywhereButton->setText(i18nc("action:button", "Your files"));
    m_everywhereButton->setToolTip(i18nc("action:button", "Search in your home directory"));
    m_everywhereButton->setIcon(QIcon::fromTheme(QStringLiteral("user-home")));
    m_everywhereButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
405
406
407
408
409
410
    initButton(m_everywhereButton);

    QButtonGroup* searchLocationGroup = new QButtonGroup(this);
    searchLocationGroup->addButton(m_fromHereButton);
    searchLocationGroup->addButton(m_everywhereButton);

411
412
413
414
415
416
417
418
419
420
421
422
423
424
    auto moreSearchToolsButton = new QToolButton(this);
    moreSearchToolsButton->setAutoRaise(true);
    moreSearchToolsButton->setPopupMode(QToolButton::InstantPopup);
    moreSearchToolsButton->setIcon(QIcon::fromTheme("arrow-down-double"));
    moreSearchToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    moreSearchToolsButton->setText(i18n("More Search Tools"));
    moreSearchToolsButton->setMenu(new QMenu(this));
    connect(moreSearchToolsButton->menu(), &QMenu::aboutToShow, moreSearchToolsButton->menu(), [this, moreSearchToolsButton]()
    {
        m_menuFactory.reset(new KMoreToolsMenuFactory("dolphin/search-tools"));
        moreSearchToolsButton->menu()->clear();
        m_menuFactory->fillMenuFromGroupingNames(moreSearchToolsButton->menu(), { "files-find" }, this->m_searchPath);
    } );

425
    // Create "Facets" widget
426
    m_facetsWidget = new DolphinFacetsWidget(this);
427
    m_facetsWidget->installEventFilter(this);
428
    m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
429
    m_facetsWidget->layout()->setSpacing(Dolphin::LAYOUT_SPACING_SMALL);
430
    connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged);
431

432
433
    // Apply layout for the options
    QHBoxLayout* optionsLayout = new QHBoxLayout();
Laurent Montel's avatar
Laurent Montel committed
434
    optionsLayout->setContentsMargins(0, 0, 0, 0);
435
    optionsLayout->setSpacing(Dolphin::LAYOUT_SPACING_SMALL);
436
437
    optionsLayout->addWidget(m_fileNameButton);
    optionsLayout->addWidget(m_contentButton);
438
439
440
    optionsLayout->addWidget(m_separator);
    optionsLayout->addWidget(m_fromHereButton);
    optionsLayout->addWidget(m_everywhereButton);
441
442
443
    optionsLayout->addWidget(new KSeparator(Qt::Vertical, this));
    optionsLayout->addWidget(moreSearchToolsButton);
    optionsLayout->addStretch(1);
444

445
446
447
448
    // 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);
Peter Penz's avatar
Peter Penz committed
449
450
451
452
453
454
455
456
457

    m_optionsScrollArea = new QScrollArea(this);
    m_optionsScrollArea->setFrameShape(QFrame::NoFrame);
    m_optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height());
    m_optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    m_optionsScrollArea->setWidget(optionsContainer);
    m_optionsScrollArea->setWidgetResizable(true);
458

459
    m_topLayout = new QVBoxLayout(this);
Laurent Montel's avatar
Laurent Montel committed
460
    m_topLayout->setContentsMargins(0, 0, 0, 0);
461
    m_topLayout->setSpacing(Dolphin::LAYOUT_SPACING_SMALL);
462
    m_topLayout->addLayout(searchInputLayout);
Peter Penz's avatar
Peter Penz committed
463
    m_topLayout->addWidget(m_optionsScrollArea);
464
    m_topLayout->addWidget(m_facetsWidget);
465
466

    loadSettings();
467
468
469
470
471
472

    // The searching should be started automatically after the user did not change
    // the text within one second
    m_startSearchTimer = new QTimer(this);
    m_startSearchTimer->setSingleShot(true);
    m_startSearchTimer->setInterval(1000);
473
    connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
474
475
}

476
477
478
479
480
481
QString DolphinSearchBox::queryTitle(const QString& text) const
{
    return i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
                             "Query Results from '%1'", text);
}

Lukáš Tinkl's avatar
Lukáš Tinkl committed
482
QUrl DolphinSearchBox::balooUrlForSearching() const
483
{
Vishesh Handa's avatar
Vishesh Handa committed
484
#ifdef HAVE_BALOO
485
    const QString text = m_searchInput->text();
Vishesh Handa's avatar
Vishesh Handa committed
486
487

    Baloo::Query query;
488
    query.addType(m_facetsWidget->facetType());
Vishesh Handa's avatar
Vishesh Handa committed
489

Ismael Asensio's avatar
Ismael Asensio committed
490
    QStringList queryStrings = m_facetsWidget->searchTerms();
491

492
    if (m_contentButton->isChecked()) {
Vishesh Handa's avatar
Vishesh Handa committed
493
        queryStrings << text;
494
    } else if (!text.isEmpty()) {
495
        queryStrings << QStringLiteral("filename:\"%1\"").arg(text);
Peter Penz's avatar
Peter Penz committed
496
497
    }

498
    if (m_fromHereButton->isChecked()) {
499
        query.setIncludeFolder(m_searchPath.toLocalFile());
500
    }
501

502
    query.setSearchString(queryStrings.join(QLatin1Char(' ')));
503

504
    return query.toSearchUrl(queryTitle(text));
505
#else
Lukáš Tinkl's avatar
Lukáš Tinkl committed
506
    return QUrl();
507
#endif
508
509
}

510
void DolphinSearchBox::updateFromQuery(const DolphinQuery& query)
511
{
512
513
514
515
    // Block all signals to avoid unnecessary "searchRequest" signals
    // while we adjust the search text and the facet widget.
    blockSignals(true);

516
517
    const QString customDir = query.includeFolder();
    if (!customDir.isEmpty()) {
518
        setSearchPath(QUrl::fromLocalFile(customDir));
Peter Penz's avatar
Peter Penz committed
519
    } else {
520
        setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
Peter Penz's avatar
Peter Penz committed
521
522
    }

523
    setText(query.text());
524

525
526
527
528
529
530
    if (query.hasContentSearch()) {
        m_contentButton->setChecked(true);
    } else if (query.hasFileName())  {
        m_fileNameButton->setChecked(true);
    }

531
    m_facetsWidget->resetSearchTerms();
532
533
534
    m_facetsWidget->setFacetType(query.type());
    const QStringList searchTerms = query.searchTerms();
    for (const QString& searchTerm : searchTerms) {
535
        m_facetsWidget->setSearchTerm(searchTerm);
536
    }
537
538
539

    m_startSearchTimer->stop();
    blockSignals(false);
540
541
}

542
void DolphinSearchBox::updateFacetsVisible()
543
544
545
{
    const bool indexingEnabled = isIndexingEnabled();
    m_facetsWidget->setEnabled(indexingEnabled);
546
    m_facetsWidget->setVisible(indexingEnabled);
547
548
}

549
550
551
552
bool DolphinSearchBox::isIndexingEnabled() const
{
#ifdef HAVE_BALOO
    const Baloo::IndexerConfig searchInfo;
553
    return searchInfo.fileIndexingEnabled() && !searchPath().isEmpty() && searchInfo.shouldBeIndexed(searchPath().toLocalFile());
554
555
556
557
#else
    return false;
#endif
}