summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/transactionform.h
blob: 5c5024851dd7971cb0f09e6bb6cf3fb60e5ba816 (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/***************************************************************************
                             transactionform.h
                             ----------
    begin                : Sun May 14 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 TRANSACTIONFORM_H
#define TRANSACTIONFORM_H

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

#include <tqtable.h>
#include <tqvaluelist.h>
#include <tqvaluevector.h>
#include <tqpalette.h>
#include <tqwidgetlist.h>
#include <tqtabbar.h>

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

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

#include <kmymoney/mymoneyaccount.h>
#include <kmymoney/mymoneyobject.h>
#include <kmymoney/register.h>

#include "../kmymoneysettings.h"

class MyMoneyObjectContainer;

namespace KMyMoneyTransactionForm {

/**
  * @author Thomas Baumgart
  */
class TabBar : public TQTabBar
{
  Q_OBJECT
  TQ_OBJECT
public:
  typedef enum {
    SignalNormal = 0,      // standard signal behaviour
    SignalNever,           // don't signal selection of a tab at all
    SignalAlways           // always signal selection of a tab
  } SignalEmissionE;

  TabBar(TQWidget* tqparent = 0, const char* name = 0);
  virtual ~TabBar() {}

  SignalEmissionE setSignalEmission(SignalEmissionE type);

  void copyTabs(const TabBar* otabbar);

  void addTab(TQTab* tab, int id);

  void setIdentifier(TQTab* tab, int newId);

  TQTab* tab(int id) const;

  int currentTab(void) const;

public slots:
  /**
    * overridden for internal reasons, API not changed
    */
  virtual void setCurrentTab( int );

  /**
    * overridden for internal reasons, API not changed
    */
  virtual void setCurrentTab( TQTab * );

  /**
    * overridden for internal reasons, API not changed
    */
  virtual void show(void);

protected slots:
  void slotTabSelected(int id);

signals:
  void tabSelected(int id);

private:
  SignalEmissionE    m_signalType;
  
  /**
    * maps our internal action ids to those used by
    * qt3. Since it does not seem possible to tell
    * qt3 to use our ids everywhere (in TQAccel) we
    * need to know which is which
    */
  TQMap<int, int>     m_idMap;
  
  
};

typedef enum {
  LabelColumn1 = 0,
  ValueColumn1,
  LabelColumn2,
  ValueColumn2,
  // insert new values above this line
  MaxColumns
} Column;

/**
  * @author Thomas Baumgart
  */
class TransactionForm : public TransactionEditorContainer
{
  Q_OBJECT
  TQ_OBJECT
public:
  TransactionForm(TQWidget *tqparent = 0, const char *name = 0);
  virtual ~TransactionForm() {}

  /**
    * Override the TQTable member function to avoid display of focus
    */
  void paintFocus(TQPainter* /*p*/, const TQRect& /*cr*/ ) {}

  TQSize tableSize(void) const;
  TQSize tqsizeHint(void) const;
  void adjustColumn(Column col);
  void clear(void);

  void paintCell(TQPainter* painter, int row, int col, const TQRect& r, bool selected, const TQColorGroup& cg);

  void resize(int col);

  void arrangeEditWidgets(TQMap<TQString, TQWidget*>& editWidgets, KMyMoneyRegister::Transaction* t);
  void removeEditWidgets(TQMap<TQString, TQWidget*>& editWidgets);
  void tabOrder(TQWidgetList& tabOrderWidgets, KMyMoneyRegister::Transaction* t) const;

  /**
    * reimplemented to prevent normal cell selection behavior
    */
  void setCurrentCell(int, int) {}

  TabBar* tabBar(TQWidget* tqparent = 0);

  void setupForm(const MyMoneyAccount& acc);

  void enableTabBar(bool b);

  protected:
  /**
    * reimplemented to support TQWidget::WState_BlockUpdates
    */
  void drawContents(TQPainter *p, int cx, int cy, int cw, int ch);

  /**
    * reimplemented to prevent normal mouse press behavior
    */
  void contentsMousePressEvent(TQMouseEvent* ev) { ev->ignore(); }

  /**
    * reimplemented to prevent normal mouse move behavior
    */
  void contentsMouseMoveEvent(TQMouseEvent* ev) { ev->ignore(); }

  /**
    * reimplemented to prevent normal mouse release behavior
    */
  void contentsMouseReleaseEvent(TQMouseEvent* ev) { ev->ignore(); }

  /**
    * reimplemented to prevent normal mouse double click behavior
    */
  void contentsMouseDoubleClickEvent(TQMouseEvent* ev) { ev->ignore(); }

  /**
    * reimplemented to prevent normal keyboard behavior
    */
  void keyPressEvent(TQKeyEvent* ev) { ev->ignore(); }

  /**
    * Override logic and use standard TQFrame behaviour
    */
  bool focusNextPrevChild(bool next);

public slots:
  void slotSetTransaction(KMyMoneyRegister::Transaction* item);

protected slots:
  void resize(void);

  /**
    * Helper method to convert @a int into @a KMyMoneyRegister::Action
    */
  void slotActionSelected(int);

signals:
  /**
    * This signal is emitted when a user selects a tab. @a id
    * contains the tab's id (e.g. KMyMoneyRegister::ActionDeposit)
    */
  void newTransaction(KMyMoneyRegister::Action id);

protected:
  KMyMoneyRegister::Transaction*       m_transaction;
  TQColorGroup                          m_cellColorGroup;
  TabBar*                              m_tabBar;
};


} // namespace

#endif
// vim:cin:si:ai:et:ts=2:sw=2: