summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/pobject.h
blob: ef1589b3b06e613b26607564598b4db46f9ff587 (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
130
131
132
133
134
135
#ifndef POBJECT_H
#define POBJECT_H

class PObject;
class PukeController;
class CreateArgs;

#include <tqobject.h>
#include "pmessage.h"


class CreateArgs {
public:
  CreateArgs(PukeController *_pc, PukeMessage *_pm, widgetId *_pwI, PObject *_parent){
    pc = _pc;
    pwI = _pwI;
    tqparent = _parent;
    pm = _pm;
    fetchedObj = 0;
  }
  PukeController *pc;
  widgetId *pwI;
  PObject *tqparent;
  PukeMessage *pm;

  /**
   * name of the widget which was fetched from kSirc, this has to be set explicitly
   */
  TQObject *fetchedObj;
};

class PObject : public TQObject
{
  Q_OBJECT
  TQ_OBJECT
 public:
  PObject(TQObject *tqparent = 0, const char *name = 0);
  virtual ~PObject();

  /**
   * Creates a new TQObject and returns a PObject
   */
  static PObject *createWidget(CreateArgs &ca);

  /**
   * Handles messages from dsirc
   * PObject can't get messages so return an error
   */
  virtual void messageHandler(int fd, PukeMessage *pm);

  /**
   * Sets the current opbect
   */
  virtual void setWidget(TQObject *w);
  
  /**
   * Returns the current object
   */
  virtual TQObject *widget();

  /**
   * Sets the window id
   */
  virtual void setWidgetId(widgetId *pwI);
  /**
   * Returns the current window identifier
   */
  virtual widgetId widgetIden();

  /**
   * Set's the puke controller for the widget
   */
  void setPukeController(PukeController *pc){
    pController = pc;
  }

  /**
   * If we cannot delete the widget, check this (ie fetched widgets)
   */
  bool isDeleteAble(){
      return deleteAble;
  }

  /**
   * Returns if an error was encountered.
   */
  bool hasError() { 
      return m_hasError;
  }

  /**
   * Returns error description
   */
  TQString error() {
      m_hasError = false;
      return m_error;
  }

  /**
   * Set this for fetched widgets and such that cannot be deleted
   */
  void setDeleteAble(bool _d){
      deleteAble = _d;
  }
  /**
   * Before deleting the widget, call manTerm() to signal manual
   * termination of the widget
   */
  void manTerm();
   

 signals:
  void outputMessage(int fd, PukeMessage *pm);
  void widgetDestroyed(widgetId wI);

 protected slots:
   void swidgetDestroyed();

protected:
  PukeController *controller();
  void errorInvalidSet(TQObject *_w);

private:
  TQObject *obj;
  PukeController *pController;
  widgetId wI;

  bool manualTerm;
  bool deleteAble;
  TQString m_error;
  bool m_hasError;
};

#include "controller.h"
#endif