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 | |||
@@ -13,39 +13,41 @@ | |||
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); |
@@ -77,43 +79,43 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f) | |||
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 | /*! |
@@ -133,23 +135,23 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param) | |||
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 | */ |
@@ -162,21 +164,21 @@ void TVBrowseKeyEntry::setTableState(TableState *t) { | |||
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 | ||
@@ -225,18 +227,17 @@ void TVBrowseKeyEntry::searchOnText() | |||
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 | */ |