author | allenforsythe <allenforsythe> | 2003-05-28 11:49:47 (UTC) |
---|---|---|
committer | allenforsythe <allenforsythe> | 2003-05-28 11:49:47 (UTC) |
commit | 52047fd3d3f30509d65834747c3a0c5c6760dc01 (patch) (unidiff) | |
tree | 136945c2ffff2434ba1e3c8959b5335f5016e8f8 /noncore/apps/qashmoney/preferences.cpp | |
parent | 7c85b3e98921afa74c7c6a90da4dfd54631c89c5 (diff) | |
download | opie-52047fd3d3f30509d65834747c3a0c5c6760dc01.zip opie-52047fd3d3f30509d65834747c3a0c5c6760dc01.tar.gz opie-52047fd3d3f30509d65834747c3a0c5c6760dc01.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'noncore/apps/qashmoney/preferences.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/preferences.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp index 9bf64dd..880807a 100755 --- a/noncore/apps/qashmoney/preferences.cpp +++ b/noncore/apps/qashmoney/preferences.cpp | |||
@@ -141,36 +141,86 @@ void Preferences::initializeColumnPreferences () | |||
141 | 141 | ||
142 | // initialize budget budget column | 142 | // initialize budget budget column |
143 | 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 ); |
144 | if ( rows == 0 ) | 144 | if ( rows == 0 ) |
145 | 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 ); |
146 | 146 | ||
147 | // initialize budget actual column | 147 | // initialize budget actual column |
148 | 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 ); |
149 | if ( rows == 0 ) | 149 | if ( rows == 0 ) |
150 | 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 ); |
151 | } | 151 | } |
152 | 152 | ||
153 | void Preferences::initializeSortingPreferences () | ||
154 | { | ||
155 | int rows = 0; | ||
156 | int columns = 0; | ||
157 | char **results; | ||
158 | |||
159 | if ( sqlite_get_table ( db, "select count() from sorting;", 0, 0, 0, 0 ) != 0 ) | ||
160 | sqlite_exec ( db, "create table sorting ( listbox, column, direction, id integer primary key );", 0, 0, 0 ); | ||
161 | |||
162 | // initialize account listbox sorting. Set direction = 1 here so ascending sort is default. | ||
163 | sqlite_get_table ( db, "select column, direction from sorting where id = 1;", &results, &rows, &columns, 0 ); | ||
164 | if ( rows == 0 ) | ||
165 | sqlite_exec ( db, "insert into sorting values ( 'accounts', 0, 1, NULL );", 0, 0, 0 ); | ||
166 | |||
167 | // initialize transaction listbox sorting | ||
168 | sqlite_get_table ( db, "select column, direction from sorting where id = 2;", &results, &rows, &columns, 0); | ||
169 | if ( rows == 0 ) | ||
170 | sqlite_exec ( db, "insert into sorting values ( 'transactions', 0, 1, NULL );", 0, 0, 0 ); | ||
171 | |||
172 | // initialize budgets listbox sorting | ||
173 | sqlite_get_table ( db, "select column, direction from sorting where id = 3;", & results, &rows, &columns, 0 ); | ||
174 | if ( rows == 0 ) | ||
175 | sqlite_exec ( db, "insert into sorting values ( 'budgets', 0, 1, NULL );", 0, 0, 0 ); | ||
176 | } | ||
177 | |||
153 | void Preferences::changeColumnPreference ( int id, int width ) | 178 | void Preferences::changeColumnPreference ( int id, int width ) |
154 | { | 179 | { |
155 | sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id ); | 180 | sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id ); |
156 | } | 181 | } |
157 | 182 | ||
158 | int Preferences::getColumnPreference ( int id ) | 183 | int Preferences::getColumnPreference ( int id ) |
159 | { | 184 | { |
160 | char **results; | 185 | char **results; |
161 | sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id ); | 186 | sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id ); |
162 | return atoi ( results [ 1 ] ); | 187 | return atoi ( results [ 1 ] ); |
163 | } | 188 | } |
164 | 189 | ||
190 | void Preferences::changeSortingPreference ( int id, int column ) | ||
191 | { | ||
192 | int pColumn = 0; // column setting coming from the prefs object | ||
193 | int pDirection = 0; // direction setting coming from the prefs object | ||
194 | |||
195 | // because there appears to be no way to query the QT header object directly for it's current sort settings, we have | ||
196 | // to maintain track of them ourselves. So start by pulling the current saved setting for this view. | ||
197 | getSortingPreference ( id, &pColumn, &pDirection ); | ||
198 | |||
199 | // if the current saved column == the new column, then the user wants to toggle the sort order. | ||
200 | // otherwise we behave like QT does by default, which is to select the new column and default to an ascending sort. | ||
201 | if ( column == pColumn ) | ||
202 | sqlite_exec_printf ( db, "update sorting set direction = %i where id = %i;", 0, 0, 0, !pDirection, id ); | ||
203 | else | ||
204 | sqlite_exec_printf ( db, "update sorting set column = %i, direction = 1 where id = %i;", 0, 0, 0, column, id ); | ||
205 | } | ||
206 | |||
207 | void Preferences::getSortingPreference ( int id, int *column, int *direction ) | ||
208 | { | ||
209 | char **results; | ||
210 | sqlite_get_table_printf ( db, "select column, direction from sorting where id = %i;", &results, NULL, NULL, NULL, id ); | ||
211 | *column = atoi ( results [ 2 ] ); | ||
212 | *direction = atoi ( results [ 3 ] ); | ||
213 | } | ||
214 | |||
165 | int Preferences::getPreference ( int id ) | 215 | int Preferences::getPreference ( int id ) |
166 | { | 216 | { |
167 | char **results; | 217 | char **results; |
168 | sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id ); | 218 | sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id ); |
169 | return atoi ( results [ 1 ] ); | 219 | return atoi ( results [ 1 ] ); |
170 | } | 220 | } |
171 | 221 | ||
172 | QString Preferences::getSeparator ( ) | 222 | QString Preferences::getSeparator ( ) |
173 | { | 223 | { |
174 | int s = getPreference ( 2 ); | 224 | int s = getPreference ( 2 ); |
175 | if ( s == 1 ) | 225 | if ( s == 1 ) |
176 | return "/"; | 226 | return "/"; |