Prepare the search criterion selector to use the new Nepomuk::Query::Term instead of a QString. The implementation still needs to be adapted, but this will be straight forward.

svn path=/trunk/KDE/kdebase/apps/; revision=1053447
This commit is contained in:
Peter Penz 2009-11-24 07:15:24 +00:00
parent 61813e0df7
commit 7662e0e4d4
4 changed files with 52 additions and 20 deletions

View file

@ -195,10 +195,23 @@ kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-fi
kde4_add_executable(dolphin ${dolphin_SRCS}) kde4_add_executable(dolphin ${dolphin_SRCS})
target_link_libraries(dolphin ${KDE4_KDEPRINT_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KUTILS_LIBRARY} konq dolphinprivate knewstuff2 ${KDE4_PHONON_LIBS}) target_link_libraries(dolphin
${KDE4_KDEPRINT_LIBS}
${KDE4_KFILE_LIBS}
${KDE4_KUTILS_LIBRARY}
konq
dolphinprivate
knewstuff2
${KDE4_PHONON_LIBS}
)
if (Nepomuk_FOUND) if (Nepomuk_FOUND)
target_link_libraries(dolphin ${NEPOMUK_LIBRARIES} ${SOPRANO_LIBRARIES}) target_link_libraries(dolphin
${NEPOMUK_LIBRARIES}
${SOPRANO_LIBRARIES}
${NEPOMUK_QUERY_LIBRARIES}
nepomukannotation
)
endif (Nepomuk_FOUND) endif (Nepomuk_FOUND)
install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})

View file

@ -22,6 +22,10 @@
#include "dolphin_searchsettings.h" #include "dolphin_searchsettings.h"
#include "searchcriterionselector.h" #include "searchcriterionselector.h"
#include <nepomuk/andterm.h>
#include <nepomuk/query.h>
#include <nepomuk/term.h>
#include <kcombobox.h> #include <kcombobox.h>
#include <kdialog.h> #include <kdialog.h>
#include <kicon.h> #include <kicon.h>
@ -173,17 +177,19 @@ DolphinSearchOptionsConfigurator::~DolphinSearchOptionsConfigurator()
KUrl DolphinSearchOptionsConfigurator::nepomukUrl() const KUrl DolphinSearchOptionsConfigurator::nepomukUrl() const
{ {
QString searchOptions; Nepomuk::Query::AndTerm andTerm;
foreach (const SearchCriterionSelector* criterion, m_criterions) { foreach (const SearchCriterionSelector* criterion, m_criterions) {
const QString criterionString = criterion->toString(); const Nepomuk::Query::Term term = criterion->queryTerm();
if (!criterionString.isEmpty()) { andTerm.addSubTerm(term);
if (!searchOptions.isEmpty()) {
searchOptions += ' ';
}
searchOptions += criterionString;
}
} }
// TODO: respect m_customSearchQuery
Nepomuk::Query::Query query;
query.setTerm(andTerm);
return query.toSearchUrl();
/*QString searchOptions;
QString searchString = m_customSearchQuery; QString searchString = m_customSearchQuery;
if (!searchString.isEmpty() && !searchOptions.isEmpty()) { if (!searchString.isEmpty() && !searchOptions.isEmpty()) {
searchString += ' ' + searchOptions; searchString += ' ' + searchOptions;
@ -192,7 +198,7 @@ KUrl DolphinSearchOptionsConfigurator::nepomukUrl() const
} }
searchString.insert(0, QLatin1String("nepomuksearch:/")); searchString.insert(0, QLatin1String("nepomuksearch:/"));
return KUrl(searchString); return KUrl(searchString);*/
} }
void DolphinSearchOptionsConfigurator::setCustomSearchQuery(const QString& searchQuery) void DolphinSearchOptionsConfigurator::setCustomSearchQuery(const QString& searchQuery)

View file

@ -20,8 +20,16 @@
#include "searchcriterionselector.h" #include "searchcriterionselector.h"
#define DISABLE_NEPOMUK_LEGACY
#include <nepomuk/comparisonterm.h>
#include <nepomuk/nie.h>
#include <nepomuk/literalterm.h>
#include <nepomuk/query.h>
#include "searchcriterionvalue.h" #include "searchcriterionvalue.h"
#include <Soprano/LiteralValue>
#include <QComboBox> #include <QComboBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QList> #include <QList>
@ -74,10 +82,10 @@ SearchCriterionSelector::~SearchCriterionSelector()
{ {
} }
QString SearchCriterionSelector::toString() const Nepomuk::Query::Term SearchCriterionSelector::queryTerm() const
{ {
if (m_valueWidget == 0) { if (m_valueWidget == 0) {
return QString(); return Nepomuk::Query::Term();
} }
const int descIndex = m_descriptionsBox->currentIndex(); const int descIndex = m_descriptionsBox->currentIndex();
@ -86,9 +94,15 @@ QString SearchCriterionSelector::toString() const
const int compIndex = m_comparatorBox->currentIndex(); const int compIndex = m_comparatorBox->currentIndex();
const SearchCriterionDescription::Comparator& comp = descr.comparators()[compIndex]; const SearchCriterionDescription::Comparator& comp = descr.comparators()[compIndex];
if (comp.operation.isEmpty()) { if (comp.operation.isEmpty()) {
return QString(); return Nepomuk::Query::Term();
} }
Nepomuk::Query::LiteralTerm literalTerm(Soprano::LiteralValue("dummy"));
Nepomuk::Query::ComparisonTerm term(Nepomuk::Vocabulary::NIE::lastModified(),
literalTerm,
Nepomuk::Query::ComparisonTerm::Smaller);
return term;
/*
QString criterion = comp.prefix + descr.identifier() + comp.operation; QString criterion = comp.prefix + descr.identifier() + comp.operation;
if (!m_valueWidget->value().isEmpty()) { if (!m_valueWidget->value().isEmpty()) {
const QString value = m_valueWidget->value(); const QString value = m_valueWidget->value();
@ -100,7 +114,7 @@ QString SearchCriterionSelector::toString() const
criterion += value; criterion += value;
} }
} }
return criterion; return criterion;*/
} }
SearchCriterionSelector::Type SearchCriterionSelector::type() const SearchCriterionSelector::Type SearchCriterionSelector::type() const

View file

@ -25,6 +25,8 @@
#include <QString> #include <QString>
#include <QWidget> #include <QWidget>
#define DISABLE_NEPOMUK_LEGACY
#include <nepomuk/term.h>
#include <search/searchcriteriondescription.h> #include <search/searchcriteriondescription.h>
class SearchCriterionValue; class SearchCriterionValue;
@ -50,11 +52,8 @@ public:
SearchCriterionSelector(Type type, QWidget* parent = 0); SearchCriterionSelector(Type type, QWidget* parent = 0);
virtual ~SearchCriterionSelector(); virtual ~SearchCriterionSelector();
/** /** Returns the query-term for the criterion. */
* Converts the string representation of the criterion. Nepomuk::Query::Term queryTerm() const;
* The string is conform to get added to a nepomuk:/-URI.
*/
QString toString() const;
Type type() const; Type type() const;