-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/commonwidgets.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvbrowseview.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvfilterview.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvlistview.cpp | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index f35dfcd..4c6d809 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp | |||
@@ -62,200 +62,200 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
62 | 62 | ||
63 | dirty = FALSE; | 63 | dirty = FALSE; |
64 | ts.current_column = 0; | 64 | ts.current_column = 0; |
65 | ts.kRep = ds->getKeys(); | 65 | ts.kRep = ds->getKeys(); |
66 | 66 | ||
67 | /* build menus */ | 67 | /* build menus */ |
68 | menu = new QMenuBar(this, 0); | 68 | menu = new QMenuBar(this, 0); |
69 | 69 | ||
70 | QPopupMenu *file_menu = new QPopupMenu; | 70 | QPopupMenu *file_menu = new QPopupMenu; |
71 | file_menu->insertItem("New", this, SLOT(newDocument())); | 71 | file_menu->insertItem("New", this, SLOT(newDocument())); |
72 | 72 | ||
73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); | 73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); |
74 | file_menu->insertSeparator(); | 74 | file_menu->insertSeparator(); |
75 | file_menu->insertItem("Properties"); | 75 | file_menu->insertItem("Properties"); |
76 | 76 | ||
77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ | 77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ |
78 | menu->insertItem("Document", file_menu); | 78 | menu->insertItem("Document", file_menu); |
79 | 79 | ||
80 | QPopupMenu *edit_menu = new QPopupMenu; | 80 | QPopupMenu *edit_menu = new QPopupMenu; |
81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); | 81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); |
82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); | 82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); |
83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); | 83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); |
84 | menu->insertItem("Edit", edit_menu); | 84 | menu->insertItem("Edit", edit_menu); |
85 | 85 | ||
86 | QPopupMenu *view_menu = new QPopupMenu; | 86 | QPopupMenu *view_menu = new QPopupMenu; |
87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); | 87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); |
88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); | 88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); |
89 | menu->insertItem("View", view_menu); | 89 | menu->insertItem("View", view_menu); |
90 | 90 | ||
91 | QVBoxLayout *main_layout = new QVBoxLayout; | 91 | QVBoxLayout *main_layout = new QVBoxLayout; |
92 | 92 | ||
93 | /* Build tool bar */ | 93 | /* Build tool bar */ |
94 | navigation = new QToolBar(this, "navigation"); | 94 | navigation = new QToolBar(this, "navigation"); |
95 | QToolButton *newItemButton = new QToolButton( | 95 | QToolButton *newItemButton = new QToolButton( |
96 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, | 96 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, |
97 | this, SLOT(newItemSlot()), navigation, "New Item"); | 97 | this, SLOT(newItemSlot()), navigation, "New Item"); |
98 | QToolButton *editItemButton = new QToolButton( | 98 | QToolButton *editItemButton = new QToolButton( |
99 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, | 99 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, |
100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); | 100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); |
101 | QToolButton *deleteItemButton = new QToolButton( | 101 | QToolButton *deleteItemButton = new QToolButton( |
102 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", | 102 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", |
103 | QString::null, this, | 103 | QString::null, this, |
104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); | 104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); |
105 | 105 | ||
106 | navigation->addSeparator(); | 106 | navigation->addSeparator(); |
107 | 107 | ||
108 | QToolButton *firstItemButton = new QToolButton( | 108 | QToolButton *firstItemButton = new QToolButton( |
109 | QIconSet(Resource::loadPixmap("fastback")), "First Item", | 109 | QIconSet(Resource::loadPixmap("fastback")), "First Item", |
110 | QString::null, this, | 110 | QString::null, this, |
111 | SLOT(firstItem()), navigation, "First Item"); | 111 | SLOT(firstItem()), navigation, "First Item"); |
112 | QToolButton *previousItemButton = new QToolButton( | 112 | QToolButton *previousItemButton = new QToolButton( |
113 | QIconSet(Resource::loadPixmap("back")), "Previous Item", | 113 | QIconSet(Resource::loadPixmap("back")), "Previous Item", |
114 | QString::null, this, | 114 | QString::null, this, |
115 | SLOT(previousItem()), navigation, "Previous Item"); | 115 | SLOT(previousItem()), navigation, "Previous Item"); |
116 | QToolButton *nextItemButton = new QToolButton( | 116 | QToolButton *nextItemButton = new QToolButton( |
117 | QIconSet(Resource::loadPixmap("forward")), "Next Item", | 117 | QIconSet(Resource::loadPixmap("forward")), "Next Item", |
118 | QString::null, this, | 118 | QString::null, this, |
119 | SLOT(nextItem()), navigation, "Next Item"); | 119 | SLOT(nextItem()), navigation, "Next Item"); |
120 | QToolButton *lastItemButton = new QToolButton( | 120 | QToolButton *lastItemButton = new QToolButton( |
121 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", | 121 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", |
122 | QString::null, this, | 122 | QString::null, this, |
123 | SLOT(lastItem()), navigation, "Last Item"); | 123 | SLOT(lastItem()), navigation, "Last Item"); |
124 | 124 | ||
125 | navigation->addSeparator(); | 125 | navigation->addSeparator(); |
126 | QToolButton *browseButton = new QToolButton( | 126 | QToolButton *browseButton = new QToolButton( |
127 | QIconSet(Resource::loadPixmap("day")), "View Single Item", | 127 | QIconSet(Resource::loadPixmap("day")), "View Single Item", |
128 | QString::null, this, | 128 | QString::null, this, |
129 | SLOT(browseViewSlot()), navigation, "View Single Item"); | 129 | SLOT(browseViewSlot()), navigation, "View Single Item"); |
130 | QToolButton *listButton = new QToolButton( | 130 | QToolButton *listButton = new QToolButton( |
131 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", | 131 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", |
132 | QString::null, this, | 132 | QString::null, this, |
133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); | 133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); |
134 | 134 | ||
135 | setToolBarsMovable(FALSE); | 135 | setToolBarsMovable(FALSE); |
136 | setToolBarsMovable(FALSE); | 136 | setToolBarsMovable(FALSE); |
137 | setToolBarsMovable(FALSE); | 137 | setToolBarsMovable(FALSE); |
138 | 138 | ||
139 | /* Build widgets */ | 139 | /* Build widgets */ |
140 | browseView = new TVBrowseView(&ts, this, 0); | 140 | browseView = new TVBrowseView(&ts, this, 0); |
141 | listView = new TVListView(&ts, this, 0); | 141 | listView = new TVListView(&ts, this, 0); |
142 | filterView = new TVFilterView(&ts, this, 0); | 142 | filterView = new TVFilterView(&ts, this, 0); |
143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", | 143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", |
144 | this, "fileselector"); | 144 | this, "fileselector"); |
145 | fileSelector->setNewVisible(FALSE); | 145 | fileSelector->setNewVisible(FALSE); |
146 | fileSelector->setCloseVisible(FALSE); | 146 | fileSelector->setCloseVisible(FALSE); |
147 | 147 | ||
148 | cw = new QWidgetStack(this, 0); | 148 | cw = new QWidgetStack(this, 0); |
149 | cw->addWidget(listView, ListState); | 149 | cw->addWidget(listView, ListState); |
150 | cw->addWidget(browseView, BrowseState); | 150 | cw->addWidget(browseView, BrowseState); |
151 | cw->addWidget(filterView, FilterState); | 151 | cw->addWidget(filterView, FilterState); |
152 | cw->addWidget(fileSelector, FileState); | 152 | cw->addWidget(fileSelector, FileState); |
153 | 153 | ||
154 | current_view = FileState; | 154 | current_view = FileState; |
155 | cw->raiseWidget(current_view); | 155 | cw->raiseWidget(current_view); |
156 | fileSelector->reread(); | 156 | fileSelector->reread(); |
157 | 157 | ||
158 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), | 158 | connect(browseView, SIGNAL(searchOnKey(int,TVVariant)), |
159 | this, SLOT(searchOnKey(int, TVVariant))); | 159 | this, SLOT(searchOnKey(int,TVVariant))); |
160 | connect(browseView, SIGNAL(sortChanged(int)), | 160 | connect(browseView, SIGNAL(sortChanged(int)), |
161 | this, SLOT(setPrimaryKey(int))); | 161 | this, SLOT(setPrimaryKey(int))); |
162 | 162 | ||
163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); | 163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); |
164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), |
165 | this, SLOT(openDocument(const DocLnk &))); | 165 | this, SLOT(openDocument(const DocLnk&))); |
166 | 166 | ||
167 | main_layout->addWidget(menu); | 167 | main_layout->addWidget(menu); |
168 | main_layout->addWidget(cw); | 168 | main_layout->addWidget(cw); |
169 | 169 | ||
170 | setCentralWidget(cw); | 170 | setCentralWidget(cw); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | /*! | 174 | /*! |
175 | Destroys the TableViewerWindow | 175 | Destroys the TableViewerWindow |
176 | */ | 176 | */ |
177 | TableViewerWindow::~TableViewerWindow() | 177 | TableViewerWindow::~TableViewerWindow() |
178 | { | 178 | { |
179 | if(dirty) | 179 | if(dirty) |
180 | saveDocument(); | 180 | saveDocument(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /*! | 183 | /*! |
184 | Opens a file dialog and loads the file specified by the dialog | 184 | Opens a file dialog and loads the file specified by the dialog |
185 | */ | 185 | */ |
186 | void TableViewerWindow::selectDocument() | 186 | void TableViewerWindow::selectDocument() |
187 | { | 187 | { |
188 | if(dirty) | 188 | if(dirty) |
189 | saveDocument(); | 189 | saveDocument(); |
190 | current_view = FileState; | 190 | current_view = FileState; |
191 | cw->raiseWidget(current_view); | 191 | cw->raiseWidget(current_view); |
192 | fileSelector->reread(); | 192 | fileSelector->reread(); |
193 | } | 193 | } |
194 | 194 | ||
195 | void TableViewerWindow::saveDocument() | 195 | void TableViewerWindow::saveDocument() |
196 | { | 196 | { |
197 | if(!dirty) | 197 | if(!dirty) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | FileManager fm; | 200 | FileManager fm; |
201 | QIODevice *dev = fm.saveFile(doc); | 201 | QIODevice *dev = fm.saveFile(doc); |
202 | 202 | ||
203 | if(!ds->saveSource(dev, doc.type())){ | 203 | if(!ds->saveSource(dev, doc.type())){ |
204 | qWarning("Save unsuccessful"); | 204 | qWarning("Save unsuccessful"); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | dev->close(); | 207 | dev->close(); |
208 | dirty = FALSE; | 208 | dirty = FALSE; |
209 | } | 209 | } |
210 | 210 | ||
211 | void TableViewerWindow::newDocument() | 211 | void TableViewerWindow::newDocument() |
212 | { | 212 | { |
213 | DocLnk nf; | 213 | DocLnk nf; |
214 | nf.setType("text/x-xml-tableviewer"); | 214 | nf.setType("text/x-xml-tableviewer"); |
215 | nf.setName("table"); | 215 | nf.setName("table"); |
216 | 216 | ||
217 | delete ds; | 217 | delete ds; |
218 | ds = new DBStore(); | 218 | ds = new DBStore(); |
219 | 219 | ||
220 | ts.current_column = 0; | 220 | ts.current_column = 0; |
221 | ts.kRep = ds->getKeys(); | 221 | ts.kRep = ds->getKeys(); |
222 | browseView->reset(); | 222 | browseView->reset(); |
223 | listView->reset(); | 223 | listView->reset(); |
224 | filterView->reset(); | 224 | filterView->reset(); |
225 | 225 | ||
226 | doc = nf; | 226 | doc = nf; |
227 | dirty = FALSE; | 227 | dirty = FALSE; |
228 | 228 | ||
229 | current_view = BrowseState; | 229 | current_view = BrowseState; |
230 | cw->raiseWidget(current_view); | 230 | cw->raiseWidget(current_view); |
231 | 231 | ||
232 | /* now set up for editing the keys */ | 232 | /* now set up for editing the keys */ |
233 | ts.kRep->addKey("key", TVVariant::String); | 233 | ts.kRep->addKey("key", TVVariant::String); |
234 | editKeysSlot(); | 234 | editKeysSlot(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void TableViewerWindow::setDocument(const QString &f) | 237 | void TableViewerWindow::setDocument(const QString &f) |
238 | { | 238 | { |
239 | openDocument(DocLnk(f, TRUE)); | 239 | openDocument(DocLnk(f, TRUE)); |
240 | } | 240 | } |
241 | 241 | ||
242 | void TableViewerWindow::openDocument(const DocLnk &f) | 242 | void TableViewerWindow::openDocument(const DocLnk &f) |
243 | { | 243 | { |
244 | 244 | ||
245 | if (!f.isValid()) | 245 | if (!f.isValid()) |
246 | return; | 246 | return; |
247 | 247 | ||
248 | FileManager fm; | 248 | FileManager fm; |
249 | QIODevice *dev = fm.openFile(f); | 249 | QIODevice *dev = fm.openFile(f); |
250 | doc = f; | 250 | doc = f; |
251 | 251 | ||
252 | if(ds->openSource(dev, doc.type())) { | 252 | if(ds->openSource(dev, doc.type())) { |
253 | DataElem *d; | 253 | DataElem *d; |
254 | 254 | ||
255 | browseView->reset(); | 255 | browseView->reset(); |
256 | listView->reset(); | 256 | listView->reset(); |
257 | filterView->reset(); | 257 | filterView->reset(); |
258 | 258 | ||
259 | current_view = BrowseState; | 259 | current_view = BrowseState; |
260 | cw->raiseWidget(current_view); | 260 | cw->raiseWidget(current_view); |
261 | 261 | ||
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index 4c47951..e82018c 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | 25 | ||
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
29 | #include "commonwidgets.h" | 29 | #include "commonwidgets.h" |
30 | 30 | ||
31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) | 31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) |
32 | : QToolButton(parent, name) | 32 | : QToolButton(parent, name) |
33 | { | 33 | { |
34 | QPopupMenu *m1 = new QPopupMenu(this); | 34 | QPopupMenu *m1 = new QPopupMenu(this); |
35 | dateSelector = new DateBookMonth(m1, 0, TRUE); | 35 | dateSelector = new DateBookMonth(m1, 0, TRUE); |
36 | m1->insertItem(dateSelector); | 36 | m1->insertItem(dateSelector); |
37 | setPopup(m1); | 37 | setPopup(m1); |
38 | setPopupDelay(0); | 38 | setPopupDelay(0); |
39 | 39 | ||
40 | connect(dateSelector, SIGNAL(dateClicked(int, int, int)), | 40 | connect(dateSelector, SIGNAL(dateClicked(int,int,int)), |
41 | this, SLOT(subValueChanged())); | 41 | this, SLOT(subValueChanged())); |
42 | 42 | ||
43 | setText(dateSelector->selectedDate().toString()); | 43 | setText(dateSelector->selectedDate().toString()); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | DateEdit::~DateEdit() {} | 47 | DateEdit::~DateEdit() {} |
48 | 48 | ||
49 | QDate DateEdit::date() const | 49 | QDate DateEdit::date() const |
50 | { | 50 | { |
51 | return dateSelector->selectedDate(); | 51 | return dateSelector->selectedDate(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void DateEdit::setDate(QDate d) | 54 | void DateEdit::setDate(QDate d) |
55 | { | 55 | { |
56 | dateSelector->setDate(d.year(), d.month(), d.day()); | 56 | dateSelector->setDate(d.year(), d.month(), d.day()); |
57 | setText(d.toString()); | 57 | setText(d.toString()); |
58 | } | 58 | } |
59 | 59 | ||
60 | QSizePolicy DateEdit::sizePolicy() const | 60 | QSizePolicy DateEdit::sizePolicy() const |
61 | { | 61 | { |
62 | QSizePolicy sp; | 62 | QSizePolicy sp; |
63 | sp.setHorData(QToolButton::sizePolicy().horData()); | 63 | sp.setHorData(QToolButton::sizePolicy().horData()); |
64 | sp.setVerData(QSizePolicy::Fixed); | 64 | sp.setVerData(QSizePolicy::Fixed); |
65 | 65 | ||
66 | return sp; | 66 | return sp; |
67 | } | 67 | } |
68 | 68 | ||
69 | void DateEdit::clear() | 69 | void DateEdit::clear() |
70 | { | 70 | { |
71 | QDate today = QDate::currentDate(); | 71 | QDate today = QDate::currentDate(); |
72 | 72 | ||
73 | dateSelector->setDate(today.year(), today.month(), today.day()); | 73 | dateSelector->setDate(today.year(), today.month(), today.day()); |
74 | setText(today.toString()); | 74 | setText(today.toString()); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateEdit::subValueChanged() | 77 | void DateEdit::subValueChanged() |
78 | { | 78 | { |
79 | QDate current = dateSelector->selectedDate(); | 79 | QDate current = dateSelector->selectedDate(); |
80 | 80 | ||
81 | setText(current.toString()); | 81 | setText(current.toString()); |
82 | emit valueChanged(current); | 82 | emit valueChanged(current); |
83 | } | 83 | } |
84 | 84 | ||
85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) | 85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) |
86 | : QWidget(parent, name, f) | 86 | : QWidget(parent, name, f) |
87 | { | 87 | { |
88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); | 88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); |
89 | 89 | ||
90 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); | 90 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); |
91 | hourKey->setWrapping(true); | 91 | hourKey->setWrapping(true); |
92 | hourKey->setMinimumWidth(30); | 92 | hourKey->setMinimumWidth(30); |
93 | hourKey->setMaximumWidth(35); | 93 | hourKey->setMaximumWidth(35); |
94 | 94 | ||
95 | layout->addWidget(new QLabel(" : ", this)); | 95 | layout->addWidget(new QLabel(" : ", this)); |
96 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); | 96 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); |
97 | minuteKey->setWrapping(true); | 97 | minuteKey->setWrapping(true); |
98 | minuteKey->setMinimumWidth(30); | 98 | minuteKey->setMinimumWidth(30); |
99 | minuteKey->setMaximumWidth(35); | 99 | minuteKey->setMaximumWidth(35); |
100 | 100 | ||
101 | layout->addWidget(new QLabel(" : ", this)); | 101 | layout->addWidget(new QLabel(" : ", this)); |
102 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); | 102 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); |
103 | secondKey->setWrapping(true); | 103 | secondKey->setWrapping(true); |
104 | secondKey->setMinimumWidth(30); | 104 | secondKey->setMinimumWidth(30); |
105 | secondKey->setMaximumWidth(35); | 105 | secondKey->setMaximumWidth(35); |
106 | 106 | ||
107 | layout->addWidget(ampm = new QComboBox(this)); | 107 | layout->addWidget(ampm = new QComboBox(this)); |
108 | ampm->insertItem("AM"); | 108 | ampm->insertItem("AM"); |
109 | ampm->insertItem("PM"); | 109 | ampm->insertItem("PM"); |
110 | 110 | ||
111 | layout->addStretch(-1); | 111 | layout->addStretch(-1); |
112 | 112 | ||
113 | clear(); | 113 | clear(); |
114 | 114 | ||
115 | connect(secondKey, SIGNAL(valueChanged(const QString&)), | 115 | connect(secondKey, SIGNAL(valueChanged(const QString&)), |
116 | this, SLOT(subValueChanged())); | 116 | this, SLOT(subValueChanged())); |
117 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), | 117 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), |
118 | this, SLOT(subValueChanged())); | 118 | this, SLOT(subValueChanged())); |
119 | connect(hourKey, SIGNAL(valueChanged(const QString&)), | 119 | connect(hourKey, SIGNAL(valueChanged(const QString&)), |
120 | this, SLOT(subValueChanged())); | 120 | this, SLOT(subValueChanged())); |
121 | connect(ampm, SIGNAL(activated(int)), | 121 | connect(ampm, SIGNAL(activated(int)), |
122 | this, SLOT(subValueChanged())); | 122 | this, SLOT(subValueChanged())); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | TimeEdit::~TimeEdit() {} | 126 | TimeEdit::~TimeEdit() {} |
127 | 127 | ||
128 | QTime TimeEdit::time() const | 128 | QTime TimeEdit::time() const |
129 | { | 129 | { |
130 | int s,m,h; | 130 | int s,m,h; |
131 | 131 | ||
132 | s = secondKey->text().toInt(); | 132 | s = secondKey->text().toInt(); |
133 | m = minuteKey->text().toInt(); | 133 | m = minuteKey->text().toInt(); |
134 | h = hourKey->text().toInt(); | 134 | h = hourKey->text().toInt(); |
135 | 135 | ||
136 | if(ampm->currentItem() == 1) { | 136 | if(ampm->currentItem() == 1) { |
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index 22bac55..8a65ed1 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp | |||
@@ -1,123 +1,123 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvbrowseview.h" | 20 | #include "tvbrowseview.h" |
21 | #include "browsekeyentry.h" | 21 | #include "browsekeyentry.h" |
22 | #include <qtoolbutton.h> | 22 | #include <qtoolbutton.h> |
23 | #include <qtextview.h> | 23 | #include <qtextview.h> |
24 | #include <qtextbrowser.h> | 24 | #include <qtextbrowser.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include "../xmlencodeattr.h" | 26 | #include "../xmlencodeattr.h" |
27 | 27 | ||
28 | /*! | 28 | /*! |
29 | \class TVBrowseView | 29 | \class TVBrowseView |
30 | \brief The widget describing how to draw the browse view user interface | 30 | \brief The widget describing how to draw the browse view user interface |
31 | 31 | ||
32 | This widget allows for the user to browse through the table, one element | 32 | This widget allows for the user to browse through the table, one element |
33 | at a time, or search on a single key. Its main goal is to show a | 33 | at a time, or search on a single key. Its main goal is to show a |
34 | single element in a readable format and make it easy for the user to | 34 | single element in a readable format and make it easy for the user to |
35 | rapidly find specific elements in the table. | 35 | rapidly find specific elements in the table. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /*! | 38 | /*! |
39 | Constructs a new TVBrowseView widget | 39 | Constructs a new TVBrowseView widget |
40 | */ | 40 | */ |
41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, | 41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, |
42 | WFlags fl ) | 42 | WFlags fl ) |
43 | { | 43 | { |
44 | if (!name) | 44 | if (!name) |
45 | setName("BrowseView"); | 45 | setName("BrowseView"); |
46 | 46 | ||
47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); | 47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); |
48 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 48 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); | 49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); |
50 | vlayout->addWidget( textViewDisplay ); | 50 | vlayout->addWidget( textViewDisplay ); |
51 | 51 | ||
52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); | 52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); |
53 | vlayout->addWidget( keyEntry ); | 53 | vlayout->addWidget( keyEntry ); |
54 | 54 | ||
55 | /* connect the signals down */ | 55 | /* connect the signals down */ |
56 | 56 | ||
57 | connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), | 57 | connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)), |
58 | this, SIGNAL(searchOnKey(int, TVVariant))); | 58 | this, SIGNAL(searchOnKey(int,TVVariant))); |
59 | connect(keyEntry, SIGNAL(sortChanged(int)), | 59 | connect(keyEntry, SIGNAL(sortChanged(int)), |
60 | this, SIGNAL(sortChanged(int))); | 60 | this, SIGNAL(sortChanged(int))); |
61 | 61 | ||
62 | ts = t; | 62 | ts = t; |
63 | keyEntry->setTableState(t); | 63 | keyEntry->setTableState(t); |
64 | } | 64 | } |
65 | 65 | ||
66 | /*! | 66 | /*! |
67 | Destroys the TVBrowseView widget | 67 | Destroys the TVBrowseView widget |
68 | */ | 68 | */ |
69 | TVBrowseView::~TVBrowseView() | 69 | TVBrowseView::~TVBrowseView() |
70 | { | 70 | { |
71 | } | 71 | } |
72 | 72 | ||
73 | void TVBrowseView::rebuildData() | 73 | void TVBrowseView::rebuildData() |
74 | { | 74 | { |
75 | if(!ts) | 75 | if(!ts) |
76 | return; | 76 | return; |
77 | if(!ts->current_elem) { | 77 | if(!ts->current_elem) { |
78 | /* also disable buttons */ | 78 | /* also disable buttons */ |
79 | textViewDisplay->setText(""); | 79 | textViewDisplay->setText(""); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | setDisplayText(ts->current_elem); | 83 | setDisplayText(ts->current_elem); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* Reset to initial state */ | 86 | /* Reset to initial state */ |
87 | void TVBrowseView::reset() | 87 | void TVBrowseView::reset() |
88 | { | 88 | { |
89 | textViewDisplay->setText(""); | 89 | textViewDisplay->setText(""); |
90 | keyEntry->reset(); | 90 | keyEntry->reset(); |
91 | } | 91 | } |
92 | 92 | ||
93 | /*! | 93 | /*! |
94 | sets the data element to be displayed to element | 94 | sets the data element to be displayed to element |
95 | */ | 95 | */ |
96 | void TVBrowseView::setDisplayText(const DataElem *element) | 96 | void TVBrowseView::setDisplayText(const DataElem *element) |
97 | { | 97 | { |
98 | QString rep = ""; | 98 | QString rep = ""; |
99 | 99 | ||
100 | KeyListIterator it(*ts->kRep); | 100 | KeyListIterator it(*ts->kRep); |
101 | 101 | ||
102 | while (it.current()) { | 102 | while (it.current()) { |
103 | if (element->hasValidValue(it.currentKey())) { | 103 | if (element->hasValidValue(it.currentKey())) { |
104 | if(it.currentKey() == ts->current_column) { | 104 | if(it.currentKey() == ts->current_column) { |
105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" | 105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" |
106 | + encodeAttr(it.current()->name()) | 106 | + encodeAttr(it.current()->name()) |
107 | + ":</FONT></B> "; | 107 | + ":</FONT></B> "; |
108 | } else { | 108 | } else { |
109 | rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> "; | 109 | rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> "; |
110 | } | 110 | } |
111 | rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>"; | 111 | rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>"; |
112 | } | 112 | } |
113 | ++it; | 113 | ++it; |
114 | } | 114 | } |
115 | 115 | ||
116 | textViewDisplay->setText(rep); | 116 | textViewDisplay->setText(rep); |
117 | textViewDisplay->scrollToAnchor("ckey"); | 117 | textViewDisplay->scrollToAnchor("ckey"); |
118 | } | 118 | } |
119 | 119 | ||
120 | void TVBrowseView::rebuildKeys() | 120 | void TVBrowseView::rebuildKeys() |
121 | { | 121 | { |
122 | keyEntry->rebuildKeys(); | 122 | keyEntry->rebuildKeys(); |
123 | } | 123 | } |
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index b03e846..22f1fb7 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp | |||
@@ -1,188 +1,188 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvfilterview.h" | 20 | #include "tvfilterview.h" |
21 | #include <qtoolbutton.h> | 21 | #include <qtoolbutton.h> |
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | 30 | ||
31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, | 31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, |
32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) | 32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) |
33 | { | 33 | { |
34 | if ( !name ) | 34 | if ( !name ) |
35 | setName( "Filter View" ); | 35 | setName( "Filter View" ); |
36 | 36 | ||
37 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 37 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
38 | 38 | ||
39 | display = new QListView(this, "display"); | 39 | display = new QListView(this, "display"); |
40 | display->addColumn("Key"); | 40 | display->addColumn("Key"); |
41 | display->addColumn("Constraint"); | 41 | display->addColumn("Constraint"); |
42 | display->addColumn("Value"); | 42 | display->addColumn("Value"); |
43 | display->header()->setClickEnabled(FALSE); | 43 | display->header()->setClickEnabled(FALSE); |
44 | display->header()->setResizeEnabled(FALSE); | 44 | display->header()->setResizeEnabled(FALSE); |
45 | 45 | ||
46 | vlayout->addWidget(display); | 46 | vlayout->addWidget(display); |
47 | 47 | ||
48 | QHBoxLayout *hlayout = new QHBoxLayout; | 48 | QHBoxLayout *hlayout = new QHBoxLayout; |
49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | 49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); |
50 | 50 | ||
51 | newFilterButton = new QPushButton(this, "new Filter"); | 51 | newFilterButton = new QPushButton(this, "new Filter"); |
52 | newFilterButton->setMaximumSize(QSize(50, 32767)); | 52 | newFilterButton->setMaximumSize(QSize(50, 32767)); |
53 | newFilterButton->setText("New"); | 53 | newFilterButton->setText("New"); |
54 | hlayout->addWidget(newFilterButton); | 54 | hlayout->addWidget(newFilterButton); |
55 | 55 | ||
56 | deleteFilterButton = new QPushButton(this, "delete Filter"); | 56 | deleteFilterButton = new QPushButton(this, "delete Filter"); |
57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); | 57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); |
58 | deleteFilterButton->setText("Delete"); | 58 | deleteFilterButton->setText("Delete"); |
59 | hlayout->addWidget(deleteFilterButton); | 59 | hlayout->addWidget(deleteFilterButton); |
60 | 60 | ||
61 | clearFilterButton = new QPushButton(this, "delete Filter"); | 61 | clearFilterButton = new QPushButton(this, "delete Filter"); |
62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); | 62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); |
63 | clearFilterButton->setText("Clear All"); | 63 | clearFilterButton->setText("Clear All"); |
64 | hlayout->addWidget(clearFilterButton); | 64 | hlayout->addWidget(clearFilterButton); |
65 | 65 | ||
66 | vlayout->addLayout(hlayout); | 66 | vlayout->addLayout(hlayout); |
67 | 67 | ||
68 | QHBoxLayout *hlayout2 = new QHBoxLayout; | 68 | QHBoxLayout *hlayout2 = new QHBoxLayout; |
69 | 69 | ||
70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); | 70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); |
71 | keyNameCombo->setEnabled(FALSE); | 71 | keyNameCombo->setEnabled(FALSE); |
72 | hlayout2->addWidget(keyNameCombo); | 72 | hlayout2->addWidget(keyNameCombo); |
73 | 73 | ||
74 | QLabel *label = new QLabel(this); | 74 | QLabel *label = new QLabel(this); |
75 | label->setText("has value"); | 75 | label->setText("has value"); |
76 | hlayout2->addWidget(label); | 76 | hlayout2->addWidget(label); |
77 | 77 | ||
78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); | 78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); |
79 | keyEntry->setEnabled(FALSE); | 79 | keyEntry->setEnabled(FALSE); |
80 | 80 | ||
81 | vlayout->addLayout(hlayout2); | 81 | vlayout->addLayout(hlayout2); |
82 | vlayout->addWidget(keyEntry); | 82 | vlayout->addWidget(keyEntry); |
83 | 83 | ||
84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); | 84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); |
85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); | 85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); |
86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); | 86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); |
87 | 87 | ||
88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); | 88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); |
89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); | 89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); |
90 | 90 | ||
91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, | 91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, |
92 | SLOT(setTerm(QListViewItem *))); | 92 | SLOT(setTerm(QListViewItem*))); |
93 | 93 | ||
94 | ts = t; | 94 | ts = t; |
95 | current = 0; | 95 | current = 0; |
96 | terms.setAutoDelete(true); | 96 | terms.setAutoDelete(true); |
97 | do_filter = false; | 97 | do_filter = false; |
98 | 98 | ||
99 | #ifdef Q_WS_QWS | 99 | #ifdef Q_WS_QWS |
100 | QPEApplication::showDialog( this ); | 100 | QPEApplication::showDialog( this ); |
101 | #endif | 101 | #endif |
102 | } | 102 | } |
103 | 103 | ||
104 | /*! | 104 | /*! |
105 | Destroys the TVFilterView widget | 105 | Destroys the TVFilterView widget |
106 | */ | 106 | */ |
107 | TVFilterView::~TVFilterView() | 107 | TVFilterView::~TVFilterView() |
108 | { | 108 | { |
109 | } | 109 | } |
110 | 110 | ||
111 | void TVFilterView::rebuildData() | 111 | void TVFilterView::rebuildData() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | void TVFilterView::reset() | 115 | void TVFilterView::reset() |
116 | { | 116 | { |
117 | keyNameCombo->clear(); | 117 | keyNameCombo->clear(); |
118 | keyIds.clear(); | 118 | keyIds.clear(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void TVFilterView::rebuildKeys() | 121 | void TVFilterView::rebuildKeys() |
122 | { | 122 | { |
123 | int i; | 123 | int i; |
124 | 124 | ||
125 | if (!ts) return; | 125 | if (!ts) return; |
126 | if(!ts->kRep) return; | 126 | if(!ts->kRep) return; |
127 | keyEntry->setTableState(ts); | 127 | keyEntry->setTableState(ts); |
128 | 128 | ||
129 | /* set up the list of keys that can be compared on */ | 129 | /* set up the list of keys that can be compared on */ |
130 | keyNameCombo->clear(); | 130 | keyNameCombo->clear(); |
131 | KeyListIterator it(*ts->kRep); | 131 | KeyListIterator it(*ts->kRep); |
132 | 132 | ||
133 | i = 0; | 133 | i = 0; |
134 | while(it.current()) { | 134 | while(it.current()) { |
135 | if(ts->kRep->validIndex(it.currentKey())) { | 135 | if(ts->kRep->validIndex(it.currentKey())) { |
136 | keyNameCombo->insertItem(it.current()->name()); | 136 | keyNameCombo->insertItem(it.current()->name()); |
137 | keyIds.insert(i, it.currentKey()); | 137 | keyIds.insert(i, it.currentKey()); |
138 | ++i; | 138 | ++i; |
139 | } | 139 | } |
140 | ++it; | 140 | ++it; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | bool TVFilterView::passesFilter(DataElem *d) { | 144 | bool TVFilterView::passesFilter(DataElem *d) { |
145 | if (!filterActive()) return true; | 145 | if (!filterActive()) return true; |
146 | 146 | ||
147 | 147 | ||
148 | FilterTerm *t; | 148 | FilterTerm *t; |
149 | 149 | ||
150 | for (t = terms.first(); t != 0; t = terms.next() ) { | 150 | for (t = terms.first(); t != 0; t = terms.next() ) { |
151 | /* check against filter */ | 151 | /* check against filter */ |
152 | switch(t->ct) { | 152 | switch(t->ct) { |
153 | case ct_less: | 153 | case ct_less: |
154 | if (!d->lessThan(t->keyIndex, t->value)) | 154 | if (!d->lessThan(t->keyIndex, t->value)) |
155 | return false; | 155 | return false; |
156 | break; | 156 | break; |
157 | case ct_more: | 157 | case ct_more: |
158 | if (!d->moreThan(t->keyIndex, t->value)) | 158 | if (!d->moreThan(t->keyIndex, t->value)) |
159 | return false; | 159 | return false; |
160 | break; | 160 | break; |
161 | case ct_equal: | 161 | case ct_equal: |
162 | if (!d->equalTo(t->keyIndex, t->value)) | 162 | if (!d->equalTo(t->keyIndex, t->value)) |
163 | return false; | 163 | return false; |
164 | break; | 164 | break; |
165 | case ct_contains: | 165 | case ct_contains: |
166 | if (!d->contains(t->keyIndex, t->value)) | 166 | if (!d->contains(t->keyIndex, t->value)) |
167 | return false; | 167 | return false; |
168 | break; | 168 | break; |
169 | case ct_startswith: | 169 | case ct_startswith: |
170 | if (!d->startsWith(t->keyIndex, t->value)) | 170 | if (!d->startsWith(t->keyIndex, t->value)) |
171 | return false; | 171 | return false; |
172 | break; | 172 | break; |
173 | case ct_endswith: | 173 | case ct_endswith: |
174 | if (!d->endsWith(t->keyIndex, t->value)) | 174 | if (!d->endsWith(t->keyIndex, t->value)) |
175 | return false; | 175 | return false; |
176 | break; | 176 | break; |
177 | default: | 177 | default: |
178 | qWarning("TVFilterView::passesFilter() " | 178 | qWarning("TVFilterView::passesFilter() " |
179 | "unrecognized filter type"); | 179 | "unrecognized filter type"); |
180 | return false; | 180 | return false; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | return true; | 183 | return true; |
184 | } | 184 | } |
185 | 185 | ||
186 | bool TVFilterView::filterActive() const | 186 | bool TVFilterView::filterActive() const |
187 | { | 187 | { |
188 | /* when button operated, also check the do_filter value | 188 | /* when button operated, also check the do_filter value |
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp index b25e813..b10ff1d 100644 --- a/noncore/apps/tableviewer/ui/tvlistview.cpp +++ b/noncore/apps/tableviewer/ui/tvlistview.cpp | |||
@@ -11,194 +11,194 @@ | |||
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 "tvlistview.h" | 20 | #include "tvlistview.h" |
21 | #include "../db/common.h" | 21 | #include "../db/common.h" |
22 | #include <qtoolbutton.h> | 22 | #include <qtoolbutton.h> |
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | void TVListViewPrivate::setColumnWidth(int column, int width) | 26 | void TVListViewPrivate::setColumnWidth(int column, int width) |
27 | { | 27 | { |
28 | if(width > 70) width = 70; | 28 | if(width > 70) width = 70; |
29 | QListView::setColumnWidth(column, width); | 29 | QListView::setColumnWidth(column, width); |
30 | } | 30 | } |
31 | 31 | ||
32 | void TVListViewPrivate::setSorting(int column, bool increasing) | 32 | void TVListViewPrivate::setSorting(int column, bool increasing) |
33 | { | 33 | { |
34 | emit sortChanged(column); | 34 | emit sortChanged(column); |
35 | QListView::setSorting(column, increasing); | 35 | QListView::setSorting(column, increasing); |
36 | } | 36 | } |
37 | 37 | ||
38 | TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name, | 38 | TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name, |
39 | WFlags fl) : QListView(parent, name, fl) { | 39 | WFlags fl) : QListView(parent, name, fl) { |
40 | ; | 40 | ; |
41 | } | 41 | } |
42 | 42 | ||
43 | class TVListViewItem : public QListViewItem | 43 | class TVListViewItem : public QListViewItem |
44 | { | 44 | { |
45 | public: | 45 | public: |
46 | 46 | ||
47 | TVListViewItem(QListView *parent, DataElem *d); | 47 | TVListViewItem(QListView *parent, DataElem *d); |
48 | ~TVListViewItem(); | 48 | ~TVListViewItem(); |
49 | 49 | ||
50 | QString text(int i) const | 50 | QString text(int i) const |
51 | { | 51 | { |
52 | return data_reference->toQString(i); | 52 | return data_reference->toQString(i); |
53 | } | 53 | } |
54 | 54 | ||
55 | /* Do nothing... all data for this item should be generated */ | 55 | /* Do nothing... all data for this item should be generated */ |
56 | void setText(int i, const QString &) | 56 | void setText(int i, const QString &) |
57 | { | 57 | { |
58 | ; | 58 | ; |
59 | } | 59 | } |
60 | QString key(int i, bool a) const | 60 | QString key(int i, bool a) const |
61 | { | 61 | { |
62 | return data_reference->toSortableQString(i); | 62 | return data_reference->toSortableQString(i); |
63 | } | 63 | } |
64 | 64 | ||
65 | void setDataElem(DataElem *d) | 65 | void setDataElem(DataElem *d) |
66 | { | 66 | { |
67 | data_reference = d; | 67 | data_reference = d; |
68 | } | 68 | } |
69 | 69 | ||
70 | DataElem *getDataElem() { | 70 | DataElem *getDataElem() { |
71 | return data_reference; | 71 | return data_reference; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | DataElem *data_reference; | 74 | DataElem *data_reference; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) | 77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) |
78 | : QListViewItem(parent) | 78 | : QListViewItem(parent) |
79 | { | 79 | { |
80 | data_reference = d; | 80 | data_reference = d; |
81 | } | 81 | } |
82 | 82 | ||
83 | TVListViewItem::~TVListViewItem() | 83 | TVListViewItem::~TVListViewItem() |
84 | { | 84 | { |
85 | data_reference = 0; | 85 | data_reference = 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | TVListView::TVListView(TableState *t, QWidget* parent, | 88 | TVListView::TVListView(TableState *t, QWidget* parent, |
89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) | 89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) |
90 | { | 90 | { |
91 | if (!name) | 91 | if (!name) |
92 | setName("TVListView"); | 92 | setName("TVListView"); |
93 | 93 | ||
94 | // the next two lines need to be rationalized. | 94 | // the next two lines need to be rationalized. |
95 | resize(318,457); | 95 | resize(318,457); |
96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, | 96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, |
97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); | 97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); |
98 | setCaption(tr("List View")); | 98 | setCaption(tr("List View")); |
99 | 99 | ||
100 | QVBoxLayout *layout = new QVBoxLayout(this); | 100 | QVBoxLayout *layout = new QVBoxLayout(this); |
101 | layout->setSpacing(0); | 101 | layout->setSpacing(0); |
102 | layout->setMargin(0); | 102 | layout->setMargin(0); |
103 | 103 | ||
104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); | 104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); |
105 | layout->addWidget(listViewDisplay); | 105 | layout->addWidget(listViewDisplay); |
106 | 106 | ||
107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem *)), this, | 107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem*)), this, |
108 | SLOT(setCurrent(QListViewItem *))); | 108 | SLOT(setCurrent(QListViewItem*))); |
109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, | 109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, |
110 | SLOT(setSorting(int))); | 110 | SLOT(setSorting(int))); |
111 | 111 | ||
112 | listViewDisplay->setShowSortIndicator(true); | 112 | listViewDisplay->setShowSortIndicator(true); |
113 | 113 | ||
114 | it = new QListViewItemIterator(listViewDisplay); | 114 | it = new QListViewItemIterator(listViewDisplay); |
115 | ts = t; | 115 | ts = t; |
116 | } | 116 | } |
117 | 117 | ||
118 | TVListView::~TVListView() | 118 | TVListView::~TVListView() |
119 | { | 119 | { |
120 | } | 120 | } |
121 | 121 | ||
122 | void TVListView::addItem(DataElem *d) | 122 | void TVListView::addItem(DataElem *d) |
123 | { | 123 | { |
124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); | 124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); |
125 | 125 | ||
126 | delete it; | 126 | delete it; |
127 | it = new QListViewItemIterator(i); | 127 | it = new QListViewItemIterator(i); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* remove current (it) item */ | 130 | /* remove current (it) item */ |
131 | void TVListView::removeItem() | 131 | void TVListView::removeItem() |
132 | { | 132 | { |
133 | QListViewItemIterator other(*it); | 133 | QListViewItemIterator other(*it); |
134 | 134 | ||
135 | QListViewItemIterator tmp = *it; | 135 | QListViewItemIterator tmp = *it; |
136 | (*it)++; | 136 | (*it)++; |
137 | if (!it->current()) { | 137 | if (!it->current()) { |
138 | *it = tmp; | 138 | *it = tmp; |
139 | (*it)--; | 139 | (*it)--; |
140 | if (!it->current()) { | 140 | if (!it->current()) { |
141 | delete it; | 141 | delete it; |
142 | it = 0; | 142 | it = 0; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | delete other.current(); | 146 | delete other.current(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void TVListView::clearItems() | 149 | void TVListView::clearItems() |
150 | { | 150 | { |
151 | /* This is ok since the destructor for TVListItem does not know about | 151 | /* This is ok since the destructor for TVListItem does not know about |
152 | the data_reference pointer.. and hence will leave it alone */ | 152 | the data_reference pointer.. and hence will leave it alone */ |
153 | listViewDisplay->clear(); | 153 | listViewDisplay->clear(); |
154 | delete it; | 154 | delete it; |
155 | it = new QListViewItemIterator(listViewDisplay); | 155 | it = new QListViewItemIterator(listViewDisplay); |
156 | } | 156 | } |
157 | 157 | ||
158 | void TVListView::first() | 158 | void TVListView::first() |
159 | { | 159 | { |
160 | delete it; | 160 | delete it; |
161 | it = new QListViewItemIterator(listViewDisplay); | 161 | it = new QListViewItemIterator(listViewDisplay); |
162 | } | 162 | } |
163 | 163 | ||
164 | void TVListView::last() | 164 | void TVListView::last() |
165 | { | 165 | { |
166 | qWarning("TVListView::last not yet implemented"); | 166 | qWarning("TVListView::last not yet implemented"); |
167 | } | 167 | } |
168 | 168 | ||
169 | void TVListView::next() | 169 | void TVListView::next() |
170 | { | 170 | { |
171 | QListViewItemIterator tmp = *it; | 171 | QListViewItemIterator tmp = *it; |
172 | (*it)++; | 172 | (*it)++; |
173 | if (!it->current()) { | 173 | if (!it->current()) { |
174 | *it = tmp; | 174 | *it = tmp; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | void TVListView::previous() | 178 | void TVListView::previous() |
179 | { | 179 | { |
180 | QListViewItemIterator tmp = *it; | 180 | QListViewItemIterator tmp = *it; |
181 | (*it)--; | 181 | (*it)--; |
182 | if (!it->current()) { | 182 | if (!it->current()) { |
183 | *it = tmp; | 183 | *it = tmp; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | DataElem *TVListView::getCurrentData() { | 187 | DataElem *TVListView::getCurrentData() { |
188 | if (it->current()) { | 188 | if (it->current()) { |
189 | return ((TVListViewItem *)it->current())->getDataElem(); | 189 | return ((TVListViewItem *)it->current())->getDataElem(); |
190 | } | 190 | } |
191 | return NULL; | 191 | return NULL; |
192 | } | 192 | } |
193 | 193 | ||
194 | /*! Now to implement the closest match function */ | 194 | /*! Now to implement the closest match function */ |
195 | void TVListView::findItem(int keyId, TVVariant value) | 195 | void TVListView::findItem(int keyId, TVVariant value) |
196 | { | 196 | { |
197 | QListViewItem *i; | 197 | QListViewItem *i; |
198 | TVListViewItem *best_so_far = NULL; | 198 | TVListViewItem *best_so_far = NULL; |
199 | /* start at the beginning... go through till find the closest elem */ | 199 | /* start at the beginning... go through till find the closest elem */ |
200 | i = listViewDisplay->firstChild(); | 200 | i = listViewDisplay->firstChild(); |
201 | while (i) { | 201 | while (i) { |
202 | /* search stuff */ | 202 | /* search stuff */ |
203 | if(best_so_far) { | 203 | if(best_so_far) { |
204 | if (DataElem::closer( | 204 | if (DataElem::closer( |