]> cloud.milkyroute.net Git - dolphin.git/commitdiff
- Automatically show the filter-panel when a searching is done
authorPeter Penz <peter.penz19@gmail.com>
Wed, 27 Oct 2010 17:08:02 +0000 (17:08 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 27 Oct 2010 17:08:02 +0000 (17:08 +0000)
- Remove filter-prototypes that conflict with the filterpanel

svn path=/trunk/KDE/kdebase/apps/; revision=1190445

17 files changed:
src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/panels/filter/filterpanel.cpp
src/panels/filter/filterpanel.h
src/search/dolphinsearchbox.cpp
src/search/dolphinsearchbox.h
src/search/filters/abstractsearchfilterwidget.cpp [deleted file]
src/search/filters/abstractsearchfilterwidget.h [deleted file]
src/search/filters/datesearchfilterwidget.cpp [deleted file]
src/search/filters/datesearchfilterwidget.h [deleted file]
src/search/filters/ratingsearchfilterwidget.cpp [deleted file]
src/search/filters/ratingsearchfilterwidget.h [deleted file]
src/search/filters/tagsearchfilterwidget.cpp [deleted file]
src/search/filters/tagsearchfilterwidget.h [deleted file]

index 1fe94261c0a24ff70cf20b3dc4d74c5664ded2c7..86d46bd56dec719241181dbdd141d47e1d245f29 100644 (file)
@@ -149,10 +149,6 @@ if(Nepomuk_FOUND)
     set(dolphin_SRCS
         ${dolphin_SRCS}
         panels/filter/filterpanel.cpp
-        search/filters/abstractsearchfilterwidget.cpp
-        search/filters/datesearchfilterwidget.cpp
-        search/filters/ratingsearchfilterwidget.cpp
-        search/filters/tagsearchfilterwidget.cpp
     )
     include(SopranoAddOntology)
     soprano_add_ontology(dolphin_SRCS ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nfo.trig "NFO" "Nepomuk::Vocabulary" "trig")
index e44495015c8716f26f4b03308925d36efbbb0a2a..3c6d4c722b4f21b3331d4b5f20a7363cce0b22d9 100644 (file)
@@ -116,7 +116,8 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_actionHandler(0),
     m_remoteEncoding(0),
     m_settingsDialog(0),
-    m_lastHandleUrlStatJob(0)
+    m_lastHandleUrlStatJob(0),
+    m_filterDockIsTemporaryVisible(false)
 {
     // Workaround for a X11-issue in combination with KModifierInfo
     // (see DolphinContextMenu::initializeModifierKeyInfo() for
@@ -571,6 +572,14 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
 
     settings.save();
 
+    if (m_filterDockIsTemporaryVisible) {
+        QDockWidget* filterDock = findChild<QDockWidget*>("filterDock");
+        if (filterDock != 0) {
+            filterDock->hide();
+        }
+        m_filterDockIsTemporaryVisible = false;
+    }
+
     KXmlGuiWindow::closeEvent(event);
 }
 
@@ -1191,6 +1200,26 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
     newFileMenu()->setEnabled(isFolderWritable);
 }
 
+void DolphinMainWindow::slotSearchModeChanged(bool enabled)
+{
+    QDockWidget* filterDock = findChild<QDockWidget*>("filterDock");
+    if (filterDock == 0) {
+        return;
+    }
+
+    if (enabled) {
+        if (!filterDock->isVisible()) {
+            m_filterDockIsTemporaryVisible = true;
+        }
+        filterDock->show();
+    } else {
+        if (filterDock->isVisible() && m_filterDockIsTemporaryVisible) {
+            filterDock->hide();
+        }
+        m_filterDockIsTemporaryVisible = false;
+    }
+}
+
 void DolphinMainWindow::openContextMenu(const KFileItem& item,
                                         const KUrl& url,
                                         const QList<QAction*>& customActions)
@@ -1603,6 +1632,9 @@ void DolphinMainWindow::setupDockWidgets()
     if (firstRun) {
         infoDock->hide();
         foldersDock->hide();
+#ifdef HAVE_NEPOMUK
+        filterDock->hide();
+#endif
 #ifndef Q_OS_WIN
         terminalDock->hide();
 #endif
@@ -1739,6 +1771,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
             this, SLOT(updateFilterBarAction(bool)));
     connect(container, SIGNAL(writeStateChanged(bool)),
             this, SLOT(slotWriteStateChanged(bool)));
+    connect(container, SIGNAL(searchModeChanged(bool)),
+            this, SLOT(slotSearchModeChanged(bool)));
 
     DolphinView* view = container->view();
     connect(view, SIGNAL(selectionChanged(KFileItemList)),
index 667e3c931408bf25ef03dfd5585c3f0a08d1a88e..4a747ac5aa6a28a030af0e7013b6fc095a987ea7 100644 (file)
@@ -431,6 +431,8 @@ private slots:
      */
     void slotWriteStateChanged(bool isFolderWritable);
 
+    void slotSearchModeChanged(bool enabled);
+
     /**
      * Opens the context menu on the current mouse position.
      * @item          File item context. If item is null, the context menu
@@ -543,6 +545,12 @@ private:
     QPointer<DolphinSettingsDialog> m_settingsDialog;
 
     KJob* m_lastHandleUrlStatJob;
+
+    /**
+     * Set to true, if the filter dock visibility is only temporary set
+     * to true by enabling the search mode.
+     */
+    bool m_filterDockIsTemporaryVisible;
 };
 
 inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
index da7466947ce2966a3a4c0221e9648329dc814dc1..c19d074c685b804abf8cdcb784587509e307b1c8 100644 (file)
@@ -230,6 +230,10 @@ bool DolphinViewContainer::isFilterBarVisible() const
 
 void DolphinViewContainer::setSearchModeEnabled(bool enabled)
 {
+    if (enabled == isSearchModeEnabled()) {
+        return;
+    }
+
     m_searchBox->setVisible(enabled);
     m_urlNavigator->setVisible(!enabled);
 
@@ -250,6 +254,8 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
             }
         }
     }
+
+    emit searchModeChanged(enabled);
 }
 
 bool DolphinViewContainer::isSearchModeEnabled() const
@@ -435,10 +441,12 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
             if (!m_searchBox->isVisible()) {
                 m_searchBox->setVisible(true);
                 m_urlNavigator->setVisible(false);
+                emit searchModeChanged(true);
             }
         } else if (!m_urlNavigator->isVisible()) {
             m_urlNavigator->setVisible(true);
             m_searchBox->setVisible(false);
+            emit searchModeChanged(false);
         }
 
         m_view->setUrl(url);
index aa43e8e66052818b63a3bbcf4ba38d47546b5e38..a34ac19764bed17b2768326db352399a853c9460 100644 (file)
@@ -127,6 +127,13 @@ signals:
      */
     void writeStateChanged(bool isFolderWritable);
 
+    /**
+     * Is emitted if the search mode has been enabled or disabled.
+     * (see DolphinViewContainer::setSearchModeEnabled() and
+     * DolphinViewContainer::isSearchModeEnabled())
+     */
+    void searchModeChanged(bool enabled);
+
 private slots:
     /**
      * Updates the number of items (= number of files + number of
index 4410a54567c3a0d1eecab9a9f882a2bddd86bec4..44cac7ecf870cbd5739735e10333e4af28be144e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <nepomuk/filequery.h>
 #include <nepomuk/facetwidget.h>
+#include <nepomuk/facet.h>
 #include <Nepomuk/Query/FileQuery>
 #include <Nepomuk/Query/Term>
 
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QTreeView>
 #include <QtGui/QPushButton>
-#include <kdebug.h>
 
-
-FilterPanel::FilterPanel(QWidget* parent)
-    : Panel(parent)
+FilterPanel::FilterPanel(QWidget* parent) :
+    Panel(parent)
 {
     QVBoxLayout* layout = new QVBoxLayout(this);
-    m_buttonRemoveFolderRestriction = new QPushButton( i18n( "Remove folder restriction" ), this );
-    connect( m_buttonRemoveFolderRestriction, SIGNAL( clicked() ), SLOT( slotRemoveFolderRestrictionClicked() ) );
+    m_removeFolderRestrictionButton = new QPushButton(i18n("Remove folder restriction"), this);
+    connect(m_removeFolderRestrictionButton, SIGNAL(clicked()), SLOT(slotRemoveFolderRestrictionClicked()));
+
+    layout->addWidget(m_removeFolderRestrictionButton);
 
-    layout->addWidget(m_buttonRemoveFolderRestriction);
+    m_facetWidget = new Nepomuk::Utils::FacetWidget(this);
+    layout->addWidget(m_facetWidget, 1);
+    connect(m_facetWidget, SIGNAL(facetsChanged()), this, SLOT(slotFacetsChanged()));
 
-    m_facetWidget = new Nepomuk::Utils::FacetWidget( this );
-    layout->addWidget( m_facetWidget, 1 );
-    connect(m_facetWidget, SIGNAL(facetsChanged()), this, SLOT(slotFacetsChanged()) );
+    /*m_facetWidget->addFacet(Nepomuk::Utils::Facet::createFileTypeFacet());
+    m_facetWidget->addFacet(Nepomuk::Utils::Facet::createTypeFacet());
+    m_facetWidget->addFacet(Nepomuk::Utils::Facet::createDateFacet());
+    m_facetWidget->addFacet(Nepomuk::Utils::Facet::createPriorityFacet());
+    m_facetWidget->addFacet(Nepomuk::Utils::Facet::createRatingFacet());*/
 
-    // init to empty panel
+    // Init to empty panel
     setQuery(Nepomuk::Query::Query());
 }
 
-
 FilterPanel::~FilterPanel()
 {
 }
 
-void FilterPanel::setUrl(const KUrl& url)
+bool FilterPanel::urlChanged()
 {
-    kDebug() << url;
-    Panel::setUrl(url);
+    if (!isVisible()) {
+        return true;
+    }
 
-    // disable us
+    // Disable us
     setQuery(Nepomuk::Query::Query());
 
-    // get the query from the item
-    m_lastSetUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
+    // Get the query from the item
+    m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
     connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)),
             this, SLOT(slotSetUrlStatFinished(KJob*)));
-}
-
-
-void FilterPanel::setQuery(const Nepomuk::Query::Query& query)
-{
-    kDebug() << query << query.isValid() << query.toSparqlQuery();
 
-    if (query.isValid()) {
-        m_buttonRemoveFolderRestriction->setVisible( query.isFileQuery() && !query.toFileQuery().includeFolders().isEmpty() );
-        m_unfacetedRestQuery = query;
-        m_unfacetedRestQuery.setTerm( m_facetWidget->extractFacetsFromTerm( query.term() ) );
-        m_facetWidget->setClientQuery( query );
-        kDebug() << "Rest query after facets:" << m_unfacetedRestQuery;
-        setEnabled(true);
-    }
-    else {
-        m_unfacetedRestQuery = Nepomuk::Query::Query();
-        setEnabled(false);
-    }
+    return true;
 }
 
-
 void FilterPanel::slotSetUrlStatFinished(KJob* job)
 {
     m_lastSetUrlStatJob = 0;
-    kDebug() << url();
     const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
-    const QString nepomukQueryStr = uds.stringValue( KIO::UDSEntry::UDS_NEPOMUK_QUERY );
-    kDebug() << nepomukQueryStr;
+    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
+    if (!nepomukQueryStr.isEmpty()) {
+        nepomukQuery = Nepomuk::Query::Query::fromString(nepomukQueryStr);
+    } else if (url().isLocalFile()) {
+        // Fallback query for local file URLs
         nepomukQuery.addIncludeFolder(url(), false);
     }
-    kDebug() << nepomukQuery;
     setQuery(nepomukQuery);
 }
 
-
 void FilterPanel::slotFacetsChanged()
 {
-    Nepomuk::Query::Query query( m_unfacetedRestQuery && m_facetWidget->queryTerm() );
-    kDebug() << query;
-    emit urlActivated( query.toSearchUrl() );
+    Nepomuk::Query::Query query(m_unfacetedRestQuery && m_facetWidget->queryTerm());
+    emit urlActivated(query.toSearchUrl());
 }
 
-
 void FilterPanel::slotRemoveFolderRestrictionClicked()
 {
-    Nepomuk::Query::FileQuery query( m_unfacetedRestQuery && m_facetWidget->queryTerm() );
-    query.setIncludeFolders( KUrl::List() );
-    query.setExcludeFolders( KUrl::List() );
-    m_facetWidget->setClientQuery( query );
-    emit urlActivated( query.toSearchUrl() );
+    Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && m_facetWidget->queryTerm());
+    query.setIncludeFolders(KUrl::List());
+    query.setExcludeFolders(KUrl::List());
+    m_facetWidget->setClientQuery(query);
+    emit urlActivated(query.toSearchUrl());
+}
+
+void FilterPanel::setQuery(const Nepomuk::Query::Query& query)
+{
+    if (query.isValid()) {
+        m_removeFolderRestrictionButton->setVisible(query.isFileQuery() && !query.toFileQuery().includeFolders().isEmpty());
+        m_unfacetedRestQuery = query;
+        m_unfacetedRestQuery.setTerm(m_facetWidget->extractFacetsFromTerm(query.term()));
+        m_facetWidget->setClientQuery(query);
+        setEnabled(true);
+    }
+    else {
+        m_unfacetedRestQuery = Nepomuk::Query::Query();
+        setEnabled(false);
+    }
 }
index d42c2f0bd2520c95ef87831bbbb9b89a78b55579..9269bd21ac5b95688b6cca9e879a847dd0a52de4 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef FILTERPANEL_H
 #define FILTERPANEL_H
 
-#include "../panel.h"
 #include <nepomuk/query.h>
+#include <panels/panel.h>
 
 class KJob;
 class QPushButton;
@@ -32,20 +32,23 @@ namespace Nepomuk {
     }
 }
 
+/**
+ * @brief Allows the filtering of search results.
+ */
 class FilterPanel : public Panel
 {
     Q_OBJECT
 
 public:
     FilterPanel(QWidget* parent = 0);
-    ~FilterPanel();
-
-public slots:
-    void setUrl(const KUrl& url);
-    void setQuery(const Nepomuk::Query::Query& query);
+    virtual ~FilterPanel();
 
 signals:
-    void urlActivated( const KUrl& url );
+    void urlActivated(const KUrl& url);
+
+protected:
+    /** @see Panel::urlChanged() */
+    virtual bool urlChanged();
 
 private slots:
     void slotSetUrlStatFinished(KJob*);
@@ -53,13 +56,12 @@ private slots:
     void slotRemoveFolderRestrictionClicked();
 
 private:
-    bool urlChanged() {
-        return true;
-    }
+    void setQuery(const Nepomuk::Query::Query& query);
 
+private:
     KJob* m_lastSetUrlStatJob;
 
-    QPushButton* m_buttonRemoveFolderRestriction;
+    QPushButton* m_removeFolderRestrictionButton;
     Nepomuk::Utils::FacetWidget* m_facetWidget;
     Nepomuk::Query::Query m_unfacetedRestQuery;
 };
index 54f3d098595260d52647f4757de32b338db9218b..d41aba605932eac4c7473fdac8d193224cb1114b 100644 (file)
     #include <nepomuk/resourcetypeterm.h>
     #include <nepomuk/comparisonterm.h>
     #include "nfo.h"
-
-    #include "filters/datesearchfilterwidget.h"
-    #include "filters/ratingsearchfilterwidget.h"
-    #include "filters/tagsearchfilterwidget.h"
 #endif
 
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
@@ -66,8 +62,6 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     m_fileNameButton(0),
     m_contentButton(0),
     m_filterButton(0),
-    m_filterWidgetsLayout(0),
-    m_filterWidgets(),
     m_searchPath(),
     m_startSearchTimer(0)
 {
@@ -184,34 +178,6 @@ void DolphinSearchBox::slotReturnPressed(const QString& text)
     emit returnPressed(text);
 }
 
-void DolphinSearchBox::setFilterWidgetsVisible(bool visible)
-{
-#ifdef HAVE_NEPOMUK
-    if (visible) {
-        if (m_filterWidgetsLayout == 0) {
-            m_filterWidgetsLayout = new QFormLayout(this);
-            m_filterWidgetsLayout->setSpacing(0);
-
-            m_filterWidgets.append(new DateSearchFilterWidget(this));
-            m_filterWidgets.append(new RatingSearchFilterWidget(this));
-            m_filterWidgets.append(new TagSearchFilterWidget(this));
-
-            foreach (AbstractSearchFilterWidget* filterWidget, m_filterWidgets) {
-                const QString labelText = filterWidget->filterLabel() + QLatin1Char(':');
-                QLabel* label = new QLabel(labelText, this);
-                m_filterWidgetsLayout->addRow(label, filterWidget);
-                connect(filterWidget, SIGNAL(filterChanged()), this, SLOT(emitSearchSignal()));
-            }
-        }
-        m_topLayout->addLayout(m_filterWidgetsLayout);
-    } else {
-        m_topLayout->removeItem(m_filterWidgetsLayout);
-    }
-#else
-    Q_UNUSED(visible);
-#endif
-}
-
 void DolphinSearchBox::initButton(QPushButton* button)
 {
     button->setAutoExclusive(true);
@@ -302,7 +268,7 @@ void DolphinSearchBox::init()
     m_filterButton->setAutoRaise(true);
     m_filterButton->setCheckable(true);
     m_filterButton->hide();
-    connect(m_filterButton, SIGNAL(toggled(bool)), this, SLOT(setFilterWidgetsVisible(bool)));
+    //connect(m_filterButton, SIGNAL(toggled(bool)), this, SLOT(setFilterWidgetsVisible(bool)));
 
     // Apply layout for the options
     QHBoxLayout* optionsLayout = new QHBoxLayout();
@@ -332,7 +298,6 @@ void DolphinSearchBox::init()
 
 bool DolphinSearchBox::isSearchPathIndexed() const
 {
-    return true;
 #ifdef HAVE_NEPOMUK
     const QString path = m_searchPath.path();
 
@@ -353,7 +318,6 @@ bool DolphinSearchBox::isSearchPathIndexed() const
         // excluded folder is part of the search path.
         const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList());
         foreach (const QString& excludedFolder, excludedFolders) {
-            // trueg: this is still not correct since there might be an include folder in the exclude folder
             if (path.startsWith(excludedFolder)) {
                 isIndexed = false;
                 break;
@@ -372,30 +336,19 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
 #ifdef HAVE_NEPOMUK
     Nepomuk::Query::AndTerm andTerm;
 
-    // Add filter terms
-    foreach (const AbstractSearchFilterWidget* filterWidget, m_filterWidgets) {
-        const Nepomuk::Query::Term term = filterWidget->queryTerm();
-        if (term.isValid()) {
-            andTerm.addSubTerm(term);
-        }
-    }
-
     // Add input from search filter
     const QString text = m_searchInput->text();
     if (!text.isEmpty()) {
-        if ( m_fileNameButton->isChecked() ) {
+        if (m_fileNameButton->isChecked()) {
             QString regex = QRegExp::escape(text);
-            regex.replace("\\*", QLatin1String( ".*" ));
-            regex.replace("\\?", QLatin1String( "." ));
+            regex.replace("\\*", QLatin1String(".*"));
+            regex.replace("\\?", QLatin1String("."));
             regex.replace("\\", "\\\\");
-            regex.prepend('^');
-            regex.append('$');
-            andTerm.addSubTerm( Nepomuk::Query::ComparisonTerm(
+            andTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(
                                     Nepomuk::Vocabulary::NFO::fileName(),
-                                    Nepomuk::Query::LiteralTerm( regex ),
-                                    Nepomuk::Query::ComparisonTerm::Regexp ) );
-        }
-        else {
+                                    Nepomuk::Query::LiteralTerm(regex),
+                                    Nepomuk::Query::ComparisonTerm::Regexp));
+        } else {
             const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern);
             if (customQuery.isValid()) {
                 andTerm.addSubTerm(customQuery.term());
index f88fc43f49d6ea13ee3190b12e65fce9186b8cd6..11cd2416798367893dcfd096dcf151d5370738b0 100644 (file)
@@ -95,7 +95,6 @@ private slots:
     void slotConfigurationChanged();
     void slotSearchTextChanged(const QString& text);
     void slotReturnPressed(const QString& text);
-    void setFilterWidgetsVisible(bool visible);
 
 private:
     void initButton(QPushButton* button);
@@ -127,8 +126,6 @@ private:
     QPushButton* m_contentButton;
 
     QToolButton* m_filterButton;
-    QFormLayout* m_filterWidgetsLayout;
-    QList<AbstractSearchFilterWidget*> m_filterWidgets;
 
     KUrl m_searchPath;
 
diff --git a/src/search/filters/abstractsearchfilterwidget.cpp b/src/search/filters/abstractsearchfilterwidget.cpp
deleted file mode 100644 (file)
index 5b44f94..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/***************************************************************************
-*    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           *
-* **************************************************************************/
-
-#include "abstractsearchfilterwidget.h"
-
-#include <QPushButton>
-
-class SearchFilterButton : public QPushButton
-{
-public:
-    SearchFilterButton(QWidget* parent = 0);
-    virtual QSize sizeHint() const;
-};
-
-SearchFilterButton::SearchFilterButton(QWidget* parent) :
-    QPushButton(parent)
-{
-    setCheckable(true);
-}
-
-QSize SearchFilterButton::sizeHint() const
-{
-    // Provide a larger preferred width, as this leads to a less
-    // cluttered layout for all search filters
-    const QSize defaultSize = QPushButton::sizeHint();
-    QFontMetrics fontMetrics(font());
-    const int minWidth = fontMetrics.height() * 8;
-    const int width = qMax(minWidth, defaultSize.width());
-    return QSize(width, defaultSize.height());
-}
-
-
-
-AbstractSearchFilterWidget::AbstractSearchFilterWidget(QWidget* parent) :
-    QWidget(parent)
-{
-}
-
-AbstractSearchFilterWidget::~AbstractSearchFilterWidget()
-{
-}
-
-QPushButton* AbstractSearchFilterWidget::createButton()
-{
-    SearchFilterButton* button = new SearchFilterButton(this);
-    connect(button, SIGNAL(toggled(bool)), this, SIGNAL(filterChanged()));
-    return button;
-}
-
-#include "abstractsearchfilterwidget.moc"
diff --git a/src/search/filters/abstractsearchfilterwidget.h b/src/search/filters/abstractsearchfilterwidget.h
deleted file mode 100644 (file)
index 95f288b..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
- *   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            *
- ***************************************************************************/
-
-#ifndef ABSTRACTSEARCHFILTERWIDGET_H
-#define ABSTRACTSEARCHFILTERWIDGET_H
-
-#include <nepomuk/term.h>
-#include <QWidget>
-
-class QPushButton;
-
-/**
- * @brief Base class for widgets that act as filter for searching.
- *
- * Derived classes need to implement the methods filterLabel() and
- * queryTerm(). It is recommended to use createButton() for a filter-switch.
- * The created button will automatically emit the signal filterChanged().
- */
-class AbstractSearchFilterWidget : public QWidget {
-    Q_OBJECT
-
-public:
-    AbstractSearchFilterWidget(QWidget* parent = 0);
-    virtual ~AbstractSearchFilterWidget();
-
-    /**
-     * @return Label that describes the kind of filter.
-     */
-    virtual QString filterLabel() const = 0;
-
-    /**
-     * @return Query-term for this filter, that respects the currently
-     *         selected filter-switches.
-     */
-    virtual Nepomuk::Query::Term queryTerm() const = 0;
-
-protected:
-    /**
-     * @return A checkable button, that automatically emits the signal
-     *         filterChanged() when being pressed.
-     */
-    QPushButton* createButton();
-
-signals:
-    /**
-     * Is emitted, if a filter-switch has been changed by the user.
-     */
-    void filterChanged();
-};
-
-#endif
diff --git a/src/search/filters/datesearchfilterwidget.cpp b/src/search/filters/datesearchfilterwidget.cpp
deleted file mode 100644 (file)
index c1856a3..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/***************************************************************************
-*    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           *
-* **************************************************************************/
-
-#include "datesearchfilterwidget.h"
-
-#include <klocale.h>
-#include <nepomuk/comparisonterm.h>
-#include <nepomuk/literalterm.h>
-#include <nepomuk/orterm.h>
-#include <nepomuk/property.h>
-#include <nepomuk/query.h>
-#include "nie.h"
-#include <QDate>
-#include <QDateTime>
-#include <QLabel>
-#include <QPushButton>
-#include <QHBoxLayout>
-
-DateSearchFilterWidget::DateSearchFilterWidget(QWidget* parent) :
-    AbstractSearchFilterWidget(parent),
-    m_dateButtons()
-{
-    QHBoxLayout* layout = new QHBoxLayout(this);
-    layout->setSpacing(0);
-
-    for (int i = Today; i <= ThisYear; ++i) {
-        QPushButton* button = createButton();
-        switch (i) {
-        case Today:     button->setText(i18nc("@action:button", "Today")); break;
-        case Yesterday: button->setText(i18nc("@action:button", "Yesterday")); break;
-        case ThisWeek:  button->setText(i18nc("@action:button", "This Week")); break;
-        case ThisMonth: button->setText(i18nc("@action:button", "This Month")); break;
-        case ThisYear:  button->setText(i18nc("@action:button", "This Year")); break;
-        default: Q_ASSERT(false);
-        }
-
-        layout->addWidget(button);
-        m_dateButtons.append(button);
-    }
-    layout->addStretch(1);
-}
-
-DateSearchFilterWidget::~DateSearchFilterWidget()
-{
-}
-
-
-QString DateSearchFilterWidget::filterLabel() const
-{
-    return i18nc("@title:group", "Date");
-}
-
-Nepomuk::Query::Term DateSearchFilterWidget::queryTerm() const
-{
-    Nepomuk::Query::OrTerm orTerm;
-
-    int index = 0;
-    foreach (const QPushButton* button, m_dateButtons) {
-        if (button->isChecked()) {
-            QDate today = QDate::currentDate();
-            QDate date;
-            switch (index) {
-            case Today:
-                // Current date is already set
-                break;
-            case Yesterday:
-                date.addDays(-1);
-                break;
-            case ThisWeek:
-                date.addDays(-today.dayOfWeek());
-                break;
-            case ThisMonth:
-                date = QDate(today.year(), today.month(), 1);
-                break;           
-            case ThisYear:
-                date = QDate(today.year(), 1, 1);
-                break;
-            default:
-                Q_ASSERT(false);
-            }
-
-            const QDateTime dateTime(date);
-            const Nepomuk::Query::LiteralTerm term(dateTime);
-            const Nepomuk::Query::ComparisonTerm compTerm(Nepomuk::Vocabulary::NIE::lastModified(),
-                                                          term,
-                                                          Nepomuk::Query::ComparisonTerm::GreaterOrEqual);
-            orTerm.addSubTerm(compTerm);
-        }
-        ++index;
-    }
-
-    return orTerm;
-}
-
-#include "datesearchfilterwidget.moc"
diff --git a/src/search/filters/datesearchfilterwidget.h b/src/search/filters/datesearchfilterwidget.h
deleted file mode 100644 (file)
index 9099489..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/***************************************************************************
- *   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            *
- ***************************************************************************/
-
-#ifndef DATESEARCHFILTERWIDGET_H
-#define DATESEARCHFILTERWIDGET_H
-
-#include <search/filters/abstractsearchfilterwidget.h>
-#include <QList>
-
-class QPushButton;
-
-/**
- * @brief Allows to filter the search by defined date values like
- *        today, yesterday, ...
- */
-class DateSearchFilterWidget : public AbstractSearchFilterWidget {
-    Q_OBJECT
-
-public:
-    DateSearchFilterWidget(QWidget* parent = 0);
-    virtual ~DateSearchFilterWidget();
-    virtual QString filterLabel() const;
-    virtual Nepomuk::Query::Term queryTerm() const;
-
-private:
-    enum DateFilterType {
-        Today,
-        Yesterday,
-        ThisWeek,
-        ThisMonth,
-        ThisYear
-    };
-
-    QList<QPushButton*> m_dateButtons;
-};
-
-#endif
diff --git a/src/search/filters/ratingsearchfilterwidget.cpp b/src/search/filters/ratingsearchfilterwidget.cpp
deleted file mode 100644 (file)
index 143c8c7..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/***************************************************************************
-*    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           *
-* **************************************************************************/
-
-#include "ratingsearchfilterwidget.h"
-
-#include <klocale.h>
-#include <nepomuk/comparisonterm.h>
-#include <nepomuk/literalterm.h>
-#include <nepomuk/orterm.h>
-#include <nepomuk/kratingpainter.h>
-#include <nepomuk/property.h>
-#include <nepomuk/query.h>
-#include "nie.h"
-#include <Soprano/LiteralValue>
-#include <Soprano/Vocabulary/NAO>
-#include <QFontMetrics>
-#include <QIcon>
-#include <QLabel>
-#include <QPainter>
-#include <QPushButton>
-#include <QHBoxLayout>
-
-namespace {
-    // Only show the ratings 0, 2, 4, ... 10
-    const int RatingInc = 2;
-};
-
-RatingSearchFilterWidget::RatingSearchFilterWidget(QWidget* parent) :
-    AbstractSearchFilterWidget(parent),
-    m_ratingButtons()
-{
-    QHBoxLayout* layout = new QHBoxLayout(this);
-    layout->setSpacing(0);
-
-    QFontMetrics fontMetrics(font());
-    const int iconHeight = fontMetrics.height();
-
-    KRatingPainter ratingPainter;
-    const int maxRating = ratingPainter.maxRating();
-    const QSize iconSize(iconHeight * (maxRating / 2), iconHeight);
-    const QRect paintRect(QPoint(0, 0), iconSize);
-
-    for (int rating = 0; rating <= ratingPainter.maxRating(); rating += RatingInc) {
-        // Create pixmap that represents the rating
-        QPixmap pixmap(iconSize);
-        pixmap.fill(Qt::transparent);
-        QPainter painter(&pixmap);
-        ratingPainter.paint(&painter, paintRect, rating);
-
-        // Create button with the rating pixmap as icon
-        QPushButton* button = createButton();
-        button->setIconSize(iconSize);
-        button->setIcon(QIcon(pixmap));
-
-        layout->addWidget(button);
-        m_ratingButtons.append(button);
-    }
-
-    layout->addStretch(1);
-}
-
-RatingSearchFilterWidget::~RatingSearchFilterWidget()
-{
-}
-
-QString RatingSearchFilterWidget::filterLabel() const
-{
-    return i18nc("@title:group", "Rating");
-}
-
-Nepomuk::Query::Term RatingSearchFilterWidget::queryTerm() const
-{
-    Nepomuk::Query::OrTerm orTerm;
-
-    int rating = 0;
-    foreach (const QPushButton* ratingButton, m_ratingButtons) {
-        if (ratingButton->isChecked()) {
-            const Nepomuk::Query::LiteralTerm term(rating);
-            const Nepomuk::Query::ComparisonTerm compTerm(Soprano::Vocabulary::NAO::numericRating(),
-                                                          term,
-                                                          Nepomuk::Query::ComparisonTerm::Equal);
-            orTerm.addSubTerm(compTerm);
-        }
-        rating += RatingInc;
-    }
-
-    return orTerm;
-}
-
-#include "ratingsearchfilterwidget.moc"
diff --git a/src/search/filters/ratingsearchfilterwidget.h b/src/search/filters/ratingsearchfilterwidget.h
deleted file mode 100644 (file)
index 05de1ad..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************************************
- *   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            *
- ***************************************************************************/
-
-#ifndef RATINGSEARCHFILTERWIDGET_H
-#define RATINGSEARCHFILTERWIDGET_H
-
-#include <search/filters/abstractsearchfilterwidget.h>
-#include <QList>
-
-class QPushButton;
-
-/**
- * @brief Allows to filter the search by rating.
- */
-class RatingSearchFilterWidget : public AbstractSearchFilterWidget {
-    Q_OBJECT
-
-public:
-    RatingSearchFilterWidget(QWidget* parent = 0);
-    virtual ~RatingSearchFilterWidget();
-    virtual QString filterLabel() const;
-    virtual Nepomuk::Query::Term queryTerm() const;
-
-private:
-    QList<QPushButton*> m_ratingButtons;
-};
-
-#endif
diff --git a/src/search/filters/tagsearchfilterwidget.cpp b/src/search/filters/tagsearchfilterwidget.cpp
deleted file mode 100644 (file)
index d4dbd30..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-*    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           *
-* **************************************************************************/
-
-#include "tagsearchfilterwidget.h"
-
-#include <nepomuk/tag.h>
-#include <nepomuk/comparisonterm.h>
-#include <nepomuk/literalterm.h>
-#include <nepomuk/orterm.h>
-#include <nepomuk/property.h>
-#include <nepomuk/query.h>
-#include <klocale.h>
-#include <Soprano/LiteralValue>
-#include <Soprano/Vocabulary/NAO>
-#include <QLabel>
-#include <QPushButton>
-#include <QHBoxLayout>
-
-static bool tagLabelLessThan(const Nepomuk::Tag& t1, const Nepomuk::Tag& t2)
-{
-    return t1.genericLabel() < t2.genericLabel();
-}
-
-TagSearchFilterWidget::TagSearchFilterWidget(QWidget* parent) :
-    AbstractSearchFilterWidget(parent),
-    m_tagButtons()
-{
-    QHBoxLayout* layout = new QHBoxLayout(this);
-    layout->setSpacing(0);
-
-    QList<Nepomuk::Tag> tags = Nepomuk::Tag::allTags();
-    qSort(tags.begin(), tags.end(), tagLabelLessThan);
-
-    // TODO: handle case if no tag is available
-    foreach (const Nepomuk::Tag& tag, tags) {
-        QPushButton* button = createButton();
-        button->setText(tag.genericLabel());
-
-        layout->addWidget(button);
-        m_tagButtons.append(button);
-    }
-
-    layout->addStretch(1);
-}
-
-TagSearchFilterWidget::~TagSearchFilterWidget()
-{
-}
-
-QString TagSearchFilterWidget::filterLabel() const
-{
-    return i18nc("@title:group", "Tag");
-}
-
-Nepomuk::Query::Term TagSearchFilterWidget::queryTerm() const
-{
-    Nepomuk::Query::OrTerm orTerm;
-
-    foreach (const QPushButton* tagButton, m_tagButtons) {
-        if (tagButton->isChecked()) {
-            const Nepomuk::Query::LiteralTerm term(tagButton->text());
-            const Nepomuk::Query::ComparisonTerm compTerm(Soprano::Vocabulary::NAO::hasTag(),
-                                                          term,
-                                                          Nepomuk::Query::ComparisonTerm::Equal);
-            orTerm.addSubTerm(compTerm);
-        }
-    }
-
-    return orTerm;
-}
-
-#include "tagsearchfilterwidget.moc"
diff --git a/src/search/filters/tagsearchfilterwidget.h b/src/search/filters/tagsearchfilterwidget.h
deleted file mode 100644 (file)
index 9897e40..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************************************
- *   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            *
- ***************************************************************************/
-
-#ifndef TAGSEARCHFILTERWIDGET_H
-#define TAGSEARCHFILTERWIDGET_H
-
-#include <search/filters/abstractsearchfilterwidget.h>
-#include <QList>
-
-class QPushButton;
-
-/**
- * @brief Allows to filter the search by tags.
- */
-class TagSearchFilterWidget : public AbstractSearchFilterWidget {
-    Q_OBJECT
-
-public:
-    TagSearchFilterWidget(QWidget* parent = 0);
-    virtual ~TagSearchFilterWidget();
-    virtual QString filterLabel() const;
-    virtual Nepomuk::Query::Term queryTerm() const;
-
-private:
-    QList<QPushButton*> m_tagButtons;
-};
-
-#endif