Diffstat (limited to 'noncore/apps/tableviewer/ui/tvfilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/ui/tvfilterview.cpp | 55 |
1 files changed, 30 insertions, 25 deletions
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 | |||
@@ -18,6 +18,13 @@ | |||
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> |
@@ -26,13 +33,12 @@ | |||
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 | ||
@@ -88,8 +94,8 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent, | |||
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; |
@@ -102,7 +108,7 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent, | |||
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 | { |
@@ -118,26 +124,26 @@ void TVFilterView::reset() | |||
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 | ||
@@ -146,7 +152,7 @@ bool TVFilterView::passesFilter(DataElem *d) { | |||
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) { |
@@ -175,8 +181,7 @@ bool TVFilterView::passesFilter(DataElem *d) { | |||
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 | } |
@@ -194,7 +199,7 @@ bool TVFilterView::filterActive() const | |||
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 | ||
@@ -212,7 +217,7 @@ void TVFilterView::newTerm() | |||
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) |
@@ -231,7 +236,7 @@ void TVFilterView::updateTerm() | |||
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) { |
@@ -260,14 +265,14 @@ void TVFilterView::updateTerm() | |||
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) |
@@ -284,7 +289,7 @@ void TVFilterView::deleteTerm() | |||
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(); |
@@ -292,7 +297,7 @@ void TVFilterView::clearTerms() | |||
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 | ||
@@ -301,6 +306,6 @@ void TVFilterView::setTerm(QListViewItem *target) | |||
301 | break; | 306 | break; |
302 | 307 | ||
303 | if (!current) { | 308 | if (!current) { |
304 | current = term; | 309 | current = term; |
305 | } | 310 | } |
306 | } | 311 | } |