-rw-r--r-- | noncore/apps/tableviewer/browsekeyentry.cpp | 53 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 165 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/datacache.cpp | 68 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/datacache.h | 24 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/browsekeyentry.cpp | 49 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/filterkeyentry.cpp | 42 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvfilterview.cpp | 55 |
7 files changed, 234 insertions, 222 deletions
diff --git a/noncore/apps/tableviewer/browsekeyentry.cpp b/noncore/apps/tableviewer/browsekeyentry.cpp index 04e7902..bab9af6 100644 --- a/noncore/apps/tableviewer/browsekeyentry.cpp +++ b/noncore/apps/tableviewer/browsekeyentry.cpp | |||
@@ -11,43 +11,45 @@ | |||
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 "browsekeyentry.h" | 20 | #include "browsekeyentry.h" |
21 | 21 | ||
22 | /* OPIE */ | ||
23 | #include <opie2/odebug.h> | ||
24 | using namespace Opie::Core; | ||
25 | |||
26 | /* QT */ | ||
22 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
23 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
24 | #include <qlayout.h> | 29 | #include <qlayout.h> |
25 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
26 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
27 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
28 | #include <qhbox.h> | 33 | #include <qhbox.h> |
29 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
30 | 35 | ||
31 | //#include <iostream.h> | ||
32 | #include <qheader.h> | ||
33 | // For qWarning(const char *) | ||
34 | 36 | ||
35 | /*! | 37 | /*! |
36 | \class TVBrowseKeyEntry | 38 | \class TVBrowseKeyEntry |
37 | \brief a Widget used enter keys into the TVBrowseViewWidget | 39 | \brief a Widget used enter keys into the TVBrowseViewWidget |
38 | 40 | ||
39 | The TVBrowseKeyEntry Widget provides the facility to enter | 41 | The TVBrowseKeyEntry Widget provides the facility to enter |
40 | various key types to be search on in the table. The key can be changed | 42 | various key types to be search on in the table. The key can be changed |
41 | and the entry field will update to the correct sort of widget appropriately | 43 | and the entry field will update to the correct sort of widget appropriately |
42 | */ | 44 | */ |
43 | 45 | ||
44 | /*! | 46 | /*! |
45 | Constructs the widget | 47 | Constructs the widget |
46 | */ | 48 | */ |
47 | TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | 49 | TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) |
48 | : QWidget(parent, name, f) | 50 | : QWidget(parent, name, f) |
49 | { | 51 | { |
50 | int stack_elem = 0; | 52 | int stack_elem = 0; |
51 | QHBoxLayout *h_layout = new QHBoxLayout(this); | 53 | QHBoxLayout *h_layout = new QHBoxLayout(this); |
52 | 54 | ||
53 | textKey = new QLineEdit(this, 0); | 55 | textKey = new QLineEdit(this, 0); |
@@ -75,47 +77,47 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | |||
75 | keyMenu = new QPopupMenu(this, "keymenu"); | 77 | keyMenu = new QPopupMenu(this, "keymenu"); |
76 | 78 | ||
77 | ws = new QWidgetStack(this, 0); | 79 | ws = new QWidgetStack(this, 0); |
78 | ws->addWidget(textKey, stack_elem++); | 80 | ws->addWidget(textKey, stack_elem++); |
79 | ws->addWidget(timeKey, stack_elem++); | 81 | ws->addWidget(timeKey, stack_elem++); |
80 | ws->addWidget(dateKey, stack_elem++); | 82 | ws->addWidget(dateKey, stack_elem++); |
81 | 83 | ||
82 | ws->raiseWidget(0); | 84 | ws->raiseWidget(0); |
83 | 85 | ||
84 | // TODO connect slots and signals.... | 86 | // TODO connect slots and signals.... |
85 | connect(changeKeyButton, SIGNAL(clicked()), | 87 | connect(changeKeyButton, SIGNAL(clicked()), |
86 | this, SLOT(changeKeyMenuSlot())); | 88 | this, SLOT(changeKeyMenuSlot())); |
87 | connect(resetButton, SIGNAL(clicked()), | 89 | connect(resetButton, SIGNAL(clicked()), |
88 | this, SLOT(resetKeySlot())); | 90 | this, SLOT(resetKeySlot())); |
89 | 91 | ||
90 | connect(textKey, SIGNAL(textChanged(const QString&)), | 92 | connect(textKey, SIGNAL(textChanged(const QString&)), |
91 | this, SLOT(searchOnText())); | 93 | this, SLOT(searchOnText())); |
92 | 94 | ||
93 | connect(dayKey, SIGNAL(textChanged(const QString&)), | 95 | connect(dayKey, SIGNAL(textChanged(const QString&)), |
94 | this, SLOT(searchOnText())); | 96 | this, SLOT(searchOnText())); |
95 | connect(monthKey, SIGNAL(textChanged(const QString&)), | 97 | connect(monthKey, SIGNAL(textChanged(const QString&)), |
96 | this, SLOT(searchOnText())); | 98 | this, SLOT(searchOnText())); |
97 | connect(yearKey, SIGNAL(textChanged(const QString&)), | 99 | connect(yearKey, SIGNAL(textChanged(const QString&)), |
98 | this, SLOT(searchOnText())); | 100 | this, SLOT(searchOnText())); |
99 | 101 | ||
100 | connect(secondKey, SIGNAL(textChanged(const QString&)), | 102 | connect(secondKey, SIGNAL(textChanged(const QString&)), |
101 | this, SLOT(searchOnText())); | 103 | this, SLOT(searchOnText())); |
102 | connect(minuteKey, SIGNAL(textChanged(const QString&)), | 104 | connect(minuteKey, SIGNAL(textChanged(const QString&)), |
103 | this, SLOT(searchOnText())); | 105 | this, SLOT(searchOnText())); |
104 | connect(hourKey, SIGNAL(textChanged(const QString&)), | 106 | connect(hourKey, SIGNAL(textChanged(const QString&)), |
105 | this, SLOT(searchOnText())); | 107 | this, SLOT(searchOnText())); |
106 | 108 | ||
107 | h_layout->addWidget(ws); | 109 | h_layout->addWidget(ws); |
108 | h_layout->addWidget(resetButton); | 110 | h_layout->addWidget(resetButton); |
109 | h_layout->addWidget(changeKeyButton); | 111 | h_layout->addWidget(changeKeyButton); |
110 | } | 112 | } |
111 | 113 | ||
112 | /*! | 114 | /*! |
113 | Destructs the widget | 115 | Destructs the widget |
114 | */ | 116 | */ |
115 | TVBrowseKeyEntry::~TVBrowseKeyEntry() | 117 | TVBrowseKeyEntry::~TVBrowseKeyEntry() |
116 | { | 118 | { |
117 | } | 119 | } |
118 | 120 | ||
119 | /*! | 121 | /*! |
120 | Changes which key the user intends to search on | 122 | Changes which key the user intends to search on |
121 | 123 | ||
@@ -131,27 +133,27 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param) | |||
131 | ws->raiseWidget(0); | 133 | ws->raiseWidget(0); |
132 | break; | 134 | break; |
133 | case kt_time: | 135 | case kt_time: |
134 | ws->raiseWidget(1); | 136 | ws->raiseWidget(1); |
135 | break; | 137 | break; |
136 | case kt_date: | 138 | case kt_date: |
137 | ws->raiseWidget(2); | 139 | ws->raiseWidget(2); |
138 | break; | 140 | break; |
139 | default: | 141 | default: |
140 | return; | 142 | return; |
141 | } | 143 | } |
142 | } | 144 | } |
143 | 145 | ||
144 | /*! | 146 | /*! |
145 | Opens the change key menu | 147 | Opens the change key menu |
146 | */ | 148 | */ |
147 | void TVBrowseKeyEntry::changeKeyMenuSlot() | 149 | void TVBrowseKeyEntry::changeKeyMenuSlot() |
148 | { | 150 | { |
149 | if(ts) | 151 | if(ts) |
150 | keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0))); | 152 | keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0))); |
151 | } | 153 | } |
152 | /*! | 154 | /*! |
153 | Blanks the key entry widget | 155 | Blanks the key entry widget |
154 | \TODO the actual implmentation | 156 | \TODO the actual implmentation |
155 | */ | 157 | */ |
156 | void TVBrowseKeyEntry::resetKeySlot() { | 158 | void TVBrowseKeyEntry::resetKeySlot() { |
157 | ; | 159 | ; |
@@ -160,25 +162,25 @@ void TVBrowseKeyEntry::resetKeySlot() { | |||
160 | void TVBrowseKeyEntry::setTableState(TableState *t) { | 162 | void TVBrowseKeyEntry::setTableState(TableState *t) { |
161 | int i; | 163 | int i; |
162 | ts = t; | 164 | ts = t; |
163 | 165 | ||
164 | /* clear the old */ | 166 | /* clear the old */ |
165 | keyMenu->clear(); | 167 | keyMenu->clear(); |
166 | 168 | ||
167 | for (i = 0; i < t->kRep->getNumFields(); i++) { | 169 | for (i = 0; i < t->kRep->getNumFields(); i++) { |
168 | keyMenu->insertItem(ts->kRep->getKeyName(i), this, | 170 | keyMenu->insertItem(ts->kRep->getKeyName(i), this, |
169 | SLOT(changeKeySlot(int)), 0, i); | 171 | SLOT(changeKeySlot(int)), 0, i); |
170 | keyMenu->setItemParameter(i, i); | 172 | keyMenu->setItemParameter(i, i); |
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
174 | /*! | 176 | /*! |
175 | Searches on the current value of the key entry provided that the | 177 | Searches on the current value of the key entry provided that the |
176 | current key is of type text WARNING, TODO fix memory leaks | 178 | current key is of type text WARNING, TODO fix memory leaks |
177 | */ | 179 | */ |
178 | void TVBrowseKeyEntry::searchOnText() | 180 | void TVBrowseKeyEntry::searchOnText() |
179 | { | 181 | { |
180 | void *sendkey; | 182 | void *sendkey; |
181 | int tmp; | 183 | int tmp; |
182 | 184 | ||
183 | switch(ts->kRep->getKeyType(ts->current_column)) { | 185 | switch(ts->kRep->getKeyType(ts->current_column)) { |
184 | /* work out what to raise */ | 186 | /* work out what to raise */ |
@@ -223,20 +225,19 @@ void TVBrowseKeyEntry::searchOnText() | |||
223 | if (!ok) | 225 | if (!ok) |
224 | return; | 226 | return; |
225 | if(!QDate::isValid(y, m, d)) | 227 | if(!QDate::isValid(y, m, d)) |
226 | return; | 228 | return; |
227 | sendkey = (void *) new QDate(y, m, d); | 229 | sendkey = (void *) new QDate(y, m, d); |
228 | break; | 230 | break; |
229 | } | 231 | } |
230 | default: | 232 | default: |
231 | qWarning("TVBrowseKeyEntry::searchOnText() " | 233 | owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl; |
232 | "cannot work out data type"); | ||
233 | return; | 234 | return; |
234 | } | 235 | } |
235 | emit searchOnKey(ts->current_column, sendkey); | 236 | emit searchOnKey(ts->current_column, sendkey); |
236 | } | 237 | } |
237 | 238 | ||
238 | /*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, void *v) | 239 | /*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, void *v) |
239 | 240 | ||
240 | This signal indicates that a search on key index currentKeyId should be | 241 | This signal indicates that a search on key index currentKeyId should be |
241 | done searching for the value v. | 242 | done searching for the value v. |
242 | */ | 243 | */ |
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index b58af85..c35dbea 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp | |||
@@ -11,18 +11,18 @@ | |||
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 "common.h" | 20 | #include "common.h" |
21 | #include "datacache.h" | 21 | #include "datacache.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
@@ -83,23 +83,23 @@ int parseNextNumber(QString *q) { | |||
83 | <LI> > 0 if the first string is bigger then the second,</LI> | 83 | <LI> > 0 if the first string is bigger then the second,</LI> |
84 | <LI> == 0 if the first string is equal to the second.</LI> | 84 | <LI> == 0 if the first string is equal to the second.</LI> |
85 | </UL> | 85 | </UL> |
86 | */ | 86 | */ |
87 | int QStringVector::compareItems(Item a, Item b) | 87 | int QStringVector::compareItems(Item a, Item b) |
88 | { | 88 | { |
89 | QString *qa = (QString *)a; | 89 | QString *qa = (QString *)a; |
90 | QString *qb = (QString *)b; | 90 | QString *qb = (QString *)b; |
91 | 91 | ||
92 | return QString::compare(*qa, *qb); | 92 | return QString::compare(*qa, *qb); |
93 | } | 93 | } |
94 | 94 | ||
95 | /*! | 95 | /*! |
96 | \class TVVariant | 96 | \class TVVariant |
97 | A way of abstracting void * and keeping information on | 97 | A way of abstracting void * and keeping information on |
98 | the keytypes and behaviours in one place | 98 | the keytypes and behaviours in one place |
99 | */ | 99 | */ |
100 | 100 | ||
101 | TVVariantPrivate::TVVariantPrivate() | 101 | TVVariantPrivate::TVVariantPrivate() |
102 | { | 102 | { |
103 | typ = TVVariant::Invalid; | 103 | typ = TVVariant::Invalid; |
104 | } | 104 | } |
105 | 105 | ||
@@ -315,17 +315,17 @@ void TVVariant::load(QDataStream &s ) | |||
315 | case Int: | 315 | case Int: |
316 | { | 316 | { |
317 | int x; | 317 | int x; |
318 | s >> x; | 318 | s >> x; |
319 | d->value.i = x; | 319 | d->value.i = x; |
320 | } | 320 | } |
321 | break; | 321 | break; |
322 | default: | 322 | default: |
323 | ofatal << "Unrecognized data type" << oendl; | 323 | ofatal << "Unrecognized data type" << oendl; |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | void TVVariant::save( QDataStream &s ) const | 327 | void TVVariant::save( QDataStream &s ) const |
328 | { | 328 | { |
329 | s << type(); | 329 | s << type(); |
330 | 330 | ||
331 | switch( d->typ ) { | 331 | switch( d->typ ) { |
@@ -377,17 +377,17 @@ const QString TVVariant::toString() const | |||
377 | { | 377 | { |
378 | switch(d->typ) { | 378 | switch(d->typ) { |
379 | case String: | 379 | case String: |
380 | return *((QString*)d->value.ptr); | 380 | return *((QString*)d->value.ptr); |
381 | case Date: | 381 | case Date: |
382 | return ((QDate*)d->value.ptr)->toString(); | 382 | return ((QDate*)d->value.ptr)->toString(); |
383 | case Time: | 383 | case Time: |
384 | return ((QTime*)d->value.ptr)->toString(); | 384 | return ((QTime*)d->value.ptr)->toString(); |
385 | case Int: | 385 | case Int: |
386 | return QString::number(d->value.i); | 386 | return QString::number(d->value.i); |
387 | case Invalid: | 387 | case Invalid: |
388 | default: | 388 | default: |
389 | return QString::null; | 389 | return QString::null; |
390 | } | 390 | } |
391 | return QString::null; | 391 | return QString::null; |
392 | } | 392 | } |
393 | 393 | ||
@@ -419,26 +419,26 @@ const QDate TVVariant::toDate() const | |||
419 | 419 | ||
420 | int day = parseNextNumber(&q); | 420 | int day = parseNextNumber(&q); |
421 | int month = parseNextNumber(&q); | 421 | int month = parseNextNumber(&q); |
422 | int year = parseNextNumber(&q); | 422 | int year = parseNextNumber(&q); |
423 | if (!QDate::isValid(year, month, day)) | 423 | if (!QDate::isValid(year, month, day)) |
424 | return QDate(); | 424 | return QDate(); |
425 | return QDate(year, month, day); | 425 | return QDate(year, month, day); |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | return QDate(); | 429 | return QDate(); |
430 | } | 430 | } |
431 | 431 | ||
432 | const QTime TVVariant::toTime() const | 432 | const QTime TVVariant::toTime() const |
433 | { | 433 | { |
434 | if(d->typ == Time) | 434 | if(d->typ == Time) |
435 | return *((QTime *)d->value.ptr); | 435 | return *((QTime *)d->value.ptr); |
436 | 436 | ||
437 | if(d->typ == String) { | 437 | if(d->typ == String) { |
438 | QString q = toString(); | 438 | QString q = toString(); |
439 | int hour = parseNextNumber(&q); | 439 | int hour = parseNextNumber(&q); |
440 | int minute = parseNextNumber(&q); | 440 | int minute = parseNextNumber(&q); |
441 | int second = parseNextNumber(&q); | 441 | int second = parseNextNumber(&q); |
442 | int msecond = parseNextNumber(&q); | 442 | int msecond = parseNextNumber(&q); |
443 | if (!QTime::isValid(hour, minute, second, msecond)) | 443 | if (!QTime::isValid(hour, minute, second, msecond)) |
444 | return QTime(); | 444 | return QTime(); |
@@ -449,17 +449,17 @@ const QTime TVVariant::toTime() const | |||
449 | } | 449 | } |
450 | 450 | ||
451 | #define TV_VARIANT_AS( f ) Q##f& TVVariant::as##f() { \ | 451 | #define TV_VARIANT_AS( f ) Q##f& TVVariant::as##f() { \ |
452 | if ( d->typ != f ) \ | 452 | if ( d->typ != f ) \ |
453 | *this = TVVariant( to##f() ); \ | 453 | *this = TVVariant( to##f() ); \ |
454 | else \ | 454 | else \ |
455 | detach(); \ | 455 | detach(); \ |
456 | return *((Q##f*)d->value.ptr); } | 456 | return *((Q##f*)d->value.ptr); } |
457 | 457 | ||
458 | TV_VARIANT_AS(String) | 458 | TV_VARIANT_AS(String) |
459 | TV_VARIANT_AS(Date) | 459 | TV_VARIANT_AS(Date) |
460 | TV_VARIANT_AS(Time) | 460 | TV_VARIANT_AS(Time) |
461 | 461 | ||
462 | #undef TV_VARIANT_AS | 462 | #undef TV_VARIANT_AS |
463 | 463 | ||
464 | int& TVVariant::asInt() | 464 | int& TVVariant::asInt() |
465 | { | 465 | { |
@@ -555,87 +555,87 @@ bool TVVariant::operator>( const TVVariant &v ) const | |||
555 | return FALSE; | 555 | return FALSE; |
556 | } | 556 | } |
557 | 557 | ||
558 | /*! True if n is closer to this than o */ | 558 | /*! True if n is closer to this than o */ |
559 | bool TVVariant::closer(TVVariant n, TVVariant o) | 559 | bool TVVariant::closer(TVVariant n, TVVariant o) |
560 | { | 560 | { |
561 | /* Nothing is close to an invalid, so nothing can be closer */ | 561 | /* Nothing is close to an invalid, so nothing can be closer */ |
562 | if(d->typ == Invalid) | 562 | if(d->typ == Invalid) |
563 | return FALSE; | 563 | return FALSE; |
564 | 564 | ||
565 | /* can't be closer if of different type */ | 565 | /* can't be closer if of different type */ |
566 | if(n.type() != type()) | 566 | if(n.type() != type()) |
567 | return FALSE; | 567 | return FALSE; |
568 | 568 | ||
569 | /* if new shares type, and old doesn't, then new is closer */ | 569 | /* if new shares type, and old doesn't, then new is closer */ |
570 | if(o.type() != type()) | 570 | if(o.type() != type()) |
571 | return TRUE; | 571 | return TRUE; |
572 | 572 | ||
573 | switch(type()){ | 573 | switch(type()){ |
574 | case String: { | 574 | case String: { |
575 | /* case for strings is close is a substring.. closer is | 575 | /* case for strings is close is a substring.. closer is |
576 | * earlier alphabetically */ | 576 | * earlier alphabetically */ |
577 | QString qs1 = n.toString().lower(); | 577 | QString qs1 = n.toString().lower(); |
578 | QString qs2 = o.toString().lower(); | 578 | QString qs2 = o.toString().lower(); |
579 | QString qsv = toString().lower(); | 579 | QString qsv = toString().lower(); |
580 | 580 | ||
581 | if (!qs1.startsWith(qsv)) | 581 | if (!qs1.startsWith(qsv)) |
582 | return FALSE; | 582 | return FALSE; |
583 | 583 | ||
584 | /* contains sub-str, if later than is not closer */ | 584 | /* contains sub-str, if later than is not closer */ |
585 | if(QString::compare(qs1, qs2) > 0) | 585 | if(QString::compare(qs1, qs2) > 0) |
586 | return FALSE; | 586 | return FALSE; |
587 | return TRUE; | 587 | return TRUE; |
588 | } | 588 | } |
589 | case Int: { | 589 | case Int: { |
590 | /* case for int is smallest absolute difference */ | 590 | /* case for int is smallest absolute difference */ |
591 | int i1 = n.toInt(); | 591 | int i1 = n.toInt(); |
592 | int i2 = o.toInt(); | 592 | int i2 = o.toInt(); |
593 | int iv = toInt(); | 593 | int iv = toInt(); |
594 | 594 | ||
595 | int diff1 = (i1 - iv); | 595 | int diff1 = (i1 - iv); |
596 | if (diff1 < 0) | 596 | if (diff1 < 0) |
597 | diff1 = -diff1; | 597 | diff1 = -diff1; |
598 | int diff2 = (i2 - iv); | 598 | int diff2 = (i2 - iv); |
599 | if (diff2 < 0) | 599 | if (diff2 < 0) |
600 | diff2 = -diff2; | 600 | diff2 = -diff2; |
601 | 601 | ||
602 | if (diff1 < diff2) | 602 | if (diff1 < diff2) |
603 | return TRUE; | 603 | return TRUE; |
604 | return FALSE; | 604 | return FALSE; |
605 | } | 605 | } |
606 | case Date: { | 606 | case Date: { |
607 | QDate i1 = n.toDate(); | 607 | QDate i1 = n.toDate(); |
608 | QDate i2 = o.toDate(); | 608 | QDate i2 = o.toDate(); |
609 | QDate iv = toDate(); | 609 | QDate iv = toDate(); |
610 | 610 | ||
611 | /* definition of closer is the least difference in days */ | 611 | /* definition of closer is the least difference in days */ |
612 | int diff1 = i1.daysTo(iv); | 612 | int diff1 = i1.daysTo(iv); |
613 | if (diff1 < 0) | 613 | if (diff1 < 0) |
614 | diff1 = -diff1; | 614 | diff1 = -diff1; |
615 | int diff2 = i2.daysTo(iv); | 615 | int diff2 = i2.daysTo(iv); |
616 | if (diff2 < 0) | 616 | if (diff2 < 0) |
617 | diff2 = -diff2; | 617 | diff2 = -diff2; |
618 | 618 | ||
619 | if (diff1 < diff2) | 619 | if (diff1 < diff2) |
620 | return TRUE; | 620 | return TRUE; |
621 | return FALSE; | 621 | return FALSE; |
622 | } | 622 | } |
623 | case Time: { | 623 | case Time: { |
624 | QTime i1 = n.toTime(); | 624 | QTime i1 = n.toTime(); |
625 | QTime i2 = o.toTime(); | 625 | QTime i2 = o.toTime(); |
626 | QTime iv = toTime(); | 626 | QTime iv = toTime(); |
627 | 627 | ||
628 | /* definition of closer is the least difference in days */ | 628 | /* definition of closer is the least difference in days */ |
629 | int diff1 = i1.msecsTo(iv); | 629 | int diff1 = i1.msecsTo(iv); |
630 | if (diff1 < 0) | 630 | if (diff1 < 0) |
631 | diff1 = -diff1; | 631 | diff1 = -diff1; |
632 | int diff2 = i2.msecsTo(iv); | 632 | int diff2 = i2.msecsTo(iv); |
633 | if (diff2 < 0) | 633 | if (diff2 < 0) |
634 | diff2 = -diff2; | 634 | diff2 = -diff2; |
635 | if (diff1 < diff2) | 635 | if (diff1 < diff2) |
636 | return TRUE; | 636 | return TRUE; |
637 | return FALSE; | 637 | return FALSE; |
638 | } | 638 | } |
639 | default: | 639 | default: |
640 | /* don't know how to do 'closer' on this type, hence never closer | 640 | /* don't know how to do 'closer' on this type, hence never closer |
641 | * or even close */ | 641 | * or even close */ |
@@ -644,65 +644,65 @@ bool TVVariant::closer(TVVariant n, TVVariant o) | |||
644 | return FALSE; | 644 | return FALSE; |
645 | } | 645 | } |
646 | 646 | ||
647 | /*! True if n is close to this */ | 647 | /*! True if n is close to this */ |
648 | bool TVVariant::close(TVVariant n) | 648 | bool TVVariant::close(TVVariant n) |
649 | { | 649 | { |
650 | /* Nothing is close to an invalid, so nothing can be closer */ | 650 | /* Nothing is close to an invalid, so nothing can be closer */ |
651 | if(type() == Invalid) | 651 | if(type() == Invalid) |
652 | return FALSE; | 652 | return FALSE; |
653 | 653 | ||
654 | /* can't be close if of different type */ | 654 | /* can't be close if of different type */ |
655 | if(n.type() != type()) | 655 | if(n.type() != type()) |
656 | return FALSE; | 656 | return FALSE; |
657 | 657 | ||
658 | switch(type()){ | 658 | switch(type()){ |
659 | case String: { | 659 | case String: { |
660 | /* case for strings is close is a substring.. closer is | 660 | /* case for strings is close is a substring.. closer is |
661 | * earlier alphabetically */ | 661 | * earlier alphabetically */ |
662 | QString qs1 = n.toString().lower(); | 662 | QString qs1 = n.toString().lower(); |
663 | QString qsv = toString().lower(); | 663 | QString qsv = toString().lower(); |
664 | 664 | ||
665 | if (!qs1.startsWith(qsv)) | 665 | if (!qs1.startsWith(qsv)) |
666 | return FALSE; | 666 | return FALSE; |
667 | return TRUE; | 667 | return TRUE; |
668 | } | 668 | } |
669 | case Int: | 669 | case Int: |
670 | case Date: | 670 | case Date: |
671 | case Time: | 671 | case Time: |
672 | return TRUE; | 672 | return TRUE; |
673 | default: | 673 | default: |
674 | /* don't know how to do 'closer' on this type, hence never closer | 674 | /* don't know how to do 'closer' on this type, hence never closer |
675 | * or even close */ | 675 | * or even close */ |
676 | break; | 676 | break; |
677 | } | 677 | } |
678 | return FALSE; | 678 | return FALSE; |
679 | } | 679 | } |
680 | 680 | ||
681 | /*! | 681 | /*! |
682 | \class Key | 682 | \class Key |
683 | \brief document me! | 683 | \brief document me! |
684 | 684 | ||
685 | document me! | 685 | document me! |
686 | */ | 686 | */ |
687 | 687 | ||
688 | Key::Key() : kname(), kexample(), kflags(0) { } | 688 | Key::Key() : kname(), kexample(), kflags(0) { } |
689 | 689 | ||
690 | Key::Key(QString name, TVVariant example, int flags) : | 690 | Key::Key(QString name, TVVariant example, int flags) : |
691 | kname(name), kexample(example), kflags(flags) { } | 691 | kname(name), kexample(example), kflags(flags) { } |
692 | 692 | ||
693 | Key::Key(const Key &other) | 693 | Key::Key(const Key &other) |
694 | { | 694 | { |
695 | kname = other.kname; | 695 | kname = other.kname; |
696 | kexample = other.kexample; | 696 | kexample = other.kexample; |
697 | kflags = other.kflags; | 697 | kflags = other.kflags; |
698 | } | 698 | } |
699 | 699 | ||
700 | Key& Key::operator=(const Key& key) | 700 | Key& Key::operator=(const Key& key) |
701 | { | 701 | { |
702 | kname = key.kname; | 702 | kname = key.kname; |
703 | kexample = key.kexample; | 703 | kexample = key.kexample; |
704 | kflags = key.kflags; | 704 | kflags = key.kflags; |
705 | return *this; | 705 | return *this; |
706 | } | 706 | } |
707 | 707 | ||
708 | QString Key::name() const | 708 | QString Key::name() const |
@@ -772,23 +772,23 @@ void Key::setNewFlag(bool v) | |||
772 | 772 | ||
773 | The KeyList class is used to store the representation of keys used in table | 773 | The KeyList class is used to store the representation of keys used in table |
774 | headings by DBStore. It stores the names and types of the keys | 774 | headings by DBStore. It stores the names and types of the keys |
775 | */ | 775 | */ |
776 | 776 | ||
777 | /*! | 777 | /*! |
778 | Constructs a KeyList | 778 | Constructs a KeyList |
779 | */ | 779 | */ |
780 | KeyList::KeyList() : QIntDict<Key>(20) | 780 | KeyList::KeyList() : QIntDict<Key>(20) |
781 | { | 781 | { |
782 | setAutoDelete(TRUE); | 782 | setAutoDelete(TRUE); |
783 | } | 783 | } |
784 | 784 | ||
785 | /* Should be deep copy, but isn't */ | 785 | /* Should be deep copy, but isn't */ |
786 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) | 786 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) |
787 | { | 787 | { |
788 | KeyListIterator it(k); | 788 | KeyListIterator it(k); |
789 | while(it.current()) { | 789 | while(it.current()) { |
790 | replace(it.currentKey(), new Key(*it.current())); | 790 | replace(it.currentKey(), new Key(*it.current())); |
791 | ++it; | 791 | ++it; |
792 | } | 792 | } |
793 | 793 | ||
794 | setAutoDelete(TRUE); | 794 | setAutoDelete(TRUE); |
@@ -817,17 +817,17 @@ bool KeyList::operator!=(const KeyList &other) | |||
817 | ++it; | 817 | ++it; |
818 | } | 818 | } |
819 | return FALSE; | 819 | return FALSE; |
820 | } | 820 | } |
821 | 821 | ||
822 | /*! | 822 | /*! |
823 | Returns the number of keys stored in the KeyList | 823 | Returns the number of keys stored in the KeyList |
824 | */ | 824 | */ |
825 | int KeyList::getNumFields() const | 825 | int KeyList::getNumFields() const |
826 | { | 826 | { |
827 | return count(); | 827 | return count(); |
828 | } | 828 | } |
829 | 829 | ||
830 | /*! | 830 | /*! |
831 | Adds a new key to the KeyList | 831 | Adds a new key to the KeyList |
832 | 832 | ||
833 | \param name the name of the new key | 833 | \param name the name of the new key |
@@ -842,104 +842,103 @@ int KeyList::addKey(QString name, TVVariant example) | |||
842 | return i; | 842 | return i; |
843 | } | 843 | } |
844 | 844 | ||
845 | int KeyList::addKey(QString name, TVVariant::KeyType type) | 845 | int KeyList::addKey(QString name, TVVariant::KeyType type) |
846 | { | 846 | { |
847 | /* generate a valid type for the example? */ | 847 | /* generate a valid type for the example? */ |
848 | TVVariant e = TVVariant("0"); | 848 | TVVariant e = TVVariant("0"); |
849 | switch(type) { | 849 | switch(type) { |
850 | case TVVariant::String: | 850 | case TVVariant::String: |
851 | return addKey(name, TVVariant("<undefined>").asString()); | 851 | return addKey(name, TVVariant("<undefined>").asString()); |
852 | break; | 852 | break; |
853 | case TVVariant::Date: | 853 | case TVVariant::Date: |
854 | return addKey(name, TVVariant(QDate::currentDate()).asDate()); | 854 | return addKey(name, TVVariant(QDate::currentDate()).asDate()); |
855 | break; | 855 | break; |
856 | case TVVariant::Time: | 856 | case TVVariant::Time: |
857 | return addKey(name, TVVariant(QTime(0,0,0)).toTime()); | 857 | return addKey(name, TVVariant(QTime(0,0,0)).toTime()); |
858 | break; | 858 | break; |
859 | case TVVariant::Int: | 859 | case TVVariant::Int: |
860 | return addKey(name, TVVariant(0).toInt()); | 860 | return addKey(name, TVVariant(0).toInt()); |
861 | break; | 861 | break; |
862 | default: | 862 | default: |
863 | qWarning(QObject::tr("KeyList::addKey() Cannot make default " | 863 | owarn << "KeyList::addKey() Cannot make default value for type " << type << ", Key not added." << oendl; |
864 | "value for type %1, Key not added.").arg(type)); | ||
865 | break; | 864 | break; |
866 | } | 865 | } |
867 | return -1; | 866 | return -1; |
868 | } | 867 | } |
869 | 868 | ||
870 | void KeyList::setKeyFlags(int i, int flag) | 869 | void KeyList::setKeyFlags(int i, int flag) |
871 | { | 870 | { |
872 | if(find(i)) | 871 | if(find(i)) |
873 | find(i)->setFlags(flag); | 872 | find(i)->setFlags(flag); |
874 | } | 873 | } |
875 | 874 | ||
876 | int KeyList::getKeyFlags(int i) const | 875 | int KeyList::getKeyFlags(int i) const |
877 | { | 876 | { |
878 | if(find(i)) | 877 | if(find(i)) |
879 | return find(i)->flags(); | 878 | return find(i)->flags(); |
880 | return 0; | 879 | return 0; |
881 | } | 880 | } |
882 | 881 | ||
883 | bool KeyList::checkNewFlag(int i) const | 882 | bool KeyList::checkNewFlag(int i) const |
884 | { | 883 | { |
885 | if (find(i)) | 884 | if (find(i)) |
886 | return find(i)->newFlag(); | 885 | return find(i)->newFlag(); |
887 | return false; | 886 | return false; |
888 | } | 887 | } |
889 | 888 | ||
890 | void KeyList::setNewFlag(int i, bool f) | 889 | void KeyList::setNewFlag(int i, bool f) |
891 | { | 890 | { |
892 | if(!find(i)) | 891 | if(!find(i)) |
893 | return; | 892 | return; |
894 | find(i)->setNewFlag(f); | 893 | find(i)->setNewFlag(f); |
895 | } | 894 | } |
896 | 895 | ||
897 | bool KeyList::checkDeleteFlag(int i) const | 896 | bool KeyList::checkDeleteFlag(int i) const |
898 | { | 897 | { |
899 | if (find(i)) | 898 | if (find(i)) |
900 | return find(i)->delFlag(); | 899 | return find(i)->delFlag(); |
901 | return false; | 900 | return false; |
902 | } | 901 | } |
903 | 902 | ||
904 | void KeyList::setDeleteFlag(int i, bool f) | 903 | void KeyList::setDeleteFlag(int i, bool f) |
905 | { | 904 | { |
906 | if(!find(i)) | 905 | if(!find(i)) |
907 | return; | 906 | return; |
908 | find(i)->setDelFlag(f); | 907 | find(i)->setDelFlag(f); |
909 | } | 908 | } |
910 | 909 | ||
911 | /*! | 910 | /*! |
912 | Returns the name of the key at index i | 911 | Returns the name of the key at index i |
913 | */ | 912 | */ |
914 | QString KeyList::getKeyName(int i) const | 913 | QString KeyList::getKeyName(int i) const |
915 | { | 914 | { |
916 | if (find (i)) | 915 | if (find (i)) |
917 | return find(i)->name(); | 916 | return find(i)->name(); |
918 | return QString(); | 917 | return QString(); |
919 | } | 918 | } |
920 | 919 | ||
921 | void KeyList::setKeyName(int i, const QString &n) | 920 | void KeyList::setKeyName(int i, const QString &n) |
922 | { | 921 | { |
923 | if(find(i)) | 922 | if(find(i)) |
924 | find(i)->setName(n); | 923 | find(i)->setName(n); |
925 | } | 924 | } |
926 | 925 | ||
927 | /*! | 926 | /*! |
928 | Returns the type of the key at index i | 927 | Returns the type of the key at index i |
929 | */ | 928 | */ |
930 | TVVariant::KeyType KeyList::getKeyType(int i) const | 929 | TVVariant::KeyType KeyList::getKeyType(int i) const |
931 | { | 930 | { |
932 | if(find(i)) | 931 | if(find(i)) |
933 | return find(i)->type(); | 932 | return find(i)->type(); |
934 | return TVVariant::Invalid; | 933 | return TVVariant::Invalid; |
935 | } | 934 | } |
936 | 935 | ||
937 | void KeyList::setKeyType(int i, TVVariant::KeyType t) | 936 | void KeyList::setKeyType(int i, TVVariant::KeyType t) |
938 | { | 937 | { |
939 | if(!find(i)) | 938 | if(!find(i)) |
940 | return; | 939 | return; |
941 | switch(t) { | 940 | switch(t) { |
942 | case TVVariant::String: | 941 | case TVVariant::String: |
943 | find(i)->setExample(TVVariant(QString("default"))); | 942 | find(i)->setExample(TVVariant(QString("default"))); |
944 | return; | 943 | return; |
945 | case TVVariant::Int: | 944 | case TVVariant::Int: |
@@ -1035,19 +1034,19 @@ QDataStream &operator>>( QDataStream &s, KeyList &k) | |||
1035 | \class DataElem | 1034 | \class DataElem |
1036 | \brief A class representing a single row or element of a table in a DBStore | 1035 | \brief A class representing a single row or element of a table in a DBStore |
1037 | 1036 | ||
1038 | This class holds the data of a row in a table. | 1037 | This class holds the data of a row in a table. |
1039 | */ | 1038 | */ |
1040 | 1039 | ||
1041 | 1040 | ||
1042 | /*! | 1041 | /*! |
1043 | Constructs a DataElem. This function needs a container because the | 1042 | Constructs a DataElem. This function needs a container because the |
1044 | size, types of keys and primary key are all defined by the containing | 1043 | size, types of keys and primary key are all defined by the containing |
1045 | database | 1044 | database |
1046 | */ | 1045 | */ |
1047 | DataElem::DataElem(DBStore *c) : values(20) | 1046 | DataElem::DataElem(DBStore *c) : values(20) |
1048 | { | 1047 | { |
1049 | int size; | 1048 | int size; |
1050 | contained = c; | 1049 | contained = c; |
1051 | size = c->getNumFields(); | 1050 | size = c->getNumFields(); |
1052 | values.setAutoDelete(TRUE); | 1051 | values.setAutoDelete(TRUE); |
1053 | } | 1052 | } |
@@ -1081,17 +1080,17 @@ QDataStream &operator>>( QDataStream &s, DataElem &d) | |||
1081 | { | 1080 | { |
1082 | int i; | 1081 | int i; |
1083 | int size; | 1082 | int size; |
1084 | TVVariant t; | 1083 | TVVariant t; |
1085 | Q_UINT16 index = 0; | 1084 | Q_UINT16 index = 0; |
1086 | 1085 | ||
1087 | s >> size; /* redundent data but makes streaming easier */ | 1086 | s >> size; /* redundent data but makes streaming easier */ |
1088 | if (size != d.getNumFields()) { | 1087 | if (size != d.getNumFields()) { |
1089 | owarn << "DataSize mis-match" << oendl; | 1088 | owarn << "DataSize mis-match" << oendl; |
1090 | return s; /* sanity check failed.. don't load */ | 1089 | return s; /* sanity check failed.. don't load */ |
1091 | } | 1090 | } |
1092 | 1091 | ||
1093 | for(i = 0; i < size; i++) { | 1092 | for(i = 0; i < size; i++) { |
1094 | s >> index; | 1093 | s >> index; |
1095 | s >> t; | 1094 | s >> t; |
1096 | d.setField(index, t); | 1095 | d.setField(index, t); |
1097 | } | 1096 | } |
@@ -1104,87 +1103,87 @@ int DataElem::getNumFields() const | |||
1104 | return contained->getNumFields(); | 1103 | return contained->getNumFields(); |
1105 | } | 1104 | } |
1106 | 1105 | ||
1107 | KeyList DataElem::getKeys() const | 1106 | KeyList DataElem::getKeys() const |
1108 | { | 1107 | { |
1109 | return *(contained->getKeys()); | 1108 | return *(contained->getKeys()); |
1110 | } | 1109 | } |
1111 | 1110 | ||
1112 | /*! | 1111 | /*! |
1113 | This function determines whether field index i of the element has been | 1112 | This function determines whether field index i of the element has been |
1114 | set yet. | 1113 | set yet. |
1115 | 1114 | ||
1116 | \return A boolean value that is TRUE if the specfied field of this | 1115 | \return A boolean value that is TRUE if the specfied field of this |
1117 | element has been set and FALSE if the field has not yet been set | 1116 | element has been set and FALSE if the field has not yet been set |
1118 | */ | 1117 | */ |
1119 | bool DataElem::hasValidValue(int i) const | 1118 | bool DataElem::hasValidValue(int i) const |
1120 | { | 1119 | { |
1121 | if(!values.find(i)) | 1120 | if(!values.find(i)) |
1122 | return FALSE; | 1121 | return FALSE; |
1123 | if(!contained->getKeys()->validIndex(i)) | 1122 | if(!contained->getKeys()->validIndex(i)) |
1124 | return FALSE; | 1123 | return FALSE; |
1125 | return values.find(i)->isValid(); | 1124 | return values.find(i)->isValid(); |
1126 | } | 1125 | } |
1127 | 1126 | ||
1128 | /*! | 1127 | /*! |
1129 | This function determines whether field name qs of the element has been | 1128 | This function determines whether field name qs of the element has been |
1130 | set yet. | 1129 | set yet. |
1131 | 1130 | ||
1132 | \return A boolean value that is TRUE if the specfied field of this | 1131 | \return A boolean value that is TRUE if the specfied field of this |
1133 | element has been set and FALSE if the field has not yet been set | 1132 | element has been set and FALSE if the field has not yet been set |
1134 | */ | 1133 | */ |
1135 | bool DataElem::hasValidValue(QString qs) const | 1134 | bool DataElem::hasValidValue(QString qs) const |
1136 | { | 1135 | { |
1137 | int i = contained->getKeyIndex(qs); | 1136 | int i = contained->getKeyIndex(qs); |
1138 | return hasValidValue(i); | 1137 | return hasValidValue(i); |
1139 | } | 1138 | } |
1140 | 1139 | ||
1141 | /*! returns the type of the field specified by index i */ | 1140 | /*! returns the type of the field specified by index i */ |
1142 | TVVariant::KeyType DataElem::getFieldType(int i) const | 1141 | TVVariant::KeyType DataElem::getFieldType(int i) const |
1143 | { | 1142 | { |
1144 | return contained->getKeyType(i); | 1143 | return contained->getKeyType(i); |
1145 | } | 1144 | } |
1146 | 1145 | ||
1147 | /*! returns the type of the field specified by name qs */ | 1146 | /*! returns the type of the field specified by name qs */ |
1148 | TVVariant::KeyType DataElem::getFieldType(QString qs) const | 1147 | TVVariant::KeyType DataElem::getFieldType(QString qs) const |
1149 | { | 1148 | { |
1150 | int i = contained->getKeyIndex(qs); | 1149 | int i = contained->getKeyIndex(qs); |
1151 | return contained->getKeyType(i); | 1150 | return contained->getKeyType(i); |
1152 | } | 1151 | } |
1153 | 1152 | ||
1154 | /*! | 1153 | /*! |
1155 | returns a pointer to the data stored in field index i for this | 1154 | returns a pointer to the data stored in field index i for this |
1156 | data element, (value may not be valid) | 1155 | data element, (value may not be valid) |
1157 | */ | 1156 | */ |
1158 | TVVariant DataElem::getField(int i) const | 1157 | TVVariant DataElem::getField(int i) const |
1159 | { | 1158 | { |
1160 | if(hasValidValue(i)) | 1159 | if(hasValidValue(i)) |
1161 | return TVVariant(*values.find(i)); | 1160 | return TVVariant(*values.find(i)); |
1162 | return TVVariant(); | 1161 | return TVVariant(); |
1163 | } | 1162 | } |
1164 | 1163 | ||
1165 | /*! | 1164 | /*! |
1166 | returns a pointer to the data stored in field name qs for this | 1165 | returns a pointer to the data stored in field name qs for this |
1167 | data element, (value may not be valid) | 1166 | data element, (value may not be valid) |
1168 | */ | 1167 | */ |
1169 | TVVariant DataElem::getField(QString qs) const | 1168 | TVVariant DataElem::getField(QString qs) const |
1170 | { | 1169 | { |
1171 | int i = contained->getKeyIndex(qs); | 1170 | int i = contained->getKeyIndex(qs); |
1172 | return getField(i); | 1171 | return getField(i); |
1173 | } | 1172 | } |
1174 | 1173 | ||
1175 | /*! | 1174 | /*! |
1176 | Sets the value of the elements field index i to the value represented in | 1175 | Sets the value of the elements field index i to the value represented in |
1177 | the QString q. | 1176 | the QString q. |
1178 | 1177 | ||
1179 | \param i index of the field to set | 1178 | \param i index of the field to set |
1180 | \param q a string that can be parsed to get the value to be set | 1179 | \param q a string that can be parsed to get the value to be set |
1181 | */ | 1180 | */ |
1182 | void DataElem::setField(int i, QString q) | 1181 | void DataElem::setField(int i, QString q) |
1183 | { | 1182 | { |
1184 | /* from the type of the field, parse q and store */ | 1183 | /* from the type of the field, parse q and store */ |
1185 | TVVariant::KeyType kt = contained->getKeyType(i); | 1184 | TVVariant::KeyType kt = contained->getKeyType(i); |
1186 | 1185 | ||
1187 | TVVariant t = TVVariant(q); | 1186 | TVVariant t = TVVariant(q); |
1188 | 1187 | ||
1189 | switch(kt) { | 1188 | switch(kt) { |
1190 | case TVVariant::Int: { | 1189 | case TVVariant::Int: { |
@@ -1203,57 +1202,55 @@ void DataElem::setField(int i, QString q) | |||
1203 | return; | 1202 | return; |
1204 | } | 1203 | } |
1205 | case TVVariant::Time: { | 1204 | case TVVariant::Time: { |
1206 | t.asTime(); | 1205 | t.asTime(); |
1207 | setField(i, t); | 1206 | setField(i, t); |
1208 | return; | 1207 | return; |
1209 | } | 1208 | } |
1210 | default: | 1209 | default: |
1211 | qWarning( | 1210 | owarn << "DataElem::setField(" << i << ", " << q << ") No valid type found" << oendl; |
1212 | QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) | ||
1213 | ); | ||
1214 | } | 1211 | } |
1215 | } | 1212 | } |
1216 | 1213 | ||
1217 | /*! | 1214 | /*! |
1218 | Sets the value of the elements field index i to the value at the pointer | 1215 | Sets the value of the elements field index i to the value at the pointer |
1219 | value. | 1216 | value. |
1220 | 1217 | ||
1221 | \param i index of the field to set | 1218 | \param i index of the field to set |
1222 | \param value a pointer to the (already allocated) value to set | 1219 | \param value a pointer to the (already allocated) value to set |
1223 | */ | 1220 | */ |
1224 | void DataElem::setField(int i, TVVariant value) | 1221 | void DataElem::setField(int i, TVVariant value) |
1225 | { | 1222 | { |
1226 | if (value.isValid()) { | 1223 | if (value.isValid()) { |
1227 | values.remove(i); | 1224 | values.remove(i); |
1228 | values.replace(i, new TVVariant(value)); | 1225 | values.replace(i, new TVVariant(value)); |
1229 | } | 1226 | } |
1230 | } | 1227 | } |
1231 | 1228 | ||
1232 | /*! | 1229 | /*! |
1233 | Sets the value of the elements field name qs to the value represented in | 1230 | Sets the value of the elements field name qs to the value represented in |
1234 | the QString q. | 1231 | the QString q. |
1235 | 1232 | ||
1236 | \param qs name of the field to set | 1233 | \param qs name of the field to set |
1237 | \param q a string that can be parsed to get the value to be set | 1234 | \param q a string that can be parsed to get the value to be set |
1238 | */ | 1235 | */ |
1239 | void DataElem::setField(QString qs, QString q) | 1236 | void DataElem::setField(QString qs, QString q) |
1240 | { | 1237 | { |
1241 | /* from the type of the field, parse q and store */ | 1238 | /* from the type of the field, parse q and store */ |
1242 | int i = contained->getKeyIndex(qs); | 1239 | int i = contained->getKeyIndex(qs); |
1243 | setField(i, qs); | 1240 | setField(i, qs); |
1244 | } | 1241 | } |
1245 | 1242 | ||
1246 | /*! | 1243 | /*! |
1247 | Sets the value of the elements field name qs to the value at the pointer | 1244 | Sets the value of the elements field name qs to the value at the pointer |
1248 | value. | 1245 | value. |
1249 | 1246 | ||
1250 | \param qs name of the field to set | 1247 | \param qs name of the field to set |
1251 | \param value a pointer to the (already allocated) value to set | 1248 | \param value a pointer to the (already allocated) value to set |
1252 | */ | 1249 | */ |
1253 | void DataElem::setField(QString qs, TVVariant value) | 1250 | void DataElem::setField(QString qs, TVVariant value) |
1254 | { | 1251 | { |
1255 | int i = contained->getKeyIndex(qs); | 1252 | int i = contained->getKeyIndex(qs); |
1256 | setField(i, value); | 1253 | setField(i, value); |
1257 | } | 1254 | } |
1258 | 1255 | ||
1259 | void DataElem::unsetField(int i) { | 1256 | void DataElem::unsetField(int i) { |
@@ -1262,17 +1259,17 @@ void DataElem::unsetField(int i) { | |||
1262 | 1259 | ||
1263 | void DataElem::unsetField(QString qs) | 1260 | void DataElem::unsetField(QString qs) |
1264 | { | 1261 | { |
1265 | int i = contained->getKeyIndex(qs); | 1262 | int i = contained->getKeyIndex(qs); |
1266 | unsetField(i); | 1263 | unsetField(i); |
1267 | } | 1264 | } |
1268 | 1265 | ||
1269 | /*! | 1266 | /*! |
1270 | Converts the data element to a Rich Text QString | 1267 | Converts the data element to a Rich Text QString |
1271 | */ | 1268 | */ |
1272 | QString DataElem::toQString() const | 1269 | QString DataElem::toQString() const |
1273 | { | 1270 | { |
1274 | /* lets make an attempt at this function */ | 1271 | /* lets make an attempt at this function */ |
1275 | int i; | 1272 | int i; |
1276 | QString scratch = ""; | 1273 | QString scratch = ""; |
1277 | 1274 | ||
1278 | QIntDictIterator<TVVariant> it(values); | 1275 | QIntDictIterator<TVVariant> it(values); |
@@ -1285,46 +1282,46 @@ QString DataElem::toQString() const | |||
1285 | scratch += "<br>"; | 1282 | scratch += "<br>"; |
1286 | } | 1283 | } |
1287 | ++it; | 1284 | ++it; |
1288 | } | 1285 | } |
1289 | return scratch; | 1286 | return scratch; |
1290 | } | 1287 | } |
1291 | 1288 | ||
1292 | /*! formats individual fields to strings so can be displayed */ | 1289 | /*! formats individual fields to strings so can be displayed */ |
1293 | QString DataElem::toQString(int i) const | 1290 | QString DataElem::toQString(int i) const |
1294 | { | 1291 | { |
1295 | if(hasValidValue(i)) { | 1292 | if(hasValidValue(i)) { |
1296 | return getField(i).toString(); | 1293 | return getField(i).toString(); |
1297 | } | 1294 | } |
1298 | return ""; | 1295 | return ""; |
1299 | } | 1296 | } |
1300 | /*! formats individual fields to strings so can be sorted by QListView */ | 1297 | /*! formats individual fields to strings so can be sorted by QListView */ |
1301 | QString DataElem::toSortableQString(int i) const | 1298 | QString DataElem::toSortableQString(int i) const |
1302 | { | 1299 | { |
1303 | QString scratch = ""; | 1300 | QString scratch = ""; |
1304 | if(hasValidValue(i)) { | 1301 | if(hasValidValue(i)) { |
1305 | switch (contained->getKeyType(i)) { | 1302 | switch (contained->getKeyType(i)) { |
1306 | case TVVariant::String: { | 1303 | case TVVariant::String: { |
1307 | scratch += getField(i).toString(); | 1304 | scratch += getField(i).toString(); |
1308 | break; | 1305 | break; |
1309 | } | 1306 | } |
1310 | case TVVariant::Int: { | 1307 | case TVVariant::Int: { |
1311 | scratch.sprintf("%08d", getField(i).toInt()); | 1308 | scratch.sprintf("%08d", getField(i).toInt()); |
1312 | break; | 1309 | break; |
1313 | } | 1310 | } |
1314 | case TVVariant::Date: { | 1311 | case TVVariant::Date: { |
1315 | static QDate epochD(1800, 1, 1); | 1312 | static QDate epochD(1800, 1, 1); |
1316 | scratch.sprintf("%08d", | 1313 | scratch.sprintf("%08d", |
1317 | epochD.daysTo(getField(i).toDate())); | 1314 | epochD.daysTo(getField(i).toDate())); |
1318 | break; | 1315 | break; |
1319 | } | 1316 | } |
1320 | case TVVariant::Time: { | 1317 | case TVVariant::Time: { |
1321 | static QTime epochT(0, 0, 0); | 1318 | static QTime epochT(0, 0, 0); |
1322 | scratch.sprintf("%08d", | 1319 | scratch.sprintf("%08d", |
1323 | epochT.msecsTo(getField(i).toTime())); | 1320 | epochT.msecsTo(getField(i).toTime())); |
1324 | break; | 1321 | break; |
1325 | } | 1322 | } |
1326 | default: | 1323 | default: |
1327 | scratch += "Unknown type"; | 1324 | scratch += "Unknown type"; |
1328 | break; | 1325 | break; |
1329 | } | 1326 | } |
1330 | } | 1327 | } |
@@ -1375,22 +1372,22 @@ bool DataElem::contains(int i, TVVariant v) const | |||
1375 | QString qs1 = getField(i).toString().lower(); | 1372 | QString qs1 = getField(i).toString().lower(); |
1376 | QString qs2 = v.toString().lower(); | 1373 | QString qs2 = v.toString().lower(); |
1377 | if (qs1.contains(qs2) > 0) return TRUE; | 1374 | if (qs1.contains(qs2) > 0) return TRUE; |
1378 | break; | 1375 | break; |
1379 | } | 1376 | } |
1380 | /* meaningless for ints */ | 1377 | /* meaningless for ints */ |
1381 | /* meaningless for time */ | 1378 | /* meaningless for time */ |
1382 | /* meaningless for dates */ | 1379 | /* meaningless for dates */ |
1383 | case TVVariant::Int: | 1380 | case TVVariant::Int: |
1384 | case TVVariant::Time: | 1381 | case TVVariant::Time: |
1385 | case TVVariant::Date: | 1382 | case TVVariant::Date: |
1386 | break; | 1383 | break; |
1387 | default: | 1384 | default: |
1388 | owarn << "Tried to compare unknown data type" << oendl; | 1385 | owarn << "Tried to compare unknown data type" << oendl; |
1389 | } | 1386 | } |
1390 | return FALSE; | 1387 | return FALSE; |
1391 | } | 1388 | } |
1392 | 1389 | ||
1393 | bool DataElem::startsWith(int i, TVVariant v) const | 1390 | bool DataElem::startsWith(int i, TVVariant v) const |
1394 | { | 1391 | { |
1395 | if (!hasValidValue(i)) return FALSE; | 1392 | if (!hasValidValue(i)) return FALSE; |
1396 | 1393 | ||
@@ -1401,22 +1398,22 @@ bool DataElem::startsWith(int i, TVVariant v) const | |||
1401 | case TVVariant::String: { | 1398 | case TVVariant::String: { |
1402 | QString qs1 = getField(i).toString().lower(); | 1399 | QString qs1 = getField(i).toString().lower(); |
1403 | QString qs2 = v.toString().lower(); | 1400 | QString qs2 = v.toString().lower(); |
1404 | return qs1.startsWith(qs2); | 1401 | return qs1.startsWith(qs2); |
1405 | } | 1402 | } |
1406 | /* meaningless for ints */ | 1403 | /* meaningless for ints */ |
1407 | /* meaningless for time */ | 1404 | /* meaningless for time */ |
1408 | /* meaningless for dates */ | 1405 | /* meaningless for dates */ |
1409 | case TVVariant::Int: | 1406 | case TVVariant::Int: |
1410 | case TVVariant::Time: | 1407 | case TVVariant::Time: |
1411 | case TVVariant::Date: | 1408 | case TVVariant::Date: |
1412 | return FALSE; | 1409 | return FALSE; |
1413 | default: | 1410 | default: |
1414 | owarn << "Tried to compare unknown data type" << oendl; | 1411 | owarn << "Tried to compare unknown data type" << oendl; |
1415 | } | 1412 | } |
1416 | return FALSE; | 1413 | return FALSE; |
1417 | } | 1414 | } |
1418 | 1415 | ||
1419 | bool DataElem::endsWith(int i, TVVariant v) const | 1416 | bool DataElem::endsWith(int i, TVVariant v) const |
1420 | { | 1417 | { |
1421 | if (!hasValidValue(i)) return FALSE; | 1418 | if (!hasValidValue(i)) return FALSE; |
1422 | 1419 | ||
@@ -1427,52 +1424,52 @@ bool DataElem::endsWith(int i, TVVariant v) const | |||
1427 | case TVVariant::String: { | 1424 | case TVVariant::String: { |
1428 | QString qs1 = getField(i).toString().lower(); | 1425 | QString qs1 = getField(i).toString().lower(); |
1429 | QString qs2 = v.toString().lower(); | 1426 | QString qs2 = v.toString().lower(); |
1430 | return qs1.startsWith(qs2); | 1427 | return qs1.startsWith(qs2); |
1431 | } | 1428 | } |
1432 | /* meaningless for ints */ | 1429 | /* meaningless for ints */ |
1433 | /* meaningless for time */ | 1430 | /* meaningless for time */ |
1434 | /* meaningless for dates */ | 1431 | /* meaningless for dates */ |
1435 | case TVVariant::Int: | 1432 | case TVVariant::Int: |
1436 | case TVVariant::Time: | 1433 | case TVVariant::Time: |
1437 | case TVVariant::Date: | 1434 | case TVVariant::Date: |
1438 | return FALSE; | 1435 | return FALSE; |
1439 | default: | 1436 | default: |
1440 | owarn << "Tried to compare unknown data type" << oendl; | 1437 | owarn << "Tried to compare unknown data type" << oendl; |
1441 | } | 1438 | } |
1442 | return FALSE; | 1439 | return FALSE; |
1443 | } | 1440 | } |
1444 | 1441 | ||
1445 | /*! | 1442 | /*! |
1446 | Determins which of the first to parameters are closer to the third, target | 1443 | Determins which of the first to parameters are closer to the third, target |
1447 | parameter. | 1444 | parameter. |
1448 | 1445 | ||
1449 | \return | 1446 | \return |
1450 | <UL> | 1447 | <UL> |
1451 | <LI>TRUE if the first element is a closer match to the target than the | 1448 | <LI>TRUE if the first element is a closer match to the target than the |
1452 | second element</LI> | 1449 | second element</LI> |
1453 | <LI>FALSE if the first element is not a closer match to the target than | 1450 | <LI>FALSE if the first element is not a closer match to the target than |
1454 | the second element</LI> | 1451 | the second element</LI> |
1455 | </UL> | 1452 | </UL> |
1456 | */ | 1453 | */ |
1457 | bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) | 1454 | bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) |
1458 | { | 1455 | { |
1459 | int type; | 1456 | int type; |
1460 | 1457 | ||
1461 | if(!d1) return FALSE; | 1458 | if(!d1) return FALSE; |
1462 | 1459 | ||
1463 | if (!d1->hasValidValue(column)) return FALSE; | 1460 | if (!d1->hasValidValue(column)) return FALSE; |
1464 | 1461 | ||
1465 | if(!target.isValid()) return FALSE; | 1462 | if(!target.isValid()) return FALSE; |
1466 | 1463 | ||
1467 | type = d1->getField(column).type(); | 1464 | type = d1->getField(column).type(); |
1468 | 1465 | ||
1469 | if(d2) { | 1466 | if(d2) { |
1470 | if (type != d2->getField(column).type()) { | 1467 | if (type != d2->getField(column).type()) { |
1471 | /* can't do compare */ | 1468 | /* can't do compare */ |
1472 | owarn << "Tried to compare two incompatable types" << oendl; | 1469 | owarn << "Tried to compare two incompatable types" << oendl; |
1473 | return FALSE; | 1470 | return FALSE; |
1474 | } | 1471 | } |
1475 | return target.closer(d1->getField(column), d2->getField(column)); | 1472 | return target.closer(d1->getField(column), d2->getField(column)); |
1476 | } | 1473 | } |
1477 | return target.close(d1->getField(column)); | 1474 | return target.close(d1->getField(column)); |
1478 | } | 1475 | } |
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp index 6380e1b..de57961 100644 --- a/noncore/apps/tableviewer/db/datacache.cpp +++ b/noncore/apps/tableviewer/db/datacache.cpp | |||
@@ -11,17 +11,17 @@ | |||
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 | * This file is used to load the xml files that represent the database. | 21 | * This file is used to load the xml files that represent the database. |
22 | * The main requirment for said file is each data entry must contain a key, | 22 | * The main requirment for said file is each data entry must contain a key, |
23 | * otherwise any other data headings are allowed. | 23 | * otherwise any other data headings are allowed. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "datacache.h" | 26 | #include "datacache.h" |
27 | #include "xmlsource.h" | 27 | #include "xmlsource.h" |
@@ -58,20 +58,20 @@ DBStore::DBStore() | |||
58 | kRep = new KeyList(); | 58 | kRep = new KeyList(); |
59 | master_table.resize(INIT_TABLE_SIZE); | 59 | master_table.resize(INIT_TABLE_SIZE); |
60 | table_size = INIT_TABLE_SIZE; | 60 | table_size = INIT_TABLE_SIZE; |
61 | 61 | ||
62 | current_elem = 0; | 62 | current_elem = 0; |
63 | archive = 0; | 63 | archive = 0; |
64 | } | 64 | } |
65 | 65 | ||
66 | //TODO | 66 | //TODO |
67 | /*! | 67 | /*! |
68 | Reinitializes the table to empty (include a resize of the master table, | 68 | Reinitializes the table to empty (include a resize of the master table, |
69 | which should free some memory) | 69 | which should free some memory) |
70 | */ | 70 | */ |
71 | void DBStore::freeTable() | 71 | void DBStore::freeTable() |
72 | { | 72 | { |
73 | name = ""; | 73 | name = ""; |
74 | if(archive) { | 74 | if(archive) { |
75 | delete archive; | 75 | delete archive; |
76 | archive = 0; | 76 | archive = 0; |
77 | } | 77 | } |
@@ -88,82 +88,82 @@ void DBStore::freeTable() | |||
88 | Removes all items from the DBStore and destroys the DBStore | 88 | Removes all items from the DBStore and destroys the DBStore |
89 | */ | 89 | */ |
90 | DBStore::~DBStore() | 90 | DBStore::~DBStore() |
91 | { | 91 | { |
92 | freeTable(); | 92 | freeTable(); |
93 | } | 93 | } |
94 | 94 | ||
95 | /*! | 95 | /*! |
96 | This function opens the given xml file, loads it and sets up the | 96 | This function opens the given xml file, loads it and sets up the |
97 | appropriate data structures. | 97 | appropriate data structures. |
98 | 98 | ||
99 | \param file_name A string representing the name of the file to be opened | 99 | \param file_name A string representing the name of the file to be opened |
100 | \return true if successful, false otherwise. | 100 | \return true if successful, false otherwise. |
101 | */ | 101 | */ |
102 | bool DBStore::openSource(QIODevice *inDev, const QString &source) { | 102 | bool DBStore::openSource(QIODevice *inDev, const QString &source) { |
103 | 103 | ||
104 | /* first check if db is already open, if contains data.. then clear */ | 104 | /* first check if db is already open, if contains data.. then clear */ |
105 | if(number_elems > 0) { | 105 | if(number_elems > 0) { |
106 | freeTable(); | 106 | freeTable(); |
107 | } | 107 | } |
108 | 108 | ||
109 | if (source == "text/x-xml-tableviewer") { | 109 | if (source == "text/x-xml-tableviewer") { |
110 | archive = new DBXml(this); | 110 | archive = new DBXml(this); |
111 | } else if (source == "text/csv") { | 111 | } else if (source == "text/csv") { |
112 | archive = new DBCsv(this); | 112 | archive = new DBCsv(this); |
113 | } else | 113 | } else |
114 | return false; | 114 | return false; |
115 | 115 | ||
116 | return (archive->openSource(inDev)); | 116 | return (archive->openSource(inDev)); |
117 | } | 117 | } |
118 | 118 | ||
119 | bool DBStore::saveSource(QIODevice *outDev, const QString &source) | 119 | bool DBStore::saveSource(QIODevice *outDev, const QString &source) |
120 | { | 120 | { |
121 | /* saving a new file */ | 121 | /* saving a new file */ |
122 | if(!archive) { | 122 | if(!archive) { |
123 | if (source == "text/x-xml-tableviewer") { | 123 | if (source == "text/x-xml-tableviewer") { |
124 | archive = new DBXml(this); | 124 | archive = new DBXml(this); |
125 | } else if (source == "text/x-xml-tableviewer") { | 125 | } else if (source == "text/x-xml-tableviewer") { |
126 | archive = new DBCsv(this); | 126 | archive = new DBCsv(this); |
127 | } else | 127 | } else |
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | 130 | ||
131 | /* changing file type */ | 131 | /* changing file type */ |
132 | if(archive->type() != source) { | 132 | if(archive->type() != source) { |
133 | delete archive; | 133 | delete archive; |
134 | if (source == "text/x-xml-tableviewer") { | 134 | if (source == "text/x-xml-tableviewer") { |
135 | archive = new DBXml(this); | 135 | archive = new DBXml(this); |
136 | } else if (source == "text/x-xml-tableviewer") { | 136 | } else if (source == "text/x-xml-tableviewer") { |
137 | archive = new DBCsv(this); | 137 | archive = new DBCsv(this); |
138 | } else | 138 | } else |
139 | return false; | 139 | return false; |
140 | } | 140 | } |
141 | 141 | ||
142 | return (archive->saveSource(outDev)); | 142 | return (archive->saveSource(outDev)); |
143 | } | 143 | } |
144 | 144 | ||
145 | /*! | 145 | /*! |
146 | This function is used to add new elements to the database. If the database | 146 | This function is used to add new elements to the database. If the database |
147 | has already reached the maximum allowable size this function does not alter | 147 | has already reached the maximum allowable size this function does not alter |
148 | the database. | 148 | the database. |
149 | 149 | ||
150 | \param delm An already allocated and initialized data element to be added | 150 | \param delm An already allocated and initialized data element to be added |
151 | */ | 151 | */ |
152 | void DBStore::addItem(DataElem *delem) | 152 | void DBStore::addItem(DataElem *delem) |
153 | { | 153 | { |
154 | addItemInternal(delem); | 154 | addItemInternal(delem); |
155 | } | 155 | } |
156 | 156 | ||
157 | void DBStore::addItemInternal(DataElem *delem) | 157 | void DBStore::addItemInternal(DataElem *delem) |
158 | { | 158 | { |
159 | /* if already full, don't over fill, do a qWarning though */ | 159 | /* if already full, don't over fill, do a owarn though */ |
160 | if (full) { | 160 | if (full) { |
161 | owarn << "Attempted to add items to already full table" << oendl; | 161 | owarn << "Attempted to add items to already full table" << oendl; |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | 164 | ||
165 | master_table.insert(number_elems, delem); | 165 | master_table.insert(number_elems, delem); |
166 | 166 | ||
167 | current_elem = number_elems; | 167 | current_elem = number_elems; |
168 | number_elems++; | 168 | number_elems++; |
169 | 169 | ||
@@ -180,47 +180,47 @@ void DBStore::addItemInternal(DataElem *delem) | |||
180 | } | 180 | } |
181 | master_table.resize(table_size); | 181 | master_table.resize(table_size); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void DBStore::removeItem(DataElem *r) | 185 | void DBStore::removeItem(DataElem *r) |
186 | { | 186 | { |
187 | int position = master_table.findRef(r); | 187 | int position = master_table.findRef(r); |
188 | if(position != -1) { | 188 | if(position != -1) { |
189 | /* there is at least one item, this is it */ | 189 | /* there is at least one item, this is it */ |
190 | /* replace this with the last element, decrease the element count */ | 190 | /* replace this with the last element, decrease the element count */ |
191 | master_table.insert(position, master_table.at(--number_elems)); | 191 | master_table.insert(position, master_table.at(--number_elems)); |
192 | master_table.remove(number_elems); | 192 | master_table.remove(number_elems); |
193 | delete r; | 193 | delete r; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | /*! | 197 | /*! |
198 | Sets the name of the database | 198 | Sets the name of the database |
199 | 199 | ||
200 | \param n A string representing the new name of the database. | 200 | \param n A string representing the new name of the database. |
201 | */ | 201 | */ |
202 | void DBStore::setName(const QString &n) | 202 | void DBStore::setName(const QString &n) |
203 | { | 203 | { |
204 | name = n; | 204 | name = n; |
205 | } | 205 | } |
206 | 206 | ||
207 | /*! | 207 | /*! |
208 | Gets the name of the database | 208 | Gets the name of the database |
209 | 209 | ||
210 | \return A string representing the name of the database. | 210 | \return A string representing the name of the database. |
211 | */ | 211 | */ |
212 | QString DBStore::getName() | 212 | QString DBStore::getName() |
213 | { | 213 | { |
214 | return name; | 214 | return name; |
215 | } | 215 | } |
216 | 216 | ||
217 | /*! | 217 | /*! |
218 | Retrieves a pointer to the key representation of the database for | 218 | Retrieves a pointer to the key representation of the database for |
219 | other classes to use as reference. | 219 | other classes to use as reference. |
220 | 220 | ||
221 | \return a pointer to the databases key representaion | 221 | \return a pointer to the databases key representaion |
222 | */ | 222 | */ |
223 | KeyList *DBStore::getKeys() | 223 | KeyList *DBStore::getKeys() |
224 | { | 224 | { |
225 | return kRep; | 225 | return kRep; |
226 | } | 226 | } |
@@ -230,39 +230,39 @@ KeyList *DBStore::getKeys() | |||
230 | \param a pointer to a key representaton | 230 | \param a pointer to a key representaton |
231 | */ | 231 | */ |
232 | void DBStore::setKeys(KeyList *k) | 232 | void DBStore::setKeys(KeyList *k) |
233 | { | 233 | { |
234 | kRep = k; | 234 | kRep = k; |
235 | } | 235 | } |
236 | 236 | ||
237 | /*! | 237 | /*! |
238 | Sets the current element to the first element of the database | 238 | Sets the current element to the first element of the database |
239 | */ | 239 | */ |
240 | void DBStore::first() | 240 | void DBStore::first() |
241 | { | 241 | { |
242 | current_elem = 0; | 242 | current_elem = 0; |
243 | } | 243 | } |
244 | 244 | ||
245 | /*! | 245 | /*! |
246 | Sets the current element to the last element of the database | 246 | Sets the current element to the last element of the database |
247 | */ | 247 | */ |
248 | void DBStore::last() | 248 | void DBStore::last() |
249 | { | 249 | { |
250 | current_elem = number_elems - 1; | 250 | current_elem = number_elems - 1; |
251 | } | 251 | } |
252 | 252 | ||
253 | /*! | 253 | /*! |
254 | Sets the current element to the next element of the database if | 254 | Sets the current element to the next element of the database if |
255 | there exists an element after the current one. | 255 | there exists an element after the current one. |
256 | */ | 256 | */ |
257 | bool DBStore::next() | 257 | bool DBStore::next() |
258 | { | 258 | { |
259 | unsigned int new_current_elem = current_elem + 1; | 259 | unsigned int new_current_elem = current_elem + 1; |
260 | if (current_elem < number_elems) | 260 | if (current_elem < number_elems) |
261 | /* was valid before inc (it is possible but unlikely that inc current | 261 | /* was valid before inc (it is possible but unlikely that inc current |
262 | elem will change it from invalid to valid) */ | 262 | elem will change it from invalid to valid) */ |
263 | if (new_current_elem < number_elems) { | 263 | if (new_current_elem < number_elems) { |
264 | /* is valid after inc */ | 264 | /* is valid after inc */ |
265 | current_elem = new_current_elem; | 265 | current_elem = new_current_elem; |
266 | return true; | 266 | return true; |
267 | } | 267 | } |
268 | return false; | 268 | return false; |
@@ -273,29 +273,29 @@ bool DBStore::next() | |||
273 | there exists an element before the current one. | 273 | there exists an element before the current one. |
274 | */ | 274 | */ |
275 | bool DBStore::previous() | 275 | bool DBStore::previous() |
276 | { | 276 | { |
277 | unsigned int new_current_elem = current_elem -1; | 277 | unsigned int new_current_elem = current_elem -1; |
278 | if (current_elem < number_elems) | 278 | if (current_elem < number_elems) |
279 | /* was valid */ | 279 | /* was valid */ |
280 | if (new_current_elem < number_elems) { | 280 | if (new_current_elem < number_elems) { |
281 | /* still is (if was 0, then now -1, but as is unsigned will wrap | 281 | /* still is (if was 0, then now -1, but as is unsigned will wrap |
282 | and hence be invalid */ | 282 | and hence be invalid */ |
283 | current_elem = new_current_elem; | 283 | current_elem = new_current_elem; |
284 | return true; | 284 | return true; |
285 | } | 285 | } |
286 | return false; | 286 | return false; |
287 | } | 287 | } |
288 | 288 | ||
289 | /*! | 289 | /*! |
290 | Returns the current data element in the database. Which element is current | 290 | Returns the current data element in the database. Which element is current |
291 | is affected by newly added items, findItem, next, previous, first and | 291 | is affected by newly added items, findItem, next, previous, first and |
292 | last functions | 292 | last functions |
293 | 293 | ||
294 | \return a pointer to the current data element | 294 | \return a pointer to the current data element |
295 | */ | 295 | */ |
296 | DataElem *DBStore::getCurrentData() | 296 | DataElem *DBStore::getCurrentData() |
297 | { | 297 | { |
298 | if (current_elem >= number_elems) | 298 | if (current_elem >= number_elems) |
299 | return NULL; | 299 | return NULL; |
300 | return master_table[current_elem]; | 300 | return master_table[current_elem]; |
301 | } | 301 | } |
diff --git a/noncore/apps/tableviewer/db/datacache.h b/noncore/apps/tableviewer/db/datacache.h index c5dc637..e38050c 100644 --- a/noncore/apps/tableviewer/db/datacache.h +++ b/noncore/apps/tableviewer/db/datacache.h | |||
@@ -22,40 +22,46 @@ | |||
22 | * This file is used to load the xml files that represent the database. | 22 | * This file is used to load the xml files that represent the database. |
23 | * The main requirment for said file is each data entry must contain a key, | 23 | * The main requirment for said file is each data entry must contain a key, |
24 | * otherwise any other data headings are allowed. | 24 | * otherwise any other data headings are allowed. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef __DATACACHE_H__ | 27 | #ifndef __DATACACHE_H__ |
28 | #define __DATACACHE_H__ | 28 | #define __DATACACHE_H__ |
29 | 29 | ||
30 | #include "common.h" | ||
31 | |||
32 | /* OPIE */ | ||
33 | #include <opie2/odebug.h> | ||
34 | using namespace Opie::Core; | ||
35 | |||
36 | /* QT */ | ||
30 | #include <qstring.h> | 37 | #include <qstring.h> |
31 | #include <qvector.h> | 38 | #include <qvector.h> |
32 | #include "common.h" | ||
33 | 39 | ||
34 | class DBStore; | 40 | class DBStore; |
35 | 41 | ||
36 | /*! Abstract class that defines how database stuff can be accessed */ | 42 | /*! Abstract class that defines how database stuff can be accessed */ |
37 | class DBAccess { | 43 | class DBAccess { |
38 | public: | 44 | public: |
39 | 45 | ||
40 | // DBAccess(DBStore *d) { dstore = d; } | 46 | // DBAccess(DBStore *d) { dstore = d; } |
41 | virtual ~DBAccess() {} | 47 | virtual ~DBAccess() {} |
42 | 48 | ||
43 | virtual QString type() { | 49 | virtual QString type() { |
44 | return QString(); | 50 | return QString(); |
45 | } | 51 | } |
46 | 52 | ||
47 | virtual bool openSource(QIODevice *) { | 53 | virtual bool openSource(QIODevice *) { |
48 | qWarning("DBAccess::openSource not yet implemented"); | 54 | owarn << "DBAccess::openSource not yet implemented" << oendl; |
49 | return false; | 55 | return false; |
50 | } | 56 | } |
51 | 57 | ||
52 | virtual bool saveSource(QIODevice *) { | 58 | virtual bool saveSource(QIODevice *) { |
53 | qWarning("DBAccess::saveSource(QString) not yet implemented"); | 59 | owarn << "DBAccess::saveSource(QString) not yet implemented" << oendl; |
54 | return false; | 60 | return false; |
55 | } | 61 | } |
56 | 62 | ||
57 | protected: | 63 | protected: |
58 | DBStore *dstore; | 64 | DBStore *dstore; |
59 | QString source_name; | 65 | QString source_name; |
60 | }; | 66 | }; |
61 | 67 | ||
@@ -65,17 +71,17 @@ public: | |||
65 | ~DBStore(); | 71 | ~DBStore(); |
66 | 72 | ||
67 | bool openSource(QIODevice *, const QString &source); | 73 | bool openSource(QIODevice *, const QString &source); |
68 | bool saveSource(QIODevice *, const QString &source); | 74 | bool saveSource(QIODevice *, const QString &source); |
69 | 75 | ||
70 | // Add an item | 76 | // Add an item |
71 | void addItem(DataElem *); | 77 | void addItem(DataElem *); |
72 | void addItemInternal(DataElem *); | 78 | void addItemInternal(DataElem *); |
73 | void removeItem(DataElem *); | 79 | void removeItem(DataElem *); |
74 | 80 | ||
75 | // Set the name of the database | 81 | // Set the name of the database |
76 | void setName(const QString &name); | 82 | void setName(const QString &name); |
77 | 83 | ||
78 | // Get the name of the database | 84 | // Get the name of the database |
79 | QString getName(); | 85 | QString getName(); |
80 | 86 | ||
81 | KeyList *getKeys(); | 87 | KeyList *getKeys(); |
@@ -101,30 +107,30 @@ public: | |||
101 | return kRep->getKeyName(i); | 107 | return kRep->getKeyName(i); |
102 | } | 108 | } |
103 | 109 | ||
104 | // Access functions.. iterator type stuff | 110 | // Access functions.. iterator type stuff |
105 | 111 | ||
106 | void first(); | 112 | void first(); |
107 | void last(); | 113 | void last(); |
108 | 114 | ||
109 | bool next(); | 115 | bool next(); |
110 | bool previous(); | 116 | bool previous(); |
111 | 117 | ||
112 | DataElem* getCurrentData(); | 118 | DataElem* getCurrentData(); |
113 | 119 | ||
114 | private: | 120 | private: |
115 | /* does the work of freeing used memory */ | 121 | /* does the work of freeing used memory */ |
116 | void freeTable(); | 122 | void freeTable(); |
117 | QString name; | 123 | QString name; |
118 | 124 | ||
119 | QVector<DataElem> master_table; | 125 | QVector<DataElem> master_table; |
120 | DBAccess *archive; | 126 | DBAccess *archive; |
121 | 127 | ||
122 | KeyList *kRep; | 128 | KeyList *kRep; |
123 | 129 | ||
124 | unsigned int number_elems; | 130 | unsigned int number_elems; |
125 | unsigned int table_size; /* should always be a power of 2 */ | 131 | unsigned int table_size; /* should always be a power of 2 */ |
126 | bool full; /* since because we are using an int for indexing there is | 132 | bool full; /* since because we are using an int for indexing there is |
127 | an upper limit on the number of items we can store. */ | 133 | an upper limit on the number of items we can store. */ |
128 | unsigned int current_elem; | 134 | unsigned int current_elem; |
129 | }; | 135 | }; |
130 | #endif | 136 | #endif |
diff --git a/noncore/apps/tableviewer/ui/browsekeyentry.cpp b/noncore/apps/tableviewer/ui/browsekeyentry.cpp index 42e24dd..6b78437 100644 --- a/noncore/apps/tableviewer/ui/browsekeyentry.cpp +++ b/noncore/apps/tableviewer/ui/browsekeyentry.cpp | |||
@@ -11,43 +11,43 @@ | |||
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 "browsekeyentry.h" | 20 | #include "browsekeyentry.h" |
21 | #include "commonwidgets.h" | 21 | #include "commonwidgets.h" |
22 | 22 | ||
23 | #include <opie2/odebug.h> | ||
24 | using namespace Opie::Core; | ||
25 | |||
23 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
24 | #include <qwidgetstack.h> | 27 | #include <qwidgetstack.h> |
25 | #include <qlayout.h> | 28 | #include <qlayout.h> |
26 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
27 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
28 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
29 | #include <qhbox.h> | 32 | #include <qhbox.h> |
30 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
31 | 34 | ||
32 | #include <qheader.h> | ||
33 | // For qWarning(const char *) | ||
34 | |||
35 | /*! | 35 | /*! |
36 | \class TVBrowseKeyEntry | 36 | \class TVBrowseKeyEntry |
37 | \brief a Widget used enter keys into the TVBrowseViewWidget | 37 | \brief a Widget used enter keys into the TVBrowseViewWidget |
38 | 38 | ||
39 | The TVBrowseKeyEntry Widget provides the facility to enter | 39 | The TVBrowseKeyEntry Widget provides the facility to enter |
40 | various key types to be search on in the table. The key can be changed | 40 | various key types to be search on in the table. The key can be changed |
41 | and the entry field will update to the correct sort of widget appropriately | 41 | and the entry field will update to the correct sort of widget appropriately |
42 | */ | 42 | */ |
43 | 43 | ||
44 | /*! | 44 | /*! |
45 | Constructs the widget | 45 | Constructs the widget |
46 | */ | 46 | */ |
47 | TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | 47 | TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) |
48 | : QWidget(parent, name, f) | 48 | : QWidget(parent, name, f) |
49 | { | 49 | { |
50 | QHBoxLayout *h_layout = new QHBoxLayout(this); | 50 | QHBoxLayout *h_layout = new QHBoxLayout(this); |
51 | 51 | ||
52 | textKey = new QLineEdit(this, 0); | 52 | textKey = new QLineEdit(this, 0); |
53 | intKey = new IntEdit(this, 0); | 53 | intKey = new IntEdit(this, 0); |
@@ -68,46 +68,46 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | |||
68 | 68 | ||
69 | ws = new QWidgetStack(this, 0); | 69 | ws = new QWidgetStack(this, 0); |
70 | ws->addWidget(textKey, TVVariant::String); | 70 | ws->addWidget(textKey, TVVariant::String); |
71 | ws->addWidget(intKey, TVVariant::Int); | 71 | ws->addWidget(intKey, TVVariant::Int); |
72 | ws->addWidget(timeKey, TVVariant::Time); | 72 | ws->addWidget(timeKey, TVVariant::Time); |
73 | ws->addWidget(dateKey, TVVariant::Date); | 73 | ws->addWidget(dateKey, TVVariant::Date); |
74 | 74 | ||
75 | ws->raiseWidget(TVVariant::String); | 75 | ws->raiseWidget(TVVariant::String); |
76 | 76 | ||
77 | // TODO connect slots and signals.... | 77 | // TODO connect slots and signals.... |
78 | connect(changeKeyButton, SIGNAL(clicked()), | 78 | connect(changeKeyButton, SIGNAL(clicked()), |
79 | this, SLOT(changeKeyMenuSlot())); | 79 | this, SLOT(changeKeyMenuSlot())); |
80 | 80 | ||
81 | connect(resetButton, SIGNAL(clicked()), | 81 | connect(resetButton, SIGNAL(clicked()), |
82 | textKey, SLOT(clear())); | 82 | textKey, SLOT(clear())); |
83 | connect(resetButton, SIGNAL(clicked()), | 83 | connect(resetButton, SIGNAL(clicked()), |
84 | intKey, SLOT(clear())); | 84 | intKey, SLOT(clear())); |
85 | connect(resetButton, SIGNAL(clicked()), | 85 | connect(resetButton, SIGNAL(clicked()), |
86 | dateKey, SLOT(clear())); | 86 | dateKey, SLOT(clear())); |
87 | connect(resetButton, SIGNAL(clicked()), | 87 | connect(resetButton, SIGNAL(clicked()), |
88 | timeKey, SLOT(clear())); | 88 | timeKey, SLOT(clear())); |
89 | 89 | ||
90 | h_layout->addWidget(ws); | 90 | h_layout->addWidget(ws); |
91 | h_layout->addWidget(resetButton); | 91 | h_layout->addWidget(resetButton); |
92 | h_layout->addWidget(changeKeyButton); | 92 | h_layout->addWidget(changeKeyButton); |
93 | 93 | ||
94 | connect(textKey, SIGNAL(textChanged(const QString&)), | 94 | connect(textKey, SIGNAL(textChanged(const QString&)), |
95 | this, SLOT(searchOnText())); | 95 | this, SLOT(searchOnText())); |
96 | connect(intKey, SIGNAL(valueChanged(int)), | 96 | connect(intKey, SIGNAL(valueChanged(int)), |
97 | this, SLOT(searchOnText())); | 97 | this, SLOT(searchOnText())); |
98 | connect(dateKey, SIGNAL(valueChanged(const QDate&)), | 98 | connect(dateKey, SIGNAL(valueChanged(const QDate&)), |
99 | this, SLOT(searchOnText())); | 99 | this, SLOT(searchOnText())); |
100 | connect(timeKey, SIGNAL(valueChanged(const QTime&)), | 100 | connect(timeKey, SIGNAL(valueChanged(const QTime&)), |
101 | this, SLOT(searchOnText())); | 101 | this, SLOT(searchOnText())); |
102 | } | 102 | } |
103 | 103 | ||
104 | /*! | 104 | /*! |
105 | Destructs the widget | 105 | Destructs the widget |
106 | */ | 106 | */ |
107 | TVBrowseKeyEntry::~TVBrowseKeyEntry() | 107 | TVBrowseKeyEntry::~TVBrowseKeyEntry() |
108 | { | 108 | { |
109 | } | 109 | } |
110 | 110 | ||
111 | /*! | 111 | /*! |
112 | Changes which key the user intends to search on | 112 | Changes which key the user intends to search on |
113 | 113 | ||
@@ -121,17 +121,17 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param) | |||
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | /*! | 124 | /*! |
125 | Opens the change key menu | 125 | Opens the change key menu |
126 | */ | 126 | */ |
127 | void TVBrowseKeyEntry::changeKeyMenuSlot() | 127 | void TVBrowseKeyEntry::changeKeyMenuSlot() |
128 | { | 128 | { |
129 | if(ts) | 129 | if(ts) |
130 | keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0))); | 130 | keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0))); |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | void TVBrowseKeyEntry::setTableState(TableState *t) { | 134 | void TVBrowseKeyEntry::setTableState(TableState *t) { |
135 | ts = t; | 135 | ts = t; |
136 | } | 136 | } |
137 | 137 | ||
@@ -141,35 +141,35 @@ void TVBrowseKeyEntry::rebuildKeys() { | |||
141 | if (!ts->kRep) return; | 141 | if (!ts->kRep) return; |
142 | 142 | ||
143 | /* clear the old */ | 143 | /* clear the old */ |
144 | keyMenu->clear(); | 144 | keyMenu->clear(); |
145 | 145 | ||
146 | KeyListIterator it(*ts->kRep); | 146 | KeyListIterator it(*ts->kRep); |
147 | 147 | ||
148 | for (i = 0; i < ts->kRep->getNumFields(); i++) { | 148 | for (i = 0; i < ts->kRep->getNumFields(); i++) { |
149 | keyMenu->insertItem(it.current()->name(), this, | 149 | keyMenu->insertItem(it.current()->name(), this, |
150 | SLOT(changeKeySlot(int)), 0, i); | 150 | SLOT(changeKeySlot(int)), 0, i); |
151 | keyMenu->setItemParameter(i, it.currentKey()); | 151 | keyMenu->setItemParameter(i, it.currentKey()); |
152 | ++it; | 152 | ++it; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | void TVBrowseKeyEntry::reset() | 156 | void TVBrowseKeyEntry::reset() |
157 | { | 157 | { |
158 | textKey->clear(); | 158 | textKey->clear(); |
159 | intKey->clear(); | 159 | intKey->clear(); |
160 | dateKey->clear(); | 160 | dateKey->clear(); |
161 | timeKey->clear(); | 161 | timeKey->clear(); |
162 | 162 | ||
163 | keyMenu->clear(); | 163 | keyMenu->clear(); |
164 | } | 164 | } |
165 | /*! | 165 | /*! |
166 | Searches on the current value of the key entry provided that the | 166 | Searches on the current value of the key entry provided that the |
167 | current key is of type text WARNING, TODO fix memory leaks | 167 | current key is of type text WARNING, TODO fix memory leaks |
168 | */ | 168 | */ |
169 | void TVBrowseKeyEntry::searchOnText() | 169 | void TVBrowseKeyEntry::searchOnText() |
170 | { | 170 | { |
171 | TVVariant sendkey; | 171 | TVVariant sendkey; |
172 | 172 | ||
173 | if (!ts) | 173 | if (!ts) |
174 | return; | 174 | return; |
175 | 175 | ||
@@ -184,23 +184,22 @@ void TVBrowseKeyEntry::searchOnText() | |||
184 | case TVVariant::Time: { | 184 | case TVVariant::Time: { |
185 | sendkey = TVVariant(QTime(timeKey->time())); | 185 | sendkey = TVVariant(QTime(timeKey->time())); |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | case TVVariant::Date: { | 188 | case TVVariant::Date: { |
189 | sendkey = TVVariant(QDate(dateKey->date())); | 189 | sendkey = TVVariant(QDate(dateKey->date())); |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | case TVVariant::Invalid: | 192 | case TVVariant::Invalid: |
193 | break; | 193 | break; |
194 | default: | 194 | default: |
195 | qWarning("TVBrowseKeyEntry::searchOnText() " | 195 | owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl; |
196 | "cannot work out data type"); | ||
197 | return; | 196 | return; |
198 | } | 197 | } |
199 | emit searchOnKey(ts->current_column, sendkey); | 198 | emit searchOnKey(ts->current_column, sendkey); |
200 | } | 199 | } |
201 | 200 | ||
202 | /*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, TVVariant) | 201 | /*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, TVVariant) |
203 | 202 | ||
204 | This signal indicates that a search on key index currentKeyId should be | 203 | This signal indicates that a search on key index currentKeyId should be |
205 | done searching for the value v. | 204 | done searching for the value v. |
206 | */ | 205 | */ |
diff --git a/noncore/apps/tableviewer/ui/filterkeyentry.cpp b/noncore/apps/tableviewer/ui/filterkeyentry.cpp index d108fbd..4d74d6b 100644 --- a/noncore/apps/tableviewer/ui/filterkeyentry.cpp +++ b/noncore/apps/tableviewer/ui/filterkeyentry.cpp | |||
@@ -11,20 +11,25 @@ | |||
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 "filterkeyentry.h" | 20 | #include "filterkeyentry.h" |
21 | #include "commonwidgets.h" | 21 | #include "commonwidgets.h" |
22 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
25 | using namespace Opie::Core; | ||
26 | |||
27 | /* QT */ | ||
23 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
24 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
25 | #include <qlayout.h> | 30 | #include <qlayout.h> |
26 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
27 | #include <qsizepolicy.h> | 32 | #include <qsizepolicy.h> |
28 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
29 | #include <qhbox.h> | 34 | #include <qhbox.h> |
30 | 35 | ||
@@ -93,44 +98,44 @@ TVFilterKeyEntry::TVFilterKeyEntry(QWidget *parent, const char *name, WFlags f) | |||
93 | ws = new QWidgetStack(this, 0); | 98 | ws = new QWidgetStack(this, 0); |
94 | ws->setMargin(0); | 99 | ws->setMargin(0); |
95 | ws->addWidget(textEntry, TVVariant::String); | 100 | ws->addWidget(textEntry, TVVariant::String); |
96 | ws->addWidget(intEntry, TVVariant::Int); | 101 | ws->addWidget(intEntry, TVVariant::Int); |
97 | ws->addWidget(timeEntry, TVVariant::Time); | 102 | ws->addWidget(timeEntry, TVVariant::Time); |
98 | ws->addWidget(dateEntry, TVVariant::Date); | 103 | ws->addWidget(dateEntry, TVVariant::Date); |
99 | 104 | ||
100 | /* connect the signals down */ | 105 | /* connect the signals down */ |
101 | connect(textKey, SIGNAL(textChanged(const QString&)), | 106 | connect(textKey, SIGNAL(textChanged(const QString&)), |
102 | this, SIGNAL(valueChanged())); | 107 | this, SIGNAL(valueChanged())); |
103 | connect(intKey, SIGNAL(valueChanged(int)), | 108 | connect(intKey, SIGNAL(valueChanged(int)), |
104 | this, SIGNAL(valueChanged())); | 109 | this, SIGNAL(valueChanged())); |
105 | connect(dateKey, SIGNAL(valueChanged(const QDate&)), | 110 | connect(dateKey, SIGNAL(valueChanged(const QDate&)), |
106 | this, SIGNAL(valueChanged())); | 111 | this, SIGNAL(valueChanged())); |
107 | connect(timeKey, SIGNAL(valueChanged(const QTime&)), | 112 | connect(timeKey, SIGNAL(valueChanged(const QTime&)), |
108 | this, SIGNAL(valueChanged())); | 113 | this, SIGNAL(valueChanged())); |
109 | 114 | ||
110 | connect(intCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); | 115 | connect(intCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); |
111 | connect(textCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); | 116 | connect(textCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); |
112 | connect(timeCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); | 117 | connect(timeCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); |
113 | connect(dateCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); | 118 | connect(dateCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged())); |
114 | 119 | ||
115 | ws->raiseWidget(TVVariant::String); | 120 | ws->raiseWidget(TVVariant::String); |
116 | layout->addWidget(ws); | 121 | layout->addWidget(ws); |
117 | 122 | ||
118 | current_type = TVVariant::String; | 123 | current_type = TVVariant::String; |
119 | } | 124 | } |
120 | 125 | ||
121 | /*! | 126 | /*! |
122 | Destructs the widget | 127 | Destructs the widget |
123 | */ | 128 | */ |
124 | TVFilterKeyEntry::~TVFilterKeyEntry() | 129 | TVFilterKeyEntry::~TVFilterKeyEntry() |
125 | { | 130 | { |
126 | } | 131 | } |
127 | 132 | ||
128 | void TVFilterKeyEntry::setKey(int i) | 133 | void TVFilterKeyEntry::setKey(int i) |
129 | { | 134 | { |
130 | 135 | ||
131 | if (!ts) return; | 136 | if (!ts) return; |
132 | if (!ts->kRep) return; | 137 | if (!ts->kRep) return; |
133 | 138 | ||
134 | /* set up to raise appropriate widget set */ | 139 | /* set up to raise appropriate widget set */ |
135 | if (current_type != ts->kRep->getKeyType(i)) { | 140 | if (current_type != ts->kRep->getKeyType(i)) { |
136 | current_type = ts->kRep->getKeyType(i); | 141 | current_type = ts->kRep->getKeyType(i); |
@@ -178,31 +183,30 @@ CmpType TVFilterKeyEntry::getCompareType() | |||
178 | 183 | ||
179 | /* MUST return a valid pointer */ | 184 | /* MUST return a valid pointer */ |
180 | TVVariant TVFilterKeyEntry::getCompareValue() | 185 | TVVariant TVFilterKeyEntry::getCompareValue() |
181 | { | 186 | { |
182 | TVVariant sendkey; | 187 | TVVariant sendkey; |
183 | int tmp; | 188 | int tmp; |
184 | 189 | ||
185 | switch(current_type) { | 190 | switch(current_type) { |
186 | case TVVariant::String: | 191 | case TVVariant::String: |
187 | sendkey = TVVariant(QString(textKey->text())); | 192 | sendkey = TVVariant(QString(textKey->text())); |
188 | break; | 193 | break; |
189 | case TVVariant::Int: { | 194 | case TVVariant::Int: { |
190 | sendkey = TVVariant(intKey->value()); | 195 | sendkey = TVVariant(intKey->value()); |
191 | break; | 196 | break; |
192 | } | 197 | } |
193 | case TVVariant::Time: { | 198 | case TVVariant::Time: { |
194 | sendkey = TVVariant(QTime(timeKey->time())); | 199 | sendkey = TVVariant(QTime(timeKey->time())); |
195 | break; | 200 | break; |
196 | } | 201 | } |
197 | case TVVariant::Date: { | 202 | case TVVariant::Date: { |
198 | sendkey = TVVariant(QDate(dateKey->date())); | 203 | sendkey = TVVariant(QDate(dateKey->date())); |
199 | break; | 204 | break; |
200 | } | 205 | } |
201 | default: { | 206 | default: { |
202 | sendkey = TVVariant(0); | 207 | sendkey = TVVariant(0); |
203 | qWarning("TVFilterKeyEntry::getCompareValue() " | 208 | owarn << "TVFilterKeyEntry::getCompareValue() cannot work out data type" << oendl; |
204 | "cannot work out data type"); | ||
205 | } | 209 | } |
206 | } | 210 | } |
207 | return sendkey; | 211 | return sendkey; |
208 | } | 212 | } |
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index 22f1fb7..198c8b5 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp | |||
@@ -13,31 +13,37 @@ | |||
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 "tvfilterview.h" | 20 | #include "tvfilterview.h" |
21 | |||
22 | /* OPIE */ | ||
23 | #include <opie2/odebug.h> | ||
24 | #include <qpe/qpeapplication.h> | ||
25 | using namespace Opie::Core; | ||
26 | |||
27 | /* QT */ | ||
21 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
22 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
23 | #include <qlistview.h> | 30 | #include <qlistview.h> |
24 | #include <qlayout.h> | 31 | #include <qlayout.h> |
25 | #include <qheader.h> | 32 | #include <qheader.h> |
26 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
27 | #include <qlabel.h> | 34 | #include <qlabel.h> |
28 | 35 | ||
29 | #include <qpe/qpeapplication.h> | ||
30 | 36 | ||
31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, | 37 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, |
32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) | 38 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) |
33 | { | 39 | { |
34 | if ( !name ) | 40 | if ( !name ) |
35 | setName( "Filter View" ); | 41 | setName( "Filter View" ); |
36 | 42 | ||
37 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 43 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
38 | 44 | ||
39 | display = new QListView(this, "display"); | 45 | display = new QListView(this, "display"); |
40 | display->addColumn("Key"); | 46 | display->addColumn("Key"); |
41 | display->addColumn("Constraint"); | 47 | display->addColumn("Constraint"); |
42 | display->addColumn("Value"); | 48 | display->addColumn("Value"); |
43 | display->header()->setClickEnabled(FALSE); | 49 | display->header()->setClickEnabled(FALSE); |
@@ -83,75 +89,75 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent, | |||
83 | 89 | ||
84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); | 90 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); |
85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); | 91 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); |
86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); | 92 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); |
87 | 93 | ||
88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); | 94 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); |
89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); | 95 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); |
90 | 96 | ||
91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, | 97 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, |
92 | SLOT(setTerm(QListViewItem*))); | 98 | SLOT(setTerm(QListViewItem*))); |
93 | 99 | ||
94 | ts = t; | 100 | ts = t; |
95 | current = 0; | 101 | current = 0; |
96 | terms.setAutoDelete(true); | 102 | terms.setAutoDelete(true); |
97 | do_filter = false; | 103 | do_filter = false; |
98 | 104 | ||
99 | #ifdef Q_WS_QWS | 105 | #ifdef Q_WS_QWS |
100 | QPEApplication::showDialog( this ); | 106 | QPEApplication::showDialog( this ); |
101 | #endif | 107 | #endif |
102 | } | 108 | } |
103 | 109 | ||
104 | /*! | 110 | /*! |
105 | Destroys the TVFilterView widget | 111 | Destroys the TVFilterView widget |
106 | */ | 112 | */ |
107 | TVFilterView::~TVFilterView() | 113 | TVFilterView::~TVFilterView() |
108 | { | 114 | { |
109 | } | 115 | } |
110 | 116 | ||
111 | void TVFilterView::rebuildData() | 117 | void TVFilterView::rebuildData() |
112 | { | 118 | { |
113 | } | 119 | } |
114 | 120 | ||
115 | void TVFilterView::reset() | 121 | void TVFilterView::reset() |
116 | { | 122 | { |
117 | keyNameCombo->clear(); | 123 | keyNameCombo->clear(); |
118 | keyIds.clear(); | 124 | keyIds.clear(); |
119 | } | 125 | } |
120 | 126 | ||
121 | void TVFilterView::rebuildKeys() | 127 | void TVFilterView::rebuildKeys() |
122 | { | 128 | { |
123 | int i; | 129 | int i; |
124 | 130 | ||
125 | if (!ts) return; | 131 | if (!ts) return; |
126 | if(!ts->kRep) return; | 132 | if(!ts->kRep) return; |
127 | keyEntry->setTableState(ts); | 133 | keyEntry->setTableState(ts); |
128 | 134 | ||
129 | /* set up the list of keys that can be compared on */ | 135 | /* set up the list of keys that can be compared on */ |
130 | keyNameCombo->clear(); | 136 | keyNameCombo->clear(); |
131 | KeyListIterator it(*ts->kRep); | 137 | KeyListIterator it(*ts->kRep); |
132 | 138 | ||
133 | i = 0; | 139 | i = 0; |
134 | while(it.current()) { | 140 | while(it.current()) { |
135 | if(ts->kRep->validIndex(it.currentKey())) { | 141 | if(ts->kRep->validIndex(it.currentKey())) { |
136 | keyNameCombo->insertItem(it.current()->name()); | 142 | keyNameCombo->insertItem(it.current()->name()); |
137 | keyIds.insert(i, it.currentKey()); | 143 | keyIds.insert(i, it.currentKey()); |
138 | ++i; | 144 | ++i; |
139 | } | 145 | } |
140 | ++it; | 146 | ++it; |
141 | } | 147 | } |
142 | } | 148 | } |
143 | 149 | ||
144 | bool TVFilterView::passesFilter(DataElem *d) { | 150 | bool TVFilterView::passesFilter(DataElem *d) { |
145 | if (!filterActive()) return true; | 151 | if (!filterActive()) return true; |
146 | 152 | ||
147 | 153 | ||
148 | FilterTerm *t; | 154 | FilterTerm *t; |
149 | 155 | ||
150 | for (t = terms.first(); t != 0; t = terms.next() ) { | 156 | for (t = terms.first(); t != 0; t = terms.next() ) { |
151 | /* check against filter */ | 157 | /* check against filter */ |
152 | switch(t->ct) { | 158 | switch(t->ct) { |
153 | case ct_less: | 159 | case ct_less: |
154 | if (!d->lessThan(t->keyIndex, t->value)) | 160 | if (!d->lessThan(t->keyIndex, t->value)) |
155 | return false; | 161 | return false; |
156 | break; | 162 | break; |
157 | case ct_more: | 163 | case ct_more: |
@@ -170,18 +176,17 @@ bool TVFilterView::passesFilter(DataElem *d) { | |||
170 | if (!d->startsWith(t->keyIndex, t->value)) | 176 | if (!d->startsWith(t->keyIndex, t->value)) |
171 | return false; | 177 | return false; |
172 | break; | 178 | break; |
173 | case ct_endswith: | 179 | case ct_endswith: |
174 | if (!d->endsWith(t->keyIndex, t->value)) | 180 | if (!d->endsWith(t->keyIndex, t->value)) |
175 | return false; | 181 | return false; |
176 | break; | 182 | break; |
177 | default: | 183 | default: |
178 | qWarning("TVFilterView::passesFilter() " | 184 | owarn << "TVFilterView::passesFilter() unrecognized filter type" << oendl; |
179 | "unrecognized filter type"); | ||
180 | return false; | 185 | return false; |
181 | } | 186 | } |
182 | } | 187 | } |
183 | return true; | 188 | return true; |
184 | } | 189 | } |
185 | 190 | ||
186 | bool TVFilterView::filterActive() const | 191 | bool TVFilterView::filterActive() const |
187 | { | 192 | { |
@@ -189,17 +194,17 @@ bool TVFilterView::filterActive() const | |||
189 | return do_filter; | 194 | return do_filter; |
190 | */ | 195 | */ |
191 | if (terms.isEmpty()) | 196 | if (terms.isEmpty()) |
192 | return false; | 197 | return false; |
193 | return true; | 198 | return true; |
194 | } | 199 | } |
195 | 200 | ||
196 | /* SLOTS */ | 201 | /* SLOTS */ |
197 | void TVFilterView::newTerm() | 202 | void TVFilterView::newTerm() |
198 | { | 203 | { |
199 | if (!ts) return; | 204 | if (!ts) return; |
200 | 205 | ||
201 | FilterTerm *term = new FilterTerm; | 206 | FilterTerm *term = new FilterTerm; |
202 | current = term; | 207 | current = term; |
203 | 208 | ||
204 | term->view = 0; | 209 | term->view = 0; |
205 | 210 | ||
@@ -207,17 +212,17 @@ void TVFilterView::newTerm() | |||
207 | 212 | ||
208 | display->setSelected(term->view, true); | 213 | display->setSelected(term->view, true); |
209 | terms.append(term); | 214 | terms.append(term); |
210 | 215 | ||
211 | keyEntry->setEnabled(true); | 216 | keyEntry->setEnabled(true); |
212 | keyNameCombo->setEnabled(true); | 217 | keyNameCombo->setEnabled(true); |
213 | } | 218 | } |
214 | 219 | ||
215 | void TVFilterView::updateTerm() | 220 | void TVFilterView::updateTerm() |
216 | { | 221 | { |
217 | FilterTerm *term; | 222 | FilterTerm *term; |
218 | /* Read the widget values (keyname, compare type, value) | 223 | /* Read the widget values (keyname, compare type, value) |
219 | * and build the lists */ | 224 | * and build the lists */ |
220 | if (!ts) return; | 225 | if (!ts) return; |
221 | if (!current) return; | 226 | if (!current) return; |
222 | 227 | ||
223 | QString keyString; | 228 | QString keyString; |
@@ -226,17 +231,17 @@ void TVFilterView::updateTerm() | |||
226 | 231 | ||
227 | term = current; | 232 | term = current; |
228 | 233 | ||
229 | /* create new list item, set initial values, enable widgets */ | 234 | /* create new list item, set initial values, enable widgets */ |
230 | term->keyIndex = keyIds[keyNameCombo->currentItem()]; | 235 | term->keyIndex = keyIds[keyNameCombo->currentItem()]; |
231 | keyEntry->setKey(term->keyIndex); /* so the next two items make sense */ | 236 | keyEntry->setKey(term->keyIndex); /* so the next two items make sense */ |
232 | term->ct = keyEntry->getCompareType(), | 237 | term->ct = keyEntry->getCompareType(), |
233 | term->value = keyEntry->getCompareValue(); | 238 | term->value = keyEntry->getCompareValue(); |
234 | 239 | ||
235 | keyString = keyNameCombo->currentText(); | 240 | keyString = keyNameCombo->currentText(); |
236 | 241 | ||
237 | switch(term->ct) { | 242 | switch(term->ct) { |
238 | case ct_less: | 243 | case ct_less: |
239 | cmpString = " less than "; | 244 | cmpString = " less than "; |
240 | break; | 245 | break; |
241 | case ct_more: | 246 | case ct_more: |
242 | cmpString = " more than "; | 247 | cmpString = " more than "; |
@@ -255,52 +260,52 @@ void TVFilterView::updateTerm() | |||
255 | break; | 260 | break; |
256 | default: | 261 | default: |
257 | cmpString = " ERROR "; | 262 | cmpString = " ERROR "; |
258 | } | 263 | } |
259 | 264 | ||
260 | vString = term->value.toString(); | 265 | vString = term->value.toString(); |
261 | 266 | ||
262 | /* remove old view */ | 267 | /* remove old view */ |
263 | if (term->view) | 268 | if (term->view) |
264 | delete(term->view); | 269 | delete(term->view); |
265 | term->view = new QListViewItem(display, 0, keyString, cmpString, vString); | 270 | term->view = new QListViewItem(display, 0, keyString, cmpString, vString); |
266 | display->setSelected(term->view, true); | 271 | display->setSelected(term->view, true); |
267 | } | 272 | } |
268 | 273 | ||
269 | /* deletes current term */ | 274 | /* deletes current term */ |
270 | void TVFilterView::deleteTerm() | 275 | void TVFilterView::deleteTerm() |
271 | { | 276 | { |
272 | if(!current) return; | 277 | if(!current) return; |
273 | if (current->view) | 278 | if (current->view) |
274 | delete(current->view); | 279 | delete(current->view); |
275 | 280 | ||
276 | terms.removeRef(current); | 281 | terms.removeRef(current); |
277 | 282 | ||
278 | current = terms.first(); | 283 | current = terms.first(); |
279 | 284 | ||
280 | if(terms.isEmpty()) { | 285 | if(terms.isEmpty()) { |
281 | keyEntry->setEnabled(false); | 286 | keyEntry->setEnabled(false); |
282 | keyNameCombo->setEnabled(false); | 287 | keyNameCombo->setEnabled(false); |
283 | } | 288 | } |
284 | } | 289 | } |
285 | 290 | ||
286 | /* clears all terminations */ | 291 | /* clears all terminations */ |
287 | void TVFilterView::clearTerms() | 292 | void TVFilterView::clearTerms() |
288 | { | 293 | { |
289 | while(current) | 294 | while(current) |
290 | deleteTerm(); | 295 | deleteTerm(); |
291 | } | 296 | } |
292 | 297 | ||
293 | void TVFilterView::setTerm(QListViewItem *target) | 298 | void TVFilterView::setTerm(QListViewItem *target) |
294 | { | 299 | { |
295 | /* Iterate through the list to find item with view=target.. | 300 | /* Iterate through the list to find item with view=target.. |
296 | * set as current, delete */ | 301 | * set as current, delete */ |
297 | FilterTerm *term = current; | 302 | FilterTerm *term = current; |
298 | 303 | ||
299 | for (current = terms.first(); current != 0; current = terms.next() ) | 304 | for (current = terms.first(); current != 0; current = terms.next() ) |
300 | if (current->view == target) | 305 | if (current->view == target) |
301 | break; | 306 | break; |
302 | 307 | ||
303 | if (!current) { | 308 | if (!current) { |
304 | current = term; | 309 | current = term; |
305 | } | 310 | } |
306 | } | 311 | } |