2007-11-02 03:34:46 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2006-2007 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.
|
|
|
|
*/
|
|
|
|
|
2008-02-19 10:12:34 +01:00
|
|
|
#ifndef SEARCHMATCH_H
|
|
|
|
#define SEARCHMATCH_H
|
2007-11-02 03:34:46 +01:00
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
2007-12-10 19:04:45 +01:00
|
|
|
class QIcon;
|
|
|
|
class QVariant;
|
|
|
|
class QString;
|
|
|
|
|
2007-11-02 03:34:46 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class SearchContext;
|
|
|
|
class AbstractRunner;
|
|
|
|
|
2007-12-10 19:04:45 +01:00
|
|
|
class PLASMA_EXPORT SearchMatch
|
2007-11-02 03:34:46 +01:00
|
|
|
{
|
|
|
|
public:
|
2008-02-18 00:02:46 +01:00
|
|
|
/**
|
|
|
|
* The type of match. Value is important here as it is used for sorting
|
|
|
|
*/
|
|
|
|
enum Type { PossibleMatch = 0 /**< Something that may match the query */,
|
|
|
|
InformationalMatch = 50 /**< A purely informational, non-actionable match,
|
|
|
|
such as the answer to a question or calculation*/,
|
|
|
|
ExactMatch = 100 /**< An exact matcht to the query */};
|
2007-11-02 03:34:46 +01:00
|
|
|
|
2008-02-19 04:59:21 +01:00
|
|
|
/**
|
|
|
|
* Constructs a PossibleMatch associated with a given SearchContext
|
|
|
|
* and runner.
|
|
|
|
*
|
|
|
|
* @arg search the SearchContext this match belongs to
|
|
|
|
* @arg runner the runner this match belongs to
|
|
|
|
*/
|
|
|
|
explicit SearchMatch(AbstractRunner *runner);
|
2007-12-03 18:18:28 +01:00
|
|
|
~SearchMatch();
|
2007-11-02 03:34:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the type of match this action represents.
|
|
|
|
*/
|
|
|
|
void setType(Type type);
|
|
|
|
|
|
|
|
/**
|
2008-02-19 04:59:21 +01:00
|
|
|
* The type of action this is. Defaults to PossibleMatch.
|
2007-11-02 03:34:46 +01:00
|
|
|
*/
|
|
|
|
Type type() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the relevance of this action for the search
|
|
|
|
* it was created for.
|
|
|
|
*
|
|
|
|
* @param relevance a number between 0 and 1.
|
|
|
|
*/
|
|
|
|
void setRelevance(qreal relevance);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The relevance of this action to the search. By default,
|
|
|
|
* the relevance is 1.
|
|
|
|
*
|
|
|
|
* @return a number between 0 and 1
|
|
|
|
*/
|
|
|
|
qreal relevance() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The runner associated with this action
|
|
|
|
*/
|
|
|
|
AbstractRunner* runner() const;
|
|
|
|
|
2007-12-02 08:11:50 +01:00
|
|
|
void setText(const QString& text);
|
2008-02-19 12:24:42 +01:00
|
|
|
void setSubtext(const QString& text);
|
2007-12-02 08:11:50 +01:00
|
|
|
void setData(const QVariant& data);
|
|
|
|
void setIcon(const QIcon& icon);
|
|
|
|
void setEnabled(bool enable);
|
|
|
|
|
|
|
|
QString text() const;
|
2008-02-19 12:24:42 +01:00
|
|
|
QString subtext() const;
|
2007-12-02 08:11:50 +01:00
|
|
|
QVariant data() const;
|
|
|
|
QIcon icon() const;
|
|
|
|
bool isEnabled() const;
|
|
|
|
|
2007-12-03 18:18:28 +01:00
|
|
|
bool operator<(const SearchMatch& other) const;
|
2007-11-02 03:34:46 +01:00
|
|
|
|
2008-02-19 04:59:21 +01:00
|
|
|
void exec(const SearchContext *context) const;
|
2007-11-02 03:34:46 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|