author | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
commit | 767f33638631d29bca260aab66c1224ab2108af7 (patch) (unidiff) | |
tree | e8c66841e18a4f106e0650e1e29d21e706bcef14 | |
parent | 3095bf47c523afcf5441057db23050767f69ebf9 (diff) | |
download | opie-767f33638631d29bca260aab66c1224ab2108af7.zip opie-767f33638631d29bca260aab66c1224ab2108af7.tar.gz opie-767f33638631d29bca260aab66c1224ab2108af7.tar.bz2 |
got tableviewer compiling to find out what the heck it is- and I still can't tell
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 40 | ||||
-rw-r--r-- | noncore/apps/tableviewer/main.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 116 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.h | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/commonwidgets.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvbrowseview.cpp | 12 |
6 files changed, 89 insertions, 88 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index 4c70e54..71844a5 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp | |||
@@ -1,121 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qvector.h> | 23 | #include <qvector.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | #include <timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include "common.h" | 26 | #include "common.h" |
27 | #include "datacache.h" | 27 | #include "datacache.h" |
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | 29 | ||
30 | static const int del_flag = 0x1; | 30 | static const int del_flag = 0x1; |
31 | static const int new_flag = 0x2; | 31 | static const int new_flag = 0x2; |
32 | 32 | ||
33 | /* Helper function */ | 33 | /* Helper function */ |
34 | 34 | ||
35 | int parseNextNumber(QString *q) { | 35 | int parseNextNumber(QString *q) { |
36 | QChar c; | 36 | QChar c; |
37 | uint i; | 37 | uint i; |
38 | int result = 0; | 38 | int result = 0; |
39 | 39 | ||
40 | bool found_digits = FALSE; | 40 | bool found_digits = FALSE; |
41 | for(i = 0; i < q->length(); i++) { | 41 | for(i = 0; i < q->length(); i++) { |
42 | c = q->at(i); | 42 | c = q->at(i); |
43 | if (c.isDigit()) { | 43 | if (c.isDigit()) { |
44 | if (found_digits) | 44 | if (found_digits) |
45 | result *= 10; | 45 | result *= 10; |
46 | found_digits = TRUE; | 46 | found_digits = TRUE; |
47 | result += c.digitValue(); | 47 | result += c.digitValue(); |
48 | } else { | 48 | } else { |
49 | if (found_digits) | 49 | if (found_digits) |
50 | break; | 50 | break; |
51 | /* just skip this char */ | 51 | /* just skip this char */ |
52 | } | 52 | } |
53 | } | 53 | } |
54 | /* now truncate q */ | 54 | /* now truncate q */ |
55 | if (found_digits) | 55 | if (found_digits) |
56 | q->remove(0, i); | 56 | q->remove(0, i); |
57 | return result; | 57 | return result; |
58 | } | 58 | } |
59 | 59 | ||
60 | /*! | 60 | /*! |
61 | \class QStringVector | 61 | \class QStringVector |
62 | \brief A Vector of QStrings that can be sorted and searched | 62 | \brief A Vector of QStrings that can be sorted and searched |
63 | 63 | ||
64 | Implmented in order to allow reverse lookup on the string name | 64 | Implmented in order to allow reverse lookup on the string name |
65 | 65 | ||
66 | */ | 66 | */ |
67 | 67 | ||
68 | /*! | 68 | /*! |
69 | This function implements the compare function in order to allow the | 69 | This function implements the compare function in order to allow the |
70 | searching and sorting of the QStringVector to occur | 70 | searching and sorting of the QStringVector to occur |
71 | 71 | ||
72 | \returns an int which is either | 72 | \returns an int which is either |
73 | <UL> | 73 | <UL> |
74 | <LI> < 0 if the first string is smaller than the second,</LI> | 74 | <LI> < 0 if the first string is smaller than the second,</LI> |
75 | <LI> > 0 if the first string is bigger then the second,</LI> | 75 | <LI> > 0 if the first string is bigger then the second,</LI> |
76 | <LI> == 0 if the first string is equal to the second.</LI> | 76 | <LI> == 0 if the first string is equal to the second.</LI> |
77 | </UL> | 77 | </UL> |
78 | */ | 78 | */ |
79 | int QStringVector::compareItems(Item a, Item b) | 79 | int QStringVector::compareItems(Item a, Item b) |
80 | { | 80 | { |
81 | QString *qa = (QString *)a; | 81 | QString *qa = (QString *)a; |
82 | QString *qb = (QString *)b; | 82 | QString *qb = (QString *)b; |
83 | 83 | ||
84 | return QString::compare(*qa, *qb); | 84 | return QString::compare(*qa, *qb); |
85 | } | 85 | } |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | \class TVVariant | 88 | \class TVVariant |
89 | A way of abstracting void * and keeping information on | 89 | A way of abstracting void * and keeping information on |
90 | the keytypes and behaviours in one place | 90 | the keytypes and behaviours in one place |
91 | */ | 91 | */ |
92 | 92 | ||
93 | TVVariantPrivate::TVVariantPrivate() | 93 | TVVariantPrivate::TVVariantPrivate() |
94 | { | 94 | { |
95 | typ = TVVariant::Invalid; | 95 | typ = TVVariant::Invalid; |
96 | } | 96 | } |
97 | 97 | ||
98 | TVVariantPrivate::TVVariantPrivate( TVVariantPrivate *d) | 98 | TVVariantPrivate::TVVariantPrivate( TVVariantPrivate *d) |
99 | { | 99 | { |
100 | switch(d->typ) | 100 | switch(d->typ) |
101 | { | 101 | { |
102 | case TVVariant::Invalid: | 102 | case TVVariant::Invalid: |
103 | break; | 103 | break; |
104 | case TVVariant::String: | 104 | case TVVariant::String: |
105 | value.ptr = new QString(*((QString *)d->value.ptr)); | 105 | value.ptr = new QString(*((QString *)d->value.ptr)); |
106 | break; | 106 | break; |
107 | case TVVariant::Date: | 107 | case TVVariant::Date: |
108 | value.ptr = new QDate(*((QDate *)d->value.ptr)); | 108 | value.ptr = new QDate(*((QDate *)d->value.ptr)); |
109 | break; | 109 | break; |
110 | case TVVariant::Time: | 110 | case TVVariant::Time: |
111 | value.ptr = new QTime(*((QTime *)d->value.ptr)); | 111 | value.ptr = new QTime(*((QTime *)d->value.ptr)); |
112 | break; | 112 | break; |
113 | case TVVariant::Int: | 113 | case TVVariant::Int: |
114 | value.i = d->value.i; | 114 | value.i = d->value.i; |
115 | break; | 115 | break; |
116 | default: | 116 | default: |
117 | ASSERT( 0 ); | 117 | ASSERT( 0 ); |
118 | } | 118 | } |
119 | 119 | ||
120 | typ = d->typ; | 120 | typ = d->typ; |
121 | } | 121 | } |
@@ -217,273 +217,273 @@ TVVariant& TVVariant::operator=(const TVVariant& variant ) | |||
217 | 217 | ||
218 | void TVVariant::detach() | 218 | void TVVariant::detach() |
219 | { | 219 | { |
220 | if (d->count == 1) | 220 | if (d->count == 1) |
221 | return; | 221 | return; |
222 | 222 | ||
223 | d->deref(); | 223 | d->deref(); |
224 | d = new TVVariantPrivate(d); | 224 | d = new TVVariantPrivate(d); |
225 | } | 225 | } |
226 | 226 | ||
227 | const QString TVVariant::typeName() const | 227 | const QString TVVariant::typeName() const |
228 | { | 228 | { |
229 | return typeToName(d->typ); | 229 | return typeToName(d->typ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void TVVariant::clear() | 232 | void TVVariant::clear() |
233 | { | 233 | { |
234 | if (d->count > 1) | 234 | if (d->count > 1) |
235 | { | 235 | { |
236 | d->deref(); | 236 | d->deref(); |
237 | d = new TVVariantPrivate; | 237 | d = new TVVariantPrivate; |
238 | return; | 238 | return; |
239 | } | 239 | } |
240 | 240 | ||
241 | d->clear(); | 241 | d->clear(); |
242 | } | 242 | } |
243 | 243 | ||
244 | const QString TVVariant::typeToName(KeyType typ) | 244 | const QString TVVariant::typeToName(KeyType typ) |
245 | { | 245 | { |
246 | switch(typ) { | 246 | switch(typ) { |
247 | case String: | 247 | case String: |
248 | return QString("String"); | 248 | return QString("String"); |
249 | case Date: | 249 | case Date: |
250 | return QString("Date"); | 250 | return QString("Date"); |
251 | case Time: | 251 | case Time: |
252 | return QString("Time"); | 252 | return QString("Time"); |
253 | case Int: | 253 | case Int: |
254 | return QString("Int"); | 254 | return QString("Int"); |
255 | case Invalid: | 255 | case Invalid: |
256 | default: | 256 | default: |
257 | return QString("Invalid"); | 257 | return QString("Invalid"); |
258 | } | 258 | } |
259 | return QString("Invalid"); | 259 | return QString("Invalid"); |
260 | } | 260 | } |
261 | 261 | ||
262 | TVVariant::KeyType TVVariant::nameToType(const QString &name) | 262 | TVVariant::KeyType TVVariant::nameToType(const QString &name) |
263 | { | 263 | { |
264 | if(!qstrcmp("String", name)) | 264 | if(!qstrcmp("String", name)) |
265 | return String; | 265 | return String; |
266 | if(!qstrcmp("Date", name)) | 266 | if(!qstrcmp("Date", name)) |
267 | return Date; | 267 | return Date; |
268 | if(!qstrcmp("Time", name)) | 268 | if(!qstrcmp("Time", name)) |
269 | return Time; | 269 | return Time; |
270 | if(!qstrcmp("Int", name)) | 270 | if(!qstrcmp("Int", name)) |
271 | return Int; | 271 | return Int; |
272 | 272 | ||
273 | return Invalid; | 273 | return Invalid; |
274 | } | 274 | } |
275 | 275 | ||
276 | void TVVariant::load(QDataStream &s ) | 276 | void TVVariant::load(QDataStream &s ) |
277 | { | 277 | { |
278 | KeyType t; | 278 | KeyType t; |
279 | s >> t; | 279 | s >> t; |
280 | 280 | ||
281 | d->typ = t; | 281 | d->typ = t; |
282 | switch(t) { | 282 | switch(t) { |
283 | case Invalid: | 283 | case Invalid: |
284 | d->typ = t; | 284 | d->typ = t; |
285 | break; | 285 | break; |
286 | case String: | 286 | case String: |
287 | { | 287 | { |
288 | QString *x = new QString; | 288 | QString *x = new QString; |
289 | s >> *x; | 289 | s >> *x; |
290 | d->value.ptr = x; | 290 | d->value.ptr = x; |
291 | } | 291 | } |
292 | break; | 292 | break; |
293 | case Time: | 293 | case Time: |
294 | { | 294 | { |
295 | QTime *x = new QTime; | 295 | QTime *x = new QTime; |
296 | s >> *x; | 296 | s >> *x; |
297 | d->value.ptr = x; | 297 | d->value.ptr = x; |
298 | } | 298 | } |
299 | break; | 299 | break; |
300 | case Date: | 300 | case Date: |
301 | { | 301 | { |
302 | QDate *x = new QDate; | 302 | QDate *x = new QDate; |
303 | s >> *x; | 303 | s >> *x; |
304 | d->value.ptr = x; | 304 | d->value.ptr = x; |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | case Int: | 307 | case Int: |
308 | { | 308 | { |
309 | int x; | 309 | int x; |
310 | s >> x; | 310 | s >> x; |
311 | d->value.i = x; | 311 | d->value.i = x; |
312 | } | 312 | } |
313 | break; | 313 | break; |
314 | default: | 314 | default: |
315 | qFatal("Unrecognized data type"); | 315 | qFatal("Unrecognized data type"); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void TVVariant::save( QDataStream &s ) const | 319 | void TVVariant::save( QDataStream &s ) const |
320 | { | 320 | { |
321 | s << type(); | 321 | s << type(); |
322 | 322 | ||
323 | switch( d->typ ) { | 323 | switch( d->typ ) { |
324 | case String: | 324 | case String: |
325 | s << *((QString *)d->value.ptr); | 325 | s << *((QString *)d->value.ptr); |
326 | break; | 326 | break; |
327 | case Date: | 327 | case Date: |
328 | s << *((QDate *)d->value.ptr); | 328 | s << *((QDate *)d->value.ptr); |
329 | break; | 329 | break; |
330 | case Time: | 330 | case Time: |
331 | s << *((QTime *)d->value.ptr); | 331 | s << *((QTime *)d->value.ptr); |
332 | break; | 332 | break; |
333 | case Int: | 333 | case Int: |
334 | s << d->value.i; | 334 | s << d->value.i; |
335 | break; | 335 | break; |
336 | case Invalid: | 336 | case Invalid: |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | QDataStream& operator>>(QDataStream& s, TVVariant& p) | 341 | QDataStream& operator>>(QDataStream& s, TVVariant& p) |
342 | { | 342 | { |
343 | p.load( s ); | 343 | p.load( s ); |
344 | return s; | 344 | return s; |
345 | } | 345 | } |
346 | 346 | ||
347 | QDataStream& operator<<(QDataStream &s, const TVVariant& p) | 347 | QDataStream& operator<<(QDataStream &s, const TVVariant& p) |
348 | { | 348 | { |
349 | p.save( s ); | 349 | p.save( s ); |
350 | return s; | 350 | return s; |
351 | } | 351 | } |
352 | 352 | ||
353 | QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p) | 353 | QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p) |
354 | { | 354 | { |
355 | Q_UINT8 u = 0; | 355 | Q_UINT8 u = 0; |
356 | s >> u; | 356 | s >> u; |
357 | p = (TVVariant::KeyType) u; | 357 | p = (TVVariant::KeyType) u; |
358 | 358 | ||
359 | return s; | 359 | return s; |
360 | } | 360 | } |
361 | 361 | ||
362 | QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p) | 362 | QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p) |
363 | { | 363 | { |
364 | s << (Q_UINT8)p; | 364 | s << (Q_UINT8)p; |
365 | return s; | 365 | return s; |
366 | } | 366 | } |
367 | 367 | ||
368 | const QString TVVariant::toString() const | 368 | const QString TVVariant::toString() const |
369 | { | 369 | { |
370 | switch(d->typ) { | 370 | switch(d->typ) { |
371 | case String: | 371 | case String: |
372 | return *((QString*)d->value.ptr); | 372 | return *((QString*)d->value.ptr); |
373 | case Date: | 373 | case Date: |
374 | return ((QDate*)d->value.ptr)->toString(); | 374 | return ((QDate*)d->value.ptr)->toString(); |
375 | case Time: | 375 | case Time: |
376 | return ((QTime*)d->value.ptr)->toString(); | 376 | return ((QTime*)d->value.ptr)->toString(); |
377 | case Int: | 377 | case Int: |
378 | return QString::number(d->value.i); | 378 | return QString::number(d->value.i); |
379 | case Invalid: | 379 | case Invalid: |
380 | default: | 380 | default: |
381 | return QString::null; | 381 | return QString::null; |
382 | } | 382 | } |
383 | return QString::null; | 383 | return QString::null; |
384 | } | 384 | } |
385 | 385 | ||
386 | // TODO DO, this properly, */ | 386 | // TODO DO, this properly, */ |
387 | int TVVariant::toInt() const | 387 | int TVVariant::toInt() const |
388 | { | 388 | { |
389 | if(d->typ == Int) | 389 | if(d->typ == Int) |
390 | return d->value.i; | 390 | return d->value.i; |
391 | 391 | ||
392 | if(d->typ == String) { | 392 | if(d->typ == String) { |
393 | QString tmpq(*(QString *)d->value.ptr); | 393 | QString tmpq(*(QString *)d->value.ptr); |
394 | return parseNextNumber(&tmpq); | 394 | return parseNextNumber(&tmpq); |
395 | } | 395 | } |
396 | 396 | ||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | const QDate TVVariant::toDate() const | 400 | const QDate TVVariant::toDate() const |
401 | { | 401 | { |
402 | if(d->typ == Date) | 402 | if(d->typ == Date) |
403 | return *((QDate *)d->value.ptr); | 403 | return *((QDate *)d->value.ptr); |
404 | 404 | ||
405 | if(d->typ == String) { | 405 | if(d->typ == String) { |
406 | QString q = toString(); | 406 | QString q = toString(); |
407 | 407 | ||
408 | /* date format is day mon d yyyy */ | 408 | /* date format is day mon d yyyy */ |
409 | /* ignore the first three letters, read the next | 409 | /* ignore the first three letters, read the next |
410 | three for month.. etc */ | 410 | three for month.. etc */ |
411 | 411 | ||
412 | int day = parseNextNumber(&q); | 412 | int day = parseNextNumber(&q); |
413 | int month = parseNextNumber(&q); | 413 | int month = parseNextNumber(&q); |
414 | int year = parseNextNumber(&q); | 414 | int year = parseNextNumber(&q); |
415 | if (!QDate::isValid(year, month, day)) | 415 | if (!QDate::isValid(year, month, day)) |
416 | return QDate(); | 416 | return QDate(); |
417 | return QDate(year, month, day); | 417 | return QDate(year, month, day); |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | return QDate(); | 421 | return QDate(); |
422 | } | 422 | } |
423 | 423 | ||
424 | const QTime TVVariant::toTime() const | 424 | const QTime TVVariant::toTime() const |
425 | { | 425 | { |
426 | if(d->typ == Time) | 426 | if(d->typ == Time) |
427 | return *((QTime *)d->value.ptr); | 427 | return *((QTime *)d->value.ptr); |
428 | 428 | ||
429 | if(d->typ == String) { | 429 | if(d->typ == String) { |
430 | QString q = toString(); | 430 | QString q = toString(); |
431 | int hour = parseNextNumber(&q); | 431 | int hour = parseNextNumber(&q); |
432 | int minute = parseNextNumber(&q); | 432 | int minute = parseNextNumber(&q); |
433 | int second = parseNextNumber(&q); | 433 | int second = parseNextNumber(&q); |
434 | int msecond = parseNextNumber(&q); | 434 | int msecond = parseNextNumber(&q); |
435 | if (!QTime::isValid(hour, minute, second, msecond)) | 435 | if (!QTime::isValid(hour, minute, second, msecond)) |
436 | return QTime(); | 436 | return QTime(); |
437 | return QTime(hour, minute, second, msecond); | 437 | return QTime(hour, minute, second, msecond); |
438 | } | 438 | } |
439 | 439 | ||
440 | return QTime(); | 440 | return QTime(); |
441 | } | 441 | } |
442 | 442 | ||
443 | #define TV_VARIANT_AS( f ) Q##f& TVVariant::as##f() { \ | 443 | #define TV_VARIANT_AS( f ) Q##f& TVVariant::as##f() { \ |
444 | if ( d->typ != f ) \ | 444 | if ( d->typ != f ) \ |
445 | *this = TVVariant( to##f() ); \ | 445 | *this = TVVariant( to##f() ); \ |
446 | else \ | 446 | else \ |
447 | detach(); \ | 447 | detach(); \ |
448 | return *((Q##f*)d->value.ptr); } | 448 | return *((Q##f*)d->value.ptr); } |
449 | 449 | ||
450 | TV_VARIANT_AS(String) | 450 | TV_VARIANT_AS(String) |
451 | TV_VARIANT_AS(Date) | 451 | TV_VARIANT_AS(Date) |
452 | TV_VARIANT_AS(Time) | 452 | TV_VARIANT_AS(Time) |
453 | 453 | ||
454 | #undef TV_VARIANT_AS | 454 | #undef TV_VARIANT_AS |
455 | 455 | ||
456 | int& TVVariant::asInt() | 456 | int& TVVariant::asInt() |
457 | { | 457 | { |
458 | detach(); | 458 | detach(); |
459 | if (d->typ != Int) { | 459 | if (d->typ != Int) { |
460 | d->value.i = toInt(); | 460 | d->value.i = toInt(); |
461 | d->typ = Int; | 461 | d->typ = Int; |
462 | } | 462 | } |
463 | return d->value.i; | 463 | return d->value.i; |
464 | } | 464 | } |
465 | 465 | ||
466 | /*! | 466 | /*! |
467 | valid cast is | 467 | valid cast is |
468 | anything to String | 468 | anything to String |
469 | same to same | 469 | same to same |
470 | */ | 470 | */ |
471 | bool TVVariant::canCast(KeyType t) const | 471 | bool TVVariant::canCast(KeyType t) const |
472 | { | 472 | { |
473 | if(d->typ == t) | 473 | if(d->typ == t) |
474 | return TRUE; | 474 | return TRUE; |
475 | 475 | ||
476 | if(t == String) | 476 | if(t == String) |
477 | return TRUE; | 477 | return TRUE; |
478 | 478 | ||
479 | if(t == Int) { | 479 | if(t == Int) { |
480 | if (d->typ == Date) | 480 | if (d->typ == Date) |
481 | return TRUE; | 481 | return TRUE; |
482 | if (d->typ == Time) | 482 | if (d->typ == Time) |
483 | return TRUE; | 483 | return TRUE; |
484 | if (d->typ == String) | 484 | if (d->typ == String) |
485 | return TRUE; | 485 | return TRUE; |
486 | } | 486 | } |
487 | 487 | ||
488 | return FALSE; | 488 | return FALSE; |
489 | } | 489 | } |
@@ -591,315 +591,315 @@ bool TVVariant::closer(TVVariant n, TVVariant o) | |||
591 | if (diff2 < 0) | 591 | if (diff2 < 0) |
592 | diff2 = -diff2; | 592 | diff2 = -diff2; |
593 | 593 | ||
594 | if (diff1 < diff2) | 594 | if (diff1 < diff2) |
595 | return TRUE; | 595 | return TRUE; |
596 | return FALSE; | 596 | return FALSE; |
597 | } | 597 | } |
598 | case Date: { | 598 | case Date: { |
599 | QDate i1 = n.toDate(); | 599 | QDate i1 = n.toDate(); |
600 | QDate i2 = o.toDate(); | 600 | QDate i2 = o.toDate(); |
601 | QDate iv = toDate(); | 601 | QDate iv = toDate(); |
602 | 602 | ||
603 | /* definition of closer is the least difference in days */ | 603 | /* definition of closer is the least difference in days */ |
604 | int diff1 = i1.daysTo(iv); | 604 | int diff1 = i1.daysTo(iv); |
605 | if (diff1 < 0) | 605 | if (diff1 < 0) |
606 | diff1 = -diff1; | 606 | diff1 = -diff1; |
607 | int diff2 = i2.daysTo(iv); | 607 | int diff2 = i2.daysTo(iv); |
608 | if (diff2 < 0) | 608 | if (diff2 < 0) |
609 | diff2 = -diff2; | 609 | diff2 = -diff2; |
610 | 610 | ||
611 | if (diff1 < diff2) | 611 | if (diff1 < diff2) |
612 | return TRUE; | 612 | return TRUE; |
613 | return FALSE; | 613 | return FALSE; |
614 | } | 614 | } |
615 | case Time: { | 615 | case Time: { |
616 | QTime i1 = n.toTime(); | 616 | QTime i1 = n.toTime(); |
617 | QTime i2 = o.toTime(); | 617 | QTime i2 = o.toTime(); |
618 | QTime iv = toTime(); | 618 | QTime iv = toTime(); |
619 | 619 | ||
620 | /* definition of closer is the least difference in days */ | 620 | /* definition of closer is the least difference in days */ |
621 | int diff1 = i1.msecsTo(iv); | 621 | int diff1 = i1.msecsTo(iv); |
622 | if (diff1 < 0) | 622 | if (diff1 < 0) |
623 | diff1 = -diff1; | 623 | diff1 = -diff1; |
624 | int diff2 = i2.msecsTo(iv); | 624 | int diff2 = i2.msecsTo(iv); |
625 | if (diff2 < 0) | 625 | if (diff2 < 0) |
626 | diff2 = -diff2; | 626 | diff2 = -diff2; |
627 | if (diff1 < diff2) | 627 | if (diff1 < diff2) |
628 | return TRUE; | 628 | return TRUE; |
629 | return FALSE; | 629 | return FALSE; |
630 | } | 630 | } |
631 | default: | 631 | default: |
632 | /* don't know how to do 'closer' on this type, hence never closer | 632 | /* don't know how to do 'closer' on this type, hence never closer |
633 | * or even close */ | 633 | * or even close */ |
634 | break; | 634 | break; |
635 | } | 635 | } |
636 | return FALSE; | 636 | return FALSE; |
637 | } | 637 | } |
638 | 638 | ||
639 | /*! True if n is close to this */ | 639 | /*! True if n is close to this */ |
640 | bool TVVariant::close(TVVariant n) | 640 | bool TVVariant::close(TVVariant n) |
641 | { | 641 | { |
642 | /* Nothing is close to an invalid, so nothing can be closer */ | 642 | /* Nothing is close to an invalid, so nothing can be closer */ |
643 | if(type() == Invalid) | 643 | if(type() == Invalid) |
644 | return FALSE; | 644 | return FALSE; |
645 | 645 | ||
646 | /* can't be close if of different type */ | 646 | /* can't be close if of different type */ |
647 | if(n.type() != type()) | 647 | if(n.type() != type()) |
648 | return FALSE; | 648 | return FALSE; |
649 | 649 | ||
650 | switch(type()){ | 650 | switch(type()){ |
651 | case String: { | 651 | case String: { |
652 | /* case for strings is close is a substring.. closer is | 652 | /* case for strings is close is a substring.. closer is |
653 | * earlier alphabetically */ | 653 | * earlier alphabetically */ |
654 | QString qs1 = n.toString().lower(); | 654 | QString qs1 = n.toString().lower(); |
655 | QString qsv = toString().lower(); | 655 | QString qsv = toString().lower(); |
656 | 656 | ||
657 | if (!qs1.startsWith(qsv)) | 657 | if (!qs1.startsWith(qsv)) |
658 | return FALSE; | 658 | return FALSE; |
659 | return TRUE; | 659 | return TRUE; |
660 | } | 660 | } |
661 | case Int: | 661 | case Int: |
662 | case Date: | 662 | case Date: |
663 | case Time: | 663 | case Time: |
664 | return TRUE; | 664 | return TRUE; |
665 | default: | 665 | default: |
666 | /* don't know how to do 'closer' on this type, hence never closer | 666 | /* don't know how to do 'closer' on this type, hence never closer |
667 | * or even close */ | 667 | * or even close */ |
668 | break; | 668 | break; |
669 | } | 669 | } |
670 | return FALSE; | 670 | return FALSE; |
671 | } | 671 | } |
672 | 672 | ||
673 | /*! | 673 | /*! |
674 | \class Key | 674 | \class Key |
675 | \brief document me! | 675 | \brief document me! |
676 | 676 | ||
677 | document me! | 677 | document me! |
678 | */ | 678 | */ |
679 | 679 | ||
680 | Key::Key() : kname(), kexample(), kflags(0) { } | 680 | Key::Key() : kname(), kexample(), kflags(0) { } |
681 | 681 | ||
682 | Key::Key(QString name, TVVariant example, int flags = 0) : | 682 | Key::Key(QString name, TVVariant example, int flags = 0) : |
683 | kname(name), kexample(example), kflags(flags) { } | 683 | kname(name), kexample(example), kflags(flags) { } |
684 | 684 | ||
685 | Key::Key(const Key &other) | 685 | Key::Key(const Key &other) |
686 | { | 686 | { |
687 | kname = other.kname; | 687 | kname = other.kname; |
688 | kexample = other.kexample; | 688 | kexample = other.kexample; |
689 | kflags = other.kflags; | 689 | kflags = other.kflags; |
690 | } | 690 | } |
691 | 691 | ||
692 | Key& Key::operator=(const Key& key) | 692 | Key& Key::operator=(const Key& key) |
693 | { | 693 | { |
694 | kname = key.kname; | 694 | kname = key.kname; |
695 | kexample = key.kexample; | 695 | kexample = key.kexample; |
696 | kflags = key.kflags; | 696 | kflags = key.kflags; |
697 | return *this; | 697 | return *this; |
698 | } | 698 | } |
699 | 699 | ||
700 | QString Key::name() const | 700 | QString Key::name() const |
701 | { | 701 | { |
702 | return QString(kname); | 702 | return QString(kname); |
703 | } | 703 | } |
704 | 704 | ||
705 | TVVariant Key::example() const | 705 | TVVariant Key::example() const |
706 | { | 706 | { |
707 | return TVVariant(kexample); | 707 | return TVVariant(kexample); |
708 | } | 708 | } |
709 | 709 | ||
710 | TVVariant::KeyType Key::type() const | 710 | TVVariant::KeyType Key::type() const |
711 | { | 711 | { |
712 | return kexample.type(); | 712 | return kexample.type(); |
713 | } | 713 | } |
714 | 714 | ||
715 | void Key::setName(const QString &name) | 715 | void Key::setName(const QString &name) |
716 | { | 716 | { |
717 | kname = QString(name); | 717 | kname = QString(name); |
718 | } | 718 | } |
719 | 719 | ||
720 | void Key::setExample(const TVVariant &e) | 720 | void Key::setExample(const TVVariant &e) |
721 | { | 721 | { |
722 | kexample = TVVariant(e); | 722 | kexample = TVVariant(e); |
723 | } | 723 | } |
724 | 724 | ||
725 | int Key::flags() const | 725 | int Key::flags() const |
726 | { | 726 | { |
727 | return kflags; | 727 | return kflags; |
728 | } | 728 | } |
729 | 729 | ||
730 | void Key::setFlags(int fl) | 730 | void Key::setFlags(int fl) |
731 | { | 731 | { |
732 | kflags = fl; | 732 | kflags = fl; |
733 | } | 733 | } |
734 | 734 | ||
735 | bool Key::delFlag() const | 735 | bool Key::delFlag() const |
736 | { | 736 | { |
737 | if(kflags & del_flag) | 737 | if(kflags & del_flag) |
738 | return TRUE; | 738 | return TRUE; |
739 | return FALSE; | 739 | return FALSE; |
740 | } | 740 | } |
741 | 741 | ||
742 | bool Key::newFlag() const | 742 | bool Key::newFlag() const |
743 | { | 743 | { |
744 | if(kflags & new_flag) | 744 | if(kflags & new_flag) |
745 | return TRUE; | 745 | return TRUE; |
746 | return FALSE; | 746 | return FALSE; |
747 | } | 747 | } |
748 | 748 | ||
749 | void Key::setDelFlag(bool v) | 749 | void Key::setDelFlag(bool v) |
750 | { | 750 | { |
751 | if(delFlag() != v) | 751 | if(delFlag() != v) |
752 | kflags = kflags ^ del_flag; | 752 | kflags = kflags ^ del_flag; |
753 | } | 753 | } |
754 | 754 | ||
755 | void Key::setNewFlag(bool v) | 755 | void Key::setNewFlag(bool v) |
756 | { | 756 | { |
757 | if(newFlag() != v) | 757 | if(newFlag() != v) |
758 | kflags = kflags ^ new_flag; | 758 | kflags = kflags ^ new_flag; |
759 | } | 759 | } |
760 | 760 | ||
761 | /*! | 761 | /*! |
762 | \class KeyList | 762 | \class KeyList |
763 | \brief A represntation of keys used for a table. | 763 | \brief A represntation of keys used for a table. |
764 | 764 | ||
765 | The KeyList class is used to store the representation of keys used in table | 765 | The KeyList class is used to store the representation of keys used in table |
766 | headings by DBStore. It stores the names and types of the keys | 766 | headings by DBStore. It stores the names and types of the keys |
767 | */ | 767 | */ |
768 | 768 | ||
769 | /*! | 769 | /*! |
770 | Constructs a KeyList | 770 | Constructs a KeyList |
771 | */ | 771 | */ |
772 | KeyList::KeyList() : QIntDict<Key>(20) | 772 | KeyList::KeyList() : QIntDict<Key>(20) |
773 | { | 773 | { |
774 | setAutoDelete(TRUE); | 774 | setAutoDelete(TRUE); |
775 | } | 775 | } |
776 | 776 | ||
777 | /* Should be deep copy, but isn't */ | 777 | /* Should be deep copy, but isn't */ |
778 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) | 778 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) |
779 | { | 779 | { |
780 | KeyListIterator it(k); | 780 | KeyListIterator it(k); |
781 | while(it.current()) { | 781 | while(it.current()) { |
782 | replace(it.currentKey(), new Key(*it.current())); | 782 | replace(it.currentKey(), new Key(*it.current())); |
783 | ++it; | 783 | ++it; |
784 | } | 784 | } |
785 | 785 | ||
786 | setAutoDelete(TRUE); | 786 | setAutoDelete(TRUE); |
787 | } | 787 | } |
788 | 788 | ||
789 | /*! | 789 | /*! |
790 | Destroys a KeyList | 790 | Destroys a KeyList |
791 | */ | 791 | */ |
792 | KeyList::~KeyList() { | 792 | KeyList::~KeyList() { |
793 | } | 793 | } |
794 | 794 | ||
795 | /* Do a comparision base on Keys */ | 795 | /* Do a comparision base on Keys */ |
796 | bool KeyList::operator!=(const KeyList &other) | 796 | bool KeyList::operator!=(const KeyList &other) |
797 | { | 797 | { |
798 | KeyListIterator it(*this); | 798 | KeyListIterator it(*this); |
799 | 799 | ||
800 | if (other.getNumFields() != getNumFields()) | 800 | if (other.getNumFields() != getNumFields()) |
801 | return TRUE; | 801 | return TRUE; |
802 | 802 | ||
803 | while(it.current()) { | 803 | while(it.current()) { |
804 | //it.currentKey(), it.current(); | 804 | //it.currentKey(), it.current(); |
805 | if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) | 805 | if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) |
806 | return TRUE; | 806 | return TRUE; |
807 | if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) | 807 | if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) |
808 | return TRUE; | 808 | return TRUE; |
809 | ++it; | 809 | ++it; |
810 | } | 810 | } |
811 | return FALSE; | 811 | return FALSE; |
812 | } | 812 | } |
813 | 813 | ||
814 | /*! | 814 | /*! |
815 | Returns the number of keys stored in the KeyList | 815 | Returns the number of keys stored in the KeyList |
816 | */ | 816 | */ |
817 | int KeyList::getNumFields() const | 817 | int KeyList::getNumFields() const |
818 | { | 818 | { |
819 | return count(); | 819 | return count(); |
820 | } | 820 | } |
821 | 821 | ||
822 | /*! | 822 | /*! |
823 | Adds a new key to the KeyList | 823 | Adds a new key to the KeyList |
824 | 824 | ||
825 | \param name the name of the new key | 825 | \param name the name of the new key |
826 | \param type the type of the new key | 826 | \param type the type of the new key |
827 | */ | 827 | */ |
828 | int KeyList::addKey(QString name, TVVariant example) | 828 | int KeyList::addKey(QString name, TVVariant example) |
829 | { | 829 | { |
830 | int i = count(); | 830 | int i = count(); |
831 | while(find(i) && (i > -1)) | 831 | while(find(i) && (i > -1)) |
832 | i--; | 832 | i--; |
833 | replace(i, new Key(name, example, 0)); | 833 | replace(i, new Key(name, example, 0)); |
834 | return i; | 834 | return i; |
835 | } | 835 | } |
836 | 836 | ||
837 | int KeyList::addKey(QString name, TVVariant::KeyType type) | 837 | int KeyList::addKey(QString name, TVVariant::KeyType type) |
838 | { | 838 | { |
839 | /* generate a valid type for the example? */ | 839 | /* generate a valid type for the example? */ |
840 | TVVariant e = TVVariant("0"); | 840 | TVVariant e = TVVariant("0"); |
841 | switch(type) { | 841 | switch(type) { |
842 | case TVVariant::String: | 842 | case TVVariant::String: |
843 | return addKey(name, TVVariant("<undefined>").asString()); | 843 | return addKey(name, TVVariant("<undefined>").asString()); |
844 | break; | 844 | break; |
845 | case TVVariant::Date: | 845 | case TVVariant::Date: |
846 | return addKey(name, TVVariant(QDate::currentDate()).asDate()); | 846 | return addKey(name, TVVariant(QDate::currentDate()).asDate()); |
847 | break; | 847 | break; |
848 | case TVVariant::Time: | 848 | case TVVariant::Time: |
849 | return addKey(name, TVVariant(QTime(0,0,0)).toTime()); | 849 | return addKey(name, TVVariant(QTime(0,0,0)).toTime()); |
850 | break; | 850 | break; |
851 | case TVVariant::Int: | 851 | case TVVariant::Int: |
852 | return addKey(name, TVVariant(0).toInt()); | 852 | return addKey(name, TVVariant(0).toInt()); |
853 | break; | 853 | break; |
854 | default: | 854 | default: |
855 | qWarning(QObject::tr("KeyList::addKey() Cannot make default " | 855 | qWarning(QObject::tr("KeyList::addKey() Cannot make default " |
856 | "value for type %1, Key not added.").arg(type)); | 856 | "value for type %1, Key not added.").arg(type)); |
857 | break; | 857 | break; |
858 | } | 858 | } |
859 | return -1; | 859 | return -1; |
860 | } | 860 | } |
861 | 861 | ||
862 | void KeyList::setKeyFlags(int i, int flag) | 862 | void KeyList::setKeyFlags(int i, int flag) |
863 | { | 863 | { |
864 | if(find(i)) | 864 | if(find(i)) |
865 | find(i)->setFlags(flag); | 865 | find(i)->setFlags(flag); |
866 | } | 866 | } |
867 | 867 | ||
868 | int KeyList::getKeyFlags(int i) const | 868 | int KeyList::getKeyFlags(int i) const |
869 | { | 869 | { |
870 | if(find(i)) | 870 | if(find(i)) |
871 | return find(i)->flags(); | 871 | return find(i)->flags(); |
872 | return 0; | 872 | return 0; |
873 | } | 873 | } |
874 | 874 | ||
875 | bool KeyList::checkNewFlag(int i) const | 875 | bool KeyList::checkNewFlag(int i) const |
876 | { | 876 | { |
877 | if (find(i)) | 877 | if (find(i)) |
878 | return find(i)->newFlag(); | 878 | return find(i)->newFlag(); |
879 | return false; | 879 | return false; |
880 | } | 880 | } |
881 | 881 | ||
882 | void KeyList::setNewFlag(int i, bool f) | 882 | void KeyList::setNewFlag(int i, bool f) |
883 | { | 883 | { |
884 | if(!find(i)) | 884 | if(!find(i)) |
885 | return; | 885 | return; |
886 | find(i)->setNewFlag(f); | 886 | find(i)->setNewFlag(f); |
887 | } | 887 | } |
888 | 888 | ||
889 | bool KeyList::checkDeleteFlag(int i) const | 889 | bool KeyList::checkDeleteFlag(int i) const |
890 | { | 890 | { |
891 | if (find(i)) | 891 | if (find(i)) |
892 | return find(i)->delFlag(); | 892 | return find(i)->delFlag(); |
893 | return false; | 893 | return false; |
894 | } | 894 | } |
895 | 895 | ||
896 | void KeyList::setDeleteFlag(int i, bool f) | 896 | void KeyList::setDeleteFlag(int i, bool f) |
897 | { | 897 | { |
898 | if(!find(i)) | 898 | if(!find(i)) |
899 | return; | 899 | return; |
900 | find(i)->setDelFlag(f); | 900 | find(i)->setDelFlag(f); |
901 | } | 901 | } |
902 | 902 | ||
903 | /*! | 903 | /*! |
904 | Returns the name of the key at index i | 904 | Returns the name of the key at index i |
905 | */ | 905 | */ |
@@ -1089,281 +1089,281 @@ QDataStream &operator>>( QDataStream &s, DataElem &d) | |||
1089 | } | 1089 | } |
1090 | return s; | 1090 | return s; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | /*! Returns the number of possible (not valid) fields in the data element */ | 1093 | /*! Returns the number of possible (not valid) fields in the data element */ |
1094 | int DataElem::getNumFields() const | 1094 | int DataElem::getNumFields() const |
1095 | { | 1095 | { |
1096 | return contained->getNumFields(); | 1096 | return contained->getNumFields(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | KeyList DataElem::getKeys() const | 1099 | KeyList DataElem::getKeys() const |
1100 | { | 1100 | { |
1101 | return *(contained->getKeys()); | 1101 | return *(contained->getKeys()); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | /*! | 1104 | /*! |
1105 | This function determines whether field index i of the element has been | 1105 | This function determines whether field index i of the element has been |
1106 | set yet. | 1106 | set yet. |
1107 | 1107 | ||
1108 | \return A boolean value that is TRUE if the specfied field of this | 1108 | \return A boolean value that is TRUE if the specfied field of this |
1109 | element has been set and FALSE if the field has not yet been set | 1109 | element has been set and FALSE if the field has not yet been set |
1110 | */ | 1110 | */ |
1111 | bool DataElem::hasValidValue(int i) const | 1111 | bool DataElem::hasValidValue(int i) const |
1112 | { | 1112 | { |
1113 | if(!values.find(i)) | 1113 | if(!values.find(i)) |
1114 | return FALSE; | 1114 | return FALSE; |
1115 | if(!contained->getKeys()->validIndex(i)) | 1115 | if(!contained->getKeys()->validIndex(i)) |
1116 | return FALSE; | 1116 | return FALSE; |
1117 | return values.find(i)->isValid(); | 1117 | return values.find(i)->isValid(); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | /*! | 1120 | /*! |
1121 | This function determines whether field name qs of the element has been | 1121 | This function determines whether field name qs of the element has been |
1122 | set yet. | 1122 | set yet. |
1123 | 1123 | ||
1124 | \return A boolean value that is TRUE if the specfied field of this | 1124 | \return A boolean value that is TRUE if the specfied field of this |
1125 | element has been set and FALSE if the field has not yet been set | 1125 | element has been set and FALSE if the field has not yet been set |
1126 | */ | 1126 | */ |
1127 | bool DataElem::hasValidValue(QString qs) const | 1127 | bool DataElem::hasValidValue(QString qs) const |
1128 | { | 1128 | { |
1129 | int i = contained->getKeyIndex(qs); | 1129 | int i = contained->getKeyIndex(qs); |
1130 | return hasValidValue(i); | 1130 | return hasValidValue(i); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | /*! returns the type of the field specified by index i */ | 1133 | /*! returns the type of the field specified by index i */ |
1134 | TVVariant::KeyType DataElem::getFieldType(int i) const | 1134 | TVVariant::KeyType DataElem::getFieldType(int i) const |
1135 | { | 1135 | { |
1136 | return contained->getKeyType(i); | 1136 | return contained->getKeyType(i); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | /*! returns the type of the field specified by name qs */ | 1139 | /*! returns the type of the field specified by name qs */ |
1140 | TVVariant::KeyType DataElem::getFieldType(QString qs) const | 1140 | TVVariant::KeyType DataElem::getFieldType(QString qs) const |
1141 | { | 1141 | { |
1142 | int i = contained->getKeyIndex(qs); | 1142 | int i = contained->getKeyIndex(qs); |
1143 | return contained->getKeyType(i); | 1143 | return contained->getKeyType(i); |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | /*! | 1146 | /*! |
1147 | returns a pointer to the data stored in field index i for this | 1147 | returns a pointer to the data stored in field index i for this |
1148 | data element, (value may not be valid) | 1148 | data element, (value may not be valid) |
1149 | */ | 1149 | */ |
1150 | TVVariant DataElem::getField(int i) const | 1150 | TVVariant DataElem::getField(int i) const |
1151 | { | 1151 | { |
1152 | if(hasValidValue(i)) | 1152 | if(hasValidValue(i)) |
1153 | return TVVariant(*values.find(i)); | 1153 | return TVVariant(*values.find(i)); |
1154 | return TVVariant(); | 1154 | return TVVariant(); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | /*! | 1157 | /*! |
1158 | returns a pointer to the data stored in field name qs for this | 1158 | returns a pointer to the data stored in field name qs for this |
1159 | data element, (value may not be valid) | 1159 | data element, (value may not be valid) |
1160 | */ | 1160 | */ |
1161 | TVVariant DataElem::getField(QString qs) const | 1161 | TVVariant DataElem::getField(QString qs) const |
1162 | { | 1162 | { |
1163 | int i = contained->getKeyIndex(qs); | 1163 | int i = contained->getKeyIndex(qs); |
1164 | return getField(i); | 1164 | return getField(i); |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | /*! | 1167 | /*! |
1168 | Sets the value of the elements field index i to the value represented in | 1168 | Sets the value of the elements field index i to the value represented in |
1169 | the QString q. | 1169 | the QString q. |
1170 | 1170 | ||
1171 | \param i index of the field to set | 1171 | \param i index of the field to set |
1172 | \param q a string that can be parsed to get the value to be set | 1172 | \param q a string that can be parsed to get the value to be set |
1173 | */ | 1173 | */ |
1174 | void DataElem::setField(int i, QString q) | 1174 | void DataElem::setField(int i, QString q) |
1175 | { | 1175 | { |
1176 | /* from the type of the field, parse q and store */ | 1176 | /* from the type of the field, parse q and store */ |
1177 | TVVariant::KeyType kt = contained->getKeyType(i); | 1177 | TVVariant::KeyType kt = contained->getKeyType(i); |
1178 | 1178 | ||
1179 | TVVariant t = TVVariant(q); | 1179 | TVVariant t = TVVariant(q); |
1180 | 1180 | ||
1181 | switch(kt) { | 1181 | switch(kt) { |
1182 | case TVVariant::Int: { | 1182 | case TVVariant::Int: { |
1183 | t.asInt(); | 1183 | t.asInt(); |
1184 | setField(i, t); | 1184 | setField(i, t); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | case TVVariant::String: { | 1187 | case TVVariant::String: { |
1188 | t.asString(); | 1188 | t.asString(); |
1189 | setField(i, t); | 1189 | setField(i, t); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | case TVVariant::Date: { | 1192 | case TVVariant::Date: { |
1193 | t.asDate(); | 1193 | t.asDate(); |
1194 | setField(i, t); | 1194 | setField(i, t); |
1195 | return; | 1195 | return; |
1196 | } | 1196 | } |
1197 | case TVVariant::Time: { | 1197 | case TVVariant::Time: { |
1198 | t.asTime(); | 1198 | t.asTime(); |
1199 | setField(i, t); | 1199 | setField(i, t); |
1200 | return; | 1200 | return; |
1201 | } | 1201 | } |
1202 | default: | 1202 | default: |
1203 | qWarning( | 1203 | qWarning( |
1204 | QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) | 1204 | QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) |
1205 | ); | 1205 | ); |
1206 | } | 1206 | } |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | /*! | 1209 | /*! |
1210 | Sets the value of the elements field index i to the value at the pointer | 1210 | Sets the value of the elements field index i to the value at the pointer |
1211 | value. | 1211 | value. |
1212 | 1212 | ||
1213 | \param i index of the field to set | 1213 | \param i index of the field to set |
1214 | \param value a pointer to the (already allocated) value to set | 1214 | \param value a pointer to the (already allocated) value to set |
1215 | */ | 1215 | */ |
1216 | void DataElem::setField(int i, TVVariant value) | 1216 | void DataElem::setField(int i, TVVariant value) |
1217 | { | 1217 | { |
1218 | if (value.isValid()) { | 1218 | if (value.isValid()) { |
1219 | values.remove(i); | 1219 | values.remove(i); |
1220 | values.replace(i, new TVVariant(value)); | 1220 | values.replace(i, new TVVariant(value)); |
1221 | } | 1221 | } |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | /*! | 1224 | /*! |
1225 | Sets the value of the elements field name qs to the value represented in | 1225 | Sets the value of the elements field name qs to the value represented in |
1226 | the QString q. | 1226 | the QString q. |
1227 | 1227 | ||
1228 | \param qs name of the field to set | 1228 | \param qs name of the field to set |
1229 | \param q a string that can be parsed to get the value to be set | 1229 | \param q a string that can be parsed to get the value to be set |
1230 | */ | 1230 | */ |
1231 | void DataElem::setField(QString qs, QString q) | 1231 | void DataElem::setField(QString qs, QString q) |
1232 | { | 1232 | { |
1233 | /* from the type of the field, parse q and store */ | 1233 | /* from the type of the field, parse q and store */ |
1234 | int i = contained->getKeyIndex(qs); | 1234 | int i = contained->getKeyIndex(qs); |
1235 | setField(i, qs); | 1235 | setField(i, qs); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | /*! | 1238 | /*! |
1239 | Sets the value of the elements field name qs to the value at the pointer | 1239 | Sets the value of the elements field name qs to the value at the pointer |
1240 | value. | 1240 | value. |
1241 | 1241 | ||
1242 | \param qs name of the field to set | 1242 | \param qs name of the field to set |
1243 | \param value a pointer to the (already allocated) value to set | 1243 | \param value a pointer to the (already allocated) value to set |
1244 | */ | 1244 | */ |
1245 | void DataElem::setField(QString qs, TVVariant value) | 1245 | void DataElem::setField(QString qs, TVVariant value) |
1246 | { | 1246 | { |
1247 | int i = contained->getKeyIndex(qs); | 1247 | int i = contained->getKeyIndex(qs); |
1248 | setField(i, value); | 1248 | setField(i, value); |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | void DataElem::unsetField(int i) { | 1251 | void DataElem::unsetField(int i) { |
1252 | values.remove(i); | 1252 | values.remove(i); |
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | void DataElem::unsetField(QString qs) | 1255 | void DataElem::unsetField(QString qs) |
1256 | { | 1256 | { |
1257 | int i = contained->getKeyIndex(qs); | 1257 | int i = contained->getKeyIndex(qs); |
1258 | unsetField(i); | 1258 | unsetField(i); |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | /*! | 1261 | /*! |
1262 | Converts the data element to a Rich Text QString | 1262 | Converts the data element to a Rich Text QString |
1263 | */ | 1263 | */ |
1264 | QString DataElem::toQString() const | 1264 | QString DataElem::toQString() const |
1265 | { | 1265 | { |
1266 | /* lets make an attempt at this function */ | 1266 | /* lets make an attempt at this function */ |
1267 | int i; | 1267 | int i; |
1268 | QString scratch = ""; | 1268 | QString scratch = ""; |
1269 | 1269 | ||
1270 | QIntDictIterator<TVVariant> it(values); | 1270 | QIntDictIterator<TVVariant> it(values); |
1271 | 1271 | ||
1272 | while (it.current()) { | 1272 | while (it.current()) { |
1273 | i = it.currentKey(); | 1273 | i = it.currentKey(); |
1274 | if(hasValidValue(i)) { | 1274 | if(hasValidValue(i)) { |
1275 | scratch += "<B>" + contained->getKeyName(i) + ":</B> "; | 1275 | scratch += "<B>" + contained->getKeyName(i) + ":</B> "; |
1276 | scratch += getField(i).toString(); | 1276 | scratch += getField(i).toString(); |
1277 | scratch += "<br>"; | 1277 | scratch += "<br>"; |
1278 | } | 1278 | } |
1279 | ++it; | 1279 | ++it; |
1280 | } | 1280 | } |
1281 | return scratch; | 1281 | return scratch; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | /*! formats individual fields to strings so can be displayed */ | 1284 | /*! formats individual fields to strings so can be displayed */ |
1285 | QString DataElem::toQString(int i) const | 1285 | QString DataElem::toQString(int i) const |
1286 | { | 1286 | { |
1287 | if(hasValidValue(i)) { | 1287 | if(hasValidValue(i)) { |
1288 | return getField(i).toString(); | 1288 | return getField(i).toString(); |
1289 | } | 1289 | } |
1290 | return ""; | 1290 | return ""; |
1291 | } | 1291 | } |
1292 | /*! formats individual fields to strings so can be sorted by QListView */ | 1292 | /*! formats individual fields to strings so can be sorted by QListView */ |
1293 | QString DataElem::toSortableQString(int i) const | 1293 | QString DataElem::toSortableQString(int i) const |
1294 | { | 1294 | { |
1295 | QString scratch = ""; | 1295 | QString scratch = ""; |
1296 | if(hasValidValue(i)) { | 1296 | if(hasValidValue(i)) { |
1297 | switch (contained->getKeyType(i)) { | 1297 | switch (contained->getKeyType(i)) { |
1298 | case TVVariant::String: { | 1298 | case TVVariant::String: { |
1299 | scratch += getField(i).toString(); | 1299 | scratch += getField(i).toString(); |
1300 | break; | 1300 | break; |
1301 | } | 1301 | } |
1302 | case TVVariant::Int: { | 1302 | case TVVariant::Int: { |
1303 | scratch.sprintf("%08d", getField(i).toInt()); | 1303 | scratch.sprintf("%08d", getField(i).toInt()); |
1304 | break; | 1304 | break; |
1305 | } | 1305 | } |
1306 | case TVVariant::Date: { | 1306 | case TVVariant::Date: { |
1307 | static QDate epochD(1800, 1, 1); | 1307 | static QDate epochD(1800, 1, 1); |
1308 | scratch.sprintf("%08d", | 1308 | scratch.sprintf("%08d", |
1309 | epochD.daysTo(getField(i).toDate())); | 1309 | epochD.daysTo(getField(i).toDate())); |
1310 | break; | 1310 | break; |
1311 | } | 1311 | } |
1312 | case TVVariant::Time: { | 1312 | case TVVariant::Time: { |
1313 | static QTime epochT(0, 0, 0); | 1313 | static QTime epochT(0, 0, 0); |
1314 | scratch.sprintf("%08d", | 1314 | scratch.sprintf("%08d", |
1315 | epochT.msecsTo(getField(i).toTime())); | 1315 | epochT.msecsTo(getField(i).toTime())); |
1316 | break; | 1316 | break; |
1317 | } | 1317 | } |
1318 | default: | 1318 | default: |
1319 | scratch += "Unknown type"; | 1319 | scratch += "Unknown type"; |
1320 | break; | 1320 | break; |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | return scratch; | 1323 | return scratch; |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | /* compare functions */ | 1326 | /* compare functions */ |
1327 | 1327 | ||
1328 | bool DataElem::lessThan(int i, TVVariant v) const | 1328 | bool DataElem::lessThan(int i, TVVariant v) const |
1329 | { | 1329 | { |
1330 | if (!hasValidValue(i)) return FALSE; | 1330 | if (!hasValidValue(i)) return FALSE; |
1331 | 1331 | ||
1332 | if (getField(i).type() != v.type()) | 1332 | if (getField(i).type() != v.type()) |
1333 | return FALSE; | 1333 | return FALSE; |
1334 | 1334 | ||
1335 | return (getField(i) < v); | 1335 | return (getField(i) < v); |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | bool DataElem::moreThan(int i, TVVariant v) const | 1338 | bool DataElem::moreThan(int i, TVVariant v) const |
1339 | { | 1339 | { |
1340 | if (!hasValidValue(i)) return FALSE; | 1340 | if (!hasValidValue(i)) return FALSE; |
1341 | 1341 | ||
1342 | if (getField(i).type() != v.type()) | 1342 | if (getField(i).type() != v.type()) |
1343 | return FALSE; | 1343 | return FALSE; |
1344 | 1344 | ||
1345 | return (getField(i) > v); | 1345 | return (getField(i) > v); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | bool DataElem::equalTo(int i, TVVariant v) const | 1348 | bool DataElem::equalTo(int i, TVVariant v) const |
1349 | { | 1349 | { |
1350 | if (!hasValidValue(i)) return FALSE; | 1350 | if (!hasValidValue(i)) return FALSE; |
1351 | 1351 | ||
1352 | if (getField(i).type() != v.type()) | 1352 | if (getField(i).type() != v.type()) |
1353 | return FALSE; | 1353 | return FALSE; |
1354 | 1354 | ||
1355 | return (getField(i) == v); | 1355 | return (getField(i) == v); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | bool DataElem::contains(int i, TVVariant v) const | 1358 | bool DataElem::contains(int i, TVVariant v) const |
1359 | { | 1359 | { |
1360 | if (!hasValidValue(i)) return FALSE; | 1360 | if (!hasValidValue(i)) return FALSE; |
1361 | 1361 | ||
1362 | if (getField(i).type() != v.type()) | 1362 | if (getField(i).type() != v.type()) |
1363 | return FALSE; | 1363 | return FALSE; |
1364 | 1364 | ||
1365 | switch(getField(i).type()) { | 1365 | switch(getField(i).type()) { |
1366 | case TVVariant::String: { | 1366 | case TVVariant::String: { |
1367 | QString qs1 = getField(i).toString().lower(); | 1367 | QString qs1 = getField(i).toString().lower(); |
1368 | QString qs2 = v.toString().lower(); | 1368 | QString qs2 = v.toString().lower(); |
1369 | if (qs1.contains(qs2) > 0) return TRUE; | 1369 | if (qs1.contains(qs2) > 0) return TRUE; |
diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index 736e1cf..56c567f 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp | |||
@@ -1,32 +1,32 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tableviewer.h" | 20 | #include "tableviewer.h" |
21 | #include <qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | int main( int argc, char ** argv ) | 23 | int main( int argc, char ** argv ) |
24 | { | 24 | { |
25 | QPEApplication a( argc, argv ); | 25 | QPEApplication a( argc, argv ); |
26 | 26 | ||
27 | TableViewerWindow * mw = new TableViewerWindow; | 27 | TableViewerWindow * mw = new TableViewerWindow; |
28 | mw->setCaption( TableViewerWindow::tr("Table Viewer") ); | 28 | mw->setCaption( TableViewerWindow::tr("Table Viewer") ); |
29 | a.showMainWidget(mw); | 29 | a.showMainWidget(mw); |
30 | 30 | ||
31 | return a.exec(); | 31 | return a.exec(); |
32 | } | 32 | } |
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index 0d4a412..0456b41 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp | |||
@@ -1,455 +1,455 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | /* local includes */ | 21 | /* local includes */ |
22 | #include "tableviewer.h" | 22 | #include "tableviewer.h" |
23 | #include "ui/tvbrowseview.h" | 23 | #include "ui/tvbrowseview.h" |
24 | #include "ui/tvfilterview.h" | 24 | #include "ui/tvfilterview.h" |
25 | #include "ui/tvlistview.h" | 25 | #include "ui/tvlistview.h" |
26 | #include "ui/tveditview.h" | 26 | #include "ui/tveditview.h" |
27 | #include "ui/tvkeyedit.h" | 27 | #include "ui/tvkeyedit.h" |
28 | #include "db/datacache.h" | 28 | #include "db/datacache.h" |
29 | 29 | ||
30 | /* QPE includes */ | 30 | /* QPE includes */ |
31 | #include "fileselector.h" | 31 | #include <qpe/fileselector.h> |
32 | #include "resource.h" | 32 | #include <qpe/resource.h> |
33 | #include <qpe/qpetoolbar.h> | ||
33 | 34 | ||
34 | /* QTE includes */ | 35 | /* QTE includes */ |
35 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
36 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
37 | #include <qapplication.h> | 38 | #include <qapplication.h> |
38 | #include <qwidgetstack.h> | 39 | #include <qwidgetstack.h> |
39 | #include <qlayout.h> | 40 | #include <qlayout.h> |
40 | #include <qbuffer.h> | 41 | #include <qbuffer.h> |
41 | |||
42 | /*! | 42 | /*! |
43 | \class TableViewerWindow | 43 | \class TableViewerWindow |
44 | \brief The main window widget of the application | 44 | \brief The main window widget of the application |
45 | 45 | ||
46 | This is the main widget of the table viewer application. | 46 | This is the main widget of the table viewer application. |
47 | It is the co-ordination point. | 47 | It is the co-ordination point. |
48 | */ | 48 | */ |
49 | 49 | ||
50 | /*! | 50 | /*! |
51 | Constructs a new TableViewerWindow | 51 | Constructs a new TableViewerWindow |
52 | */ | 52 | */ |
53 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) | 53 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) |
54 | : QMainWindow(parent, name, f) | 54 | : QMainWindow(parent, name, f) |
55 | { | 55 | { |
56 | setCaption(tr("Table Viewer")); | 56 | setCaption(tr("Table Viewer")); |
57 | 57 | ||
58 | /* Build data */ | 58 | /* Build data */ |
59 | ds = new DBStore(); | 59 | ds = new DBStore(); |
60 | doc.setType("text/x-xml-tableviewer"); | 60 | doc.setType("text/x-xml-tableviewer"); |
61 | doc.setName("table"); | 61 | doc.setName("table"); |
62 | 62 | ||
63 | dirty = FALSE; | 63 | dirty = FALSE; |
64 | ts.current_column = 0; | 64 | ts.current_column = 0; |
65 | ts.kRep = ds->getKeys(); | 65 | ts.kRep = ds->getKeys(); |
66 | 66 | ||
67 | /* build menus */ | 67 | /* build menus */ |
68 | menu = new QPEMenuBar(this, 0); | 68 | menu = new QPEMenuBar(this, 0); |
69 | 69 | ||
70 | QPopupMenu *file_menu = new QPopupMenu; | 70 | QPopupMenu *file_menu = new QPopupMenu; |
71 | file_menu->insertItem("New", this, SLOT(newDocument())); | 71 | file_menu->insertItem("New", this, SLOT(newDocument())); |
72 | 72 | ||
73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); | 73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); |
74 | file_menu->insertSeparator(); | 74 | file_menu->insertSeparator(); |
75 | file_menu->insertItem("Properties"); | 75 | file_menu->insertItem("Properties"); |
76 | 76 | ||
77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ | 77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ |
78 | menu->insertItem("Document", file_menu); | 78 | menu->insertItem("Document", file_menu); |
79 | 79 | ||
80 | QPopupMenu *edit_menu = new QPopupMenu; | 80 | QPopupMenu *edit_menu = new QPopupMenu; |
81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); | 81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); |
82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); | 82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); |
83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); | 83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); |
84 | menu->insertItem("Edit", edit_menu); | 84 | menu->insertItem("Edit", edit_menu); |
85 | 85 | ||
86 | QPopupMenu *view_menu = new QPopupMenu; | 86 | QPopupMenu *view_menu = new QPopupMenu; |
87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); | 87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); |
88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); | 88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); |
89 | menu->insertItem("View", view_menu); | 89 | menu->insertItem("View", view_menu); |
90 | 90 | ||
91 | QVBoxLayout *main_layout = new QVBoxLayout; | 91 | QVBoxLayout *main_layout = new QVBoxLayout; |
92 | 92 | ||
93 | /* Build tool bar */ | 93 | /* Build tool bar */ |
94 | navigation = new QPEToolBar(this, "navigation"); | 94 | navigation = new QPEToolBar(this, "navigation"); |
95 | QToolButton *newItemButton = new QToolButton( | 95 | QToolButton *newItemButton = new QToolButton( |
96 | QIconSet(Resource::loadImage("new")), "New Item", QString::null, | 96 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, |
97 | this, SLOT(newItemSlot()), navigation, "New Item"); | 97 | this, SLOT(newItemSlot()), navigation, "New Item"); |
98 | QToolButton *editItemButton = new QToolButton( | 98 | QToolButton *editItemButton = new QToolButton( |
99 | QIconSet(Resource::loadImage("edit")), "Edit Item", QString::null, | 99 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, |
100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); | 100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); |
101 | QToolButton *deleteItemButton = new QToolButton( | 101 | QToolButton *deleteItemButton = new QToolButton( |
102 | QIconSet(Resource::loadImage("trash")), "Delete Item", | 102 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", |
103 | QString::null, this, | 103 | QString::null, this, |
104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); | 104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); |
105 | 105 | ||
106 | navigation->addSeparator(); | 106 | navigation->addSeparator(); |
107 | 107 | ||
108 | QToolButton *firstItemButton = new QToolButton( | 108 | QToolButton *firstItemButton = new QToolButton( |
109 | QIconSet(Resource::loadImage("fastback")), "First Item", | 109 | QIconSet(Resource::loadPixmap("fastback")), "First Item", |
110 | QString::null, this, | 110 | QString::null, this, |
111 | SLOT(firstItem()), navigation, "First Item"); | 111 | SLOT(firstItem()), navigation, "First Item"); |
112 | QToolButton *previousItemButton = new QToolButton( | 112 | QToolButton *previousItemButton = new QToolButton( |
113 | QIconSet(Resource::loadImage("back")), "Previous Item", | 113 | QIconSet(Resource::loadPixmap("back")), "Previous Item", |
114 | QString::null, this, | 114 | QString::null, this, |
115 | SLOT(previousItem()), navigation, "Previous Item"); | 115 | SLOT(previousItem()), navigation, "Previous Item"); |
116 | QToolButton *nextItemButton = new QToolButton( | 116 | QToolButton *nextItemButton = new QToolButton( |
117 | QIconSet(Resource::loadImage("forward")), "Next Item", | 117 | QIconSet(Resource::loadPixmap("forward")), "Next Item", |
118 | QString::null, this, | 118 | QString::null, this, |
119 | SLOT(nextItem()), navigation, "Next Item"); | 119 | SLOT(nextItem()), navigation, "Next Item"); |
120 | QToolButton *lastItemButton = new QToolButton( | 120 | QToolButton *lastItemButton = new QToolButton( |
121 | QIconSet(Resource::loadImage("fastforward")), "Last Item", | 121 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", |
122 | QString::null, this, | 122 | QString::null, this, |
123 | SLOT(lastItem()), navigation, "Last Item"); | 123 | SLOT(lastItem()), navigation, "Last Item"); |
124 | 124 | ||
125 | navigation->addSeparator(); | 125 | navigation->addSeparator(); |
126 | QToolButton *browseButton = new QToolButton( | 126 | QToolButton *browseButton = new QToolButton( |
127 | QIconSet(Resource::loadImage("day")), "View Single Item", | 127 | QIconSet(Resource::loadPixmap("day")), "View Single Item", |
128 | QString::null, this, | 128 | QString::null, this, |
129 | SLOT(browseViewSlot()), navigation, "View Single Item"); | 129 | SLOT(browseViewSlot()), navigation, "View Single Item"); |
130 | QToolButton *listButton = new QToolButton( | 130 | QToolButton *listButton = new QToolButton( |
131 | QIconSet(Resource::loadImage("month")), "View Multiple Items", | 131 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", |
132 | QString::null, this, | 132 | QString::null, this, |
133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); | 133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); |
134 | 134 | ||
135 | setToolBarsMovable(FALSE); | 135 | setToolBarsMovable(FALSE); |
136 | setToolBarsMovable(FALSE); | 136 | setToolBarsMovable(FALSE); |
137 | setToolBarsMovable(FALSE); | 137 | setToolBarsMovable(FALSE); |
138 | 138 | ||
139 | /* Build widgets */ | 139 | /* Build widgets */ |
140 | browseView = new TVBrowseView(&ts, this, 0); | 140 | browseView = new TVBrowseView(&ts, this, 0); |
141 | listView = new TVListView(&ts, this, 0); | 141 | listView = new TVListView(&ts, this, 0); |
142 | filterView = new TVFilterView(&ts, this, 0); | 142 | filterView = new TVFilterView(&ts, this, 0); |
143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", | 143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", |
144 | this, "fileselector"); | 144 | this, "fileselector"); |
145 | fileSelector->setNewVisible(FALSE); | 145 | fileSelector->setNewVisible(FALSE); |
146 | fileSelector->setCloseVisible(FALSE); | 146 | fileSelector->setCloseVisible(FALSE); |
147 | 147 | ||
148 | cw = new QWidgetStack(this, 0); | 148 | cw = new QWidgetStack(this, 0); |
149 | cw->addWidget(listView, ListState); | 149 | cw->addWidget(listView, ListState); |
150 | cw->addWidget(browseView, BrowseState); | 150 | cw->addWidget(browseView, BrowseState); |
151 | cw->addWidget(filterView, FilterState); | 151 | cw->addWidget(filterView, FilterState); |
152 | cw->addWidget(fileSelector, FileState); | 152 | cw->addWidget(fileSelector, FileState); |
153 | 153 | ||
154 | current_view = FileState; | 154 | current_view = FileState; |
155 | cw->raiseWidget(current_view); | 155 | cw->raiseWidget(current_view); |
156 | fileSelector->reread(); | 156 | fileSelector->reread(); |
157 | 157 | ||
158 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), | 158 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), |
159 | this, SLOT(searchOnKey(int, TVVariant))); | 159 | this, SLOT(searchOnKey(int, TVVariant))); |
160 | connect(browseView, SIGNAL(sortChanged(int)), | 160 | connect(browseView, SIGNAL(sortChanged(int)), |
161 | this, SLOT(setPrimaryKey(int))); | 161 | this, SLOT(setPrimaryKey(int))); |
162 | 162 | ||
163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); | 163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); |
164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), |
165 | this, SLOT(openDocument(const DocLnk &))); | 165 | this, SLOT(openDocument(const DocLnk &))); |
166 | 166 | ||
167 | main_layout->addWidget(menu); | 167 | main_layout->addWidget(menu); |
168 | main_layout->addWidget(cw); | 168 | main_layout->addWidget(cw); |
169 | 169 | ||
170 | setCentralWidget(cw); | 170 | setCentralWidget(cw); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | /*! | 174 | /*! |
175 | Destroys the TableViewerWindow | 175 | Destroys the TableViewerWindow |
176 | */ | 176 | */ |
177 | TableViewerWindow::~TableViewerWindow() | 177 | TableViewerWindow::~TableViewerWindow() |
178 | { | 178 | { |
179 | if(dirty) | 179 | if(dirty) |
180 | saveDocument(); | 180 | saveDocument(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /*! | 183 | /*! |
184 | Opens a file dialog and loads the file specified by the dialog | 184 | Opens a file dialog and loads the file specified by the dialog |
185 | */ | 185 | */ |
186 | void TableViewerWindow::selectDocument() | 186 | void TableViewerWindow::selectDocument() |
187 | { | 187 | { |
188 | if(dirty) | 188 | if(dirty) |
189 | saveDocument(); | 189 | saveDocument(); |
190 | current_view = FileState; | 190 | current_view = FileState; |
191 | cw->raiseWidget(current_view); | 191 | cw->raiseWidget(current_view); |
192 | fileSelector->reread(); | 192 | fileSelector->reread(); |
193 | } | 193 | } |
194 | 194 | ||
195 | void TableViewerWindow::saveDocument() | 195 | void TableViewerWindow::saveDocument() |
196 | { | 196 | { |
197 | if(!dirty) | 197 | if(!dirty) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | FileManager fm; | 200 | FileManager fm; |
201 | QIODevice *dev = fm.saveFile(doc); | 201 | QIODevice *dev = fm.saveFile(doc); |
202 | 202 | ||
203 | if(!ds->saveSource(dev, doc.type())){ | 203 | if(!ds->saveSource(dev, doc.type())){ |
204 | qWarning("Save unsuccessful"); | 204 | qWarning("Save unsuccessful"); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | dev->close(); | 207 | dev->close(); |
208 | dirty = FALSE; | 208 | dirty = FALSE; |
209 | } | 209 | } |
210 | 210 | ||
211 | void TableViewerWindow::newDocument() | 211 | void TableViewerWindow::newDocument() |
212 | { | 212 | { |
213 | DocLnk nf; | 213 | DocLnk nf; |
214 | nf.setType("text/x-xml-tableviewer"); | 214 | nf.setType("text/x-xml-tableviewer"); |
215 | nf.setName("table"); | 215 | nf.setName("table"); |
216 | 216 | ||
217 | delete ds; | 217 | delete ds; |
218 | ds = new DBStore(); | 218 | ds = new DBStore(); |
219 | 219 | ||
220 | ts.current_column = 0; | 220 | ts.current_column = 0; |
221 | ts.kRep = ds->getKeys(); | 221 | ts.kRep = ds->getKeys(); |
222 | browseView->reset(); | 222 | browseView->reset(); |
223 | listView->reset(); | 223 | listView->reset(); |
224 | filterView->reset(); | 224 | filterView->reset(); |
225 | 225 | ||
226 | doc = nf; | 226 | doc = nf; |
227 | dirty = FALSE; | 227 | dirty = FALSE; |
228 | 228 | ||
229 | current_view = BrowseState; | 229 | current_view = BrowseState; |
230 | cw->raiseWidget(current_view); | 230 | cw->raiseWidget(current_view); |
231 | 231 | ||
232 | /* now set up for editing the keys */ | 232 | /* now set up for editing the keys */ |
233 | ts.kRep->addKey("key", TVVariant::String); | 233 | ts.kRep->addKey("key", TVVariant::String); |
234 | editKeysSlot(); | 234 | editKeysSlot(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void TableViewerWindow::openDocument(const DocLnk &f) | 237 | void TableViewerWindow::openDocument(const DocLnk &f) |
238 | { | 238 | { |
239 | 239 | ||
240 | if (!f.isValid()) | 240 | if (!f.isValid()) |
241 | return; | 241 | return; |
242 | 242 | ||
243 | FileManager fm; | 243 | FileManager fm; |
244 | QIODevice *dev = fm.openFile(f); | 244 | QIODevice *dev = fm.openFile(f); |
245 | doc = f; | 245 | doc = f; |
246 | 246 | ||
247 | if(ds->openSource(dev, doc.type())) { | 247 | if(ds->openSource(dev, doc.type())) { |
248 | DataElem *d; | 248 | DataElem *d; |
249 | 249 | ||
250 | browseView->reset(); | 250 | browseView->reset(); |
251 | listView->reset(); | 251 | listView->reset(); |
252 | filterView->reset(); | 252 | filterView->reset(); |
253 | 253 | ||
254 | current_view = BrowseState; | 254 | current_view = BrowseState; |
255 | cw->raiseWidget(current_view); | 255 | cw->raiseWidget(current_view); |
256 | 256 | ||
257 | /* set up new table state and ensure sub widgets have a reference */ | 257 | /* set up new table state and ensure sub widgets have a reference */ |
258 | ts.current_column = 0; | 258 | ts.current_column = 0; |
259 | ts.kRep = ds->getKeys(); | 259 | ts.kRep = ds->getKeys(); |
260 | browseView->rebuildKeys(); | 260 | browseView->rebuildKeys(); |
261 | listView->rebuildKeys(); | 261 | listView->rebuildKeys(); |
262 | filterView->rebuildKeys(); | 262 | filterView->rebuildKeys(); |
263 | 263 | ||
264 | ds->first(); | 264 | ds->first(); |
265 | /* set up the list view */ | 265 | /* set up the list view */ |
266 | listView->clearItems(); | 266 | listView->clearItems(); |
267 | do { | 267 | do { |
268 | d = ds->getCurrentData(); | 268 | d = ds->getCurrentData(); |
269 | if(d) | 269 | if(d) |
270 | listView->addItem(d); | 270 | listView->addItem(d); |
271 | } while(ds->next()); | 271 | } while(ds->next()); |
272 | 272 | ||
273 | /* Set up browse view, Will be based of structure of listView */ | 273 | /* Set up browse view, Will be based of structure of listView */ |
274 | listView->first(); | 274 | listView->first(); |
275 | ts.current_elem = listView->getCurrentData(); | 275 | ts.current_elem = listView->getCurrentData(); |
276 | browseView->rebuildData(); | 276 | browseView->rebuildData(); |
277 | listView->rebuildData(); | 277 | listView->rebuildData(); |
278 | 278 | ||
279 | QString scratch = "Table Viewer";/* later take from constant */ | 279 | QString scratch = "Table Viewer";/* later take from constant */ |
280 | scratch += " - "; | 280 | scratch += " - "; |
281 | scratch += ds->getName(); | 281 | scratch += ds->getName(); |
282 | setCaption(tr(scratch)); | 282 | setCaption(tr(scratch)); |
283 | 283 | ||
284 | dirty = FALSE; | 284 | dirty = FALSE; |
285 | } else { | 285 | } else { |
286 | qWarning(tr("could not load Document")); | 286 | qWarning(tr("could not load Document")); |
287 | } | 287 | } |
288 | dev->close(); | 288 | dev->close(); |
289 | } | 289 | } |
290 | 290 | ||
291 | /*! | 291 | /*! |
292 | Moves to the next item of the current table | 292 | Moves to the next item of the current table |
293 | */ | 293 | */ |
294 | void TableViewerWindow::nextItem() | 294 | void TableViewerWindow::nextItem() |
295 | { | 295 | { |
296 | listView->next(); | 296 | listView->next(); |
297 | ts.current_elem = listView->getCurrentData(); | 297 | ts.current_elem = listView->getCurrentData(); |
298 | browseView->rebuildData(); | 298 | browseView->rebuildData(); |
299 | } | 299 | } |
300 | 300 | ||
301 | /*! | 301 | /*! |
302 | Moves to the previous item of the current table | 302 | Moves to the previous item of the current table |
303 | */ | 303 | */ |
304 | void TableViewerWindow::previousItem() | 304 | void TableViewerWindow::previousItem() |
305 | { | 305 | { |
306 | listView->previous(); | 306 | listView->previous(); |
307 | ts.current_elem = listView->getCurrentData(); | 307 | ts.current_elem = listView->getCurrentData(); |
308 | browseView->rebuildData(); | 308 | browseView->rebuildData(); |
309 | } | 309 | } |
310 | 310 | ||
311 | /*! | 311 | /*! |
312 | Raises the List View. This is a mode change for the application. | 312 | Raises the List View. This is a mode change for the application. |
313 | */ | 313 | */ |
314 | void TableViewerWindow::listViewSlot() | 314 | void TableViewerWindow::listViewSlot() |
315 | { | 315 | { |
316 | if(current_view == FilterState) | 316 | if(current_view == FilterState) |
317 | applyFilter(); | 317 | applyFilter(); |
318 | current_view = ListState; | 318 | current_view = ListState; |
319 | cw->raiseWidget(current_view); | 319 | cw->raiseWidget(current_view); |
320 | } | 320 | } |
321 | 321 | ||
322 | void TableViewerWindow::applyFilter() | 322 | void TableViewerWindow::applyFilter() |
323 | { | 323 | { |
324 | DataElem *d; | 324 | DataElem *d; |
325 | 325 | ||
326 | listView->clearItems(); | 326 | listView->clearItems(); |
327 | ds->first(); | 327 | ds->first(); |
328 | do { | 328 | do { |
329 | d = ds->getCurrentData(); | 329 | d = ds->getCurrentData(); |
330 | if(d) | 330 | if(d) |
331 | if(filterView->passesFilter(d)) | 331 | if(filterView->passesFilter(d)) |
332 | listView->addItem(d); | 332 | listView->addItem(d); |
333 | } while(ds->next()); | 333 | } while(ds->next()); |
334 | listView->first(); | 334 | listView->first(); |
335 | listView->rebuildData(); | 335 | listView->rebuildData(); |
336 | } | 336 | } |
337 | 337 | ||
338 | /*! | 338 | /*! |
339 | Raises the Browse View. This is a mode change for the application. | 339 | Raises the Browse View. This is a mode change for the application. |
340 | */ | 340 | */ |
341 | void TableViewerWindow::browseViewSlot() | 341 | void TableViewerWindow::browseViewSlot() |
342 | { | 342 | { |
343 | if(current_view == FilterState) | 343 | if(current_view == FilterState) |
344 | applyFilter(); | 344 | applyFilter(); |
345 | 345 | ||
346 | ts.current_elem = listView->getCurrentData(); | 346 | ts.current_elem = listView->getCurrentData(); |
347 | browseView->rebuildData(); | 347 | browseView->rebuildData(); |
348 | 348 | ||
349 | current_view = BrowseState; | 349 | current_view = BrowseState; |
350 | cw->raiseWidget(current_view); | 350 | cw->raiseWidget(current_view); |
351 | } | 351 | } |
352 | 352 | ||
353 | /*! | 353 | /*! |
354 | Raises the List View. This is a mode change for the application. | 354 | Raises the List View. This is a mode change for the application. |
355 | */ | 355 | */ |
356 | void TableViewerWindow::filterViewSlot() | 356 | void TableViewerWindow::filterViewSlot() |
357 | { | 357 | { |
358 | current_view = FilterState; | 358 | current_view = FilterState; |
359 | cw->raiseWidget(current_view); | 359 | cw->raiseWidget(current_view); |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | 363 | ||
364 | 364 | ||
365 | void TableViewerWindow::editItemSlot() | 365 | void TableViewerWindow::editItemSlot() |
366 | { | 366 | { |
367 | if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { | 367 | if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { |
368 | listView->rebuildData(); | 368 | listView->rebuildData(); |
369 | browseView->rebuildData(); | 369 | browseView->rebuildData(); |
370 | dirty = TRUE; | 370 | dirty = TRUE; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | void TableViewerWindow::newItemSlot() | 374 | void TableViewerWindow::newItemSlot() |
375 | { | 375 | { |
376 | DataElem *d = new DataElem(ds); | 376 | DataElem *d = new DataElem(ds); |
377 | if (TVEditView::openEditItemDialog(&ts, d, this)) { | 377 | if (TVEditView::openEditItemDialog(&ts, d, this)) { |
378 | 378 | ||
379 | ds->addItem(d); | 379 | ds->addItem(d); |
380 | ts.current_elem = d; | 380 | ts.current_elem = d; |
381 | applyFilter(); | 381 | applyFilter(); |
382 | listView->rebuildData(); | 382 | listView->rebuildData(); |
383 | browseView->rebuildData(); | 383 | browseView->rebuildData(); |
384 | dirty = TRUE; | 384 | dirty = TRUE; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | void TableViewerWindow::deleteItemSlot() | 388 | void TableViewerWindow::deleteItemSlot() |
389 | { | 389 | { |
390 | /* delete the actual item, then do a 'filter' */ | 390 | /* delete the actual item, then do a 'filter' */ |
391 | DataElem *to_remove = ts.current_elem; | 391 | DataElem *to_remove = ts.current_elem; |
392 | 392 | ||
393 | if(!to_remove) | 393 | if(!to_remove) |
394 | return; | 394 | return; |
395 | 395 | ||
396 | listView->removeItem(); | 396 | listView->removeItem(); |
397 | ds->removeItem(to_remove); | 397 | ds->removeItem(to_remove); |
398 | 398 | ||
399 | applyFilter(); | 399 | applyFilter(); |
400 | listView->rebuildData(); | 400 | listView->rebuildData(); |
401 | browseView->rebuildData(); | 401 | browseView->rebuildData(); |
402 | dirty = TRUE; | 402 | dirty = TRUE; |
403 | } | 403 | } |
404 | 404 | ||
405 | void TableViewerWindow::editKeysSlot() | 405 | void TableViewerWindow::editKeysSlot() |
406 | { | 406 | { |
407 | DataElem *d; | 407 | DataElem *d; |
408 | KeyList *k = TVKeyEdit::openEditKeysDialog(&ts, this); | 408 | KeyList *k = TVKeyEdit::openEditKeysDialog(&ts, this); |
409 | 409 | ||
410 | if(k) { | 410 | if(k) { |
411 | /* set as new keys */ | 411 | /* set as new keys */ |
412 | ds->setKeys(k); | 412 | ds->setKeys(k); |
413 | 413 | ||
414 | ts.current_column = 0; | 414 | ts.current_column = 0; |
415 | ts.kRep = k; | 415 | ts.kRep = k; |
416 | 416 | ||
417 | browseView->reset(); | 417 | browseView->reset(); |
418 | listView->reset(); | 418 | listView->reset(); |
419 | filterView->reset(); | 419 | filterView->reset(); |
420 | 420 | ||
421 | browseView->rebuildKeys(); | 421 | browseView->rebuildKeys(); |
422 | listView->rebuildKeys(); | 422 | listView->rebuildKeys(); |
423 | filterView->rebuildKeys(); | 423 | filterView->rebuildKeys(); |
424 | 424 | ||
425 | ds->first(); | 425 | ds->first(); |
426 | /* set up the list view */ | 426 | /* set up the list view */ |
427 | listView->clearItems(); | 427 | listView->clearItems(); |
428 | do { | 428 | do { |
429 | d = ds->getCurrentData(); | 429 | d = ds->getCurrentData(); |
430 | if(d) | 430 | if(d) |
431 | listView->addItem(d); | 431 | listView->addItem(d); |
432 | } while(ds->next()); | 432 | } while(ds->next()); |
433 | 433 | ||
434 | /* Set up browse view, Will be based of structure of listView */ | 434 | /* Set up browse view, Will be based of structure of listView */ |
435 | dirty = TRUE; | 435 | dirty = TRUE; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | /*! | 439 | /*! |
440 | A Slot that allows for widgets above to indicate a search should be | 440 | A Slot that allows for widgets above to indicate a search should be |
441 | done on a specified key index for a specified value | 441 | done on a specified key index for a specified value |
442 | */ | 442 | */ |
443 | void TableViewerWindow::searchOnKey(int i, TVVariant v) | 443 | void TableViewerWindow::searchOnKey(int i, TVVariant v) |
444 | { | 444 | { |
445 | listView->findItem(i, v); | 445 | listView->findItem(i, v); |
446 | ts.current_elem = listView->getCurrentData(); | 446 | ts.current_elem = listView->getCurrentData(); |
447 | browseView->rebuildData(); | 447 | browseView->rebuildData(); |
448 | } | 448 | } |
449 | 449 | ||
450 | void TableViewerWindow::setPrimaryKey(int i) | 450 | void TableViewerWindow::setPrimaryKey(int i) |
451 | { | 451 | { |
452 | ts.current_column = i; | 452 | ts.current_column = i; |
453 | listView->rebuildData(); | 453 | listView->rebuildData(); |
454 | browseView->rebuildData(); | 454 | browseView->rebuildData(); |
455 | } | 455 | } |
diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 2d4686a..0d3c39d 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h | |||
@@ -1,109 +1,109 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Tableviewer_H | 20 | #ifndef Tableviewer_H |
21 | #define Tableviewer_H | 21 | #define Tableviewer_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include "db/common.h" | 24 | #include "db/common.h" |
25 | #include "fileselector.h" | 25 | #include <qpe/fileselector.h> |
26 | 26 | ||
27 | /* Forward class declarations */ | 27 | /* Forward class declarations */ |
28 | class QWidgetStack; | 28 | class QWidgetStack; |
29 | class QDialog; | 29 | class QDialog; |
30 | class QMenuBar; | 30 | class QMenuBar; |
31 | 31 | ||
32 | class TVListView; | 32 | class TVListView; |
33 | class TVBrowseView; | 33 | class TVBrowseView; |
34 | class TVFilterView; | 34 | class TVFilterView; |
35 | class TVEditView; | 35 | class TVEditView; |
36 | 36 | ||
37 | class DBStore; | 37 | class DBStore; |
38 | 38 | ||
39 | class TableViewerWindow: public QMainWindow | 39 | class TableViewerWindow: public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | TableViewerWindow( QWidget *parent = 0, | 43 | TableViewerWindow( QWidget *parent = 0, |
44 | const char *name = 0, WFlags f = 0 ); | 44 | const char *name = 0, WFlags f = 0 ); |
45 | ~TableViewerWindow(); | 45 | ~TableViewerWindow(); |
46 | 46 | ||
47 | public slots: | 47 | public slots: |
48 | void selectDocument(); | 48 | void selectDocument(); |
49 | 49 | ||
50 | void newDocument(); | 50 | void newDocument(); |
51 | void saveDocument(); | 51 | void saveDocument(); |
52 | void openDocument(const DocLnk &); | 52 | void openDocument(const DocLnk &); |
53 | 53 | ||
54 | void nextItem(); | 54 | void nextItem(); |
55 | void previousItem(); | 55 | void previousItem(); |
56 | 56 | ||
57 | void listViewSlot(); | 57 | void listViewSlot(); |
58 | void browseViewSlot(); | 58 | void browseViewSlot(); |
59 | void filterViewSlot(); | 59 | void filterViewSlot(); |
60 | 60 | ||
61 | void editItemSlot(); | 61 | void editItemSlot(); |
62 | void newItemSlot(); | 62 | void newItemSlot(); |
63 | void deleteItemSlot(); | 63 | void deleteItemSlot(); |
64 | 64 | ||
65 | void editKeysSlot(); | 65 | void editKeysSlot(); |
66 | 66 | ||
67 | /* reveiw the sig. for this function TODO */ | 67 | /* reveiw the sig. for this function TODO */ |
68 | void searchOnKey(int, TVVariant); | 68 | void searchOnKey(int, TVVariant); |
69 | void setPrimaryKey(int); | 69 | void setPrimaryKey(int); |
70 | 70 | ||
71 | /* TODO add new event */ | 71 | /* TODO add new event */ |
72 | protected: | 72 | protected: |
73 | 73 | ||
74 | /* TODO add new slots */ | 74 | /* TODO add new slots */ |
75 | private slots: | 75 | private slots: |
76 | 76 | ||
77 | /* TODO add other widgets used here */ | 77 | /* TODO add other widgets used here */ |
78 | private: | 78 | private: |
79 | bool dirty; | 79 | bool dirty; |
80 | 80 | ||
81 | QMenuBar *menu; | 81 | QMenuBar *menu; |
82 | QToolBar *navigation; | 82 | QToolBar *navigation; |
83 | 83 | ||
84 | TVListView *listView; | 84 | TVListView *listView; |
85 | TVBrowseView *browseView; | 85 | TVBrowseView *browseView; |
86 | TVFilterView *filterView; | 86 | TVFilterView *filterView; |
87 | TVEditView *editView; | 87 | TVEditView *editView; |
88 | FileSelector *fileSelector; | 88 | FileSelector *fileSelector; |
89 | 89 | ||
90 | DocLnk doc; | 90 | DocLnk doc; |
91 | 91 | ||
92 | QWidgetStack *cw; | 92 | QWidgetStack *cw; |
93 | DBStore *ds; | 93 | DBStore *ds; |
94 | TableState ts; /* not a pointer.. this class keeps the state */ | 94 | TableState ts; /* not a pointer.. this class keeps the state */ |
95 | 95 | ||
96 | enum UserState { | 96 | enum UserState { |
97 | BrowseState = 0, | 97 | BrowseState = 0, |
98 | ListState, | 98 | ListState, |
99 | FilterState, | 99 | FilterState, |
100 | EditState, | 100 | EditState, |
101 | FileState, | 101 | FileState, |
102 | }; | 102 | }; |
103 | 103 | ||
104 | UserState current_view; | 104 | UserState current_view; |
105 | 105 | ||
106 | void applyFilter(); | 106 | void applyFilter(); |
107 | }; | 107 | }; |
108 | 108 | ||
109 | #endif | 109 | #endif |
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index 0b4f3c2..bf4c36f 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp | |||
@@ -1,121 +1,122 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <datebookmonth.h> | 25 | |
26 | #include <qpe/datebookmonth.h> | ||
26 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
27 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
28 | #include "commonwidgets.h" | 29 | #include "commonwidgets.h" |
29 | 30 | ||
30 | DateEdit::DateEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) | 31 | DateEdit::DateEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) |
31 | : QToolButton(parent, name) | 32 | : QToolButton(parent, name) |
32 | { | 33 | { |
33 | QPopupMenu *m1 = new QPopupMenu(this); | 34 | QPopupMenu *m1 = new QPopupMenu(this); |
34 | dateSelector = new DateBookMonth(m1, 0, TRUE); | 35 | dateSelector = new DateBookMonth(m1, 0, TRUE); |
35 | m1->insertItem(dateSelector); | 36 | m1->insertItem(dateSelector); |
36 | setPopup(m1); | 37 | setPopup(m1); |
37 | setPopupDelay(0); | 38 | setPopupDelay(0); |
38 | 39 | ||
39 | connect(dateSelector, SIGNAL(dateClicked(int, int, int)), | 40 | connect(dateSelector, SIGNAL(dateClicked(int, int, int)), |
40 | this, SLOT(subValueChanged())); | 41 | this, SLOT(subValueChanged())); |
41 | 42 | ||
42 | setText(dateSelector->selectedDate().toString()); | 43 | setText(dateSelector->selectedDate().toString()); |
43 | } | 44 | } |
44 | 45 | ||
45 | 46 | ||
46 | DateEdit::~DateEdit() {} | 47 | DateEdit::~DateEdit() {} |
47 | 48 | ||
48 | QDate DateEdit::date() const | 49 | QDate DateEdit::date() const |
49 | { | 50 | { |
50 | return dateSelector->selectedDate(); | 51 | return dateSelector->selectedDate(); |
51 | } | 52 | } |
52 | 53 | ||
53 | void DateEdit::setDate(QDate d) | 54 | void DateEdit::setDate(QDate d) |
54 | { | 55 | { |
55 | dateSelector->setDate(d.year(), d.month(), d.day()); | 56 | dateSelector->setDate(d.year(), d.month(), d.day()); |
56 | setText(d.toString()); | 57 | setText(d.toString()); |
57 | } | 58 | } |
58 | 59 | ||
59 | QSizePolicy DateEdit::sizePolicy() const | 60 | QSizePolicy DateEdit::sizePolicy() const |
60 | { | 61 | { |
61 | QSizePolicy sp; | 62 | QSizePolicy sp; |
62 | sp.setHorData(QToolButton::sizePolicy().horData()); | 63 | sp.setHorData(QToolButton::sizePolicy().horData()); |
63 | sp.setVerData(QSizePolicy::Fixed); | 64 | sp.setVerData(QSizePolicy::Fixed); |
64 | 65 | ||
65 | return sp; | 66 | return sp; |
66 | } | 67 | } |
67 | 68 | ||
68 | void DateEdit::clear() | 69 | void DateEdit::clear() |
69 | { | 70 | { |
70 | QDate today = QDate::currentDate(); | 71 | QDate today = QDate::currentDate(); |
71 | 72 | ||
72 | dateSelector->setDate(today.year(), today.month(), today.day()); | 73 | dateSelector->setDate(today.year(), today.month(), today.day()); |
73 | setText(today.toString()); | 74 | setText(today.toString()); |
74 | } | 75 | } |
75 | 76 | ||
76 | void DateEdit::subValueChanged() | 77 | void DateEdit::subValueChanged() |
77 | { | 78 | { |
78 | QDate current = dateSelector->selectedDate(); | 79 | QDate current = dateSelector->selectedDate(); |
79 | 80 | ||
80 | setText(current.toString()); | 81 | setText(current.toString()); |
81 | emit valueChanged(current); | 82 | emit valueChanged(current); |
82 | } | 83 | } |
83 | 84 | ||
84 | TimeEdit::TimeEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) | 85 | TimeEdit::TimeEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) |
85 | : QWidget(parent, name, f) | 86 | : QWidget(parent, name, f) |
86 | { | 87 | { |
87 | QHBoxLayout *layout = new QHBoxLayout(this, 0); | 88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); |
88 | 89 | ||
89 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); | 90 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); |
90 | hourKey->setWrapping(true); | 91 | hourKey->setWrapping(true); |
91 | hourKey->setMinimumWidth(30); | 92 | hourKey->setMinimumWidth(30); |
92 | hourKey->setMaximumWidth(35); | 93 | hourKey->setMaximumWidth(35); |
93 | 94 | ||
94 | layout->addWidget(new QLabel(" : ", this)); | 95 | layout->addWidget(new QLabel(" : ", this)); |
95 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); | 96 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); |
96 | minuteKey->setWrapping(true); | 97 | minuteKey->setWrapping(true); |
97 | minuteKey->setMinimumWidth(30); | 98 | minuteKey->setMinimumWidth(30); |
98 | minuteKey->setMaximumWidth(35); | 99 | minuteKey->setMaximumWidth(35); |
99 | 100 | ||
100 | layout->addWidget(new QLabel(" : ", this)); | 101 | layout->addWidget(new QLabel(" : ", this)); |
101 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); | 102 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); |
102 | secondKey->setWrapping(true); | 103 | secondKey->setWrapping(true); |
103 | secondKey->setMinimumWidth(30); | 104 | secondKey->setMinimumWidth(30); |
104 | secondKey->setMaximumWidth(35); | 105 | secondKey->setMaximumWidth(35); |
105 | 106 | ||
106 | layout->addWidget(ampm = new QComboBox(this)); | 107 | layout->addWidget(ampm = new QComboBox(this)); |
107 | ampm->insertItem("AM"); | 108 | ampm->insertItem("AM"); |
108 | ampm->insertItem("PM"); | 109 | ampm->insertItem("PM"); |
109 | 110 | ||
110 | layout->addStretch(-1); | 111 | layout->addStretch(-1); |
111 | 112 | ||
112 | clear(); | 113 | clear(); |
113 | 114 | ||
114 | connect(secondKey, SIGNAL(valueChanged(const QString&)), | 115 | connect(secondKey, SIGNAL(valueChanged(const QString&)), |
115 | this, SLOT(subValueChanged())); | 116 | this, SLOT(subValueChanged())); |
116 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), | 117 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), |
117 | this, SLOT(subValueChanged())); | 118 | this, SLOT(subValueChanged())); |
118 | connect(hourKey, SIGNAL(valueChanged(const QString&)), | 119 | connect(hourKey, SIGNAL(valueChanged(const QString&)), |
119 | this, SLOT(subValueChanged())); | 120 | this, SLOT(subValueChanged())); |
120 | connect(ampm, SIGNAL(activated(int)), | 121 | connect(ampm, SIGNAL(activated(int)), |
121 | this, SLOT(subValueChanged())); | 122 | this, SLOT(subValueChanged())); |
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index f6da7b1..9bfc791 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp | |||
@@ -1,122 +1,122 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvbrowseview.h" | 20 | #include "tvbrowseview.h" |
21 | #include "browsekeyentry.h" | 21 | #include "browsekeyentry.h" |
22 | #include <qtoolbutton.h> | 22 | #include <qtoolbutton.h> |
23 | #include <qtextview.h> | 23 | #include <qtextview.h> |
24 | #include <qtextbrowser.h> | 24 | #include <qtextbrowser.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | /*! | 27 | /*! |
28 | \class TVBrowseView | 28 | \class TVBrowseView |
29 | \brief The widget describing how to draw the browse view user interface | 29 | \brief The widget describing how to draw the browse view user interface |
30 | 30 | ||
31 | This widget allows for the user to browse through the table, one element | 31 | This widget allows for the user to browse through the table, one element |
32 | at a time, or search on a single key. Its main goal is to show a | 32 | at a time, or search on a single key. Its main goal is to show a |
33 | single element in a readable format and make it easy for the user to | 33 | single element in a readable format and make it easy for the user to |
34 | rapidly find specific elements in the table. | 34 | rapidly find specific elements in the table. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | /*! | 37 | /*! |
38 | Constructs a new TVBrowseView widget | 38 | Constructs a new TVBrowseView widget |
39 | */ | 39 | */ |
40 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent = 0, const char *name = 0, | 40 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent = 0, const char *name = 0, |
41 | WFlags fl =0) | 41 | WFlags fl =0) |
42 | { | 42 | { |
43 | if (!name) | 43 | if (!name) |
44 | setName("BrowseView"); | 44 | setName("BrowseView"); |
45 | 45 | ||
46 | setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); | 46 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); |
47 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 47 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
48 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); | 48 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); |
49 | vlayout->addWidget( textViewDisplay ); | 49 | vlayout->addWidget( textViewDisplay ); |
50 | 50 | ||
51 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); | 51 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); |
52 | vlayout->addWidget( keyEntry ); | 52 | vlayout->addWidget( keyEntry ); |
53 | 53 | ||
54 | /* connect the signals down */ | 54 | /* connect the signals down */ |
55 | 55 | ||
56 | connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), | 56 | connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), |
57 | this, SIGNAL(searchOnKey(int, TVVariant))); | 57 | this, SIGNAL(searchOnKey(int, TVVariant))); |
58 | connect(keyEntry, SIGNAL(sortChanged(int)), | 58 | connect(keyEntry, SIGNAL(sortChanged(int)), |
59 | this, SIGNAL(sortChanged(int))); | 59 | this, SIGNAL(sortChanged(int))); |
60 | 60 | ||
61 | ts = t; | 61 | ts = t; |
62 | keyEntry->setTableState(t); | 62 | keyEntry->setTableState(t); |
63 | } | 63 | } |
64 | 64 | ||
65 | /*! | 65 | /*! |
66 | Destroys the TVBrowseView widget | 66 | Destroys the TVBrowseView widget |
67 | */ | 67 | */ |
68 | TVBrowseView::~TVBrowseView() | 68 | TVBrowseView::~TVBrowseView() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void TVBrowseView::rebuildData() | 72 | void TVBrowseView::rebuildData() |
73 | { | 73 | { |
74 | if(!ts) | 74 | if(!ts) |
75 | return; | 75 | return; |
76 | if(!ts->current_elem) { | 76 | if(!ts->current_elem) { |
77 | /* also disable buttons */ | 77 | /* also disable buttons */ |
78 | textViewDisplay->setText(""); | 78 | textViewDisplay->setText(""); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | 81 | ||
82 | setDisplayText(ts->current_elem); | 82 | setDisplayText(ts->current_elem); |
83 | } | 83 | } |
84 | 84 | ||
85 | /* Reset to initial state */ | 85 | /* Reset to initial state */ |
86 | void TVBrowseView::reset() | 86 | void TVBrowseView::reset() |
87 | { | 87 | { |
88 | textViewDisplay->setText(""); | 88 | textViewDisplay->setText(""); |
89 | keyEntry->reset(); | 89 | keyEntry->reset(); |
90 | } | 90 | } |
91 | 91 | ||
92 | /*! | 92 | /*! |
93 | sets the data element to be displayed to element | 93 | sets the data element to be displayed to element |
94 | */ | 94 | */ |
95 | void TVBrowseView::setDisplayText(const DataElem *element) | 95 | void TVBrowseView::setDisplayText(const DataElem *element) |
96 | { | 96 | { |
97 | QString rep = ""; | 97 | QString rep = ""; |
98 | 98 | ||
99 | KeyListIterator it(*ts->kRep); | 99 | KeyListIterator it(*ts->kRep); |
100 | 100 | ||
101 | while (it.current()) { | 101 | while (it.current()) { |
102 | if (element->hasValidValue(it.currentKey())) { | 102 | if (element->hasValidValue(it.currentKey())) { |
103 | if(it.currentKey() == ts->current_column) { | 103 | if(it.currentKey() == ts->current_column) { |
104 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" | 104 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" |
105 | + it.current()->name() | 105 | + it.current()->name() |
106 | + ":</FONT></B> "; | 106 | + ":</FONT></B> "; |
107 | } else { | 107 | } else { |
108 | rep += "<B>" + it.current()->name() + ":</B> "; | 108 | rep += "<B>" + it.current()->name() + ":</B> "; |
109 | } | 109 | } |
110 | rep += element->toQString(it.currentKey()) + "<BR>"; | 110 | rep += element->toQString(it.currentKey()) + "<BR>"; |
111 | } | 111 | } |
112 | ++it; | 112 | ++it; |
113 | } | 113 | } |
114 | 114 | ||
115 | textViewDisplay->setText(rep); | 115 | textViewDisplay->setText(rep); |
116 | textViewDisplay->scrollToAnchor("ckey"); | 116 | textViewDisplay->scrollToAnchor("ckey"); |
117 | } | 117 | } |
118 | 118 | ||
119 | void TVBrowseView::rebuildKeys() | 119 | void TVBrowseView::rebuildKeys() |
120 | { | 120 | { |
121 | keyEntry->rebuildKeys(); | 121 | keyEntry->rebuildKeys(); |
122 | } | 122 | } |