author | allenforsythe <allenforsythe> | 2003-05-15 10:54:55 (UTC) |
---|---|---|
committer | allenforsythe <allenforsythe> | 2003-05-15 10:54:55 (UTC) |
commit | 2e756a3677b9d4ef426f06beab7ba595c9878f4a (patch) (unidiff) | |
tree | 0776c1d88c1188bb0ee3e84fc5115980275b26df | |
parent | 19be94085643ce40e35a58eb419eb6b51a02b8d1 (diff) | |
download | opie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.zip opie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.tar.gz opie-2e756a3677b9d4ef426f06beab7ba595c9878f4a.tar.bz2 |
Added limit transaction combobox to transaction prefs
-rwxr-xr-x | noncore/apps/qashmoney/preferencedialogs.cpp | 23 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/preferencedialogs.h | 6 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/preferences.cpp | 8 |
3 files changed, 34 insertions, 3 deletions
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp index 3c2fb97..00d52c6 100755 --- a/noncore/apps/qashmoney/preferencedialogs.cpp +++ b/noncore/apps/qashmoney/preferencedialogs.cpp | |||
@@ -1,195 +1,216 @@ | |||
1 | #include "preferencedialogs.h" | 1 | #include "preferencedialogs.h" |
2 | #include "preferences.h" | 2 | #include "preferences.h" |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | 4 | ||
5 | extern Preferences *preferences; | 5 | extern Preferences *preferences; |
6 | 6 | ||
7 | DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 7 | DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
8 | { | 8 | { |
9 | setCaption( tr( "Date" ) ); | 9 | setCaption( tr( "Date" ) ); |
10 | 10 | ||
11 | QLabel *datelabel = new QLabel ( "Format", this ); | 11 | QLabel *datelabel = new QLabel ( "Format", this ); |
12 | dateformat = new QComboBox ( this ); | 12 | dateformat = new QComboBox ( this ); |
13 | dateformat->setEditable ( FALSE ); | 13 | dateformat->setEditable ( FALSE ); |
14 | dateformat->insertItem ( "yyyymmdd" ); | 14 | dateformat->insertItem ( "yyyymmdd" ); |
15 | dateformat->insertItem ( "yymmdd" ); | 15 | dateformat->insertItem ( "yymmdd" ); |
16 | dateformat->insertItem ( "mmddyyyy" ); | 16 | dateformat->insertItem ( "mmddyyyy" ); |
17 | dateformat->insertItem ( "mmddyy" ); | 17 | dateformat->insertItem ( "mmddyy" ); |
18 | dateformat->insertItem ( "yyyyddmm" ); | 18 | dateformat->insertItem ( "yyyyddmm" ); |
19 | dateformat->insertItem ( "yyddmm" ); | 19 | dateformat->insertItem ( "yyddmm" ); |
20 | dateformat->insertItem ( "ddmmyyyy" ); | 20 | dateformat->insertItem ( "ddmmyyyy" ); |
21 | dateformat->insertItem ( "ddmmyy" ); | 21 | dateformat->insertItem ( "ddmmyy" ); |
22 | connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) ); | 22 | connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) ); |
23 | 23 | ||
24 | QLabel *dateseparatorlabel = new QLabel ( "Separator", this ); | 24 | QLabel *dateseparatorlabel = new QLabel ( "Separator", this ); |
25 | dateseparator = new QComboBox ( this ); | 25 | dateseparator = new QComboBox ( this ); |
26 | dateseparator->insertItem ( "/" ); | 26 | dateseparator->insertItem ( "/" ); |
27 | dateseparator->insertItem ( "-" ); | 27 | dateseparator->insertItem ( "-" ); |
28 | dateseparator->insertItem ( "." ); | 28 | dateseparator->insertItem ( "." ); |
29 | connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) ); | 29 | connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) ); |
30 | 30 | ||
31 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 31 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
32 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) ); | 32 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) ); |
33 | 33 | ||
34 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); | 34 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); |
35 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); | 35 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); |
36 | 36 | ||
37 | layout = new QVBoxLayout ( this, 2, 2 ); | 37 | layout = new QVBoxLayout ( this, 2, 2 ); |
38 | layout->addWidget ( datelabel ); | 38 | layout->addWidget ( datelabel ); |
39 | layout->addWidget ( dateformat ); | 39 | layout->addWidget ( dateformat ); |
40 | layout->addWidget ( dateseparatorlabel ); | 40 | layout->addWidget ( dateseparatorlabel ); |
41 | layout->addWidget ( dateseparator ); | 41 | layout->addWidget ( dateseparator ); |
42 | layout->insertSpacing ( 4, 5 ); | 42 | layout->insertSpacing ( 4, 5 ); |
43 | layout->addWidget ( defaults ); | 43 | layout->addWidget ( defaults ); |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | DatePreferences::~DatePreferences () | 47 | DatePreferences::~DatePreferences () |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void DatePreferences::changeDateFormat ( int index ) | 51 | void DatePreferences::changeDateFormat ( int index ) |
52 | { | 52 | { |
53 | index ++; | 53 | index ++; |
54 | preferences->changePreference ( 1, index ); | 54 | preferences->changePreference ( 1, index ); |
55 | } | 55 | } |
56 | 56 | ||
57 | void DatePreferences::changeDateSeparator ( int index ) | 57 | void DatePreferences::changeDateSeparator ( int index ) |
58 | { | 58 | { |
59 | index ++; | 59 | index ++; |
60 | preferences->changePreference ( 2, index ); | 60 | preferences->changePreference ( 2, index ); |
61 | } | 61 | } |
62 | 62 | ||
63 | void DatePreferences::setDefaultDatePreferences () | 63 | void DatePreferences::setDefaultDatePreferences () |
64 | { | 64 | { |
65 | preferences->setDefaultDatePreferences (); | 65 | preferences->setDefaultDatePreferences (); |
66 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); | 66 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); |
67 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); | 67 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); |
68 | } | 68 | } |
69 | 69 | ||
70 | // START TRANSACTION PREFERENCES | 70 | // START TRANSACTION PREFERENCES |
71 | 71 | ||
72 | TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 72 | TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
73 | { | 73 | { |
74 | setCaption( tr ( "Transaction" ) ); | 74 | setCaption( tr ( "Transaction" ) ); |
75 | 75 | ||
76 | showclearedtransactions = new QCheckBox ( this ); | 76 | showclearedtransactions = new QCheckBox ( this ); |
77 | showclearedtransactions->setText ( "Show Cleared Transactions" ); | 77 | showclearedtransactions->setText ( "Show Cleared Transactions" ); |
78 | 78 | ||
79 | excludetransfers = new QCheckBox ( this ); | 79 | excludetransfers = new QCheckBox ( this ); |
80 | excludetransfers->setText ( "Include Transfers In Limit View" ); | 80 | excludetransfers->setText ( "Include Transfers In Limit View" ); |
81 | 81 | ||
82 | limittransactionsbox = new QHBox ( this ); | ||
83 | limittransactionsbox->setSpacing ( 2 ); | ||
84 | limittransactionslabel = new QLabel ( "Limit All Transactions To", limittransactionsbox ); | ||
85 | limittransactions = new QComboBox ( limittransactionsbox ); | ||
86 | limittransactions->insertItem ( "14 days" ); | ||
87 | limittransactions->insertItem ( "30 days" ); | ||
88 | limittransactions->insertItem ( "60 days" ); | ||
89 | limittransactions->insertItem ( "90 days" ); | ||
90 | limittransactions->insertItem ( "180 days" ); | ||
91 | limittransactions->insertItem ( "365 days" ); | ||
92 | limittransactions->insertItem ( "All" ); | ||
93 | |||
82 | if ( preferences->getPreference ( 3 ) == 1 ) | 94 | if ( preferences->getPreference ( 3 ) == 1 ) |
83 | showclearedtransactions->setChecked ( TRUE ); | 95 | showclearedtransactions->setChecked ( TRUE ); |
84 | else | 96 | else |
85 | showclearedtransactions->setChecked ( FALSE ); | 97 | showclearedtransactions->setChecked ( FALSE ); |
86 | 98 | ||
87 | if ( preferences->getPreference ( 6 ) == 1 ) | 99 | if ( preferences->getPreference ( 6 ) == 1 ) |
88 | excludetransfers->setChecked ( TRUE ); | 100 | excludetransfers->setChecked ( TRUE ); |
89 | else | 101 | else |
90 | excludetransfers->setChecked ( FALSE ); | 102 | excludetransfers->setChecked ( FALSE ); |
91 | 103 | ||
92 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 104 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
93 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) ); | 105 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) ); |
94 | 106 | ||
95 | layout = new QVBoxLayout ( this, 2, 2 ); | 107 | layout = new QVBoxLayout ( this, 2, 2 ); |
96 | layout->addWidget ( showclearedtransactions ); | 108 | layout->addWidget ( showclearedtransactions ); |
97 | layout->addWidget ( excludetransfers ); | 109 | layout->addWidget ( excludetransfers ); |
98 | layout->insertSpacing ( 2, 5 ); | 110 | layout->addWidget ( limittransactionsbox ); |
111 | layout->insertSpacing ( 3, 5 ); | ||
99 | layout->addWidget ( defaults ); | 112 | layout->addWidget ( defaults ); |
100 | 113 | ||
101 | connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) ); | 114 | connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) ); |
102 | connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) ); | 115 | connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) ); |
116 | connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) ); | ||
103 | } | 117 | } |
104 | 118 | ||
105 | TransactionPreferences::~TransactionPreferences () | 119 | TransactionPreferences::~TransactionPreferences () |
106 | { | 120 | { |
107 | } | 121 | } |
108 | 122 | ||
123 | void TransactionPreferences::changeLimitTransactionsPreference ( int pref ) | ||
124 | { | ||
125 | preferences->changePreference ( 7, pref ); | ||
126 | } | ||
127 | |||
109 | void TransactionPreferences::changeShowClearedPreference ( bool state ) | 128 | void TransactionPreferences::changeShowClearedPreference ( bool state ) |
110 | { | 129 | { |
111 | if ( state == TRUE ) | 130 | if ( state == TRUE ) |
112 | preferences->changePreference ( 3, 1 ); | 131 | preferences->changePreference ( 3, 1 ); |
113 | else | 132 | else |
114 | preferences->changePreference ( 3, 0 ); | 133 | preferences->changePreference ( 3, 0 ); |
115 | } | 134 | } |
116 | 135 | ||
117 | void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) | 136 | void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) |
118 | { | 137 | { |
119 | if ( state == TRUE ) | 138 | if ( state == TRUE ) |
120 | preferences->changePreference ( 6, 1 ); | 139 | preferences->changePreference ( 6, 1 ); |
121 | else | 140 | else |
122 | preferences->changePreference ( 6, 0 ); | 141 | preferences->changePreference ( 6, 0 ); |
123 | } | 142 | } |
124 | 143 | ||
125 | void TransactionPreferences::setDefaultTransactionPreferences () | 144 | void TransactionPreferences::setDefaultTransactionPreferences () |
126 | { | 145 | { |
127 | preferences->changePreference ( 3, 0 ); | 146 | preferences->changePreference ( 3, 0 ); |
128 | preferences->changePreference ( 6, 0 ); | 147 | preferences->changePreference ( 6, 0 ); |
148 | preferences->changePreference ( 7, 0 ); | ||
129 | showclearedtransactions->setChecked ( FALSE ); | 149 | showclearedtransactions->setChecked ( FALSE ); |
150 | limittransactions->setCurrentItem ( 0 ); | ||
130 | } | 151 | } |
131 | 152 | ||
132 | // START ACCOUNT PREFERNCES | 153 | // START ACCOUNT PREFERNCES |
133 | 154 | ||
134 | AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 155 | AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
135 | { | 156 | { |
136 | 157 | ||
137 | setCaption( tr ( "Account" ) ); | 158 | setCaption( tr ( "Account" ) ); |
138 | 159 | ||
139 | currencysupport = new QCheckBox ( this ); | 160 | currencysupport = new QCheckBox ( this ); |
140 | currencysupport->setText ( "Enable Currency Support" ); | 161 | currencysupport->setText ( "Enable Currency Support" ); |
141 | 162 | ||
142 | onetouch = new QCheckBox ( this ); | 163 | onetouch = new QCheckBox ( this ); |
143 | onetouch->setText ( "One Touch Account Viewing" ); | 164 | onetouch->setText ( "One Touch Account Viewing" ); |
144 | 165 | ||
145 | if ( preferences->getPreference ( 4 ) == 1 ) | 166 | if ( preferences->getPreference ( 4 ) == 1 ) |
146 | currencysupport->setChecked ( TRUE ); | 167 | currencysupport->setChecked ( TRUE ); |
147 | else | 168 | else |
148 | currencysupport->setChecked ( FALSE ); | 169 | currencysupport->setChecked ( FALSE ); |
149 | 170 | ||
150 | if ( preferences->getPreference ( 5 ) == 1 ) | 171 | if ( preferences->getPreference ( 5 ) == 1 ) |
151 | onetouch->setChecked ( TRUE ); | 172 | onetouch->setChecked ( TRUE ); |
152 | else | 173 | else |
153 | onetouch->setChecked ( FALSE ); | 174 | onetouch->setChecked ( FALSE ); |
154 | 175 | ||
155 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 176 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
156 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) ); | 177 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) ); |
157 | 178 | ||
158 | layout = new QVBoxLayout ( this, 2, 2 ); | 179 | layout = new QVBoxLayout ( this, 2, 2 ); |
159 | layout->addWidget ( currencysupport ); | 180 | layout->addWidget ( currencysupport ); |
160 | layout->addWidget ( onetouch ); | 181 | layout->addWidget ( onetouch ); |
161 | layout->insertSpacing ( 2, 5 ); | 182 | layout->insertSpacing ( 2, 5 ); |
162 | layout->addWidget ( defaults ); | 183 | layout->addWidget ( defaults ); |
163 | 184 | ||
164 | connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) ); | 185 | connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) ); |
165 | connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) ); | 186 | connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) ); |
166 | } | 187 | } |
167 | 188 | ||
168 | AccountPreferences::~AccountPreferences () | 189 | AccountPreferences::~AccountPreferences () |
169 | { | 190 | { |
170 | } | 191 | } |
171 | 192 | ||
172 | void AccountPreferences::changeCurrencySupport ( bool state ) | 193 | void AccountPreferences::changeCurrencySupport ( bool state ) |
173 | { | 194 | { |
174 | if ( state == TRUE ) | 195 | if ( state == TRUE ) |
175 | preferences->changePreference ( 4, 1 ); | 196 | preferences->changePreference ( 4, 1 ); |
176 | else | 197 | else |
177 | preferences->changePreference ( 4, 0 ); | 198 | preferences->changePreference ( 4, 0 ); |
178 | } | 199 | } |
179 | 200 | ||
180 | void AccountPreferences::changeOneTouchViewing ( bool state ) | 201 | void AccountPreferences::changeOneTouchViewing ( bool state ) |
181 | { | 202 | { |
182 | if ( state == TRUE ) | 203 | if ( state == TRUE ) |
183 | preferences->changePreference ( 5, 1 ); | 204 | preferences->changePreference ( 5, 1 ); |
184 | else | 205 | else |
185 | preferences->changePreference ( 5, 0 ); | 206 | preferences->changePreference ( 5, 0 ); |
186 | } | 207 | } |
187 | 208 | ||
188 | void AccountPreferences::setDefaultAccountPreferences () | 209 | void AccountPreferences::setDefaultAccountPreferences () |
189 | { | 210 | { |
190 | preferences->changePreference ( 4, 0 ); | 211 | preferences->changePreference ( 4, 0 ); |
191 | preferences->changePreference ( 5, 0 ); | 212 | preferences->changePreference ( 5, 0 ); |
192 | currencysupport->setChecked ( FALSE ); | 213 | currencysupport->setChecked ( FALSE ); |
193 | onetouch->setChecked ( FALSE ); | 214 | onetouch->setChecked ( FALSE ); |
194 | } | 215 | } |
195 | 216 | ||
diff --git a/noncore/apps/qashmoney/preferencedialogs.h b/noncore/apps/qashmoney/preferencedialogs.h index 97b2dbb..88281b8 100755 --- a/noncore/apps/qashmoney/preferencedialogs.h +++ b/noncore/apps/qashmoney/preferencedialogs.h | |||
@@ -1,86 +1,90 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
5 | #include <qgroupbox.h> | 5 | #include <qgroupbox.h> |
6 | #include <qhbuttongroup.h> | 6 | #include <qhbuttongroup.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlabel.h> | ||
10 | #include <qhbox.h> | ||
9 | 11 | ||
10 | #ifndef DATEPREFERENCES_H | 12 | #ifndef DATEPREFERENCES_H |
11 | #define DATEPREFERENCES_H | 13 | #define DATEPREFERENCES_H |
12 | 14 | ||
13 | class DatePreferences : public QDialog | 15 | class DatePreferences : public QDialog |
14 | { | 16 | { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | 18 | ||
17 | public: | 19 | public: |
18 | DatePreferences ( QWidget * parent ); | 20 | DatePreferences ( QWidget * parent ); |
19 | ~DatePreferences(); | 21 | ~DatePreferences(); |
20 | 22 | ||
21 | QPushButton *defaults; | 23 | QPushButton *defaults; |
22 | QComboBox *dateformat; | 24 | QComboBox *dateformat; |
23 | QComboBox *dateseparator; | 25 | QComboBox *dateseparator; |
24 | QBoxLayout *layout; | 26 | QBoxLayout *layout; |
25 | 27 | ||
26 | public slots: | 28 | public slots: |
27 | void changeDateFormat ( int ); | 29 | void changeDateFormat ( int ); |
28 | void changeDateSeparator ( int ); | 30 | void changeDateSeparator ( int ); |
29 | void setDefaultDatePreferences (); | 31 | void setDefaultDatePreferences (); |
30 | }; | 32 | }; |
31 | 33 | ||
32 | #endif | 34 | #endif |
33 | 35 | ||
34 | #ifndef TRANSACTIONPREFERENCES_H | 36 | #ifndef TRANSACTIONPREFERENCES_H |
35 | #define TRANSACTIONPREFERENCES_H | 37 | #define TRANSACTIONPREFERENCES_H |
36 | 38 | ||
37 | class TransactionPreferences : public QDialog | 39 | class TransactionPreferences : public QDialog |
38 | { | 40 | { |
39 | Q_OBJECT | 41 | Q_OBJECT |
40 | 42 | ||
41 | public: | 43 | public: |
42 | TransactionPreferences ( QWidget * parent ); | 44 | TransactionPreferences ( QWidget * parent ); |
43 | ~TransactionPreferences(); | 45 | ~TransactionPreferences(); |
44 | 46 | ||
45 | QCheckBox *showclearedtransactions; | 47 | QCheckBox *showclearedtransactions; |
46 | QCheckBox *excludetransfers; | 48 | QCheckBox *excludetransfers; |
47 | QString *limittransactionslabel; | 49 | QHBox *limittransactionsbox; |
50 | QLabel *limittransactionslabel; | ||
48 | QComboBox *limittransactions; | 51 | QComboBox *limittransactions; |
49 | QPushButton *defaults; | 52 | QPushButton *defaults; |
50 | QBoxLayout *layout; | 53 | QBoxLayout *layout; |
51 | 54 | ||
52 | public slots: | 55 | public slots: |
53 | void changeShowClearedPreference ( bool ); | 56 | void changeShowClearedPreference ( bool ); |
54 | void changeExcludeTranfersPreference ( bool ); | 57 | void changeExcludeTranfersPreference ( bool ); |
55 | void setDefaultTransactionPreferences (); | 58 | void setDefaultTransactionPreferences (); |
59 | void changeLimitTransactionsPreference ( int ); | ||
56 | }; | 60 | }; |
57 | 61 | ||
58 | #endif | 62 | #endif |
59 | 63 | ||
60 | #ifndef ACCOUNTPREFERENCES_H | 64 | #ifndef ACCOUNTPREFERENCES_H |
61 | #define ACCOUNTPREFERENCES_H | 65 | #define ACCOUNTPREFERENCES_H |
62 | 66 | ||
63 | class AccountPreferences : public QDialog | 67 | class AccountPreferences : public QDialog |
64 | { | 68 | { |
65 | Q_OBJECT | 69 | Q_OBJECT |
66 | 70 | ||
67 | public: | 71 | public: |
68 | AccountPreferences ( QWidget * parent ); | 72 | AccountPreferences ( QWidget * parent ); |
69 | ~AccountPreferences(); | 73 | ~AccountPreferences(); |
70 | 74 | ||
71 | QCheckBox *currencysupport; | 75 | QCheckBox *currencysupport; |
72 | QCheckBox *onetouch; | 76 | QCheckBox *onetouch; |
73 | QPushButton *defaults; | 77 | QPushButton *defaults; |
74 | QBoxLayout *layout; | 78 | QBoxLayout *layout; |
75 | 79 | ||
76 | public slots: | 80 | public slots: |
77 | void changeCurrencySupport ( bool ); | 81 | void changeCurrencySupport ( bool ); |
78 | void changeOneTouchViewing ( bool ); | 82 | void changeOneTouchViewing ( bool ); |
79 | void setDefaultAccountPreferences (); | 83 | void setDefaultAccountPreferences (); |
80 | }; | 84 | }; |
81 | 85 | ||
82 | #endif | 86 | #endif |
83 | 87 | ||
84 | 88 | ||
85 | 89 | ||
86 | 90 | ||
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp index 8783a47..819d5cf 100755 --- a/noncore/apps/qashmoney/preferences.cpp +++ b/noncore/apps/qashmoney/preferences.cpp | |||
@@ -1,296 +1,302 @@ | |||
1 | #include "preferences.h" | 1 | #include "preferences.h" |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | Preferences::Preferences () | 4 | Preferences::Preferences () |
5 | { | 5 | { |
6 | db = sqlite_open ( "qmpreferences.db", 0, NULL ); | 6 | db = sqlite_open ( "qmpreferences.db", 0, NULL ); |
7 | } | 7 | } |
8 | 8 | ||
9 | Preferences::~Preferences () | 9 | Preferences::~Preferences () |
10 | { | 10 | { |
11 | sqlite_close ( db ); | 11 | sqlite_close ( db ); |
12 | } | 12 | } |
13 | 13 | ||
14 | void Preferences::addPreferences () | 14 | void Preferences::addPreferences () |
15 | { | 15 | { |
16 | // This function checks the preferences database for existing preferences and adds | 16 | // This function checks the preferences database for existing preferences and adds |
17 | // them if they are not there. First we set up variables. Preferences are always set | 17 | // them if they are not there. First we set up variables. Preferences are always set |
18 | // to non-zero numbers because when we check to see if a preference has been | 18 | // to non-zero numbers because when we check to see if a preference has been |
19 | // added to the database, the result is zero if it hasn't | 19 | // added to the database, the result is zero if it hasn't |
20 | int rows = 0; | 20 | int rows = 0; |
21 | int columns = 0; | 21 | int columns = 0; |
22 | char **results; | 22 | char **results; |
23 | 23 | ||
24 | sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 ); | 24 | sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 ); |
25 | if ( atoi ( results [ 1 ] ) != 6 ) | 25 | if ( atoi ( results [ 1 ] ) != 7 ) |
26 | { | 26 | { |
27 | // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy | 27 | // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy |
28 | // 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy | 28 | // 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy |
29 | sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 ); | 29 | sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 ); |
30 | if ( rows == 0 ) | 30 | if ( rows == 0 ) |
31 | sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 ); | 31 | sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 ); |
32 | 32 | ||
33 | // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period ) | 33 | // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period ) |
34 | rows = 0; | 34 | rows = 0; |
35 | sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 ); | 35 | sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 ); |
36 | if ( rows == 0 ) | 36 | if ( rows == 0 ) |
37 | sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 ); | 37 | sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 ); |
38 | 38 | ||
39 | // showclearedtransactions preference 0 = no 1 = yes | 39 | // showclearedtransactions preference 0 = no 1 = yes |
40 | rows = 0; | 40 | rows = 0; |
41 | sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 ); | 41 | sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 ); |
42 | if ( rows == 0 ) | 42 | if ( rows == 0 ) |
43 | sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 ); | 43 | sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 ); |
44 | 44 | ||
45 | // enable currency support preference 0 = no 1 = yes | 45 | // enable currency support preference 0 = no 1 = yes |
46 | rows = 0; | 46 | rows = 0; |
47 | sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 ); | 47 | sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 ); |
48 | if ( rows == 0 ) | 48 | if ( rows == 0 ) |
49 | sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 ); | 49 | sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 ); |
50 | 50 | ||
51 | // one touch account viewing preference 0 = no 1 = yes | 51 | // one touch account viewing preference 0 = no 1 = yes |
52 | rows = 0; | 52 | rows = 0; |
53 | sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 ); | 53 | sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 ); |
54 | if ( rows == 0 ) | 54 | if ( rows == 0 ) |
55 | sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 ); | 55 | sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 ); |
56 | 56 | ||
57 | // exclude transfers from limit view 0 = no 1 = yes | 57 | // exclude transfers from limit view 0 = no 1 = yes |
58 | rows = 0; | 58 | rows = 0; |
59 | sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 ); | 59 | sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 ); |
60 | if ( rows == 0 ) | 60 | if ( rows == 0 ) |
61 | sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 ); | 61 | sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 ); |
62 | |||
63 | // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 60 days, 3 = 90 days, 4 = 180 days, 5 = 365 days, 6 = all | ||
64 | rows = 0; | ||
65 | sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 ); | ||
66 | if ( rows == 0 ) | ||
67 | sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 ); | ||
62 | } | 68 | } |
63 | } | 69 | } |
64 | 70 | ||
65 | void Preferences::initializeColumnPreferences () | 71 | void Preferences::initializeColumnPreferences () |
66 | { | 72 | { |
67 | int rows = 0; | 73 | int rows = 0; |
68 | int columns = 0; | 74 | int columns = 0; |
69 | char **results; | 75 | char **results; |
70 | 76 | ||
71 | // initialize accountname column width | 77 | // initialize accountname column width |
72 | sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 ); | 78 | sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 ); |
73 | if ( rows == 0 ) | 79 | if ( rows == 0 ) |
74 | sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 ); | 80 | sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 ); |
75 | 81 | ||
76 | // initialize accountbalance column width | 82 | // initialize accountbalance column width |
77 | sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 ); | 83 | sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 ); |
78 | if ( rows == 0 ) | 84 | if ( rows == 0 ) |
79 | sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 ); | 85 | sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 ); |
80 | 86 | ||
81 | // initialize transactiondate column width | 87 | // initialize transactiondate column width |
82 | sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 ); | 88 | sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 ); |
83 | if ( rows == 0 ) | 89 | if ( rows == 0 ) |
84 | sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 90 | sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
85 | 91 | ||
86 | // initialize transactionname column width | 92 | // initialize transactionname column width |
87 | sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 ); | 93 | sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 ); |
88 | if ( rows == 0 ) | 94 | if ( rows == 0 ) |
89 | sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); | 95 | sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); |
90 | 96 | ||
91 | // initialize transactionamount column width | 97 | // initialize transactionamount column width |
92 | sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 ); | 98 | sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 ); |
93 | if ( rows == 0 ) | 99 | if ( rows == 0 ) |
94 | sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 100 | sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
95 | 101 | ||
96 | // initialize transactiondate column width | 102 | // initialize transactiondate column width |
97 | sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 ); | 103 | sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 ); |
98 | if ( rows == 0 ) | 104 | if ( rows == 0 ) |
99 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 105 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
100 | 106 | ||
101 | // initialize transactionname column width | 107 | // initialize transactionname column width |
102 | sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 ); | 108 | sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 ); |
103 | if ( rows == 0 ) | 109 | if ( rows == 0 ) |
104 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); | 110 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); |
105 | 111 | ||
106 | // initialize transactionamount column width | 112 | // initialize transactionamount column width |
107 | sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 ); | 113 | sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 ); |
108 | if ( rows == 0 ) | 114 | if ( rows == 0 ) |
109 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 115 | sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
110 | 116 | ||
111 | // initialize transactionaccount column width | 117 | // initialize transactionaccount column width |
112 | sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 ); | 118 | sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 ); |
113 | if ( rows == 0 ) | 119 | if ( rows == 0 ) |
114 | sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 120 | sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
115 | 121 | ||
116 | // initialize account name with currency column width | 122 | // initialize account name with currency column width |
117 | sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 ); | 123 | sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 ); |
118 | if ( rows == 0 ) | 124 | if ( rows == 0 ) |
119 | sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 ); | 125 | sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 ); |
120 | 126 | ||
121 | // initialize account currency column width | 127 | // initialize account currency column width |
122 | sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 ); | 128 | sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 ); |
123 | if ( rows == 0 ) | 129 | if ( rows == 0 ) |
124 | sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 ); | 130 | sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 ); |
125 | 131 | ||
126 | // initialize account balance with currency column width | 132 | // initialize account balance with currency column width |
127 | sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 ); | 133 | sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 ); |
128 | if ( rows == 0 ) | 134 | if ( rows == 0 ) |
129 | sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 135 | sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
130 | 136 | ||
131 | // initialize budget line item column | 137 | // initialize budget line item column |
132 | sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 ); | 138 | sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 ); |
133 | if ( rows == 0 ) | 139 | if ( rows == 0 ) |
134 | sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 140 | sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
135 | 141 | ||
136 | // initialize budget budget column | 142 | // initialize budget budget column |
137 | sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 ); | 143 | sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 ); |
138 | if ( rows == 0 ) | 144 | if ( rows == 0 ) |
139 | sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 145 | sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
140 | 146 | ||
141 | // initialize budget actual column | 147 | // initialize budget actual column |
142 | sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 ); | 148 | sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 ); |
143 | if ( rows == 0 ) | 149 | if ( rows == 0 ) |
144 | sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 ); | 150 | sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 ); |
145 | } | 151 | } |
146 | 152 | ||
147 | void Preferences::changeColumnPreference ( int id, int width ) | 153 | void Preferences::changeColumnPreference ( int id, int width ) |
148 | { | 154 | { |
149 | sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id ); | 155 | sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id ); |
150 | } | 156 | } |
151 | 157 | ||
152 | int Preferences::getColumnPreference ( int id ) | 158 | int Preferences::getColumnPreference ( int id ) |
153 | { | 159 | { |
154 | char **results; | 160 | char **results; |
155 | sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id ); | 161 | sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id ); |
156 | return atoi ( results [ 1 ] ); | 162 | return atoi ( results [ 1 ] ); |
157 | } | 163 | } |
158 | 164 | ||
159 | int Preferences::getPreference ( int id ) | 165 | int Preferences::getPreference ( int id ) |
160 | { | 166 | { |
161 | char **results; | 167 | char **results; |
162 | sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id ); | 168 | sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id ); |
163 | return atoi ( results [ 1 ] ); | 169 | return atoi ( results [ 1 ] ); |
164 | } | 170 | } |
165 | 171 | ||
166 | QString Preferences::getSeparator ( ) | 172 | QString Preferences::getSeparator ( ) |
167 | { | 173 | { |
168 | int s = getPreference ( 2 ); | 174 | int s = getPreference ( 2 ); |
169 | if ( s == 1 ) | 175 | if ( s == 1 ) |
170 | return "/"; | 176 | return "/"; |
171 | if ( s ==2 ) | 177 | if ( s ==2 ) |
172 | return "-"; | 178 | return "-"; |
173 | else | 179 | else |
174 | return "."; | 180 | return "."; |
175 | } | 181 | } |
176 | 182 | ||
177 | void Preferences::changePreference ( int id, int newpreference ) | 183 | void Preferences::changePreference ( int id, int newpreference ) |
178 | { | 184 | { |
179 | sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id ); | 185 | sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id ); |
180 | } | 186 | } |
181 | 187 | ||
182 | void Preferences::setDefaultDatePreferences () | 188 | void Preferences::setDefaultDatePreferences () |
183 | { | 189 | { |
184 | sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 ); | 190 | sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 ); |
185 | sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 ); | 191 | sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 ); |
186 | } | 192 | } |
187 | 193 | ||
188 | QString Preferences::getDate ( int y, int m, int d ) | 194 | QString Preferences::getDate ( int y, int m, int d ) |
189 | { | 195 | { |
190 | QString date; | 196 | QString date; |
191 | int format = getPreference ( 1 ); | 197 | int format = getPreference ( 1 ); |
192 | QString separator = getSeparator(); | 198 | QString separator = getSeparator(); |
193 | 199 | ||
194 | // Convert all date integers to QStrings | 200 | // Convert all date integers to QStrings |
195 | QString year = QString::number ( y ); | 201 | QString year = QString::number ( y ); |
196 | QString month = QString::number ( m ); | 202 | QString month = QString::number ( m ); |
197 | if ( m < 10 ) | 203 | if ( m < 10 ) |
198 | month.prepend ( "0" ); | 204 | month.prepend ( "0" ); |
199 | QString day = QString::number ( d ); | 205 | QString day = QString::number ( d ); |
200 | if ( d < 10 ) | 206 | if ( d < 10 ) |
201 | day.prepend ( "0" ); | 207 | day.prepend ( "0" ); |
202 | 208 | ||
203 | // Truncate four digit year if necessary | 209 | // Truncate four digit year if necessary |
204 | if ( format == 2 || format == 4 || format == 6 || format == 8 ) | 210 | if ( format == 2 || format == 4 || format == 6 || format == 8 ) |
205 | year.remove ( 0, 2 ); | 211 | year.remove ( 0, 2 ); |
206 | 212 | ||
207 | // Concatenate dates as necessary | 213 | // Concatenate dates as necessary |
208 | if ( format == 1 || format == 2 ) | 214 | if ( format == 1 || format == 2 ) |
209 | { | 215 | { |
210 | date = year; | 216 | date = year; |
211 | date.append ( separator ); | 217 | date.append ( separator ); |
212 | date.append ( month ); | 218 | date.append ( month ); |
213 | date.append ( separator ); | 219 | date.append ( separator ); |
214 | date.append ( day ); | 220 | date.append ( day ); |
215 | return date; | 221 | return date; |
216 | } | 222 | } |
217 | if ( format == 3 || format == 4 ) | 223 | if ( format == 3 || format == 4 ) |
218 | { | 224 | { |
219 | date = month; | 225 | date = month; |
220 | date.append ( separator ); | 226 | date.append ( separator ); |
221 | date.append ( day ); | 227 | date.append ( day ); |
222 | date.append ( separator ); | 228 | date.append ( separator ); |
223 | date.append ( year ); | 229 | date.append ( year ); |
224 | return date; | 230 | return date; |
225 | } | 231 | } |
226 | if ( format == 5 || format == 6 ) | 232 | if ( format == 5 || format == 6 ) |
227 | { | 233 | { |
228 | date = year; | 234 | date = year; |
229 | date.append ( separator ); | 235 | date.append ( separator ); |
230 | date.append ( day ); | 236 | date.append ( day ); |
231 | date.append ( separator ); | 237 | date.append ( separator ); |
232 | date.append ( month ); | 238 | date.append ( month ); |
233 | return date; | 239 | return date; |
234 | } | 240 | } |
235 | if ( format == 7 || format == 8 ) | 241 | if ( format == 7 || format == 8 ) |
236 | { | 242 | { |
237 | date = day; | 243 | date = day; |
238 | date.append ( separator ); | 244 | date.append ( separator ); |
239 | date.append ( month ); | 245 | date.append ( month ); |
240 | date.append ( separator ); | 246 | date.append ( separator ); |
241 | date.append ( year ); | 247 | date.append ( year ); |
242 | return date; | 248 | return date; |
243 | } | 249 | } |
244 | } | 250 | } |
245 | 251 | ||
246 | QString Preferences::getDate ( int y, int m ) | 252 | QString Preferences::getDate ( int y, int m ) |
247 | { | 253 | { |
248 | QString date; | 254 | QString date; |
249 | int format = getPreference ( 1 ); | 255 | int format = getPreference ( 1 ); |
250 | QString separator = getSeparator(); | 256 | QString separator = getSeparator(); |
251 | 257 | ||
252 | // Convert all date integers to QStrings | 258 | // Convert all date integers to QStrings |
253 | QString year = QString::number ( y ); | 259 | QString year = QString::number ( y ); |
254 | QString month = QString::number ( m ); | 260 | QString month = QString::number ( m ); |
255 | if ( m < 10 ) | 261 | if ( m < 10 ) |
256 | month.prepend ( "0" ); | 262 | month.prepend ( "0" ); |
257 | 263 | ||
258 | // Truncate four digit year if necessary | 264 | // Truncate four digit year if necessary |
259 | if ( format == 2 || format == 4 || format == 6 || format == 8 ) | 265 | if ( format == 2 || format == 4 || format == 6 || format == 8 ) |
260 | year.remove ( 0, 2 ); | 266 | year.remove ( 0, 2 ); |
261 | 267 | ||
262 | // Concatenate dates as necessary | 268 | // Concatenate dates as necessary |
263 | if ( format == 1 || format == 2 ) | 269 | if ( format == 1 || format == 2 ) |
264 | { | 270 | { |
265 | date = year; | 271 | date = year; |
266 | date.append ( separator ); | 272 | date.append ( separator ); |
267 | date.append ( month ); | 273 | date.append ( month ); |
268 | return date; | 274 | return date; |
269 | } | 275 | } |
270 | if ( format == 3 || format == 4 ) | 276 | if ( format == 3 || format == 4 ) |
271 | { | 277 | { |
272 | date = month; | 278 | date = month; |
273 | date.append ( separator ); | 279 | date.append ( separator ); |
274 | date.append ( year ); | 280 | date.append ( year ); |
275 | return date; | 281 | return date; |
276 | } | 282 | } |
277 | if ( format == 5 || format == 6 ) | 283 | if ( format == 5 || format == 6 ) |
278 | { | 284 | { |
279 | date = year; | 285 | date = year; |
280 | date.append ( separator ); | 286 | date.append ( separator ); |
281 | date.append ( month ); | 287 | date.append ( month ); |
282 | return date; | 288 | return date; |
283 | } | 289 | } |
284 | if ( format == 7 || format == 8 ) | 290 | if ( format == 7 || format == 8 ) |
285 | { | 291 | { |
286 | date.append ( month ); | 292 | date.append ( month ); |
287 | date.append ( separator ); | 293 | date.append ( separator ); |
288 | date.append ( year ); | 294 | date.append ( year ); |
289 | return date; | 295 | return date; |
290 | } | 296 | } |
291 | } | 297 | } |
292 | 298 | ||
293 | 299 | ||
294 | 300 | ||
295 | 301 | ||
296 | 302 | ||