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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
/***************************************************************************
kmymoneycombo.h - description
-------------------
begin : Mon Mar 12 2007
copyright : (C) 2007 by Thomas Baumgart
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 KMYMONEYCOMBO_H
#define KMYMONEYCOMBO_H
// ----------------------------------------------------------------------------
// QT Includes
#include <tqtimer.h>
#include <tqmutex.h>
// ----------------------------------------------------------------------------
// KDE Includes
#include <kcombobox.h>
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/mymoneyutils.h>
#include <kmymoney/mymoneysplit.h>
#include <kmymoney/register.h>
#include <kmymoney/mymoneyaccount.h>
#include <kmymoney/transaction.h>
#include <kmymoney/mymoneypayee.h>
#include <kmymoney/mymoneytransactionfilter.h>
#include <kmymoney/mymoneyscheduled.h>
class kMyMoneyCompletion;
class KMyMoneySelector;
class kMyMoneyLineEdit;
/**
* @author Thomas Baumgart
*/
class KMyMoneyCombo : public KComboBox
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyCombo(TQWidget *w = 0, const char *name=0);
KMyMoneyCombo(bool rw, TQWidget *w = 0, const char *name=0);
/**
* This method is used to turn on/off the hint display and to setup the appropriate text.
* The hint text is shown in a lighter color if the field is otherwise empty and does
* not have the keyboard focus.
*
* @param hint reference to text. If @a hint is empty, no hint will be shown.
*/
void setHint(const TQString& hint) const;
/**
* overridden for internal reasons.
*
* @param editable make combo box editable (@a true) or selectable only (@a false).
*/
void setEditable(bool editable);
/**
* This method returns a pointer to the completion object of the combo box.
*
* @return pointer to kMyMoneyCompletion or derivative.
*/
kMyMoneyCompletion* completion(void) const;
/**
* This method returns a pointer to the completion object's selector.
*
* @return pointer to KMyMoneySelector or derivative.
*/
KMyMoneySelector* selector(void) const;
/**
* This method returns the ids of the currently selected items
*/
void selectedItems(TQStringList& list) const;
/**
* This method returns the id of the first selected item.
* Usage makes usually only sense when the selection mode
* of the associated KMyMoneySelector is TQListView::Single.
*
* @sa KMyMoneySelector::setSelectionMode()
*
* @param id reference to TQString containing the id. If no item
* is selected id will be empty.
*/
void selectedItem(TQString& id) const KDE_DEPRECATED;
/**
* This method returns the id of the first selected item.
* Usage makes usually only sense when the selection mode
* of the associated KMyMoneySelector is TQListView::Single.
*
* @sa KMyMoneySelector::setSelectionMode()
*
* @return reference to TQString containing the id. If no item
* is selected the TQString will be empty.
*/
const TQString& selectedItem(void) const { return m_id; }
/**
* This method selects the item with the respective @a id.
*
* @param id reference to TQString containing the id
*/
void setSelectedItem(const TQString& id);
/**
* This method checks if the position @a pos is part of the
* area of the drop down arrow.
*/
bool isInArrowArea(const TQPoint& pos) const;
void setSuppressObjectCreation(bool suppress) { m_canCreateObjects = !suppress; }
/**
* overridden for internal reasons, no API change
*/
void setCurrentText(const TQString& txt = TQString()) { KComboBox::setCurrentText(txt); }
/**
* overridden to set the background color of the lineedit as well
*/
void setPaletteBackgroundColor(const TQColor& color);
/**
* Overridden to support our own completion box
*/
TQSize tqsizeHint() const;
protected slots:
virtual void slotItemSelected(const TQString& id);
protected:
/**
* reimplemented to support our own popup widget
*/
void mousePressEvent(TQMouseEvent *e);
/**
* reimplemented to support our own popup widget
*/
void keyPressEvent(TQKeyEvent *e);
/**
* reimplemented to support our own popup widget
*/
void paintEvent(TQPaintEvent *);
/**
* reimplemented to support detection of new items
*/
void focusOutEvent(TQFocusEvent* );
/**
* set the widgets text area based on the item with the given @a id.
*/
virtual void setCurrentTextById(const TQString& id);
/**
* Overridden for internal reasons, no API change
*/
void connectNotify(const char* signal);
/**
* Overridden for internal reasons, no API change
*/
void disconnectNotify(const char* signal);
protected:
/**
* This member keeps a pointer to the object's completion object
*/
kMyMoneyCompletion* m_completion;
/**
* Use our own line edit to provide hint functionality
*/
kMyMoneyLineEdit* m_edit;
/**
* The currently selected item
*/
TQString m_id;
signals:
void itemSelected(const TQString& id);
void objectCreation(bool);
void createItem(const TQString&, TQString&);
private:
TQTimer m_timer;
TQMutex m_focusMutex;
/**
* Flag to control object creation. Use setSuppressObjectCreation()
* to modify it's setting. Defaults to @a false.
*/
bool m_canCreateObjects;
/**
* Flag to check whether a focusOutEvent processing is underway or not
*/
bool m_inFocusOutEvent;
};
/**
* @author Thomas Baumgart
* This class implements a combo box with the possible states for
* reconciliation.
*/
class KMyMoneyReconcileCombo : public KMyMoneyCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyReconcileCombo(TQWidget *w = 0, const char *name=0);
void setState(MyMoneySplit::reconcileFlagE state);
MyMoneySplit::reconcileFlagE state(void) const;
void removeDontCare(void);
protected slots:
void slotSetState(const TQString&);
};
/**
* @author Thomas Baumgart
* This class implements a combo box with the possible states for
* actions (Deposit, Withdrawal, etc.).
*
* @deprecated
*/
class KMyMoneyComboAction : public KMyMoneyCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyComboAction(TQWidget *w = 0, const char *name=0);
void setAction(int state);
int action(void) const;
void protectItem(int id, bool protect);
protected slots:
void slotSetAction(const TQString&);
signals:
void actionSelected(int);
};
/**
* @author Thomas Baumgart
* This class implements a combo box with the possible states for
* actions (Deposit, Withdrawal, etc.).
*/
class KMyMoneyCashFlowCombo : public KMyMoneyCombo
{
Q_OBJECT
TQ_OBJECT
public:
/**
* Create a combo box that contains the entries "Pay to", "From" and
* " " for don't care.
*/
KMyMoneyCashFlowCombo(TQWidget *w = 0, const char *name=0, MyMoneyAccount::accountTypeE type = MyMoneyAccount::Asset);
void setDirection(KMyMoneyRegister::CashFlowDirection dir);
KMyMoneyRegister::CashFlowDirection direction(void) const { return m_dir; }
void removeDontCare(void);
protected slots:
void slotSetDirection(const TQString& id);
signals:
void directionSelected(KMyMoneyRegister::CashFlowDirection);
private:
KMyMoneyRegister::CashFlowDirection m_dir;
};
/**
* @author Thomas Baumgart
* This class implements a combo box with the possible activities
* for investment transactions (buy, sell, dividend, etc.)
*/
class KMyMoneyActivityCombo : public KMyMoneyCombo
{
Q_OBJECT
TQ_OBJECT
public:
/**
* Create a combo box that contains the entries "Buy", "Sell" etc.
*/
KMyMoneyActivityCombo(TQWidget *w = 0, const char *name=0);
void setActivity(MyMoneySplit::investTransactionTypeE activity);
MyMoneySplit::investTransactionTypeE activity(void) const { return m_activity; }
protected slots:
void slotSetActivity(const TQString& id);
signals:
void activitySelected(MyMoneySplit::investTransactionTypeE);
private:
MyMoneySplit::investTransactionTypeE m_activity;
};
/**
* This class implements a text based payee selector.
* When initially used, the widget has the functionality of a KComboBox object.
* Whenever a key is pressed, the set of loaded payees is searched for
* payees names which match the currently entered text.
*
* If any match is found a list selection box is opened and the user can use
* the up/down, page-up/page-down keys or the mouse to navigate in the list. If
* a payee is selected, the selection box is closed. Other key-strokes are
* directed to the tqparent object to manipulate the text. The visible contents of
* the selection box is updated with every key-stroke.
*
* This object is a replacement of the kMyMoneyPayee object and should be used
* for new code.
*
* @author Thomas Baumgart
*/
class KMyMoneyPayeeCombo : public KMyMoneyCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyPayeeCombo(TQWidget* tqparent = 0, const char* name = 0);
void loadPayees(const TQValueList<MyMoneyPayee>& list);
};
class KMyMoneyGeneralCombo : public KComboBox
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyGeneralCombo(TQWidget* tqparent = 0, const char* name = 0);
virtual ~KMyMoneyGeneralCombo();
void insertItem(const TQString& txt, int id, int idx = -1);
void setItem(int id) KDE_DEPRECATED; // replace with setCurrentItem(id)
int item(void) const KDE_DEPRECATED; // replace with currentItem()
void setCurrentItem(int id);
int currentItem(void) const;
void removeItem(int id);
public slots:
void clear(void);
signals:
void itemSelected(int id);
protected:
// prevent the caller to use the standard KComboBox insertItem function with a default idx
void insertItem(const TQString&);
protected slots:
void slotChangeItem(int idx);
private:
/// \internal d-pointer class.
class Private;
/// \internal d-pointer instance.
Private* const d;
};
/**
* This class implements a time period selector
* @author Thomas Baumgart
*/
class KMyMoneyPeriodCombo : public KMyMoneyGeneralCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyPeriodCombo(TQWidget* tqparent = 0, const char* name = 0);
MyMoneyTransactionFilter::dateOptionE currentItem(void) const;
void setCurrentItem(MyMoneyTransactionFilter::dateOptionE id);
/**
* This function returns the actual start date for the given
* period definition given by @p id. For user defined periods
* the returned value is TQDate()
*/
static TQDate start(MyMoneyTransactionFilter::dateOptionE id);
/**
* This function returns the actual end date for the given
* period definition given by @p id. For user defined periods
* the returned value is TQDate()
*/
static TQDate end(MyMoneyTransactionFilter::dateOptionE id);
// static void dates(TQDate& start, TQDate& end, MyMoneyTransactionFilter::dateOptionE id);
};
/**
* This class implements an occurence selector
* as a tqparent class for both OccurencePeriod and Frequency combos
*
* @author Colin Wright
*/
class KMyMoneyOccurenceCombo : public KMyMoneyGeneralCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyOccurenceCombo(TQWidget* tqparent = 0, const char* name = 0);
MyMoneySchedule::occurenceE currentItem(void) const;
};
/**
* This class implements an occurence period selector
*
* @author Colin Wright
*/
class KMyMoneyOccurencePeriodCombo : public KMyMoneyOccurenceCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyOccurencePeriodCombo(TQWidget* tqparent = 0, const char* name = 0);
};
/**
* This class implements a payment frequency selector
* @author Thomas Baumgart
*/
class KMyMoneyFrequencyCombo : public KMyMoneyOccurenceCombo
{
Q_OBJECT
TQ_OBJECT
public:
KMyMoneyFrequencyCombo(TQWidget* tqparent = 0, const char* name = 0);
/**
* This method returns the number of events for the selected payment
* frequency (eg for yearly the return value is 1 and for monthly it
* is 12). In case, the frequency cannot be converted (once, every other year, etc.)
* the method returns 0.
*/
int eventsPerYear(void) const;
/**
* This method returns the number of days between two events of
* the selected frequency. The return value for months is based
* on 30 days and the year is 360 days long.
*/
int daysBetweenEvents(void) const;
};
#endif
|