2 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "searchmatch.h"
23 #include <QStringList>
28 #include "abstractrunner.h"
33 class SearchMatch::Private
36 Private(AbstractRunner
*r
)
38 type(SearchMatch::ExactMatch
),
44 AbstractRunner
*runner
;
45 SearchMatch::Type type
;
55 SearchMatch::SearchMatch(AbstractRunner
*runner
)
56 : d(new Private(runner
))
60 SearchMatch::~SearchMatch()
65 void SearchMatch::setType(Type type
)
70 SearchMatch::Type
SearchMatch::type() const
75 void SearchMatch::setRelevance(qreal relevance
)
77 d
->relevance
= qMax(qreal(0.0), qMin(qreal(1.0), relevance
));
80 qreal
SearchMatch::relevance() const
85 AbstractRunner
* SearchMatch::runner() const
90 void SearchMatch::setText(const QString
& text
)
95 void SearchMatch::setSubtext(const QString
& subtext
)
100 void SearchMatch::setData(const QVariant
& data
)
105 void SearchMatch::setIcon(const QIcon
& icon
)
110 QVariant
SearchMatch::data() const
115 QString
SearchMatch::text() const
120 QString
SearchMatch::subtext() const
125 QIcon
SearchMatch::icon() const
130 void SearchMatch::setEnabled( bool enabled
)
132 d
->enabled
= enabled
;
135 bool SearchMatch::isEnabled() const
140 bool SearchMatch::operator<(const SearchMatch
& other
) const
142 return d
->relevance
< other
.d
->relevance
;
145 void SearchMatch::exec(const SearchContext
*context
) const
149 //kDebug() << "we have" << context->searchTerm() << context->mimetype();
151 //TODO: this could be dangerous if the runner is deleted behind our backs.
152 d
->runner
->exec(context
, this);
156 } // Plasma namespace