Diffstat (limited to 'noncore/apps/tableviewer/browsekeyentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/browsekeyentry.cpp | 53 |
1 files changed, 27 insertions, 26 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 | |||
@@ -7,51 +7,53 @@ | |||
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "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); |
54 | 56 | ||
55 | dateKey = new QHBox(this, 0); | 57 | dateKey = new QHBox(this, 0); |
56 | dayKey = new QLineEdit(dateKey, 0); | 58 | dayKey = new QLineEdit(dateKey, 0); |
57 | monthKey = new QLineEdit(dateKey, 0); | 59 | monthKey = new QLineEdit(dateKey, 0); |
@@ -71,55 +73,55 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | |||
71 | changeKeyButton->setText(tr("key")); | 73 | changeKeyButton->setText(tr("key")); |
72 | 74 | ||
73 | totalKeys = 0; | 75 | totalKeys = 0; |
74 | ts = 0; | 76 | ts = 0; |
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 | ||
122 | \param id_param the index of the key future searches should be base on | 124 | \param id_param the index of the key future searches should be base on |
123 | */ | 125 | */ |
124 | void TVBrowseKeyEntry::changeKeySlot(int id_param) | 126 | void TVBrowseKeyEntry::changeKeySlot(int id_param) |
125 | { | 127 | { |
@@ -127,62 +129,62 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param) | |||
127 | switch(ts->kRep->getKeyType(ts->current_column)) { | 129 | switch(ts->kRep->getKeyType(ts->current_column)) { |
128 | /* work out what to raise */ | 130 | /* work out what to raise */ |
129 | case kt_string: | 131 | case kt_string: |
130 | case kt_int: | 132 | case kt_int: |
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 | ; |
158 | } | 160 | } |
159 | 161 | ||
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 */ |
185 | case kt_string: | 187 | case kt_string: |
186 | sendkey = (void *)new QString(textKey->text()); | 188 | sendkey = (void *)new QString(textKey->text()); |
187 | break; | 189 | break; |
188 | case kt_int: { | 190 | case kt_int: { |
@@ -219,24 +221,23 @@ void TVBrowseKeyEntry::searchOnText() | |||
219 | m = monthKey->text().toInt(&ok); | 221 | m = monthKey->text().toInt(&ok); |
220 | if (!ok) | 222 | if (!ok) |
221 | return; | 223 | return; |
222 | y = yearKey->text().toInt(&ok); | 224 | y = yearKey->text().toInt(&ok); |
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 | */ |