File: packagestatusplugin.h

package info (click to toggle)
packagesearch 2.10.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,704 kB
  • sloc: cpp: 9,176; perl: 248; makefile: 15; sh: 11
file content (133 lines) | stat: -rw-r--r-- 4,262 bytes parent folder | download | duplicates (4)
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
#ifndef __PACKAGESTATUSPLUGIN_H_2004_06_21
#define __PACKAGESTATUSPLUGIN_H_2004_06_21

#include <vector>
#include <map>

#include <QObject>

#include <shortinformationplugin.h>
#include <searchplugin.h>

#include "ipackage.h"

using namespace std;

class InstalledFilterWidget;

namespace NApt
{
	class IPackageDB;
}


namespace NPlugin
{

/** @brief This Plugin offers information about the installed State of the package.
  *
  * It offers short information (an x if the package is installed and an empty string 
  * if not) and allows searching by installed status using the filter search technique.
  *
  * @author Benjamin Mesing
  */
// take care to keep the order of the subclasses (SearchPlugin must be first as it
// is the QT class
class PackageStatusPlugin : public SearchPlugin, public ShortInformationPlugin
{
	Q_OBJECT
	const QString _title;
	const QString _briefDescription;
	const QString _description;
	/** @brief This enum must always match NApt::Package::InstalledState except for ALL. */
	enum InstalledState 
	{ 
		NOT_INSTALLED = NApt::IPackage::NOT_INSTALLED, 
		UPGRADABLE = NApt::IPackage::UPGRADABLE, 
		INSTALLED = NApt::IPackage::INSTALLED, 
		ALL = 100 
	};
	/** This holds the currently selected installed state filter. */
	InstalledState _installedFilter;

	NApt::IPackageDB* _pPackageDB;
	/** The widget where to select which packages should be shown. */
	InstalledFilterWidget* _pInstalledFilterWidget;
	/** The text to mark an installed package ("x") */
	QString _installedText;
	/** The text to mark a not installed package (empty string) */
	QString _notInstalledText;
	std::set<string> _emptyOpSet;
	/** @brief This maps the installed state to how it shall be diplayed. 
	  *
	  * So _stateToText[Package::INSTALLED] returns "x" while _stateToText[Package::NOT_INSTALLED] returns an empty string
	  */
    map<NApt::IPackage::InstalledState, QString> _stateToText;

public:
	static const QString PLUGIN_NAME;
	/**
	  */
	PackageStatusPlugin(NApt::IPackageDB* pPackageDB);
	~PackageStatusPlugin() ;
	/** @name Plugin Interface
	  * 
	  * Implementation of the PluginInterface
	  */
	//@{
	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
	  */
	//@{
	virtual uint searchPriority() const	{ return 2; }
	/** @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 true; };
	virtual const std::set<string>& searchResult() const	{ return _emptyOpSet; };
	virtual bool filterPackage(const string& package) const;
	/** Returns true if ALL is selected as filter. */
	virtual bool isInactive() const;
	//@}
	
	/** @name ShortInformationPlugin interface
	  * 
	  * Implementation of the ShortInformationPlugin interface
	  */
	//@{
	virtual uint shortInformationPriority() const	{ return 2; }
	virtual const QString shortInformationText(const string& package);
	/** The caption for the short information is <b>I</b> for installed  */
	virtual QString shortInformationCaption() const { return QString("I"); };
	// documented in base class
	virtual int preferredColumnWidth() const { return 1; }
	//@}
protected:
	/** @brief Returns the state of the handed package. 
	  *
	  * Returns NApt::Package::NOT_INSTALLED if the package is not in the database. */
    NApt::IPackage::InstalledState getState(const string& package) const;
protected Q_SLOTS:
	/** Called whenever the user selects a new installed filter. 
	  * @param the item that was activated */
	void onInstalledFilterChanged(int activated);
};

}	// namespace NPlugin

#endif //	__PACKAGESTATUSPLUGIN_H_2004_06_21