~ubuntu-branches/ubuntu/karmic/eqonomize/karmic

« back to all changes in this revision

Viewing changes to src/transactioneditwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Kavanagh
  • Date: 2006-08-10 13:06:12 UTC
  • Revision ID: james.westby@ubuntu.com-20060810130612-s8uxbf97hs51qf0r
Tags: upstream-0.3
ImportĀ upstreamĀ versionĀ 0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2006 by Niklas Knutsson   *
 
3
 *   nq@altern.org   *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
 
 
22
#ifndef TRANSACTION_EDIT_WIDGET_H
 
23
#define TRANSACTION_EDIT_WIDGET_H
 
24
 
 
25
#include <qvaluevector.h>
 
26
#include <knuminput.h>
 
27
#include <qwidget.h>
 
28
#include <qdict.h>
 
29
#include <transaction.h>
 
30
#include <kdialogbase.h>
 
31
 
 
32
class Budget;
 
33
class KLineEdit;
 
34
class ValueSpinBox;
 
35
class KDateEdit;
 
36
class KComboBox;
 
37
class QPushButton;
 
38
class QLabel;
 
39
class QCheckBox;
 
40
 
 
41
typedef enum {
 
42
        SECURITY_SHARES_AND_QUOTATION,
 
43
        SECURITY_VALUE_AND_SHARES,
 
44
        SECURITY_VALUE_AND_QUOTATION
 
45
} SecurityValueDefineType;
 
46
 
 
47
class TransactionEditWidget : public QWidget {
 
48
 
 
49
        Q_OBJECT
 
50
        
 
51
        public:
 
52
 
 
53
                TransactionEditWidget(bool auto_edit, bool extra_parameters, int transaction_type, Security *security, SecurityValueDefineType security_value_type, Budget *budg, QWidget *parent = 0, const char *name = 0);
 
54
                void setTransaction(Transaction *trans);
 
55
                void setScheduledTransaction(ScheduledTransaction *strans, const QDate &date);
 
56
                void updateFromAccounts();
 
57
                void updateToAccounts();
 
58
                void updateAccounts();
 
59
                void transactionsReset();
 
60
                void setCurrentToItem(int index);
 
61
                void setCurrentFromItem(int index);
 
62
                int currentToItem();
 
63
                int currentFromItem();
 
64
                void focusDescription();
 
65
                QWidget *bottomWidget();
 
66
                void transactionRemoved(Transaction *trans);
 
67
                void transactionAdded(Transaction *trans);
 
68
                void transactionModified(Transaction *trans);
 
69
                bool modifyTransaction(Transaction *trans);
 
70
                Transaction *createTransaction();
 
71
                bool validValues();
 
72
                QDate date();
 
73
                void setMaxShares(double max);
 
74
                bool checkAccounts();
 
75
        
 
76
        protected:
 
77
 
 
78
                QDict<Transaction> default_values;
 
79
                int transtype;
 
80
                bool description_changed;
 
81
                Budget *budget;
 
82
                Security *security;
 
83
                bool b_autoedit, b_sec, b_extra;
 
84
                QValueVector<Account*> froms, tos;
 
85
                KLineEdit *descriptionEdit, *commentsEdit, *payeeEdit;
 
86
                KComboBox *fromCombo, *toCombo;
 
87
                KDoubleSpinBox *valueEdit, *sharesEdit, *quotationEdit, *quantityEdit;
 
88
                QPushButton *maxSharesButton;
 
89
                KDateEdit *dateEdit;
 
90
                QWidget *bottom_widget;
 
91
 
 
92
        signals:
 
93
 
 
94
                void addmodify();
 
95
                void dateChanged(const QDate&);
 
96
 
 
97
        public slots:
 
98
 
 
99
                void descriptionChanged(const QString&);
 
100
                void setDefaultValue();
 
101
                void maxShares();
 
102
                
 
103
};
 
104
 
 
105
class ValueSpinBox : public KDoubleSpinBox {
 
106
        
 
107
        Q_OBJECT
 
108
                        
 
109
        public:
 
110
                
 
111
                ValueSpinBox(QWidget *parent = 0, const char *name = 0);
 
112
                ValueSpinBox(double lower, double upper, double step, double value, int precision = 2, QWidget *parent = 0, const char *name = 0);
 
113
 
 
114
                QLineEdit *lineEdit() const;
 
115
                
 
116
        public slots:
 
117
                
 
118
                void selectAll();
 
119
                
 
120
        signals:
 
121
                
 
122
                void returnPressed();
 
123
                
 
124
};
 
125
 
 
126
class TransactionEditDialog : public KDialogBase {
 
127
 
 
128
        Q_OBJECT
 
129
 
 
130
        public:
 
131
 
 
132
                TransactionEditDialog(bool extra_parameters, int transaction_type, Security *security, SecurityValueDefineType security_value_type, Budget *budg, QWidget *parent);
 
133
                TransactionEditWidget *editWidget;              
 
134
 
 
135
        protected slots:
 
136
 
 
137
                void slotOk();
 
138
                
 
139
};
 
140
 
 
141
class MultipleTransactionsEditDialog : public KDialogBase {
 
142
 
 
143
        Q_OBJECT
 
144
        
 
145
        public:
 
146
 
 
147
                MultipleTransactionsEditDialog(bool extra_parameters, int transaction_type, Budget *budg, QWidget *parent = 0, const char *name = 0);
 
148
                void setTransaction(Transaction *trans);
 
149
                void setScheduledTransaction(ScheduledTransaction *strans, const QDate &date);
 
150
                void updateAccounts();
 
151
                bool modifyTransaction(Transaction *trans);
 
152
                bool validValues();
 
153
                bool checkAccounts();
 
154
                QDate date();
 
155
 
 
156
                QCheckBox *descriptionButton, *valueButton, *categoryButton, *dateButton, *payeeButton;
 
157
        
 
158
        protected:
 
159
 
 
160
                int transtype;
 
161
                Budget *budget;
 
162
                bool b_extra;
 
163
                QValueVector<Account*> categories;
 
164
                KLineEdit *descriptionEdit, *payeeEdit;
 
165
                KComboBox *categoryCombo;
 
166
                KDoubleSpinBox *valueEdit;
 
167
                KDateEdit *dateEdit;
 
168
 
 
169
        protected slots:
 
170
 
 
171
                void slotOk();
 
172
                
 
173
};
 
174
 
 
175
 
 
176
#endif
 
177