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
|
/***************************************************************************
kmymoneycategory.h
-------------------
begin : Mon Jul 10 2006
copyright : (C) 2006 by Thomas Baumgart
email : Thomas Baumgart <ipwizard@users.sourceforge.net>
***************************************************************************/
/***************************************************************************
* *
* 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 KMYMONEYCATEGORY_H
#define KMYMONEYCATEGORY_H
// ----------------------------------------------------------------------------
// QT Includes
class TQWidget;
class TQFrame;
// ----------------------------------------------------------------------------
// KDE Includes
#include <kcombobox.h>
class KPushButton;
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/mymoneyaccount.h>
#include <kmymoney/kmymoneycombo.h>
class kMyMoneyAccountSelector;
/**
* This class implements a text based account/category selector.
* When initially used, the widget has the functionality of a KComboBox object.
* Whenever a key is pressed, the set of loaded accounts is searched for
* accounts 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
* an account is selected, the selection box is closed. Other key-strokes are
* directed to the parent 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 kMyMoneyCategory object and should be used
* for new code.
*
* @author Thomas Baumgart
*/
class KMyMoneyCategory : public KMyMoneyCombo
{
TQ_OBJECT
public:
/**
* Standard constructor for the account selection object.
*
* If parameter @a splitButton is @a true, the widget
* will construct a surrounding TQFrame and reparent itself to be a child of this
* TQFrame. It also adds a KPushButton with the "Split" icon to the right of the
* input field. In this case it is important not to use the pointer to this widget
* but it's parent when placing the object in a TQLayout, TQTable or some such. The
* parent widget (the TQFrame in this case) can be extracted with the parentWidget()
* method.
*
* Reparenting is handled by the object transparently for both cases.
*
* Standard usage example (no split button):
*
* @code
* KMyMoneyCategory* category = new KMyMoneyCategory;
* category->reparent(newParent);
* layout->addWidget(category);
* table->setCellWidget(category);
* @endcode
*
* Enhanced usage example (with split button):
*
* @code
* KMyMoneyCategory* category = new KMyMoneyCategory(0, 0, true);
* category->reparent(newParent);
* layout->addWidget(category->parentWidget());
* table->setCellWidget(category->parentWidget());
* @endcode
*/
KMyMoneyCategory(TQWidget* parent = 0, const char* name = 0, bool splitButton = false);
virtual ~KMyMoneyCategory();
/**
* This member returns a pointer to the completion object.
*
* @return pointer to completion's selector object
*/
kMyMoneyAccountSelector* selector(void) const;
/**
* This member returns a pointer to the split button. In case the @a splitButton parameter
* of the constructor was @a false, this method prints a warning to stderr and returns 0.
*/
KPushButton* splitButton(void) const;
/**
* Reimplemented for internal reasons. No API change
*/
virtual void reparent( TQWidget *parent, WFlags, const TQPoint &, bool showIt = FALSE );
/**
* Reimplemented for internal reasons. No API change.
*/
virtual void setPalette(const TQPalette& palette);
/**
* Force the text field to show the text for split transaction.
*/
void setSplitTransaction(void);
/**
* Check if the text field contains the text for a split transaction
*/
bool isSplitTransaction(void) const;
/**
* overridden for internal reasons, no API change
*/
void setCurrentText(const TQString& txt = TQString()) { KMyMoneyCombo::setCurrentText(txt); }
protected:
/**
* Reimplemented to support protected category text ("split transactions")
*
* @sa focusIn()
*/
virtual void focusInEvent(TQFocusEvent* ev);
/**
* Reimplemented to support protected category text ("split transactions")
*/
virtual void focusOutEvent(TQFocusEvent* ev);
/**
* set the widgets text area based on the item with the given @a id.
*/
virtual void setCurrentTextById(const TQString& id);
public slots:
virtual void slotItemSelected(const TQString& id);
virtual void setEnabled(bool);
virtual void setDisabled(bool);
signals:
/**
* Signal to inform other objects that this object has reached focus.
* Used for e.g. to open the split dialog when the focus reaches this
* object and it contains the text 'Split transaction'.
*
* @sa focusInEvent()
*/
void focusIn(void);
private:
/// \internal d-pointer class.
class Private;
/// \internal d-pointer instance.
Private* const d;
};
class KMyMoneySecurity : public KMyMoneyCategory
{
TQ_OBJECT
public:
KMyMoneySecurity(TQWidget* parent = 0, const char* name = 0);
virtual ~KMyMoneySecurity();
/**
* overridden for internal reasons, no API change
*/
void setCurrentText(const TQString& txt = TQString()) { KMyMoneyCategory::setCurrentText(txt); }
protected:
/**
* set the widgets text area based on the item with the given @a id.
*/
virtual void setCurrentTextById(const TQString& id);
};
#endif
|