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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
#ifndef __FILENAMEPLUGIN_H_2004_06_21
#define __FILENAMEPLUGIN_H_2004_06_21
#include <string>
#include <QFileInfo>
#include <QObject>
#include <qstring.h>
#include <qstringlist.h>
#include <qmutex.h>
#include <searchplugin.h>
#include <informationplugin.h>
class FilenameView;
class FilenameSearchInput;
class FilenameFeedbackWidget;
class QWidget;
class QTimer;
namespace NApplication
{
class RunCommandForOutput;
}
using namespace std;
namespace NPlugin
{
// Class FilenamePlugin
//
//
class FilenamePlugin : public SearchPlugin, public InformationPlugin
{
Q_OBJECT
public:
static const QString PLUGIN_NAME;
FilenamePlugin();
virtual ~FilenamePlugin();
/** @name Plugin Interface
*
* Implementation of the PluginInterface
*/
//@{
virtual uint priority() const { return 7; };
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; }
/** @returns "FilenamePlugin" */
virtual QString title() const;
virtual QString briefDescription() const;
virtual QString description() const;
//@}
/** @name InformationPlugin interface
*
* Implementation of the InformationPlugin interface
*/
//@{
virtual uint informationPriority() const { return 7; }
/** @returns a widget which shows a description of this package. */
virtual QWidget* informationWidget() const;
/** @returns "Description" */
virtual QString informationWidgetTitle() const;
virtual void updateInformationWidget(const string& package);
virtual void clearInformationWidget();
/** This plugin offers an information text. */
virtual bool offersInformationText() const { return false; };
virtual QString informationText(const string& package);
//@}
/** @name SearchPlugin interface
*
* Implementation of the SearchPlugin interface
*/
//@{
virtual uint searchPriority() const { return 7; };
virtual QWidget* inputWidget() const;
virtual QString inputWidgetTitle() const;
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;
//@}
protected:
/** This exception is thrown to indicate that no information about the
* package could have be retrieved. */
class NoInformationException
{
public:
/** This holds a message about what wen wrong. */
QString _errorMessage;
NoInformationException(const QString& errorMessage)
{ _errorMessage = errorMessage; };
};
/** @brief This returns the files which belong to the given package.
*
* It might return an empty list, if the information can not
* be retrieved immidiately.\n
* @throws NoInformationException if no inforamtion about the package
* can be retrieved. */
QStringList filesForPackage(const string& packageName);
/** @brief File info for the file containing the list of installed files for the package.
*
* I first looks for the file in /var/lib/dpkg/info/<em>packagename</em> without
* any arch extension, then for any file
* with an arbitrary extension (returns the first match).
* Returns an empty QFileInfo if the package is not installed (i.e. no list file is
* available).
*/
QFileInfo getFileListFileName(const string& packageName);
/** @brief Returns if the given package is installed.
*/
bool isInstalled(const string& packageName);
/** This checks if the apt-file system is available. */
bool aptFileAvailable();
protected Q_SLOTS:
/** @brief Slot that calls clearSearch() */
void onClearSearch() { clearSearch(); };
/** @brief Evaluates the currently entered search. */
void evaluateSearch();
private Q_SLOTS:
/** This is called whenever the text of the widget where to insert the
* search pattern changes. */
void onInputTextChanged(const QString&);
/** Called when the search process has exited. */
void onSearchProcessExited();
/** Called when the search process has exited. */
void onFilelistProcessExited();
/** Called whenever the user clicked "show" in the view. */
void onShowRequested();
private:
/** Locked if we currently evaluate a search. */
QMutex _processMutex;
/** Process currently executed, make sure to get the _processMutex if you want to use it.
*
* 0 if no process is currently running. */
NApplication::RunCommandForOutput* _pProcess;
/** @brief This checks if the given entry is for the handed package and
* prepares the entry for output.
*
* It works on entries as returned by <tt>apt-file list <i>packageName</i></tt>.
* (which have the type: <tt>package: filename</tt>).
* The entries which are for the given package will be changed to represent the
* file location (i.e. the leading <tt>packageName: </tt> will be replaced by <tt>/</tt>).
* @param entry the entry to be fixed (it will be changed by this function)
* @param packageName the package to be matched against
* @returns false if the entry is not for the current package (i.e. does not start with packageName:)
* else true.
*/
bool fixEntry(QString& entry, const QString& packageName);
/** Widget where the search might be enterd. */
FilenameSearchInput* _pInputWidget;
/** The widget where the files will be shown in. */
FilenameView* _pFileView;
/** The widget where the search selected is shown in. */
FilenameFeedbackWidget* _pFilenameFeedbackWidget;
/** Holds a pointer to the pluginmanager which manages this pugin. */
IProvider* _pProvider;
/** This holds the result of the currently active search. */
std::set<string> _searchResult;
/** This timer is used to delay the evaluation of the search a little to avoid unneccessary operations
* e.g. on text input. */
QTimer* _pDelayTimer;
/** This is the delay time in ms the delay timer waits for another input. */
uint _delayTime;
/** The package where information for should be displayed. */
QString _currentPackage;
/** @brief Returns an error message reporting, that apt-file is missing, and required for
* retrieving file information for the given package.
*/
QString aptFileMissingErrorMsg(QString packageName);
};
} // namespace NPlugin
#endif // __FILENAMEPLUGIN_H_2004_06_21
|