1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#ifndef __APTSEARCHPLUGIN_H_2004_06_21
#define __APTSEARCHPLUGIN_H_2004_06_21
#include <string>
#include <QObject>
#include <QStringList>
// NPlugin
#include <searchplugin.h>
#include <scoreplugin.h>
class QTimer;
class QStatusBar;
class AptSearchPluginShortInputWidget;
using namespace std;
namespace NApt
{
class IAptSearch;
class IPackageDB;
class AptSearchScoreCalculationStrategy;
}
namespace NPlugin
{
// Class AptSearchPlugin
//
//
class AptSearchPlugin : public SearchPlugin, public ScorePlugin
{
Q_OBJECT
const QString _title;
const QString _briefDescription;
const QString _description;
/** @brief This holds the result of the currently active search. */
std::set<string> _searchResult;
/** @brief This holds a link to the manager which manages the plugin. */
IProvider* _pProvider;
/** @brief Holds a pointer to the main widgets status bar. */
QStatusBar* _pStatusBar;
/** @brief This timer is used to delay the evaluation of the search a little
* to avoid unneccessary operations e.g. on text input. */
QTimer* _pDelayTimer;
/** @brief Holds the strategy object used to calculate the scores. */
NApt::AptSearchScoreCalculationStrategy* _pScoreCalculationStrategy;
/** @brief This is the delay time in ms the delay timer waits for another input. */
uint _delayTime;
/** @brief The short widget used for getting the user input. */
AptSearchPluginShortInputWidget* _pShortInputWidget;
/** @brief Holds the interface used for searching. */
NApt::IAptSearch* _pAptSearch;
/** @brief Holds the interface used to access the package database directly. */
NApt::IPackageDB* _pPackageDb;
/** @brief Holds the patterns that must be contained in the text to be searched. */
QStringList _includePatterns;
protected Q_SLOTS:
/** @brief Evaluates the search as specified in the input widgets. */
virtual void evaluateSearch();
/** @brief Called whenever the text of the widget where to insert the
* search pattern changes. */
void onInputTextChanged(const QString&);
/** @brief Slot that calls clearSearch() */
void onClearSearch() { clearSearch(); };
protected:
/** @brief Parses the handed search expression.
*
* It fills #_includePatterns and #_excludePatterns;
*/
void parseSearchExpression(const QString& expression);
public:
static const QString PLUGIN_NAME;
AptSearchPlugin(NApt::IAptSearch* pAptSearch, NApt::IPackageDB* pPackageDb);
virtual ~AptSearchPlugin();
/** @name Plugin Interface
*
* Implementation of the PluginInterface
*/
//@{
/**
*
* @param pluginManager the search window this plugin is added to
*/
virtual void init(IProvider* pProvider);
/// @todo not yet implemented
virtual void setEnabled(bool) {};
/// @todo not yet implemented
virtual void setVisible(bool) {};
virtual QString name() const { return PLUGIN_NAME; }
virtual QString title() const { return _title; };
virtual QString briefDescription() const { return _briefDescription; };
virtual QString description() const { return _description; };
//@}
/** @name SearchPlugin interface
*
* Implementation of the SearchPlugin interface
*/
//@{
/** @brief This plugin offers no input widgets. */
virtual QWidget* inputWidget() const { return 0; };
/** @brief This plugin offers no input widgets. */
virtual QString inputWidgetTitle() const { return _emptyString; };
virtual QWidget* shortInputAndFeedbackWidget() const;
virtual void clearSearch();
virtual bool usesFilterTechnique() const { return false; };
virtual const std::set<string>& searchResult() const { return _searchResult; };
virtual bool filterPackage(const string&) const { return true; };
virtual bool isInactive() const;
virtual uint searchPriority() const { return 1; };
//@}
/** @name ScorePlugin interface
*
* Implementation of the ScorePlugin interface
*/
//@{
virtual map<string, float> getScore(const set<string>& packages) const;
virtual bool offersScore() const { return !_includePatterns.isEmpty(); }
//@}
/** @brief Returns the list of patterns currently searched for by the AptSearchPlugin.
*
* @returns the list of patterns currently searched for or an empty list if no searched
* is active
*/
QStringList searchPatterns();
};
} // namespace NPlugin
#endif // __APTSEARCHPLUGIN_H_2004_06_21
|