summaryrefslogtreecommitdiffstats
path: root/quanta/plugins/quantaplugin.h
blob: 5f022797d7a819ddafd652b44b04e6d877772882 (plain)
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
/***************************************************************************
                          quantaplugin.h  -  description
                             -------------------
    begin                : Mon Sep 16 2002
    copyright            : (C) 2002 by Marc Britton <consume@optushome.com.au>
                           (C) 2003-2004 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef QUANTAPLUGIN_H
#define QUANTAPLUGIN_H

/* KDE INCLUDES */
#include <tdeparts/part.h>

/* QT INCLUDES */
#include <tqguardedptr.h>
#include <tqobject.h>

class TQString;

/**Base class for quanta plugins
  *@author Marc Britton
  */

class TDEToggleAction;
class KMdiToolViewAccessor;

class QuantaView;

class QuantaPlugin : public TQObject
{
  Q_OBJECT
  
public:
  QuantaPlugin();
  ~QuantaPlugin();
  virtual bool isRunning() const;
  /** Gets the superficial plugin name */
  virtual TQString pluginName() const;
  /** Gets the location of the plugin */
  virtual TQString location() const;
  /** Gets the plugin's standard attribute */
  virtual bool isStandard() const;
  /** Gets the output window */
  virtual TQString outputWindow() const;
  /** Returns true if the plugin specified by a_plugin is valid, false otherwise */
  static bool validatePlugin(QuantaPlugin *);
  /** Returns true if the options of a plugin are valid, otherwise false */
  static bool validatePluginInfo(const TQString &, const TQString &,
              const TQString &, const TQString &);

  virtual void addWidget();
  virtual void removeWidget();
  TQWidget *widget();
  KParts::ReadOnlyPart *part() {return m_part;}
  TQString name() {return m_name;}
  /** plugs action into menu */
  void plugAction(TQPopupMenu *menu);
public slots:
  /** Sets whether the plugin is running or not */
  virtual void setRunning(bool);
  /** Loads the plugin */
  virtual bool load();
  /** Unloads te plugin. If remove is true, it will also remove the plugin widget. */
  virtual bool unload(bool remove = true);
  /** Runs the plugin */
  virtual bool run();
  /** Runs the plugin if it's not running yet, unloads otherwise.*/
  virtual bool toggle();
  /** Sets the superficial name of the plugin */
  virtual void setPluginName(const TQString &);
  /** Sets the output window */
  virtual void setOutputWindow(const TQString &);
  /** Sets the plugin's standard attribute */
  virtual void setStandard(bool isStandard);
  /** Sets the location of the plugin */
  virtual void setLocation(const TQString &);
  /** Sets the file name of the plugin */
  virtual void setFileName(const TQString &);
  /** Returns the file name of the plugin */
  virtual TQString fileName() const;
  virtual int input() {return m_input;}
  virtual void setInput(int a_input) { m_input = a_input;}
  /** Returns whether the plugin is loaded or not */
  virtual bool isLoaded();
  /** No descriptions */
  void setIcon(const TQString& a_icon);
  /** No descriptions */
  TQString icon();
  /** No descriptions */
  void setStandardName(const TQString& a_stdName);
  /** No descriptions */
  TQString standardName();
  void setReadOnlyPart(bool a_readOnlyPart) {m_readOnlyPart = a_readOnlyPart;}
  bool readOnlyPart() {return m_readOnlyPart;}
signals:
  void pluginStarted();
  void pluginStopped();
protected:
  /** Superficial name of plugin */
  TQString m_fileName;
  TQString m_name;
  TQString m_location;
  TQString m_icon;
  TQString m_outputWindow;
  int m_input;
  /** True, if it is not a user added plugin. Special handling code may be necessary for standard plugins. */
  bool m_standard;
  bool m_isRunning;
  TQGuardedPtr<KParts::ReadOnlyPart> m_part;
  bool m_readOnlyPart;
  QuantaView *m_view;
  TDEToggleAction *m_action;
private: // Private attributes
  TQString m_standardName;
  KMdiToolViewAccessor* m_pluginToolView;
  TQWidget *m_targetWidget; //this will be the parent, used only to make the plugin widget hidden until addWidget is called
};

#endif