2009-03-25 02:08:08 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, 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 Library 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 "runnersyntax.h"
|
|
|
|
|
|
|
|
#include <klocalizedstring.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class RunnerSyntaxPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RunnerSyntaxPrivate(const QString &s, const QString &d)
|
|
|
|
: description(d)
|
|
|
|
{
|
|
|
|
exampleQueries.append(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList exampleQueries;
|
|
|
|
QString description;
|
|
|
|
QString termDescription;
|
|
|
|
};
|
|
|
|
|
|
|
|
RunnerSyntax::RunnerSyntax(const QString &exampleQuery, const QString &description)
|
|
|
|
: d(new RunnerSyntaxPrivate(exampleQuery, description))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RunnerSyntax::RunnerSyntax(const RunnerSyntax &other)
|
|
|
|
: d(new RunnerSyntaxPrivate(*other.d))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-02 08:49:53 +02:00
|
|
|
RunnerSyntax::~RunnerSyntax()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2009-03-25 02:08:08 +01:00
|
|
|
RunnerSyntax &RunnerSyntax::operator=(const RunnerSyntax &rhs)
|
|
|
|
{
|
|
|
|
*d = *rhs.d;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerSyntax::addExampleQuery(const QString &exampleQuery)
|
|
|
|
{
|
|
|
|
d->exampleQueries.append(exampleQuery);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList RunnerSyntax::exampleQueries() const
|
|
|
|
{
|
|
|
|
return d->exampleQueries;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList RunnerSyntax::exampleQueriesWithTermDescription() const
|
|
|
|
{
|
|
|
|
QStringList queries;
|
2009-10-13 14:40:13 +02:00
|
|
|
const QString termDesc('<' + searchTermDescription() + '>');
|
2009-03-25 02:08:08 +01:00
|
|
|
foreach (QString query, d->exampleQueries) {
|
|
|
|
queries << query.replace(":q:", termDesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return queries;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerSyntax::setDescription(const QString &description)
|
|
|
|
{
|
|
|
|
d->description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString RunnerSyntax::description() const
|
|
|
|
{
|
|
|
|
QString description = d->description;
|
2009-10-13 14:40:13 +02:00
|
|
|
description.replace(":q:", '<' + searchTermDescription() + '>');
|
2009-03-25 02:08:08 +01:00
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerSyntax::setSearchTermDescription(const QString &description)
|
|
|
|
{
|
|
|
|
d->termDescription = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString RunnerSyntax::searchTermDescription() const
|
|
|
|
{
|
|
|
|
if (d->termDescription.isEmpty()) {
|
|
|
|
return i18n("search term");
|
|
|
|
}
|
|
|
|
|
|
|
|
return d->termDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|