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
|
/***************************************************************************
kmymoneysplittable.h - description
-------------------
begin : Thu Jan 10 2002
copyright : (C) 2000-2002 by Michael Edwardes
email : [email protected]
Javier Campos Morales <[email protected]>
Felix Rodriguez <[email protected]>
John C <[email protected]>
Thomas Baumgart <[email protected]>
Kevin Tambascio <[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 KMYMONEYSPLITTABLE_H
#define KMYMONEYSPLITTABLE_H
// ----------------------------------------------------------------------------
// QT Includes
#include <tqwidget.h>
#include <tqtable.h>
#include <tqwidgetlist.h>
#include <tqguardedptr.h>
// ----------------------------------------------------------------------------
// KDE Includes
class KPopupMenu;
class KPushButton;
// ----------------------------------------------------------------------------
// Project Includes
#include "../mymoney/mymoneytransaction.h"
#include "../mymoney/mymoneyaccount.h"
class KMyMoneyCategory;
class kMyMoneyLineEdit;
class kMyMoneyEdit;
/**
* @author Thomas Baumgart
*/
class kMyMoneySplitTable : public TQTable
{
Q_OBJECT
TQ_OBJECT
public:
kMyMoneySplitTable(TQWidget *parent=0, const char *name=0);
virtual ~kMyMoneySplitTable();
void paintCell(TQPainter *p, int row, int col, const TQRect& r, bool /*selected*/);
void paintFocus(TQPainter *p, const TQRect &cr);
/**
* This method is used to load the widget with the information about
* the transaction @p t. The split referencing the account @p acc is
* not shown in the widget.
*
* @param t reference to transaction to be shown/modified
* @param s reference to split that is to be hidden
* @param acc reference to account
*/
void setTransaction(const MyMoneyTransaction& t, const MyMoneySplit& s, const MyMoneyAccount& acc);
/**
* This method is used to retrieve the transaction from the widget.
*/
const MyMoneyTransaction& transaction(void) const { return m_transaction; }
/**
* Returns a list of MyMoneySplit objects. It contains all but the one
* referencing the account passed in setTransaction().
*
* @param t reference to transaction
* @return list of splits
*/
const TQValueList<MyMoneySplit> getSplits(const MyMoneyTransaction& t) const;
void setup(const TQMap<TQString, MyMoneyMoney>& priceInfo);
protected:
void contentsMousePressEvent( TQMouseEvent* e );
void contentsMouseReleaseEvent( TQMouseEvent* e );
void contentsMouseDoubleClickEvent( TQMouseEvent* e );
bool eventFilter(TQObject *o, TQEvent *e);
void endEdit(int row, int col, bool accept, bool replace );
void resizeEvent(TQResizeEvent*);
TQWidget* createEditWidgets(void);
void destroyEditWidgets(void);
/**
* This method handles the focus of the keyboard. When in edit mode
* (m_editCategory widget is visible) the keyboard focus is handled
* according to the widgets that are referenced in m_tabOrderWidgets.
* If not in edit mode, the base class functionality is provided.
*
* @param next true if forward-tab, false if backward-tab was
* pressed by the user
*/
virtual bool focusNextPrevChild(bool next);
void addToTabOrder(TQWidget* w);
/**
* convenience function for setCurrentCell(int row, int col)
*/
void setCurrentCell(int row) { setCurrentCell(row, 0); }
void updateTransactionTableSize(void);
/**
* This method returns the current state of the inline editing mode
*
* @return true if inline edit mode is on, false otherwise
*/
bool isEditMode(void) const;
/**
* This method retuns the background color for a given @p row.
*
* @param row the row in question
* @return the color as TQColor object
*/
const TQColor rowBackgroundColor(const int row) const;
void endEdit(bool keyboardDriven);
public slots:
/** No descriptions */
virtual void setCurrentCell(int row, int col);
virtual void setNumRows(int r);
TQWidget* slotStartEdit(void);
void slotEndEdit(void);
void slotEndEditKeyboard(void);
void slotDeleteSplit(void);
void slotCancelEdit(void);
void slotDuplicateSplit(void);
protected slots:
virtual void columnWidthChanged(int col);
/// move the focus to the selected @p row.
void slotSetFocus(int row, int col = 0, int button = Qt::LeftButton, const TQPoint & mousePos = TQPoint(0, 0));
/**
* Calling this slot refills the widget with the data
* passed in the argument @p t.
*
* @param t reference to transaction data
*/
void slotUpdateData(const MyMoneyTransaction& t);
void slotLoadEditWidgets(void);
signals:
/**
* This signal is emitted whenever the return key is pressed
* and the widget is not in edit mode.
*/
void escapePressed(void);
/**
* This signal is emitted whenever the return key is pressed
* and the widget is not in edit mode.
*/
void returnPressed(void);
/**
* This signal is emitted whenever the transaction data has been changed
*
* @param t modified transaction data
*/
void transactionChanged(const MyMoneyTransaction& t);
/**
* This signal is sent out, when a new category needs to be created
* @sa KMyMoneyCombo::createItem()
*
* @param txt The name of the category to be created
* @param id A connected slot should store the id of the created object in this variable
*/
void createCategory(const TQString& txt, TQString& id);
/**
* Signal is emitted, if any of the widgets enters (@a state equals @a true)
* or leaves (@a state equals @a false) object creation mode.
*
* @param state Enter (@a true) or leave (@a false) object creation
*/
void objectCreation(bool state);
private:
/// the currently selected row (will be printed as selected)
int m_currentRow;
/// the number of rows filled with data
int m_maxRows;
/// indication if inline editing mode is on or not
bool m_editMode;
MyMoneyTransaction m_transaction;
MyMoneyAccount m_account;
MyMoneySplit m_split;
MyMoneySplit m_hiddenSplit;
unsigned m_amountWidth;
/**
* This member keeps a pointer to the context menu
*/
KPopupMenu* m_contextMenu;
/// keeps the id of the delete entry in the context menu
int m_contextMenuDelete;
/// keeps the id of the duplicate entry in the context menu
int m_contextMenuDuplicate;
/**
* This member contains a pointer to the input widget for the category.
* The widget will be created and destroyed dynamically in createInputWidgets()
* and destroyInputWidgets().
*/
TQGuardedPtr<KMyMoneyCategory> m_editCategory;
/**
* This member contains a pointer to the input widget for the memo.
* The widget will be created and destroyed dynamically in createInputWidgets()
* and destroyInputWidgets().
*/
TQGuardedPtr<kMyMoneyLineEdit> m_editMemo;
/**
* This member contains a pointer to the input widget for the amount.
* The widget will be created and destroyed dynamically in createInputWidgets()
* and destroyInputWidgets().
*/
TQGuardedPtr<kMyMoneyEdit> m_editAmount;
/**
* This member keeps the tab order for the above widgets
*/
TQWidgetList m_tabOrderWidgets;
TQGuardedPtr<TQFrame> m_registerButtonFrame;
TQGuardedPtr<KPushButton> m_registerEnterButton;
TQGuardedPtr<KPushButton> m_registerCancelButton;
TQMap<TQString, MyMoneyMoney> m_priceInfo;
};
#endif
|