Diffstat (limited to 'noncore/apps/tableviewer/tableviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index 0d4a412..0456b41 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp | |||
@@ -28,8 +28,9 @@ | |||
28 | #include "db/datacache.h" | 28 | #include "db/datacache.h" |
29 | 29 | ||
30 | /* QPE includes */ | 30 | /* QPE includes */ |
31 | #include "fileselector.h" | 31 | #include <qpe/fileselector.h> |
32 | #include "resource.h" | 32 | #include <qpe/resource.h> |
33 | #include <qpe/qpetoolbar.h> | ||
33 | 34 | ||
34 | /* QTE includes */ | 35 | /* QTE includes */ |
35 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
@@ -38,7 +39,6 @@ | |||
38 | #include <qwidgetstack.h> | 39 | #include <qwidgetstack.h> |
39 | #include <qlayout.h> | 40 | #include <qlayout.h> |
40 | #include <qbuffer.h> | 41 | #include <qbuffer.h> |
41 | |||
42 | /*! | 42 | /*! |
43 | \class TableViewerWindow | 43 | \class TableViewerWindow |
44 | \brief The main window widget of the application | 44 | \brief The main window widget of the application |
@@ -93,44 +93,44 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
93 | /* Build tool bar */ | 93 | /* Build tool bar */ |
94 | navigation = new QPEToolBar(this, "navigation"); | 94 | navigation = new QPEToolBar(this, "navigation"); |
95 | QToolButton *newItemButton = new QToolButton( | 95 | QToolButton *newItemButton = new QToolButton( |
96 | QIconSet(Resource::loadImage("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::loadImage("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::loadImage("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::loadImage("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::loadImage("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::loadImage("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::loadImage("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::loadImage("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::loadImage("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); |
@@ -141,7 +141,7 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
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 | ||
@@ -162,7 +162,7 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
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); |
@@ -177,7 +177,7 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
177 | TableViewerWindow::~TableViewerWindow() | 177 | TableViewerWindow::~TableViewerWindow() |
178 | { | 178 | { |
179 | if(dirty) | 179 | if(dirty) |
180 | saveDocument(); | 180 | saveDocument(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /*! | 183 | /*! |
@@ -186,7 +186,7 @@ TableViewerWindow::~TableViewerWindow() | |||
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(); |
@@ -195,14 +195,14 @@ void TableViewerWindow::selectDocument() | |||
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; |
@@ -229,16 +229,16 @@ void TableViewerWindow::newDocument() | |||
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::openDocument(const DocLnk &f) | 237 | void TableViewerWindow::openDocument(const DocLnk &f) |
238 | { | 238 | { |
239 | 239 | ||
240 | if (!f.isValid()) | 240 | if (!f.isValid()) |
241 | return; | 241 | return; |
242 | 242 | ||
243 | FileManager fm; | 243 | FileManager fm; |
244 | QIODevice *dev = fm.openFile(f); | 244 | QIODevice *dev = fm.openFile(f); |
@@ -251,8 +251,8 @@ void TableViewerWindow::openDocument(const DocLnk &f) | |||
251 | listView->reset(); | 251 | listView->reset(); |
252 | filterView->reset(); | 252 | filterView->reset(); |
253 | 253 | ||
254 | current_view = BrowseState; | 254 | current_view = BrowseState; |
255 | cw->raiseWidget(current_view); | 255 | cw->raiseWidget(current_view); |
256 | 256 | ||
257 | /* set up new table state and ensure sub widgets have a reference */ | 257 | /* set up new table state and ensure sub widgets have a reference */ |
258 | ts.current_column = 0; | 258 | ts.current_column = 0; |
@@ -281,7 +281,7 @@ void TableViewerWindow::openDocument(const DocLnk &f) | |||
281 | scratch += ds->getName(); | 281 | scratch += ds->getName(); |
282 | setCaption(tr(scratch)); | 282 | setCaption(tr(scratch)); |
283 | 283 | ||
284 | dirty = FALSE; | 284 | dirty = FALSE; |
285 | } else { | 285 | } else { |
286 | qWarning(tr("could not load Document")); | 286 | qWarning(tr("could not load Document")); |
287 | } | 287 | } |
@@ -329,7 +329,7 @@ void TableViewerWindow::applyFilter() | |||
329 | d = ds->getCurrentData(); | 329 | d = ds->getCurrentData(); |
330 | if(d) | 330 | if(d) |
331 | if(filterView->passesFilter(d)) | 331 | if(filterView->passesFilter(d)) |
332 | listView->addItem(d); | 332 | listView->addItem(d); |
333 | } while(ds->next()); | 333 | } while(ds->next()); |
334 | listView->first(); | 334 | listView->first(); |
335 | listView->rebuildData(); | 335 | listView->rebuildData(); |
@@ -365,9 +365,9 @@ void TableViewerWindow::filterViewSlot() | |||
365 | void TableViewerWindow::editItemSlot() | 365 | void TableViewerWindow::editItemSlot() |
366 | { | 366 | { |
367 | if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { | 367 | if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { |
368 | listView->rebuildData(); | 368 | listView->rebuildData(); |
369 | browseView->rebuildData(); | 369 | browseView->rebuildData(); |
370 | dirty = TRUE; | 370 | dirty = TRUE; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
@@ -376,25 +376,25 @@ void TableViewerWindow::newItemSlot() | |||
376 | DataElem *d = new DataElem(ds); | 376 | DataElem *d = new DataElem(ds); |
377 | if (TVEditView::openEditItemDialog(&ts, d, this)) { | 377 | if (TVEditView::openEditItemDialog(&ts, d, this)) { |
378 | 378 | ||
379 | ds->addItem(d); | 379 | ds->addItem(d); |
380 | ts.current_elem = d; | 380 | ts.current_elem = d; |
381 | applyFilter(); | 381 | applyFilter(); |
382 | listView->rebuildData(); | 382 | listView->rebuildData(); |
383 | browseView->rebuildData(); | 383 | browseView->rebuildData(); |
384 | dirty = TRUE; | 384 | dirty = TRUE; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | void TableViewerWindow::deleteItemSlot() | 388 | void TableViewerWindow::deleteItemSlot() |
389 | { | 389 | { |
390 | /* delete the actual item, then do a 'filter' */ | 390 | /* delete the actual item, then do a 'filter' */ |
391 | DataElem *to_remove = ts.current_elem; | 391 | DataElem *to_remove = ts.current_elem; |
392 | 392 | ||
393 | if(!to_remove) | 393 | if(!to_remove) |
394 | return; | 394 | return; |
395 | 395 | ||
396 | listView->removeItem(); | 396 | listView->removeItem(); |
397 | ds->removeItem(to_remove); | 397 | ds->removeItem(to_remove); |
398 | 398 | ||
399 | applyFilter(); | 399 | applyFilter(); |
400 | listView->rebuildData(); | 400 | listView->rebuildData(); |
@@ -432,7 +432,7 @@ void TableViewerWindow::editKeysSlot() | |||
432 | } while(ds->next()); | 432 | } while(ds->next()); |
433 | 433 | ||
434 | /* Set up browse view, Will be based of structure of listView */ | 434 | /* Set up browse view, Will be based of structure of listView */ |
435 | dirty = TRUE; | 435 | dirty = TRUE; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||