KVIrc  4.9.2
DeveloperAPIs
KviSelectors.h
Go to the documentation of this file.
1 #ifndef _KVI_SELECTORS_H_
2 #define _KVI_SELECTORS_H_
3 
4 //=============================================================================
5 //
6 // File : KviSelectors.h
7 // Creation date : Mon Now 13 2000 15:21:10 CEST by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "kvi_settings.h"
29 #include "KviCString.h"
30 #include "KviPixmap.h"
31 #include "KviTalHBox.h"
32 #include "KviTalVBox.h"
33 #include "KviTalListWidget.h"
34 
35 #include <QTreeWidget>
36 #include <QScrollArea>
37 #include <QCheckBox>
38 #include <QLineEdit>
39 #include <QLabel>
40 #include <QPushButton>
41 #include <QColor>
42 #include <QFont>
43 #include <QSpinBox>
44 #include <QStringList>
45 #include <QValidator>
46 
48 {
49 public:
51  virtual ~KviSelectorInterface(){};
52 
53 public:
54  virtual void commit(){};
55  virtual QString textForSearch() { return QString(); };
56  virtual QWidget * widgetToHighlight() { return 0; };
57 };
58 
59 class KVIRC_API KviBoolSelector : public QCheckBox, public KviSelectorInterface
60 {
61  Q_OBJECT
62 public:
63  KviBoolSelector(QWidget * par, const QString & txt, bool * pOption, bool bEnabled);
65 
66 private:
67  bool * m_pOption;
68 
69 public:
70  virtual void commit();
71  QString textForSearch() { return text(); };
72  QWidget * widgetToHighlight() { return (QWidget *)this; };
73 public slots:
74  void setNotEnabled(bool bNotEnabled);
75  void setEnabled(bool bEnabled);
76 };
77 
79 {
80  Q_OBJECT
81 public:
82  KviStringSelector(QWidget * par, const QString & txt, QString * pOption, bool bEnabled);
84 
85 protected:
86  QLabel * m_pLabel;
87  QLineEdit * m_pLineEdit;
88  QString * m_pOption;
89 
90 public:
91  void setValidator(QValidator * v) { m_pLineEdit->setValidator(v); };
92  void setMinimumLabelWidth(unsigned int uWidth) { m_pLabel->setMinimumWidth(uWidth); };
93  virtual void commit();
94  void setText(const QString & text);
95  QString textForSearch() { return m_pLabel->text(); };
96  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
97  QLineEdit * lineEdit() { return m_pLineEdit; };
98  QString currentText() { return m_pLineEdit->text(); };
99 public slots:
100  virtual void setEnabled(bool bEnabled);
101 };
102 
104 {
105  Q_OBJECT
106 public:
107  KviPasswordSelector(QWidget * par, const QString & txt, QString * pOption, bool bEnabled);
109 
110 protected:
111  QLabel * m_pLabel;
112  QString textForSearch() { return m_pLabel->text(); };
113  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
114  QLineEdit * m_pLineEdit;
115  QCheckBox * m_pCheckBox;
116  QString * m_pOption;
117 
118 public:
119  void setValidator(QValidator * v) { m_pLineEdit->setValidator(v); };
120  void setMinimumLabelWidth(unsigned int uWidth) { m_pLabel->setMinimumWidth(uWidth); };
121  virtual void commit();
122  void setText(const QString & text);
123 public slots:
124  virtual void setEnabled(bool bEnabled);
125 protected slots:
126  void checkToggled(int state);
127 };
128 
130 {
131  Q_OBJECT
132 public:
133  KviPasswordLineEdit(QWidget * par);
135 
136 protected:
137  QLineEdit * m_pLineEdit;
138  QCheckBox * m_pCheckBox;
139 
140 public:
141  QString text();
142  void setText(const QString & text);
143 public slots:
144  virtual void setEnabled(bool bEnabled);
145 protected slots:
146  void checkToggled(int state);
147 };
148 
149 class KVIRC_API KviPixmapPreview : public QScrollArea
150 {
151  Q_OBJECT
152 public:
153  KviPixmapPreview(QWidget * par);
154  ~KviPixmapPreview();
155 
156 protected:
157  QLabel * m_pLabPixmap;
158 
159 public:
160  void setPixmap(KviPixmap * pix);
161 };
162 
163 class KVIRC_API KviPixmapSelector : public QWidget, public KviSelectorInterface
164 {
165  Q_OBJECT
166 public:
167  KviPixmapSelector(QWidget * par, const QString & txt, KviPixmap * pOption, bool bEnabled);
169 
170 private:
171  QCheckBox * m_pCheckBox;
174  QPushButton * m_pChooseButton;
177 
178 public:
179  void setImagePath(const QString & path);
180  virtual void commit();
181  virtual void setEnabled(bool bEnabled);
182 protected slots:
183  void checkBoxToggled(bool bEnabled);
184  void choosePixmap();
185 };
186 
188 {
189  Q_OBJECT
190 public:
191  KviUIntSelector(QWidget * par, const QString & txt, unsigned int * pOption,
192  unsigned int uLowBound, unsigned int uHighBound, unsigned int uDefault, bool bEnabled, bool bShortInt = false);
194 
195 private:
196  QLabel * m_pLabel;
197 
198  QSpinBox * m_pSpinBox;
199  unsigned int * m_pOption;
200  unsigned int m_uLowBound;
201  unsigned int m_uHighBound;
202  unsigned int m_uDefault;
204 
205 public:
206  QString textForSearch() { return m_pLabel->text(); };
207  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
208  virtual void setPrefix(const QString & txt);
209  virtual void setSuffix(const QString & txt);
210  virtual void commit();
211 public slots:
212  virtual void setEnabled(bool bEnabled);
213 };
214 
215 class KVIRC_API KviFileSelector : public QWidget, public KviSelectorInterface
216 {
217  Q_OBJECT
218  Q_PROPERTY(QString tmpFile READ tmpFile WRITE setTmpFile)
219 public:
220  KviFileSelector(QWidget * par, const QString & txt, QString * pOption, bool bEnabled, unsigned int uFlags = 0, const QString & szFilter = QString());
222 
223 public:
224  enum Flags
225  {
226  ChooseSaveFileName = 1,
227  DontConfirmOverwrite = 2,
228  VerticalLayout = 4
229  };
230 
231 protected:
232  QLabel * m_pLabel;
233  QLineEdit * m_pLineEdit;
234  QPushButton * m_pButton;
235  QString * m_pOption;
236  unsigned int m_uFlags;
237  QString m_szFilter;
238  QGridLayout * m_Layout;
239 
240 public:
241  QString tmpFile() { return m_pLineEdit->text(); };
242  void setTmpFile(QString & szFile) { m_pLineEdit->setText(szFile); };
243  virtual void commit();
244  void setSelection(const QString & szSelection);
245 signals:
246  void selectionChanged(const QString & szNewValue);
247 public slots:
248  virtual void setEnabled(bool bEnabled);
249 private slots:
250  void browseClicked();
251 
252 protected:
253  virtual void select();
254 };
255 
257 {
258  Q_OBJECT
259 public:
260  KviDirectorySelector(QWidget * par, const QString & txt, QString * pOption, bool bEnabled, unsigned int uFlags = 0);
262 
263 protected:
264  virtual void select();
265 };
266 
268 {
269  Q_OBJECT
270 public:
271  KviColorSelector(QWidget * par, const QString & txt, QColor * pOption, bool bEnabled);
273 
274 private:
275  QLabel * m_pLabel;
276  QColor * m_pOption;
277  QColor m_memColor;
278  QPushButton * m_pButton;
279 
280 public:
281  QString textForSearch() { return m_pLabel->text(); };
282  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
283  virtual void commit();
284  QColor getColor() { return m_memColor; };
285  void forceColor(QColor clr);
286 
287 private:
288  void setButtonPalette(QColor * pOption);
289 private slots:
290  void changeClicked();
291 public slots:
292  virtual void setEnabled(bool bEnabled);
293 };
294 
296 {
297  Q_OBJECT
298 public:
299  KviFontSelector(QWidget * par, const QString & txt, QFont * pOption, bool bEnabled);
301 
302 private:
303  QLabel * m_pLabel;
304  QFont * m_pOption;
305  QPushButton * m_pButton;
306 
307 public:
308  virtual void commit();
309  QString textForSearch() { return m_pLabel->text(); };
310  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
311 private:
312  void setButtonFont(QFont * pOption);
313 public slots:
314  virtual void setEnabled(bool bEnabled);
315 private slots:
316  void changeClicked();
317 };
318 
320 {
321  Q_OBJECT
322 public:
323  KviStringListSelector(QWidget * par, const QString & txt, QStringList * pOption, bool bEnabled);
325 
326 private:
327  QLabel * m_pLabel;
329  QLineEdit * m_pLineEdit;
330  QPushButton * m_pAddButton;
331  QPushButton * m_pRemoveButton;
332  QStringList * m_pOption;
333 
334 public:
335  virtual void commit();
336  QString textForSearch() { return m_pLabel->text(); };
337  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
338 public slots:
339  virtual void setEnabled(bool bEnabled);
340 private slots:
341  void textChanged(const QString & str);
342  void itemSelectionChanged();
343  void addClicked();
344  void removeClicked();
345 };
346 
347 class QMenu;
348 
350 {
351  Q_OBJECT
352 public:
353  KviMircTextColorSelector(QWidget * par, const QString & txt, unsigned int * uFore, unsigned int * uBack, bool bEnabled);
355 
356 private:
357  QLabel * m_pLabel;
358  QPushButton * m_pButton;
359  unsigned int * m_pUFore;
360  unsigned int * m_pUBack;
361  unsigned int m_uFore;
362  unsigned int m_uBack;
364  QMenu * m_pForePopup;
365  QMenu * m_pBackPopup;
366 
367 public:
368  virtual void commit();
369  virtual void setEnabled(bool bEnabled);
370 protected slots:
371  void buttonClicked();
372  void foreSelected(QAction * pAction);
373  void backSelected(QAction * pAction);
374 
375 protected:
376  void setButtonPalette();
377 };
378 
380 {
381  Q_OBJECT
382 public:
383  KviSoundSelector(QWidget * par, const QString & txt, QString * pOption, bool bEnabled);
384  ~KviSoundSelector();
385 
386 protected:
387  QPushButton * m_pPlayButton;
388 private slots:
389  void playSound();
390 
391 public:
392  virtual void setEnabled(bool bEnabled);
393 };
394 
395 class KVIRC_API KviChanTreeViewItem : public QTreeWidgetItem
396 {
397 private:
398  QString m_szPass;
399 
400 public:
401  KviChanTreeViewItem(QTreeWidget * pList, QString szChan, QString szPass);
403 
404  const QString & pass() { return m_szPass; }
405 };
406 
408 {
409  Q_OBJECT
410 public:
411  KviChannelListSelector(QWidget * par, const QString & txt, QStringList * pOption, bool bEnabled);
413 
414 private:
415  QLabel * m_pLabel;
416  QTreeWidget * m_pTreeWidget;
417  QLineEdit * m_pChanLineEdit;
418  QLineEdit * m_pPassLineEdit;
419  QPushButton * m_pAddButton;
420  QPushButton * m_pRemoveButton;
421  QStringList * m_pOption;
422 
423 public:
424  virtual void commit();
425  QString textForSearch() { return m_pLabel->text(); };
426  QWidget * widgetToHighlight() { return (QWidget *)m_pLabel; };
427  virtual void setEnabled(bool bEnabled);
428 private slots:
429  void textChanged(const QString & str);
430  void itemSelectionChanged();
431  void addClicked();
432  void removeClicked();
433 };
434 
435 #endif
QPushButton * m_pRemoveButton
Definition: KviSelectors.h:420
QPushButton * m_pAddButton
Definition: KviSelectors.h:419
Definition: KviTalListWidget.h:35
Toolkit Abstraction Layer: hbox class.
Definition: KviTalHBox.h:44
QFont * m_pOption
Definition: KviSelectors.h:304
Definition: KviSelectors.h:215
QPushButton * m_pButton
Definition: KviSelectors.h:305
KviPixmapPreview * m_pPreview
Definition: KviSelectors.h:173
Definition: KviSelectors.h:395
QWidget * widgetToHighlight()
Definition: KviSelectors.h:207
QLineEdit * lineEdit()
Definition: KviSelectors.h:97
Definition: KviSelectors.h:59
void setMinimumLabelWidth(unsigned int uWidth)
Definition: KviSelectors.h:120
QLineEdit * m_pLineEdit
Definition: KviSelectors.h:329
#define KVIRC_API
Definition: kvi_settings.h:128
const QString & pass()
Definition: KviSelectors.h:404
QLabel * m_pLabel
Definition: KviSelectors.h:232
QLabel * m_pFileNameLabel
Definition: KviSelectors.h:172
KviTalListWidget * m_pListWidget
Definition: KviSelectors.h:328
Class for horizontal box.
QLineEdit * m_pPassLineEdit
Definition: KviSelectors.h:418
QString textForSearch()
Definition: KviSelectors.h:425
Class for vertical box.
QString tmpFile()
Definition: KviSelectors.h:241
QLabel * m_pLabel
Definition: KviSelectors.h:111
QLineEdit * m_pLineEdit
Definition: KviSelectors.h:233
Definition: KviSelectors.h:149
QString textForSearch()
Definition: KviSelectors.h:95
unsigned int m_uLowBound
Definition: KviSelectors.h:200
QLabel * m_pLabPixmap
Definition: KviSelectors.h:157
QString textForSearch()
Definition: KviSelectors.h:336
QLabel * m_pLabel
Definition: KviSelectors.h:327
QLineEdit * m_pLineEdit
Definition: KviSelectors.h:87
QGridLayout * m_Layout
Definition: KviSelectors.h:238
KviPixmap * m_pOption
Definition: KviSelectors.h:175
QWidget * widgetToHighlight()
Definition: KviSelectors.h:426
QLineEdit * m_pLineEdit
Definition: KviSelectors.h:137
Definition: KviSelectors.h:163
QMenu * m_pContextPopup
Definition: KviSelectors.h:363
QPushButton * m_pAddButton
Definition: KviSelectors.h:330
QWidget * widgetToHighlight()
Definition: KviSelectors.h:310
~KviUIntSelector()
Definition: KviSelectors.h:193
Definition: KviSelectors.h:349
~KviFontSelector()
Definition: KviSelectors.h:300
QLineEdit * m_pChanLineEdit
Definition: KviSelectors.h:417
QColor m_memColor
Definition: KviSelectors.h:277
Definition: KviPixmap.h:33
~KviChanTreeViewItem()
Definition: KviSelectors.h:402
QLabel * m_pLabel
Definition: KviSelectors.h:86
unsigned int m_uFore
Definition: KviSelectors.h:361
QMenu * m_pForePopup
Definition: KviSelectors.h:364
QString textForSearch()
Definition: KviSelectors.h:71
void setTmpFile(QString &szFile)
Definition: KviSelectors.h:242
virtual void select()
Definition: KviSelectors.cpp:444
QCheckBox * m_pCheckBox
Definition: KviSelectors.h:171
QSpinBox * m_pSpinBox
Definition: KviSelectors.h:198
QPushButton * m_pRemoveButton
Definition: KviSelectors.h:331
QString textForSearch()
Definition: KviSelectors.h:309
Definition: KviSelectors.h:78
QString textForSearch()
Definition: KviSelectors.h:112
unsigned int * m_pUFore
Definition: KviSelectors.h:359
QString * m_pOption
Definition: KviSelectors.h:235
QLabel * m_pLabel
Definition: KviSelectors.h:415
QString textForSearch()
Definition: KviSelectors.h:206
Definition: KviSelectors.h:47
QPushButton * m_pPlayButton
Definition: KviSelectors.h:387
Definition: KviSelectors.h:256
QCheckBox * m_pCheckBox
Definition: KviSelectors.h:115
QStringList * m_pOption
Definition: KviSelectors.h:332
void setMinimumLabelWidth(unsigned int uWidth)
Definition: KviSelectors.h:92
QCheckBox * m_pCheckBox
Definition: KviSelectors.h:138
QColor * m_pOption
Definition: KviSelectors.h:276
QPushButton * m_pChooseButton
Definition: KviSelectors.h:174
Flags
Definition: KviSelectors.h:224
Definition: KviSelectors.h:407
Definition: KviSelectors.h:103
unsigned int m_uBack
Definition: KviSelectors.h:362
QPushButton * m_pButton
Definition: KviSelectors.h:278
KviSelectorInterface()
Definition: KviSelectors.h:50
Definition: KviSelectors.h:129
Toolkit Abstraction Layer: vbox class.
Definition: KviTalVBox.h:44
QString textForSearch()
Definition: KviSelectors.h:281
QWidget * widgetToHighlight()
Definition: KviSelectors.h:96
QWidget * widgetToHighlight()
Definition: KviSelectors.h:113
Definition: KviSelectors.h:379
~KviFileSelector()
Definition: KviSelectors.h:221
QString * m_pOption
Definition: KviSelectors.h:88
virtual void commit()
Definition: KviSelectors.h:54
QWidget * widgetToHighlight()
Definition: KviSelectors.h:72
QMenu * m_pBackPopup
Definition: KviSelectors.h:365
virtual QWidget * widgetToHighlight()
Definition: KviSelectors.h:56
KviPixmap m_localPixmap
Definition: KviSelectors.h:176
virtual ~KviSelectorInterface()
Definition: KviSelectors.h:51
QString m_szPass
Definition: KviSelectors.h:398
QPushButton * m_pButton
Definition: KviSelectors.h:234
QString currentText()
Definition: KviSelectors.h:98
unsigned int * m_pUBack
Definition: KviSelectors.h:360
Definition: KviSelectors.h:295
Definition: KviSelectors.h:267
virtual void setEnabled(bool bEnabled)
Definition: KviSelectors.cpp:426
QWidget * widgetToHighlight()
Definition: KviSelectors.h:337
~KviBoolSelector()
Definition: KviSelectors.h:64
unsigned int m_uFlags
Definition: KviSelectors.h:236
QTreeWidget * m_pTreeWidget
Definition: KviSelectors.h:416
This file contains compile time settings.
void setValidator(QValidator *v)
Definition: KviSelectors.h:119
#define v
Definition: detector.cpp:86
unsigned int m_uDefault
Definition: KviSelectors.h:202
QString * m_pOption
Definition: KviSelectors.h:116
QColor getColor()
Definition: KviSelectors.h:284
Definition: KviSelectors.h:319
unsigned int m_uHighBound
Definition: KviSelectors.h:201
QLabel * m_pLabel
Definition: KviSelectors.h:357
bool m_bIsShortInt
Definition: KviSelectors.h:203
QPushButton * m_pButton
Definition: KviSelectors.h:358
unsigned int * m_pOption
Definition: KviSelectors.h:199
virtual QString textForSearch()
Definition: KviSelectors.h:55
QString m_szFilter
Definition: KviSelectors.h:237
~KviDirectorySelector()
Definition: KviSelectors.h:261
Definition: KviSelectors.h:187
QStringList * m_pOption
Definition: KviSelectors.h:421
~KviColorSelector()
Definition: KviSelectors.h:272
void setValidator(QValidator *v)
Definition: KviSelectors.h:91
QWidget * widgetToHighlight()
Definition: KviSelectors.h:282