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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
/*
* Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MK_BOXCONTAINERITEM_H
#define MK_BOXCONTAINERITEM_H
#include "accountmanager.h"
#include <dcopobject.h>
class KornMailSubject;
class KActionCollection;
class KConfig;
class KPopupMenu;
class KProcess;
class TQColor;
class TQLabel;
//template< class T > class TQPtrList;
class TQString;
/**
* This class provide a base for an item. This item should be
* shown in a BoxContainer, and represent one number somewhere.
* This also is the DCOP-interface for such a box.
* @author Mart Kelder <mart.kde@hccnet.nl>
*/
class BoxContainerItem : public AccountManager, public DCOPObject
{ Q_OBJECT
K_DCOP
public:
/**
* Standaard QObject-constuctor
* This constructor implements the default arguments for any TQObject.
* Note that is does not give a name to DCOPObject; that name
* is set in the readConfig-function.
* @param parent The parent of this object, See Object::QObject
* @param name The name of this object, See TQObject::QObject
* @see BoxContainerItem::readConfig
*/
BoxContainerItem( TQObject * parent = 0, const char * name = 0 );
/**
* The default destructor. This only removes _command-pointer.
*/
~BoxContainerItem();
/**
* If this function should call a "show"-function of its widget.
*/
virtual void showBox() = 0;
/**
* This function reads the config. It stores the readed values in the class.
* It also sets the DCOPObject-name.
* @param config The KConfigGroup-object which contains the configuration of this box.
* @param index The index of the box used in the config-file
*/
virtual void readConfig( KConfig* config, const int index );
public slots:
/**
* This functions sets the number to be displayed. It should be reimplemented.
* @param count The number of new messages waiting
* @param newMessages Are there any new messages added?
*/
virtual void setCount( const int count, const bool newMessages ) = 0;
/**
* This functions execute a given command
*
* @param cmd The command to be executed.
*/
virtual void runCommand( const TQString& cmd );
/**
* This function displays the (kde) help dialog
*/
void help();
/**
* This function calls a bug report dialog
*/
void reportBug();
/**
* This function calls the about dialog
*/
void about();
/**
* This functions should be called if a mouse-button has been pressed.
* This handles the connected events of it.
*
* @param button The button that was pressed, See Qt::ButtonState
*/
void mouseButtonPressed( Qt::ButtonState button );
protected:
/**
* This function filles a KPopupMenu-reference. The target is
* to set in all implementations the same KPopupMenu-content.
* Because some implementations (DockedItem) got a KPopupMenu
* by itself, this only changes a KPopupMenu instance.
* @param menu The menu to be changed.
* @param actions The actions to which the items should be added.
*/
void fillKPopupMenu( KPopupMenu* menu, KActionCollection* actions ) const;
/**
* This displays the passive popup.
*
* @param parent The Winget of the visual widget
* @param list List with the first (five) subjects
* @param total The total numbers of unread mail
* @param accountName The name of the account it belongs to
* @param date Should the date be displayed?
*/
void showPassivePopup( TQWidget* parent, TQPtrList< KornMailSubject >* list, int total, const TQString& accountName, bool date );
//this functions should be reimplemented
/**
* This function is called when the implementation of the class
* should display the popup-menu.
*/
virtual void doPopup() = 0;
/**
* This function draws a specified configuration into a label
* @param label The label to be filled
* @param count the number of new messages
* @param newMessages are the messages new?
*/
void drawLabel( TQLabel *label, const int count, const bool newMessages );
private:
/**
* This function helps to make a pixmap
* @param icon The icon to be set in
* @param fgColour the colour of the foreground
* @param font the font; 0 is default font.
* @param count the number of messages
*/
static TQPixmap calcComplexPixmap( const TQPixmap &icon, const TQColor& fgColour, const TQFont* font, const int count );
/**
* This functions sets a movie to a specified label
* @param label The label to set the movie in
* @param anim The path to the animation
*/
void setAnimIcon( TQLabel* label, const TQString& anim );
private slots:
void slotRecheck() { recheck(); }
void slotReset() { reset(); }
void slotView() { view(); }
void slotRunCommand() { runCommand(); }
void slotPopup() { popup(); }
void slotConfigure() { showConfig(); }
public:
k_dcop:
/**
* This call immediately checked all accounts of this box.
*/
void recheck();
/**
* This call reset the number of unread messages to 0.
*/
void reset();
/**
* This call popup's a window with the headers of the new messages.
*/
void view();
/**
* This program executes the command as setup'ed.
*/
void runCommand(); //Possible_unsafe?
/**
* This function lets the popup-menu's be displayed.
*/
void popup();
/**
* This function lets the user edit the configuration
*/
void showConfig();
/**
* With these DCOP-calls, a user can start and stop the accounts.
*/
void startTimer();
void stopTimer();
signals:
/**
* This signal is emitted when the user whants to configure something.
*/
void showConfiguration();
private slots:
/**
* This slot is called when a KProcess-instance needs to be deleted:)
* @param proc The instance of the instance which must be deleted.
*/
void processExited( KProcess* proc );
protected:
//This settings are stored here because every implementation needs them.
TQString *_icons[ 2 ];
TQString *_anims[ 2 ];
TQColor *_fgColour[ 2 ];
TQColor *_bgColour[ 2 ];
TQFont *_fonts[ 2 ];
private:
TQString *_command;
bool _recheckSettings[ 3 ];
bool _resetSettings[ 3 ];
bool _viewSettings[ 3 ];
bool _runSettings[ 3 ];
bool _popupSettings[ 3 ];
};
#endif //MK_BOXCONTAINERITEM_H
|