]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinsearchbox.cpp
Merge remote-tracking branch 'origin/KDE/4.9'
[dolphin.git] / src / search / dolphinsearchbox.cpp
index 28f1f1af56329f4b8c3cd872b90d660d0c2a4801..8b660712a1abff9545499a6164892d62e734f41e 100644 (file)
 
 #include <config-nepomuk.h>
 #ifdef HAVE_NEPOMUK
-    #include <Nepomuk/Query/AndTerm>
-    #include <Nepomuk/Query/FileQuery>
-    #include <Nepomuk/Query/LiteralTerm>
-    #include <Nepomuk/Query/OrTerm>
-    #include <Nepomuk/Query/Query>
-    #include <Nepomuk/Query/QueryParser>
-    #include <Nepomuk/Query/ResourceTypeTerm>
-    #include <Nepomuk/Query/ComparisonTerm>
-    #include <Nepomuk/ResourceManager>
-    #include <Nepomuk/Vocabulary/NFO>
+    #include <Nepomuk2/Query/AndTerm>
+    #include <Nepomuk2/Query/FileQuery>
+    #include <Nepomuk2/Query/LiteralTerm>
+    #include <Nepomuk2/Query/OrTerm>
+    #include <Nepomuk2/Query/Query>
+    #include <Nepomuk2/Query/QueryParser>
+    #include <Nepomuk2/Query/ResourceTypeTerm>
+    #include <Nepomuk2/Query/ComparisonTerm>
+    #include <Nepomuk2/ResourceManager>
+    #include <Nepomuk2/Vocabulary/NFO>
 #endif
 
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
@@ -239,10 +239,9 @@ void DolphinSearchBox::slotReturnPressed(const QString& text)
 
 void DolphinSearchBox::slotFacetsButtonToggled()
 {
-    const bool visible = !m_facetsWidget->isVisible();
-    m_facetsWidget->setVisible(visible);
-    SearchSettings::setShowFacetsWidget(visible);
-    updateFacetsToggleButtonIcon();
+    const bool facetsIsVisible = !m_facetsWidget->isVisible();
+    m_facetsWidget->setVisible(facetsIsVisible);
+    updateFacetsToggleButton();
 }
 
 void DolphinSearchBox::slotFacetChanged()
@@ -281,6 +280,7 @@ void DolphinSearchBox::saveSettings()
 {
     SearchSettings::setLocation(m_fromHereButton->isChecked() ? "FromHere" : "Everywhere");
     SearchSettings::setWhat(m_fileNameButton->isChecked() ? "FileName" : "Content");
+    SearchSettings::setShowFacetsWidget(m_facetsToggleButton->isChecked());
     SearchSettings::self()->writeConfig();
 }
 
@@ -343,7 +343,8 @@ void DolphinSearchBox::init()
 
     // Create "Facets" widgets
     m_facetsToggleButton = new QToolButton(this);
-    m_facetsToggleButton->setAutoRaise(true);
+    m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+    initButton(m_facetsToggleButton);
     connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled()));
 
     m_facetsWidget = new DolphinFacetsWidget(this);
@@ -390,7 +391,7 @@ void DolphinSearchBox::init()
     m_startSearchTimer->setInterval(1000);
     connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest()));
 
-    updateFacetsToggleButtonIcon();
+    updateFacetsToggleButton();
     applyReadOnlyState();
 }
 
@@ -401,30 +402,30 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
     // dependent on whether a searching for content or
     // filename is done
     const QString text = m_searchInput->text();
-    Nepomuk::Query::Term searchLabelTerm;
+    Nepomuk2::Query::Term searchLabelTerm;
     if (m_contentButton->isChecked()) {
         // Let Nepomuk parse the query
-        searchLabelTerm = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern).term();
+        searchLabelTerm = Nepomuk2::Query::QueryParser::parseQuery(text, Nepomuk2::Query::QueryParser::DetectFilenamePattern).term();
     } else {
         // Search the text in the filename only
         QString regex = QRegExp::escape(text);
         regex.replace("\\*", QLatin1String(".*"));
         regex.replace("\\?", QLatin1String("."));
         regex.replace("\\", "\\\\");
-        searchLabelTerm = Nepomuk::Query::ComparisonTerm(
-                                Nepomuk::Vocabulary::NFO::fileName(),
-                                Nepomuk::Query::LiteralTerm(regex),
-                                Nepomuk::Query::ComparisonTerm::Regexp);
+        searchLabelTerm = Nepomuk2::Query::ComparisonTerm(
+                                Nepomuk2::Vocabulary::NFO::fileName(),
+                                Nepomuk2::Query::LiteralTerm(regex),
+                                Nepomuk2::Query::ComparisonTerm::Regexp);
     }
 
     // Get the term from the facets and merge it with the
     // created term from the input-field.
-    Nepomuk::Query::Term facetsTerm = m_facetsWidget->facetsTerm();
+    Nepomuk2::Query::Term facetsTerm = m_facetsWidget->facetsTerm();
 
-    Nepomuk::Query::FileQuery fileQuery;
-    fileQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFilesAndFolders);
+    Nepomuk2::Query::FileQuery fileQuery;
+    fileQuery.setFileMode(Nepomuk2::Query::FileQuery::QueryFilesAndFolders);
     if (facetsTerm.isValid()) {
-        Nepomuk::Query::AndTerm andTerm;
+        Nepomuk2::Query::AndTerm andTerm;
         andTerm.addSubTerm(searchLabelTerm);
         andTerm.addSubTerm(facetsTerm);
         fileQuery.setTerm(andTerm);
@@ -449,7 +450,7 @@ void DolphinSearchBox::applyReadOnlyState()
 {
 #ifdef HAVE_NEPOMUK
     if (m_readOnly) {
-        m_searchLabel->setText(Nepomuk::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
+        m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
     } else {
 #else
     {
@@ -467,10 +468,12 @@ void DolphinSearchBox::applyReadOnlyState()
     }
 }
 
-void DolphinSearchBox::updateFacetsToggleButtonIcon()
+void DolphinSearchBox::updateFacetsToggleButton()
 {
-    const bool visible = SearchSettings::showFacetsWidget();
-    m_facetsToggleButton->setIcon(KIcon(visible ? "list-remove" : "list-add"));
+    const bool facetsIsVisible = SearchSettings::showFacetsWidget();
+    m_facetsToggleButton->setChecked(facetsIsVisible ? true : false);
+    m_facetsToggleButton->setIcon(KIcon(facetsIsVisible ? "arrow-up-double" : "arrow-down-double"));
+    m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Less Options") : i18nc("action:button", "More Options"));
 }
 
 #include "dolphinsearchbox.moc"