From 90d6867a5e892fb34c0dd6706d96a039572449b4 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 27 Oct 2010 13:35:24 +0000 Subject: Rename FacetPanel to FilterPanel so that the name reflects the headline. svn path=/trunk/KDE/kdebase/apps/; revision=1190370 --- src/CMakeLists.txt | 2 +- src/dolphinmainwindow.cpp | 28 ++++----- src/panels/facets/facetpanel.cpp | 128 -------------------------------------- src/panels/facets/facetpanel.h | 67 -------------------- src/panels/filter/filterpanel.cpp | 128 ++++++++++++++++++++++++++++++++++++++ src/panels/filter/filterpanel.h | 67 ++++++++++++++++++++ 6 files changed, 210 insertions(+), 210 deletions(-) delete mode 100644 src/panels/facets/facetpanel.cpp delete mode 100644 src/panels/facets/facetpanel.h create mode 100644 src/panels/filter/filterpanel.cpp create mode 100644 src/panels/filter/filterpanel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e435cfb44..1fe94261c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,7 +148,7 @@ kde4_add_kcfg_files(dolphin_SRCS if(Nepomuk_FOUND) set(dolphin_SRCS ${dolphin_SRCS} - panels/facets/facetpanel.cpp + panels/filter/filterpanel.cpp search/filters/abstractsearchfilterwidget.cpp search/filters/datesearchfilterwidget.cpp search/filters/ratingsearchfilterwidget.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index efae23d6e..167debd33 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -28,7 +28,7 @@ #include "dolphinnewfilemenu.h" #include "dolphinviewcontainer.h" #include "mainwindowadaptor.h" -#include "panels/facets/facetpanel.h" +#include "panels/filter/filterpanel.h" #include "panels/folders/folderspanel.h" #include "panels/places/placespanel.h" #include "panels/information/informationpanel.h" @@ -1563,20 +1563,20 @@ void DolphinMainWindow::setupDockWidgets() connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)), this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); - // setup "Facets" + // setup "Filter" #ifdef HAVE_NEPOMUK - QDockWidget* facetDock = new QDockWidget(i18nc("@title:window", "Filter")); - facetDock->setObjectName("facetDock"); - facetDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - Panel* facetPanel = new FacetPanel(facetDock); - connect(facetPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl))); - facetDock->setWidget(facetPanel); - - QAction* facetAction = facetDock->toggleViewAction(); - facetAction->setIcon(KIcon("dialog-facet")); - addDockWidget(Qt::RightDockWidgetArea, facetDock); + QDockWidget* filterDock = new QDockWidget(i18nc("@title:window", "Filter")); + filterDock->setObjectName("filterDock"); + filterDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + Panel* filterPanel = new FilterPanel(filterDock); + connect(filterPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl))); + filterDock->setWidget(filterPanel); + + QAction* filterAction = filterDock->toggleViewAction(); + filterAction->setIcon(KIcon("dialog-facet")); + addDockWidget(Qt::RightDockWidgetArea, filterDock); connect(this, SIGNAL(urlChanged(KUrl)), - facetPanel, SLOT(setUrl(KUrl))); + filterPanel, SLOT(setUrl(KUrl))); #endif // setup "Terminal" @@ -1634,7 +1634,7 @@ void DolphinMainWindow::setupDockWidgets() panelsMenu->addAction(infoAction); panelsMenu->addAction(foldersAction); #ifdef HAVE_NEPOMUK - panelsMenu->addAction(facetAction); + panelsMenu->addAction(filterAction); #endif #ifndef Q_OS_WIN panelsMenu->addAction(terminalAction); diff --git a/src/panels/facets/facetpanel.cpp b/src/panels/facets/facetpanel.cpp deleted file mode 100644 index 3c930209c..000000000 --- a/src/panels/facets/facetpanel.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Sebastian Trueg * - * * - * 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 "facetpanel.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - - -FacetPanel::FacetPanel(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() ) ); - - layout->addWidget(m_buttonRemoveFolderRestriction); - - m_facetWidget = new Nepomuk::Utils::FacetWidget( this ); - layout->addWidget( m_facetWidget, 1 ); - connect(m_facetWidget, SIGNAL(facetsChanged()), this, SLOT(slotFacetsChanged()) ); - - // init to empty panel - setQuery(Nepomuk::Query::Query()); -} - - -FacetPanel::~FacetPanel() -{ -} - -void FacetPanel::setUrl(const KUrl& url) -{ - kDebug() << url; - Panel::setUrl(url); - - // disable us - setQuery(Nepomuk::Query::Query()); - - // get the query from the item - m_lastSetUrlStatJob = KIO::stat(url, KIO::HideProgressInfo); - connect(m_lastSetUrlStatJob, SIGNAL(result(KJob*)), - this, SLOT(slotSetUrlStatFinished(KJob*))); -} - - -void FacetPanel::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); - } -} - - -void FacetPanel::slotSetUrlStatFinished(KJob* job) -{ - m_lastSetUrlStatJob = 0; - kDebug() << url(); - const KIO::UDSEntry uds = static_cast(job)->statResult(); - const QString nepomukQueryStr = uds.stringValue( KIO::UDSEntry::UDS_NEPOMUK_QUERY ); - kDebug() << nepomukQueryStr; - Nepomuk::Query::FileQuery nepomukQuery; - 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 FacetPanel::slotFacetsChanged() -{ - Nepomuk::Query::Query query( m_unfacetedRestQuery && m_facetWidget->queryTerm() ); - kDebug() << query; - emit urlActivated( query.toSearchUrl() ); -} - - -void FacetPanel::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() ); -} diff --git a/src/panels/facets/facetpanel.h b/src/panels/facets/facetpanel.h deleted file mode 100644 index 6673c7953..000000000 --- a/src/panels/facets/facetpanel.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Sebastian Trueg * - * * - * 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 FACETPANEL_H -#define FACETPANEL_H - -#include "../panel.h" -#include - -class KJob; -class QPushButton; - -namespace Nepomuk { - namespace Utils { - class FacetWidget; - } -} - -class FacetPanel : public Panel -{ - Q_OBJECT - -public: - FacetPanel(QWidget* parent = 0); - ~FacetPanel(); - -public slots: - void setUrl(const KUrl& url); - void setQuery(const Nepomuk::Query::Query& query); - -signals: - void urlActivated( const KUrl& url ); - -private slots: - void slotSetUrlStatFinished(KJob*); - void slotFacetsChanged(); - void slotRemoveFolderRestrictionClicked(); - -private: - bool urlChanged() { - return true; - } - - KJob* m_lastSetUrlStatJob; - - QPushButton* m_buttonRemoveFolderRestriction; - Nepomuk::Utils::FacetWidget* m_facetWidget; - Nepomuk::Query::Query m_unfacetedRestQuery; -}; - -#endif // FACETPANEL_H diff --git a/src/panels/filter/filterpanel.cpp b/src/panels/filter/filterpanel.cpp new file mode 100644 index 000000000..4410a5456 --- /dev/null +++ b/src/panels/filter/filterpanel.cpp @@ -0,0 +1,128 @@ +/*************************************************************************** + * Copyright (C) 2010 by Sebastian Trueg * + * * + * 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 +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + + +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() ) ); + + layout->addWidget(m_buttonRemoveFolderRestriction); + + m_facetWidget = new Nepomuk::Utils::FacetWidget( this ); + layout->addWidget( m_facetWidget, 1 ); + connect(m_facetWidget, SIGNAL(facetsChanged()), this, SLOT(slotFacetsChanged()) ); + + // init to empty panel + setQuery(Nepomuk::Query::Query()); +} + + +FilterPanel::~FilterPanel() +{ +} + +void FilterPanel::setUrl(const KUrl& url) +{ + kDebug() << url; + Panel::setUrl(url); + + // disable us + setQuery(Nepomuk::Query::Query()); + + // 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); + } +} + + +void FilterPanel::slotSetUrlStatFinished(KJob* job) +{ + m_lastSetUrlStatJob = 0; + kDebug() << url(); + const KIO::UDSEntry uds = static_cast(job)->statResult(); + const QString nepomukQueryStr = uds.stringValue( KIO::UDSEntry::UDS_NEPOMUK_QUERY ); + kDebug() << nepomukQueryStr; + Nepomuk::Query::FileQuery nepomukQuery; + 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() ); +} + + +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() ); +} diff --git a/src/panels/filter/filterpanel.h b/src/panels/filter/filterpanel.h new file mode 100644 index 000000000..d42c2f0bd --- /dev/null +++ b/src/panels/filter/filterpanel.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2010 by Sebastian Trueg * + * * + * 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 "../panel.h" +#include + +class KJob; +class QPushButton; + +namespace Nepomuk { + namespace Utils { + class FacetWidget; + } +} + +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); + +signals: + void urlActivated( const KUrl& url ); + +private slots: + void slotSetUrlStatFinished(KJob*); + void slotFacetsChanged(); + void slotRemoveFolderRestrictionClicked(); + +private: + bool urlChanged() { + return true; + } + + KJob* m_lastSetUrlStatJob; + + QPushButton* m_buttonRemoveFolderRestriction; + Nepomuk::Utils::FacetWidget* m_facetWidget; + Nepomuk::Query::Query m_unfacetedRestQuery; +}; + +#endif // FILTERPANEL_H -- cgit v1.3