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
|
/***************************************************************************
kpayeesview.h
-------------
begin : Thu Jan 24 2002
copyright : (C) 2000-2002 by Michael Edwardes
2005 by Andrea Nicolai
2006 by Thomas Baumgart
email : [email protected]
Javier Campos Morales <[email protected]>
Felix Rodriguez <[email protected]>
John C <[email protected]>
Thomas Baumgart <[email protected]>
Kevin Tambascio <[email protected]>
Andreas Nicolai <[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 KPAYEESVIEW_H
#define KPAYEESVIEW_H
// ----------------------------------------------------------------------------
// QT Includes
#include <tqwidget.h>
class TQSplitter;
// ----------------------------------------------------------------------------
// KDE Includes
#include <klistview.h>
#include <kpopupmenu.h>
// ----------------------------------------------------------------------------
// Project Includes
#include "kpayeesviewdecl.h"
#include "kmymoneytransaction.h"
#include <kmymoney/mymoneypayee.h>
class KListViewSearchLineWidget;
/**
* @author Michael Edwardes, Thomas Baumgart
*/
/**
* This class is used to store a sorted vector of pointers to
* the transactions that are visible in a ledger view. When the
* vector is created, the sort method is set to SortPostDate.
* The sort type can be changed using the method setSortType().
*/
class KTransactionPtrVector : public TQPtrVector<KMyMoneyTransaction> {
public:
/**
* This enumerator defines the possible sort methods.
* Possible values are:
*
*/
enum TransactionSortE {
SortEntryDate = 0, /**< Sort the vector so that the transactions appear sorted
* according to their entry date
*/
SortPostDate, /**< Sort the vector so that the transactions appear sorted
* according to their post date
*/
SortTypeNr, /**< Sort the vector so that the transactions appear sorted
* according to their action and nr
*/
SortReceiver, /**< Sort the vector so that the transactions appear sorted
* according to their receiver
*/
SortValue, /**< Sort the vector so that the transactions appear sorted
* according to their value
*/
SortNr, /**< Sort the vector so that the transactions appear sorted
* according to nr field contents
*/
SortEntryOrder /**< Sort the vector so that the transactions appear sorted
* according to order of entry
*/
};
KTransactionPtrVector() { m_sortType = SortPostDate; };
~KTransactionPtrVector() {}
/**
* This method is used to set a different sort type.
* The vector is resorted. See KTransactionPtrVector::TransactionSortE
* for possible values.
*/
void setSortType(const TransactionSortE type);
/**
* This method returns the current sort type.
*
* @return transactionSortE value of sort order. See
* KTransactionPtrVector::TransactionSortE for possible values.
*/
TransactionSortE sortType(void) const { return m_sortType; };
/**
* This method is used to set the account id to have a chance to
* get information about the split referencing the current account
* during the sort phase.
*/
void setAccountId(const TQString& id);
/**
* This method is used to set the payee id to have a chance to
* get information about the split referencing the current payee
* during the sort phase.
*/
void setPayeeId(const TQString& id);
protected:
int compareItems(KTransactionPtrVector::Item d1, KTransactionPtrVector::Item d2);
private:
int compareItems(const TQString& s1, const TQString& s2) const;
private:
enum {
AccountMode = 0,
PayeeMode
};
short m_idMode;
TQString m_id;
TransactionSortE m_sortType;
};
/**
* This class represents an item in the payees list view.
*/
class KPayeeListItem : public KListViewItem
{
public:
/**
* Constructor to be used to construct a payee entry object.
*
* @param parent pointer to the KListView object this entry should be
* added to.
* @param payee const reference to MyMoneyPayee for which
* the KListView entry is constructed
*/
KPayeeListItem(KListView *parent, const MyMoneyPayee& payee);
~KPayeeListItem();
/**
* This method is re-implemented from TQListViewItem::paintCell().
* Besides the standard implementation, the TQPainter is set
* according to the applications settings.
*/
void paintCell(TQPainter *p, const TQColorGroup & cg, int column, int width, int align);
const MyMoneyPayee& payee(void) const { return m_payee; };
private:
MyMoneyPayee m_payee;
};
/**
* This class represents an item in the transaction list view. It is used
* by the KPayeesView to select between transactions.
*/
class KTransactionListItem : public KListViewItem
{
public:
KTransactionListItem(KListView* view, KTransactionListItem* parent, const TQString& accountId, const TQString& transaction);
~KTransactionListItem();
const TQString& transactionId(void) const { return m_transactionId; };
const TQString& accountId(void) const { return m_accountId; };
/**
* use my own paint method
*/
void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment);
/**
* use my own backgroundColor method
*/
const TQColor backgroundColor();
private:
TQString m_transactionId;
TQString m_accountId;
};
class KPayeesView : public KPayeesViewDecl
{
Q_OBJECT
public:
KPayeesView(TQWidget *parent=0, const char *name=0);
~KPayeesView();
void show(void);
public slots:
void slotSelectPayeeAndTransaction(const TQString& payeeId, const TQString& accountId = TQString(), const TQString& transactionId = TQString());
void slotLoadPayees(void);
void slotStartRename(void);
void slotHelp(void);
protected:
void resizeEvent(TQResizeEvent*);
void loadPayees(void);
void selectedPayees(TQValueList<MyMoneyPayee>& payeesList) const;
void ensurePayeeVisible(const TQString& id);
void clearItemData(void);
protected slots:
/**
* This method loads the m_transactionList, clears
* the m_TransactionPtrVector and rebuilds and sorts
* it according to the current settings. Then it
* loads the m_transactionView with the transaction data.
*/
void showTransactions(void);
/**
* This slot is called whenever the selection in m_payeesList
* has been changed.
*/
void slotSelectPayee(void);
/**
* This slot marks the current selected payee as modified (dirty).
*/
void slotPayeeDataChanged(void);
void slotKeyListChanged(void);
/**
* This slot is called when the name of a payee is changed inside
* the payee list view and only a single payee is selected.
*/
void slotRenamePayee(TQListViewItem *p, int col, const TQString& txt);
/**
* Updates the payee data in m_payee from the information in the
* payee information widget.
*/
void slotUpdatePayee(void);
void slotTransactionDoubleClicked(TQListViewItem *);
private slots:
void rearrange(void);
/**
* This slot receives the signal from the listview control that an item was right-clicked,
* If @p item points to a real payee item, emits openContextMenu().
*
* @param lv pointer to the listview sending the signal
* @param item the item on which the cursor resides
* @param p position of the pointer device
*/
void slotOpenContextMenu(KListView* lv, TQListViewItem* item, const TQPoint& p);
void slotQueueUpdate(void);
void slotActivateUpdate(void);
void slotChooseDefaultAccount(void);
private:
void readConfig(void);
signals:
void transactionSelected(const TQString& accountId, const TQString& transactionId);
void openContextMenu(const MyMoneyObject& obj);
void selectObjects(const TQValueList<MyMoneyPayee>& payees);
private:
MyMoneyPayee m_payee;
TQString m_newName;
TQSplitter* m_splitter;
/**
* This member holds a list of all transactions
*/
TQValueList<KMyMoneyTransaction> m_transactionList;
/**
* This member keeps a vector of pointers to all visible (filtered)
* transaction in m_transactionList in sorted order. Sorting is done
* in KTransactionPtrVector::compareItems
*/
KTransactionPtrVector m_transactionPtrVector;
/**
* This member holds the state of the toggle switch used
* to suppress updates due to MyMoney engine data changes
*/
bool m_needReload;
/**
* Search widget for the list
*/
KListViewSearchLineWidget* m_searchWidget;
bool m_needConnection;
/**
* Counting semaphore to collect updates
*/
int m_updatesQueued;
/**
* Semaphore to suppress loading during selection
*/
bool m_inSelection;
};
#endif
|