]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Rename the "Filter Panel" to "Search Panel"
authorPeter Penz <peter.penz19@gmail.com>
Wed, 9 Mar 2011 18:18:25 +0000 (19:18 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 9 Mar 2011 18:19:54 +0000 (19:19 +0100)
Bug reports indicate that users are confused by the term "filter" for this.

src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/panels/filter/filterpanel.cpp [deleted file]
src/panels/filter/filterpanel.h [deleted file]

index a06549593039bdb0e62ddf2d7fff9eb22e860a96..3700b36fe8377935e82bc2c265000d981e5a26c7 100644 (file)
@@ -151,7 +151,7 @@ kde4_add_kcfg_files(dolphin_SRCS
 if(Nepomuk_FOUND)
     set(dolphin_SRCS
         ${dolphin_SRCS}
-        panels/filter/filterpanel.cpp
+        panels/search/searchpanel.cpp
     )
 endif(Nepomuk_FOUND)
 
index e0f6019c001ae5185d9da10fa375bfbc671809ec..f9c9bf0df4fa311c65831cda7fc99183ff19672b 100644 (file)
@@ -30,7 +30,7 @@
 #include "dolphinviewcontainer.h"
 #include "mainwindowadaptor.h"
 #ifdef HAVE_NEPOMUK
-    #include "panels/filter/filterpanel.h"
+    #include "panels/search/searchpanel.h"
     #include <Nepomuk/ResourceManager>
 #endif
 #include "panels/folders/folderspanel.h"
@@ -121,7 +121,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_remoteEncoding(0),
     m_settingsDialog(0),
     m_lastHandleUrlStatJob(0),
-    m_filterDockIsTemporaryVisible(false)
+    m_searchDockIsTemporaryVisible(false)
 {
     // Workaround for a X11-issue in combination with KModifierInfo
     // (see DolphinContextMenu::initializeModifierKeyInfo() for
@@ -578,12 +578,12 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
 
     settings.save();
 
-    if (m_filterDockIsTemporaryVisible) {
-        QDockWidget* filterDock = findChild<QDockWidget*>("filterDock");
-        if (filterDock) {
-            filterDock->hide();
+    if (m_searchDockIsTemporaryVisible) {
+        QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
+        if (searchDock) {
+            searchDock->hide();
         }
-        m_filterDockIsTemporaryVisible = false;
+        m_searchDockIsTemporaryVisible = false;
     }
 
     KXmlGuiWindow::closeEvent(event);
@@ -1231,21 +1231,21 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled)
         return;
     }
 
-    QDockWidget* filterDock = findChild<QDockWidget*>("filterDock");
-    if (!filterDock) {
+    QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
+    if (!searchDock) {
         return;
     }
 
     if (enabled) {
-        if (!filterDock->isVisible()) {
-            m_filterDockIsTemporaryVisible = true;
+        if (!searchDock->isVisible()) {
+            m_searchDockIsTemporaryVisible = true;
         }
-        filterDock->show();
+        searchDock->show();
     } else {
-        if (filterDock->isVisible() && m_filterDockIsTemporaryVisible) {
-            filterDock->hide();
+        if (searchDock->isVisible() && m_searchDockIsTemporaryVisible) {
+            searchDock->hide();
         }
-        m_filterDockIsTemporaryVisible = false;
+        m_searchDockIsTemporaryVisible = false;
     }
 #else
     Q_UNUSED(enabled);
@@ -1662,24 +1662,24 @@ void DolphinMainWindow::setupDockWidgets()
             terminalPanel, SLOT(setUrl(KUrl)));
 #endif
 
-    // Setup "Filter"
+    // Setup "Search"
 #ifdef HAVE_NEPOMUK
-    DolphinDockWidget* filterDock = new DolphinDockWidget(i18nc("@title:window", "Filter"));
-    filterDock->setLocked(lock);
-    filterDock->setObjectName("filterDock");
-    filterDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-    Panel* filterPanel = new FilterPanel(filterDock);
-    filterPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
-    connect(filterPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
-    filterDock->setWidget(filterPanel);
-
-    QAction* filterAction = filterDock->toggleViewAction();
-    filterAction->setShortcut(Qt::Key_F12);
-    filterAction->setIcon(KIcon("view-filter"));
-    addActionCloneToCollection(filterAction, "show_filter_panel");
-    addDockWidget(Qt::RightDockWidgetArea, filterDock);
+    DolphinDockWidget* searchDock = new DolphinDockWidget(i18nc("@title:window", "Search"));
+    searchDock->setLocked(lock);
+    searchDock->setObjectName("searchDock");
+    searchDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+    Panel* searchPanel = new SearchPanel(searchDock);
+    searchPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    connect(searchPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
+    searchDock->setWidget(searchPanel);
+
+    QAction* searchAction = searchDock->toggleViewAction();
+    searchAction->setShortcut(Qt::Key_F12);
+    searchAction->setIcon(KIcon("system-search"));
+    addActionCloneToCollection(searchAction, "show_search_panel");
+    addDockWidget(Qt::RightDockWidgetArea, searchDock);
     connect(this, SIGNAL(urlChanged(KUrl)),
-            filterPanel, SLOT(setUrl(KUrl)));
+            searchPanel, SLOT(setUrl(KUrl)));
 #endif
 
     const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
@@ -1690,7 +1690,7 @@ void DolphinMainWindow::setupDockWidgets()
         terminalDock->hide();
 #endif
 #ifdef HAVE_NEPOMUK
-        filterDock->hide();
+        searchDock->hide();
 #endif
     }
 
@@ -1733,7 +1733,7 @@ void DolphinMainWindow::setupDockWidgets()
     panelsMenu->addAction(terminalAction);
 #endif
 #ifdef HAVE_NEPOMUK
-    panelsMenu->addAction(filterAction);
+    panelsMenu->addAction(searchAction);
 #endif
     panelsMenu->addSeparator();
     panelsMenu->addAction(lockLayoutAction);
index f4ccfdce492f35c91b4ff90f37ff0fb584eed424..10ebccb805e0548404d6ea1cd5d9b8f02b30d280 100644 (file)
@@ -553,7 +553,7 @@ private:
      * Set to true, if the filter dock visibility is only temporary set
      * to true by enabling the search mode.
      */
-    bool m_filterDockIsTemporaryVisible;
+    bool m_searchDockIsTemporaryVisible;
 };
 
 inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
diff --git a/src/panels/filter/filterpanel.cpp b/src/panels/filter/filterpanel.cpp
deleted file mode 100644 (file)
index e4d352b..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Sebastian Trueg <trueg@kde.org>                  *
- *                                                                         *
- *   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 "filterpanel.h"
-
-#include "dolphin_searchsettings.h"
-
-#include <Nepomuk/ResourceManager>
-#include <Nepomuk/Utils/FacetWidget>
-#include <Nepomuk/Utils/Facet>
-#include <Nepomuk/Utils/SimpleFacet>
-#include <Nepomuk/Utils/ProxyFacet>
-#include <Nepomuk/Utils/DynamicResourceFacet>
-#include <Nepomuk/Query/FileQuery>
-#include <Nepomuk/Query/ResourceTypeTerm>
-#include <Nepomuk/Query/LiteralTerm>
-#include <Nepomuk/Query/ComparisonTerm>
-#include <Nepomuk/Vocabulary/NFO>
-#include <Nepomuk/Vocabulary/NMM>
-#include <Nepomuk/Vocabulary/NIE>
-
-#include <search/dolphinsearchinformation.h>
-
-#include <KFileItem>
-#include <KIO/JobClasses>
-#include <KIO/Job>
-#include <KMenu>
-
-#include <QPushButton>
-#include <QShowEvent>
-#include <QTreeView>
-#include <QVBoxLayout>
-
-FilterPanel::FilterPanel(QWidget* parent) :
-    Panel(parent),
-    m_initialized(false),
-    m_lastSetUrlStatJob(0),
-    m_startedFromDir(),
-    m_facetWidget(0),
-    m_unfacetedRestQuery()
-{
-    setEnabled(false);
-}
-
-FilterPanel::~FilterPanel()
-{
-}
-
-bool FilterPanel::urlChanged()
-{
-    if (!url().protocol().startsWith(QLatin1String("nepomuk"))) {
-        // Remember the current directory before a searching is started.
-        // This is required to restore the directory in case that all facets
-        // have been reset by the user (see slotQueryTermChanged()).
-        m_startedFromDir = url();
-    }
-
-    if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) {
-        setQuery(Nepomuk::Query::Query());
-
-        delete m_lastSetUrlStatJob;
-
-        m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
-        connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)),
-                this, SLOT(slotSetUrlStatFinished(KJob*)));
-    }
-
-    return true;
-}
-
-void FilterPanel::showEvent(QShowEvent* event)
-{
-    if (event->spontaneous()) {
-        Panel::showEvent(event);
-        return;
-    }
-
-    if (!m_initialized) {
-        QVBoxLayout* layout = new QVBoxLayout(this);
-        layout->setMargin(0);
-
-        Q_ASSERT(!m_facetWidget);
-        m_facetWidget = new Nepomuk::Utils::FacetWidget(this);
-        layout->addWidget(m_facetWidget, 1);
-
-        // File Type
-        m_facetWidget->addFacet(Nepomuk::Utils::Facet::createFileTypeFacet());
-
-        // Image Size
-        Nepomuk::Utils::ProxyFacet* imageSizeProxy = new Nepomuk::Utils::ProxyFacet();
-        imageSizeProxy->setFacetCondition(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image()));
-        Nepomuk::Utils::SimpleFacet* imageSizeFacet = new Nepomuk::Utils::SimpleFacet(imageSizeProxy);
-        imageSizeFacet->setSelectionMode(Nepomuk::Utils::Facet::MatchAny);
-        imageSizeFacet->addTerm( i18nc("option:check Refers to a filter on image size", "Small"),
-                                Nepomuk::Vocabulary::NFO::width() <= Nepomuk::Query::LiteralTerm(300));
-        imageSizeFacet->addTerm( i18nc("option:check Refers to a filter on image size", "Medium"),
-                                (Nepomuk::Vocabulary::NFO::width() > Nepomuk::Query::LiteralTerm(300)) &&
-                                (Nepomuk::Vocabulary::NFO::width() <= Nepomuk::Query::LiteralTerm(800)));
-        imageSizeFacet->addTerm( i18nc("option:check Refers to a filter on image size", "Large"),
-                                Nepomuk::Vocabulary::NFO::width() > Nepomuk::Query::LiteralTerm(800));
-        imageSizeProxy->setSourceFacet(imageSizeFacet);
-        m_facetWidget->addFacet(imageSizeProxy);
-
-        // Artists
-        Nepomuk::Utils::ProxyFacet* artistProxy = new Nepomuk::Utils::ProxyFacet();
-        artistProxy->setFacetCondition(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Audio()) ||
-                                       Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
-                                                                      Nepomuk::Query::LiteralTerm(QLatin1String("audio"))));
-        Nepomuk::Utils::DynamicResourceFacet* artistFacet = new Nepomuk::Utils::DynamicResourceFacet(artistProxy);
-        artistFacet->setSelectionMode(Nepomuk::Utils::Facet::MatchAny);
-        artistFacet->setRelation(Nepomuk::Vocabulary::NMM::performer());
-        artistProxy->setSourceFacet(artistFacet);
-        m_facetWidget->addFacet(artistProxy);
-
-        // Misc
-        m_facetWidget->addFacet(Nepomuk::Utils::Facet::createDateFacet());
-        m_facetWidget->addFacet(Nepomuk::Utils::Facet::createRatingFacet());
-        m_facetWidget->addFacet(Nepomuk::Utils::Facet::createTagFacet());
-
-        Q_ASSERT(!m_lastSetUrlStatJob);
-        m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
-        connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)),
-                this, SLOT(slotSetUrlStatFinished(KJob*)));
-
-        connect(m_facetWidget, SIGNAL(queryTermChanged(Nepomuk::Query::Term)),
-                this, SLOT(slotQueryTermChanged(Nepomuk::Query::Term)));
-
-        m_initialized = true;
-    }
-
-    const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
-    setEnabled(searchInfo.isIndexingEnabled() &&
-               searchInfo.isPathIndexed(m_startedFromDir));
-
-    Panel::showEvent(event);
-}
-
-void FilterPanel::hideEvent(QHideEvent* event)
-{
-    if (!event->spontaneous()) {
-        setEnabled(false);
-    }
-
-    Panel::hideEvent(event);
-}
-
-void FilterPanel::contextMenuEvent(QContextMenuEvent* event)
-{
-    Panel::contextMenuEvent(event);
-
-    QWeakPointer<KMenu> popup = new KMenu(this);
-    foreach (QAction* action, customContextMenuActions()) {
-        popup.data()->addAction(action);
-    }
-    popup.data()->exec(QCursor::pos());
-    delete popup.data();
-}
-
-void FilterPanel::slotSetUrlStatFinished(KJob* job)
-{
-    m_lastSetUrlStatJob = 0;
-
-    const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
-    const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY);
-    Nepomuk::Query::FileQuery nepomukQuery;
-    if (!nepomukQueryStr.isEmpty()) {
-        nepomukQuery = Nepomuk::Query::Query::fromString(nepomukQueryStr);
-    } else if (url().isLocalFile()) {
-        // Fallback query for local file URLs: List all files
-        Nepomuk::Query::ComparisonTerm compTerm(
-                                Nepomuk::Vocabulary::NFO::fileName(),
-                                Nepomuk::Query::Term());
-        nepomukQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFiles);
-        if (SearchSettings::location() == QLatin1String("FromHere")) {
-            nepomukQuery.addIncludeFolder(url(), true);
-        }
-        nepomukQuery.setTerm(compTerm);
-    }
-    setQuery(nepomukQuery);
-}
-
-void FilterPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
-{
-    if (term.isValid()) {
-        // Default case: A facet has been changed by the user to restrict the query.
-        Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && term);
-        emit urlActivated(query.toSearchUrl());
-        return;
-    }
-
-    // All facets have been reset by the user to be unrestricted.
-    // Verify whether the unfaceted rest query contains any additional restriction
-    // (e.g. a filename in the search field). If no further restriction is given, exit
-    // the search mode by returning to the directory where the searching has been
-    // started from.
-    const Nepomuk::Query::Term rootTerm = m_unfacetedRestQuery.term();
-    if (rootTerm.type() == Nepomuk::Query::Term::Comparison) {
-        const Nepomuk::Query::ComparisonTerm& compTerm = static_cast<const Nepomuk::Query::ComparisonTerm&>(rootTerm);
-        if (compTerm.subTerm().isValid()) {
-            Nepomuk::Query::FileQuery query(m_unfacetedRestQuery);
-            emit urlActivated(query.toSearchUrl());
-            return;
-        }
-    }
-
-    emit urlActivated(m_startedFromDir);
-}
-
-void FilterPanel::setQuery(const Nepomuk::Query::Query& query)
-{
-    if (query.isValid()) {
-        const bool block = m_facetWidget->blockSignals(true);
-
-        m_unfacetedRestQuery = m_facetWidget->extractFacetsFromQuery(query);
-        m_facetWidget->setClientQuery(query);
-
-        const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
-        setEnabled(searchInfo.isIndexingEnabled() &&
-                   searchInfo.isPathIndexed(m_startedFromDir));
-
-        m_facetWidget->blockSignals(block);
-    } else {
-        m_unfacetedRestQuery = Nepomuk::Query::Query();
-        setEnabled(false);
-    }
-}
diff --git a/src/panels/filter/filterpanel.h b/src/panels/filter/filterpanel.h
deleted file mode 100644 (file)
index 33c18c0..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Sebastian Trueg <trueg@kde.org>                  *
- *                                                                         *
- *   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 FILTERPANEL_H
-#define FILTERPANEL_H
-
-#include <Nepomuk/Query/Query>
-#include <panels/panel.h>
-
-class KJob;
-
-namespace Nepomuk {
-    namespace Utils {
-        class FacetWidget;
-    }
-}
-
-/**
- * @brief Allows the filtering of search results.
- */
-class FilterPanel : public Panel
-{
-    Q_OBJECT
-
-public:
-    FilterPanel(QWidget* parent = 0);
-    virtual ~FilterPanel();
-
-signals:
-    void urlActivated(const KUrl& url);
-
-protected:
-    /** @see Panel::urlChanged() */
-    virtual bool urlChanged();
-
-    /** @see QWidget::showEvent() */
-    virtual void showEvent(QShowEvent* event);
-
-    /** @see QWidget::hideEvent() */
-    virtual void hideEvent(QHideEvent* event);
-
-    /** @see QWidget::contextMenuEvent() */
-    virtual void contextMenuEvent(QContextMenuEvent* event);
-
-private slots:
-    void slotSetUrlStatFinished(KJob*);
-    void slotQueryTermChanged(const Nepomuk::Query::Term& term);
-
-private:
-    void setQuery(const Nepomuk::Query::Query& query);
-
-private:
-    bool m_initialized;
-    KJob* m_lastSetUrlStatJob;
-
-    KUrl m_startedFromDir;
-    Nepomuk::Utils::FacetWidget* m_facetWidget;
-    Nepomuk::Query::Query m_unfacetedRestQuery;
-};
-
-#endif // FILTERPANEL_H