┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-25 02:16:35 +0200
committerPeter Penz <[email protected]>2012-04-25 02:20:25 +0200
commit67f58d5082cbab3a1a4a83926e77ade299ec07ea (patch)
tree4cb2171bb8ccf0cab7a4d4361836def5fb82ee44 /src/search
parentd9de39172033c28b8f9a7c1573130cf2124b4f7a (diff)
Fix search-UI issues in combination with the new places entries
The places-entries for searching revealed some serious issues in combination with the search-panel. Move the filtering away from QDockWidget and bring it back below the search-bar.
Diffstat (limited to 'src/search')
-rw-r--r--src/search/dolphin_searchsettings.kcfg4
-rw-r--r--src/search/dolphinfacetswidget.cpp108
-rw-r--r--src/search/dolphinfacetswidget.h73
-rw-r--r--src/search/dolphinsearchbox.cpp40
-rw-r--r--src/search/dolphinsearchbox.h8
5 files changed, 231 insertions, 2 deletions
diff --git a/src/search/dolphin_searchsettings.kcfg b/src/search/dolphin_searchsettings.kcfg
index 1acebf874..81190d29e 100644
--- a/src/search/dolphin_searchsettings.kcfg
+++ b/src/search/dolphin_searchsettings.kcfg
@@ -14,5 +14,9 @@
<label>What</label>
<default>FileName</default>
</entry>
+ <entry name="ShowFacetsWidget" type="Bool">
+ <label>Show facets widget</label>
+ <default>false</default>
+ </entry>
</group>
</kcfg>
diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp
new file mode 100644
index 000000000..1a912af48
--- /dev/null
+++ b/src/search/dolphinfacetswidget.cpp
@@ -0,0 +1,108 @@
+/***************************************************************************
+* Copyright (C) 2012 by Peter Penz <[email protected]> *
+* *
+* 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 "dolphinfacetswidget.h"
+
+#include <KLocale>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+
+DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
+ QWidget(parent),
+ m_documents(0),
+ m_images(0),
+ m_audio(0),
+ m_videos(0),
+ m_anytime(0),
+ m_today(0),
+ m_yesterday(0),
+ m_thisWeek(0),
+ m_thisMonth(0),
+ m_thisYear(0),
+ m_anyRating(0),
+ m_oneOrMore(0),
+ m_twoOrMore(0),
+ m_threeOrMore(0),
+ m_fourOrMore(0),
+ m_maxRating(0)
+{
+ m_documents = new QCheckBox(i18nc("@option:check", "Documents"));
+ m_images = new QCheckBox(i18nc("@option:check", "Images"));
+ m_audio = new QCheckBox(i18nc("@option:check", "Audio"));
+ m_videos = new QCheckBox(i18nc("@option:check", "Videos"));
+
+ QVBoxLayout* typeLayout = new QVBoxLayout();
+ typeLayout->setSpacing(0);
+ typeLayout->addWidget(m_documents);
+ typeLayout->addWidget(m_images);
+ typeLayout->addWidget(m_audio);
+ typeLayout->addWidget(m_videos);
+ typeLayout->addStretch();
+
+ m_anytime = new QRadioButton(i18nc("@option:option", "Anytime"));
+ m_today = new QRadioButton(i18nc("@option:option", "Today"));
+ m_yesterday = new QRadioButton(i18nc("@option:option", "Yesterday"));
+ m_thisWeek = new QRadioButton(i18nc("@option:option", "This Week"));
+ m_thisMonth = new QRadioButton(i18nc("@option:option", "This Month"));
+ m_thisYear = new QRadioButton(i18nc("@option:option", "This Year"));
+
+ QVBoxLayout* timespanLayout = new QVBoxLayout();
+ timespanLayout->setSpacing(0);
+ timespanLayout->addWidget(m_anytime);
+ timespanLayout->addWidget(m_today);
+ timespanLayout->addWidget(m_yesterday);
+ timespanLayout->addWidget(m_thisWeek);
+ timespanLayout->addWidget(m_thisMonth);
+ timespanLayout->addWidget(m_thisYear);
+ timespanLayout->addStretch();
+
+ m_anyRating = new QRadioButton(i18nc("@option:option", "Any Rating"));
+ m_oneOrMore = new QRadioButton(i18nc("@option:option", "1 or more"));
+ m_twoOrMore = new QRadioButton(i18nc("@option:option", "2 or more"));
+ m_threeOrMore = new QRadioButton(i18nc("@option:option", "3 or more"));
+ m_fourOrMore = new QRadioButton(i18nc("@option:option", "4 or more"));
+ m_maxRating = new QRadioButton(i18nc("@option:option", "Maximum Rating"));
+
+ QVBoxLayout* ratingLayout = new QVBoxLayout();
+ ratingLayout->setSpacing(0);
+ ratingLayout->addWidget(m_anyRating);
+ ratingLayout->addWidget(m_oneOrMore);
+ ratingLayout->addWidget(m_twoOrMore);
+ ratingLayout->addWidget(m_threeOrMore);
+ ratingLayout->addWidget(m_fourOrMore);
+ ratingLayout->addWidget(m_maxRating);
+
+ QHBoxLayout* topLayout = new QHBoxLayout(this);
+ topLayout->addLayout(typeLayout);
+ topLayout->addLayout(timespanLayout);
+ topLayout->addLayout(ratingLayout);
+ topLayout->addStretch();
+
+ // TODO:
+ m_anytime->setChecked(true);
+ m_anyRating->setChecked(true);
+}
+
+DolphinFacetsWidget::~DolphinFacetsWidget()
+{
+}
+
+#include "dolphinfacetswidget.moc"
diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h
new file mode 100644
index 000000000..916e05608
--- /dev/null
+++ b/src/search/dolphinfacetswidget.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * Copyright (C) 2012 by Peter Penz <[email protected]> *
+ * *
+ * 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 DOLPHINFACETSWIDGET_H
+#define DOLPHINFACETSWIDGET_H
+
+#include <QWidget>
+
+class QCheckBox;
+class QRadioButton;
+
+/**
+ * @brief Allows to filter search-queries by facets.
+ *
+ * TODO: The current implementation is a temporary
+ * workaround for the 4.10 release and represents no
+ * real facets-implementation yet: There have been
+ * some Dolphin specific user-interface and interaction
+ * issues since 4.6 by embedding the Nepomuk facet-widget
+ * into a QDockWidget (this is unrelated to the
+ * Nepomuk facet-widget itself). Now in combination
+ * with the search-shortcuts in the Places Panel some
+ * existing issues turned into real showstoppers.
+ *
+ * So the longterm plan is to use the Nepomuk facets
+ * again as soon as possible.
+ */
+class DolphinFacetsWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DolphinFacetsWidget(QWidget* parent = 0);
+ virtual ~DolphinFacetsWidget();
+
+private:
+ QCheckBox* m_documents;
+ QCheckBox* m_images;
+ QCheckBox* m_audio;
+ QCheckBox* m_videos;
+
+ QRadioButton* m_anytime;
+ QRadioButton* m_today;
+ QRadioButton* m_yesterday;
+ QRadioButton* m_thisWeek;
+ QRadioButton* m_thisMonth;
+ QRadioButton* m_thisYear;
+
+ QRadioButton* m_anyRating;
+ QRadioButton* m_oneOrMore;
+ QRadioButton* m_twoOrMore;
+ QRadioButton* m_threeOrMore;
+ QRadioButton* m_fourOrMore;
+ QRadioButton* m_maxRating;
+};
+
+#endif
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index 06644e1f3..a9c960c24 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -20,6 +20,7 @@
#include "dolphinsearchbox.h"
#include "dolphin_searchsettings.h"
+#include "dolphinfacetswidget.h"
#include "dolphinsearchinformation.h"
#include <KIcon>
@@ -65,6 +66,8 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
m_separator(0),
m_fromHereButton(0),
m_everywhereButton(0),
+ m_facetsToggleButton(0),
+ m_facetsWidget(0),
m_searchPath(),
m_readOnlyQuery(),
m_startSearchTimer(0)
@@ -109,6 +112,10 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
m_separator->setVisible(showSearchFromButtons);
m_fromHereButton->setVisible(showSearchFromButtons);
m_everywhereButton->setVisible(showSearchFromButtons);
+
+ const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
+ const bool hasFacetsSupport = searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath);
+ m_facetsWidget->setEnabled(hasFacetsSupport);
}
KUrl DolphinSearchBox::searchPath() const
@@ -228,6 +235,14 @@ void DolphinSearchBox::slotReturnPressed(const QString& text)
emit returnPressed(text);
}
+void DolphinSearchBox::slotFacetsButtonToggled()
+{
+ const bool visible = !m_facetsWidget->isVisible();
+ m_facetsWidget->setVisible(visible);
+ SearchSettings::setShowFacetsWidget(visible);
+ updateFacetsToggleButtonIcon();
+}
+
void DolphinSearchBox::initButton(QToolButton* button)
{
button->setAutoExclusive(true);
@@ -249,6 +264,8 @@ void DolphinSearchBox::loadSettings()
} else {
m_fileNameButton->setChecked(true);
}
+
+ m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
}
void DolphinSearchBox::saveSettings()
@@ -319,6 +336,14 @@ void DolphinSearchBox::init()
connect(m_fromHereButton, SIGNAL(clicked()), this, SLOT(slotSearchLocationChanged()));
connect(m_everywhereButton, SIGNAL(clicked()), this, SLOT(slotSearchLocationChanged()));
+ // Create "Facets" widgets
+ m_facetsToggleButton = new QToolButton(this);
+ m_facetsToggleButton->setAutoRaise(true);
+ connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled()));
+
+ m_facetsWidget = new DolphinFacetsWidget(this);
+ m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
optionsLayout->setMargin(0);
@@ -328,6 +353,7 @@ void DolphinSearchBox::init()
optionsLayout->addWidget(m_fromHereButton);
optionsLayout->addWidget(m_everywhereButton);
optionsLayout->addStretch(1);
+ optionsLayout->addWidget(m_facetsToggleButton);
// Put the options into a QScrollArea. This prevents increasing the view width
// in case that not enough width for the options is available.
@@ -347,6 +373,7 @@ void DolphinSearchBox::init()
m_topLayout->setMargin(0);
m_topLayout->addLayout(searchInputLayout);
m_topLayout->addWidget(m_optionsScrollArea);
+ m_topLayout->addWidget(m_facetsWidget);
loadSettings();
@@ -357,6 +384,7 @@ void DolphinSearchBox::init()
m_startSearchTimer->setInterval(1000);
connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchSignal()));
+ updateFacetsToggleButtonIcon();
applyReadOnlyState();
}
@@ -413,6 +441,18 @@ void DolphinSearchBox::applyReadOnlyState()
m_searchInput->setVisible(!m_readOnly);
m_optionsScrollArea->setVisible(!m_readOnly);
+
+ if (m_readOnly) {
+ m_facetsWidget->hide();
+ } else {
+ m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
+ }
+}
+
+void DolphinSearchBox::updateFacetsToggleButtonIcon()
+{
+ const bool visible = SearchSettings::showFacetsWidget();
+ m_facetsToggleButton->setIcon(KIcon(visible ? "list-remove" : "list-add"));
}
#include "dolphinsearchbox.moc"
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index 8af32b377..2b4632bb1 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -24,10 +24,9 @@
#include <QList>
#include <QWidget>
-class AbstractSearchFilterWidget;
+class DolphinFacetsWidget;
class KLineEdit;
class KSeparator;
-class QFormLayout;
class QToolButton;
class QScrollArea;
class QLabel;
@@ -141,6 +140,7 @@ private slots:
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
void slotReturnPressed(const QString& text);
+ void slotFacetsButtonToggled();
private:
void initButton(QToolButton* button);
@@ -155,6 +155,8 @@ private:
void applyReadOnlyState();
+ void updateFacetsToggleButtonIcon();
+
private:
bool m_startedSearching;
bool m_readOnly;
@@ -169,6 +171,8 @@ private:
KSeparator* m_separator;
QToolButton* m_fromHereButton;
QToolButton* m_everywhereButton;
+ QToolButton* m_facetsToggleButton;
+ DolphinFacetsWidget* m_facetsWidget;
KUrl m_searchPath;
KUrl m_readOnlyQuery;