summaryrefslogtreecommitdiffstats
path: root/src/app/ActionMan/addplaceholderpopup.h
blob: c463daed80d9de352bfcba8ea86f255ea96025f4 (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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//
// C++ Interface: addplaceholderpopup
//
// Description: 
//
//
// Author: Shie Erlich and Rafi Yanai <>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef ADDPLACEHOLDERPOPUP_H
#define ADDPLACEHOLDERPOPUP_H

#include <tdepopupmenu.h>
#include <kdialogbase.h>
#include "../UserAction/expander.h"

class TQString;
class KLineEdit;
class TQToolButton;
class TQCheckBox;
class KComboBox;
class KrBookmarkButton;
class KURL;
class KIntSpinBox;


/**
 * This reads Expander::placeholder[] and fills a popup for easy access to the UserAction Placeholder
 * @author Jonas Bähr (http://www.jonas-baehr.de), Shie Erlich
 */
class AddPlaceholderPopup : public TDEPopupMenu {

public:
   AddPlaceholderPopup( TQWidget *parent );
   
   /**
    * Use this to exec the popup. 
    * @param pos Position where the popup should appear
    * @return the expression which can be placed in the UserAction commandline
    */
   TQString getPlaceholder( const TQPoint& pos );

protected:
   /**
    * This is calles when a Placeholder got parameter.
    * @param currentPlaceholder A pointer to the Placeholder the user has choosen
    * @return a parameter-string
    */
   TQString getParameter( exp_placeholder* currentPlaceholder );
   
private:
   TDEPopupMenu *_activeSub, *_otherSub, *_leftSub, *_rightSub, *_independentSub;
};


////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Parameter Widgets ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  abstract baseclass for all Parameter widgets
 * @author Jonas Bähr (http://www.jonas-baehr.de)
 */
class ParameterBase : public TQWidget {
public:
   inline ParameterBase( const exp_parameter& parameter, TQWidget* parent ) : TQWidget( parent ) { _nessesary = parameter.nessesary(); }
   /**
    * @return the text for the parameter
    */
   virtual TQString text() = 0;
   /**
    * @return the default of the parameter
    */
   virtual TQString preset() = 0;
   /**
    * re-init the parameter with the default
    */
   virtual void reset() = 0;
   /**
    * @return true if the Parameter as a valid value
    */
   virtual bool valid() = 0;
   /**
    * @return true if the Placeholder realy needs this parameter
    */
   inline bool nessesary() { return _nessesary; }
private:
   bool _nessesary;
};

/**
 *  The simple Parameter widgets: a line-edit with the description above
 *  used by default
 */
class ParameterText : public ParameterBase {
public:
   ParameterText( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KLineEdit * _lineEdit;
   TQString _preset;
};

/**
 *  A line-edit with the "addPlaceholder"-button
 *  used with default = "__placeholder"
 */
class ParameterPlaceholder : public ParameterBase {
TQ_OBJECT
  
public:
   ParameterPlaceholder( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KLineEdit * _lineEdit;
   TQToolButton* _button;
private slots:
   void addPlaceholder();
};

/**
 *  A Checkbox, default: checked; retuns "No" if unchecked
 *  used with default = "__yes"
 */
class ParameterYes : public ParameterBase {
public:
   ParameterYes( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   TQCheckBox* _checkBox;
};

/**
 *  A Checkbox, default: unchecked; retuns "Yes" if checked
 *  used with default = "__no"
 */
class ParameterNo : public ParameterBase {
public:
   ParameterNo( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   TQCheckBox* _checkBox;
};

/**
 *  A line-edit with the "file open"-button
 *  used with default = "__file"
 */
class ParameterFile : public ParameterBase {
TQ_OBJECT
  
public:
   ParameterFile( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KLineEdit * _lineEdit;
   TQToolButton* _button;
private slots:
   void addFile();
};

/**
 *  A ComboBox with the description above
 *  used with default = "__choose:item1;item2;..."
 */
class ParameterChoose : public ParameterBase {
public:
   ParameterChoose( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KComboBox * _combobox;
};

/**
 *  An editable ComboBox with the predifined selections
 *  used with default = "__select"
 */
class ParameterSelect : public ParameterBase {
public:
   ParameterSelect( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KComboBox * _combobox;
};

/**
 *  A line-edit with a "choose dir"- and a bookmark-button
 *  used with default = "__goto"
 */
class ParameterGoto : public ParameterBase {
TQ_OBJECT
  
public:
   ParameterGoto( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KLineEdit * _lineEdit;
   TQToolButton* _dirButton, *_placeholderButton;
private slots:
   void setDir();
   void addPlaceholder();
};

/**
 *  A ComboBox with all profiles available for the Synchronizer
 *  used with default = "__syncprofile"
 */
class ParameterSyncprofile : public ParameterBase {
public:
   ParameterSyncprofile( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KComboBox * _combobox;
};

/**
 *  A ComboBox with all profiles available for the panels
 *  used with default = "__panelprofile"
 */
class ParameterPanelprofile : public ParameterBase {
public:
   ParameterPanelprofile( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KComboBox * _combobox;
};

/**
 *  A ComboBox with all profiles available for the Searchmodule
 *  used with default = "__searchprofile"
 */
class ParameterSearch : public ParameterBase {
public:
   ParameterSearch( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KComboBox * _combobox;
};

/**
 *  A SpinBox for integer
 *  used with default = "__int:min;max;step;value"
 */
class ParameterInt : public ParameterBase {
public:
   ParameterInt( const exp_parameter& parameter, TQWidget* parent );
   TQString text();
   TQString preset();
   void reset();
   bool valid();
private:
   KIntSpinBox * _spinbox;
   int _default;
};

////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// ParameterDialog ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  Opens a dialog for the parameter. Depending on the default (preset) a differend widget is used.
 *  See Parameter-Classes for details
 */
class ParameterDialog : public KDialogBase {
TQ_OBJECT
  
public:
   ParameterDialog( const exp_placeholder* currentPlaceholder, TQWidget *parent );
   
   /**
    * Use this to execute the dialog.
    * @return a TQString with all paremeters; ommiting the optional ones if they have the default-value.
    */
   TQString getParameter();

private:
   typedef TQValueList<ParameterBase*> ParameterList;
   ParameterList _parameter;
   int _parameterCount;
private slots:
   void reset();
   void slotOk();
};


#endif // ADDPLACEHOLDERPOPUP_H