summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp67
-rw-r--r--noncore/comm/keypebble/kvnc.cpp18
2 files changed, 40 insertions, 45 deletions
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp
index 9538cb3..8668368 100644
--- a/noncore/apps/tableviewer/tableviewer.cpp
+++ b/noncore/apps/tableviewer/tableviewer.cpp
@@ -1,331 +1,324 @@
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 "tableviewer.h" 21#include "tableviewer.h"
22#include "ui/tvbrowseview.h" 22#include "ui/tvbrowseview.h"
23#include "ui/tvfilterview.h" 23#include "ui/tvfilterview.h"
24#include "ui/tvlistview.h" 24#include "ui/tvlistview.h"
25#include "ui/tveditview.h" 25#include "ui/tveditview.h"
26#include "ui/tvkeyedit.h" 26#include "ui/tvkeyedit.h"
27#include "db/datacache.h" 27#include "db/datacache.h"
28 28
29/* OPIE */ 29/* OPIE */
30#include <opie2/odebug.h> 30#include <opie2/odebug.h>
31#include <opie2/oresource.h>
31#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
32#include <qpe/resource.h>
33using namespace Opie::Core; 33using namespace Opie::Core;
34 34
35/* QT */ 35/* QT */
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qtoolbar.h> 37#include <qtoolbar.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qapplication.h> 39#include <qapplication.h>
40#include <qwidgetstack.h> 40#include <qwidgetstack.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qbuffer.h> 42#include <qbuffer.h>
43 43
44/*! 44/*!
45 \class TableViewerWindow 45 \class TableViewerWindow
46 \brief The main window widget of the application 46 \brief The main window widget of the application
47 47
48 This is the main widget of the table viewer application. 48 This is the main widget of the table viewer application.
49 It is the co-ordination point. 49 It is the co-ordination point.
50*/ 50*/
51 51
52/*! 52/*!
53 Constructs a new TableViewerWindow 53 Constructs a new TableViewerWindow
54*/ 54*/
55TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) 55TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f)
56 : QMainWindow(parent, name, f) 56 : QMainWindow(parent, name, f)
57{ 57{
58 setCaption(tr("Table Viewer")); 58 setCaption(tr("Table Viewer"));
59 59
60/* Build data */ 60/* Build data */
61 ds = new DBStore(); 61 ds = new DBStore();
62 doc.setType("text/x-xml-tableviewer"); 62 doc.setType("text/x-xml-tableviewer");
63 doc.setName("table"); 63 doc.setName("table");
64 64
65 dirty = FALSE; 65 dirty = FALSE;
66 ts.current_column = 0; 66 ts.current_column = 0;
67 ts.kRep = ds->getKeys(); 67 ts.kRep = ds->getKeys();
68 68
69/* build menus */ 69/* build menus */
70 menu = new QMenuBar(this, 0); 70 menu = new QMenuBar(this, 0);
71 71
72 QPopupMenu *file_menu = new QPopupMenu; 72 QPopupMenu *file_menu = new QPopupMenu;
73 file_menu->insertItem("New", this, SLOT(newDocument())); 73 file_menu->insertItem("New", this, SLOT(newDocument()));
74 74
75 file_menu->insertItem("Open", this, SLOT(selectDocument())); 75 file_menu->insertItem("Open", this, SLOT(selectDocument()));
76 file_menu->insertSeparator(); 76 file_menu->insertSeparator();
77 file_menu->insertItem("Properties"); 77 file_menu->insertItem("Properties");
78 78
79 /* later will want to set this up to clean up first via this, SLOT(quit) */ 79 /* later will want to set this up to clean up first via this, SLOT(quit) */
80 menu->insertItem("Document", file_menu); 80 menu->insertItem("Document", file_menu);
81 81
82 QPopupMenu *edit_menu = new QPopupMenu; 82 QPopupMenu *edit_menu = new QPopupMenu;
83 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); 83 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot()));
84 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); 84 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot()));
85 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); 85 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot()));
86 menu->insertItem("Edit", edit_menu); 86 menu->insertItem("Edit", edit_menu);
87 87
88 QPopupMenu *view_menu = new QPopupMenu; 88 QPopupMenu *view_menu = new QPopupMenu;
89 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); 89 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot()));
90 view_menu->insertItem("List View", this, SLOT(listViewSlot())); 90 view_menu->insertItem("List View", this, SLOT(listViewSlot()));
91 menu->insertItem("View", view_menu); 91 menu->insertItem("View", view_menu);
92 92
93 QVBoxLayout *main_layout = new QVBoxLayout; 93 QVBoxLayout *main_layout = new QVBoxLayout;
94 94
95 /* Build tool bar */ 95 /* Build tool bar */
96 bool useBigIcon = qApp->desktop()->size().width() > 330;
97
96 navigation = new QToolBar(this, "navigation"); 98 navigation = new QToolBar(this, "navigation");
97 QToolButton *newItemButton = new QToolButton( 99 QToolButton *btn = new QToolButton( Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
98 QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, 100 "New Item", QString::null, this, SLOT(newItemSlot()), navigation, "New Item");
99 this, SLOT(newItemSlot()), navigation, "New Item"); 101 btn->setUsesBigPixmap( useBigIcon );
100 QToolButton *editItemButton = new QToolButton( 102 btn = new QToolButton( Opie::Core::OResource::loadPixmap("edit", Opie::Core::OResource::SmallIcon),
101 QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, 103 "Edit Item", QString::null, this, SLOT(editItemSlot()), navigation, "Edit Item");
102 this, SLOT(editItemSlot()), navigation, "Edit Item"); 104 btn->setUsesBigPixmap( useBigIcon );
103 QToolButton *deleteItemButton = new QToolButton( 105 btn = new QToolButton( Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon),
104 QIconSet(Resource::loadPixmap("trash")), "Delete Item", 106 "Delete Item", QString::null, this, SLOT(deleteItemSlot()), navigation, "Delete Item");
105 QString::null, this, 107 btn->setUsesBigPixmap( useBigIcon );
106 SLOT(deleteItemSlot()), navigation, "Delete Item");
107 108
108 navigation->addSeparator(); 109 navigation->addSeparator();
109 110
110 QToolButton *firstItemButton = new QToolButton( 111 btn = new QToolButton( Opie::Core::OResource::loadPixmap("fastback", Opie::Core::OResource::SmallIcon),
111 QIconSet(Resource::loadPixmap("fastback")), "First Item", 112 "First Item", QString::null, this, SLOT(firstItem()), navigation, "First Item");
112 QString::null, this, 113 btn->setUsesBigPixmap( useBigIcon );
113 SLOT(firstItem()), navigation, "First Item"); 114 btn = new QToolButton( Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon),
114 QToolButton *previousItemButton = new QToolButton( 115 "Previous Item", QString::null, this, SLOT(previousItem()), navigation, "Previous Item");
115 QIconSet(Resource::loadPixmap("back")), "Previous Item", 116 btn->setUsesBigPixmap( useBigIcon );
116 QString::null, this, 117 btn = new QToolButton( Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon),
117 SLOT(previousItem()), navigation, "Previous Item"); 118 "Next Item", QString::null, this, SLOT(nextItem()), navigation, "Next Item");
118 QToolButton *nextItemButton = new QToolButton( 119 btn->setUsesBigPixmap( useBigIcon );
119 QIconSet(Resource::loadPixmap("forward")), "Next Item", 120 btn = new QToolButton( Opie::Core::OResource::loadPixmap("fastforward", Opie::Core::OResource::SmallIcon),
120 QString::null, this, 121 "Last Item", QString::null, this, SLOT(lastItem()), navigation, "Last Item");
121 SLOT(nextItem()), navigation, "Next Item"); 122 btn->setUsesBigPixmap( useBigIcon );
122 QToolButton *lastItemButton = new QToolButton(
123 QIconSet(Resource::loadPixmap("fastforward")), "Last Item",
124 QString::null, this,
125 SLOT(lastItem()), navigation, "Last Item");
126 123
127 navigation->addSeparator(); 124 navigation->addSeparator();
128 QToolButton *browseButton = new QToolButton( 125 btn = new QToolButton( Opie::Core::OResource::loadPixmap("day", Opie::Core::OResource::SmallIcon),
129 QIconSet(Resource::loadPixmap("day")), "View Single Item", 126 "View Single Item", QString::null, this, SLOT(browseViewSlot()), navigation, "View Single Item");
130 QString::null, this, 127 btn->setUsesBigPixmap( useBigIcon );
131 SLOT(browseViewSlot()), navigation, "View Single Item"); 128 btn = new QToolButton( Opie::Core::OResource::loadPixmap("month", Opie::Core::OResource::SmallIcon),
132 QToolButton *listButton = new QToolButton( 129 "View Multiple Items", QString::null, this, SLOT(listViewSlot()), navigation, "View Multiple Items");
133 QIconSet(Resource::loadPixmap("month")), "View Multiple Items", 130 btn->setUsesBigPixmap( useBigIcon );
134 QString::null, this,
135 SLOT(listViewSlot()), navigation, "View Multiple Items");
136 131
137 setToolBarsMovable(FALSE); 132 setToolBarsMovable(FALSE);
138 setToolBarsMovable(FALSE);
139 setToolBarsMovable(FALSE);
140 133
141/* Build widgets */ 134/* Build widgets */
142 browseView = new TVBrowseView(&ts, this, 0); 135 browseView = new TVBrowseView(&ts, this, 0);
143 listView = new TVListView(&ts, this, 0); 136 listView = new TVListView(&ts, this, 0);
144 filterView = new TVFilterView(&ts, this, 0); 137 filterView = new TVFilterView(&ts, this, 0);
145 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", 138 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer",
146 this, "fileselector"); 139 this, "fileselector");
147 fileSelector->setNewVisible(FALSE); 140 fileSelector->setNewVisible(FALSE);
148 fileSelector->setCloseVisible(FALSE); 141 fileSelector->setCloseVisible(FALSE);
149 142
150 cw = new QWidgetStack(this, 0); 143 cw = new QWidgetStack(this, 0);
151 cw->addWidget(listView, ListState); 144 cw->addWidget(listView, ListState);
152 cw->addWidget(browseView, BrowseState); 145 cw->addWidget(browseView, BrowseState);
153 cw->addWidget(filterView, FilterState); 146 cw->addWidget(filterView, FilterState);
154 cw->addWidget(fileSelector, FileState); 147 cw->addWidget(fileSelector, FileState);
155 148
156 current_view = FileState; 149 current_view = FileState;
157 cw->raiseWidget(current_view); 150 cw->raiseWidget(current_view);
158 fileSelector->reread(); 151 fileSelector->reread();
159 152
160 connect(browseView, SIGNAL(searchOnKey(int,TVVariant)), 153 connect(browseView, SIGNAL(searchOnKey(int,TVVariant)),
161 this, SLOT(searchOnKey(int,TVVariant))); 154 this, SLOT(searchOnKey(int,TVVariant)));
162 connect(browseView, SIGNAL(sortChanged(int)), 155 connect(browseView, SIGNAL(sortChanged(int)),
163 this, SLOT(setPrimaryKey(int))); 156 this, SLOT(setPrimaryKey(int)));
164 157
165 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); 158 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot()));
166 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), 159 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)),
167 this, SLOT(openDocument(const DocLnk&))); 160 this, SLOT(openDocument(const DocLnk&)));
168 161
169 main_layout->addWidget(menu); 162 main_layout->addWidget(menu);
170 main_layout->addWidget(cw); 163 main_layout->addWidget(cw);
171 164
172 setCentralWidget(cw); 165 setCentralWidget(cw);
173 166
174} 167}
175 168
176/*! 169/*!
177 Destroys the TableViewerWindow 170 Destroys the TableViewerWindow
178*/ 171*/
179TableViewerWindow::~TableViewerWindow() 172TableViewerWindow::~TableViewerWindow()
180{ 173{
181 if(dirty) 174 if(dirty)
182 saveDocument(); 175 saveDocument();
183} 176}
184 177
185/*! 178/*!
186 Opens a file dialog and loads the file specified by the dialog 179 Opens a file dialog and loads the file specified by the dialog
187*/ 180*/
188void TableViewerWindow::selectDocument() 181void TableViewerWindow::selectDocument()
189{ 182{
190 if(dirty) 183 if(dirty)
191 saveDocument(); 184 saveDocument();
192 current_view = FileState; 185 current_view = FileState;
193 cw->raiseWidget(current_view); 186 cw->raiseWidget(current_view);
194 fileSelector->reread(); 187 fileSelector->reread();
195} 188}
196 189
197void TableViewerWindow::saveDocument() 190void TableViewerWindow::saveDocument()
198{ 191{
199 if(!dirty) 192 if(!dirty)
200 return; 193 return;
201 194
202 FileManager fm; 195 FileManager fm;
203 QIODevice *dev = fm.saveFile(doc); 196 QIODevice *dev = fm.saveFile(doc);
204 197
205 if(!ds->saveSource(dev, doc.type())){ 198 if(!ds->saveSource(dev, doc.type())){
206 owarn << "Save unsuccessful" << oendl; 199 owarn << "Save unsuccessful" << oendl;
207 return; 200 return;
208 } 201 }
209 dev->close(); 202 dev->close();
210 dirty = FALSE; 203 dirty = FALSE;
211} 204}
212 205
213void TableViewerWindow::newDocument() 206void TableViewerWindow::newDocument()
214{ 207{
215 DocLnk nf; 208 DocLnk nf;
216 nf.setType("text/x-xml-tableviewer"); 209 nf.setType("text/x-xml-tableviewer");
217 nf.setName("table"); 210 nf.setName("table");
218 211
219 delete ds; 212 delete ds;
220 ds = new DBStore(); 213 ds = new DBStore();
221 214
222 ts.current_column = 0; 215 ts.current_column = 0;
223 ts.kRep = ds->getKeys(); 216 ts.kRep = ds->getKeys();
224 browseView->reset(); 217 browseView->reset();
225 listView->reset(); 218 listView->reset();
226 filterView->reset(); 219 filterView->reset();
227 220
228 doc = nf; 221 doc = nf;
229 dirty = FALSE; 222 dirty = FALSE;
230 223
231 current_view = BrowseState; 224 current_view = BrowseState;
232 cw->raiseWidget(current_view); 225 cw->raiseWidget(current_view);
233 226
234 /* now set up for editing the keys */ 227 /* now set up for editing the keys */
235 ts.kRep->addKey("key", TVVariant::String); 228 ts.kRep->addKey("key", TVVariant::String);
236 editKeysSlot(); 229 editKeysSlot();
237} 230}
238 231
239void TableViewerWindow::setDocument(const QString &f) 232void TableViewerWindow::setDocument(const QString &f)
240{ 233{
241 openDocument(DocLnk(f, TRUE)); 234 openDocument(DocLnk(f, TRUE));
242} 235}
243 236
244void TableViewerWindow::openDocument(const DocLnk &f) 237void TableViewerWindow::openDocument(const DocLnk &f)
245{ 238{
246 239
247 if (!f.isValid()) 240 if (!f.isValid())
248 return; 241 return;
249 242
250 FileManager fm; 243 FileManager fm;
251 QIODevice *dev = fm.openFile(f); 244 QIODevice *dev = fm.openFile(f);
252 doc = f; 245 doc = f;
253 246
254 if(ds->openSource(dev, doc.type())) { 247 if(ds->openSource(dev, doc.type())) {
255 DataElem *d; 248 DataElem *d;
256 249
257 browseView->reset(); 250 browseView->reset();
258 listView->reset(); 251 listView->reset();
259 filterView->reset(); 252 filterView->reset();
260 253
261 current_view = BrowseState; 254 current_view = BrowseState;
262 cw->raiseWidget(current_view); 255 cw->raiseWidget(current_view);
263 256
264 /* 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 */
265 ts.current_column = 0; 258 ts.current_column = 0;
266 ts.kRep = ds->getKeys(); 259 ts.kRep = ds->getKeys();
267 browseView->rebuildKeys(); 260 browseView->rebuildKeys();
268 listView->rebuildKeys(); 261 listView->rebuildKeys();
269 filterView->rebuildKeys(); 262 filterView->rebuildKeys();
270 263
271 ds->first(); 264 ds->first();
272 /* set up the list view */ 265 /* set up the list view */
273 listView->clearItems(); 266 listView->clearItems();
274 do { 267 do {
275 d = ds->getCurrentData(); 268 d = ds->getCurrentData();
276 if(d) 269 if(d)
277 listView->addItem(d); 270 listView->addItem(d);
278 } while(ds->next()); 271 } while(ds->next());
279 272
280 /* Set up browse view, Will be based of structure of listView */ 273 /* Set up browse view, Will be based of structure of listView */
281 listView->first(); 274 listView->first();
282 ts.current_elem = listView->getCurrentData(); 275 ts.current_elem = listView->getCurrentData();
283 browseView->rebuildData(); 276 browseView->rebuildData();
284 listView->rebuildData(); 277 listView->rebuildData();
285 278
286 QString scratch = "Table Viewer";/* later take from constant */ 279 QString scratch = "Table Viewer";/* later take from constant */
287 scratch += " - "; 280 scratch += " - ";
288 scratch += ds->getName(); 281 scratch += ds->getName();
289 setCaption(tr(scratch)); 282 setCaption(tr(scratch));
290 283
291 dirty = FALSE; 284 dirty = FALSE;
292 } else { 285 } else {
293 owarn << tr("could not load Document") << oendl; 286 owarn << tr("could not load Document") << oendl;
294 } 287 }
295 dev->close(); 288 dev->close();
296} 289}
297 290
298/*! 291/*!
299 Moves to the first item of the current table 292 Moves to the first item of the current table
300*/ 293*/
301void TableViewerWindow::firstItem() 294void TableViewerWindow::firstItem()
302{ 295{
303 listView->first(); 296 listView->first();
304 ts.current_elem = listView->getCurrentData(); 297 ts.current_elem = listView->getCurrentData();
305 browseView->rebuildData(); 298 browseView->rebuildData();
306} 299}
307 300
308/*! 301/*!
309 Moves to the lat item of the current table 302 Moves to the lat item of the current table
310*/ 303*/
311void TableViewerWindow::lastItem() 304void TableViewerWindow::lastItem()
312{ 305{
313 listView->last(); 306 listView->last();
314 ts.current_elem = listView->getCurrentData(); 307 ts.current_elem = listView->getCurrentData();
315 browseView->rebuildData(); 308 browseView->rebuildData();
316} 309}
317 310
318/*! 311/*!
319 Moves to the next item of the current table 312 Moves to the next item of the current table
320*/ 313*/
321void TableViewerWindow::nextItem() 314void TableViewerWindow::nextItem()
322{ 315{
323 listView->next(); 316 listView->next();
324 ts.current_elem = listView->getCurrentData(); 317 ts.current_elem = listView->getCurrentData();
325 browseView->rebuildData(); 318 browseView->rebuildData();
326} 319}
327 320
328/*! 321/*!
329 Moves to the previous item of the current table 322 Moves to the previous item of the current table
330*/ 323*/
331void TableViewerWindow::previousItem() 324void TableViewerWindow::previousItem()
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
index 3a8e919..c089551 100644
--- a/noncore/comm/keypebble/kvnc.cpp
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -1,279 +1,281 @@
1#include <opie2/oresource.h>
2
3#include <qpe/qpeapplication.h>
4
1#include <qaction.h> 5#include <qaction.h>
2#include <qpopupmenu.h> 6#include <qpopupmenu.h>
3#include <qpushbutton.h> 7#include <qpushbutton.h>
4#include <qmessagebox.h> 8#include <qmessagebox.h>
5#include <qlistbox.h> 9#include <qlistbox.h>
6#include <qpe/qpeapplication.h>
7#include <qpe/resource.h>
8 10
9#include <assert.h> 11#include <assert.h>
10 12
11#include "kvnc.h" 13#include "kvnc.h"
12#include "krfbcanvas.h" 14#include "krfbcanvas.h"
13#include "krfbconnection.h" 15#include "krfbconnection.h"
14#include "kvncconndlg.h" 16#include "kvncconndlg.h"
15 17
16static int u_id = 1; 18static int u_id = 1;
17static int get_unique_id() 19static int get_unique_id()
18{ 20{
19 return u_id++; 21 return u_id++;
20} 22}
21 23
22 24
23/* XPM */ 25/* XPM */
24static char * menu_xpm[] = { 26static char * menu_xpm[] = {
25"12 12 5 1", 27"12 12 5 1",
26 " c None", 28 " c None",
27 ".c #000000", 29 ".c #000000",
28 "+c #FFFDAD", 30 "+c #FFFDAD",
29 "@c #FFFF00", 31 "@c #FFFF00",
30 "#c #E5E100", 32 "#c #E5E100",
31" ", 33" ",
32" ", 34" ",
33" ......... ", 35" ......... ",
34" .+++++++. ", 36" .+++++++. ",
35" .+@@@@#. ", 37" .+@@@@#. ",
36" .+@@@#. ", 38" .+@@@#. ",
37" .+@@#. ", 39" .+@@#. ",
38" .+@#. ", 40" .+@#. ",
39" .+#. ", 41" .+#. ",
40" .+. ", 42" .+. ",
41" .. ", 43" .. ",
42" "}; 44" "};
43 45
44const int StatusTextId = 0; 46const int StatusTextId = 0;
45 47
46KVNC::KVNC( QWidget *parent, const char *name, WFlags ) : QMainWindow( parent, name ,WStyle_ContextHelp) 48KVNC::KVNC( QWidget *parent, const char *name, WFlags ) : QMainWindow( parent, name ,WStyle_ContextHelp)
47{ 49{
48 setCaption( tr("VNC Viewer") ); 50 setCaption( tr("VNC Viewer") );
49 fullscreen = false; 51 fullscreen = false;
50 52
51 stack = new QWidgetStack( this ); 53 stack = new QWidgetStack( this );
52 setCentralWidget( stack ); 54 setCentralWidget( stack );
53 55
54 bookmarkSelector=new KVNCBookmarkDlg(); 56 bookmarkSelector=new KVNCBookmarkDlg();
55 stack->addWidget(bookmarkSelector,get_unique_id()); 57 stack->addWidget(bookmarkSelector,get_unique_id());
56 stack->raiseWidget( bookmarkSelector ); 58 stack->raiseWidget( bookmarkSelector );
57 59
58 canvas = new KRFBCanvas( stack, "canvas" ); 60 canvas = new KRFBCanvas( stack, "canvas" );
59 stack->addWidget(canvas,get_unique_id()); 61 stack->addWidget(canvas,get_unique_id());
60 setCentralWidget( stack ); 62 setCentralWidget( stack );
61 63
62 64
63 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem*)), 65 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem*)),
64 this, SLOT(openConnection(QListBoxItem*)) ); 66 this, SLOT(openConnection(QListBoxItem*)) );
65 connect( canvas->connection(), SIGNAL(statusChanged(const QString&)), 67 connect( canvas->connection(), SIGNAL(statusChanged(const QString&)),
66 this, SLOT(statusMessage(const QString&)) ); 68 this, SLOT(statusMessage(const QString&)) );
67 connect( canvas->connection(), SIGNAL(error(const QString&)), 69 connect( canvas->connection(), SIGNAL(error(const QString&)),
68 this, SLOT(error(const QString&)) ); 70 this, SLOT(error(const QString&)) );
69 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) ); 71 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) );
70 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); 72 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) );
71 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) ); 73 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) );
72 74
73 setupActions(); 75 setupActions();
74 76
75 cornerButton = new QPushButton( this ); 77 cornerButton = new QPushButton( this );
76 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 78 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
77 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); 79 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
78 canvas->setCornerWidget( cornerButton ); 80 canvas->setCornerWidget( cornerButton );
79 81
80 stack->raiseWidget( bookmarkSelector ); 82 stack->raiseWidget( bookmarkSelector );
81 83
82 84
83 bar= new QToolBar( this ); 85 bar= new QToolBar( this );
84 setToolBarsMovable( false ); 86 setToolBarsMovable( false );
85 setRightJustification(false); 87 setRightJustification(false);
86 88
87 89
88 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), 90 QAction *n = new QAction( tr( "New Connection" ), Opie::Core::OResource::loadPixmap( "new",
89 QString::null, 0, this, 0 ); 91 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
90 connect( n, SIGNAL( activated() ), 92 connect( n, SIGNAL( activated() ),
91 this, SLOT( newConnection() ) ); 93 this, SLOT( newConnection() ) );
92 n->addTo( bar ); 94 n->addTo( bar );
93 95
94 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ), 96 QAction *o = new QAction( tr( "Open Bookmark" ), Opie::Core::OResource::loadPixmap( "fileopen",
95 QString::null, 0, this, 0 ); 97 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
96 connect( o, SIGNAL( activated() ), 98 connect( o, SIGNAL( activated() ),
97 this, SLOT( openConnection() ) ); 99 this, SLOT( openConnection() ) );
98 o->addTo( bar ); 100 o->addTo( bar );
99 101
100 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), 102 QAction *d = new QAction( tr( "Delete Bookmark" ), Opie::Core::OResource::loadPixmap( "trash",
101 QString::null, 0, this, 0 ); 103 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
102 connect( d, SIGNAL( activated() ), 104 connect( d, SIGNAL( activated() ),
103 this, SLOT( deleteBookmark() ) ); 105 this, SLOT( deleteBookmark() ) );
104 d->addTo( bar ); 106 d->addTo( bar );
105} 107}
106 108
107KVNC::~KVNC() 109KVNC::~KVNC()
108{ 110{
109 111
110} 112}
111 113
112void KVNC::newConnection() 114void KVNC::newConnection()
113{ 115{
114 curServer=new KRFBServer; 116 curServer=new KRFBServer;
115 117
116 KVNCConnDlg dlg( curServer,this); 118 KVNCConnDlg dlg( curServer,this);
117 if ( QPEApplication::execDialog( &dlg )) { 119 if ( QPEApplication::execDialog( &dlg )) {
118 if (!curServer->name.isEmpty()) 120 if (!curServer->name.isEmpty())
119 bookmarkSelector->addBookmark(curServer); 121 bookmarkSelector->addBookmark(curServer);
120 canvas->openConnection(*curServer); 122 canvas->openConnection(*curServer);
121 } else 123 } else
122 curServer=0; 124 curServer=0;
123} 125}
124 126
125void KVNC::openConnection( QString name) 127void KVNC::openConnection( QString name)
126{ 128{
127 curServer=bookmarkSelector->getServer(name); 129 curServer=bookmarkSelector->getServer(name);
128 130
129 if (curServer) { 131 if (curServer) {
130 KVNCConnDlg dlg( curServer,this); 132 KVNCConnDlg dlg( curServer,this);
131 if ( QPEApplication::execDialog( &dlg ) ) { 133 if ( QPEApplication::execDialog( &dlg ) ) {
132 canvas->openConnection(*curServer); 134 canvas->openConnection(*curServer);
133 bookmarkSelector->writeBookmarks(); 135 bookmarkSelector->writeBookmarks();
134 } else 136 } else
135 curServer=0; 137 curServer=0;
136 } 138 }
137} 139}
138 140
139void KVNC::openConnection( void ) 141void KVNC::openConnection( void )
140{ 142{
141 openConnection( bookmarkSelector->selectedBookmark()); 143 openConnection( bookmarkSelector->selectedBookmark());
142} 144}
143 145
144void KVNC::openConnection( QListBoxItem * item) 146void KVNC::openConnection( QListBoxItem * item)
145{ 147{
146 if (item) 148 if (item)
147 openConnection(item->text()); 149 openConnection(item->text());
148} 150}
149 151
150void KVNC::setupActions() 152void KVNC::setupActions()
151{ 153{
152 cornerMenu = new QPopupMenu( this ); 154 cornerMenu = new QPopupMenu( this );
153 155
154 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 ); 156 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 );
155 connect( fullScreenAction, SIGNAL(activated()), 157 connect( fullScreenAction, SIGNAL(activated()),
156 this, SLOT( toggleFullScreen() ) ); 158 this, SLOT( toggleFullScreen() ) );
157 fullScreenAction->addTo( cornerMenu ); 159 fullScreenAction->addTo( cornerMenu );
158 fullScreenAction->setEnabled( false ); 160 fullScreenAction->setEnabled( false );
159 161
160 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); 162 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 );
161 connect( ctlAltDelAction, SIGNAL(activated()), 163 connect( ctlAltDelAction, SIGNAL(activated()),
162 canvas, SLOT( sendCtlAltDel() ) ); 164 canvas, SLOT( sendCtlAltDel() ) );
163 ctlAltDelAction->addTo( cornerMenu ); 165 ctlAltDelAction->addTo( cornerMenu );
164 ctlAltDelAction->setEnabled( false ); 166 ctlAltDelAction->setEnabled( false );
165 167
166 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); 168 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
167 connect( disconnectAction, SIGNAL(activated()), 169 connect( disconnectAction, SIGNAL(activated()),
168 this, SLOT( closeConnection() ) ); 170 this, SLOT( closeConnection() ) );
169 disconnectAction->addTo( cornerMenu ); 171 disconnectAction->addTo( cornerMenu );
170 disconnectAction->setEnabled( false ); 172 disconnectAction->setEnabled( false );
171 173
172 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 ); 174 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 );
173 connect( doubleClickAction, SIGNAL(activated()), 175 connect( doubleClickAction, SIGNAL(activated()),
174 canvas, SLOT( markDoubleClick() ) ); 176 canvas, SLOT( markDoubleClick() ) );
175 doubleClickAction->addTo( cornerMenu ); 177 doubleClickAction->addTo( cornerMenu );
176 doubleClickAction->setEnabled( false ); 178 doubleClickAction->setEnabled( false );
177 179
178 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 ); 180 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 );
179 connect( rightClickAction, SIGNAL(activated()), 181 connect( rightClickAction, SIGNAL(activated()),
180 canvas, SLOT( markRightClick() ) ); 182 canvas, SLOT( markRightClick() ) );
181 rightClickAction->addTo( cornerMenu ); 183 rightClickAction->addTo( cornerMenu );
182 rightClickAction->setEnabled( false ); 184 rightClickAction->setEnabled( false );
183} 185}
184 186
185void KVNC::toggleFullScreen() 187void KVNC::toggleFullScreen()
186{ 188{
187 if ( fullscreen ) { 189 if ( fullscreen ) {
188 canvas->releaseKeyboard(); 190 canvas->releaseKeyboard();
189 canvas->reparent( stack, 0, QPoint(0,0), false ); 191 canvas->reparent( stack, 0, QPoint(0,0), false );
190 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 192 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
191 setCentralWidget( stack ); 193 setCentralWidget( stack );
192 stack->addWidget(canvas,get_unique_id()); 194 stack->addWidget(canvas,get_unique_id());
193 stack->raiseWidget(canvas); 195 stack->raiseWidget(canvas);
194 canvas->show(); 196 canvas->show();
195 stack->show(); 197 stack->show();
196 fullScreenAction->setText( tr("Full Screen") ); 198 fullScreenAction->setText( tr("Full Screen") );
197 } else { 199 } else {
198 canvas->setFrameStyle( QFrame::NoFrame ); 200 canvas->setFrameStyle( QFrame::NoFrame );
199 stack->removeWidget(canvas); 201 stack->removeWidget(canvas);
200 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 202 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
201 QPoint(0,0),false); 203 QPoint(0,0),false);
202 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); 204 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
203 canvas->raise(); 205 canvas->raise();
204 canvas->setFocus(); 206 canvas->setFocus();
205 canvas->grabKeyboard(); 207 canvas->grabKeyboard();
206 canvas->show(); 208 canvas->show();
207 209
208 fullScreenAction->setText( tr("Stop Full Screen") ); 210 fullScreenAction->setText( tr("Stop Full Screen") );
209 } 211 }
210 212
211 213
212 fullscreen = !fullscreen; 214 fullscreen = !fullscreen;
213} 215}
214 216
215void KVNC::closeConnection() 217void KVNC::closeConnection()
216{ 218{
217 if ( fullscreen ) 219 if ( fullscreen )
218 toggleFullScreen(); 220 toggleFullScreen();
219 canvas->closeConnection(); 221 canvas->closeConnection();
220} 222}
221 223
222void KVNC::showMenu() 224void KVNC::showMenu()
223{ 225{
224 QPoint pt = mapToGlobal(cornerButton->pos()); 226 QPoint pt = mapToGlobal(cornerButton->pos());
225 QSize s = cornerMenu->sizeHint(); 227 QSize s = cornerMenu->sizeHint();
226 pt.ry() -= s.height(); 228 pt.ry() -= s.height();
227 pt.rx() -= s.width(); 229 pt.rx() -= s.width();
228 cornerMenu->popup( pt ); 230 cornerMenu->popup( pt );
229} 231}
230 232
231void KVNC::connected() 233void KVNC::connected()
232{ 234{
233 static QString msg = tr( "Connected to remote host" ); 235 static QString msg = tr( "Connected to remote host" );
234 statusMessage( msg ); 236 statusMessage( msg );
235 ctlAltDelAction->setEnabled(true); 237 ctlAltDelAction->setEnabled(true);
236 disconnectAction->setEnabled( true ); 238 disconnectAction->setEnabled( true );
237 fullScreenAction->setEnabled( true ); 239 fullScreenAction->setEnabled( true );
238 doubleClickAction->setEnabled( false ); 240 doubleClickAction->setEnabled( false );
239 rightClickAction->setEnabled( true ); 241 rightClickAction->setEnabled( true );
240 stack->raiseWidget(canvas); 242 stack->raiseWidget(canvas);
241 bar->hide(); 243 bar->hide();
242} 244}
243 245
244void KVNC::loggedIn() 246void KVNC::loggedIn()
245{ 247{
246 static QString msg = tr( "Logged in to remote host" ); 248 static QString msg = tr( "Logged in to remote host" );
247 statusMessage( msg ); 249 statusMessage( msg );
248} 250}
249 251
250void KVNC::disconnected() 252void KVNC::disconnected()
251{ 253{
252 254
253 if ( fullscreen ) 255 if ( fullscreen )
254 toggleFullScreen(); 256 toggleFullScreen();
255 static QString msg = tr( "Connection closed" ); 257 static QString msg = tr( "Connection closed" );
256 statusMessage( msg ); 258 statusMessage( msg );
257 ctlAltDelAction->setEnabled(false); 259 ctlAltDelAction->setEnabled(false);
258 disconnectAction->setEnabled( false ); 260 disconnectAction->setEnabled( false );
259 fullScreenAction->setEnabled( false ); 261 fullScreenAction->setEnabled( false );
260 doubleClickAction->setEnabled( false ); 262 doubleClickAction->setEnabled( false );
261 rightClickAction->setEnabled( false ); 263 rightClickAction->setEnabled( false );
262 stack->raiseWidget(bookmarkSelector); 264 stack->raiseWidget(bookmarkSelector);
263 bar->show(); 265 bar->show();
264} 266}
265 267
266void KVNC::statusMessage( const QString &m ) 268void KVNC::statusMessage( const QString &m )
267{ 269{
268 Global::statusMessage( m ); 270 Global::statusMessage( m );
269} 271}
270 272
271void KVNC::error( const QString &msg ) 273void KVNC::error( const QString &msg )
272{ 274{
273 statusMessage( msg ); 275 statusMessage( msg );
274 QMessageBox::warning( this, tr("VNC Viewer"), msg ); 276 QMessageBox::warning( this, tr("VNC Viewer"), msg );
275} 277}
276void KVNC::deleteBookmark(void) 278void KVNC::deleteBookmark(void)
277{ 279{
278 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); 280 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark());
279} 281}