summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/kfindtransactiondlg.h
blob: c40cb403ce72f04706b59e1f2750adb3895fd437 (plain)
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
/***************************************************************************
                          kfindtransactiondlg.h
                             -------------------
    copyright            : (C) 2003 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 KFINDTRANSACTIONDLG_H
#define KFINDTRANSACTIONDLG_H

// ----------------------------------------------------------------------------
// QT Includes

#include <tqlistview.h>
#include <tqdatetime.h>
#include <tqmap.h>

// ----------------------------------------------------------------------------
// KDE Includes

// ----------------------------------------------------------------------------
// Project Includes

// #include "../views/kledgerview.h"
#include <kmymoney/mymoneyutils.h>
#include <kmymoney/mymoneytransactionfilter.h>

#include "../dialogs/kfindtransactiondlgdecl.h"

class TQListView;
class TQListViewItem;

/**
  * @author Thomas Baumgart
  */
class KFindTransactionDlg : public KFindTransactionDlgDecl
{
  Q_OBJECT
  TQ_OBJECT
public:

  /*
  // Make sure to keep the following enum valus in sync with the values
  // used by the GUI in kfindtransactiondlgdecl.ui
  enum dateOptionE {
    allDates = 0,
    asOfToday,
    currentMonth,
    currentYear,
    monthToDate,
    yearToDate,
    yearToMonth,
    lastMonth,
    lastYear,
    last7Days,
    last30Days,
    last3Months,
    last6Months,
    last12Months,
    next7Days,
    next30Days,
    next3Months,
    next6Months,
    next12Months,
    userDefined,
    last3ToNext3Months,
    last11Months,
    // insert new constants above of this line
    dateOptionCount
  };
*/
  KFindTransactionDlg(TQWidget *parent=0, const char *name=0);
  ~KFindTransactionDlg() {}

  virtual bool eventFilter( TQObject *o, TQEvent *e );

public slots:
  void show(void);

protected:
  void resizeEvent(TQResizeEvent*);

protected slots:
  virtual void slotReset(void);
  virtual void slotSearch(void);

  /**
    * This slot opens the detailed help page in khelpcenter. The
    * anchor for the information is taken from m_helpAnchor.
    */
  virtual void slotShowHelp(void);


  void slotUpdateSelections(void);

  virtual void slotDateRangeChanged(int);
  virtual void slotDateChanged(void);

  virtual void slotAmountSelected(void);
  virtual void slotAmountRangeSelected(void);

  virtual void slotSelectAllPayees(void);
  virtual void slotDeselectAllPayees(void);

  virtual void slotNrSelected(void);
  virtual void slotNrRangeSelected(void);

  void slotRefreshView(void);

  /**
    * This slot selects the current selected transaction/split and emits
    * the signal @a transactionSelected(const TQString& accountId, const TQString& transactionId)
    */
  void slotSelectTransaction(void);

  void slotRightSize(void);

  void slotSortOptions(void);

signals:
  void transactionSelected(const TQString& accountId, const TQString& transactionId);

  /**
    * This signal is sent out when no selection has been made. It is
    * used to control the state of the Search button.
    */
  void selectionEmpty(bool);

protected:
  enum opTypeE {
    addAccountToFilter = 0,
    addCategoryToFilter,
    addPayeeToFilter
  };

  void setupCategoriesPage(void);
  void setupDatePage(void);
  void setupAccountsPage(void);
  void setupAmountPage(void);
  void setupPayeesPage(void);
  void setupDetailsPage(void);

  void setupFilter(void);

  void selectAllItems(TQListView* view, const bool state);
  void selectAllSubItems(TQListViewItem* item, const bool state);
  void selectItems(TQListView* view, const TQStringList& list, const bool state);
  void selectSubItems(TQListViewItem* item, const TQStringList& list, const bool state);

  /**
    * This method loads the m_payeesView with the payees name
    * found in the engine.
    */
  void loadPayees(void);

  /**
    * This method loads the register with the matching transactions
    */
  void loadView(void);

  /**
    * This method returns information about the selection state
    * of the items in the m_accountsView.
    *
    * @param view pointer to the listview to scan
    *
    * @retval true if all items in the view are marked
    * @retval false if at least one item is not marked
    *
    * @note If the view contains no items the method returns @p true.
    */
  bool allItemsSelected(const TQListView* view) const;
  bool allItemsSelected(const TQListViewItem *item) const;

  void scanCheckListItems(const TQListView* view, const opTypeE op);
  void scanCheckListItems(const TQListViewItem* item, const opTypeE op);
  void addItemToFilter(const opTypeE op, const TQString& id);

protected:
  TQDate                m_startDates[MyMoneyTransactionFilter::dateOptionCount];
  TQDate                m_endDates[MyMoneyTransactionFilter::dateOptionCount];

  /**
    * This member holds a list of all transactions matching the filter criteria
    */
  TQValueList<TQPair<MyMoneyTransaction, MyMoneySplit> > m_transactionList;

  MyMoneyTransactionFilter        m_filter;

  TQMap<TQWidget*, TQString>         m_helpAnchor;

  bool                            m_needReload;
};

#endif