summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp2
-rw-r--r--noncore/apps/advancedfm/advancedfm.h7
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp1
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp6
-rw-r--r--noncore/apps/advancedfm/main.cpp19
-rw-r--r--noncore/apps/advancedfm/output.cpp8
-rw-r--r--noncore/apps/advancedfm/output.h6
-rw-r--r--noncore/apps/checkbook/checkbook.cpp1
-rw-r--r--noncore/apps/checkbook/checkbook.h3
-rw-r--r--noncore/apps/checkbook/main.cpp2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp2
-rw-r--r--noncore/apps/confedit/main.cpp3
-rw-r--r--noncore/apps/odict/main.cpp2
-rw-r--r--noncore/apps/odict/searchmethoddlg.cpp3
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp2
-rw-r--r--noncore/apps/opie-console/io_bt.cpp4
-rw-r--r--noncore/apps/opie-console/io_bt.h4
-rw-r--r--noncore/apps/opie-console/io_irda.cpp4
-rw-r--r--noncore/apps/opie-console/io_irda.h4
-rw-r--r--noncore/apps/opie-console/io_modem.cpp2
-rw-r--r--noncore/apps/opie-console/io_modem.h2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp5
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h2
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp8
-rw-r--r--noncore/apps/opie-console/sz_transfer.h6
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp1
-rw-r--r--noncore/apps/opie-console/tabwidget.h2
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp2
-rw-r--r--noncore/apps/opie-console/test/senderui.h4
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp3
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2
-rw-r--r--noncore/apps/opie-sheet/main.cpp3
-rw-r--r--noncore/apps/opie-write/main.cpp2
-rw-r--r--noncore/apps/oxygen/main.cpp2
-rw-r--r--noncore/apps/tableviewer/main.cpp2
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/view/kateviewdialog.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/view/kateviewdialog.h2
-rw-r--r--noncore/apps/tinykate/main.cpp3
-rw-r--r--noncore/apps/tinykate/tinykate.cpp7
-rw-r--r--noncore/apps/tinykate/tinykate.h2
-rw-r--r--noncore/apps/zsafe/zsafe.cpp3
43 files changed, 90 insertions, 63 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 2ba3dca..a60d6ce 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,883 +1,885 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/config.h> 16#include <qpe/config.h>
17#include <qpe/mimetype.h> 17#include <qpe/mimetype.h>
18#include <qpe/applnk.h> 18#include <qpe/applnk.h>
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20#include <qpe/menubutton.h> 20#include <qpe/menubutton.h>
21 21
22#include <qcombobox.h> 22#include <qcombobox.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qlistview.h> 24#include <qlistview.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27 27
28 28
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <time.h> 30#include <time.h>
31#include <dirent.h> 31#include <dirent.h>
32#include <fcntl.h> 32#include <fcntl.h>
33#include <sys/vfs.h> 33#include <sys/vfs.h>
34#include <mntent.h> 34#include <mntent.h>
35 35
36using namespace Opie::Ui;
37
36#ifdef NOQUICKLAUNCH 38#ifdef NOQUICKLAUNCH
37AdvancedFm::AdvancedFm( ) 39AdvancedFm::AdvancedFm( )
38#else 40#else
39AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) 41AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
40#endif 42#endif
41 : QMainWindow( ) { 43 : QMainWindow( ) {
42 init(); 44 init();
43 renameBox = 0; 45 renameBox = 0;
44 46
45 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 47 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
46 48
47 initConnections(); 49 initConnections();
48 whichTab=1; 50 whichTab=1;
49 rePopulate(); 51 rePopulate();
50 currentPathCombo->setFocus(); 52 currentPathCombo->setFocus();
51 channel = new QCopChannel( "QPE/Application/advancedfm", this ); 53 channel = new QCopChannel( "QPE/Application/advancedfm", this );
52 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 54 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
53 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 55 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
54} 56}
55 57
56AdvancedFm::~AdvancedFm() { 58AdvancedFm::~AdvancedFm() {
57} 59}
58 60
59 61
60void AdvancedFm::cleanUp() { 62void AdvancedFm::cleanUp() {
61 QString sfile=QDir::homeDirPath(); 63 QString sfile=QDir::homeDirPath();
62 if(sfile.right(1) != "/") 64 if(sfile.right(1) != "/")
63 sfile+="/._temp"; 65 sfile+="/._temp";
64 else 66 else
65 sfile+="._temp"; 67 sfile+="._temp";
66 QFile file( sfile); 68 QFile file( sfile);
67 if(file.exists()) 69 if(file.exists())
68 file.remove(); 70 file.remove();
69} 71}
70 72
71void AdvancedFm::tabChanged(QWidget *) { 73void AdvancedFm::tabChanged(QWidget *) {
72// qWarning("tab changed"); 74// qWarning("tab changed");
73 QString path = CurrentDir()->canonicalPath(); 75 QString path = CurrentDir()->canonicalPath();
74 currentPathCombo->lineEdit()->setText( path ); 76 currentPathCombo->lineEdit()->setText( path );
75 77
76 if(whichTab == 1) { 78 if(whichTab == 1) {
77 viewMenu->setItemChecked(viewMenu->idAt(0), true); 79 viewMenu->setItemChecked(viewMenu->idAt(0), true);
78 viewMenu->setItemChecked(viewMenu->idAt(1), false); 80 viewMenu->setItemChecked(viewMenu->idAt(1), false);
79 } else { 81 } else {
80 viewMenu->setItemChecked(viewMenu->idAt(0), false); 82 viewMenu->setItemChecked(viewMenu->idAt(0), false);
81 viewMenu->setItemChecked(viewMenu->idAt(1), true); 83 viewMenu->setItemChecked(viewMenu->idAt(1), true);
82 } 84 }
83 85
84 QString fs= getFileSystemType( (const QString &) path); 86 QString fs= getFileSystemType( (const QString &) path);
85 87
86 setCaption(tr("AdvancedFm :: ")+fs+" :: " 88 setCaption(tr("AdvancedFm :: ")+fs+" :: "
87 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 89 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
88 chdir( path.latin1()); 90 chdir( path.latin1());
89} 91}
90 92
91 93
92void AdvancedFm::populateView() { 94void AdvancedFm::populateView() {
93 95
94// qWarning("PopulateView"); 96// qWarning("PopulateView");
95 QPixmap pm; 97 QPixmap pm;
96 QListView *thisView = CurrentView(); 98 QListView *thisView = CurrentView();
97 QDir *thisDir = CurrentDir(); 99 QDir *thisDir = CurrentDir();
98 QString path = thisDir->canonicalPath(); 100 QString path = thisDir->canonicalPath();
99 101
100//qWarning("path is "+path); 102//qWarning("path is "+path);
101 thisView->clear(); 103 thisView->clear();
102 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 104 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
103 thisDir->setMatchAllDirs(TRUE); 105 thisDir->setMatchAllDirs(TRUE);
104 thisDir->setNameFilter(filterStr); 106 thisDir->setNameFilter(filterStr);
105 QString fileL, fileS, fileDate; 107 QString fileL, fileS, fileDate;
106 QString fs= getFileSystemType((const QString &) path); 108 QString fs= getFileSystemType((const QString &) path);
107 setCaption(tr("AdvancedFm :: ")+fs+" :: " 109 setCaption(tr("AdvancedFm :: ")+fs+" :: "
108 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 110 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
109 bool isDir=FALSE; 111 bool isDir=FALSE;
110 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 112 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
111 QFileInfoListIterator it(*list); 113 QFileInfoListIterator it(*list);
112 QFileInfo *fi; 114 QFileInfo *fi;
113 while ( (fi=it.current()) ) { 115 while ( (fi=it.current()) ) {
114 if (fi->isSymLink() ) { 116 if (fi->isSymLink() ) {
115 QString symLink=fi->readLink(); 117 QString symLink=fi->readLink();
116 QFileInfo sym( symLink); 118 QFileInfo sym( symLink);
117 fileS.sprintf( "%10i", sym.size() ); 119 fileS.sprintf( "%10i", sym.size() );
118 fileL = fi->fileName() +" -> " + sym.filePath().data(); 120 fileL = fi->fileName() +" -> " + sym.filePath().data();
119 fileDate = sym.lastModified().toString(); 121 fileDate = sym.lastModified().toString();
120 } else { 122 } else {
121 fileS.sprintf( "%10i", fi->size() ); 123 fileS.sprintf( "%10i", fi->size() );
122 fileL = fi->fileName(); 124 fileL = fi->fileName();
123 fileDate= fi->lastModified().toString(); 125 fileDate= fi->lastModified().toString();
124 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 126 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
125// if(fileL == "..") 127// if(fileL == "..")
126 fileL += "/"; 128 fileL += "/";
127 isDir=TRUE; 129 isDir=TRUE;
128 } 130 }
129 } 131 }
130 QFileInfo fileInfo( path + "/" + fileL); 132 QFileInfo fileInfo( path + "/" + fileL);
131 133
132 if(fileL !="./" && fi->exists()) { 134 if(fileL !="./" && fi->exists()) {
133 item = new QListViewItem( thisView, fileL, fileS , fileDate); 135 item = new QListViewItem( thisView, fileL, fileS , fileDate);
134 136
135 if(isDir || fileL.find("/",0,TRUE) != -1) { 137 if(isDir || fileL.find("/",0,TRUE) != -1) {
136 138
137 if( !QDir( fi->filePath() ).isReadable()) //is directory 139 if( !QDir( fi->filePath() ).isReadable()) //is directory
138 pm = Resource::loadPixmap( "lockedfolder" ); 140 pm = Resource::loadPixmap( "lockedfolder" );
139 else 141 else
140 pm= Resource::loadPixmap( "folder" ); 142 pm= Resource::loadPixmap( "folder" );
141 } 143 }
142 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 144 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
143 pm = Resource::loadPixmap( "exec"); 145 pm = Resource::loadPixmap( "exec");
144 } 146 }
145 else if( (fileInfo.permission( QFileInfo::ExeUser) 147 else if( (fileInfo.permission( QFileInfo::ExeUser)
146 | fileInfo.permission( QFileInfo::ExeGroup) 148 | fileInfo.permission( QFileInfo::ExeGroup)
147 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 149 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
148 pm = Resource::loadPixmap( "exec"); 150 pm = Resource::loadPixmap( "exec");
149 } 151 }
150 else if( !fi->isReadable() ) { 152 else if( !fi->isReadable() ) {
151 pm = Resource::loadPixmap( "locked" ); 153 pm = Resource::loadPixmap( "locked" );
152 } 154 }
153 else { //everything else goes by mimetype 155 else { //everything else goes by mimetype
154 MimeType mt(fi->filePath()); 156 MimeType mt(fi->filePath());
155 pm=mt.pixmap(); //sets the correct pixmap for mimetype 157 pm=mt.pixmap(); //sets the correct pixmap for mimetype
156 if(pm.isNull()) { 158 if(pm.isNull()) {
157 pm = unknownXpm; 159 pm = unknownXpm;
158 } 160 }
159 } 161 }
160 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 162 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
161 // qDebug(" overlay link image"); 163 // qDebug(" overlay link image");
162 pm= Resource::loadPixmap( "advancedfm/symlink" ); 164 pm= Resource::loadPixmap( "advancedfm/symlink" );
163 // pm= Resource::loadPixmap( "folder" ); 165 // pm= Resource::loadPixmap( "folder" );
164// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 166// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
165// QPainter painter( &pm ); 167// QPainter painter( &pm );
166// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 168// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
167// pm.setMask( pm.createHeuristicMask( FALSE ) ); 169// pm.setMask( pm.createHeuristicMask( FALSE ) );
168 } 170 }
169 item->setPixmap( 0,pm); 171 item->setPixmap( 0,pm);
170 172
171 } 173 }
172 isDir=FALSE; 174 isDir=FALSE;
173 ++it; 175 ++it;
174 } 176 }
175 177
176 if( path.find("dev",0,TRUE) != -1) { 178 if( path.find("dev",0,TRUE) != -1) {
177 struct stat buf; 179 struct stat buf;
178 dev_t devT; 180 dev_t devT;
179 DIR *dir; 181 DIR *dir;
180 struct dirent *mydirent; 182 struct dirent *mydirent;
181 183
182 if((dir = opendir( path.latin1())) != NULL) 184 if((dir = opendir( path.latin1())) != NULL)
183 while ((mydirent = readdir(dir)) != NULL) { 185 while ((mydirent = readdir(dir)) != NULL) {
184 lstat( mydirent->d_name, &buf); 186 lstat( mydirent->d_name, &buf);
185// qDebug(mydirent->d_name); 187// qDebug(mydirent->d_name);
186 fileL.sprintf("%s", mydirent->d_name); 188 fileL.sprintf("%s", mydirent->d_name);
187 devT = buf.st_dev; 189 devT = buf.st_dev;
188 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
189 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 191 fileDate.sprintf("%s", ctime( &buf.st_mtime));
190 if( fileL.find(".") == -1 ) { 192 if( fileL.find(".") == -1 ) {
191 item= new QListViewItem( thisView, fileL, fileS, fileDate); 193 item= new QListViewItem( thisView, fileL, fileS, fileDate);
192 pm = unknownXpm; 194 pm = unknownXpm;
193 item->setPixmap( 0,pm); 195 item->setPixmap( 0,pm);
194 } 196 }
195 } 197 }
196 198
197 closedir(dir); 199 closedir(dir);
198 } 200 }
199 201
200 thisView->setSorting( 3,FALSE); 202 thisView->setSorting( 3,FALSE);
201 fillCombo( (const QString &) path ); 203 fillCombo( (const QString &) path );
202} 204}
203 205
204void AdvancedFm::rePopulate() { 206void AdvancedFm::rePopulate() {
205 populateView(); 207 populateView();
206 setOtherTabCurrent(); 208 setOtherTabCurrent();
207 populateView(); 209 populateView();
208 210
209// int tmpTab = whichTab; 211// int tmpTab = whichTab;
210// // qDebug("%d", tmpTab); 212// // qDebug("%d", tmpTab);
211 213
212// for(int i =1; i < 3; i++) { 214// for(int i =1; i < 3; i++) {
213// TabWidget->setCurrentWidget(i - 1); 215// TabWidget->setCurrentWidget(i - 1);
214// populateView(); 216// populateView();
215// } 217// }
216// TabWidget->setCurrentWidget( tmpTab - 1); 218// TabWidget->setCurrentWidget( tmpTab - 1);
217} 219}
218 220
219void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 221void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
220//qWarning("listclicked"); 222//qWarning("listclicked");
221 if(selectedItem) { 223 if(selectedItem) {
222 QString strItem=selectedItem->text(0); 224 QString strItem=selectedItem->text(0);
223// qWarning(strItem); 225// qWarning(strItem);
224 QString strSize=selectedItem->text(1); 226 QString strSize=selectedItem->text(1);
225 strSize=strSize.stripWhiteSpace(); 227 strSize=strSize.stripWhiteSpace();
226 bool isDirectory = false; 228 bool isDirectory = false;
227 QString strItem2; 229 QString strItem2;
228 230
229 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink 231 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
230 strItem2 = dealWithSymName((const QString&)strItem); 232 strItem2 = dealWithSymName((const QString&)strItem);
231 if(QDir(strItem2).exists() ) 233 if(QDir(strItem2).exists() )
232 strItem = strItem2; 234 strItem = strItem2;
233 } 235 }
234 236
235 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 237 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
236 238
237 if(QDir(strItem).exists()) 239 if(QDir(strItem).exists())
238 isDirectory = true; 240 isDirectory = true;
239 } 241 }
240 242
241 if( isDirectory ) { 243 if( isDirectory ) {
242 CurrentDir()->cd( strItem, TRUE); 244 CurrentDir()->cd( strItem, TRUE);
243 populateView(); 245 populateView();
244 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 246 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
245 } 247 }
246 chdir( strItem.latin1()); 248 chdir( strItem.latin1());
247 } 249 }
248} 250}
249 251
250void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { 252void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
251 dealWithSchmooSchmaa( item->listView()); 253 dealWithSchmooSchmaa( item->listView());
252 switch (mouse) { 254 switch (mouse) {
253 case 1: 255 case 1:
254 { 256 {
255 if(renameBox != 0 ) { 257 if(renameBox != 0 ) {
256 cancelRename(); 258 cancelRename();
257 } 259 }
258 } 260 }
259 break; 261 break;
260 case 2: 262 case 2:
261 menuTimer.start( 500, TRUE ); 263 menuTimer.start( 500, TRUE );
262 break; 264 break;
263 }; 265 };
264} 266}
265 267
266 268
267void AdvancedFm::switchToLocalTab() { 269void AdvancedFm::switchToLocalTab() {
268//qWarning("switch to local view"); 270//qWarning("switch to local view");
269 TabWidget->setCurrentWidget(0); 271 TabWidget->setCurrentWidget(0);
270 Local_View->setFocus(); 272 Local_View->setFocus();
271} 273}
272 274
273void AdvancedFm::switchToRemoteTab() { 275void AdvancedFm::switchToRemoteTab() {
274//qWarning("switch to local view"); 276//qWarning("switch to local view");
275 TabWidget->setCurrentWidget(1); 277 TabWidget->setCurrentWidget(1);
276 Remote_View->setFocus(); 278 Remote_View->setFocus();
277} 279}
278 280
279void AdvancedFm::readConfig() { 281void AdvancedFm::readConfig() {
280 Config cfg("AdvancedFm"); 282 Config cfg("AdvancedFm");
281} 283}
282 284
283void AdvancedFm::writeConfig() { 285void AdvancedFm::writeConfig() {
284 Config cfg("AdvancedFm"); 286 Config cfg("AdvancedFm");
285} 287}
286 288
287void AdvancedFm::currentPathComboChanged() { 289void AdvancedFm::currentPathComboChanged() {
288 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 290 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
289 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 291 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
290 populateView(); 292 populateView();
291 } else { 293 } else {
292 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 294 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
293 } 295 }
294} 296}
295 297
296void AdvancedFm::fillCombo(const QString &currentPath) { 298void AdvancedFm::fillCombo(const QString &currentPath) {
297 299
298 if ( whichTab == 1) { 300 if ( whichTab == 1) {
299 currentPathCombo->lineEdit()->setText( currentPath); 301 currentPathCombo->lineEdit()->setText( currentPath);
300 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 302 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
301 currentPathCombo->clear(); 303 currentPathCombo->clear();
302 localDirPathStringList.prepend( currentPath ); 304 localDirPathStringList.prepend( currentPath );
303 currentPathCombo->insertStringList( localDirPathStringList,-1); 305 currentPathCombo->insertStringList( localDirPathStringList,-1);
304 } 306 }
305 } else { 307 } else {
306 currentPathCombo->lineEdit()->setText( currentPath); 308 currentPathCombo->lineEdit()->setText( currentPath);
307 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 309 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
308 currentPathCombo->clear(); 310 currentPathCombo->clear();
309 remoteDirPathStringList.prepend( currentPath ); 311 remoteDirPathStringList.prepend( currentPath );
310 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 312 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
311 } 313 }
312 } 314 }
313} 315}
314 316
315void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 317void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
316 chdir( currentPath.latin1() ); 318 chdir( currentPath.latin1() );
317 CurrentDir()->cd( currentPath, TRUE); 319 CurrentDir()->cd( currentPath, TRUE);
318 populateView(); 320 populateView();
319 update(); 321 update();
320} 322}
321 323
322QStringList AdvancedFm::getPath() { 324QStringList AdvancedFm::getPath() {
323 QStringList strList; 325 QStringList strList;
324 QListView *thisView=CurrentView(); 326 QListView *thisView=CurrentView();
325 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 327 QList<QListViewItem> * getSelectedItems( QListView * thisView );
326 QListViewItemIterator it( thisView ); 328 QListViewItemIterator it( thisView );
327 for ( ; it.current(); ++it ) { 329 for ( ; it.current(); ++it ) {
328 if ( it.current()->isSelected() ) { 330 if ( it.current()->isSelected() ) {
329 strList << it.current()->text(0); 331 strList << it.current()->text(0);
330// qDebug(it.current()->text(0)); 332// qDebug(it.current()->text(0));
331 } 333 }
332 } 334 }
333 return strList; 335 return strList;
334} 336}
335 337
336void AdvancedFm::homeButtonPushed() { 338void AdvancedFm::homeButtonPushed() {
337 QString current = QDir::homeDirPath(); 339 QString current = QDir::homeDirPath();
338 chdir( current.latin1() ); 340 chdir( current.latin1() );
339 CurrentDir()->cd( current, TRUE); 341 CurrentDir()->cd( current, TRUE);
340 populateView(); 342 populateView();
341 update(); 343 update();
342} 344}
343 345
344void AdvancedFm::docButtonPushed() { 346void AdvancedFm::docButtonPushed() {
345 QString current = QPEApplication::documentDir(); 347 QString current = QPEApplication::documentDir();
346 chdir( current.latin1() ); 348 chdir( current.latin1() );
347 CurrentDir()->cd( current, TRUE); 349 CurrentDir()->cd( current, TRUE);
348 populateView(); 350 populateView();
349 update(); 351 update();
350} 352}
351 353
352void AdvancedFm::SDButtonPushed() { 354void AdvancedFm::SDButtonPushed() {
353 QString current = "/mnt/card";// this can change so fix 355 QString current = "/mnt/card";// this can change so fix
354 chdir( current.latin1() ); 356 chdir( current.latin1() );
355 CurrentDir()->cd( current, TRUE); 357 CurrentDir()->cd( current, TRUE);
356 populateView(); 358 populateView();
357 update(); 359 update();
358} 360}
359 361
360void AdvancedFm::CFButtonPushed() { 362void AdvancedFm::CFButtonPushed() {
361 QString current; 363 QString current;
362 if(zaurusDevice) 364 if(zaurusDevice)
363 current= "/mnt/cf"; //zaurus 365 current= "/mnt/cf"; //zaurus
364 else 366 else
365 current = "/mnt/hda"; //ipaq 367 current = "/mnt/hda"; //ipaq
366 chdir( current.latin1() ); 368 chdir( current.latin1() );
367 CurrentDir()->cd( current, TRUE); 369 CurrentDir()->cd( current, TRUE);
368 populateView(); 370 populateView();
369 update(); 371 update();
370} 372}
371 373
372 374
373void AdvancedFm::doAbout() { 375void AdvancedFm::doAbout() {
374 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 376 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
375 "is copyright 2002-2003 by\n" 377 "is copyright 2002-2003 by\n"
376 "L.J.Potter<llornkcor@handhelds.org>\n" 378 "L.J.Potter<llornkcor@handhelds.org>\n"
377 "and is licensed by the GPL")); 379 "and is licensed by the GPL"));
378} 380}
379 381
380void AdvancedFm::keyPressEvent( QKeyEvent *e) { 382void AdvancedFm::keyPressEvent( QKeyEvent *e) {
381// qWarning("key %d", e->key()); 383// qWarning("key %d", e->key());
382// if( CurrentView()->hasFocus() ) 384// if( CurrentView()->hasFocus() )
383 { 385 {
384 switch ( e->key() ) { 386 switch ( e->key() ) {
385 case Key_Left: 387 case Key_Left:
386 upDir(); 388 upDir();
387 break; 389 break;
388 case Key_Next: 390 case Key_Next:
389 break; 391 break;
390 case Key_Return: 392 case Key_Return:
391 case Key_Enter: 393 case Key_Enter:
392 navigateToSelected(); 394 navigateToSelected();
393 break; 395 break;
394 case Key_Tab: { 396 case Key_Tab: {
395 setOtherTabCurrent(); 397 setOtherTabCurrent();
396 } 398 }
397 break; 399 break;
398 case Key_Delete: 400 case Key_Delete:
399 del(); 401 del();
400 break; 402 break;
401 case Key_A: 403 case Key_A:
402 copyAs(); 404 copyAs();
403 break; 405 break;
404 case Key_C: 406 case Key_C:
405 copy(); 407 copy();
406 break; 408 break;
407 case Key_E: 409 case Key_E:
408 runThis(); 410 runThis();
409 break; 411 break;
410 case Key_G: 412 case Key_G:
411 { 413 {
412 currentPathCombo->lineEdit()->setFocus(); 414 currentPathCombo->lineEdit()->setFocus();
413 } 415 }
414 break; 416 break;
415 417
416 case Key_H: 418 case Key_H:
417 showHidden(); 419 showHidden();
418 break; 420 break;
419 case Key_I: 421 case Key_I:
420 fileStatus(); 422 fileStatus();
421 break; 423 break;
422 case Key_M: 424 case Key_M:
423 move(); 425 move();
424 break; 426 break;
425 case Key_N: 427 case Key_N:
426 mkDir(); 428 mkDir();
427 break; 429 break;
428 case Key_P: 430 case Key_P:
429 filePerms(); 431 filePerms();
430 break; 432 break;
431 case Key_R: 433 case Key_R:
432 rn(); 434 rn();
433 break; 435 break;
434 case Key_U: 436 case Key_U:
435 upDir(); 437 upDir();
436 break; 438 break;
437 case Key_1: 439 case Key_1:
438 switchToLocalTab(); 440 switchToLocalTab();
439 break; 441 break;
440 case Key_2: 442 case Key_2:
441 switchToRemoteTab(); 443 switchToRemoteTab();
442 break; 444 break;
443 case Key_3: 445 case Key_3:
444 CFButtonPushed(); 446 CFButtonPushed();
445 break; 447 break;
446 case Key_4: 448 case Key_4:
447 SDButtonPushed(); 449 SDButtonPushed();
448 break; 450 break;
449 case Key_5: 451 case Key_5:
450 homeButtonPushed(); 452 homeButtonPushed();
451 break; 453 break;
452 case Key_6: 454 case Key_6:
453 docButtonPushed(); 455 docButtonPushed();
454 break; 456 break;
455 case Key_7: 457 case Key_7:
456 break; 458 break;
457 case Key_8: 459 case Key_8:
458 break; 460 break;
459 case Key_9: 461 case Key_9:
460 break; 462 break;
461 case Key_0: 463 case Key_0:
462 break; 464 break;
463 }; 465 };
464 e->accept(); 466 e->accept();
465 } 467 }
466} 468}
467 469
468void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 470void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
469 if( CurrentView()->hasFocus() ) 471 if( CurrentView()->hasFocus() )
470 e->ignore(); 472 e->ignore();
471} 473}
472 474
473 475
474void AdvancedFm::QPEButtonPushed() { 476void AdvancedFm::QPEButtonPushed() {
475 QString current = QPEApplication::qpeDir(); 477 QString current = QPEApplication::qpeDir();
476 chdir( current.latin1() ); 478 chdir( current.latin1() );
477 CurrentDir()->cd( current, TRUE); 479 CurrentDir()->cd( current, TRUE);
478 populateView(); 480 populateView();
479 update(); 481 update();
480} 482}
481 483
482void AdvancedFm::parsetab(const QString &fileName) { 484void AdvancedFm::parsetab(const QString &fileName) {
483 485
484 fileSystemTypeList.clear(); 486 fileSystemTypeList.clear();
485 fsList.clear(); 487 fsList.clear();
486 struct mntent *me; 488 struct mntent *me;
487 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 489 FILE *mntfp = setmntent( fileName.latin1(), "r" );
488 if ( mntfp ) { 490 if ( mntfp ) {
489 while ( (me = getmntent( mntfp )) != 0 ) { 491 while ( (me = getmntent( mntfp )) != 0 ) {
490 QString deviceName = me->mnt_fsname; 492 QString deviceName = me->mnt_fsname;
491 QString filesystemType = me->mnt_type; 493 QString filesystemType = me->mnt_type;
492 QString mountDir = me->mnt_dir; 494 QString mountDir = me->mnt_dir;
493 if(deviceName != "none") { 495 if(deviceName != "none") {
494 if( fsList.contains(filesystemType) == 0 496 if( fsList.contains(filesystemType) == 0
495 & filesystemType.find("proc",0,TRUE) == -1 497 & filesystemType.find("proc",0,TRUE) == -1
496 & filesystemType.find("cramfs",0,TRUE) == -1 498 & filesystemType.find("cramfs",0,TRUE) == -1
497 & filesystemType.find("auto",0,TRUE) == -1) 499 & filesystemType.find("auto",0,TRUE) == -1)
498 fsList << filesystemType; 500 fsList << filesystemType;
499 fileSystemTypeList << mountDir+"::"+filesystemType; 501 fileSystemTypeList << mountDir+"::"+filesystemType;
500 } 502 }
501 } 503 }
502 } 504 }
503 endmntent( mntfp ); 505 endmntent( mntfp );
504} 506}
505 507
506QString AdvancedFm::getFileSystemType(const QString &currentText) { 508QString AdvancedFm::getFileSystemType(const QString &currentText) {
507 parsetab("/etc/mtab"); //why did TT forget filesystem type? 509 parsetab("/etc/mtab"); //why did TT forget filesystem type?
508 QString current = currentText;//.right( currentText.length()-1); 510 QString current = currentText;//.right( currentText.length()-1);
509 QString baseFs; 511 QString baseFs;
510 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 512 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
511 QString temp = (*it); 513 QString temp = (*it);
512 QString path = temp.left(temp.find("::",0,TRUE) ); 514 QString path = temp.left(temp.find("::",0,TRUE) );
513 path = path.right( path.length()-1); 515 path = path.right( path.length()-1);
514 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 516 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
515 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 517 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
516 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 518 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
517 } 519 }
518 } 520 }
519 return baseFs; 521 return baseFs;
520} 522}
521 523
522QString AdvancedFm::getDiskSpace( const QString &path) { 524QString AdvancedFm::getDiskSpace( const QString &path) {
523 struct statfs fss; 525 struct statfs fss;
524 if ( !statfs( path.latin1(), &fss ) ) { 526 if ( !statfs( path.latin1(), &fss ) ) {
525 int blkSize = fss.f_bsize; 527 int blkSize = fss.f_bsize;
526 // int totalBlks = fs.f_blocks; 528 // int totalBlks = fs.f_blocks;
527 int availBlks = fss.f_bavail; 529 int availBlks = fss.f_bavail;
528 530
529 long mult = blkSize / 1024; 531 long mult = blkSize / 1024;
530 long div = 1024 / blkSize; 532 long div = 1024 / blkSize;
531 if ( !mult ) mult = 1; 533 if ( !mult ) mult = 1;
532 if ( !div ) div = 1; 534 if ( !div ) div = 1;
533 535
534 return QString::number(availBlks * mult / div); 536 return QString::number(availBlks * mult / div);
535 } 537 }
536 return ""; 538 return "";
537} 539}
538 540
539 541
540void AdvancedFm::showFileMenu() { 542void AdvancedFm::showFileMenu() {
541 QString curApp; 543 QString curApp;
542 curApp = CurrentView()->currentItem()->text(0); 544 curApp = CurrentView()->currentItem()->text(0);
543 545
544 MimeType mt( curApp ); 546 MimeType mt( curApp );
545 const AppLnk* app = mt.application(); 547 const AppLnk* app = mt.application();
546 QFile fi(curApp); 548 QFile fi(curApp);
547 QPopupMenu *m = new QPopupMenu(0); 549 QPopupMenu *m = new QPopupMenu(0);
548 QPopupMenu *n = new QPopupMenu(0); 550 QPopupMenu *n = new QPopupMenu(0);
549 // QPopupMenu *o = new QPopupMenu(0); 551 // QPopupMenu *o = new QPopupMenu(0);
550 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 552 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
551 553
552 if ( QFileInfo(fi).isDir() ) { 554 if ( QFileInfo(fi).isDir() ) {
553 m->insertSeparator(); 555 m->insertSeparator();
554 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 556 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
555 } else { 557 } else {
556 558
557 if ( app ) 559 if ( app )
558 m->insertItem( app->pixmap(), tr( "Open in " 560 m->insertItem( app->pixmap(), tr( "Open in "
559 + app->name() ), this, SLOT( runThis() ) ); 561 + app->name() ), this, SLOT( runThis() ) );
560 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 562 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
561 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 563 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
562 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 564 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
563 } 565 }
564 566
565 m->insertItem(tr("Actions"),n); 567 m->insertItem(tr("Actions"),n);
566 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 568 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
567 569
568 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 570 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
569 571
570 n->insertSeparator(); 572 n->insertSeparator();
571 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 573 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
572 574
573 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 575 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
574 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 576 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
575 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 577 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
576 n->insertItem( tr( "Move" ), this, SLOT( move() )); 578 n->insertItem( tr( "Move" ), this, SLOT( move() ));
577 579
578 n->insertSeparator(); 580 n->insertSeparator();
579 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 581 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
580 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 582 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
581 583
582 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 584 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
583 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 585 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
584 586
585 m->insertSeparator(); 587 m->insertSeparator();
586 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 588 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
587 589
588#if defined(QT_QWS_OPIE) 590#if defined(QT_QWS_OPIE)
589 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 591 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
590#endif 592#endif
591 m->setCheckable(TRUE); 593 m->setCheckable(TRUE);
592 if (!b) 594 if (!b)
593 m->setItemChecked(m->idAt(0),TRUE); 595 m->setItemChecked(m->idAt(0),TRUE);
594 else 596 else
595 m->setItemChecked(m->idAt(0),FALSE); 597 m->setItemChecked(m->idAt(0),FALSE);
596 598
597 if(Ir::supported()) 599 if(Ir::supported())
598 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 600 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
599 m->setFocus(); 601 m->setFocus();
600 602
601 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 603 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
602 604
603 if(m) delete m; 605 if(m) delete m;
604} 606}
605 607
606 608
607void AdvancedFm::cancelMenuTimer() { 609void AdvancedFm::cancelMenuTimer() {
608 610
609 if( menuTimer.isActive() ) 611 if( menuTimer.isActive() )
610 menuTimer.stop(); 612 menuTimer.stop();
611} 613}
612 614
613QString AdvancedFm::checkDiskSpace(const QString &path) { 615QString AdvancedFm::checkDiskSpace(const QString &path) {
614 struct statfs fss; 616 struct statfs fss;
615 if ( !statfs( path.latin1(), &fss ) ) { 617 if ( !statfs( path.latin1(), &fss ) ) {
616 int blkSize = fss.f_bsize; 618 int blkSize = fss.f_bsize;
617// int totalBlks = fs.f_blocks; 619// int totalBlks = fs.f_blocks;
618 int availBlks = fss.f_bavail; 620 int availBlks = fss.f_bavail;
619 621
620 long mult = blkSize / 1024; 622 long mult = blkSize / 1024;
621 long div = 1024 / blkSize; 623 long div = 1024 / blkSize;
622 if ( !mult ) mult = 1; 624 if ( !mult ) mult = 1;
623 if ( !div ) div = 1; 625 if ( !div ) div = 1;
624 626
625 627
626 return QString::number(availBlks * mult / div); 628 return QString::number(availBlks * mult / div);
627 } 629 }
628 return ""; 630 return "";
629} 631}
630 632
631void AdvancedFm::addToDocs() { 633void AdvancedFm::addToDocs() {
632 QStringList strListPaths = getPath(); 634 QStringList strListPaths = getPath();
633 QDir *thisDir = CurrentDir(); 635 QDir *thisDir = CurrentDir();
634 636
635 if( strListPaths.count() > 0) { 637 if( strListPaths.count() > 0) {
636 QString curFile; 638 QString curFile;
637 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 639 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
638 curFile = thisDir->canonicalPath()+"/"+(*it); 640 curFile = thisDir->canonicalPath()+"/"+(*it);
639// qDebug(curFile); 641// qDebug(curFile);
640 QFileInfo fi(curFile); 642 QFileInfo fi(curFile);
641 DocLnk f; 643 DocLnk f;
642// curFile.replace(QRegExp("\\..*"),""); 644// curFile.replace(QRegExp("\\..*"),"");
643 f.setName(fi.baseName() ); 645 f.setName(fi.baseName() );
644 f.setFile( curFile); 646 f.setFile( curFile);
645 f.writeLink(); 647 f.writeLink();
646 } 648 }
647 } 649 }
648} 650}
649 651
650 652
651void AdvancedFm::customDirsToMenu() { 653void AdvancedFm::customDirsToMenu() {
652 654
653 Config cfg("AdvancedFm"); 655 Config cfg("AdvancedFm");
654 cfg.setGroup("Menu"); 656 cfg.setGroup("Menu");
655 657
656 QStringList list = cfg.readListEntry( "CustomDir", ','); 658 QStringList list = cfg.readListEntry( "CustomDir", ',');
657 menuButton->insertItems(list ); 659 menuButton->insertItems(list );
658 660
659// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 661// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
660// { 662// {
661// customDirMenu->insertItem(*it ); 663// customDirMenu->insertItem(*it );
662// } 664// }
663} 665}
664 666
665void AdvancedFm::dirMenuSelected(int item) { 667void AdvancedFm::dirMenuSelected(int item) {
666 switch(item) 668 switch(item)
667 { 669 {
668 670
669 case -21: 671 case -21:
670 case 0: 672 case 0:
671 addCustomDir(); 673 addCustomDir();
672 break; 674 break;
673 case -22: 675 case -22:
674 case 1: 676 case 1:
675 removeCustomDir(); 677 removeCustomDir();
676 break; 678 break;
677 default: 679 default:
678 { 680 {
679// gotoCustomDir( menuButton->text(item)); 681// gotoCustomDir( menuButton->text(item));
680// gotoCustomDir( customDirMenu->text(item)); 682// gotoCustomDir( customDirMenu->text(item));
681 } 683 }
682 break; 684 break;
683 685
684 }; 686 };
685} 687}
686 688
687void AdvancedFm::addCustomDir() { 689void AdvancedFm::addCustomDir() {
688 Config cfg("AdvancedFm"); 690 Config cfg("AdvancedFm");
689 cfg.setGroup("Menu"); 691 cfg.setGroup("Menu");
690 QString dir; 692 QString dir;
691 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 693 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
692 694
693 dir = CurrentDir()->canonicalPath(); 695 dir = CurrentDir()->canonicalPath();
694 696
695 bool addIt=true; 697 bool addIt=true;
696 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 698 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
697 if( dir == (*it)) { 699 if( dir == (*it)) {
698 addIt=false; 700 addIt=false;
699 } 701 }
700 } 702 }
701 if(addIt) { 703 if(addIt) {
702 menuButton->insertItem(dir); 704 menuButton->insertItem(dir);
703// customDirMenu->insertItem(dir); 705// customDirMenu->insertItem(dir);
704 list << dir; 706 list << dir;
705 } 707 }
706 708
707 cfg.writeEntry("CustomDir", list, ','); 709 cfg.writeEntry("CustomDir", list, ',');
708 cfg.write(); 710 cfg.write();
709} 711}
710 712
711void AdvancedFm::removeCustomDir() { 713void AdvancedFm::removeCustomDir() {
712// qDebug("remove custom dir"); 714// qDebug("remove custom dir");
713 Config cfg("AdvancedFm"); 715 Config cfg("AdvancedFm");
714 cfg.setGroup("Menu"); 716 cfg.setGroup("Menu");
715 QString dir; 717 QString dir;
716 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 718 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
717 QStringList list2; 719 QStringList list2;
718 dir = CurrentDir()->canonicalPath(); 720 dir = CurrentDir()->canonicalPath();
719 int ramble=2; 721 int ramble=2;
720// int ramble=-24; 722// int ramble=-24;
721//first remove list 723//first remove list
722 if(list.grep(dir,true).isEmpty()) { 724 if(list.grep(dir,true).isEmpty()) {
723 QMessageBox::message(tr( "AdvancedFm" ), 725 QMessageBox::message(tr( "AdvancedFm" ),
724 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 726 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
725 } else { 727 } else {
726 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 728 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
727 if((*it) != dir) { 729 if((*it) != dir) {
728//current item is not our current dir, so add it to temp list 730//current item is not our current dir, so add it to temp list
729 list2 <<(*it); 731 list2 <<(*it);
730 } else { 732 } else {
731// customDirMenu->removeItem( ramble); 733// customDirMenu->removeItem( ramble);
732 menuButton->remove( ramble); 734 menuButton->remove( ramble);
733 735
734 } 736 }
735 ramble++; 737 ramble++;
736// ramble--; 738// ramble--;
737 } 739 }
738 740
739 cfg.writeEntry("CustomDir", list2, ','); 741 cfg.writeEntry("CustomDir", list2, ',');
740 cfg.write(); 742 cfg.write();
741 } 743 }
742// customDirsToMenu(); 744// customDirsToMenu();
743 745
744} 746}
745 747
746void AdvancedFm::gotoCustomDir(const QString &dir) { 748void AdvancedFm::gotoCustomDir(const QString &dir) {
747// qDebug("gotoCustomDir(const QString &dir) " +dir ); 749// qDebug("gotoCustomDir(const QString &dir) " +dir );
748// QString curDir = dir; 750// QString curDir = dir;
749// QDir *thisDir = CurrentDir(); 751// QDir *thisDir = CurrentDir();
750// if( curDir.isEmpty()) { 752// if( curDir.isEmpty()) {
751// } 753// }
752 if( dir == s_addBookmark) { 754 if( dir == s_addBookmark) {
753 addCustomDir(); 755 addCustomDir();
754 } 756 }
755 if( dir == s_removeBookmark) { 757 if( dir == s_removeBookmark) {
756 removeCustomDir( ); 758 removeCustomDir( );
757 } else { 759 } else {
758 gotoDirectory( dir); 760 gotoDirectory( dir);
759// if(QDir( curDir).exists() ) 761// if(QDir( curDir).exists() )
760// { 762// {
761// thisDir->setPath( curDir ); 763// thisDir->setPath( curDir );
762// chdir( curDir.latin1() ); 764// chdir( curDir.latin1() );
763// thisDir->cd( curDir, TRUE); 765// thisDir->cd( curDir, TRUE);
764// populateView(); 766// populateView();
765// } 767// }
766 } 768 }
767} 769}
768 770
769QDir *AdvancedFm::CurrentDir() { 771QDir *AdvancedFm::CurrentDir() {
770 772
771 if ( whichTab == 1) { 773 if ( whichTab == 1) {
772 return &currentDir; 774 return &currentDir;
773 } else { 775 } else {
774 return &currentRemoteDir; 776 return &currentRemoteDir;
775 } 777 }
776} 778}
777 779
778QDir *AdvancedFm::OtherDir() { 780QDir *AdvancedFm::OtherDir() {
779 if ( whichTab == 1) { 781 if ( whichTab == 1) {
780 return &currentRemoteDir; 782 return &currentRemoteDir;
781 } else { 783 } else {
782 return &currentDir; 784 return &currentDir;
783 } 785 }
784} 786}
785 787
786QListView * AdvancedFm::CurrentView() { 788QListView * AdvancedFm::CurrentView() {
787 if ( whichTab == 1) { 789 if ( whichTab == 1) {
788// qWarning("CurrentView Tab 1"); 790// qWarning("CurrentView Tab 1");
789 return Local_View; 791 return Local_View;
790 } else { 792 } else {
791// qWarning("CurrentView Tab 2"); 793// qWarning("CurrentView Tab 2");
792 return Remote_View; 794 return Remote_View;
793 } 795 }
794} 796}
795 797
796QListView * AdvancedFm::OtherView() { 798QListView * AdvancedFm::OtherView() {
797 if ( whichTab == 1) 799 if ( whichTab == 1)
798 return Remote_View; 800 return Remote_View;
799 else 801 else
800 return Local_View; 802 return Local_View;
801} 803}
802 804
803void AdvancedFm::setOtherTabCurrent() { 805void AdvancedFm::setOtherTabCurrent() {
804// qWarning("setOtherTabCurrent() %d", whichTab); 806// qWarning("setOtherTabCurrent() %d", whichTab);
805 if ( whichTab == 1) { 807 if ( whichTab == 1) {
806 TabWidget->setCurrentWidget(1); 808 TabWidget->setCurrentWidget(1);
807 } else { 809 } else {
808 TabWidget->setCurrentWidget(0); 810 TabWidget->setCurrentWidget(0);
809 } 811 }
810 OtherView()->setFocus(); 812 OtherView()->setFocus();
811 OtherView()->setSelected( CurrentView()->firstChild(), true); 813 OtherView()->setSelected( CurrentView()->firstChild(), true);
812} 814}
813 815
814void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 816void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
815// qDebug("qcop message "+msg ); 817// qDebug("qcop message "+msg );
816 QDataStream stream ( data, IO_ReadOnly ); 818 QDataStream stream ( data, IO_ReadOnly );
817 if ( msg == "openDirectory(QString)" ) { 819 if ( msg == "openDirectory(QString)" ) {
818// qDebug("received"); 820// qDebug("received");
819 QString file; 821 QString file;
820 stream >> file; 822 stream >> file;
821 gotoDirectory( (const QString &) file); 823 gotoDirectory( (const QString &) file);
822 } 824 }
823} 825}
824 826
825void AdvancedFm::setDocument(const QString &file) { 827void AdvancedFm::setDocument(const QString &file) {
826 gotoDirectory( file); 828 gotoDirectory( file);
827 829
828} 830}
829 831
830void AdvancedFm::gotoDirectory(const QString &file) { 832void AdvancedFm::gotoDirectory(const QString &file) {
831// qWarning("goto dir "+file); 833// qWarning("goto dir "+file);
832 QString curDir = file; 834 QString curDir = file;
833 QDir *thisDir = CurrentDir(); 835 QDir *thisDir = CurrentDir();
834 if(QDir( curDir).exists() ) { 836 if(QDir( curDir).exists() ) {
835 thisDir->setPath( curDir ); 837 thisDir->setPath( curDir );
836 chdir( curDir.latin1() ); 838 chdir( curDir.latin1() );
837 thisDir->cd( curDir, TRUE); 839 thisDir->cd( curDir, TRUE);
838 populateView(); 840 populateView();
839 } 841 }
840 else if(QFileInfo(curDir).exists()) { 842 else if(QFileInfo(curDir).exists()) {
841 QFileInfo fileInfo(curDir); 843 QFileInfo fileInfo(curDir);
842 curDir=fileInfo.dirPath(); 844 curDir=fileInfo.dirPath();
843 if(QDir( curDir).exists() ) { 845 if(QDir( curDir).exists() ) {
844 thisDir->setPath( curDir ); 846 thisDir->setPath( curDir );
845 chdir( curDir.latin1() ); 847 chdir( curDir.latin1() );
846 thisDir->cd( curDir, TRUE); 848 thisDir->cd( curDir, TRUE);
847 populateView(); 849 populateView();
848 } 850 }
849 findFile(file); 851 findFile(file);
850 } 852 }
851 853
852} 854}
853 855
854void AdvancedFm::findFile(const QString &fileName) { 856void AdvancedFm::findFile(const QString &fileName) {
855 QFileInfo fi(fileName); 857 QFileInfo fi(fileName);
856 QListView *thisView = CurrentView(); 858 QListView *thisView = CurrentView();
857 QListViewItemIterator it( thisView ); 859 QListViewItemIterator it( thisView );
858 for ( ; it.current(); ++it ) { 860 for ( ; it.current(); ++it ) {
859 if(it.current()->text(0) == fi.fileName()) { 861 if(it.current()->text(0) == fi.fileName()) {
860 it.current()->setSelected(true); 862 it.current()->setSelected(true);
861 thisView->ensureItemVisible(it.current()); 863 thisView->ensureItemVisible(it.current());
862 } 864 }
863 } 865 }
864} 866}
865 867
866void AdvancedFm::slotSwitchMenu(int ) { 868void AdvancedFm::slotSwitchMenu(int ) {
867// qDebug("Switch %d", item); 869// qDebug("Switch %d", item);
868 // viewMenu->setItemChecked(item, true); 870 // viewMenu->setItemChecked(item, true);
869} 871}
870 872
871void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { 873void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
872 tabChanged( w); 874 tabChanged( w);
873 if( w == Local_View) { 875 if( w == Local_View) {
874 Remote_View->clearFocus(); 876 Remote_View->clearFocus();
875 } else { 877 } else {
876 Local_View->clearFocus(); 878 Local_View->clearFocus();
877 } 879 }
878} 880}
879 881
880void AdvancedFm::navigateToSelected() { 882void AdvancedFm::navigateToSelected() {
881 if( !CurrentView()->currentItem()) return; 883 if( !CurrentView()->currentItem()) return;
882 doDirChange(); 884 doDirChange();
883} 885}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 547fa7c..4eaa6d6 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,192 +1,191 @@
1/*************************************************************************** 1/***************************************************************************
2 advancedfm.h 2 advancedfm.h
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef ADVANCEDFM_H 12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H 13#define ADVANCEDFM_H
14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties 14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
15#define QT_QWS_OPIE 15#define QT_QWS_OPIE
16 16
17#include <opie2/oprocess.h> 17#include <opie2/oprocess.h>
18#include <opie2/osplitter.h> 18#include <opie2/osplitter.h>
19 19
20#include <qpe/ir.h> 20#include <qpe/ir.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22 22
23#include <qvariant.h> 23#include <qvariant.h>
24#include <qdialog.h> 24#include <qdialog.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qpoint.h> 29#include <qpoint.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpixmap.h> 31#include <qpixmap.h>
32 32
33using Opie::OSplitter;
34 33
35class QVBoxLayout; 34class QVBoxLayout;
36class QHBoxLayout; 35class QHBoxLayout;
37class QGridLayout; 36class QGridLayout;
38class QComboBox; 37class QComboBox;
39class QListView; 38class QListView;
40class QListviewItem; 39class QListviewItem;
41class QLabel; 40class QLabel;
42class QProgressBar; 41class QProgressBar;
43class QSpinBox; 42class QSpinBox;
44class QWidget; 43class QWidget;
45class QPopupMenu; 44class QPopupMenu;
46class QFile; 45class QFile;
47class QListViewItem; 46class QListViewItem;
48class QLineEdit; 47class QLineEdit;
49class MenuButton; 48class MenuButton;
50 49
51class QToolButton; 50class QToolButton;
52class Ir; 51class Ir;
53 52
54class AdvancedFm : public QMainWindow 53class AdvancedFm : public QMainWindow
55{ 54{
56 Q_OBJECT 55 Q_OBJECT
57public: 56public:
58 static QString appName() { return QString::fromLatin1("advancedfm"); } 57 static QString appName() { return QString::fromLatin1("advancedfm"); }
59#ifdef NOQUICKLAUNCH 58#ifdef NOQUICKLAUNCH
60 AdvancedFm(); 59 AdvancedFm();
61#else 60#else
62 AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0); 61 AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0);
63#endif 62#endif
64 ~AdvancedFm(); 63 ~AdvancedFm();
65protected slots: 64protected slots:
66 void slotSwitchMenu(int); 65 void slotSwitchMenu(int);
67 void selectAll(); 66 void selectAll();
68 void addToDocs(); 67 void addToDocs();
69 void doDirChange(); 68 void doDirChange();
70 void mkDir(); 69 void mkDir();
71 void del(); 70 void del();
72 void rn(); 71 void rn();
73 void populateView(); 72 void populateView();
74 void rePopulate(); 73 void rePopulate();
75 void showHidden(); 74 void showHidden();
76 void showMenuHidden(); 75 void showMenuHidden();
77 void writeConfig(); 76 void writeConfig();
78 void readConfig(); 77 void readConfig();
79 void ListClicked(QListViewItem *); 78 void ListClicked(QListViewItem *);
80 void ListPressed( int, QListViewItem *, const QPoint&, int); 79 void ListPressed( int, QListViewItem *, const QPoint&, int);
81 void makeDir(); 80 void makeDir();
82 void doDelete(); 81 void doDelete();
83 void tabChanged(QWidget*); 82 void tabChanged(QWidget*);
84 void cleanUp(); 83 void cleanUp();
85 void renameIt(); 84 void renameIt();
86 void runThis(); 85 void runThis();
87 void runText(); 86 void runText();
88 void filePerms(); 87 void filePerms();
89 void doProperties(); 88 void doProperties();
90 void runCommand(); 89 void runCommand();
91 void runCommandStd(); 90 void runCommandStd();
92 QStringList getPath(); 91 QStringList getPath();
93 void mkSym(); 92 void mkSym();
94 void switchToLocalTab(); 93 void switchToLocalTab();
95 void switchToRemoteTab(); 94 void switchToRemoteTab();
96 95
97protected: 96protected:
98 97
99 OSplitter *TabWidget; 98 Opie::Ui::OSplitter *TabWidget;
100 QCopChannel * channel; 99 QCopChannel * channel;
101 QPixmap unknownXpm; 100 QPixmap unknownXpm;
102 int whichTab; 101 int whichTab;
103// QTabWidget *TabWidget; 102// QTabWidget *TabWidget;
104 QWidget *tab, *tab_2, *tab_3; 103 QWidget *tab, *tab_2, *tab_3;
105 QListView *Local_View, *Remote_View; 104 QListView *Local_View, *Remote_View;
106 105
107 QLineEdit *currentPathEdit; 106 QLineEdit *currentPathEdit;
108 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; 107 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/;
109 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 108 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
110// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 109// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
111 QDir currentDir, currentRemoteDir; 110 QDir currentDir, currentRemoteDir;
112 QComboBox *currentPathCombo; 111 QComboBox *currentPathCombo;
113 QString filterStr, s_addBookmark, s_removeBookmark; 112 QString filterStr, s_addBookmark, s_removeBookmark;
114 QListViewItem * item; 113 QListViewItem * item;
115 bool b; 114 bool b;
116 QStringList fileSystemTypeList, fsList; 115 QStringList fileSystemTypeList, fsList;
117 int currentServerConfig; 116 int currentServerConfig;
118 bool zaurusDevice; 117 bool zaurusDevice;
119 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 118 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
120 QStringList remoteDirPathStringList, localDirPathStringList; 119 QStringList remoteDirPathStringList, localDirPathStringList;
121 QLineEdit *renameBox; 120 QLineEdit *renameBox;
122 121
123 void init(); 122 void init();
124 void initConnections(); 123 void initConnections();
125 void keyReleaseEvent( QKeyEvent *); 124 void keyReleaseEvent( QKeyEvent *);
126 void keyPressEvent( QKeyEvent *); 125 void keyPressEvent( QKeyEvent *);
127 QString getFileSystemType(const QString &); 126 QString getFileSystemType(const QString &);
128 QString getDiskSpace(const QString &); 127 QString getDiskSpace(const QString &);
129 void parsetab(const QString &fileName); 128 void parsetab(const QString &fileName);
130 QString checkDiskSpace(const QString &); 129 QString checkDiskSpace(const QString &);
131 QString dealWithSymName(const QString &); 130 QString dealWithSymName(const QString &);
132 QDir *CurrentDir(); 131 QDir *CurrentDir();
133 QDir *OtherDir(); 132 QDir *OtherDir();
134 QListView *CurrentView(); 133 QListView *CurrentView();
135 QListView *OtherView(); 134 QListView *OtherView();
136 void setOtherTabCurrent(); 135 void setOtherTabCurrent();
137 void dealWithSchmooSchmaa(QWidget *); 136 void dealWithSchmooSchmaa(QWidget *);
138 137
139protected slots: 138protected slots:
140 void openSearch(); 139 void openSearch();
141 void dirMenuSelected(int); 140 void dirMenuSelected(int);
142 void showFileMenu(); 141 void showFileMenu();
143 void cancelMenuTimer(); 142 void cancelMenuTimer();
144 void homeButtonPushed(); 143 void homeButtonPushed();
145 void docButtonPushed(); 144 void docButtonPushed();
146 void SDButtonPushed(); 145 void SDButtonPushed();
147 void CFButtonPushed(); 146 void CFButtonPushed();
148 void QPEButtonPushed(); 147 void QPEButtonPushed();
149 void upDir(); 148 void upDir();
150 void currentPathComboChanged(); 149 void currentPathComboChanged();
151 void copy(); 150 void copy();
152 void copyAs(); 151 void copyAs();
153 void copySameDir(); 152 void copySameDir();
154 void currentPathComboActivated(const QString &); 153 void currentPathComboActivated(const QString &);
155 void fillCombo(const QString &); 154 void fillCombo(const QString &);
156 bool copyFile( const QString & , const QString & ); 155 bool copyFile( const QString & , const QString & );
157 void move(); 156 void move();
158 void fileStatus(); 157 void fileStatus();
159 void doAbout(); 158 void doAbout();
160 void doBeam(); 159 void doBeam();
161 void fileBeamFinished( Ir *); 160 void fileBeamFinished( Ir *);
162 bool copyDirectory( const QString & , const QString & ); 161 bool copyDirectory( const QString & , const QString & );
163// void navigateToSelected(); 162// void navigateToSelected();
164 bool moveDirectory( const QString & , const QString & ); 163 bool moveDirectory( const QString & , const QString & );
165// void slotSwitchtoLocal(int); 164// void slotSwitchtoLocal(int);
166 165
167private: 166private:
168 MenuButton *menuButton; 167 MenuButton *menuButton;
169 QString oldName; 168 QString oldName;
170 QTimer menuTimer; 169 QTimer menuTimer;
171 void startProcess(const QString &); 170 void startProcess(const QString &);
172 bool eventFilter( QObject * , QEvent * ); 171 bool eventFilter( QObject * , QEvent * );
173 void cancelRename(); 172 void cancelRename();
174 void doRename(QListView *); 173 void doRename(QListView *);
175 void okRename(); 174 void okRename();
176 void customDirsToMenu(); 175 void customDirsToMenu();
177 void addCustomDir(); 176 void addCustomDir();
178 void removeCustomDir(); 177 void removeCustomDir();
179 void gotoDirectory(const QString &); 178 void gotoDirectory(const QString &);
180 void navigateToSelected(); 179 void navigateToSelected();
181 void findFile(const QString &); 180 void findFile(const QString &);
182 181
183private slots: 182private slots:
184 void processEnded(OProcess *); 183 void processEnded(Opie::Core::OProcess *);
185 void oprocessStderr(OProcess *, char *, int); 184 void oprocessStderr(Opie::Core::OProcess *, char *, int);
186 void gotoCustomDir(const QString &); 185 void gotoCustomDir(const QString &);
187 void qcopReceive(const QCString&, const QByteArray&); 186 void qcopReceive(const QCString&, const QByteArray&);
188 void setDocument(const QString &); 187 void setDocument(const QString &);
189 188
190}; 189};
191 190
192#endif // ADVANCEDFM_H 191#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index f791c77..73ef8f9 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -1,286 +1,287 @@
1/*************************************************************************** 1/***************************************************************************
2 advancedfmData.cpp 2 advancedfmData.cpp
3 ------------------- 3 -------------------
4** Created: Mon 09-23-2002 13:24:11 4** Created: Mon 09-23-2002 13:24:11
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13 13
14#include <qpe/storage.h> 14#include <qpe/storage.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/menubutton.h> 17#include <qpe/menubutton.h>
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qhbox.h> 20#include <qhbox.h>
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qcombobox.h> 22#include <qcombobox.h>
23#include <qtoolbutton.h> 23#include <qtoolbutton.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qlistview.h> 25#include <qlistview.h>
26 26
27#include <sys/utsname.h> 27#include <sys/utsname.h>
28 28
29 29
30using namespace Opie::Ui;
30void AdvancedFm::init() { 31void AdvancedFm::init() {
31#if defined(QT_QWS_OPIE) 32#if defined(QT_QWS_OPIE)
32 qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); 33 qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!");
33#endif 34#endif
34 setCaption( tr( "AdvancedFm" ) ); 35 setCaption( tr( "AdvancedFm" ) );
35 36
36 QVBoxLayout *layout = new QVBoxLayout( this ); 37 QVBoxLayout *layout = new QVBoxLayout( this );
37 layout->setSpacing( 2); 38 layout->setSpacing( 2);
38 layout->setMargin( 2); 39 layout->setMargin( 2);
39 40
40 QMenuBar *menuBar = new QMenuBar(this); 41 QMenuBar *menuBar = new QMenuBar(this);
41 fileMenu = new QPopupMenu( this ); 42 fileMenu = new QPopupMenu( this );
42 viewMenu = new QPopupMenu( this ); 43 viewMenu = new QPopupMenu( this );
43// customDirMenu = new QPopupMenu( this ); 44// customDirMenu = new QPopupMenu( this );
44 45
45 layout->addWidget( menuBar ); 46 layout->addWidget( menuBar );
46 47
47 menuBar->insertItem( tr( "File" ), fileMenu); 48 menuBar->insertItem( tr( "File" ), fileMenu);
48 menuBar->insertItem( tr( "View" ), viewMenu); 49 menuBar->insertItem( tr( "View" ), viewMenu);
49 50
50 cdUpButton = new QToolButton( 0,"cdUpButton"); 51 cdUpButton = new QToolButton( 0,"cdUpButton");
51 cdUpButton->setPixmap(Resource::loadPixmap("up")); 52 cdUpButton->setPixmap(Resource::loadPixmap("up"));
52 cdUpButton->setAutoRaise( true ); 53 cdUpButton->setAutoRaise( true );
53 menuBar->insertItem( cdUpButton ); 54 menuBar->insertItem( cdUpButton );
54 55
55 56
56 QHBox *lineBox = new QHBox( this ); 57 QHBox *lineBox = new QHBox( this );
57 58
58 qpeDirButton= new QToolButton( 0,"QPEButton"); 59 qpeDirButton= new QToolButton( 0,"QPEButton");
59 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); 60 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
60 qpeDirButton->setAutoRaise( true ); 61 qpeDirButton->setAutoRaise( true );
61 menuBar->insertItem( qpeDirButton ); 62 menuBar->insertItem( qpeDirButton );
62 63
63 cfButton = new QToolButton( 0, "CFButton"); 64 cfButton = new QToolButton( 0, "CFButton");
64 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); 65 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
65 cfButton->setAutoRaise( true ); 66 cfButton->setAutoRaise( true );
66 menuBar->insertItem( cfButton ); 67 menuBar->insertItem( cfButton );
67 68
68 sdButton = new QToolButton( 0, "SDButton"); 69 sdButton = new QToolButton( 0, "SDButton");
69 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); 70 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard"));
70 sdButton->setAutoRaise( true ); 71 sdButton->setAutoRaise( true );
71 menuBar->insertItem( sdButton ); 72 menuBar->insertItem( sdButton );
72 73
73 docButton = new QToolButton( 0,"docsButton"); 74 docButton = new QToolButton( 0,"docsButton");
74 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 75 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
75 docButton->setAutoRaise( true ); 76 docButton->setAutoRaise( true );
76 menuBar->insertItem( docButton ); 77 menuBar->insertItem( docButton );
77 78
78 homeButton = new QToolButton( 0, "homeButton"); 79 homeButton = new QToolButton( 0, "homeButton");
79 homeButton->setPixmap(Resource::loadPixmap("home")); 80 homeButton->setPixmap(Resource::loadPixmap("home"));
80 homeButton->setAutoRaise( true ); 81 homeButton->setAutoRaise( true );
81 menuBar->insertItem( homeButton ); 82 menuBar->insertItem( homeButton );
82 83
83 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); 84 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() ));
84 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 85 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
85 fileMenu->insertSeparator(); 86 fileMenu->insertSeparator();
86 fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); 87 fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() ));
87 fileMenu->insertSeparator(); 88 fileMenu->insertSeparator();
88 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); 89 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
89 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); 90 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
90 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 91 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
91 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); 92 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
92 fileMenu->insertSeparator(); 93 fileMenu->insertSeparator();
93 fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 94 fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
94 fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); 95 fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() ));
95 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 96 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
96 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); 97 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
97 fileMenu->setCheckable(TRUE); 98 fileMenu->setCheckable(TRUE);
98 99
99 viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); 100 viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab()));
100 viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); 101 viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab()));
101// viewMenu->insertSeparator(); 102// viewMenu->insertSeparator();
102// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 103// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
103 viewMenu->setCheckable(true); 104 viewMenu->setCheckable(true);
104 viewMenu->setItemChecked( viewMenu->idAt(0), true); 105 viewMenu->setItemChecked( viewMenu->idAt(0), true);
105 viewMenu->setItemChecked( viewMenu->idAt(1), false); 106 viewMenu->setItemChecked( viewMenu->idAt(1), false);
106 107
107 s_addBookmark = tr("Bookmark Directory"); 108 s_addBookmark = tr("Bookmark Directory");
108 s_removeBookmark = tr("Remove Current Directory from Bookmarks"); 109 s_removeBookmark = tr("Remove Current Directory from Bookmarks");
109 110
110// menuButton->insertItem(""); 111// menuButton->insertItem("");
111 112
112// customDirMenu->insertItem(tr("Add This Directory")); 113// customDirMenu->insertItem(tr("Add This Directory"));
113// customDirMenu->insertItem(tr("Remove This Directory")); 114// customDirMenu->insertItem(tr("Remove This Directory"));
114// customDirMenu->insertSeparator(); 115// customDirMenu->insertSeparator();
115 116
116 menuButton = new MenuButton( lineBox ); 117 menuButton = new MenuButton( lineBox );
117 118
118 menuButton->setUseLabel(false); 119 menuButton->setUseLabel(false);
119 menuButton->setMaximumWidth( 20 ); 120 menuButton->setMaximumWidth( 20 );
120 menuButton->insertItem( s_addBookmark); 121 menuButton->insertItem( s_addBookmark);
121 menuButton->insertItem( s_removeBookmark); 122 menuButton->insertItem( s_removeBookmark);
122 menuButton->insertSeparator(); 123 menuButton->insertSeparator();
123 menuButton->setFocusPolicy(NoFocus); 124 menuButton->setFocusPolicy(NoFocus);
124 125
125 customDirsToMenu(); 126 customDirsToMenu();
126 127
127 currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); 128 currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" );
128 currentPathCombo->setEditable(TRUE); 129 currentPathCombo->setEditable(TRUE);
129 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 130 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
130 currentPathCombo->setFocusPolicy(NoFocus); 131 currentPathCombo->setFocusPolicy(NoFocus);
131 layout->addWidget( lineBox ); 132 layout->addWidget( lineBox );
132 133
133 134
134 TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); 135 TabWidget = new OSplitter( Horizontal, this, "TabWidget" );
135// TabWidget = new QTabWidget( this, "TabWidget" ); 136// TabWidget = new QTabWidget( this, "TabWidget" );
136 layout->addWidget( TabWidget, 4 ); 137 layout->addWidget( TabWidget, 4 );
137 138
138 tab = new QWidget( TabWidget, "tab" ); 139 tab = new QWidget( TabWidget, "tab" );
139 tabLayout = new QGridLayout( tab ); 140 tabLayout = new QGridLayout( tab );
140 tabLayout->setSpacing( 2); 141 tabLayout->setSpacing( 2);
141 tabLayout->setMargin( 2); 142 tabLayout->setMargin( 2);
142 143
143 Local_View = new QListView( tab, "Local_View" ); 144 Local_View = new QListView( tab, "Local_View" );
144 Local_View->addColumn( tr("File"),130); 145 Local_View->addColumn( tr("File"),130);
145 Local_View->addColumn( tr("Size"),-1); 146 Local_View->addColumn( tr("Size"),-1);
146 Local_View->setColumnAlignment(1,QListView::AlignRight); 147 Local_View->setColumnAlignment(1,QListView::AlignRight);
147 Local_View->addColumn( tr("Date"),-1); 148 Local_View->addColumn( tr("Date"),-1);
148 Local_View->setColumnAlignment(2,QListView::AlignRight); 149 Local_View->setColumnAlignment(2,QListView::AlignRight);
149 Local_View->setAllColumnsShowFocus(TRUE); 150 Local_View->setAllColumnsShowFocus(TRUE);
150 Local_View->setMultiSelection( TRUE ); 151 Local_View->setMultiSelection( TRUE );
151 Local_View->setSelectionMode(QListView::Extended); 152 Local_View->setSelectionMode(QListView::Extended);
152 Local_View->setFocusPolicy(StrongFocus); 153 Local_View->setFocusPolicy(StrongFocus);
153 Local_View->installEventFilter( this ); 154 Local_View->installEventFilter( this );
154 155
155 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 156 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
156 157
157 tabLayout->addWidget( Local_View, 0, 0 ); 158 tabLayout->addWidget( Local_View, 0, 0 );
158 159
159 TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); 160 TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1"));
160// TabWidget->insertTab( tab, tr("1")); 161// TabWidget->insertTab( tab, tr("1"));
161 162
162 tab_2 = new QWidget( TabWidget, "tab_2" ); 163 tab_2 = new QWidget( TabWidget, "tab_2" );
163 tabLayout_2 = new QGridLayout( tab_2 ); 164 tabLayout_2 = new QGridLayout( tab_2 );
164 tabLayout_2->setSpacing( 2); 165 tabLayout_2->setSpacing( 2);
165 tabLayout_2->setMargin( 2); 166 tabLayout_2->setMargin( 2);
166 167
167 Remote_View = new QListView( tab_2, "Remote_View" ); 168 Remote_View = new QListView( tab_2, "Remote_View" );
168 Remote_View->addColumn( tr("File"),130); 169 Remote_View->addColumn( tr("File"),130);
169 Remote_View->addColumn( tr("Size"),-1); 170 Remote_View->addColumn( tr("Size"),-1);
170 Remote_View->setColumnAlignment(1,QListView::AlignRight); 171 Remote_View->setColumnAlignment(1,QListView::AlignRight);
171 Remote_View->addColumn( tr("Date"),-1); 172 Remote_View->addColumn( tr("Date"),-1);
172 Remote_View->setColumnAlignment(2,QListView::AlignRight); 173 Remote_View->setColumnAlignment(2,QListView::AlignRight);
173 Remote_View->setAllColumnsShowFocus(TRUE); 174 Remote_View->setAllColumnsShowFocus(TRUE);
174 Remote_View->setMultiSelection( TRUE ); 175 Remote_View->setMultiSelection( TRUE );
175 Remote_View->setSelectionMode(QListView::Extended); 176 Remote_View->setSelectionMode(QListView::Extended);
176 Remote_View->setFocusPolicy(StrongFocus); 177 Remote_View->setFocusPolicy(StrongFocus);
177 Remote_View->installEventFilter( this ); 178 Remote_View->installEventFilter( this );
178 179
179 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 180 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
180 181
181 tabLayout_2->addWidget( Remote_View, 0, 0 ); 182 tabLayout_2->addWidget( Remote_View, 0, 0 );
182 183
183 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); 184 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
184 TabWidget->setSizeChange( 370 ); 185 TabWidget->setSizeChange( 370 );
185// TabWidget->insertTab( tab_2, tr( "2")); 186// TabWidget->insertTab( tab_2, tr( "2"));
186 187
187 /* tab_3 = new QWidget( TabWidget, "tab_3" ); 188 /* tab_3 = new QWidget( TabWidget, "tab_3" );
188 tabLayout_3 = new QGridLayout( tab_3 ); 189 tabLayout_3 = new QGridLayout( tab_3 );
189 tabLayout_3->setSpacing( 2); 190 tabLayout_3->setSpacing( 2);
190 tabLayout_3->setMargin( 2); 191 tabLayout_3->setMargin( 2);
191 192
192 193
193 // OFileDialog fileDialog; 194 // OFileDialog fileDialog;
194 // fileDialog; 195 // fileDialog;
195 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy 196 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
196 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); 197 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
197 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); 198 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
198 199
199 QListView *fileTree; 200 QListView *fileTree;
200 fileTree = new QListView( tab_3, "tree" ); 201 fileTree = new QListView( tab_3, "tree" );
201 202
202 203
203 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); 204 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
204 205
205 TabWidget->insertTab( tab_3, tr( "Remote" ) ); 206 TabWidget->insertTab( tab_3, tr( "Remote" ) );
206 */ 207 */
207 208
208 /////////////// 209 ///////////////
209 210
210 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 211 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
211 zaurusDevice=TRUE; 212 zaurusDevice=TRUE;
212 else 213 else
213 zaurusDevice=FALSE; 214 zaurusDevice=FALSE;
214 215
215 216
216 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { 217 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
217 qDebug("not have sd"); 218 qDebug("not have sd");
218 sdButton->hide(); 219 sdButton->hide();
219 } 220 }
220 if( !StorageInfo::hasCf() ) { 221 if( !StorageInfo::hasCf() ) {
221 qDebug("not have cf"); 222 qDebug("not have cf");
222 cfButton->hide(); 223 cfButton->hide();
223 } 224 }
224 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 225 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
225 currentDir.setPath( QDir::currentDirPath()); 226 currentDir.setPath( QDir::currentDirPath());
226 227
227 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 228 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
228 currentRemoteDir.setPath( QDir::currentDirPath()); 229 currentRemoteDir.setPath( QDir::currentDirPath());
229 230
230 // b = TRUE; 231 // b = TRUE;
231 232
232 filterStr="*"; 233 filterStr="*";
233 b=FALSE; 234 b=FALSE;
234 showMenuHidden(); 235 showMenuHidden();
235 TabWidget->setCurrentWidget(0); 236 TabWidget->setCurrentWidget(0);
236 237
237} 238}
238 239
239void AdvancedFm::initConnections() 240void AdvancedFm::initConnections()
240{ 241{
241 242
242 connect( qApp,SIGNAL( aboutToQuit()), 243 connect( qApp,SIGNAL( aboutToQuit()),
243 this, SLOT( cleanUp()) ); 244 this, SLOT( cleanUp()) );
244 connect( qpeDirButton ,SIGNAL(released()), 245 connect( qpeDirButton ,SIGNAL(released()),
245 this,SLOT( QPEButtonPushed()) ); 246 this,SLOT( QPEButtonPushed()) );
246 connect( cfButton ,SIGNAL(released()), 247 connect( cfButton ,SIGNAL(released()),
247 this,SLOT( CFButtonPushed()) ); 248 this,SLOT( CFButtonPushed()) );
248 connect( sdButton ,SIGNAL(released()), 249 connect( sdButton ,SIGNAL(released()),
249 this,SLOT( SDButtonPushed()) ); 250 this,SLOT( SDButtonPushed()) );
250 connect( cdUpButton ,SIGNAL(released()), 251 connect( cdUpButton ,SIGNAL(released()),
251 this,SLOT( upDir()) ); 252 this,SLOT( upDir()) );
252 connect( docButton,SIGNAL(released()), 253 connect( docButton,SIGNAL(released()),
253 this,SLOT( docButtonPushed()) ); 254 this,SLOT( docButtonPushed()) );
254 connect( homeButton,SIGNAL(released()), 255 connect( homeButton,SIGNAL(released()),
255 this,SLOT( homeButtonPushed()) ); 256 this,SLOT( homeButtonPushed()) );
256 connect( currentPathCombo, SIGNAL( activated(const QString&) ), 257 connect( currentPathCombo, SIGNAL( activated(const QString&) ),
257 this, SLOT( currentPathComboActivated(const QString&) ) ); 258 this, SLOT( currentPathComboActivated(const QString&) ) );
258 259
259 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 260 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
260 this,SLOT(currentPathComboChanged())); 261 this,SLOT(currentPathComboChanged()));
261 262
262 connect( Local_View, SIGNAL( clicked(QListViewItem*)), 263 connect( Local_View, SIGNAL( clicked(QListViewItem*)),
263 this,SLOT( ListClicked(QListViewItem*)) ); 264 this,SLOT( ListClicked(QListViewItem*)) );
264 265
265 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 266 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
266 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); 267 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
267 268
268 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 269 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
269 270
270 connect( Remote_View, SIGNAL( clicked(QListViewItem*)), 271 connect( Remote_View, SIGNAL( clicked(QListViewItem*)),
271 this,SLOT( ListClicked(QListViewItem*)) ); 272 this,SLOT( ListClicked(QListViewItem*)) );
272 connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 273 connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
273 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); 274 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
274 275
275 connect( TabWidget,SIGNAL(currentChanged(QWidget*)), 276 connect( TabWidget,SIGNAL(currentChanged(QWidget*)),
276 this,SLOT(tabChanged(QWidget*))); 277 this,SLOT(tabChanged(QWidget*)));
277 278
278 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 279 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
279 280
280 connect( menuButton, SIGNAL( selected(const QString&)), SLOT(gotoCustomDir(const QString&))); 281 connect( menuButton, SIGNAL( selected(const QString&)), SLOT(gotoCustomDir(const QString&)));
281// connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int))); 282// connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int)));
282 connect( viewMenu, SIGNAL( activated(int)), this, SLOT(slotSwitchMenu(int))); 283 connect( viewMenu, SIGNAL( activated(int)), this, SLOT(slotSwitchMenu(int)));
283// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); 284// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
284 285
285} 286}
286 287
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 9e740d0..a694b70 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,836 +1,838 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13#include "output.h" 13#include "output.h"
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <qpe/lnkproperties.h> 16#include <qpe/lnkproperties.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18#include <qpe/applnk.h> 18#include <qpe/applnk.h>
19 19
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22 22
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qlistview.h> 24#include <qlistview.h>
25 25
26#include <errno.h> 26#include <errno.h>
27#include <stdlib.h> 27#include <stdlib.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <dirent.h> 30#include <dirent.h>
31#include <sys/sendfile.h> 31#include <sys/sendfile.h>
32#include <fcntl.h> 32#include <fcntl.h>
33 33
34 34
35using namespace Opie::Core;
36using namespace Opie::Core;
35void AdvancedFm::doDirChange() { 37void AdvancedFm::doDirChange() {
36 QString pathItem = CurrentView()->currentItem()->text(0); 38 QString pathItem = CurrentView()->currentItem()->text(0);
37 if( pathItem == "../") { 39 if( pathItem == "../") {
38 ListClicked( CurrentView()->currentItem()); 40 ListClicked( CurrentView()->currentItem());
39 } else { 41 } else {
40 if( pathItem.find(" -> ",0,TRUE) != -1) 42 if( pathItem.find(" -> ",0,TRUE) != -1)
41 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 43 pathItem = dealWithSymName((const QString&)pathItem)+"/";
42// qWarning(pathItem); 44// qWarning(pathItem);
43 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 45 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
44 } 46 }
45} 47}
46 48
47void AdvancedFm::showMenuHidden() { 49void AdvancedFm::showMenuHidden() {
48 if (b) { 50 if (b) {
49 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 51 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
50 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 52 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
51 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 53 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
52 } else { 54 } else {
53 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 55 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
54 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 56 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
55 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 57 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
56 } 58 }
57 b = !b; 59 b = !b;
58 populateView(); 60 populateView();
59} 61}
60 62
61void AdvancedFm::showHidden() { 63void AdvancedFm::showHidden() {
62 if (b) { 64 if (b) {
63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 65 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 66 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
65 } else { 67 } else {
66 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 69 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 } 70 }
69 populateView(); 71 populateView();
70} 72}
71 73
72QString AdvancedFm::dealWithSymName(const QString &fileName) { 74QString AdvancedFm::dealWithSymName(const QString &fileName) {
73 QString strItem = fileName; 75 QString strItem = fileName;
74 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 76 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
75} 77}
76 78
77void AdvancedFm::runThis() { 79void AdvancedFm::runThis() {
78 if( !CurrentView()->currentItem()) return; 80 if( !CurrentView()->currentItem()) return;
79 QString fs; 81 QString fs;
80 QDir *thisDir = CurrentDir(); 82 QDir *thisDir = CurrentDir();
81 83
82 QString curFile = CurrentView()->currentItem()->text(0); 84 QString curFile = CurrentView()->currentItem()->text(0);
83 QString path = thisDir->canonicalPath(); 85 QString path = thisDir->canonicalPath();
84 86
85 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 87 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
86 88
87 curFile = dealWithSymName((const QString&)curFile); 89 curFile = dealWithSymName((const QString&)curFile);
88 90
89 if(curFile != "../") { 91 if(curFile != "../") {
90 92
91 fs = getFileSystemType((const QString &) path); 93 fs = getFileSystemType((const QString &) path);
92 QFileInfo fileInfo( path + "/" + curFile); 94 QFileInfo fileInfo( path + "/" + curFile);
93// qDebug( fileInfo.owner()); 95// qDebug( fileInfo.owner());
94 96
95 if( (fileInfo.permission( QFileInfo::ExeUser) 97 if( (fileInfo.permission( QFileInfo::ExeUser)
96 | fileInfo.permission( QFileInfo::ExeGroup) 98 | fileInfo.permission( QFileInfo::ExeGroup)
97 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 99 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
98 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 100 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
99 QCopEnvelope e("QPE/System", "execute(QString)" ); 101 QCopEnvelope e("QPE/System", "execute(QString)" );
100 e << curFile; 102 e << curFile;
101 } else { 103 } else {
102 curFile = path + "/" + curFile; 104 curFile = path + "/" + curFile;
103 DocLnk nf(curFile); 105 DocLnk nf(curFile);
104 QString execStr = nf.exec(); 106 QString execStr = nf.exec();
105// qDebug( execStr); 107// qDebug( execStr);
106 if( execStr.isEmpty() ) { 108 if( execStr.isEmpty() ) {
107 } else { 109 } else {
108 nf.execute(); 110 nf.execute();
109 } 111 }
110 } 112 }
111 } 113 }
112} 114}
113 115
114void AdvancedFm::runText() { 116void AdvancedFm::runText() {
115 if( !CurrentView()->currentItem()) return; 117 if( !CurrentView()->currentItem()) return;
116 QString curFile = CurrentView()->currentItem()->text(0); 118 QString curFile = CurrentView()->currentItem()->text(0);
117 if(curFile != "../") { 119 if(curFile != "../") {
118 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 120 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
119 curFile = dealWithSymName((const QString&)curFile); 121 curFile = dealWithSymName((const QString&)curFile);
120 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 122 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
121 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 123 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
122 e << curFile; 124 e << curFile;
123 } 125 }
124} 126}
125 127
126void AdvancedFm::makeDir() { 128void AdvancedFm::makeDir() {
127 InputDialog *fileDlg; 129 InputDialog *fileDlg;
128 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 130 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
129 fileDlg->exec(); 131 fileDlg->exec();
130 if( fileDlg->result() == 1 ) { 132 if( fileDlg->result() == 1 ) {
131 QDir *thisDir = CurrentDir(); 133 QDir *thisDir = CurrentDir();
132 QString filename = fileDlg->LineEdit1->text(); 134 QString filename = fileDlg->LineEdit1->text();
133 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 135 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
134 } 136 }
135 populateView(); 137 populateView();
136} 138}
137 139
138void AdvancedFm::doDelete() { 140void AdvancedFm::doDelete() {
139 QStringList curFileList = getPath(); 141 QStringList curFileList = getPath();
140 bool doMsg=true; 142 bool doMsg=true;
141 int count = curFileList.count(); 143 int count = curFileList.count();
142 if( count > 0) { 144 if( count > 0) {
143 if(count > 1 ) { 145 if(count > 1 ) {
144 QString msg; 146 QString msg;
145 msg=tr("Really delete\n%1 files?").arg(count); 147 msg=tr("Really delete\n%1 files?").arg(count);
146 switch ( QMessageBox::warning(this,tr("Delete"),msg 148 switch ( QMessageBox::warning(this,tr("Delete"),msg
147 ,tr("Yes"),tr("No"),0,0,1) ) 149 ,tr("Yes"),tr("No"),0,0,1) )
148 { 150 {
149 case 0: 151 case 0:
150 doMsg=false; 152 doMsg=false;
151 break; 153 break;
152 case 1: 154 case 1:
153 return; 155 return;
154 break; 156 break;
155 }; 157 };
156 } 158 }
157 159
158 QString myFile; 160 QString myFile;
159 161
160 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 162 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
161 myFile = (*it); 163 myFile = (*it);
162 if( myFile.find(" -> ",0,TRUE) != -1) 164 if( myFile.find(" -> ",0,TRUE) != -1)
163 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 165 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
164 166
165 QString f = CurrentDir()->canonicalPath(); 167 QString f = CurrentDir()->canonicalPath();
166 if(f.right(1).find("/",0,TRUE) == -1) 168 if(f.right(1).find("/",0,TRUE) == -1)
167 f += "/"; 169 f += "/";
168 f += myFile; 170 f += myFile;
169 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 171 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
170 //if file is a directory 172 //if file is a directory
171 173
172 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 174 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
173 tr("Really delete %1\nand all it's contents ?" ).arg( f ) , 175 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
174 tr("Yes"), tr("No"), 0, 0, 1) ) { 176 tr("Yes"), tr("No"), 0, 0, 1) ) {
175 case 0: 177 case 0:
176 { 178 {
177 f=f.left(f.length()-1); 179 f=f.left(f.length()-1);
178 QString cmd="rm -rf "+f; 180 QString cmd="rm -rf "+f;
179 startProcess( (const QString)cmd.latin1() ); 181 startProcess( (const QString)cmd.latin1() );
180 populateView(); 182 populateView();
181 } 183 }
182 break; 184 break;
183 case 1: 185 case 1:
184 // exit 186 // exit
185 break; 187 break;
186 }; 188 };
187 189
188 } else { 190 } else {
189 if(doMsg) { 191 if(doMsg) {
190 switch ( QMessageBox::warning(this,tr("Delete"), 192 switch ( QMessageBox::warning(this,tr("Delete"),
191 tr("Really delete\n%1?").arg( myFile ), 193 tr("Really delete\n%1?").arg( myFile ),
192 tr("Yes"), tr("No"), 0, 0, 1) ) { 194 tr("Yes"), tr("No"), 0, 0, 1) ) {
193 case 1: 195 case 1:
194 return; 196 return;
195 break; 197 break;
196 }; 198 };
197 } 199 }
198 200
199 QString cmd="rm "+f; 201 QString cmd="rm "+f;
200 QFile file(f); 202 QFile file(f);
201 QFileInfo fi(myFile); 203 QFileInfo fi(myFile);
202 if( fi.fileName().find("../",0,TRUE)==-1) { 204 if( fi.fileName().find("../",0,TRUE)==-1) {
203// qDebug("remove link files "+myFile); 205// qDebug("remove link files "+myFile);
204 206
205// DocLnk lnk(f); 207// DocLnk lnk(f);
206 DocLnk *lnk; 208 DocLnk *lnk;
207 lnk = new DocLnk(f); 209 lnk = new DocLnk(f);
208// qDebug("Deleting doclnk " + lnk->linkFile()); 210// qDebug("Deleting doclnk " + lnk->linkFile());
209 if(lnk->isValid()) 211 if(lnk->isValid())
210 lnk->removeLinkFile(); 212 lnk->removeLinkFile();
211 // delete lnk; 213 // delete lnk;
212 file.remove(); 214 file.remove();
213 } 215 }
214 } 216 }
215 } 217 }
216 } 218 }
217 populateView(); 219 populateView();
218} 220}
219 221
220void AdvancedFm::filePerms() { 222void AdvancedFm::filePerms() {
221 QStringList curFileList = getPath(); 223 QStringList curFileList = getPath();
222 QString filePath; 224 QString filePath;
223 225
224 filePath = CurrentDir()->canonicalPath()+"/"; 226 filePath = CurrentDir()->canonicalPath()+"/";
225 227
226 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 228 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
227 filePermissions *filePerm; 229 filePermissions *filePerm;
228 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 230 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
229 QPEApplication::execDialog( filePerm ); 231 QPEApplication::execDialog( filePerm );
230 if( filePerm ) 232 if( filePerm )
231 delete filePerm; 233 delete filePerm;
232 } 234 }
233 populateView(); 235 populateView();
234} 236}
235 237
236void AdvancedFm::doProperties() { 238void AdvancedFm::doProperties() {
237#if defined(QT_QWS_OPIE) 239#if defined(QT_QWS_OPIE)
238 240
239 QStringList curFileList = getPath(); 241 QStringList curFileList = getPath();
240 242
241 QString filePath; 243 QString filePath;
242 filePath = CurrentDir()->canonicalPath()+"/"; 244 filePath = CurrentDir()->canonicalPath()+"/";
243 245
244// qDebug("%d",curFileList.count()); 246// qDebug("%d",curFileList.count());
245 247
246 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
247// qDebug((filePath+*it)); 249// qDebug((filePath+*it));
248 DocLnk lnk( (filePath+*it)); 250 DocLnk lnk( (filePath+*it));
249 LnkProperties prop( &lnk ); 251 LnkProperties prop( &lnk );
250 QPEApplication::execDialog( &prop ); 252 QPEApplication::execDialog( &prop );
251 } 253 }
252#endif 254#endif
253 255
254} 256}
255 257
256void AdvancedFm::upDir() { 258void AdvancedFm::upDir() {
257 QDir *thisDir = CurrentDir(); 259 QDir *thisDir = CurrentDir();
258 QString current = thisDir->canonicalPath(); 260 QString current = thisDir->canonicalPath();
259 QDir dir(current); 261 QDir dir(current);
260 dir.cdUp(); 262 dir.cdUp();
261 current = dir.canonicalPath(); 263 current = dir.canonicalPath();
262 chdir( current.latin1() ); 264 chdir( current.latin1() );
263 thisDir->cd( current, TRUE); 265 thisDir->cd( current, TRUE);
264 266
265 populateView(); 267 populateView();
266 update(); 268 update();
267} 269}
268 270
269void AdvancedFm::copy() { 271void AdvancedFm::copy() {
270 qApp->processEvents(); 272 qApp->processEvents();
271 QStringList curFileList = getPath(); 273 QStringList curFileList = getPath();
272 274
273 QDir *thisDir = CurrentDir(); 275 QDir *thisDir = CurrentDir();
274 QDir *thatDir = OtherDir(); 276 QDir *thatDir = OtherDir();
275 277
276 bool doMsg=true; 278 bool doMsg=true;
277 int count=curFileList.count(); 279 int count=curFileList.count();
278 if( count > 0) { 280 if( count > 0) {
279 if(count > 1 ){ 281 if(count > 1 ){
280 QString msg; 282 QString msg;
281 msg=tr("Really copy\n%1 files?").arg(count); 283 msg=tr("Really copy\n%1 files?").arg(count);
282 switch ( QMessageBox::warning(this,tr("Copy"),msg 284 switch ( QMessageBox::warning(this,tr("Copy"),msg
283 ,tr("Yes"),tr("No"),0,0,1) ) 285 ,tr("Yes"),tr("No"),0,0,1) )
284 { 286 {
285 case 0: 287 case 0:
286 doMsg=false; 288 doMsg=false;
287 break; 289 break;
288 case 1: 290 case 1:
289 return; 291 return;
290 break; 292 break;
291 }; 293 };
292 } 294 }
293 295
294 QString curFile, item, destFile; 296 QString curFile, item, destFile;
295 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 297 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
296 item=(*it); 298 item=(*it);
297 if(item.find("->",0,TRUE)) //symlink 299 if(item.find("->",0,TRUE)) //symlink
298 item = item.left(item.find("->",0,TRUE)); 300 item = item.left(item.find("->",0,TRUE));
299 301
300 curFile = thisDir->canonicalPath()+"/"+ item; 302 curFile = thisDir->canonicalPath()+"/"+ item;
301 destFile = thatDir->canonicalPath()+"/"+ item; 303 destFile = thatDir->canonicalPath()+"/"+ item;
302 304
303// qDebug("Destination file is "+destFile); 305// qDebug("Destination file is "+destFile);
304// qDebug("CurrentFile file is " + curFile); 306// qDebug("CurrentFile file is " + curFile);
305 307
306 QFile f(destFile); 308 QFile f(destFile);
307 if( f.exists()) { 309 if( f.exists()) {
308 if(doMsg) { 310 if(doMsg) {
309 switch ( QMessageBox::warning(this,tr("File Exists!"), 311 switch ( QMessageBox::warning(this,tr("File Exists!"),
310 tr("%1 exists. Ok to overwrite?").arg( item ), 312 tr("%1 exists. Ok to overwrite?").arg( item ),
311 tr("Yes"),tr("No"),0,0,1) ) { 313 tr("Yes"),tr("No"),0,0,1) ) {
312 case 1: 314 case 1:
313 return; 315 return;
314 break; 316 break;
315 }; 317 };
316 } 318 }
317 f.remove(); 319 f.remove();
318 } 320 }
319 321
320 if( !copyFile( curFile, destFile) ) { 322 if( !copyFile( curFile, destFile) ) {
321 QMessageBox::message("AdvancedFm", 323 QMessageBox::message("AdvancedFm",
322 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 324 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
323 return; 325 return;
324 } 326 }
325 } 327 }
326 setOtherTabCurrent(); 328 setOtherTabCurrent();
327 rePopulate(); 329 rePopulate();
328 } 330 }
329} 331}
330 332
331void AdvancedFm::copyAs() { 333void AdvancedFm::copyAs() {
332 qApp->processEvents(); 334 qApp->processEvents();
333 335
334 QStringList curFileList = getPath(); 336 QStringList curFileList = getPath();
335 QString curFile, item; 337 QString curFile, item;
336 InputDialog *fileDlg; 338 InputDialog *fileDlg;
337 339
338 QDir *thisDir = CurrentDir(); 340 QDir *thisDir = CurrentDir();
339 QDir *thatDir = OtherDir(); 341 QDir *thatDir = OtherDir();
340 342
341 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 343 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
342 QString destFile; 344 QString destFile;
343 item=(*it); 345 item=(*it);
344 curFile = thisDir->canonicalPath()+"/"+(*it); 346 curFile = thisDir->canonicalPath()+"/"+(*it);
345 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 347 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
346 348
347 fileDlg->setInputText((const QString &) destFile ); 349 fileDlg->setInputText((const QString &) destFile );
348 fileDlg->exec(); 350 fileDlg->exec();
349 351
350 if( fileDlg->result() == 1 ) { 352 if( fileDlg->result() == 1 ) {
351 QString filename = fileDlg->LineEdit1->text(); 353 QString filename = fileDlg->LineEdit1->text();
352 destFile = thatDir->canonicalPath()+"/"+filename; 354 destFile = thatDir->canonicalPath()+"/"+filename;
353 355
354 QFile f( destFile); 356 QFile f( destFile);
355 if( f.exists()) { 357 if( f.exists()) {
356 switch (QMessageBox::warning(this,tr("File Exists!"), 358 switch (QMessageBox::warning(this,tr("File Exists!"),
357 item+tr("\nexists. Ok to overwrite?"), 359 item+tr("\nexists. Ok to overwrite?"),
358 tr("Yes"),tr("No"),0,0,1) ) { 360 tr("Yes"),tr("No"),0,0,1) ) {
359 case 0: 361 case 0:
360 f.remove(); 362 f.remove();
361 break; 363 break;
362 case 1: 364 case 1:
363 return; 365 return;
364 break; 366 break;
365 }; 367 };
366 } 368 }
367 if( !copyFile( curFile, destFile) ) { 369 if( !copyFile( curFile, destFile) ) {
368 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 370 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
369 +curFile +tr("to\n")+destFile); 371 +curFile +tr("to\n")+destFile);
370 return; 372 return;
371 } 373 }
372 } 374 }
373 delete fileDlg; 375 delete fileDlg;
374 376
375 } 377 }
376 rePopulate(); 378 rePopulate();
377 setOtherTabCurrent(); 379 setOtherTabCurrent();
378} 380}
379 381
380void AdvancedFm::copySameDir() { 382void AdvancedFm::copySameDir() {
381 qApp->processEvents(); 383 qApp->processEvents();
382 QStringList curFileList = getPath(); 384 QStringList curFileList = getPath();
383 QString curFile, item, destFile; 385 QString curFile, item, destFile;
384 InputDialog *fileDlg; 386 InputDialog *fileDlg;
385 387
386 QDir *thisDir = CurrentDir(); 388 QDir *thisDir = CurrentDir();
387 389
388 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 390 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
389 item=(*it); 391 item=(*it);
390 curFile = thisDir->canonicalPath()+"/"+ item; 392 curFile = thisDir->canonicalPath()+"/"+ item;
391 393
392 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 394 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
393 fileDlg->setInputText((const QString &) destFile ); 395 fileDlg->setInputText((const QString &) destFile );
394 fileDlg->exec(); 396 fileDlg->exec();
395 397
396 if( fileDlg->result() == 1 ) { 398 if( fileDlg->result() == 1 ) {
397 399
398 QString filename = fileDlg->LineEdit1->text(); 400 QString filename = fileDlg->LineEdit1->text();
399 destFile = thisDir->canonicalPath()+"/"+filename; 401 destFile = thisDir->canonicalPath()+"/"+filename;
400 402
401 QFile f(destFile); 403 QFile f(destFile);
402 if( f.exists()) { 404 if( f.exists()) {
403 switch (QMessageBox::warning(this,tr("Delete"), 405 switch (QMessageBox::warning(this,tr("Delete"),
404 destFile+tr(" already exists.\nDo you really want to delete it?"), 406 destFile+tr(" already exists.\nDo you really want to delete it?"),
405 tr("Yes"),tr("No"),0,0,1) ) { 407 tr("Yes"),tr("No"),0,0,1) ) {
406 case 0: 408 case 0:
407 409
408 f.remove(); 410 f.remove();
409 break; 411 break;
410 case 1: 412 case 1:
411 return; 413 return;
412 break; 414 break;
413 }; 415 };
414 } 416 }
415 if(!copyFile( curFile,destFile) ) { 417 if(!copyFile( curFile,destFile) ) {
416 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 418 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
417 +curFile +tr("to\n")+destFile); 419 +curFile +tr("to\n")+destFile);
418 return; 420 return;
419 } 421 }
420 422
421// qDebug("copy "+curFile+" as "+destFile); 423// qDebug("copy "+curFile+" as "+destFile);
422 } 424 }
423 delete fileDlg; 425 delete fileDlg;
424 } 426 }
425 rePopulate(); 427 rePopulate();
426} 428}
427 429
428void AdvancedFm::move() { 430void AdvancedFm::move() {
429 qApp->processEvents(); 431 qApp->processEvents();
430 432
431 QStringList curFileList = getPath(); 433 QStringList curFileList = getPath();
432 if( curFileList.count() > 0) { 434 if( curFileList.count() > 0) {
433 QString curFile, destFile, item; 435 QString curFile, destFile, item;
434 436
435 QDir *thisDir = CurrentDir(); 437 QDir *thisDir = CurrentDir();
436 QDir *thatDir = OtherDir(); 438 QDir *thatDir = OtherDir();
437 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 439 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
438 item=(*it); 440 item=(*it);
439 QString destFile = thatDir->canonicalPath(); 441 QString destFile = thatDir->canonicalPath();
440 442
441 if(destFile.right(1).find("/",0,TRUE) == -1) 443 if(destFile.right(1).find("/",0,TRUE) == -1)
442 destFile+="/"; 444 destFile+="/";
443 destFile += item; 445 destFile += item;
444// qDebug("Destination file is "+destFile); 446// qDebug("Destination file is "+destFile);
445 447
446 curFile = thisDir->canonicalPath(); 448 curFile = thisDir->canonicalPath();
447 if(curFile.right(1).find("/",0,TRUE) == -1) 449 if(curFile.right(1).find("/",0,TRUE) == -1)
448 curFile +="/"; 450 curFile +="/";
449 curFile+= item; 451 curFile+= item;
450// qDebug("CurrentFile file is " + curFile); 452// qDebug("CurrentFile file is " + curFile);
451 453
452 if(QFileInfo(curFile).isDir()) { 454 if(QFileInfo(curFile).isDir()) {
453 moveDirectory( curFile, destFile ); 455 moveDirectory( curFile, destFile );
454 rePopulate(); 456 rePopulate();
455 return; 457 return;
456 } 458 }
457 459
458 QFile f( curFile); 460 QFile f( curFile);
459 if( f.exists()) { 461 if( f.exists()) {
460 if( !copyFile( curFile, destFile) ) { 462 if( !copyFile( curFile, destFile) ) {
461 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 463 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
462 return; 464 return;
463 } else 465 } else
464 QFile::remove(curFile); 466 QFile::remove(curFile);
465 } 467 }
466 } 468 }
467 469
468 } 470 }
469 rePopulate(); 471 rePopulate();
470 setOtherTabCurrent(); 472 setOtherTabCurrent();
471} 473}
472 474
473bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 475bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
474 int err = 0; 476 int err = 0;
475 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; 477 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
476 err = system((const char*)cmd); 478 err = system((const char*)cmd);
477 } else 479 } else
478 err = -1; 480 err = -1;
479 481
480 if(err!=0) { 482 if(err!=0) {
481 QMessageBox::message(tr("Note"),tr("Could not move\n") + src); 483 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
482 return false; 484 return false;
483 } 485 }
484 return true; 486 return true;
485} 487}
486 488
487bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 489bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
488 490
489 QString cmd = "/bin/cp -fpR " + src + " " + dest; 491 QString cmd = "/bin/cp -fpR " + src + " " + dest;
490 qWarning(cmd); 492 qWarning(cmd);
491 int err = system( (const char *) cmd ); 493 int err = system( (const char *) cmd );
492 if ( err != 0 ) { 494 if ( err != 0 ) {
493 QMessageBox::message("AdvancedFm", 495 QMessageBox::message("AdvancedFm",
494 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); 496 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
495 return false; 497 return false;
496 } 498 }
497 499
498 return true; 500 return true;
499} 501}
500 502
501 503
502bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 504bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
503 505
504 506
505 if(QFileInfo(src).isDir()) { 507 if(QFileInfo(src).isDir()) {
506 if( copyDirectory( src, dest )) { 508 if( copyDirectory( src, dest )) {
507 setOtherTabCurrent(); 509 setOtherTabCurrent();
508 populateView(); 510 populateView();
509 return true; 511 return true;
510 } 512 }
511 else 513 else
512 return false; 514 return false;
513 } 515 }
514 516
515 517
516 bool success = true; 518 bool success = true;
517 struct stat status; 519 struct stat status;
518 QFile srcFile(src); 520 QFile srcFile(src);
519 QFile destFile(dest); 521 QFile destFile(dest);
520 int err=0; 522 int err=0;
521 int read_fd=0; 523 int read_fd=0;
522 int write_fd=0; 524 int write_fd=0;
523 struct stat stat_buf; 525 struct stat stat_buf;
524 off_t offset = 0; 526 off_t offset = 0;
525 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 527 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
526// qWarning("open failed"); 528// qWarning("open failed");
527 return success = false; 529 return success = false;
528 } 530 }
529 read_fd = srcFile.handle(); 531 read_fd = srcFile.handle();
530 if(read_fd != -1) { 532 if(read_fd != -1) {
531 fstat (read_fd, &stat_buf); 533 fstat (read_fd, &stat_buf);
532 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 534 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
533// qWarning("destfile open failed"); 535// qWarning("destfile open failed");
534 return success = false; 536 return success = false;
535 } 537 }
536 write_fd = destFile.handle(); 538 write_fd = destFile.handle();
537 if(write_fd != -1) { 539 if(write_fd != -1) {
538 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 540 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
539 if( err == -1) { 541 if( err == -1) {
540 QString msg; 542 QString msg;
541 switch(err) { 543 switch(err) {
542 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 544 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
543 case EINVAL: msg = "Descriptor is not valid or locked. "; 545 case EINVAL: msg = "Descriptor is not valid or locked. ";
544 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 546 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
545 case EIO: msg = "Unspecified error while reading from in_fd."; 547 case EIO: msg = "Unspecified error while reading from in_fd.";
546 }; 548 };
547 success = false; 549 success = false;
548// qWarning(msg); 550// qWarning(msg);
549 } 551 }
550 } else { 552 } else {
551 success = false; 553 success = false;
552 } 554 }
553 } else { 555 } else {
554 success = false; 556 success = false;
555 } 557 }
556 srcFile.close(); 558 srcFile.close();
557 destFile.close(); 559 destFile.close();
558 // Set file permissions 560 // Set file permissions
559 if( stat( (const char *) src, &status ) == 0 ) { 561 if( stat( (const char *) src, &status ) == 0 ) {
560 chmod( (const char *) dest, status.st_mode ); 562 chmod( (const char *) dest, status.st_mode );
561 } 563 }
562 564
563 return success; 565 return success;
564} 566}
565 567
566void AdvancedFm::runCommand() { 568void AdvancedFm::runCommand() {
567 if( !CurrentView()->currentItem()) return; 569 if( !CurrentView()->currentItem()) return;
568 QDir *thisDir = CurrentDir(); 570 QDir *thisDir = CurrentDir();
569 571
570 QString curFile; 572 QString curFile;
571 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 573 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
572 574
573 InputDialog *fileDlg; 575 InputDialog *fileDlg;
574 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 576 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
575 fileDlg->setInputText(curFile); 577 fileDlg->setInputText(curFile);
576 fileDlg->exec(); 578 fileDlg->exec();
577 //QString command; 579 //QString command;
578 580
579 if( fileDlg->result() == 1 ) { 581 if( fileDlg->result() == 1 ) {
580// qDebug(fileDlg->LineEdit1->text()); 582// qDebug(fileDlg->LineEdit1->text());
581 QStringList command; 583 QStringList command;
582 584
583 command << "/bin/sh"; 585 command << "/bin/sh";
584 command << "-c"; 586 command << "-c";
585 command << fileDlg->LineEdit1->text(); 587 command << fileDlg->LineEdit1->text();
586 Output *outDlg; 588 Output *outDlg;
587 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 589 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
588 QPEApplication::execDialog( outDlg ); 590 QPEApplication::execDialog( outDlg );
589 qApp->processEvents(); 591 qApp->processEvents();
590 592
591 } 593 }
592} 594}
593 595
594void AdvancedFm::runCommandStd() { 596void AdvancedFm::runCommandStd() {
595 if( !CurrentView()->currentItem()) return; 597 if( !CurrentView()->currentItem()) return;
596 QString curFile; 598 QString curFile;
597 QDir *thisDir = CurrentDir(); 599 QDir *thisDir = CurrentDir();
598 QListView *thisView = CurrentView(); 600 QListView *thisView = CurrentView();
599 if( thisView->currentItem()) 601 if( thisView->currentItem())
600 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 602 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
601 603
602 InputDialog *fileDlg; 604 InputDialog *fileDlg;
603 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 605 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
604 fileDlg->setInputText(curFile); 606 fileDlg->setInputText(curFile);
605 fileDlg->exec(); 607 fileDlg->exec();
606 608
607 if( fileDlg->result() == 1 ) { 609 if( fileDlg->result() == 1 ) {
608 qApp->processEvents(); 610 qApp->processEvents();
609 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 611 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
610 } 612 }
611} 613}
612 614
613void AdvancedFm::fileStatus() { 615void AdvancedFm::fileStatus() {
614 if( !CurrentView()->currentItem()) return; 616 if( !CurrentView()->currentItem()) return;
615 QString curFile; 617 QString curFile;
616 curFile = CurrentView()->currentItem()->text(0); 618 curFile = CurrentView()->currentItem()->text(0);
617 619
618 QStringList command; 620 QStringList command;
619 command << "/bin/sh"; 621 command << "/bin/sh";
620 command << "-c"; 622 command << "-c";
621 command << "stat -l "+ curFile; 623 command << "stat -l "+ curFile;
622 624
623 Output *outDlg; 625 Output *outDlg;
624 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 626 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
625 QPEApplication::execDialog( outDlg ); 627 QPEApplication::execDialog( outDlg );
626 qApp->processEvents(); 628 qApp->processEvents();
627} 629}
628 630
629 631
630void AdvancedFm::mkDir() { 632void AdvancedFm::mkDir() {
631 makeDir(); 633 makeDir();
632} 634}
633 635
634void AdvancedFm::rn() { 636void AdvancedFm::rn() {
635 renameIt(); 637 renameIt();
636} 638}
637 639
638void AdvancedFm::del() { 640void AdvancedFm::del() {
639 doDelete(); 641 doDelete();
640} 642}
641 643
642void AdvancedFm::mkSym() { 644void AdvancedFm::mkSym() {
643 QString cmd; 645 QString cmd;
644 QStringList curFileList = getPath(); 646 QStringList curFileList = getPath();
645 if( curFileList.count() > 0) { 647 if( curFileList.count() > 0) {
646 QDir *thisDir = CurrentDir(); 648 QDir *thisDir = CurrentDir();
647 QDir * thatDir = OtherDir(); 649 QDir * thatDir = OtherDir();
648 650
649 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 651 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
650 652
651 QString destName = thatDir->canonicalPath()+"/"+(*it); 653 QString destName = thatDir->canonicalPath()+"/"+(*it);
652 if(destName.right(1) == "/") { 654 if(destName.right(1) == "/") {
653 destName = destName.left( destName.length() -1); 655 destName = destName.left( destName.length() -1);
654 } 656 }
655 657
656 QString curFile = thisDir->canonicalPath()+"/"+(*it); 658 QString curFile = thisDir->canonicalPath()+"/"+(*it);
657 659
658 if( curFile.right(1) == "/") { 660 if( curFile.right(1) == "/") {
659 curFile = curFile.left( curFile.length() -1); 661 curFile = curFile.left( curFile.length() -1);
660 } 662 }
661 663
662 cmd = "ln -s "+curFile+" "+destName; 664 cmd = "ln -s "+curFile+" "+destName;
663// qDebug(cmd); 665// qDebug(cmd);
664 startProcess( (const QString)cmd ); 666 startProcess( (const QString)cmd );
665 } 667 }
666 rePopulate(); 668 rePopulate();
667 setOtherTabCurrent(); 669 setOtherTabCurrent();
668 } 670 }
669} 671}
670 672
671void AdvancedFm::doBeam() { 673void AdvancedFm::doBeam() {
672 Ir ir; 674 Ir ir;
673 if(!ir.supported()) { 675 if(!ir.supported()) {
674 } else { 676 } else {
675 QStringList curFileList = getPath(); 677 QStringList curFileList = getPath();
676 if( curFileList.count() > 0) { 678 if( curFileList.count() > 0) {
677 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 679 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
678 QString curFile = (*it); 680 QString curFile = (*it);
679 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 681 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
680 if( curFilePath.right(1) == "/") { 682 if( curFilePath.right(1) == "/") {
681 curFilePath = curFilePath.left( curFilePath.length() -1); 683 curFilePath = curFilePath.left( curFilePath.length() -1);
682 } 684 }
683 Ir *file = new Ir(this, "IR"); 685 Ir *file = new Ir(this, "IR");
684 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 686 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
685 file->send( curFilePath, curFile ); 687 file->send( curFilePath, curFile );
686 } 688 }
687 } 689 }
688 } 690 }
689} 691}
690 692
691void AdvancedFm::fileBeamFinished( Ir *) { 693void AdvancedFm::fileBeamFinished( Ir *) {
692 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 694 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
693} 695}
694 696
695void AdvancedFm::selectAll() { 697void AdvancedFm::selectAll() {
696 QListView *thisView = CurrentView(); 698 QListView *thisView = CurrentView();
697 thisView->selectAll(true); 699 thisView->selectAll(true);
698 thisView->setSelected( thisView->firstChild(),false); 700 thisView->setSelected( thisView->firstChild(),false);
699} 701}
700 702
701void AdvancedFm::startProcess(const QString & cmd) { 703void AdvancedFm::startProcess(const QString & cmd) {
702 QStringList command; 704 QStringList command;
703 OProcess *process; 705 OProcess *process;
704 process = new OProcess(); 706 process = new OProcess();
705 connect(process, SIGNAL(processExited(OProcess*)), 707 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
706 this, SLOT( processEnded(OProcess*))); 708 this, SLOT( processEnded(OProcess*)));
707 709
708 connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), 710 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
709 this, SLOT( oprocessStderr(OProcess*,char*,int))); 711 this, SLOT( oprocessStderr(OProcess*,char*,int)));
710 712
711 command << "/bin/sh"; 713 command << "/bin/sh";
712 command << "-c"; 714 command << "-c";
713 command << cmd.latin1(); 715 command << cmd.latin1();
714 *process << command; 716 *process << command;
715 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 717 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
716 qDebug("could not start process"); 718 qDebug("could not start process");
717} 719}
718 720
719void AdvancedFm::processEnded(OProcess *) { 721void AdvancedFm::processEnded(OProcess *) {
720 rePopulate(); 722 rePopulate();
721} 723}
722 724
723void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 725void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
724// qWarning("received stderrt %d bytes", buflen); 726// qWarning("received stderrt %d bytes", buflen);
725 727
726 QString lineStr = buffer; 728 QString lineStr = buffer;
727 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 729 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
728} 730}
729 731
730bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 732bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
731 if ( o->inherits( "QLineEdit" ) ) { 733 if ( o->inherits( "QLineEdit" ) ) {
732 if ( e->type() == QEvent::KeyPress ) { 734 if ( e->type() == QEvent::KeyPress ) {
733 QKeyEvent *ke = (QKeyEvent*)e; 735 QKeyEvent *ke = (QKeyEvent*)e;
734 if ( ke->key() == Key_Return || 736 if ( ke->key() == Key_Return ||
735 ke->key() == Key_Enter ) { 737 ke->key() == Key_Enter ) {
736 okRename(); 738 okRename();
737 return true; 739 return true;
738 } 740 }
739 else if ( ke->key() == Key_Escape ) { 741 else if ( ke->key() == Key_Escape ) {
740 cancelRename(); 742 cancelRename();
741 return true; 743 return true;
742 } 744 }
743 } 745 }
744 else if ( e->type() == QEvent::FocusOut ) { 746 else if ( e->type() == QEvent::FocusOut ) {
745 cancelRename(); 747 cancelRename();
746 return true; 748 return true;
747 } 749 }
748 } 750 }
749 if ( o->inherits( "QListView" ) ) { 751 if ( o->inherits( "QListView" ) ) {
750 if ( e->type() == QEvent::FocusIn ) { 752 if ( e->type() == QEvent::FocusIn ) {
751 if( o == Local_View) { //keep track of which view 753 if( o == Local_View) { //keep track of which view
752 whichTab=1; 754 whichTab=1;
753 } 755 }
754 else { 756 else {
755 whichTab=2; 757 whichTab=2;
756 } 758 }
757 } 759 }
758 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 760 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
759 } 761 }
760 762
761 return QWidget::eventFilter( o, e ); 763 return QWidget::eventFilter( o, e );
762} 764}
763 765
764 766
765void AdvancedFm::cancelRename() { 767void AdvancedFm::cancelRename() {
766// qDebug("cancel rename"); 768// qDebug("cancel rename");
767 QListView * view; 769 QListView * view;
768 view = CurrentView(); 770 view = CurrentView();
769 771
770 bool resetFocus = view->viewport()->focusProxy() == renameBox; 772 bool resetFocus = view->viewport()->focusProxy() == renameBox;
771 delete renameBox; 773 delete renameBox;
772 renameBox = 0; 774 renameBox = 0;
773 if ( resetFocus ) { 775 if ( resetFocus ) {
774 view->viewport()->setFocusProxy( view); 776 view->viewport()->setFocusProxy( view);
775 view->setFocus(); 777 view->setFocus();
776 } 778 }
777} 779}
778 780
779void AdvancedFm::doRename(QListView * view) { 781void AdvancedFm::doRename(QListView * view) {
780 if( !CurrentView()->currentItem()) return; 782 if( !CurrentView()->currentItem()) return;
781 783
782 QRect r = view->itemRect( view->currentItem( )); 784 QRect r = view->itemRect( view->currentItem( ));
783 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 785 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
784 r.setX( view->contentsX() ); 786 r.setX( view->contentsX() );
785 787
786 if ( r.width() > view->visibleWidth() ) 788 if ( r.width() > view->visibleWidth() )
787 r.setWidth( view->visibleWidth() ); 789 r.setWidth( view->visibleWidth() );
788 790
789 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 791 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
790 renameBox->setFrame(true); 792 renameBox->setFrame(true);
791 793
792 renameBox->setText( view->currentItem()->text(0) ); 794 renameBox->setText( view->currentItem()->text(0) );
793 795
794 renameBox->selectAll(); 796 renameBox->selectAll();
795 renameBox->installEventFilter( this ); 797 renameBox->installEventFilter( this );
796 798
797 view->addChild( renameBox, r.x(), r.y() ); 799 view->addChild( renameBox, r.x(), r.y() );
798 800
799 renameBox->resize( r.size() ); 801 renameBox->resize( r.size() );
800 802
801 view->viewport()->setFocusProxy( renameBox ); 803 view->viewport()->setFocusProxy( renameBox );
802 804
803 renameBox->setFocus(); 805 renameBox->setFocus();
804 renameBox->show(); 806 renameBox->show();
805} 807}
806 808
807 809
808void AdvancedFm::renameIt() { 810void AdvancedFm::renameIt() {
809 if( !CurrentView()->currentItem()) return; 811 if( !CurrentView()->currentItem()) return;
810 812
811 QListView *thisView = CurrentView(); 813 QListView *thisView = CurrentView();
812 oldName = thisView->currentItem()->text(0); 814 oldName = thisView->currentItem()->text(0);
813 doRename( thisView ); 815 doRename( thisView );
814} 816}
815 817
816void AdvancedFm::okRename() { 818void AdvancedFm::okRename() {
817 if( !CurrentView()->currentItem()) return; 819 if( !CurrentView()->currentItem()) return;
818 820
819 QString newName = renameBox->text(); 821 QString newName = renameBox->text();
820 cancelRename(); 822 cancelRename();
821 QListView * view = CurrentView(); 823 QListView * view = CurrentView();
822 QString path = CurrentDir()->canonicalPath() + "/"; 824 QString path = CurrentDir()->canonicalPath() + "/";
823 oldName = path + oldName; 825 oldName = path + oldName;
824 newName = path + newName; 826 newName = path + newName;
825 if( rename( oldName.latin1(), newName.latin1())== -1) 827 if( rename( oldName.latin1(), newName.latin1())== -1)
826 QMessageBox::message(tr("Note"),tr("Could not rename")); 828 QMessageBox::message(tr("Note"),tr("Could not rename"));
827 else 829 else
828 oldName = ""; 830 oldName = "";
829 view->takeItem( view->currentItem() ); 831 view->takeItem( view->currentItem() );
830 delete view->currentItem(); 832 delete view->currentItem();
831 rePopulate(); 833 rePopulate();
832} 834}
833 835
834void AdvancedFm::openSearch() { 836void AdvancedFm::openSearch() {
835 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 837 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
836} 838}
diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp
index 3c1a164..df0d4af 100644
--- a/noncore/apps/advancedfm/main.cpp
+++ b/noncore/apps/advancedfm/main.cpp
@@ -1,33 +1,22 @@
1 1
2/*************************************************************************** 2/***************************************************************************
3using namespace Opie::Core;
4using namespace Opie::Core;
3 main.cpp - description 5 main.cpp - description
4 ------------------- 6 -------------------
5 begin : March 10, 2002 7 begin : March 10, 2002
6 copyright : (C) 2002 by llornkcor 8 copyright : (C) 2002 by llornkcor
7 email : ljp@llornkcor.com 9 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. * 13 * (at your option) any later version. *
12 ***************************************************************************/ 14 ***************************************************************************/
13 15
14#include "advancedfm.h" 16#include "advancedfm.h"
15
16#ifdef NOQUICKLAUNCH
17
18#include <qpe/qpeapplication.h>
19
20int main(int argc, char *argv[])
21{
22 QPEApplication a(argc, argv);
23
24 AdvancedFm advencedFm;
25 a.showMainWidget( &advencedFm);
26 return a.exec();
27}
28#else
29#include <opie2/oapplicationfactory.h> 17#include <opie2/oapplicationfactory.h>
30 18
19using namespace Opie::Core;
20
31OPIE_EXPORT_APP( OApplicationFactory<AdvancedFm> ) 21OPIE_EXPORT_APP( OApplicationFactory<AdvancedFm> )
32 22
33#endif
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 0bba1d8..16a0992 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,276 +1,278 @@
1/**************************************************************************** 1/****************************************************************************
2** outputEdit.cpp 2** outputEdit.cpp
3** 3**
4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> 4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#include "output.h" 6#include "output.h"
7 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/applnk.h> 9#include <qpe/applnk.h>
10 10
11#include <qfile.h> 11#include <qfile.h>
12#include <qmultilineedit.h> 12#include <qmultilineedit.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qlayout.h> 14#include <qlayout.h>
15 15
16#include <errno.h> 16#include <errno.h>
17 17
18/* XPM */ 18/* XPM */
19using namespace Opie::Core;
20using namespace Opie::Core;
19static char * filesave_xpm[] = { 21static char * filesave_xpm[] = {
20"16 16 78 1", 22"16 16 78 1",
21" c None", 23" c None",
22". c #343434", 24". c #343434",
23"+ c #A0A0A0", 25"+ c #A0A0A0",
24"@ c #565656", 26"@ c #565656",
25"# c #9E9E9E", 27"# c #9E9E9E",
26"$ c #525252", 28"$ c #525252",
27"% c #929292", 29"% c #929292",
28"& c #676767", 30"& c #676767",
29"* c #848484", 31"* c #848484",
30"= c #666666", 32"= c #666666",
31"- c #D8D8D8", 33"- c #D8D8D8",
32"; c #FFFFFF", 34"; c #FFFFFF",
33"> c #DBDBDB", 35"> c #DBDBDB",
34", c #636363", 36", c #636363",
35"' c #989898", 37"' c #989898",
36") c #2D2D2D", 38") c #2D2D2D",
37"! c #909090", 39"! c #909090",
38"~ c #AEAEAE", 40"~ c #AEAEAE",
39"{ c #EAEAEA", 41"{ c #EAEAEA",
40"] c #575757", 42"] c #575757",
41"^ c #585858", 43"^ c #585858",
42"/ c #8A8A8A", 44"/ c #8A8A8A",
43"( c #828282", 45"( c #828282",
44"_ c #6F6F6F", 46"_ c #6F6F6F",
45": c #C9C9C9", 47": c #C9C9C9",
46"< c #050505", 48"< c #050505",
47"[ c #292929", 49"[ c #292929",
48"} c #777777", 50"} c #777777",
49"| c #616161", 51"| c #616161",
50"1 c #3A3A3A", 52"1 c #3A3A3A",
51"2 c #BEBEBE", 53"2 c #BEBEBE",
52"3 c #2C2C2C", 54"3 c #2C2C2C",
53"4 c #7C7C7C", 55"4 c #7C7C7C",
54"5 c #F6F6F6", 56"5 c #F6F6F6",
55"6 c #FCFCFC", 57"6 c #FCFCFC",
56"7 c #6B6B6B", 58"7 c #6B6B6B",
57"8 c #959595", 59"8 c #959595",
58"9 c #4F4F4F", 60"9 c #4F4F4F",
59"0 c #808080", 61"0 c #808080",
60"a c #767676", 62"a c #767676",
61"b c #818181", 63"b c #818181",
62"c c #B8B8B8", 64"c c #B8B8B8",
63"d c #FBFBFB", 65"d c #FBFBFB",
64"e c #F9F9F9", 66"e c #F9F9F9",
65"f c #CCCCCC", 67"f c #CCCCCC",
66"g c #030303", 68"g c #030303",
67"h c #737373", 69"h c #737373",
68"i c #7A7A7A", 70"i c #7A7A7A",
69"j c #7E7E7E", 71"j c #7E7E7E",
70"k c #6A6A6A", 72"k c #6A6A6A",
71"l c #FAFAFA", 73"l c #FAFAFA",
72"m c #505050", 74"m c #505050",
73"n c #9D9D9D", 75"n c #9D9D9D",
74"o c #333333", 76"o c #333333",
75"p c #7B7B7B", 77"p c #7B7B7B",
76"q c #787878", 78"q c #787878",
77"r c #696969", 79"r c #696969",
78"s c #494949", 80"s c #494949",
79"t c #555555", 81"t c #555555",
80"u c #949494", 82"u c #949494",
81"v c #E6E6E6", 83"v c #E6E6E6",
82"w c #424242", 84"w c #424242",
83"x c #515151", 85"x c #515151",
84"y c #535353", 86"y c #535353",
85"z c #3E3E3E", 87"z c #3E3E3E",
86"A c #D4D4D4", 88"A c #D4D4D4",
87"B c #0C0C0C", 89"B c #0C0C0C",
88"C c #353535", 90"C c #353535",
89"D c #474747", 91"D c #474747",
90"E c #ECECEC", 92"E c #ECECEC",
91"F c #919191", 93"F c #919191",
92"G c #7D7D7D", 94"G c #7D7D7D",
93"H c #000000", 95"H c #000000",
94"I c #404040", 96"I c #404040",
95"J c #858585", 97"J c #858585",
96"K c #323232", 98"K c #323232",
97"L c #D0D0D0", 99"L c #D0D0D0",
98"M c #1C1C1C", 100"M c #1C1C1C",
99" ...+ ", 101" ...+ ",
100" @#$%&..+ ", 102" @#$%&..+ ",
101" .*=-;;>,..+ ", 103" .*=-;;>,..+ ",
102" ')!~;;;;;;{]..", 104" ')!~;;;;;;{]..",
103" ^/(-;;;;;;;_:<", 105" ^/(-;;;;;;;_:<",
104" [}|;;;;;;;{12$", 106" [}|;;;;;;;{12$",
105" #34-55;;;;678$+", 107" #34-55;;;;678$+",
106" 90ab=c;dd;e1fg ", 108" 90ab=c;dd;e1fg ",
107" [ahij((kbl0mn$ ", 109" [ahij((kbl0mn$ ",
108" op^q^^7r&]s/$+ ", 110" op^q^^7r&]s/$+ ",
109"@btu;vbwxy]zAB ", 111"@btu;vbwxy]zAB ",
110"CzDEvEv;;DssF$ ", 112"CzDEvEv;;DssF$ ",
111"G.H{E{E{IxsJ$+ ", 113"G.H{E{E{IxsJ$+ ",
112" +...vEKxzLM ", 114" +...vEKxzLM ",
113" +...z]n$ ", 115" +...z]n$ ",
114" +... "}; 116" +... "};
115 117
116Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 118Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
117 : QDialog( parent, name, modal, fl ) 119 : QDialog( parent, name, modal, fl )
118{ 120{
119 QStringList cmmds; 121 QStringList cmmds;
120// cmmds=QStringList::split( " ", commands, false); 122// cmmds=QStringList::split( " ", commands, false);
121 cmmds=commands; 123 cmmds=commands;
122// qDebug("count %d", cmmds.count()); 124// qDebug("count %d", cmmds.count());
123 if ( !name ) 125 if ( !name )
124 setName( tr("Output")); 126 setName( tr("Output"));
125 resize( 196, 269 ); 127 resize( 196, 269 );
126 setCaption( name ); 128 setCaption( name );
127 129
128 OutputLayout = new QGridLayout( this ); 130 OutputLayout = new QGridLayout( this );
129 OutputLayout->setSpacing( 2); 131 OutputLayout->setSpacing( 2);
130 OutputLayout->setMargin( 2); 132 OutputLayout->setMargin( 2);
131 133
132 QPushButton *docButton; 134 QPushButton *docButton;
133 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 135 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
134 docButton->setFixedSize( QSize( 20, 20 ) ); 136 docButton->setFixedSize( QSize( 20, 20 ) );
135 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 137 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
136 // docButton->setFlat(TRUE); 138 // docButton->setFlat(TRUE);
137 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 139 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
138 140
139 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 141 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
140 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 142 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
141 143
142 proc = new OProcess(); 144 proc = new OProcess();
143 145
144 connect(proc, SIGNAL(processExited(OProcess*)), 146 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
145 this, SLOT( processFinished())); 147 this, SLOT( processFinished()));
146 148
147 connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), 149 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
148 this, SLOT(commandStdout(OProcess*,char*,int))); 150 this, SLOT(commandStdout(OProcess*,char*,int)));
149 151
150 connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), 152 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
151 this, SLOT(commandStderr(OProcess*,char*,int))); 153 this, SLOT(commandStderr(OProcess*,char*,int)));
152 154
153// connect( , SIGNAL(received(const QByteArray&)), 155// connect( , SIGNAL(received(const QByteArray&)),
154// this, SLOT(commandStdin(const QByteArray&))); 156// this, SLOT(commandStdin(const QByteArray&)));
155 157
156// * proc << commands.latin1(); 158// * proc << commands.latin1();
157 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 159 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
158 qDebug( "%s", (*it).latin1() ); 160 qDebug( "%s", (*it).latin1() );
159 * proc << (*it).latin1(); 161 * proc << (*it).latin1();
160 } 162 }
161 163
162 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 164 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
163 165
164 OutputEdit->append(tr("Process could not start") ); 166 OutputEdit->append(tr("Process could not start") );
165 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 167 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
166 perror("Error: "); 168 perror("Error: ");
167 QString errorMsg=tr("Error\n")+(QString)strerror(errno); 169 QString errorMsg=tr("Error\n")+(QString)strerror(errno);
168 OutputEdit->append( errorMsg); 170 OutputEdit->append( errorMsg);
169 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 171 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
170 } 172 }
171} 173}
172 174
173Output::~Output() { 175Output::~Output() {
174} 176}
175 177
176void Output::saveOutput() { 178void Output::saveOutput() {
177 179
178 InputDialog *fileDlg; 180 InputDialog *fileDlg;
179 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 181 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
180 fileDlg->exec(); 182 fileDlg->exec();
181 if( fileDlg->result() == 1 ) { 183 if( fileDlg->result() == 1 ) {
182 QString filename = QPEApplication::documentDir(); 184 QString filename = QPEApplication::documentDir();
183 if(filename.right(1).find('/') == -1) 185 if(filename.right(1).find('/') == -1)
184 filename+="/"; 186 filename+="/";
185 QString name = fileDlg->LineEdit1->text(); 187 QString name = fileDlg->LineEdit1->text();
186 filename+="text/plain/"+name; 188 filename+="text/plain/"+name;
187 qDebug(filename); 189 qDebug(filename);
188 190
189 QFile f(filename); 191 QFile f(filename);
190 f.open( IO_WriteOnly); 192 f.open( IO_WriteOnly);
191 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 193 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
192 DocLnk lnk; 194 DocLnk lnk;
193 lnk.setName(name); //sets file name 195 lnk.setName(name); //sets file name
194 lnk.setFile(filename); //sets File property 196 lnk.setFile(filename); //sets File property
195 lnk.setType("text/plain"); 197 lnk.setType("text/plain");
196 if(!lnk.writeLink()) { 198 if(!lnk.writeLink()) {
197 qDebug("Writing doclink did not work"); 199 qDebug("Writing doclink did not work");
198 } 200 }
199 } else 201 } else
200 qWarning("Could not write file"); 202 qWarning("Could not write file");
201 f.close(); 203 f.close();
202 } 204 }
203} 205}
204 206
205void Output::commandStdout(OProcess*, char *buffer, int buflen) { 207void Output::commandStdout(OProcess*, char *buffer, int buflen) {
206 qWarning("received stdout %d bytes", buflen); 208 qWarning("received stdout %d bytes", buflen);
207 209
208// QByteArray data(buflen); 210// QByteArray data(buflen);
209// data.fill(*buffer, buflen); 211// data.fill(*buffer, buflen);
210// for (uint i = 0; i < data.count(); i++ ) { 212// for (uint i = 0; i < data.count(); i++ ) {
211// printf("%c", buffer[i] ); 213// printf("%c", buffer[i] );
212// } 214// }
213// printf("\n"); 215// printf("\n");
214 216
215 QString lineStr = buffer; 217 QString lineStr = buffer;
216 lineStr=lineStr.left(lineStr.length()-1); 218 lineStr=lineStr.left(lineStr.length()-1);
217 OutputEdit->append(lineStr); 219 OutputEdit->append(lineStr);
218 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 220 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
219} 221}
220 222
221 223
222void Output::commandStdin( const QByteArray &data) { 224void Output::commandStdin( const QByteArray &data) {
223 qWarning("received stdin %d bytes", data.size()); 225 qWarning("received stdin %d bytes", data.size());
224 // recieved data from the io layer goes to sz 226 // recieved data from the io layer goes to sz
225 proc->writeStdin(data.data(), data.size()); 227 proc->writeStdin(data.data(), data.size());
226} 228}
227 229
228void Output::commandStderr(OProcess*, char *buffer, int buflen) { 230void Output::commandStderr(OProcess*, char *buffer, int buflen) {
229 qWarning("received stderrt %d bytes", buflen); 231 qWarning("received stderrt %d bytes", buflen);
230 232
231 QString lineStr = buffer; 233 QString lineStr = buffer;
232// lineStr=lineStr.left(lineStr.length()-1); 234// lineStr=lineStr.left(lineStr.length()-1);
233 OutputEdit->append(lineStr); 235 OutputEdit->append(lineStr);
234 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 236 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
235} 237}
236 238
237void Output::processFinished() { 239void Output::processFinished() {
238 240
239 delete proc; 241 delete proc;
240 OutputEdit->append( tr("\nFinished\n") ); 242 OutputEdit->append( tr("\nFinished\n") );
241 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 243 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
242// close(); 244// close();
243// disconnect( layer(), SIGNAL(received(const QByteArray&)), 245// disconnect( layer(), SIGNAL(received(const QByteArray&)),
244// this, SLOT(commandStdin(const QByteArray&))); 246// this, SLOT(commandStdin(const QByteArray&)));
245} 247}
246 248
247//============================== 249//==============================
248 250
249InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 251InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
250 : QDialog( parent, name, modal, fl ) 252 : QDialog( parent, name, modal, fl )
251{ 253{
252 if ( !name ) 254 if ( !name )
253 setName( "InputDialog" ); 255 setName( "InputDialog" );
254 resize( 234, 50 ); 256 resize( 234, 50 );
255 setMaximumSize( QSize( 240, 50 ) ); 257 setMaximumSize( QSize( 240, 50 ) );
256 setCaption( tr(name ) ); 258 setCaption( tr(name ) );
257 259
258 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 260 LineEdit1 = new QLineEdit( this, "LineEdit1" );
259 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 261 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
260 LineEdit1->setFocus(); 262 LineEdit1->setFocus();
261 LineEdit1->setFocus(); 263 LineEdit1->setFocus();
262 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 264 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
263} 265}
264 266
265InputDialog::~InputDialog() { 267InputDialog::~InputDialog() {
266 inputText = LineEdit1->text(); 268 inputText = LineEdit1->text();
267} 269}
268 270
269void InputDialog::setInputText(const QString &string) { 271void InputDialog::setInputText(const QString &string) {
270 LineEdit1->setText( string); 272 LineEdit1->setText( string);
271} 273}
272 274
273void InputDialog::returned() { 275void InputDialog::returned() {
274 inputText = LineEdit1->text(); 276 inputText = LineEdit1->text();
275 this->accept(); 277 this->accept();
276} 278}
diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h
index 26c0fa0..37ba57d 100644
--- a/noncore/apps/advancedfm/output.h
+++ b/noncore/apps/advancedfm/output.h
@@ -1,65 +1,65 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file 'outputEdit.ui' 2** Form interface generated from reading ui file 'outputEdit.ui'
3** 3**
4** Created: Fri Apr 12 15:12:44 2002 4** Created: Fri Apr 12 15:12:44 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#ifndef OUTPUT_H 9#ifndef OUTPUT_H
10#define OUTPUT_H 10#define OUTPUT_H
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qdialog.h> 13#include <qdialog.h>
14#include <qcstring.h> 14#include <qcstring.h>
15#include <qstringlist.h> 15#include <qstringlist.h>
16#include <qlineedit.h> 16#include <qlineedit.h>
17#include <qwhatsthis.h> 17#include <qwhatsthis.h>
18 18
19#include <opie2/oprocess.h> 19#include <opie2/oprocess.h>
20 20
21class QVBoxLayout; 21class QVBoxLayout;
22class QHBoxLayout; 22class QHBoxLayout;
23class QGridLayout; 23class QGridLayout;
24class QMultiLineEdit; 24class QMultiLineEdit;
25 25
26class Output : public QDialog 26class Output : public QDialog
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 31 Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
32 ~Output(); 32 ~Output();
33 33
34 QMultiLineEdit* OutputEdit; 34 QMultiLineEdit* OutputEdit;
35 35
36protected: 36protected:
37 QGridLayout* OutputLayout; 37 QGridLayout* OutputLayout;
38 OProcess *proc; 38 Opie::Core::OProcess *proc;
39protected slots: 39protected slots:
40 void saveOutput(); 40 void saveOutput();
41 void commandStdout(OProcess*, char *, int); 41 void commandStdout(Opie::Core::OProcess*, char *, int);
42 void commandStdin(const QByteArray &); 42 void commandStdin(const QByteArray &);
43 void commandStderr(OProcess*, char *, int); 43 void commandStderr(Opie::Core::OProcess*, char *, int);
44 void processFinished(); 44 void processFinished();
45 private: 45 private:
46 QString cmmd; 46 QString cmmd;
47 47
48}; 48};
49 49
50class InputDialog : public QDialog 50class InputDialog : public QDialog
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 55 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
56 ~InputDialog(); 56 ~InputDialog();
57 QString inputText; 57 QString inputText;
58 QLineEdit* LineEdit1; 58 QLineEdit* LineEdit1;
59 void setInputText(const QString &); 59 void setInputText(const QString &);
60private slots: 60private slots:
61 void returned(); 61 void returned();
62 62
63}; 63};
64 64
65#endif // OUTPUT_H 65#endif // OUTPUT_H
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp
index 1b933f2..706d970 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -1,785 +1,786 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "checkbook.h" 29#include "checkbook.h"
30#include "cbinfo.h" 30#include "cbinfo.h"
31#include "transaction.h" 31#include "transaction.h"
32#include "traninfo.h" 32#include "traninfo.h"
33#include "graph.h" 33#include "graph.h"
34#include "graphinfo.h" 34#include "graphinfo.h"
35#include "password.h" 35#include "password.h"
36#include "cfg.h" 36#include "cfg.h"
37 37
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41 41
42#include <qcheckbox.h> 42#include <qcheckbox.h>
43#include <qcombobox.h> 43#include <qcombobox.h>
44#include <qlabel.h> 44#include <qlabel.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qmultilineedit.h> 47#include <qmultilineedit.h>
48#include <qpushbutton.h> 48#include <qpushbutton.h>
49#include <qwhatsthis.h> 49#include <qwhatsthis.h>
50#include <qpopupmenu.h> 50#include <qpopupmenu.h>
51 51
52#define COL_ID 0 52#define COL_ID 0
53#define COL_SORTDATE 1 53#define COL_SORTDATE 1
54#define COL_NUM 2 54#define COL_NUM 2
55#define COL_DATE 3 55#define COL_DATE 3
56#define COL_DESC 4 56#define COL_DESC 4
57#define COL_AMOUNT 5 57#define COL_AMOUNT 5
58#define COL_BAL 6 58#define COL_BAL 6
59 59
60// --- Checkbook -------------------------------------------------------------- 60// --- Checkbook --------------------------------------------------------------
61using namespace Opie::Ui;
61Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) 62Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg )
62 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 63 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
63{ 64{
64 info = i; 65 info = i;
65 _pCfg=cfg; 66 _pCfg=cfg;
66 67
67 // Title bar 68 // Title bar
68 if ( info->name() != "" ) 69 if ( info->name() != "" )
69 { 70 {
70 QString tempstr = info->name(); 71 QString tempstr = info->name();
71 tempstr.append( " - " ); 72 tempstr.append( " - " );
72 tempstr.append( tr( "Checkbook" ) ); 73 tempstr.append( tr( "Checkbook" ) );
73 setCaption( tempstr ); 74 setCaption( tempstr );
74 } 75 }
75 else 76 else
76 { 77 {
77 setCaption( tr( "New checkbook" ) ); 78 setCaption( tr( "New checkbook" ) );
78 } 79 }
79 80
80 81
81 // Setup layout to make everything pretty 82 // Setup layout to make everything pretty
82 QVBoxLayout *layout = new QVBoxLayout( this ); 83 QVBoxLayout *layout = new QVBoxLayout( this );
83 layout->setMargin( 2 ); 84 layout->setMargin( 2 );
84 layout->setSpacing( 4 ); 85 layout->setSpacing( 4 );
85 86
86 // Setup tabs for all info 87 // Setup tabs for all info
87 mainWidget = new OTabWidget( this ); 88 mainWidget = new OTabWidget( this );
88 layout->addWidget( mainWidget ); 89 layout->addWidget( mainWidget );
89 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); 90 mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
90 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); 91 mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
91 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); 92 mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
92 if( _pCfg->isShowLastTab() ) 93 if( _pCfg->isShowLastTab() )
93 mainWidget->setCurrentTab( info->getLastTab() ); 94 mainWidget->setCurrentTab( info->getLastTab() );
94 else 95 else
95 mainWidget->setCurrentTab( tr( "Info" ) ); 96 mainWidget->setCurrentTab( tr( "Info" ) );
96 connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) ); 97 connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) );
97 98
98 // Load checkbook information 99 // Load checkbook information
99 loadCheckbook(); 100 loadCheckbook();
100} 101}
101 102
102Checkbook::~Checkbook() 103Checkbook::~Checkbook()
103{ 104{
104} 105}
105 106
106// --- initInfo --------------------------------------------------------------- 107// --- initInfo ---------------------------------------------------------------
107QWidget *Checkbook::initInfo() 108QWidget *Checkbook::initInfo()
108{ 109{
109 QWidget *control = new QWidget( mainWidget, tr("Info") ); 110 QWidget *control = new QWidget( mainWidget, tr("Info") );
110 111
111 QVBoxLayout *vb = new QVBoxLayout( control ); 112 QVBoxLayout *vb = new QVBoxLayout( control );
112 113
113 QScrollView *sv = new QScrollView( control ); 114 QScrollView *sv = new QScrollView( control );
114 vb->addWidget( sv, 0, 0 ); 115 vb->addWidget( sv, 0, 0 );
115 sv->setResizePolicy( QScrollView::AutoOneFit ); 116 sv->setResizePolicy( QScrollView::AutoOneFit );
116 sv->setFrameStyle( QFrame::NoFrame ); 117 sv->setFrameStyle( QFrame::NoFrame );
117 118
118 QWidget *container = new QWidget( sv->viewport() ); 119 QWidget *container = new QWidget( sv->viewport() );
119 sv->addChild( container ); 120 sv->addChild( container );
120 121
121 QGridLayout *layout = new QGridLayout( container ); 122 QGridLayout *layout = new QGridLayout( container );
122 layout->setSpacing( 2 ); 123 layout->setSpacing( 2 );
123 layout->setMargin( 4 ); 124 layout->setMargin( 4 );
124 125
125 // Password protection 126 // Password protection
126 passwordCB = new QCheckBox( tr( "Password protect" ), container ); 127 passwordCB = new QCheckBox( tr( "Password protect" ), container );
127 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); 128 QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
128 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); 129 connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
129 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); 130 layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
130 131
131 // Account name 132 // Account name
132 QLabel *label = new QLabel( tr( "Name:" ), container ); 133 QLabel *label = new QLabel( tr( "Name:" ), container );
133 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); 134 QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
134 layout->addWidget( label, 1, 0 ); 135 layout->addWidget( label, 1, 0 );
135 nameEdit = new QLineEdit( container ); 136 nameEdit = new QLineEdit( container );
136 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); 137 QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
137 connect( nameEdit, SIGNAL( textChanged(const QString&) ), 138 connect( nameEdit, SIGNAL( textChanged(const QString&) ),
138 this, SLOT( slotNameChanged(const QString&) ) ); 139 this, SLOT( slotNameChanged(const QString&) ) );
139 layout->addWidget( nameEdit, 1, 1 ); 140 layout->addWidget( nameEdit, 1, 1 );
140 141
141 // Type of account 142 // Type of account
142 label = new QLabel( tr( "Type:" ), container ); 143 label = new QLabel( tr( "Type:" ), container );
143 QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); 144 QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
144 layout->addWidget( label, 2, 0 ); 145 layout->addWidget( label, 2, 0 );
145 typeList = new QComboBox( container ); 146 typeList = new QComboBox( container );
146 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); 147 QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
147 typeList->insertStringList( _pCfg->getAccountTypes() ); 148 typeList->insertStringList( _pCfg->getAccountTypes() );
148 layout->addWidget( typeList, 2, 1 ); 149 layout->addWidget( typeList, 2, 1 );
149 150
150 // Bank/institution name 151 // Bank/institution name
151 label = new QLabel( tr( "Bank:" ), container ); 152 label = new QLabel( tr( "Bank:" ), container );
152 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); 153 QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
153 layout->addWidget( label, 3, 0 ); 154 layout->addWidget( label, 3, 0 );
154 bankEdit = new QLineEdit( container ); 155 bankEdit = new QLineEdit( container );
155 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); 156 QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
156 layout->addWidget( bankEdit, 3, 1 ); 157 layout->addWidget( bankEdit, 3, 1 );
157 158
158 // Account number 159 // Account number
159 label = new QLabel( tr( "Account number:" ), container ); 160 label = new QLabel( tr( "Account number:" ), container );
160 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); 161 QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
161 layout->addWidget( label, 4, 0 ); 162 layout->addWidget( label, 4, 0 );
162 acctNumEdit = new QLineEdit( container ); 163 acctNumEdit = new QLineEdit( container );
163 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); 164 QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
164 layout->addWidget( acctNumEdit, 4, 1 ); 165 layout->addWidget( acctNumEdit, 4, 1 );
165 166
166 // PIN number 167 // PIN number
167 label = new QLabel( tr( "PIN number:" ), container ); 168 label = new QLabel( tr( "PIN number:" ), container );
168 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); 169 QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
169 layout->addWidget( label, 5, 0 ); 170 layout->addWidget( label, 5, 0 );
170 pinNumEdit = new QLineEdit( container ); 171 pinNumEdit = new QLineEdit( container );
171 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); 172 QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
172 layout->addWidget( pinNumEdit, 5, 1 ); 173 layout->addWidget( pinNumEdit, 5, 1 );
173 174
174 // Starting balance 175 // Starting balance
175 label = new QLabel( tr( "Starting balance:" ), container ); 176 label = new QLabel( tr( "Starting balance:" ), container );
176 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); 177 QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
177 layout->addWidget( label, 6, 0 ); 178 layout->addWidget( label, 6, 0 );
178 balanceEdit = new QLineEdit( container ); 179 balanceEdit = new QLineEdit( container );
179 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); 180 QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
180 connect( balanceEdit, SIGNAL( textChanged(const QString&) ), 181 connect( balanceEdit, SIGNAL( textChanged(const QString&) ),
181 this, SLOT( slotStartingBalanceChanged(const QString&) ) ); 182 this, SLOT( slotStartingBalanceChanged(const QString&) ) );
182 layout->addWidget( balanceEdit, 6, 1 ); 183 layout->addWidget( balanceEdit, 6, 1 );
183 184
184 // Notes 185 // Notes
185 label = new QLabel( tr( "Notes:" ), container ); 186 label = new QLabel( tr( "Notes:" ), container );
186 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); 187 QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
187 layout->addWidget( label, 7, 0 ); 188 layout->addWidget( label, 7, 0 );
188 notesEdit = new QMultiLineEdit( container ); 189 notesEdit = new QMultiLineEdit( container );
189 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); 190 QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
190 notesEdit->setMinimumHeight( 25 ); 191 notesEdit->setMinimumHeight( 25 );
191 notesEdit->setMaximumHeight( 65 ); 192 notesEdit->setMaximumHeight( 65 );
192 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); 193 layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
193 194
194 return control; 195 return control;
195} 196}
196 197
197 198
198// --- initTransactions ------------------------------------------------------- 199// --- initTransactions -------------------------------------------------------
199QWidget *Checkbook::initTransactions() 200QWidget *Checkbook::initTransactions()
200{ 201{
201 QWidget *control = new QWidget( mainWidget, tr("Transactions") ); 202 QWidget *control = new QWidget( mainWidget, tr("Transactions") );
202 203
203 QGridLayout *layout = new QGridLayout( control ); 204 QGridLayout *layout = new QGridLayout( control );
204 layout->setSpacing( 2 ); 205 layout->setSpacing( 2 );
205 layout->setMargin( 4 ); 206 layout->setMargin( 4 );
206 207
207 // Sort selector 208 // Sort selector
208 QLabel *label = new QLabel( tr( "Sort by:" ), control ); 209 QLabel *label = new QLabel( tr( "Sort by:" ), control );
209 QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); 210 QWhatsThis::add( label, tr( "Select checkbook sorting here." ) );
210 layout->addMultiCellWidget( label, 0, 0, 0, 1 ); 211 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
211 _cbSortType=new QComboBox( control ); 212 _cbSortType=new QComboBox( control );
212 _cbSortType->insertItem( tr("Entry Order") ); 213 _cbSortType->insertItem( tr("Entry Order") );
213 _cbSortType->insertItem( tr("Date") ); 214 _cbSortType->insertItem( tr("Date") );
214 _cbSortType->insertItem( tr("Number") ); 215 _cbSortType->insertItem( tr("Number") );
215 layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); 216 layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 );
216 connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) ); 217 connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) );
217 218
218 // Table 219 // Table
219 tranTable = new QListView( control ); 220 tranTable = new QListView( control );
220 QFont fnt(QPEApplication::font()); 221 QFont fnt(QPEApplication::font());
221 fnt.setPointSize( fnt.pointSize()-1 ); 222 fnt.setPointSize( fnt.pointSize()-1 );
222 tranTable->setFont( fnt ); 223 tranTable->setFont( fnt );
223 QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); 224 QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) );
224 tranTable->addColumn( tr( "Id" ) ); 225 tranTable->addColumn( tr( "Id" ) );
225 tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); 226 tranTable->setColumnWidthMode( COL_ID, QListView::Manual );
226 tranTable->setColumnWidth( COL_ID, 0); 227 tranTable->setColumnWidth( COL_ID, 0);
227 tranTable->addColumn( tr( "SortDate" ) ); 228 tranTable->addColumn( tr( "SortDate" ) );
228 tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); 229 tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual );
229 tranTable->setColumnWidth( COL_SORTDATE, 0); 230 tranTable->setColumnWidth( COL_SORTDATE, 0);
230 tranTable->addColumn( tr( "Num" ) ); 231 tranTable->addColumn( tr( "Num" ) );
231 tranTable->addColumn( tr( "Date" ) ); 232 tranTable->addColumn( tr( "Date" ) );
232 //tranTable->addColumn( tr( "Cleared" ) ); 233 //tranTable->addColumn( tr( "Cleared" ) );
233 tranTable->addColumn( tr( "Description" ) ); 234 tranTable->addColumn( tr( "Description" ) );
234 int column = tranTable->addColumn( tr( "Amount" ) ); 235 int column = tranTable->addColumn( tr( "Amount" ) );
235 tranTable->setColumnAlignment( column, Qt::AlignRight ); 236 tranTable->setColumnAlignment( column, Qt::AlignRight );
236 column=tranTable->addColumn( tr("Balance") ); 237 column=tranTable->addColumn( tr("Balance") );
237 tranTable->setColumnAlignment( column, Qt::AlignRight ); 238 tranTable->setColumnAlignment( column, Qt::AlignRight );
238 tranTable->setAllColumnsShowFocus( TRUE ); 239 tranTable->setAllColumnsShowFocus( TRUE );
239 tranTable->setSorting( -1 ); 240 tranTable->setSorting( -1 );
240 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); 241 layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
241 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); 242 QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
242 connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), 243 connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
243 this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) ); 244 this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) );
244 connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ), 245 connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ),
245 this, SLOT( slotEditTran() ) ); 246 this, SLOT( slotEditTran() ) );
246 _sortCol=COL_ID; 247 _sortCol=COL_ID;
247 248
248 // Buttons 249 // Buttons
249 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); 250 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
250 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 251 QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
251 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); 252 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
252 layout->addWidget( btn, 2, 0 ); 253 layout->addWidget( btn, 2, 0 );
253 254
254 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); 255 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
255 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 256 QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
256 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); 257 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
257 layout->addWidget( btn, 2, 1 ); 258 layout->addWidget( btn, 2, 1 );
258 259
259 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); 260 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
260 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 261 QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
261 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); 262 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
262 layout->addWidget( btn, 2, 2 ); 263 layout->addWidget( btn, 2, 2 );
263 264
264 return( control ); 265 return( control );
265} 266}
266 267
267 268
268// --- initCharts ------------------------------------------------------------- 269// --- initCharts -------------------------------------------------------------
269QWidget *Checkbook::initCharts() 270QWidget *Checkbook::initCharts()
270{ 271{
271 graphInfo = 0x0; 272 graphInfo = 0x0;
272 273
273 QWidget *control = new QWidget( mainWidget, tr("Charts") ); 274 QWidget *control = new QWidget( mainWidget, tr("Charts") );
274 275
275 QGridLayout *layout = new QGridLayout( control ); 276 QGridLayout *layout = new QGridLayout( control );
276 layout->setSpacing( 2 ); 277 layout->setSpacing( 2 );
277 layout->setMargin( 4 ); 278 layout->setMargin( 4 );
278 279
279 graphWidget = new Graph( control ); 280 graphWidget = new Graph( control );
280 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); 281 QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
281 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); 282 layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
282 283
283 graphList = new QComboBox( control ); 284 graphList = new QComboBox( control );
284 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); 285 QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
285 graphList->insertItem( tr( "Account balance" ) ); 286 graphList->insertItem( tr( "Account balance" ) );
286 graphList->insertItem( tr( "Withdrawals by category" ) ); 287 graphList->insertItem( tr( "Withdrawals by category" ) );
287 graphList->insertItem( tr( "Deposits by category" ) ); 288 graphList->insertItem( tr( "Deposits by category" ) );
288 289
289 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); 290 layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
290 291
291 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); 292 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
292 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); 293 QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
293 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); 294 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
294 layout->addWidget( btn, 1, 2 ); 295 layout->addWidget( btn, 1, 2 );
295 296
296 return control; 297 return control;
297} 298}
298 299
299// --- loadCheckbook ---------------------------------------------------------- 300// --- loadCheckbook ----------------------------------------------------------
300void Checkbook::loadCheckbook() 301void Checkbook::loadCheckbook()
301{ 302{
302 if ( !info ) 303 if ( !info )
303 { 304 {
304 return; 305 return;
305 } 306 }
306 307
307 tranList = info->transactions(); 308 tranList = info->transactions();
308 309
309 passwordCB->setChecked( !info->password().isNull() ); 310 passwordCB->setChecked( !info->password().isNull() );
310 nameEdit->setText( info->name() ); 311 nameEdit->setText( info->name() );
311 QString temptext = info->type(); 312 QString temptext = info->type();
312 int i = typeList->count(); 313 int i = typeList->count();
313 while ( i > 0 ) 314 while ( i > 0 )
314 { 315 {
315 i--; 316 i--;
316 typeList->setCurrentItem( i ); 317 typeList->setCurrentItem( i );
317 if ( typeList->currentText() == temptext ) 318 if ( typeList->currentText() == temptext )
318 { 319 {
319 break; 320 break;
320 } 321 }
321 } 322 }
322 if( i<=0 ) { 323 if( i<=0 ) {
323 typeList->insertItem( temptext, 0 ); 324 typeList->insertItem( temptext, 0 );
324 typeList->setCurrentItem(0); 325 typeList->setCurrentItem(0);
325 } 326 }
326 bankEdit->setText( info->bank() ); 327 bankEdit->setText( info->bank() );
327 acctNumEdit->setText( info->account() ); 328 acctNumEdit->setText( info->account() );
328 pinNumEdit->setText( info->pin() ); 329 pinNumEdit->setText( info->pin() );
329 temptext.setNum( info->startingBalance(), 'f', 2 ); 330 temptext.setNum( info->startingBalance(), 'f', 2 );
330 balanceEdit->setText( temptext ); 331 balanceEdit->setText( temptext );
331 notesEdit->setText( info->notes() ); 332 notesEdit->setText( info->notes() );
332 333
333 // Load transactions 334 // Load transactions
334 float amount; 335 float amount;
335 QString stramount; 336 QString stramount;
336 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) 337 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
337 { 338 {
338 amount = tran->amount(); 339 amount = tran->amount();
339 if ( tran->withdrawal() ) 340 if ( tran->withdrawal() )
340 { 341 {
341 amount *= -1; 342 amount *= -1;
342 } 343 }
343 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 344 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
344 ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); 345 ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount );
345 } 346 }
346 347
347 // set sort order 348 // set sort order
348 bool bOk=false; 349 bool bOk=false;
349 for(int i=0; i<_cbSortType->count(); i++) { 350 for(int i=0; i<_cbSortType->count(); i++) {
350 if( _cbSortType->text(i)==info->getSortOrder() ) { 351 if( _cbSortType->text(i)==info->getSortOrder() ) {
351 _cbSortType->setCurrentItem(i); 352 _cbSortType->setCurrentItem(i);
352 slotSortChanged( info->getSortOrder() ); 353 slotSortChanged( info->getSortOrder() );
353 bOk=true; 354 bOk=true;
354 break; 355 break;
355 } 356 }
356 } 357 }
357 if( !bOk ) { 358 if( !bOk ) {
358 _cbSortType->setCurrentItem(0); 359 _cbSortType->setCurrentItem(0);
359 slotSortChanged( _cbSortType->currentText() ); 360 slotSortChanged( _cbSortType->currentText() );
360 } 361 }
361 362
362 // calc running balance 363 // calc running balance
363 adjustBalance(); 364 adjustBalance();
364} 365}
365 366
366 367
367// --- adjustBalance ---------------------------------------------------------- 368// --- adjustBalance ----------------------------------------------------------
368void Checkbook::adjustBalance() 369void Checkbook::adjustBalance()
369{ 370{
370 // update running balance in register 371 // update running balance in register
371 QString sRunning; 372 QString sRunning;
372 float bal=info->startingBalance(); 373 float bal=info->startingBalance();
373 for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { 374 for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) {
374 TranInfo *tran=item->getTranInfo(); 375 TranInfo *tran=item->getTranInfo();
375 bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); 376 bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee();
376 sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); 377 sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal );
377 item->setText( COL_BAL, sRunning); 378 item->setText( COL_BAL, sRunning);
378 } 379 }
379} 380}
380 381
381// --- resort ----------------------------------------------------------------- 382// --- resort -----------------------------------------------------------------
382void Checkbook::resort() 383void Checkbook::resort()
383{ 384{
384 tranTable->setSorting(_sortCol); 385 tranTable->setSorting(_sortCol);
385 tranTable->sort(); 386 tranTable->sort();
386 tranTable->setSorting(-1); 387 tranTable->setSorting(-1);
387} 388}
388 389
389 390
390// --- accept ----------------------------------------------------------------- 391// --- accept -----------------------------------------------------------------
391void Checkbook::accept() 392void Checkbook::accept()
392{ 393{
393 info->setName( nameEdit->text() ); 394 info->setName( nameEdit->text() );
394 info->setType( typeList->currentText() ); 395 info->setType( typeList->currentText() );
395 info->setBank( bankEdit->text() ); 396 info->setBank( bankEdit->text() );
396 info->setAccount( acctNumEdit->text() ); 397 info->setAccount( acctNumEdit->text() );
397 info->setPin( pinNumEdit->text() ); 398 info->setPin( pinNumEdit->text() );
398 bool ok; 399 bool ok;
399 info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); 400 info->setStartingBalance( balanceEdit->text().toFloat( &ok ) );
400 info->setNotes( notesEdit->text() ); 401 info->setNotes( notesEdit->text() );
401 402
402 QDialog::accept(); 403 QDialog::accept();
403} 404}
404 405
405// --- slotPasswordClicked ---------------------------------------------------- 406// --- slotPasswordClicked ----------------------------------------------------
406void Checkbook::slotPasswordClicked() 407void Checkbook::slotPasswordClicked()
407{ 408{
408 if ( info->password().isNull() && passwordCB->isChecked() ) 409 if ( info->password().isNull() && passwordCB->isChecked() )
409 { 410 {
410 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 411 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
411 if ( pw->exec() != QDialog::Accepted ) 412 if ( pw->exec() != QDialog::Accepted )
412 { 413 {
413 passwordCB->setChecked( FALSE ); 414 passwordCB->setChecked( FALSE );
414 delete pw; 415 delete pw;
415 return; 416 return;
416 } 417 }
417 info->setPassword( pw->password ); 418 info->setPassword( pw->password );
418 delete pw; 419 delete pw;
419 420
420 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); 421 pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
421 if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) 422 if ( pw->exec() != QDialog::Accepted || pw->password != info->password() )
422 { 423 {
423 passwordCB->setChecked( FALSE ); 424 passwordCB->setChecked( FALSE );
424 info->setPassword( QString::null ); 425 info->setPassword( QString::null );
425 } 426 }
426 427
427 delete pw; 428 delete pw;
428 } 429 }
429 else if ( !info->password().isNull() && !passwordCB->isChecked() ) 430 else if ( !info->password().isNull() && !passwordCB->isChecked() )
430 { 431 {
431 Password *pw = new Password( this, tr( "Enter password" ), 432 Password *pw = new Password( this, tr( "Enter password" ),
432 tr( "Please enter your password to confirm removal of password protection:" ) ); 433 tr( "Please enter your password to confirm removal of password protection:" ) );
433 if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) 434 if ( pw->exec() == QDialog::Accepted && pw->password == info->password() )
434 { 435 {
435 info->setPassword( QString::null ); 436 info->setPassword( QString::null );
436 delete pw; 437 delete pw;
437 return; 438 return;
438 } 439 }
439 else 440 else
440 { 441 {
441 passwordCB->setChecked( TRUE ); 442 passwordCB->setChecked( TRUE );
442 } 443 }
443 444
444 delete pw; 445 delete pw;
445 } 446 }
446} 447}
447 448
448void Checkbook::slotNameChanged( const QString &newname ) 449void Checkbook::slotNameChanged( const QString &newname )
449{ 450{
450 info->setName( newname ); 451 info->setName( newname );
451 452
452 // TODO - need filedir 453 // TODO - need filedir
453// QString namestr = filedir; 454// QString namestr = filedir;
454// namestr.append( newname ); 455// namestr.append( newname );
455// namestr.append( ".qcb" ); 456// namestr.append( ".qcb" );
456// info->setFilename( namestr ); 457// info->setFilename( namestr );
457 458
458 QString namestr = newname; 459 QString namestr = newname;
459 namestr.append( " - " ); 460 namestr.append( " - " );
460 namestr.append( tr( "Checkbook" ) ); 461 namestr.append( tr( "Checkbook" ) );
461 setCaption( namestr ); 462 setCaption( namestr );
462} 463}
463 464
464 465
465// ---slotStartingBalanceChanged ---------------------------------------------- 466// ---slotStartingBalanceChanged ----------------------------------------------
466void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) 467void Checkbook::slotStartingBalanceChanged( const QString &newbalance )
467{ 468{
468 bool ok; 469 bool ok;
469 info->setStartingBalance( newbalance.toFloat( &ok ) ); 470 info->setStartingBalance( newbalance.toFloat( &ok ) );
470 adjustBalance(); 471 adjustBalance();
471} 472}
472 473
473 474
474// --- slotNewTran ------------------------------------------------------------ 475// --- slotNewTran ------------------------------------------------------------
475void Checkbook::slotNewTran() 476void Checkbook::slotNewTran()
476{ 477{
477 TranInfo *traninfo = new TranInfo( info->getNextNumber() ); 478 TranInfo *traninfo = new TranInfo( info->getNextNumber() );
478 if( !_dLastNew.isNull() ) 479 if( !_dLastNew.isNull() )
479 traninfo->setDate(_dLastNew); 480 traninfo->setDate(_dLastNew);
480 481
481 Transaction *currtran = new Transaction( this, true, info->name(), 482 Transaction *currtran = new Transaction( this, true, info->name(),
482 traninfo, 483 traninfo,
483 _pCfg ); 484 _pCfg );
484 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) 485 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted )
485 { 486 {
486 // Add to transaction list 487 // Add to transaction list
487 info->addTransaction( traninfo ); 488 info->addTransaction( traninfo );
488 489
489 // Add to transaction table 490 // Add to transaction table
490 float amount; 491 float amount;
491 QString stramount; 492 QString stramount;
492 amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); 493 amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount();
493 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 494 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
494 ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), 495 ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false),
495 traninfo->number(), traninfo->datestr(true), traninfo->desc(), 496 traninfo->number(), traninfo->datestr(true), traninfo->desc(),
496 stramount ); 497 stramount );
497 resort(); 498 resort();
498 adjustBalance(); 499 adjustBalance();
499 500
500 // save last date 501 // save last date
501 _dLastNew = traninfo->date(); 502 _dLastNew = traninfo->date();
502 503
503 // save description in list of payees, if not in there 504 // save description in list of payees, if not in there
504 QStringList *pLst=&_pCfg->getPayees(); 505 QStringList *pLst=&_pCfg->getPayees();
505 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { 506 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
506 pLst->append( traninfo->desc() ); 507 pLst->append( traninfo->desc() );
507 pLst->sort(); 508 pLst->sort();
508 _pCfg->setDirty(true); 509 _pCfg->setDirty(true);
509 } 510 }
510 } 511 }
511 else 512 else
512 { 513 {
513 delete traninfo; 514 delete traninfo;
514 } 515 }
515} 516}
516 517
517 518
518// --- slotEditTran ----------------------------------------------------------- 519// --- slotEditTran -----------------------------------------------------------
519void Checkbook::slotEditTran() 520void Checkbook::slotEditTran()
520{ 521{
521 QListViewItem *curritem = tranTable->currentItem(); 522 QListViewItem *curritem = tranTable->currentItem();
522 if ( !curritem ) 523 if ( !curritem )
523 return; 524 return;
524 525
525 TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); 526 TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) );
526 527
527 Transaction *currtran = new Transaction( this, false, info->name(), 528 Transaction *currtran = new Transaction( this, false, info->name(),
528 traninfo, 529 traninfo,
529 _pCfg ); 530 _pCfg );
530 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) 531 if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted )
531 { 532 {
532 curritem->setText( COL_NUM, traninfo->number() ); 533 curritem->setText( COL_NUM, traninfo->number() );
533 curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); 534 curritem->setText( COL_SORTDATE, traninfo->datestr(false) );
534 curritem->setText( COL_DATE, traninfo->datestr(true) ); 535 curritem->setText( COL_DATE, traninfo->datestr(true) );
535 curritem->setText( COL_DESC, traninfo->desc() ); 536 curritem->setText( COL_DESC, traninfo->desc() );
536 537
537 float amount = traninfo->amount(); 538 float amount = traninfo->amount();
538 if ( traninfo->withdrawal() ) 539 if ( traninfo->withdrawal() )
539 { 540 {
540 amount *= -1; 541 amount *= -1;
541 } 542 }
542 QString stramount; 543 QString stramount;
543 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); 544 stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
544 curritem->setText( COL_AMOUNT, stramount ); 545 curritem->setText( COL_AMOUNT, stramount );
545 resort(); 546 resort();
546 adjustBalance(); 547 adjustBalance();
547 548
548 // save description in list of payees, if not in there 549 // save description in list of payees, if not in there
549 QStringList *pLst=&_pCfg->getPayees(); 550 QStringList *pLst=&_pCfg->getPayees();
550 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { 551 if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) {
551 pLst->append( traninfo->desc() ); 552 pLst->append( traninfo->desc() );
552 pLst->sort(); 553 pLst->sort();
553 _pCfg->setDirty(true); 554 _pCfg->setDirty(true);
554 } 555 }
555 } 556 }
556 557
557 delete currtran; 558 delete currtran;
558} 559}
559 560
560// --- slotMenuTran ----------------------------------------------------------- 561// --- slotMenuTran -----------------------------------------------------------
561void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) 562void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt)
562{ 563{
563 // active item? 564 // active item?
564 if( !item ) 565 if( !item )
565 return; 566 return;
566 567
567 // Display menu 568 // Display menu
568 QPopupMenu m; 569 QPopupMenu m;
569 m.insertItem( QWidget::tr( "Edit" ), 1 ); 570 m.insertItem( QWidget::tr( "Edit" ), 1 );
570 m.insertItem( QWidget::tr( "New" ), 2 ); 571 m.insertItem( QWidget::tr( "New" ), 2 );
571 m.insertItem( QWidget::tr( "Delete" ), 3 ); 572 m.insertItem( QWidget::tr( "Delete" ), 3 );
572 int r = m.exec( pnt ); 573 int r = m.exec( pnt );
573 switch(r) { 574 switch(r) {
574 case 1: 575 case 1:
575 slotEditTran(); 576 slotEditTran();
576 break; 577 break;
577 case 2: 578 case 2:
578 slotNewTran(); 579 slotNewTran();
579 break; 580 break;
580 case 3: 581 case 3:
581 slotDeleteTran(); 582 slotDeleteTran();
582 break; 583 break;
583 } 584 }
584} 585}
585 586
586 587
587// --- slotDeleteTran --------------------------------------------------------- 588// --- slotDeleteTran ---------------------------------------------------------
588void Checkbook::slotDeleteTran() 589void Checkbook::slotDeleteTran()
589{ 590{
590 QListViewItem *curritem = tranTable->currentItem(); 591 QListViewItem *curritem = tranTable->currentItem();
591 if ( !curritem ) 592 if ( !curritem )
592 return; 593 return;
593 594
594 TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); 595 TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) );
595 596
596 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) 597 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) )
597 { 598 {
598 info->removeTransaction( traninfo ); 599 info->removeTransaction( traninfo );
599 delete curritem; 600 delete curritem;
600 adjustBalance(); 601 adjustBalance();
601 } 602 }
602} 603}
603 604
604void Checkbook::slotDrawGraph() 605void Checkbook::slotDrawGraph()
605{ 606{
606 if ( graphInfo ) 607 if ( graphInfo )
607 { 608 {
608 delete graphInfo; 609 delete graphInfo;
609 } 610 }
610 611
611 switch ( graphList->currentItem() ) 612 switch ( graphList->currentItem() )
612 { 613 {
613 case 0 : drawBalanceChart(); 614 case 0 : drawBalanceChart();
614 break; 615 break;
615 case 1 : drawCategoryChart( TRUE ); 616 case 1 : drawCategoryChart( TRUE );
616 break; 617 break;
617 case 2 : drawCategoryChart( FALSE ); 618 case 2 : drawCategoryChart( FALSE );
618 break; 619 break;
619 }; 620 };
620 621
621 graphWidget->setGraphInfo( graphInfo ); 622 graphWidget->setGraphInfo( graphInfo );
622 graphWidget->drawGraph( TRUE ); 623 graphWidget->drawGraph( TRUE );
623} 624}
624 625
625void Checkbook::drawBalanceChart() 626void Checkbook::drawBalanceChart()
626{ 627{
627 DataPointList *list = new DataPointList(); 628 DataPointList *list = new DataPointList();
628 629
629 float balance = info->startingBalance(); 630 float balance = info->startingBalance();
630 float amount; 631 float amount;
631 QString label; 632 QString label;
632 int i = 0; 633 int i = 0;
633 int count = tranList->count(); 634 int count = tranList->count();
634 635
635 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) 636 for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
636 { 637 {
637 i++; 638 i++;
638 balance -= tran->fee(); 639 balance -= tran->fee();
639 amount = tran->amount(); 640 amount = tran->amount();
640 if ( tran->withdrawal() ) 641 if ( tran->withdrawal() )
641 { 642 {
642 amount *= -1; 643 amount *= -1;
643 } 644 }
644 balance += amount; 645 balance += amount;
645 if ( i == 1 || i == count / 2 || i == count ) 646 if ( i == 1 || i == count / 2 || i == count )
646 { 647 {
647 label = tran->datestr(true); 648 label = tran->datestr(true);
648 } 649 }
649 else 650 else
650 { 651 {
651 label = ""; 652 label = "";
652 } 653 }
653 list->append( new DataPointInfo( label, balance ) ); 654 list->append( new DataPointInfo( label, balance ) );
654 } 655 }
655 656
656 graphInfo = new GraphInfo( GraphInfo::BarChart, list ); 657 graphInfo = new GraphInfo( GraphInfo::BarChart, list );
657} 658}
658 659
659void Checkbook::drawCategoryChart( bool withdrawals ) 660void Checkbook::drawCategoryChart( bool withdrawals )
660{ 661{
661 DataPointList *list = new DataPointList(); 662 DataPointList *list = new DataPointList();
662 663
663 TranInfo *tran = tranList->first(); 664 TranInfo *tran = tranList->first();
664 if ( tran && tran->withdrawal() == withdrawals ) 665 if ( tran && tran->withdrawal() == withdrawals )
665 { 666 {
666 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 667 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
667 } 668 }
668 tran = tranList->next(); 669 tran = tranList->next();
669 670
670 DataPointInfo *cat; 671 DataPointInfo *cat;
671 for ( ; tran; tran = tranList->next() ) 672 for ( ; tran; tran = tranList->next() )
672 { 673 {
673 if ( tran->withdrawal() == withdrawals ) 674 if ( tran->withdrawal() == withdrawals )
674 { 675 {
675 // Find category in list 676 // Find category in list
676 for ( cat = list->first(); cat; cat = list->next() ) 677 for ( cat = list->first(); cat; cat = list->next() )
677 { 678 {
678 if ( cat->label() == tran->category() ) 679 if ( cat->label() == tran->category() )
679 { 680 {
680 break; 681 break;
681 } 682 }
682 } 683 }
683 if ( cat && cat->label() == tran->category() ) 684 if ( cat && cat->label() == tran->category() )
684 { // Found category, add to transaction to category total 685 { // Found category, add to transaction to category total
685 cat->addToValue( tran->amount() ); 686 cat->addToValue( tran->amount() );
686 } 687 }
687 else 688 else
688 { // Didn't find category, add category to list 689 { // Didn't find category, add category to list
689 list->append( new DataPointInfo( tran->category(), tran->amount() ) ); 690 list->append( new DataPointInfo( tran->category(), tran->amount() ) );
690 } 691 }
691 } 692 }
692 } 693 }
693 694
694 graphInfo = new GraphInfo( GraphInfo::PieChart, list ); 695 graphInfo = new GraphInfo( GraphInfo::PieChart, list );
695} 696}
696 697
697CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, 698CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2,
698 QString label3, QString label4, QString label5, QString label6, QString label7, 699 QString label3, QString label4, QString label5, QString label6, QString label7,
699 QString label8 ) 700 QString label8 )
700 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) 701 : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 )
701{ 702{
702 _pTran=pTran; 703 _pTran=pTran;
703 m_known = FALSE; 704 m_known = FALSE;
704 owner = parent; 705 owner = parent;
705} 706}
706 707
707void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) 708void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
708{ 709{
709 QColorGroup _cg = cg; 710 QColorGroup _cg = cg;
710 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 711 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
711 if ( pm && !pm->isNull() ) 712 if ( pm && !pm->isNull() )
712 { 713 {
713 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); 714 _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) );
714 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 715 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
715 } 716 }
716 else if ( isAltBackground() ) 717 else if ( isAltBackground() )
717 _cg.setColor(QColorGroup::Base, cg.background() ); 718 _cg.setColor(QColorGroup::Base, cg.background() );
718 719
719 QListViewItem::paintCell(p, _cg, column, width, align); 720 QListViewItem::paintCell(p, _cg, column, width, align);
720} 721}
721 722
722// --- CBListItem::isAltBackground -------------------------------------------- 723// --- CBListItem::isAltBackground --------------------------------------------
723bool CBListItem::isAltBackground() 724bool CBListItem::isAltBackground()
724{ 725{
725 QListView *lv = static_cast<QListView *>( listView() ); 726 QListView *lv = static_cast<QListView *>( listView() );
726 if ( lv ) 727 if ( lv )
727 { 728 {
728 CBListItem *above = 0; 729 CBListItem *above = 0;
729 above = (CBListItem *)( itemAbove() ); 730 above = (CBListItem *)( itemAbove() );
730 m_known = above ? above->m_known : true; 731 m_known = above ? above->m_known : true;
731 if ( m_known ) 732 if ( m_known )
732 { 733 {
733 m_odd = above ? !above->m_odd : false; 734 m_odd = above ? !above->m_odd : false;
734 } 735 }
735 else 736 else
736 { 737 {
737 CBListItem *item; 738 CBListItem *item;
738 bool previous = true; 739 bool previous = true;
739 if ( parent() ) 740 if ( parent() )
740 { 741 {
741 item = (CBListItem *)( parent() ); 742 item = (CBListItem *)( parent() );
742 if ( item ) 743 if ( item )
743 previous = item->m_odd; 744 previous = item->m_odd;
744 item = (CBListItem *)( parent()->firstChild() ); 745 item = (CBListItem *)( parent()->firstChild() );
745 } 746 }
746 else 747 else
747 { 748 {
748 item = (CBListItem *)( lv->firstChild() ); 749 item = (CBListItem *)( lv->firstChild() );
749 } 750 }
750 751
751 while(item) 752 while(item)
752 { 753 {
753 item->m_odd = previous = !previous; 754 item->m_odd = previous = !previous;
754 item->m_known = true; 755 item->m_known = true;
755 item = (CBListItem *)( item->nextSibling() ); 756 item = (CBListItem *)( item->nextSibling() );
756 } 757 }
757 } 758 }
758 return m_odd; 759 return m_odd;
759 } 760 }
760 return false; 761 return false;
761} 762}
762 763
763 764
764// --- slotTab ---------------------------------------------------------------- 765// --- slotTab ----------------------------------------------------------------
765void Checkbook::slotTab(QWidget *tab) 766void Checkbook::slotTab(QWidget *tab)
766{ 767{
767 if( !tab || !info ) return; 768 if( !tab || !info ) return;
768 info->setLastTab( tab->name() ); 769 info->setLastTab( tab->name() );
769} 770}
770 771
771 772
772// --- slotSortChanged --------------------------------------------------------- 773// --- slotSortChanged ---------------------------------------------------------
773void Checkbook::slotSortChanged( const QString &selc ) 774void Checkbook::slotSortChanged( const QString &selc )
774{ 775{
775 if( selc==tr("Entry Order") ) { 776 if( selc==tr("Entry Order") ) {
776 _sortCol=COL_ID; 777 _sortCol=COL_ID;
777 } else if( selc==tr("Number") ) { 778 } else if( selc==tr("Number") ) {
778 _sortCol=COL_NUM; 779 _sortCol=COL_NUM;
779 } else if( selc==tr("Date") ) { 780 } else if( selc==tr("Date") ) {
780 _sortCol=COL_SORTDATE; 781 _sortCol=COL_SORTDATE;
781 } 782 }
782 info->setSortOrder( selc ); 783 info->setSortOrder( selc );
783 resort(); 784 resort();
784} 785}
785 786
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h
index e2f0e56..80bc106 100644
--- a/noncore/apps/checkbook/checkbook.h
+++ b/noncore/apps/checkbook/checkbook.h
@@ -1,150 +1,149 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef CHECKBOOK_H 29#ifndef CHECKBOOK_H
30#define CHECKBOOK_H 30#define CHECKBOOK_H
31 31
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33 33
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlistview.h> 36#include <qlistview.h>
37 37
38using Opie::OTabWidget;
39 38
40class CBInfo; 39class CBInfo;
41class Graph; 40class Graph;
42class GraphInfo; 41class GraphInfo;
43class QCheckBox; 42class QCheckBox;
44class QComboBox; 43class QComboBox;
45class QLabel; 44class QLabel;
46class QLineEdit; 45class QLineEdit;
47class QListView; 46class QListView;
48class QMultiLineEdit; 47class QMultiLineEdit;
49class QString; 48class QString;
50class TranInfo; 49class TranInfo;
51class TranInfoList; 50class TranInfoList;
52class Cfg; 51class Cfg;
53class QMouseEvent; 52class QMouseEvent;
54 53
55 54
56// --- Checkbook -------------------------------------------------------------- 55// --- Checkbook --------------------------------------------------------------
57class Checkbook : public QDialog 56class Checkbook : public QDialog
58{ 57{
59 Q_OBJECT 58 Q_OBJECT
60 59
61 public: 60 public:
62 Checkbook( QWidget *, CBInfo *, Cfg *cfg ); 61 Checkbook( QWidget *, CBInfo *, Cfg *cfg );
63 ~Checkbook(); 62 ~Checkbook();
64 63
65 // resort 64 // resort
66 void resort(); 65 void resort();
67 66
68 // members 67 // members
69 TranInfoList *getTranList() { return(tranList); } 68 TranInfoList *getTranList() { return(tranList); }
70 69
71 private: 70 private:
72 CBInfo *info; 71 CBInfo *info;
73 TranInfoList *tranList; 72 TranInfoList *tranList;
74 Cfg *_pCfg; 73 Cfg *_pCfg;
75 74
76 OTabWidget *mainWidget; 75 Opie::Ui::OTabWidget *mainWidget;
77 void loadCheckbook(); 76 void loadCheckbook();
78 void adjustBalance(); 77 void adjustBalance();
79 78
80 // Info tab 79 // Info tab
81 QWidget *initInfo(); 80 QWidget *initInfo();
82 QCheckBox *passwordCB; 81 QCheckBox *passwordCB;
83 QLineEdit *nameEdit; 82 QLineEdit *nameEdit;
84 QComboBox *typeList; 83 QComboBox *typeList;
85 QLineEdit *bankEdit; 84 QLineEdit *bankEdit;
86 QLineEdit *acctNumEdit; 85 QLineEdit *acctNumEdit;
87 QLineEdit *pinNumEdit; 86 QLineEdit *pinNumEdit;
88 QLineEdit *balanceEdit; 87 QLineEdit *balanceEdit;
89 QMultiLineEdit *notesEdit; 88 QMultiLineEdit *notesEdit;
90 int _sortCol; 89 int _sortCol;
91 90
92 // Transactions tab 91 // Transactions tab
93 QWidget *initTransactions(); 92 QWidget *initTransactions();
94 QListView *tranTable; 93 QListView *tranTable;
95 QComboBox *_cbSortType; 94 QComboBox *_cbSortType;
96 QDate _dLastNew; 95 QDate _dLastNew;
97 96
98 // Charts tab 97 // Charts tab
99 QWidget *initCharts(); 98 QWidget *initCharts();
100 GraphInfo *graphInfo; 99 GraphInfo *graphInfo;
101 QComboBox *graphList; 100 QComboBox *graphList;
102 Graph *graphWidget; 101 Graph *graphWidget;
103 102
104 void drawBalanceChart(); 103 void drawBalanceChart();
105 void drawCategoryChart( bool = TRUE ); 104 void drawCategoryChart( bool = TRUE );
106 105
107 106
108 protected slots: 107 protected slots:
109 void accept(); 108 void accept();
110 void slotTab(QWidget *tab); 109 void slotTab(QWidget *tab);
111 110
112 private slots: 111 private slots:
113 void slotPasswordClicked(); 112 void slotPasswordClicked();
114 void slotNameChanged( const QString & ); 113 void slotNameChanged( const QString & );
115 void slotStartingBalanceChanged( const QString & ); 114 void slotStartingBalanceChanged( const QString & );
116 void slotNewTran(); 115 void slotNewTran();
117 void slotEditTran(); 116 void slotEditTran();
118 void slotMenuTran(QListViewItem *, const QPoint &); 117 void slotMenuTran(QListViewItem *, const QPoint &);
119 void slotDeleteTran(); 118 void slotDeleteTran();
120 void slotDrawGraph(); 119 void slotDrawGraph();
121 void slotSortChanged( const QString & ); 120 void slotSortChanged( const QString & );
122}; 121};
123 122
124 123
125// --- CBListItem ------------------------------------------------------------- 124// --- CBListItem -------------------------------------------------------------
126class CBListItem : public QListViewItem 125class CBListItem : public QListViewItem
127{ 126{
128 //Q_OBJECT 127 //Q_OBJECT
129 128
130 public: 129 public:
131 CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, 130 CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null,
132 QString = QString::null, QString = QString::null, QString = QString::null, 131 QString = QString::null, QString = QString::null, QString = QString::null,
133 QString = QString::null, QString = QString::null, QString = QString::null ); 132 QString = QString::null, QString = QString::null, QString = QString::null );
134 133
135 void paintCell( QPainter *, const QColorGroup &, int, int, int ); 134 void paintCell( QPainter *, const QColorGroup &, int, int, int );
136 135
137 // --- members 136 // --- members
138 TranInfo *getTranInfo() { return(_pTran); } 137 TranInfo *getTranInfo() { return(_pTran); }
139 138
140 private: 139 private:
141 TranInfo *_pTran; 140 TranInfo *_pTran;
142 QListView *owner; 141 QListView *owner;
143 bool m_known; 142 bool m_known;
144 bool m_odd; 143 bool m_odd;
145 144
146 bool isAltBackground(); 145 bool isAltBackground();
147}; 146};
148 147
149 148
150#endif 149#endif
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp
index 0384620..1135bee 100644
--- a/noncore/apps/checkbook/main.cpp
+++ b/noncore/apps/checkbook/main.cpp
@@ -1,33 +1,35 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <opie2/oapplicationfactory.h> 29#include <opie2/oapplicationfactory.h>
30 30
31using namespace Opie::Core;
32using namespace Opie::Core;
31#include "mainwindow.h" 33#include "mainwindow.h"
32 34
33OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 35OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 254ce6a..ce15e3e 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -1,358 +1,358 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> 4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "mainwindow.h" 29#include "mainwindow.h"
30#include "cbinfo.h" 30#include "cbinfo.h"
31#include "configuration.h" 31#include "configuration.h"
32#include "password.h" 32#include "password.h"
33#include "checkbook.h" 33#include "checkbook.h"
34 34
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
38#include <qpe/qpetoolbar.h> 38#include <qtoolbar.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qmenubar.h> 41#include <qmenubar.h>
42#include <qaction.h> 42#include <qaction.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qwhatsthis.h> 44#include <qwhatsthis.h>
45 45
46 46
47MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) 47MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ )
48 : QMainWindow( parent, name, WStyle_ContextHelp ) 48 : QMainWindow( parent, name, WStyle_ContextHelp )
49{ 49{
50 setCaption( tr( "Checkbook" ) ); 50 setCaption( tr( "Checkbook" ) );
51 51
52 cbDir = Global::applicationFileName( "checkbook", "" ); 52 cbDir = Global::applicationFileName( "checkbook", "" );
53 lockIcon = Resource::loadPixmap( "locked" ); 53 lockIcon = Resource::loadPixmap( "locked" );
54 54
55 // Load configuration options 55 // Load configuration options
56 Config config( "checkbook" ); 56 Config config( "checkbook" );
57 _cfg.readConfig( config ); 57 _cfg.readConfig( config );
58 58
59 59
60 // Build menu and tool bars 60 // Build menu and tool bars
61 setToolBarsMovable( FALSE ); 61 setToolBarsMovable( FALSE );
62 62
63 QToolBar *bar = new QToolBar( this ); 63 QToolBar *bar = new QToolBar( this );
64 bar->setHorizontalStretchable( TRUE ); 64 bar->setHorizontalStretchable( TRUE );
65 QMenuBar *mb = new QMenuBar( bar ); 65 QMenuBar *mb = new QMenuBar( bar );
66 mb->setMargin( 0 ); 66 mb->setMargin( 0 );
67 QPopupMenu *popup = new QPopupMenu( this ); 67 QPopupMenu *popup = new QPopupMenu( this );
68 68
69 bar = new QToolBar( this ); 69 bar = new QToolBar( this );
70 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 70 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
71 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); 71 a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
72 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); 72 connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
73 a->addTo( popup ); 73 a->addTo( popup );
74 a->addTo( bar ); 74 a->addTo( bar );
75 75
76 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 76 actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
77 0, this, 0 ); 77 0, this, 0 );
78 actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); 78 actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) );
79 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); 79 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
80 actionOpen->addTo( popup ); 80 actionOpen->addTo( popup );
81 actionOpen->addTo( bar ); 81 actionOpen->addTo( bar );
82 82
83 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 83 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
84 0, this, 0 ); 84 0, this, 0 );
85 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); 85 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
86 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); 86 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
87 actionDelete->addTo( popup ); 87 actionDelete->addTo( popup );
88 actionDelete->addTo( bar ); 88 actionDelete->addTo( bar );
89 89
90 popup->insertSeparator(); 90 popup->insertSeparator();
91 91
92 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 92 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
93 a->setWhatsThis( tr( "Click here to configure this app." ) ); 93 a->setWhatsThis( tr( "Click here to configure this app." ) );
94 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); 94 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
95 a->addTo( popup ); 95 a->addTo( popup );
96 a->addTo( bar ); 96 a->addTo( bar );
97 97
98 mb->insertItem( tr( "Checkbook" ), popup ); 98 mb->insertItem( tr( "Checkbook" ), popup );
99 99
100 // Load Checkbook selection list 100 // Load Checkbook selection list
101 checkbooks = new CBInfoList(); 101 checkbooks = new CBInfoList();
102 102
103 QDir checkdir( cbDir ); 103 QDir checkdir( cbDir );
104 if (checkdir.exists() == true) 104 if (checkdir.exists() == true)
105 { 105 {
106 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, 106 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
107 QDir::Time ); 107 QDir::Time );
108 CBInfo *cb = 0x0; 108 CBInfo *cb = 0x0;
109 QString filename; 109 QString filename;
110 110
111 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) 111 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
112 { 112 {
113 filename = cbDir; 113 filename = cbDir;
114 filename.append( (*it) ); 114 filename.append( (*it) );
115 115
116 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); 116 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
117 checkbooks->inSort( cb ); 117 checkbooks->inSort( cb );
118 } 118 }
119 } 119 }
120 120
121 // Build Checkbook selection list control 121 // Build Checkbook selection list control
122 cbList = 0x0; 122 cbList = 0x0;
123 buildList(); 123 buildList();
124 124
125 // open last book? 125 // open last book?
126 if( _cfg.isOpenLastBook() ) { 126 if( _cfg.isOpenLastBook() ) {
127 this->show(); 127 this->show();
128 this->showMaximized(); 128 this->showMaximized();
129 QListViewItem *itm=cbList->firstChild(); 129 QListViewItem *itm=cbList->firstChild();
130 while( itm ) { 130 while( itm ) {
131 if( itm->text(posName)==_cfg.getLastBook() ) { 131 if( itm->text(posName)==_cfg.getLastBook() ) {
132 openBook( itm ); 132 openBook( itm );
133 break; 133 break;
134 } 134 }
135 itm=itm->nextSibling(); 135 itm=itm->nextSibling();
136 } 136 }
137 } 137 }
138} 138}
139 139
140 140
141// --- ~MainWindow ------------------------------------------------------------ 141// --- ~MainWindow ------------------------------------------------------------
142MainWindow::~MainWindow() 142MainWindow::~MainWindow()
143{ 143{
144 writeConfig(); 144 writeConfig();
145} 145}
146 146
147 147
148// --- buildList -------------------------------------------------------------- 148// --- buildList --------------------------------------------------------------
149void MainWindow::buildList() 149void MainWindow::buildList()
150{ 150{
151 if ( cbList ) 151 if ( cbList )
152 delete cbList; 152 delete cbList;
153 153
154 cbList = new QListView( this ); 154 cbList = new QListView( this );
155 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 155 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
156 156
157 if ( _cfg.getShowLocks() ) 157 if ( _cfg.getShowLocks() )
158 { 158 {
159 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); 159 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
160 posName = 1; 160 posName = 1;
161 } 161 }
162 else 162 else
163 { 163 {
164 posName = 0; 164 posName = 0;
165 } 165 }
166 cbList->addColumn( tr( "Checkbook Name" ) ); 166 cbList->addColumn( tr( "Checkbook Name" ) );
167 if ( _cfg.getShowBalances() ) 167 if ( _cfg.getShowBalances() )
168 { 168 {
169 int colnum = cbList->addColumn( tr( "Balance" ) ); 169 int colnum = cbList->addColumn( tr( "Balance" ) );
170 cbList->setColumnAlignment( colnum, Qt::AlignRight ); 170 cbList->setColumnAlignment( colnum, Qt::AlignRight );
171 } 171 }
172 cbList->setAllColumnsShowFocus( TRUE ); 172 cbList->setAllColumnsShowFocus( TRUE );
173 cbList->setSorting( posName ); 173 cbList->setSorting( posName );
174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
175 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), 175 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
176 this, SLOT( slotEdit() ) ); 176 this, SLOT( slotEdit() ) );
177 setCentralWidget( cbList ); 177 setCentralWidget( cbList );
178 178
179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) 179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
180 { 180 {
181 addCheckbook( cb ); 181 addCheckbook( cb );
182 } 182 }
183} 183}
184 184
185void MainWindow::addCheckbook( CBInfo *cb ) 185void MainWindow::addCheckbook( CBInfo *cb )
186{ 186{
187 QListViewItem *lvi = new QListViewItem( cbList ); 187 QListViewItem *lvi = new QListViewItem( cbList );
188 if ( _cfg.getShowLocks() && !cb->password().isNull() ) 188 if ( _cfg.getShowLocks() && !cb->password().isNull() )
189 { 189 {
190 lvi->setPixmap( 0, lockIcon ); 190 lvi->setPixmap( 0, lockIcon );
191 } 191 }
192 lvi->setText( posName, cb->name() ); 192 lvi->setText( posName, cb->name() );
193 if ( _cfg.getShowBalances() ) 193 if ( _cfg.getShowBalances() )
194 { 194 {
195 QString balance; 195 QString balance;
196 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 196 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
197 lvi->setText( posName + 1, balance ); 197 lvi->setText( posName + 1, balance );
198 } 198 }
199} 199}
200 200
201void MainWindow::buildFilename( const QString &name ) 201void MainWindow::buildFilename( const QString &name )
202{ 202{
203 tempFilename = cbDir; 203 tempFilename = cbDir;
204 tempFilename.append( name ); 204 tempFilename.append( name );
205 tempFilename.append( ".qcb" ); 205 tempFilename.append( ".qcb" );
206} 206}
207 207
208void MainWindow::slotNew() 208void MainWindow::slotNew()
209{ 209{
210 CBInfo *cb = new CBInfo(); 210 CBInfo *cb = new CBInfo();
211 211
212 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 212 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
213 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 213 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
214 { 214 {
215 // Save new checkbook 215 // Save new checkbook
216 buildFilename( cb->name() ); 216 buildFilename( cb->name() );
217 _cfg.setLastBook( cb->name() ); 217 _cfg.setLastBook( cb->name() );
218 cb->setFilename( tempFilename ); 218 cb->setFilename( tempFilename );
219 cb->write(); 219 cb->write();
220 220
221 // Add to listbox 221 // Add to listbox
222 checkbooks->inSort( cb ); 222 checkbooks->inSort( cb );
223 addCheckbook( cb ); 223 addCheckbook( cb );
224 } 224 }
225 delete currcb; 225 delete currcb;
226} 226}
227 227
228// --- slotEdit --------------------------------------------------------------- 228// --- slotEdit ---------------------------------------------------------------
229void MainWindow::slotEdit() 229void MainWindow::slotEdit()
230{ 230{
231 // get name and open it 231 // get name and open it
232 QListViewItem *curritem = cbList->currentItem(); 232 QListViewItem *curritem = cbList->currentItem();
233 if ( !curritem ) 233 if ( !curritem )
234 return; 234 return;
235 openBook( curritem ); 235 openBook( curritem );
236} 236}
237 237
238 238
239// --- openBook --------------------------------------------------------------- 239// --- openBook ---------------------------------------------------------------
240void MainWindow::openBook(QListViewItem *curritem) 240void MainWindow::openBook(QListViewItem *curritem)
241{ 241{
242 // find book in List 242 // find book in List
243 QString currname=curritem->text(posName); 243 QString currname=curritem->text(posName);
244 CBInfo *cb = checkbooks->first(); 244 CBInfo *cb = checkbooks->first();
245 while ( cb ) { 245 while ( cb ) {
246 if ( cb->name() == currname ) 246 if ( cb->name() == currname )
247 break; 247 break;
248 cb = checkbooks->next(); 248 cb = checkbooks->next();
249 } 249 }
250 if ( !cb ) return; 250 if ( !cb ) return;
251 251
252 // 252 //
253 buildFilename( currname ); 253 buildFilename( currname );
254 float currbalance = cb->balance(); 254 float currbalance = cb->balance();
255 bool currlock = !cb->password().isNull(); 255 bool currlock = !cb->password().isNull();
256 256
257 if ( currlock ) 257 if ( currlock )
258 { 258 {
259 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 259 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
260 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) 260 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
261 { 261 {
262 delete pw; 262 delete pw;
263 return; 263 return;
264 } 264 }
265 delete pw; 265 delete pw;
266 } 266 }
267 267
268 _cfg.setLastBook( currname ); 268 _cfg.setLastBook( currname );
269 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 269 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
270 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 270 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
271 { 271 {
272 QString newname = cb->name(); 272 QString newname = cb->name();
273 if ( currname != newname ) 273 if ( currname != newname )
274 { 274 {
275 // Update name if changed 275 // Update name if changed
276 if( curritem ) { 276 if( curritem ) {
277 curritem->setText( posName, newname ); 277 curritem->setText( posName, newname );
278 cbList->sort(); 278 cbList->sort();
279 } 279 }
280 _cfg.setLastBook( newname ); 280 _cfg.setLastBook( newname );
281 281
282 // Remove old file 282 // Remove old file
283 QFile f( tempFilename ); 283 QFile f( tempFilename );
284 if ( f.exists() ) 284 if ( f.exists() )
285 f.remove(); 285 f.remove();
286 286
287 // Get new filename 287 // Get new filename
288 buildFilename( newname ); 288 buildFilename( newname );
289 cb->setFilename( tempFilename ); 289 cb->setFilename( tempFilename );
290 } 290 }
291 291
292 cb->write(); 292 cb->write();
293 293
294 // Update lock if changed 294 // Update lock if changed
295 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) 295 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
296 { 296 {
297 if ( !cb->password().isNull() ) 297 if ( !cb->password().isNull() )
298 curritem->setPixmap( 0, lockIcon ); 298 curritem->setPixmap( 0, lockIcon );
299 else 299 else
300 curritem->setPixmap( 0, nullIcon ); 300 curritem->setPixmap( 0, nullIcon );
301 } 301 }
302 302
303 // Update balance if changed 303 // Update balance if changed
304 if ( _cfg.getShowBalances() && cb->balance() != currbalance ) 304 if ( _cfg.getShowBalances() && cb->balance() != currbalance )
305 { 305 {
306 QString tempstr; 306 QString tempstr;
307 tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 307 tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
308 curritem->setText( posName + 1, tempstr ); 308 curritem->setText( posName + 1, tempstr );
309 } 309 }
310 310
311 // write config, if needed 311 // write config, if needed
312 if( _cfg.isDirty() ) { 312 if( _cfg.isDirty() ) {
313 Config config("checkbook"); 313 Config config("checkbook");
314 _cfg.writeConfig( config ); 314 _cfg.writeConfig( config );
315 } 315 }
316 } 316 }
317 delete currcb; 317 delete currcb;
318} 318}
319 319
320// --- slotDelete ------------------------------------------------------------- 320// --- slotDelete -------------------------------------------------------------
321void MainWindow::slotDelete() 321void MainWindow::slotDelete()
322{ 322{
323 QString currname = cbList->currentItem()->text( posName ); 323 QString currname = cbList->currentItem()->text( posName );
324 324
325 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) 325 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
326 { 326 {
327 buildFilename( currname ); 327 buildFilename( currname );
328 QFile f( tempFilename ); 328 QFile f( tempFilename );
329 if ( f.exists() ) 329 if ( f.exists() )
330 { 330 {
331 f.remove(); 331 f.remove();
332 } 332 }
333 333
334 delete cbList->currentItem(); 334 delete cbList->currentItem();
335 } 335 }
336} 336}
337 337
338// --- slotConfigure ---------------------------------------------------------- 338// --- slotConfigure ----------------------------------------------------------
339void MainWindow::slotConfigure() 339void MainWindow::slotConfigure()
340{ 340{
341 Configuration *cfgdlg = new Configuration( this, _cfg ); 341 Configuration *cfgdlg = new Configuration( this, _cfg );
342 if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted ) 342 if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted )
343 { 343 {
344 // read data from config dialog & save it 344 // read data from config dialog & save it
345 cfgdlg->saveConfig( _cfg ); 345 cfgdlg->saveConfig( _cfg );
346 writeConfig(); 346 writeConfig();
347 buildList(); 347 buildList();
348 } 348 }
349 delete cfgdlg; 349 delete cfgdlg;
350} 350}
351 351
352 352
353// --- writeConfig -------------------------------------------------------------- 353// --- writeConfig --------------------------------------------------------------
354void MainWindow::writeConfig() 354void MainWindow::writeConfig()
355{ 355{
356 Config config("checkbook"); 356 Config config("checkbook");
357 _cfg.writeConfig( config ); 357 _cfg.writeConfig( config );
358} 358}
diff --git a/noncore/apps/confedit/main.cpp b/noncore/apps/confedit/main.cpp
index 584e6b2..3a010dd 100644
--- a/noncore/apps/confedit/main.cpp
+++ b/noncore/apps/confedit/main.cpp
@@ -1,5 +1,6 @@
1
2#include "mainwindow.h" 1#include "mainwindow.h"
3#include <opie2/oapplicationfactory.h> 2#include <opie2/oapplicationfactory.h>
4 3
4using namespace Opie::Core;
5
5OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 6OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/apps/odict/main.cpp b/noncore/apps/odict/main.cpp
index d5b08d3..7729d5f 100644
--- a/noncore/apps/odict/main.cpp
+++ b/noncore/apps/odict/main.cpp
@@ -1,24 +1,26 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : ODict 2 application: : ODict
3 3
4 begin : December 2002 4 begin : December 2002
5 copyright : ( C ) 2002, 2003 by Carsten Niehaus 5 copyright : ( C ) 2002, 2003 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17 17
18 18
19#include <opie2/oapplicationfactory.h> 19#include <opie2/oapplicationfactory.h>
20 20
21#include "odict.h" 21#include "odict.h"
22 22
23 23
24using namespace Opie::Core;
25using namespace Opie::Core;
24OPIE_EXPORT_APP( OApplicationFactory<ODict> ) 26OPIE_EXPORT_APP( OApplicationFactory<ODict> )
diff --git a/noncore/apps/odict/searchmethoddlg.cpp b/noncore/apps/odict/searchmethoddlg.cpp
index f71cfd8..34e8b16 100644
--- a/noncore/apps/odict/searchmethoddlg.cpp
+++ b/noncore/apps/odict/searchmethoddlg.cpp
@@ -1,109 +1,108 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : ODict 2 application: : ODict
3 3
4 begin : December 2002 4 begin : December 2002
5 copyright : ( C ) 2002, 2003 by Carsten Niehaus 5 copyright : ( C ) 2002, 2003 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17#include "searchmethoddlg.h" 17#include "searchmethoddlg.h"
18 18
19#include <opie2/ofileselector.h> 19#include <opie2/ofileselector.h>
20#include <opie2/ofiledialog.h> 20#include <opie2/ofiledialog.h>
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32using Opie::OFileDialog; 32using namespace Opie::Ui;
33using Opie::OFileSelector;
34 33
35SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal) 34SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal)
36{ 35{
37 36
38 QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" ); 37 QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" );
39 QVBox *vbox = new QVBox( this ); 38 QVBox *vbox = new QVBox( this );
40 39
41 QHBox *hbox1 = new QHBox( vbox ); 40 QHBox *hbox1 = new QHBox( vbox );
42 QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 ); 41 QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 );
43 nameLE = new QLineEdit( hbox1 ); 42 nameLE = new QLineEdit( hbox1 );
44 43
45 QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox ); 44 QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox );
46 QHBox *hbox2 = new QHBox( vbox ); 45 QHBox *hbox2 = new QHBox( vbox );
47 dictFileLE = new QLineEdit( hbox2 ); 46 dictFileLE = new QLineEdit( hbox2 );
48 QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 ); 47 QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 );
49 connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) ); 48 connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) );
50 49
51 QWidget *dummywidget = new QWidget( vbox ); 50 QWidget *dummywidget = new QWidget( vbox );
52 QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget); 51 QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget);
53 QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget); 52 QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget);
54 QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget); 53 QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget);
55 lang1 = new QLineEdit( dummywidget ); 54 lang1 = new QLineEdit( dummywidget );
56 lang2 = new QLineEdit( dummywidget ); 55 lang2 = new QLineEdit( dummywidget );
57 trenner = new QLineEdit( dummywidget ); 56 trenner = new QLineEdit( dummywidget );
58 trenner->setText( "::" ); 57 trenner->setText( "::" );
59 58
60 QGridLayout *grid = new QGridLayout( dummywidget, 2,3 ); 59 QGridLayout *grid = new QGridLayout( dummywidget, 2,3 );
61 grid->addWidget( lag1, 0,0 ); 60 grid->addWidget( lag1, 0,0 );
62 grid->addWidget( devider, 0,1 ); 61 grid->addWidget( devider, 0,1 );
63 grid->addWidget( lag2, 0,2 ); 62 grid->addWidget( lag2, 0,2 );
64 grid->addWidget( lang1, 1,0 ); 63 grid->addWidget( lang1, 1,0 );
65 grid->addWidget( trenner, 1,1 ); 64 grid->addWidget( trenner, 1,1 );
66 grid->addWidget( lang2, 1,2 ); 65 grid->addWidget( lang2, 1,2 );
67 66
68 vbox_layout->addWidget( vbox ); 67 vbox_layout->addWidget( vbox );
69 68
70 QPEApplication::execDialog ( this ); 69 QPEApplication::execDialog ( this );
71 70
72 if( !itemname ) 71 if( !itemname )
73 setCaption( tr( "New Searchmethod" ) ); 72 setCaption( tr( "New Searchmethod" ) );
74 else 73 else
75 { 74 {
76 setCaption( tr( "Change Searchmethod" ) ); 75 setCaption( tr( "Change Searchmethod" ) );
77 itemName = itemname; 76 itemName = itemname;
78 setupEntries(itemname); 77 setupEntries(itemname);
79 } 78 }
80} 79}
81 80
82void SearchMethodDlg::setupEntries( QString item ) 81void SearchMethodDlg::setupEntries( QString item )
83{ 82{
84 Config cfg( "odict" ); 83 Config cfg( "odict" );
85 cfg.setGroup( "Method_"+itemName ); 84 cfg.setGroup( "Method_"+itemName );
86 trenner->setText( cfg.readEntry( "Seperator" ) ); 85 trenner->setText( cfg.readEntry( "Seperator" ) );
87 lang1->setText( cfg.readEntry( "Lang1" ) ); 86 lang1->setText( cfg.readEntry( "Lang1" ) );
88 lang2->setText( cfg.readEntry( "Lang2" ) ); 87 lang2->setText( cfg.readEntry( "Lang2" ) );
89 nameLE->setText( itemName ); 88 nameLE->setText( itemName );
90 dictFileLE->setText( cfg.readEntry( "file" ) ); 89 dictFileLE->setText( cfg.readEntry( "file" ) );
91} 90}
92 91
93void SearchMethodDlg::slotBrowse() 92void SearchMethodDlg::slotBrowse()
94{ 93{
95 itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath()); 94 itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath());
96 dictFileLE->setText( itemName ); 95 dictFileLE->setText( itemName );
97} 96}
98 97
99void SearchMethodDlg::saveItem() 98void SearchMethodDlg::saveItem()
100{ 99{
101 QString name = nameLE->text(); 100 QString name = nameLE->text();
102 Config cfg( "odict" ); 101 Config cfg( "odict" );
103 cfg.setGroup( "Method_"+name ); 102 cfg.setGroup( "Method_"+name );
104 cfg.writeEntry( "Name", name ); 103 cfg.writeEntry( "Name", name );
105 cfg.writeEntry( "Seperator", trenner->text() ); 104 cfg.writeEntry( "Seperator", trenner->text() );
106 cfg.writeEntry( "Lang1", lang1->text() ); 105 cfg.writeEntry( "Lang1", lang1->text() );
107 cfg.writeEntry( "Lang2", lang2->text() ); 106 cfg.writeEntry( "Lang2", lang2->text() );
108 cfg.writeEntry( "file", dictFileLE->text() ); 107 cfg.writeEntry( "file", dictFileLE->text() );
109} 108}
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index b6401ed..e6cb515 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -1,432 +1,432 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Sat Jul 20 08:10:53 2002 3** Created: Sat Jul 20 08:10:53 2002
4** by: L.J. Potter <ljp@llornkcor.com> 4** by: L.J. Potter <ljp@llornkcor.com>
5** copyright : (C) 2002 by ljp 5** copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12 12
13#include "bartender.h" 13#include "bartender.h"
14#include "showdrinks.h" 14#include "showdrinks.h"
15#include "inputDialog.h" 15#include "inputDialog.h"
16#include "searchresults.h" 16#include "searchresults.h"
17#include "bac.h" 17#include "bac.h"
18 18
19#include <qpe/qpetoolbar.h> 19#include <qtoolbar.h>
20#include <qmenubar.h> 20#include <qmenubar.h>
21//#include <opie2/colorpopupmenu.h> 21//#include <opie2/colorpopupmenu.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qdir.h> 26#include <qdir.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29#include <qmultilineedit.h> 29#include <qmultilineedit.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qaction.h> 32#include <qaction.h>
33#include <qheader.h> 33#include <qheader.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qlayout.h> 35#include <qlayout.h>
36 36
37#include <fcntl.h> 37#include <fcntl.h>
38#include <unistd.h> 38#include <unistd.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <stdio.h> 40#include <stdio.h>
41#include <errno.h> 41#include <errno.h>
42 42
43 43
44Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) 44Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
45 : QMainWindow( parent, name, fl ) { 45 : QMainWindow( parent, name, fl ) {
46 if ( !name ) 46 if ( !name )
47 setName( "Bartender" ); 47 setName( "Bartender" );
48 QGridLayout *layout = new QGridLayout( this ); 48 QGridLayout *layout = new QGridLayout( this );
49 layout->setSpacing( 2); 49 layout->setSpacing( 2);
50 layout->setMargin( 2); 50 layout->setMargin( 2);
51 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 51 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
52 52
53 setCaption( tr( "Bartender" ) ); 53 setCaption( tr( "Bartender" ) );
54 54
55 ToolBar1 = new QToolBar( this, "ToolBar1" ); 55 ToolBar1 = new QToolBar( this, "ToolBar1" );
56 ToolBar1->setFixedHeight(22); 56 ToolBar1->setFixedHeight(22);
57 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); 57 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
58 58
59 QMenuBar *menuBar = new QMenuBar( ToolBar1 ); 59 QMenuBar *menuBar = new QMenuBar( ToolBar1 );
60 QPopupMenu *fileMenu; 60 QPopupMenu *fileMenu;
61 fileMenu = new QPopupMenu( this); 61 fileMenu = new QPopupMenu( this);
62 menuBar->insertItem( tr("File"), fileMenu ); 62 menuBar->insertItem( tr("File"), fileMenu );
63 63
64 fileMenu->insertItem(tr("New Drink")); 64 fileMenu->insertItem(tr("New Drink"));
65 fileMenu->insertItem(tr("Open Drink")); 65 fileMenu->insertItem(tr("Open Drink"));
66 fileMenu->insertItem(tr("Find by Drink Name")); 66 fileMenu->insertItem(tr("Find by Drink Name"));
67 fileMenu->insertItem(tr("Find by Alcohol")); 67 fileMenu->insertItem(tr("Find by Alcohol"));
68 68
69 QPopupMenu *editMenu; 69 QPopupMenu *editMenu;
70 editMenu = new QPopupMenu( this); 70 editMenu = new QPopupMenu( this);
71 menuBar->insertItem( tr("Edit"), editMenu ); 71 menuBar->insertItem( tr("Edit"), editMenu );
72 editMenu->insertItem(tr("edit")); 72 editMenu->insertItem(tr("edit"));
73 73
74 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); 74 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) ));
75 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); 75 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) ));
76 76
77 77
78 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); 78 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 );
79 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 79 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
80 a->addTo( ToolBar1 ); 80 a->addTo( ToolBar1 );
81 81
82 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); 82 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 );
83 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); 83 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) );
84 a->addTo( ToolBar1 ); 84 a->addTo( ToolBar1 );
85 85
86 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); 86 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 );
87 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); 87 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) );
88 a->addTo( ToolBar1 ); 88 a->addTo( ToolBar1 );
89 89
90 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); 90 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 );
91 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); 91 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) );
92 a->addTo( ToolBar1 ); 92 a->addTo( ToolBar1 );
93 93
94 QPushButton *t; 94 QPushButton *t;
95 t= new QPushButton( "BAC", ToolBar1, "bacButtin"); 95 t= new QPushButton( "BAC", ToolBar1, "bacButtin");
96 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); 96 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) );
97 97
98 DrinkView = new QListView( this, "DrinkView" ); 98 DrinkView = new QListView( this, "DrinkView" );
99 DrinkView->addColumn( tr( "Name of Drink" ) ); 99 DrinkView->addColumn( tr( "Name of Drink" ) );
100// DrinkView->setRootIsDecorated( TRUE ); 100// DrinkView->setRootIsDecorated( TRUE );
101 DrinkView->header()->hide(); 101 DrinkView->header()->hide();
102 102
103 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); 103 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold);
104 104
105 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); 105 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*)));
106 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 106 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
107 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); 107 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int)));
108 108
109 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); 109 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 );
110 if(QDir("db").exists()) { 110 if(QDir("db").exists()) {
111 dbFile.setName( "db/drinkdb.txt"); 111 dbFile.setName( "db/drinkdb.txt");
112 } else 112 } else
113 dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); 113 dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt");
114 initDrinkDb(); 114 initDrinkDb();
115} 115}
116 116
117Bartender::~Bartender() { 117Bartender::~Bartender() {
118} 118}
119 119
120/* 120/*
121this happens right before exit */ 121this happens right before exit */
122void Bartender::cleanUp() { 122void Bartender::cleanUp() {
123 dbFile.close(); 123 dbFile.close();
124 124
125} 125}
126 126
127void Bartender::initDrinkDb() { 127void Bartender::initDrinkDb() {
128 128
129 if(!dbFile.isOpen()) 129 if(!dbFile.isOpen())
130 if ( !dbFile.open( IO_ReadOnly)) { 130 if ( !dbFile.open( IO_ReadOnly)) {
131 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 131 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
132 return; 132 return;
133 } 133 }
134 fillList(); 134 fillList();
135} 135}
136 136
137void Bartender::fillList() { 137void Bartender::fillList() {
138 dbFile.at(1); 138 dbFile.at(1);
139 DrinkView->clear(); 139 DrinkView->clear();
140 int i=0; 140 int i=0;
141 QListViewItem * item ; 141 QListViewItem * item ;
142 QTextStream t( &dbFile); 142 QTextStream t( &dbFile);
143 QString s; 143 QString s;
144 while ( !t.eof()) { 144 while ( !t.eof()) {
145 s = t.readLine(); 145 s = t.readLine();
146 if(s.find("#",0,TRUE) != -1) { 146 if(s.find("#",0,TRUE) != -1) {
147// qDebug(s.right(s.length()-2)); 147// qDebug(s.right(s.length()-2));
148 item= new QListViewItem( DrinkView, 0 ); 148 item= new QListViewItem( DrinkView, 0 );
149 item->setText( 0, s.right(s.length()-2)); 149 item->setText( 0, s.right(s.length()-2));
150 i++; 150 i++;
151 } 151 }
152 } 152 }
153 qDebug("there are currently %d of drinks", i); 153 qDebug("there are currently %d of drinks", i);
154} 154}
155 155
156void Bartender::fileNew() { 156void Bartender::fileNew() {
157 157
158 New_Drink *newDrinks; 158 New_Drink *newDrinks;
159 newDrinks = new New_Drink(this,"New Drink....", TRUE); 159 newDrinks = new New_Drink(this,"New Drink....", TRUE);
160 QString newName, newIng; 160 QString newName, newIng;
161 QPEApplication::execDialog( newDrinks ); 161 QPEApplication::execDialog( newDrinks );
162 newName = newDrinks->LineEdit1->text(); 162 newName = newDrinks->LineEdit1->text();
163 newIng= newDrinks->MultiLineEdit1->text(); 163 newIng= newDrinks->MultiLineEdit1->text();
164 164
165 if(dbFile.isOpen()) 165 if(dbFile.isOpen())
166 dbFile.close(); 166 dbFile.close();
167 if ( !dbFile.open( IO_WriteOnly| IO_Append)) { 167 if ( !dbFile.open( IO_WriteOnly| IO_Append)) {
168 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 168 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
169 return; 169 return;
170 } 170 }
171 if(newDrinks ->result() == 1 ) { 171 if(newDrinks ->result() == 1 ) {
172 QString newDrink="\n# "+newName+"\n"; 172 QString newDrink="\n# "+newName+"\n";
173 newDrink.append(newIng+"\n"); 173 newDrink.append(newIng+"\n");
174 qDebug("writing "+newDrink); 174 qDebug("writing "+newDrink);
175 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 175 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
176 clearList(); 176 clearList();
177 dbFile.close(); 177 dbFile.close();
178 178
179 initDrinkDb(); 179 initDrinkDb();
180 } 180 }
181 delete newDrinks; 181 delete newDrinks;
182} 182}
183 183
184void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { 184void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) {
185 switch (mouse) { 185 switch (mouse) {
186 case 1: 186 case 1:
187// showDrink(item); 187// showDrink(item);
188 break; 188 break;
189 case 2: 189 case 2:
190 showDrink(item); 190 showDrink(item);
191 break; 191 break;
192 } 192 }
193} 193}
194 194
195void Bartender::showDrink( QListViewItem *item) { 195void Bartender::showDrink( QListViewItem *item) {
196 if(item==NULL) return; 196 if(item==NULL) return;
197 dbFile.at(0); 197 dbFile.at(0);
198 Show_Drink *showDrinks; 198 Show_Drink *showDrinks;
199 QString myDrink=item->text(0); 199 QString myDrink=item->text(0);
200 showDrinks = new Show_Drink(this, myDrink, TRUE); 200 showDrinks = new Show_Drink(this, myDrink, TRUE);
201 QTextStream t( &dbFile); 201 QTextStream t( &dbFile);
202 202
203 QString s, s2; 203 QString s, s2;
204 while ( !t.eof()) { 204 while ( !t.eof()) {
205 s = t.readLine(); 205 s = t.readLine();
206 if(s.find( myDrink, 0, TRUE) != -1) { 206 if(s.find( myDrink, 0, TRUE) != -1) {
207 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { 207 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
208 s2 = t.readLine(); 208 s2 = t.readLine();
209 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { 209 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
210// qDebug(s2); 210// qDebug(s2);
211 showDrinks->MultiLineEdit1->append(s2); 211 showDrinks->MultiLineEdit1->append(s2);
212 } 212 }
213 if( dbFile.atEnd() ) break; 213 if( dbFile.atEnd() ) break;
214 } 214 }
215 } 215 }
216 } 216 }
217 QPEApplication::execDialog( showDrinks ); 217 QPEApplication::execDialog( showDrinks );
218 218
219 if(showDrinks ->result() ==0) { 219 if(showDrinks ->result() ==0) {
220 doEdit(); 220 doEdit();
221 } 221 }
222 delete showDrinks; 222 delete showDrinks;
223} 223}
224 224
225void Bartender::askSearch() { 225void Bartender::askSearch() {
226 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ 226 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+
227 "\nor alcohol ?" 227 "\nor alcohol ?"
228 ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { 228 ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) {
229 case 0: 229 case 0:
230 doSearchByName(); 230 doSearchByName();
231 break; 231 break;
232 case 1: 232 case 1:
233 doSearchByDrink(); 233 doSearchByDrink();
234 break; 234 break;
235 }; 235 };
236} 236}
237 237
238/* search by name */ 238/* search by name */
239void Bartender::doSearchByName() { 239void Bartender::doSearchByName() {
240// if( DrinkView->currentItem() == NULL) return; 240// if( DrinkView->currentItem() == NULL) return;
241 QStringList searchList; 241 QStringList searchList;
242 QString searchForDrinkName; 242 QString searchForDrinkName;
243 InputDialog *fileDlg; 243 InputDialog *fileDlg;
244 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); 244 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0);
245 fileDlg->exec(); 245 fileDlg->exec();
246 if( fileDlg->result() == 1 ) { 246 if( fileDlg->result() == 1 ) {
247 searchForDrinkName = fileDlg->LineEdit1->text(); 247 searchForDrinkName = fileDlg->LineEdit1->text();
248 QListViewItemIterator it( DrinkView ); 248 QListViewItemIterator it( DrinkView );
249 for ( ; it.current(); ++it ) { 249 for ( ; it.current(); ++it ) {
250 if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { 250 if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) {
251// qDebug( it.current()->text(0)); 251// qDebug( it.current()->text(0));
252 searchList.append(it.current()->text(0)); 252 searchList.append(it.current()->text(0));
253 } 253 }
254 } 254 }
255 if(searchList.count() >0) 255 if(searchList.count() >0)
256 showSearchResult(searchList); 256 showSearchResult(searchList);
257 else 257 else
258 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); 258 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName);
259 }//end Inputdialog 259 }//end Inputdialog
260 delete fileDlg; 260 delete fileDlg;
261} 261}
262 262
263void Bartender::doSearchByDrink() { 263void Bartender::doSearchByDrink() {
264// if( DrinkView->currentItem() == NULL) return; 264// if( DrinkView->currentItem() == NULL) return;
265 QStringList searchList; 265 QStringList searchList;
266 QString searchForDrinkName, lastDrinkName, tempName; 266 QString searchForDrinkName, lastDrinkName, tempName;
267 267
268 InputDialog *fileDlg; 268 InputDialog *fileDlg;
269 fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); 269 fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0);
270 fileDlg->exec(); 270 fileDlg->exec();
271 if( fileDlg->result() == 1 ) { 271 if( fileDlg->result() == 1 ) {
272 searchForDrinkName = fileDlg->LineEdit1->text(); 272 searchForDrinkName = fileDlg->LineEdit1->text();
273 273
274 dbFile.at(0); 274 dbFile.at(0);
275 QTextStream t( &dbFile); 275 QTextStream t( &dbFile);
276 276
277 QString s, s2; 277 QString s, s2;
278 while ( !t.eof()) { 278 while ( !t.eof()) {
279 s = t.readLine(); 279 s = t.readLine();
280 if(s.find("#",0,TRUE) != -1) { 280 if(s.find("#",0,TRUE) != -1) {
281 lastDrinkName=s.right(s.length()-2); 281 lastDrinkName=s.right(s.length()-2);
282// qDebug("last drink name "+lastDrinkName); 282// qDebug("last drink name "+lastDrinkName);
283 } 283 }
284 else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { 284 else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) {
285// qDebug("appending "+lastDrinkName); 285// qDebug("appending "+lastDrinkName);
286 searchList.append( lastDrinkName); 286 searchList.append( lastDrinkName);
287 tempName=lastDrinkName; 287 tempName=lastDrinkName;
288 } 288 }
289// if( dbFile.atEnd() ) break; 289// if( dbFile.atEnd() ) break;
290 290
291 } //oef 291 } //oef
292 if(searchList.count() >0) 292 if(searchList.count() >0)
293 showSearchResult(searchList); 293 showSearchResult(searchList);
294 else 294 else
295 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); 295 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName);
296 } 296 }
297 delete fileDlg; 297 delete fileDlg;
298} 298}
299 299
300void Bartender::showSearchResult(QStringList &searchList) { 300void Bartender::showSearchResult(QStringList &searchList) {
301 QString result; 301 QString result;
302 Search_Results *searchDlg; 302 Search_Results *searchDlg;
303 303
304 searchList.sort(); 304 searchList.sort();
305 305
306 searchDlg = new Search_Results(this, "Search Results", TRUE); 306 searchDlg = new Search_Results(this, "Search Results", TRUE);
307 searchDlg->ListBox1->insertStringList( searchList,-1); 307 searchDlg->ListBox1->insertStringList( searchList,-1);
308 QPEApplication::execDialog( searchDlg ); 308 QPEApplication::execDialog( searchDlg );
309 309
310 if( searchDlg->result() == 1 ) { 310 if( searchDlg->result() == 1 ) {
311 result= searchDlg->ListBox1->currentText(); 311 result= searchDlg->ListBox1->currentText();
312 } 312 }
313 QListViewItemIterator it2( DrinkView ); 313 QListViewItemIterator it2( DrinkView );
314 for ( ; it2.current(); ++it2 ) { 314 for ( ; it2.current(); ++it2 ) {
315 if ( it2.current()->text(0)== result ) { 315 if ( it2.current()->text(0)== result ) {
316// qDebug( it2.current()->text(0)); 316// qDebug( it2.current()->text(0));
317 showDrink(it2.current()); 317 showDrink(it2.current());
318 } 318 }
319 } 319 }
320delete searchDlg; 320delete searchDlg;
321} 321}
322 322
323void Bartender::doEdit() { 323void Bartender::doEdit() {
324 if(DrinkView->currentItem() == NULL) { 324 if(DrinkView->currentItem() == NULL) {
325 fileNew(); 325 fileNew();
326 } 326 }
327 327
328 QString myDrink; 328 QString myDrink;
329 myDrink= DrinkView->currentItem()->text(0); 329 myDrink= DrinkView->currentItem()->text(0);
330 dbFile.at(0); 330 dbFile.at(0);
331 int foundAt=0; 331 int foundAt=0;
332 New_Drink *newDrinks; 332 New_Drink *newDrinks;
333 newDrinks = new New_Drink(this,"Edit Drink....", TRUE); 333 newDrinks = new New_Drink(this,"Edit Drink....", TRUE);
334 QString newName, newIng; 334 QString newName, newIng;
335 QPEApplication::showDialog( newDrinks ); 335 QPEApplication::showDialog( newDrinks );
336 QTextStream t( &dbFile); 336 QTextStream t( &dbFile);
337 337
338 QString s, s2; 338 QString s, s2;
339 while ( !t.eof()) { 339 while ( !t.eof()) {
340 s = t.readLine(); 340 s = t.readLine();
341 if(s.find( myDrink, 0, TRUE) != -1) { 341 if(s.find( myDrink, 0, TRUE) != -1) {
342 foundAt = dbFile.at() - (s.length()+1); 342 foundAt = dbFile.at() - (s.length()+1);
343 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { 343 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
344 s2 = t.readLine(); 344 s2 = t.readLine();
345 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { 345 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
346// qDebug(s2); 346// qDebug(s2);
347 newDrinks->MultiLineEdit1->append(s2); 347 newDrinks->MultiLineEdit1->append(s2);
348 newDrinks->LineEdit1->setText(myDrink); 348 newDrinks->LineEdit1->setText(myDrink);
349 } 349 }
350 if( dbFile.atEnd() ) break; 350 if( dbFile.atEnd() ) break;
351 } 351 }
352 } 352 }
353 } 353 }
354 newDrinks->exec(); 354 newDrinks->exec();
355 newName = newDrinks->LineEdit1->text(); 355 newName = newDrinks->LineEdit1->text();
356 newIng= newDrinks->MultiLineEdit1->text(); 356 newIng= newDrinks->MultiLineEdit1->text();
357 357
358 if( newDrinks ->result() == 1 ) { 358 if( newDrinks ->result() == 1 ) {
359 if(dbFile.isOpen()) 359 if(dbFile.isOpen())
360 dbFile.close(); 360 dbFile.close();
361 if ( !dbFile.open( IO_ReadWrite )) { 361 if ( !dbFile.open( IO_ReadWrite )) {
362 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 362 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
363 return; 363 return;
364 } 364 }
365 int fd = dbFile.handle(); 365 int fd = dbFile.handle();
366 lseek( fd, foundAt, SEEK_SET); 366 lseek( fd, foundAt, SEEK_SET);
367 367
368// dbFile.at( foundAt); 368// dbFile.at( foundAt);
369#warning FIXME problems with editing drinks db 369#warning FIXME problems with editing drinks db
370 ////////// FIXME write to user file 370 ////////// FIXME write to user file
371 QString newDrink="# "+newName+"\n"; 371 QString newDrink="# "+newName+"\n";
372 newDrink.append(newIng+"\n"); 372 newDrink.append(newIng+"\n");
373 qDebug("writing "+newDrink); 373 qDebug("writing "+newDrink);
374 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 374 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
375 clearList(); 375 clearList();
376 376
377 dbFile.flush(); 377 dbFile.flush();
378 378
379 initDrinkDb(); 379 initDrinkDb();
380 } 380 }
381} 381}
382 382
383void Bartender::clearList() { 383void Bartender::clearList() {
384 DrinkView->clear(); 384 DrinkView->clear();
385} 385}
386 386
387void Bartender::doBac() { 387void Bartender::doBac() {
388 BacDialog *bacDlg; 388 BacDialog *bacDlg;
389 bacDlg = new BacDialog(this,"BAC",TRUE); 389 bacDlg = new BacDialog(this,"BAC",TRUE);
390 QPEApplication::execDialog( bacDlg ); 390 QPEApplication::execDialog( bacDlg );
391 delete bacDlg; 391 delete bacDlg;
392} 392}
393 393
394void Bartender::openCurrentDrink() { 394void Bartender::openCurrentDrink() {
395 if(DrinkView->currentItem() == NULL) return; 395 if(DrinkView->currentItem() == NULL) return;
396 showDrink(DrinkView->currentItem()); 396 showDrink(DrinkView->currentItem());
397} 397}
398 398
399void Bartender::fileMenuActivated( int item) { 399void Bartender::fileMenuActivated( int item) {
400 qDebug("Item %d", item); 400 qDebug("Item %d", item);
401 switch(item) { 401 switch(item) {
402 case -3: // new -3 402 case -3: // new -3
403 fileNew(); 403 fileNew();
404 break; 404 break;
405 case -4:// open -4 405 case -4:// open -4
406 openCurrentDrink(); 406 openCurrentDrink();
407 break; 407 break;
408 case -5:// drink -5 408 case -5:// drink -5
409 doSearchByName(); 409 doSearchByName();
410 410
411 break; 411 break;
412 case -6:// alcohol -6 412 case -6:// alcohol -6
413 doSearchByDrink(); 413 doSearchByDrink();
414 414
415 break; 415 break;
416 416
417 } 417 }
418} 418}
419 419
420void Bartender::editMenuActivated(int item) { 420void Bartender::editMenuActivated(int item) {
421 qDebug("Item %d", item); 421 qDebug("Item %d", item);
422 /* 422 /*
423 edit -8 423 edit -8
424 */ 424 */
425 switch(item) { 425 switch(item) {
426 case -8: 426 case -8:
427 doEdit() ; 427 doEdit() ;
428 break; 428 break;
429 429
430 } 430 }
431} 431}
432 432
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index 1a8c979..35a328f 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,92 +1,94 @@
1 1
2#include "io_bt.h" 2#include "io_bt.h"
3 3
4using namespace Opie::Core;
5using namespace Opie::Core;
4IOBt::IOBt( const Profile &config ) : IOSerial( config ) { 6IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 7 m_attach = 0;
6} 8}
7 9
8 10
9IOBt::~IOBt() { 11IOBt::~IOBt() {
10 if ( m_attach ) { 12 if ( m_attach ) {
11 delete m_attach; 13 delete m_attach;
12 } 14 }
13} 15}
14 16
15 17
16void IOBt::close() { 18void IOBt::close() {
17 19
18 IOSerial::close(); 20 IOSerial::close();
19 // still need error handling 21 // still need error handling
20 if ( m_attach ) { 22 if ( m_attach ) {
21 delete m_attach; 23 delete m_attach;
22 m_attach = 0; 24 m_attach = 0;
23 } 25 }
24} 26}
25 27
26bool IOBt::open() { 28bool IOBt::open() {
27 bool ret = false; 29 bool ret = false;
28 30
29 // only set up bt stuff if mac address was set, otherwise use the device set 31 // only set up bt stuff if mac address was set, otherwise use the device set
30 if ( !m_mac.isEmpty() ) { 32 if ( !m_mac.isEmpty() ) {
31 33
32 // now it should also be checked, if there is a connection to the device with that mac allready 34 // now it should also be checked, if there is a connection to the device with that mac allready
33 // hciattach here 35 // hciattach here
34 m_attach = new OProcess(); 36 m_attach = new OProcess();
35 *m_attach << "hciattach /dev/ttyS2 any 57600"; 37 *m_attach << "hciattach /dev/ttyS2 any 57600";
36 38
37 // then start hcid, then rcfomm handling (m_mac) 39 // then start hcid, then rcfomm handling (m_mac)
38 40
39 connect( m_attach, SIGNAL( processExited(OProcess*) ), 41 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ),
40 this, SLOT( slotExited(OProcess*) ) ); 42 this, SLOT( slotExited(OProcess*) ) );
41 43
42 if ( m_attach->start() ) { 44 if ( m_attach->start() ) {
43 ret = IOSerial::open(); 45 ret = IOSerial::open();
44 } else { 46 } else {
45 qWarning("could not attach to device"); 47 qWarning("could not attach to device");
46 delete m_attach; 48 delete m_attach;
47 m_attach = 0; 49 m_attach = 0;
48 } 50 }
49 } else { 51 } else {
50 // directly to the normal serial 52 // directly to the normal serial
51 // TODO: look first if the connection really exists. ( is set up ) 53 // TODO: look first if the connection really exists. ( is set up )
52 54
53 ret =IOSerial::open(); 55 ret =IOSerial::open();
54 } 56 }
55 return ret; 57 return ret;
56} 58}
57 59
58void IOBt::reload( const Profile &config ) { 60void IOBt::reload( const Profile &config ) {
59 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); 61 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
60 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); 62 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
61 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); 63 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
62 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); 64 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
63 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); 65 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
64 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); 66 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
65 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); 67 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
66} 68}
67 69
68 70
69QString IOBt::identifier() const { 71QString IOBt::identifier() const {
70 return "bluetooth"; 72 return "bluetooth";
71} 73}
72 74
73QString IOBt::name() const { 75QString IOBt::name() const {
74 return "BLuetooth IO Layer"; 76 return "BLuetooth IO Layer";
75} 77}
76 78
77void IOBt::slotExited( OProcess* proc ){ 79void IOBt::slotExited( OProcess* proc ){
78 close(); 80 close();
79 delete proc; 81 delete proc;
80} 82}
81 83
82QBitArray IOBt::supports() const { 84QBitArray IOBt::supports() const {
83 return QBitArray( 3 ); 85 return QBitArray( 3 );
84} 86}
85 87
86bool IOBt::isConnected() { 88bool IOBt::isConnected() {
87 return false; 89 return false;
88} 90}
89 91
90void IOBt::send(const QByteArray &data) { 92void IOBt::send(const QByteArray &data) {
91 qDebug( "Please overload me..." ); 93 qDebug( "Please overload me..." );
92} 94}
diff --git a/noncore/apps/opie-console/io_bt.h b/noncore/apps/opie-console/io_bt.h
index df6dd38..00ca7e5 100644
--- a/noncore/apps/opie-console/io_bt.h
+++ b/noncore/apps/opie-console/io_bt.h
@@ -1,51 +1,51 @@
1#ifndef OPIE_IO_BT 1#ifndef OPIE_IO_BT
2#define OPIE_IO_BT 2#define OPIE_IO_BT
3 3
4#include <opie2/oprocess.h> 4#include <opie2/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6 6
7/* Default values to be used if the profile information is incomplete */ 7/* Default values to be used if the profile information is incomplete */
8#define BT_DEFAULT_DEVICE "/dev/ttyU0" 8#define BT_DEFAULT_DEVICE "/dev/ttyU0"
9#define BT_DEFAULT_BAUD 9600 9#define BT_DEFAULT_BAUD 9600
10#define BT_DEFAULT_PARITY 0 10#define BT_DEFAULT_PARITY 0
11#define BT_DEFAULT_DBITS 8 11#define BT_DEFAULT_DBITS 8
12#define BT_DEFAULT_SBITS 1 12#define BT_DEFAULT_SBITS 1
13#define BT_DEFAULT_FLOW 0 13#define BT_DEFAULT_FLOW 0
14#define BT_DEFAULT_MAC 0 14#define BT_DEFAULT_MAC 0
15 15
16 16
17/* IOSerial implements a RS232 IO Layer */ 17/* IOSerial implements a RS232 IO Layer */
18 18
19class IOBt : public IOSerial { 19class IOBt : public IOSerial {
20 20
21 Q_OBJECT 21 Q_OBJECT
22 22
23public: 23public:
24 24
25 IOBt(const Profile &); 25 IOBt(const Profile &);
26 ~IOBt(); 26 ~IOBt();
27 27
28 virtual QString identifier() const; 28 virtual QString identifier() const;
29 virtual QString name() const; 29 virtual QString name() const;
30 virtual QBitArray supports() const; 30 virtual QBitArray supports() const;
31 virtual bool isConnected(); 31 virtual bool isConnected();
32 32
33signals: 33signals:
34 void received(const QByteArray &); 34 void received(const QByteArray &);
35 void error(int, const QString &); 35 void error(int, const QString &);
36 36
37public slots: 37public slots:
38 virtual void send( const QByteArray& ); 38 virtual void send( const QByteArray& );
39 virtual bool open(); 39 virtual bool open();
40 virtual void close(); 40 virtual void close();
41 virtual void reload(const Profile &); 41 virtual void reload(const Profile &);
42 42
43private: 43private:
44 OProcess *m_attach; 44 Opie::Core::OProcess *m_attach;
45 QString m_mac; 45 QString m_mac;
46private slots: 46private slots:
47 void slotExited(OProcess* proc); 47 void slotExited(Opie::Core::OProcess* proc);
48 48
49}; 49};
50 50
51#endif /* OPIE_IO_IRDA */ 51#endif /* OPIE_IO_IRDA */
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index b281b7d..ba0b0e5 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,77 +1,79 @@
1 1
2#include "io_irda.h" 2#include "io_irda.h"
3 3
4using namespace Opie::Core;
5using namespace Opie::Core;
4IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { 6IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 7 m_attach = 0;
6} 8}
7 9
8 10
9IOIrda::~IOIrda() { 11IOIrda::~IOIrda() {
10 if ( m_attach ) { 12 if ( m_attach ) {
11 delete m_attach; 13 delete m_attach;
12 } 14 }
13} 15}
14 16
15 17
16void IOIrda::close() { 18void IOIrda::close() {
17 19
18 IOSerial::close(); 20 IOSerial::close();
19 // still need error handling 21 // still need error handling
20 delete m_attach; 22 delete m_attach;
21} 23}
22 24
23bool IOIrda::open() { 25bool IOIrda::open() {
24 bool ret; 26 bool ret;
25 27
26 // irdaattach here 28 // irdaattach here
27 m_attach = new OProcess(); 29 m_attach = new OProcess();
28 *m_attach << "irattach /dev/ttyS2 -s"; 30 *m_attach << "irattach /dev/ttyS2 -s";
29 31
30 connect( m_attach, SIGNAL( processExited(OProcess*) ), 32 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ),
31 this, SLOT( slotExited(OProcess*) ) ); 33 this, SLOT( slotExited(OProcess*) ) );
32 34
33 if ( m_attach->start() ) { 35 if ( m_attach->start() ) {
34 ret= IOSerial::open(); 36 ret= IOSerial::open();
35 } else { 37 } else {
36 // emit error!!! 38 // emit error!!!
37 qWarning("could not attach to device"); 39 qWarning("could not attach to device");
38 delete m_attach; 40 delete m_attach;
39 m_attach = 0l; 41 m_attach = 0l;
40 } 42 }
41 return ret; 43 return ret;
42} 44}
43 45
44void IOIrda::reload( const Profile &config ) { 46void IOIrda::reload( const Profile &config ) {
45 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); 47 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
46 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); 48 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
47 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); 49 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
48 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); 50 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
49 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); 51 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
50 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); 52 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
51} 53}
52 54
53 55
54QString IOIrda::identifier() const { 56QString IOIrda::identifier() const {
55 return "irda"; 57 return "irda";
56} 58}
57 59
58QString IOIrda::name() const { 60QString IOIrda::name() const {
59 return "Irda IO Layer"; 61 return "Irda IO Layer";
60} 62}
61 63
62void IOIrda::slotExited(OProcess* proc ){ 64void IOIrda::slotExited(OProcess* proc ){
63 close(); 65 close();
64 delete proc; 66 delete proc;
65} 67}
66 68
67QBitArray IOIrda::supports()const { 69QBitArray IOIrda::supports()const {
68 return QBitArray( 3 ); 70 return QBitArray( 3 );
69} 71}
70 72
71bool IOIrda::isConnected() { 73bool IOIrda::isConnected() {
72 return false; 74 return false;
73} 75}
74 76
75void IOIrda::send(const QByteArray &data) { 77void IOIrda::send(const QByteArray &data) {
76 qDebug( "Please overload me..." ); 78 qDebug( "Please overload me..." );
77} 79}
diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h
index 69bed7d..fb29686 100644
--- a/noncore/apps/opie-console/io_irda.h
+++ b/noncore/apps/opie-console/io_irda.h
@@ -1,49 +1,49 @@
1#ifndef OPIE_IO_IRDA 1#ifndef OPIE_IO_IRDA
2#define OPIE_IO_IRDA 2#define OPIE_IO_IRDA
3 3
4#include <opie2/oprocess.h> 4#include <opie2/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6 6
7/* Default values to be used if the profile information is incomplete */ 7/* Default values to be used if the profile information is incomplete */
8#define IRDA_DEFAULT_DEVICE "/dev/ircomm0" 8#define IRDA_DEFAULT_DEVICE "/dev/ircomm0"
9#define IRDA_DEFAULT_BAUD 9600 9#define IRDA_DEFAULT_BAUD 9600
10#define IRDA_DEFAULT_PARITY 0 10#define IRDA_DEFAULT_PARITY 0
11#define IRDA_DEFAULT_DBITS 8 11#define IRDA_DEFAULT_DBITS 8
12#define IRDA_DEFAULT_SBITS 1 12#define IRDA_DEFAULT_SBITS 1
13#define IRDA_DEFAULT_FLOW 0 13#define IRDA_DEFAULT_FLOW 0
14 14
15/* IOSerial implements a RS232 IO Layer */ 15/* IOSerial implements a RS232 IO Layer */
16 16
17class IOIrda : public IOSerial { 17class IOIrda : public IOSerial {
18 18
19 Q_OBJECT 19 Q_OBJECT
20 20
21public: 21public:
22 22
23 IOIrda(const Profile &); 23 IOIrda(const Profile &);
24 ~IOIrda(); 24 ~IOIrda();
25 25
26 virtual QString identifier() const; 26 virtual QString identifier() const;
27 virtual QString name() const; 27 virtual QString name() const;
28 virtual QBitArray supports() const; 28 virtual QBitArray supports() const;
29 virtual bool isConnected(); 29 virtual bool isConnected();
30 30
31signals: 31signals:
32 void received(const QByteArray &); 32 void received(const QByteArray &);
33 void error(int, const QString &); 33 void error(int, const QString &);
34 34
35public slots: 35public slots:
36 virtual void send( const QByteArray& ); 36 virtual void send( const QByteArray& );
37 virtual bool open(); 37 virtual bool open();
38 virtual void close(); 38 virtual void close();
39 virtual void reload(const Profile &); 39 virtual void reload(const Profile &);
40 40
41private: 41private:
42 OProcess *m_attach; 42 Opie::Core::OProcess *m_attach;
43 43
44private slots: 44private slots:
45 void slotExited(OProcess* proc); 45 void slotExited(Opie::Core::OProcess* proc);
46 46
47}; 47};
48 48
49#endif /* OPIE_IO_IRDA */ 49#endif /* OPIE_IO_IRDA */
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index 1ce680a..b74d076 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,106 +1,108 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3 3
4#include "dialer.h" 4#include "dialer.h"
5 5
6using namespace Opie::Core;
7using namespace Opie::Core;
6IOModem::IOModem( const Profile &profile ) 8IOModem::IOModem( const Profile &profile )
7 : IOSerial( profile ) { 9 : IOSerial( profile ) {
8 m_profile = profile; 10 m_profile = profile;
9} 11}
10 12
11 13
12IOModem::~IOModem() { 14IOModem::~IOModem() {
13 15
14} 16}
15 17
16 18
17void IOModem::close() { 19void IOModem::close() {
18 // Hangup, discarding result 20 // Hangup, discarding result
19 //int fd = rawIO(); 21 //int fd = rawIO();
20 internDetach(); 22 internDetach();
21 Dialer d(m_profile, m_fd); 23 Dialer d(m_profile, m_fd);
22 d.setHangupOnly(); 24 d.setHangupOnly();
23 //d.exec(); 25 //d.exec();
24 internAttach(); 26 internAttach();
25 //closeRawIO(fd); 27 //closeRawIO(fd);
26 28
27 IOSerial::close(); 29 IOSerial::close();
28} 30}
29 31
30bool IOModem::open() { 32bool IOModem::open() {
31 bool ret = IOSerial::open(); 33 bool ret = IOSerial::open();
32 if(!ret) return false; 34 if(!ret) return false;
33 35
34 //int fd = rawIO(); 36 //int fd = rawIO();
35 internDetach(); 37 internDetach();
36 Dialer d(m_profile, m_fd); 38 Dialer d(m_profile, m_fd);
37 39
38 int result = d.exec(); 40 int result = d.exec();
39 internAttach(); 41 internAttach();
40 //closeRawIO(fd); 42 //closeRawIO(fd);
41 if(result == QDialog::Accepted) 43 if(result == QDialog::Accepted)
42 { 44 {
43 return true; 45 return true;
44 } 46 }
45 else 47 else
46 { 48 {
47 close(); 49 close();
48 return false; 50 return false;
49 } 51 }
50} 52}
51 53
52void IOModem::reload( const Profile &config ) { 54void IOModem::reload( const Profile &config ) {
53 55
54 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); 56 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
55 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); 57 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
56 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); 58 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
57 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); 59 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
58 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); 60 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
59 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); 61 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
60 62
61 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); 63 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
62 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); 64 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
63 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); 65 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
64 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); 66 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
65 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); 67 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
66 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); 68 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
67 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); 69 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
68 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); 70 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
69 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); 71 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
70 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); 72 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
71 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); 73 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
72 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); 74 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
73 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); 75 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL );
74 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); 76 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES );
75 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); 77 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME );
76 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); 78 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT );
77 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); 79 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES );
78 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); 80 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG );
79} 81}
80 82
81 83
82QString IOModem::identifier() const { 84QString IOModem::identifier() const {
83 return "modem"; 85 return "modem";
84} 86}
85 87
86QString IOModem::name() const { 88QString IOModem::name() const {
87 return "Modem IO Layer"; 89 return "Modem IO Layer";
88} 90}
89 91
90void IOModem::slotExited(OProcess* proc ){ 92void IOModem::slotExited(OProcess* proc ){
91 close(); 93 close();
92 /* delete it afterwards */ 94 /* delete it afterwards */
93 delete proc; 95 delete proc;
94} 96}
95 97
96QBitArray IOModem::supports()const { 98QBitArray IOModem::supports()const {
97 return QBitArray( 3 ); 99 return QBitArray( 3 );
98} 100}
99 101
100bool IOModem::isConnected() { 102bool IOModem::isConnected() {
101 return false; 103 return false;
102} 104}
103 105
104void IOModem::send(const QByteArray &data) { 106void IOModem::send(const QByteArray &data) {
105 qDebug( "Please overload me..." ); 107 qDebug( "Please overload me..." );
106} 108}
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h
index 96ec3ef..5b99e00 100644
--- a/noncore/apps/opie-console/io_modem.h
+++ b/noncore/apps/opie-console/io_modem.h
@@ -1,74 +1,74 @@
1#ifndef OPIE_IO_MODEM 1#ifndef OPIE_IO_MODEM
2#define OPIE_IO_MODEM 2#define OPIE_IO_MODEM
3 3
4#include <opie2/oprocess.h> 4#include <opie2/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6#include "profile.h" 6#include "profile.h"
7 7
8/* Default values to be used if the profile information is incomplete */ 8/* Default values to be used if the profile information is incomplete */
9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0" 9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0"
10#define MODEM_DEFAULT_BAUD 9600 10#define MODEM_DEFAULT_BAUD 9600
11#define MODEM_DEFAULT_PARITY 0 11#define MODEM_DEFAULT_PARITY 0
12#define MODEM_DEFAULT_DBITS 8 12#define MODEM_DEFAULT_DBITS 8
13#define MODEM_DEFAULT_SBITS 1 13#define MODEM_DEFAULT_SBITS 1
14#define MODEM_DEFAULT_FLOW 0 14#define MODEM_DEFAULT_FLOW 0
15 15
16#define MODEM_DEFAULT_INIT_STRING "AT" 16#define MODEM_DEFAULT_INIT_STRING "AT"
17#define MODEM_DEFAULT_RESET_STRING "ATZ~" 17#define MODEM_DEFAULT_RESET_STRING "ATZ~"
18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" 18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
19#define MODEM_DEFAULT_DIAL_SUFFIX1 "" 19#define MODEM_DEFAULT_DIAL_SUFFIX1 ""
20#define MODEM_DEFAULT_DIAL_PREFIX2 "" 20#define MODEM_DEFAULT_DIAL_PREFIX2 ""
21#define MODEM_DEFAULT_DIAL_SUFFIX2 "" 21#define MODEM_DEFAULT_DIAL_SUFFIX2 ""
22#define MODEM_DEFAULT_DIAL_PREFIX3 "" 22#define MODEM_DEFAULT_DIAL_PREFIX3 ""
23#define MODEM_DEFAULT_DIAL_SUFFIX3 "" 23#define MODEM_DEFAULT_DIAL_SUFFIX3 ""
24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT" 24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH" 25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH"
26#define MODEM_DEFAULT_CANCEL_STRING "" 26#define MODEM_DEFAULT_CANCEL_STRING ""
27#define MODEM_DEFAULT_DIAL_TIME 45 27#define MODEM_DEFAULT_DIAL_TIME 45
28#define MODEM_DEFAULT_DELAY_REDIAL 2 28#define MODEM_DEFAULT_DELAY_REDIAL 2
29#define MODEM_DEFAULT_NUMBER_TRIES 10 29#define MODEM_DEFAULT_NUMBER_TRIES 10
30#define MODEM_DEFAULT_DTR_DROP_TIME 1 30#define MODEM_DEFAULT_DTR_DROP_TIME 1
31#define MODEM_DEFAULT_BPS_DETECT 0 // bool 31#define MODEM_DEFAULT_BPS_DETECT 0 // bool
32#define MODEM_DEFAULT_DCD_LINES 1 //bool 32#define MODEM_DEFAULT_DCD_LINES 1 //bool
33#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool 33#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool
34 34
35/* IOSerial implements a RS232 IO Layer */ 35/* IOSerial implements a RS232 IO Layer */
36 36
37class IOModem : public IOSerial { 37class IOModem : public IOSerial {
38 38
39 Q_OBJECT 39 Q_OBJECT
40 40
41public: 41public:
42 42
43 IOModem(const Profile &); 43 IOModem(const Profile &);
44 ~IOModem(); 44 ~IOModem();
45 45
46 virtual QString identifier() const; 46 virtual QString identifier() const;
47 virtual QString name() const; 47 virtual QString name() const;
48 virtual QBitArray supports() const; 48 virtual QBitArray supports() const;
49 virtual bool isConnected(); 49 virtual bool isConnected();
50 50
51signals: 51signals:
52 void received(const QByteArray &); 52 void received(const QByteArray &);
53 void error(int, const QString &); 53 void error(int, const QString &);
54 54
55public slots: 55public slots:
56 virtual void send( const QByteArray& ); 56 virtual void send( const QByteArray& );
57 virtual bool open(); 57 virtual bool open();
58 virtual void close(); 58 virtual void close();
59 virtual void reload(const Profile &); 59 virtual void reload(const Profile &);
60 60
61private: 61private:
62 62
63 QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, 63 QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2,
64 m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; 64 m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel;
65 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, 65 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime,
66 m_bpsDetect, m_dcdLines, m_multiLineUntag; 66 m_bpsDetect, m_dcdLines, m_multiLineUntag;
67 Profile m_profile; 67 Profile m_profile;
68 68
69private slots: 69private slots:
70 void slotExited(OProcess* proc); 70 void slotExited(Opie::Core::OProcess* proc);
71 71
72}; 72};
73 73
74#endif 74#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 197f799..06a8f7d 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,727 +1,728 @@
1#include <assert.h> 1#include <assert.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qmenubar.h> 4#include <qmenubar.h>
5#include <qtoolbar.h> 5#include <qtoolbar.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qwhatsthis.h> 7#include <qwhatsthis.h>
8#include <qfileinfo.h> 8#include <qfileinfo.h>
9 9
10#include <qpe/filemanager.h> 10#include <qpe/filemanager.h>
11 11
12#include <opie2/ofiledialog.h> 12#include <opie2/ofiledialog.h>
13 13
14#include "TEmulation.h" 14#include "TEmulation.h"
15#include "profileeditordialog.h" 15#include "profileeditordialog.h"
16#include "configdialog.h" 16#include "configdialog.h"
17#include "default.h" 17#include "default.h"
18#include "profilemanager.h" 18#include "profilemanager.h"
19#include "mainwindow.h" 19#include "mainwindow.h"
20#include "tabwidget.h" 20#include "tabwidget.h"
21#include "transferdialog.h" 21#include "transferdialog.h"
22#include "function_keyboard.h" 22#include "function_keyboard.h"
23#include "emulation_handler.h" 23#include "emulation_handler.h"
24#include "script.h" 24#include "script.h"
25 25
26 26
27using namespace Opie::Ui;
27MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 28MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
28 KeyTrans::loadAll(); 29 KeyTrans::loadAll();
29 for (int i = 0; i < KeyTrans::count(); i++ ) { 30 for (int i = 0; i < KeyTrans::count(); i++ ) {
30 KeyTrans* s = KeyTrans::find(i ); 31 KeyTrans* s = KeyTrans::find(i );
31 assert( s ); 32 assert( s );
32 } 33 }
33 m_factory = new MetaFactory(); 34 m_factory = new MetaFactory();
34 Default def(m_factory); 35 Default def(m_factory);
35 m_sessions.setAutoDelete( TRUE ); 36 m_sessions.setAutoDelete( TRUE );
36 m_curSession = 0; 37 m_curSession = 0;
37 m_manager = new ProfileManager( m_factory ); 38 m_manager = new ProfileManager( m_factory );
38 m_manager->load(); 39 m_manager->load();
39 m_scriptsData.setAutoDelete(TRUE); 40 m_scriptsData.setAutoDelete(TRUE);
40 41
41 initUI(); 42 initUI();
42 populateProfiles(); 43 populateProfiles();
43 populateScripts(); 44 populateScripts();
44} 45}
45 46
46void MainWindow::initUI() { 47void MainWindow::initUI() {
47 48
48 setToolBarsMovable( FALSE ); 49 setToolBarsMovable( FALSE );
49 50
50 /* tool bar for the menu */ 51 /* tool bar for the menu */
51 m_tool = new QToolBar( this ); 52 m_tool = new QToolBar( this );
52 m_tool->setHorizontalStretchable( TRUE ); 53 m_tool->setHorizontalStretchable( TRUE );
53 54
54 m_bar = new QMenuBar( m_tool ); 55 m_bar = new QMenuBar( m_tool );
55 m_console = new QPopupMenu( this ); 56 m_console = new QPopupMenu( this );
56 m_scripts = new QPopupMenu( this ); 57 m_scripts = new QPopupMenu( this );
57 m_sessionsPop= new QPopupMenu( this ); 58 m_sessionsPop= new QPopupMenu( this );
58 m_scriptsPop = new QPopupMenu( this ); 59 m_scriptsPop = new QPopupMenu( this );
59 60
60 /* add a toolbar for icons */ 61 /* add a toolbar for icons */
61 m_icons = new QToolBar(this); 62 m_icons = new QToolBar(this);
62 63
63 /* 64 /*
64 * the settings action 65 * the settings action
65 */ 66 */
66 m_setProfiles = new QAction(tr("Configure Profiles"), 67 m_setProfiles = new QAction(tr("Configure Profiles"),
67 Resource::loadPixmap( "SettingsIcon" ), 68 Resource::loadPixmap( "SettingsIcon" ),
68 QString::null, 0, this, 0); 69 QString::null, 0, this, 0);
69 m_setProfiles->addTo( m_console ); 70 m_setProfiles->addTo( m_console );
70 connect( m_setProfiles, SIGNAL(activated() ), 71 connect( m_setProfiles, SIGNAL(activated() ),
71 this, SLOT(slotConfigure() ) ); 72 this, SLOT(slotConfigure() ) );
72 73
73 m_console->insertSeparator(); 74 m_console->insertSeparator();
74 /* 75 /*
75 * new Action for new sessions 76 * new Action for new sessions
76 */ 77 */
77 QAction* newCon = new QAction(tr("New Profile"), 78 QAction* newCon = new QAction(tr("New Profile"),
78 Resource::loadPixmap( "new" ), 79 Resource::loadPixmap( "new" ),
79 QString::null, 0, this, 0); 80 QString::null, 0, this, 0);
80 newCon->addTo( m_console ); 81 newCon->addTo( m_console );
81 connect( newCon, SIGNAL(activated() ), 82 connect( newCon, SIGNAL(activated() ),
82 this, SLOT(slotNew() ) ); 83 this, SLOT(slotNew() ) );
83 84
84 m_console->insertSeparator(); 85 m_console->insertSeparator();
85 86
86 QAction *saveCon = new QAction( tr("Save Profile" ), 87 QAction *saveCon = new QAction( tr("Save Profile" ),
87 Resource::loadPixmap( "save" ), QString::null, 88 Resource::loadPixmap( "save" ), QString::null,
88 0, this, 0 ); 89 0, this, 0 );
89 saveCon->addTo( m_console ); 90 saveCon->addTo( m_console );
90 connect( saveCon, SIGNAL(activated() ), 91 connect( saveCon, SIGNAL(activated() ),
91 this, SLOT(slotSaveSession() ) ); 92 this, SLOT(slotSaveSession() ) );
92 m_console->insertSeparator(); 93 m_console->insertSeparator();
93 94
94 /* 95 /*
95 * connect action 96 * connect action
96 */ 97 */
97 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 98 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
98 QString::null, 0, this, 0 ); 99 QString::null, 0, this, 0 );
99 m_connect->addTo( m_console ); 100 m_connect->addTo( m_console );
100 connect(m_connect, SIGNAL(activated() ), 101 connect(m_connect, SIGNAL(activated() ),
101 this, SLOT(slotConnect() ) ); 102 this, SLOT(slotConnect() ) );
102 103
103 /* 104 /*
104 * disconnect action 105 * disconnect action
105 */ 106 */
106 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 107 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
107 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
108 m_disconnect->addTo( m_console ); 109 m_disconnect->addTo( m_console );
109 connect(m_disconnect, SIGNAL(activated() ), 110 connect(m_disconnect, SIGNAL(activated() ),
110 this, SLOT(slotDisconnect() ) ); 111 this, SLOT(slotDisconnect() ) );
111 112
112 m_console->insertSeparator(); 113 m_console->insertSeparator();
113 114
114 115
115 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 116 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
116 m_quickLaunch->addTo( m_icons ); 117 m_quickLaunch->addTo( m_icons );
117 connect( m_quickLaunch, SIGNAL( activated() ), 118 connect( m_quickLaunch, SIGNAL( activated() ),
118 this, SLOT( slotQuickLaunch() ) ); 119 this, SLOT( slotQuickLaunch() ) );
119 120
120 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 121 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
121 122
122 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 123 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
123 0, this, 0 ); 124 0, this, 0 );
124 m_transfer->addTo( m_console ); 125 m_transfer->addTo( m_console );
125 connect(m_transfer, SIGNAL(activated() ), 126 connect(m_transfer, SIGNAL(activated() ),
126 this, SLOT(slotTransfer() ) ); 127 this, SLOT(slotTransfer() ) );
127 128
128 129
129 130
130 /* 131 /*
131 * immediate change of line wrap policy 132 * immediate change of line wrap policy
132 */ 133 */
133 m_isWrapped = false; 134 m_isWrapped = false;
134 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); 135 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
135 m_wrap->addTo( m_console ); 136 m_wrap->addTo( m_console );
136 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 137 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
137 138
138 /* 139 /*
139 * fullscreen 140 * fullscreen
140 */ 141 */
141 m_isFullscreen = false; 142 m_isFullscreen = false;
142 143
143 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 144 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
144 , QString::null, 0, this, 0); 145 , QString::null, 0, this, 0);
145 m_fullscreen->addTo( m_console ); 146 m_fullscreen->addTo( m_console );
146 connect( m_fullscreen, SIGNAL( activated() ), 147 connect( m_fullscreen, SIGNAL( activated() ),
147 this, SLOT( slotFullscreen() ) ); 148 this, SLOT( slotFullscreen() ) );
148 149
149 m_console->insertSeparator(); 150 m_console->insertSeparator();
150 151
151 QAction *a = new QAction(); 152 QAction *a = new QAction();
152 a->setText( tr("Save history") ); 153 a->setText( tr("Save history") );
153 a->addTo( m_console ); 154 a->addTo( m_console );
154 connect(a, SIGNAL(activated() ), 155 connect(a, SIGNAL(activated() ),
155 this, SLOT(slotSaveHistory() ) ); 156 this, SLOT(slotSaveHistory() ) );
156 /* 157 /*
157 * terminate action 158 * terminate action
158 */ 159 */
159 m_terminate = new QAction(); 160 m_terminate = new QAction();
160 m_terminate->setText( tr("Terminate") ); 161 m_terminate->setText( tr("Terminate") );
161 m_terminate->addTo( m_console ); 162 m_terminate->addTo( m_console );
162 connect(m_terminate, SIGNAL(activated() ), 163 connect(m_terminate, SIGNAL(activated() ),
163 this, SLOT(slotTerminate() ) ); 164 this, SLOT(slotTerminate() ) );
164 165
165 m_closewindow = new QAction(); 166 m_closewindow = new QAction();
166 m_closewindow->setText( tr("Close Window") ); 167 m_closewindow->setText( tr("Close Window") );
167 m_closewindow->addTo( m_console ); 168 m_closewindow->addTo( m_console );
168 connect( m_closewindow, SIGNAL(activated() ), 169 connect( m_closewindow, SIGNAL(activated() ),
169 this, SLOT(slotClose() ) ); 170 this, SLOT(slotClose() ) );
170 171
171 172
172 /* 173 /*
173 * script actions 174 * script actions
174 */ 175 */
175 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 176 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
176 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 177 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
177 178
178 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 179 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
179 m_recordScript->addTo(m_scripts); 180 m_recordScript->addTo(m_scripts);
180 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 181 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
181 182
182 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 183 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
183 m_saveScript->addTo(m_scripts); 184 m_saveScript->addTo(m_scripts);
184 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 185 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
185 186
186 187
187 /* 188 /*
188 * action that open/closes the keyboard 189 * action that open/closes the keyboard
189 */ 190 */
190 m_openKeys = new QAction (tr("Open Keyboard..."), 191 m_openKeys = new QAction (tr("Open Keyboard..."),
191 Resource::loadPixmap( "console/keys/keyboard_icon" ), 192 Resource::loadPixmap( "console/keys/keyboard_icon" ),
192 QString::null, 0, this, 0); 193 QString::null, 0, this, 0);
193 m_openKeys->setToggleAction(true); 194 m_openKeys->setToggleAction(true);
194 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 195 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
195 196
196 /* insert the submenu */ 197 /* insert the submenu */
197 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 198 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
198 -1, 0); 199 -1, 0);
199 200
200 /* insert the connection menu */ 201 /* insert the connection menu */
201 m_bar->insertItem( tr("Connection"), m_console ); 202 m_bar->insertItem( tr("Connection"), m_console );
202 203
203 /* the scripts menu */ 204 /* the scripts menu */
204 m_bar->insertItem( tr("Scripts"), m_scripts ); 205 m_bar->insertItem( tr("Scripts"), m_scripts );
205 206
206 /* and the keyboard */ 207 /* and the keyboard */
207 m_keyBar = new QToolBar(this); 208 m_keyBar = new QToolBar(this);
208 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 209 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
209 m_keyBar->setHorizontalStretchable( TRUE ); 210 m_keyBar->setHorizontalStretchable( TRUE );
210 m_keyBar->hide(); 211 m_keyBar->hide();
211 212
212 m_kb = new FunctionKeyboard(m_keyBar); 213 m_kb = new FunctionKeyboard(m_keyBar);
213 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 214 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
214 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 215 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
215 216
216 217
217 a = new QAction(tr("Copy"), 218 a = new QAction(tr("Copy"),
218 Resource::loadPixmap("copy"), QString::null, 219 Resource::loadPixmap("copy"), QString::null,
219 0, this, 0 ); 220 0, this, 0 );
220 //a->addTo( m_icons ); 221 //a->addTo( m_icons );
221 connect( a, SIGNAL(activated() ), 222 connect( a, SIGNAL(activated() ),
222 this, SLOT(slotCopy() ) ); 223 this, SLOT(slotCopy() ) );
223 224
224 QAction *paste = new QAction(tr("Paste"), 225 QAction *paste = new QAction(tr("Paste"),
225 Resource::loadPixmap("paste"), QString::null, 226 Resource::loadPixmap("paste"), QString::null,
226 0, this, 0 ); 227 0, this, 0 );
227 connect( paste, SIGNAL(activated() ), 228 connect( paste, SIGNAL(activated() ),
228 this, SLOT(slotPaste() ) ); 229 this, SLOT(slotPaste() ) );
229 230
230 231
231 newCon->addTo( m_icons ); 232 newCon->addTo( m_icons );
232 //m_setProfiles->addTo( m_icons ); 233 //m_setProfiles->addTo( m_icons );
233 paste->addTo( m_icons ); 234 paste->addTo( m_icons );
234 m_openKeys->addTo(m_icons); 235 m_openKeys->addTo(m_icons);
235 m_fullscreen->addTo( m_icons ); 236 m_fullscreen->addTo( m_icons );
236 237
237 m_connect->setEnabled( false ); 238 m_connect->setEnabled( false );
238 m_disconnect->setEnabled( false ); 239 m_disconnect->setEnabled( false );
239 m_terminate->setEnabled( false ); 240 m_terminate->setEnabled( false );
240 m_transfer->setEnabled( false ); 241 m_transfer->setEnabled( false );
241 m_scripts->setItemEnabled(m_runScript_id, false); 242 m_scripts->setItemEnabled(m_runScript_id, false);
242 m_recordScript->setEnabled( false ); 243 m_recordScript->setEnabled( false );
243 m_saveScript->setEnabled( false ); 244 m_saveScript->setEnabled( false );
244 m_fullscreen->setEnabled( false ); 245 m_fullscreen->setEnabled( false );
245 m_closewindow->setEnabled( false ); 246 m_closewindow->setEnabled( false );
246 m_wrap->setEnabled( false ); 247 m_wrap->setEnabled( false );
247 248
248 /* 249 /*
249 * connect to the menu activation 250 * connect to the menu activation
250 */ 251 */
251 connect( m_sessionsPop, SIGNAL(activated(int) ), 252 connect( m_sessionsPop, SIGNAL(activated(int) ),
252 this, SLOT(slotProfile(int) ) ); 253 this, SLOT(slotProfile(int) ) );
253 254
254 m_consoleWindow = new TabWidget( this, "blah"); 255 m_consoleWindow = new TabWidget( this, "blah");
255 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 256 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
256 this, SLOT(slotSessionChanged(Session*) ) ); 257 this, SLOT(slotSessionChanged(Session*) ) );
257 setCentralWidget( m_consoleWindow ); 258 setCentralWidget( m_consoleWindow );
258 259
259 slotQuickLaunch(); 260 slotQuickLaunch();
260} 261}
261 262
262ProfileManager* MainWindow::manager() { 263ProfileManager* MainWindow::manager() {
263 return m_manager; 264 return m_manager;
264} 265}
265TabWidget* MainWindow::tabWidget() { 266TabWidget* MainWindow::tabWidget() {
266 return m_consoleWindow; 267 return m_consoleWindow;
267} 268}
268void MainWindow::populateProfiles() { 269void MainWindow::populateProfiles() {
269 m_sessionsPop->clear(); 270 m_sessionsPop->clear();
270 Profile::ValueList list = manager()->all(); 271 Profile::ValueList list = manager()->all();
271 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 272 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
272 m_sessionsPop->insertItem( (*it).name() ); 273 m_sessionsPop->insertItem( (*it).name() );
273 } 274 }
274 275
275} 276}
276 277
277void MainWindow::populateScripts() { 278void MainWindow::populateScripts() {
278 m_scriptsPop->clear(); 279 m_scriptsPop->clear();
279 m_scriptsData.clear(); 280 m_scriptsData.clear();
280 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 281 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
281 QListIterator<DocLnk> dit(files.children()); 282 QListIterator<DocLnk> dit(files.children());
282 for (; dit.current(); ++dit) { 283 for (; dit.current(); ++dit) {
283 if (*dit && (*dit)->name().length()>0) { 284 if (*dit && (*dit)->name().length()>0) {
284 QFileInfo info((*dit)->file()); 285 QFileInfo info((*dit)->file());
285 if (info.extension(false) == "script") { 286 if (info.extension(false) == "script") {
286 m_scriptsData.append(new DocLnk(**dit)); 287 m_scriptsData.append(new DocLnk(**dit));
287 m_scriptsPop->insertItem((*dit)->name()); 288 m_scriptsPop->insertItem((*dit)->name());
288 } 289 }
289 } 290 }
290 } 291 }
291 292
292} 293}
293 294
294MainWindow::~MainWindow() { 295MainWindow::~MainWindow() {
295 delete m_factory; 296 delete m_factory;
296 manager()->save(); 297 manager()->save();
297} 298}
298 299
299MetaFactory* MainWindow::factory() { 300MetaFactory* MainWindow::factory() {
300 return m_factory; 301 return m_factory;
301} 302}
302 303
303Session* MainWindow::currentSession() { 304Session* MainWindow::currentSession() {
304 return m_curSession; 305 return m_curSession;
305} 306}
306 307
307QList<Session> MainWindow::sessions() { 308QList<Session> MainWindow::sessions() {
308 return m_sessions; 309 return m_sessions;
309} 310}
310 311
311void MainWindow::slotNew() { 312void MainWindow::slotNew() {
312 ProfileEditorDialog dlg(factory() ); 313 ProfileEditorDialog dlg(factory() );
313 dlg.setCaption( tr("New Connection") ); 314 dlg.setCaption( tr("New Connection") );
314 int ret = QPEApplication::execDialog( &dlg ); 315 int ret = QPEApplication::execDialog( &dlg );
315 316
316 if ( ret == QDialog::Accepted ) { 317 if ( ret == QDialog::Accepted ) {
317 create( dlg.profile() ); 318 create( dlg.profile() );
318 } 319 }
319} 320}
320 321
321void MainWindow::slotRecordScript() { 322void MainWindow::slotRecordScript() {
322 if (currentSession()) { 323 if (currentSession()) {
323 currentSession()->emulationHandler()->startRecording(); 324 currentSession()->emulationHandler()->startRecording();
324 m_saveScript->setEnabled(true); 325 m_saveScript->setEnabled(true);
325 m_recordScript->setEnabled(false); 326 m_recordScript->setEnabled(false);
326 } 327 }
327} 328}
328 329
329void MainWindow::slotSaveScript() { 330void MainWindow::slotSaveScript() {
330 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 331 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
331 QMap<QString, QStringList> map; 332 QMap<QString, QStringList> map;
332 QStringList text; 333 QStringList text;
333 text << "text/plain"; 334 text << "text/plain";
334 map.insert(tr("Script"), text ); 335 map.insert(tr("Script"), text );
335 QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 336 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
336 if (!filename.isEmpty()) { 337 if (!filename.isEmpty()) {
337 QFileInfo info(filename); 338 QFileInfo info(filename);
338 if (info.extension(FALSE) != "script") 339 if (info.extension(FALSE) != "script")
339 filename += ".script"; 340 filename += ".script";
340 DocLnk nf; 341 DocLnk nf;
341 nf.setType("text/plain"); 342 nf.setType("text/plain");
342 nf.setFile(filename); 343 nf.setFile(filename);
343 nf.setName(info.fileName()); 344 nf.setName(info.fileName());
344 FileManager fm; 345 FileManager fm;
345 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 346 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
346 currentSession()->emulationHandler()->clearScript(); 347 currentSession()->emulationHandler()->clearScript();
347 m_saveScript->setEnabled(false); 348 m_saveScript->setEnabled(false);
348 m_recordScript->setEnabled(true); 349 m_recordScript->setEnabled(true);
349 populateScripts(); 350 populateScripts();
350 } 351 }
351 } 352 }
352} 353}
353 354
354void MainWindow::slotRunScript(int id) { 355void MainWindow::slotRunScript(int id) {
355 if (currentSession()) { 356 if (currentSession()) {
356 int index = m_scriptsPop->indexOf(id); 357 int index = m_scriptsPop->indexOf(id);
357 DocLnk *lnk = m_scriptsData.at(index); 358 DocLnk *lnk = m_scriptsData.at(index);
358 QString filePath = lnk->file(); 359 QString filePath = lnk->file();
359 Script script(filePath); 360 Script script(filePath);
360 currentSession()->emulationHandler()->runScript(&script); 361 currentSession()->emulationHandler()->runScript(&script);
361 } 362 }
362} 363}
363 364
364void MainWindow::slotConnect() { 365void MainWindow::slotConnect() {
365 if ( currentSession() ) { 366 if ( currentSession() ) {
366 bool ret = currentSession()->layer()->open(); 367 bool ret = currentSession()->layer()->open();
367 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 368 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
368 QObject::tr("Failed"), 369 QObject::tr("Failed"),
369 QObject::tr("Connecting failed for this session.")); 370 QObject::tr("Connecting failed for this session."));
370 else { 371 else {
371 m_connect->setEnabled( false ); 372 m_connect->setEnabled( false );
372 m_disconnect->setEnabled( true ); 373 m_disconnect->setEnabled( true );
373 374
374 // if it does not support file transfer, disable the menu entry 375 // if it does not support file transfer, disable the menu entry
375 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 376 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
376 m_transfer->setEnabled( false ); 377 m_transfer->setEnabled( false );
377 } else { 378 } else {
378 m_transfer->setEnabled( true ); 379 m_transfer->setEnabled( true );
379 } 380 }
380 381
381 m_recordScript->setEnabled( true ); 382 m_recordScript->setEnabled( true );
382 m_scripts->setItemEnabled(m_runScript_id, true); 383 m_scripts->setItemEnabled(m_runScript_id, true);
383 } 384 }
384 } 385 }
385} 386}
386 387
387void MainWindow::slotDisconnect() { 388void MainWindow::slotDisconnect() {
388 if ( currentSession() ) { 389 if ( currentSession() ) {
389 currentSession()->layer()->close(); 390 currentSession()->layer()->close();
390 m_connect->setEnabled( true ); 391 m_connect->setEnabled( true );
391 m_disconnect->setEnabled( false ); 392 m_disconnect->setEnabled( false );
392 m_transfer->setEnabled( false ); 393 m_transfer->setEnabled( false );
393 m_recordScript->setEnabled( false); 394 m_recordScript->setEnabled( false);
394 m_saveScript->setEnabled( false ); 395 m_saveScript->setEnabled( false );
395 m_scripts->setItemEnabled(m_runScript_id, false); 396 m_scripts->setItemEnabled(m_runScript_id, false);
396 } 397 }
397} 398}
398 399
399void MainWindow::slotTerminate() { 400void MainWindow::slotTerminate() {
400 if ( currentSession() ) 401 if ( currentSession() )
401 currentSession()->layer()->close(); 402 currentSession()->layer()->close();
402 403
403 slotClose(); 404 slotClose();
404 /* FIXME move to the next session */ 405 /* FIXME move to the next session */
405} 406}
406 407
407 408
408 409
409 410
410 411
411 412
412void MainWindow::slotQuickLaunch() { 413void MainWindow::slotQuickLaunch() {
413 Profile prof = manager()->profile( "default" ); 414 Profile prof = manager()->profile( "default" );
414 if ( prof.name() == "default" ) { 415 if ( prof.name() == "default" ) {
415 create( prof ); 416 create( prof );
416 } else { 417 } else {
417 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 418 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
418 newProf.setAutoConnect( true ); 419 newProf.setAutoConnect( true );
419 create( newProf ); 420 create( newProf );
420 slotSaveSession(); 421 slotSaveSession();
421 } 422 }
422 423
423} 424}
424 425
425void MainWindow::slotConfigure() { 426void MainWindow::slotConfigure() {
426 ConfigDialog conf( manager()->all(), factory() ); 427 ConfigDialog conf( manager()->all(), factory() );
427 428
428 int ret = QPEApplication::execDialog( &conf ); 429 int ret = QPEApplication::execDialog( &conf );
429 430
430 if ( QDialog::Accepted == ret ) { 431 if ( QDialog::Accepted == ret ) {
431 manager()->setProfiles( conf.list() ); 432 manager()->setProfiles( conf.list() );
432 manager()->save(); 433 manager()->save();
433 populateProfiles(); 434 populateProfiles();
434 } 435 }
435} 436}
436/* 437/*
437 * we will remove 438 * we will remove
438 * this window from the tabwidget 439 * this window from the tabwidget
439 * remove it from the list 440 * remove it from the list
440 * delete it 441 * delete it
441 * and set the currentSession() 442 * and set the currentSession()
442 */ 443 */
443void MainWindow::slotClose() { 444void MainWindow::slotClose() {
444 if (!currentSession() ) 445 if (!currentSession() )
445 return; 446 return;
446 447
447 Session* ses = currentSession(); 448 Session* ses = currentSession();
448 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 449 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
449 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 450 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
450 m_curSession = NULL; 451 m_curSession = NULL;
451 tabWidget()->remove( /*currentSession()*/ses ); 452 tabWidget()->remove( /*currentSession()*/ses );
452 /*it's autodelete */ 453 /*it's autodelete */
453 m_sessions.remove( ses ); 454 m_sessions.remove( ses );
454 qWarning("after remove!!"); 455 qWarning("after remove!!");
455 456
456 if (!currentSession() ) { 457 if (!currentSession() ) {
457 m_connect->setEnabled( false ); 458 m_connect->setEnabled( false );
458 m_disconnect->setEnabled( false ); 459 m_disconnect->setEnabled( false );
459 m_terminate->setEnabled( false ); 460 m_terminate->setEnabled( false );
460 m_transfer->setEnabled( false ); 461 m_transfer->setEnabled( false );
461 m_recordScript->setEnabled( false ); 462 m_recordScript->setEnabled( false );
462 m_saveScript->setEnabled( false ); 463 m_saveScript->setEnabled( false );
463 m_scripts->setItemEnabled(m_runScript_id, false); 464 m_scripts->setItemEnabled(m_runScript_id, false);
464 m_fullscreen->setEnabled( false ); 465 m_fullscreen->setEnabled( false );
465 m_wrap->setEnabled( false ); 466 m_wrap->setEnabled( false );
466 m_closewindow->setEnabled( false ); 467 m_closewindow->setEnabled( false );
467 } 468 }
468 469
469 m_kb->loadDefaults(); 470 m_kb->loadDefaults();
470} 471}
471 472
472/* 473/*
473 * We will get the name 474 * We will get the name
474 * Then the profile 475 * Then the profile
475 * and then we will make a profile 476 * and then we will make a profile
476 */ 477 */
477void MainWindow::slotProfile( int id) { 478void MainWindow::slotProfile( int id) {
478 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 479 Profile prof = manager()->profile( m_sessionsPop->text( id) );
479 create( prof ); 480 create( prof );
480} 481}
481 482
482 483
483 484
484void MainWindow::create( const Profile& prof ) { 485void MainWindow::create( const Profile& prof ) {
485 if(m_curSession) 486 if(m_curSession)
486 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 487 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
487 488
488 Session *ses = manager()->fromProfile( prof, tabWidget() ); 489 Session *ses = manager()->fromProfile( prof, tabWidget() );
489 490
490 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 491 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
491 { 492 {
492 QMessageBox::warning(this, 493 QMessageBox::warning(this,
493 QObject::tr("Session failed"), 494 QObject::tr("Session failed"),
494 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 495 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
495 //if(ses) delete ses; 496 //if(ses) delete ses;
496 return; 497 return;
497 } 498 }
498 499
499 m_sessions.append( ses ); 500 m_sessions.append( ses );
500 tabWidget()->add( ses ); 501 tabWidget()->add( ses );
501 tabWidget()->repaint(); 502 tabWidget()->repaint();
502 m_curSession = ses; 503 m_curSession = ses;
503 504
504 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 505 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
505 m_connect->setEnabled( true ); 506 m_connect->setEnabled( true );
506 m_disconnect->setEnabled( false ); 507 m_disconnect->setEnabled( false );
507 m_terminate->setEnabled( true ); 508 m_terminate->setEnabled( true );
508 m_fullscreen->setEnabled( true ); 509 m_fullscreen->setEnabled( true );
509 m_wrap->setEnabled( true ); 510 m_wrap->setEnabled( true );
510 m_closewindow->setEnabled( true ); 511 m_closewindow->setEnabled( true );
511 m_transfer->setEnabled( false ); 512 m_transfer->setEnabled( false );
512 m_recordScript->setEnabled( false ); 513 m_recordScript->setEnabled( false );
513 m_saveScript->setEnabled( false ); 514 m_saveScript->setEnabled( false );
514 m_scripts->setItemEnabled(m_runScript_id, false); 515 m_scripts->setItemEnabled(m_runScript_id, false);
515 516
516 // is io_layer wants direct connection, then autoconnect 517 // is io_layer wants direct connection, then autoconnect
517 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 518 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
518 if (prof.autoConnect()) { 519 if (prof.autoConnect()) {
519 slotConnect(); 520 slotConnect();
520 } 521 }
521 522
522 523
523 QWidget *w = currentSession()->widget(); 524 QWidget *w = currentSession()->widget();
524 if(w) w->setFocus(); 525 if(w) w->setFocus();
525 526
526 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 527 if(currentSession()->profile().readNumEntry("Wrap", 80)){
527 m_isWrapped = true; 528 m_isWrapped = true;
528 } else { 529 } else {
529 m_isWrapped = false; 530 m_isWrapped = false;
530 } 531 }
531 532
532 m_kb->load(currentSession()->profile()); 533 m_kb->load(currentSession()->profile());
533} 534}
534 535
535void MainWindow::slotTransfer() 536void MainWindow::slotTransfer()
536{ 537{
537 if ( currentSession() ) { 538 if ( currentSession() ) {
538 Session *mysession = currentSession(); 539 Session *mysession = currentSession();
539 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 540 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
540 mysession->setTransferDialog(&dlg); 541 mysession->setTransferDialog(&dlg);
541 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 542 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
542 //dlg.showMaximized(); 543 //dlg.showMaximized();
543 currentSession()->widgetStack()->addWidget(&dlg, -1); 544 currentSession()->widgetStack()->addWidget(&dlg, -1);
544 dlg.show(); 545 dlg.show();
545 //dlg.exec(); 546 //dlg.exec();
546 while(dlg.isRunning()) qApp->processEvents(); 547 while(dlg.isRunning()) qApp->processEvents();
547 mysession->setTransferDialog(0l); 548 mysession->setTransferDialog(0l);
548 } 549 }
549} 550}
550 551
551 552
552void MainWindow::slotOpenKeb(bool state) { 553void MainWindow::slotOpenKeb(bool state) {
553 554
554 if (state) m_keyBar->show(); 555 if (state) m_keyBar->show();
555 else m_keyBar->hide(); 556 else m_keyBar->hide();
556 557
557} 558}
558 559
559 560
560void MainWindow::slotOpenButtons( bool state ) { 561void MainWindow::slotOpenButtons( bool state ) {
561 562
562 if ( state ) { 563 if ( state ) {
563 m_buttonBar->show(); 564 m_buttonBar->show();
564 } else { 565 } else {
565 m_buttonBar->hide(); 566 m_buttonBar->hide();
566 } 567 }
567} 568}
568 569
569 570
570 571
571void MainWindow::slotSessionChanged( Session* ses ) { 572void MainWindow::slotSessionChanged( Session* ses ) {
572 qWarning("changed!"); 573 qWarning("changed!");
573 574
574 if(m_curSession) 575 if(m_curSession)
575 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 576 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
576 if(ses) 577 if(ses)
577 if(ses->transferDialog()) ses->transferDialog()->show(); 578 if(ses->transferDialog()) ses->transferDialog()->show();
578 579
579 if ( ses ) { 580 if ( ses ) {
580 m_curSession = ses; 581 m_curSession = ses;
581 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 582 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
582 if ( m_curSession->layer()->isConnected() ) { 583 if ( m_curSession->layer()->isConnected() ) {
583 m_connect->setEnabled( false ); 584 m_connect->setEnabled( false );
584 m_disconnect->setEnabled( true ); 585 m_disconnect->setEnabled( true );
585 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 586 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
586 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 587 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
587 m_scripts->setItemEnabled(m_runScript_id, true); 588 m_scripts->setItemEnabled(m_runScript_id, true);
588 } else { 589 } else {
589 m_connect->setEnabled( true ); 590 m_connect->setEnabled( true );
590 m_disconnect->setEnabled( false ); 591 m_disconnect->setEnabled( false );
591 m_recordScript->setEnabled( false ); 592 m_recordScript->setEnabled( false );
592 m_saveScript->setEnabled( false ); 593 m_saveScript->setEnabled( false );
593 m_scripts->setItemEnabled(m_runScript_id, false); 594 m_scripts->setItemEnabled(m_runScript_id, false);
594 } 595 }
595 596
596 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 597 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
597 m_transfer->setEnabled( false ); 598 m_transfer->setEnabled( false );
598 } else { 599 } else {
599 m_transfer->setEnabled( true ); 600 m_transfer->setEnabled( true );
600 } 601 }
601 602
602 QWidget *w = m_curSession->widget(); 603 QWidget *w = m_curSession->widget();
603 if(w) w->setFocus(); 604 if(w) w->setFocus();
604 605
605 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 606 if(currentSession()->profile().readNumEntry("Wrap", 80)){
606 m_isWrapped = true; 607 m_isWrapped = true;
607 } else { 608 } else {
608 m_isWrapped = false; 609 m_isWrapped = false;
609 } 610 }
610 611
611 m_kb->load(currentSession()->profile()); 612 m_kb->load(currentSession()->profile());
612 } 613 }
613} 614}
614 615
615void MainWindow::slotWrap() 616void MainWindow::slotWrap()
616{ 617{
617 if(m_curSession) 618 if(m_curSession)
618 { 619 {
619 EmulationHandler *e = m_curSession->emulationHandler(); 620 EmulationHandler *e = m_curSession->emulationHandler();
620 if(e) 621 if(e)
621 { 622 {
622 if(m_isWrapped) 623 if(m_isWrapped)
623 { 624 {
624 e->setWrap(80); 625 e->setWrap(80);
625 m_isWrapped = false; 626 m_isWrapped = false;
626 } 627 }
627 else 628 else
628 { 629 {
629 e->setWrap(0); 630 e->setWrap(0);
630 m_isWrapped = true; 631 m_isWrapped = true;
631 } 632 }
632 } 633 }
633 } 634 }
634} 635}
635 636
636void MainWindow::slotFullscreen() { 637void MainWindow::slotFullscreen() {
637 638
638 639
639 640
640 if ( m_isFullscreen ) { 641 if ( m_isFullscreen ) {
641 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 642 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
642 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 643 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
643 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 644 ( m_curSession->emulationHandler() )->cornerButton()->hide();
644 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 645 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
645 646
646 } else { 647 } else {
647 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 648 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
648 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 649 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
649 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 650 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
650 , QPoint(0,0), false ); 651 , QPoint(0,0), false );
651 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 652 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
652 ( m_curSession->widgetStack() )->setFocus(); 653 ( m_curSession->widgetStack() )->setFocus();
653 ( m_curSession->widgetStack() )->show(); 654 ( m_curSession->widgetStack() )->show();
654 655
655 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 656 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
656 657
657 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 658 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
658 } 659 }
659 660
660 m_isFullscreen = !m_isFullscreen; 661 m_isFullscreen = !m_isFullscreen;
661} 662}
662 663
663 664
664void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 665void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
665 666
666 if ( m_curSession ) { 667 if ( m_curSession ) {
667 668
668 QEvent::Type state; 669 QEvent::Type state;
669 670
670 if (pressed) state = QEvent::KeyPress; 671 if (pressed) state = QEvent::KeyPress;
671 else state = QEvent::KeyRelease; 672 else state = QEvent::KeyRelease;
672 673
673 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 674 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
674 675
675 // is this the best way to do this? cant figure out any other way to work 676 // is this the best way to do this? cant figure out any other way to work
676 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 677 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
677 ke.ignore(); 678 ke.ignore();
678 } 679 }
679} 680}
680void MainWindow::slotCopy() { 681void MainWindow::slotCopy() {
681 if (!currentSession() ) return; 682 if (!currentSession() ) return;
682 currentSession()->emulationHandler()->copy(); 683 currentSession()->emulationHandler()->copy();
683} 684}
684void MainWindow::slotPaste() { 685void MainWindow::slotPaste() {
685 if (!currentSession() ) return; 686 if (!currentSession() ) return;
686 currentSession()->emulationHandler()->paste(); 687 currentSession()->emulationHandler()->paste();
687} 688}
688 689
689/* 690/*
690 * Save the session 691 * Save the session
691 */ 692 */
692 693
693void MainWindow::slotSaveSession() { 694void MainWindow::slotSaveSession() {
694 if (!currentSession() ) { 695 if (!currentSession() ) {
695 QMessageBox::information(this, tr("Save Connection"), 696 QMessageBox::information(this, tr("Save Connection"),
696 tr("<qt>There is no Connection.</qt>"), 1 ); 697 tr("<qt>There is no Connection.</qt>"), 1 );
697 return; 698 return;
698 } 699 }
699 manager()->add( currentSession()->profile() ); 700 manager()->add( currentSession()->profile() );
700 manager()->save(); 701 manager()->save();
701 populateProfiles(); 702 populateProfiles();
702} 703}
703void MainWindow::slotSaveHistory() { 704void MainWindow::slotSaveHistory() {
704 QMap<QString, QStringList> map; 705 QMap<QString, QStringList> map;
705 QStringList text; 706 QStringList text;
706 text << "text/plain"; 707 text << "text/plain";
707 map.insert(tr("History"), text ); 708 map.insert(tr("History"), text );
708 QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 709 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
709 if (filename.isEmpty() ) return; 710 if (filename.isEmpty() ) return;
710 711
711 QFileInfo info(filename); 712 QFileInfo info(filename);
712 713
713 DocLnk nf; 714 DocLnk nf;
714 nf.setType("text/plain"); 715 nf.setType("text/plain");
715 nf.setFile(filename); 716 nf.setFile(filename);
716 nf.setName(info.fileName()); 717 nf.setName(info.fileName());
717 718
718 719
719 QFile file(filename); 720 QFile file(filename);
720 file.open(IO_WriteOnly ); 721 file.open(IO_WriteOnly );
721 QTextStream str(&file ); 722 QTextStream str(&file );
722 if ( currentSession() ) 723 if ( currentSession() )
723 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 724 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
724 725
725 file.close(); 726 file.close();
726 nf.writeLink(); 727 nf.writeLink();
727} 728}
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 6e1e23e..dc42d8b 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,241 +1,242 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qcombobox.h> 5#include <qcombobox.h>
6#include <qcheckbox.h> 6#include <qcheckbox.h>
7#include <qscrollview.h> 7#include <qscrollview.h>
8 8
9#include "metafactory.h" 9#include "metafactory.h"
10#include "profileeditordialog.h" 10#include "profileeditordialog.h"
11 11
12using namespace Opie::Ui;
12namespace { 13namespace {
13 void setCurrent( const QString& str, QComboBox* bo ) { 14 void setCurrent( const QString& str, QComboBox* bo ) {
14 for (int i = 0; i < bo->count(); i++ ) { 15 for (int i = 0; i < bo->count(); i++ ) {
15 if ( bo->text(i) == str ) { 16 if ( bo->text(i) == str ) {
16 bo->setCurrentItem( i ); 17 bo->setCurrentItem( i );
17 } 18 }
18 } 19 }
19 }; 20 };
20} 21}
21 22
22ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 23ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
23 const Profile& prof ) 24 const Profile& prof )
24 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 25 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
25{ 26{
26 initUI(); 27 initUI();
27 28
28 // Apply current profile 29 // Apply current profile
29 // plugin_plugin->load(profile); 30 // plugin_plugin->load(profile);
30 // ... (reset profile name line edit etc.) 31 // ... (reset profile name line edit etc.)
31} 32}
32 33
33ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 34ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
34 : QDialog(0, 0, TRUE), m_fact( fact ) 35 : QDialog(0, 0, TRUE), m_fact( fact )
35{ 36{
36 // Default profile 37 // Default profile
37 m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); 38 m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102);
38 39
39 initUI(); 40 initUI();
40 41
41 // Apply current profile 42 // Apply current profile
42 // plugin_plugin->load(profile); 43 // plugin_plugin->load(profile);
43} 44}
44 45
45Profile ProfileEditorDialog::profile() const 46Profile ProfileEditorDialog::profile() const
46{ 47{
47 return m_prof; 48 return m_prof;
48} 49}
49 50
50void ProfileEditorDialog::initUI() 51void ProfileEditorDialog::initUI()
51{ 52{
52 m_con = m_term = m_key = 0l; 53 m_con = m_term = m_key = 0l;
53 54
54 55
55 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 56 QVBoxLayout *mainLayout = new QVBoxLayout( this );
56 tabWidget = new OTabWidget( this ); 57 tabWidget = new OTabWidget( this );
57 tabWidget->setTabStyle(OTabWidget::TextTab); 58 tabWidget->setTabStyle(OTabWidget::TextTab);
58 mainLayout->add(tabWidget); 59 mainLayout->add(tabWidget);
59 60
60 /* base tabs */ 61 /* base tabs */
61 tabprof = new QWidget(this); 62 tabprof = new QWidget(this);
62 m_tabTerm = new QWidget(this); 63 m_tabTerm = new QWidget(this);
63 m_tabCon = new QWidget(this); 64 m_tabCon = new QWidget(this);
64 m_tabKey = new QWidget(this); 65 m_tabKey = new QWidget(this);
65 66
66 m_svCon = new QScrollView( m_tabCon ); 67 m_svCon = new QScrollView( m_tabCon );
67 m_svCon->setResizePolicy( QScrollView::AutoOneFit ); 68 m_svCon->setResizePolicy( QScrollView::AutoOneFit );
68 //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); 69 //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
69 m_svCon->setFrameShape( QFrame::NoFrame ); 70 m_svCon->setFrameShape( QFrame::NoFrame );
70 m_svTerm = new QScrollView( m_tabTerm ); 71 m_svTerm = new QScrollView( m_tabTerm );
71 m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); 72 m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
72 //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); 73 //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
73 m_svTerm->setFrameShape( QFrame::NoFrame ); 74 m_svTerm->setFrameShape( QFrame::NoFrame );
74 75
75 /* base layout for tabs */ 76 /* base layout for tabs */
76 m_layCon = new QHBoxLayout( m_tabCon , 2 ); 77 m_layCon = new QHBoxLayout( m_tabCon , 2 );
77 m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); 78 m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
78 m_layKey = new QHBoxLayout( m_tabKey, 2 ); 79 m_layKey = new QHBoxLayout( m_tabKey, 2 );
79 80
80 m_layCon->addWidget( m_svCon ); 81 m_layCon->addWidget( m_svCon );
81 m_layTerm->addWidget( m_svTerm ); 82 m_layTerm->addWidget( m_svTerm );
82 83
83 // profile tab 84 // profile tab
84 85
85 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 86 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
86 m_name = new QLineEdit(tabprof); 87 m_name = new QLineEdit(tabprof);
87 QLabel *con = new QLabel(tr("Connection"), tabprof ); 88 QLabel *con = new QLabel(tr("Connection"), tabprof );
88 QLabel *term = new QLabel(tr("Terminal"), tabprof ); 89 QLabel *term = new QLabel(tr("Terminal"), tabprof );
89 m_conCmb = new QComboBox( tabprof ); 90 m_conCmb = new QComboBox( tabprof );
90 m_termCmb = new QComboBox( tabprof ); 91 m_termCmb = new QComboBox( tabprof );
91 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); 92 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
92 93
93 // layouting 94 // layouting
94 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 95 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
95 vbox3->add(name); 96 vbox3->add(name);
96 vbox3->add(m_name); 97 vbox3->add(m_name);
97 vbox3->add(con ); 98 vbox3->add(con );
98 vbox3->add(m_conCmb ); 99 vbox3->add(m_conCmb );
99 vbox3->add(term ); 100 vbox3->add(term );
100 vbox3->add(m_termCmb ); 101 vbox3->add(m_termCmb );
101 vbox3->add(m_autoConnect); 102 vbox3->add(m_autoConnect);
102 vbox3->addStretch(1); 103 vbox3->addStretch(1);
103 104
104 m_showconntab = 0; 105 m_showconntab = 0;
105 tabWidget->addTab(tabprof, "", QObject::tr("Profile")); 106 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
106 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); 107 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
107 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); 108 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
108 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); 109 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
109 tabWidget->setCurrentTab( tabprof ); 110 tabWidget->setCurrentTab( tabprof );
110 111
111 112
112 // fill the comboboxes 113 // fill the comboboxes
113 QStringList list = m_fact->connectionWidgets(); 114 QStringList list = m_fact->connectionWidgets();
114 QStringList::Iterator it; 115 QStringList::Iterator it;
115 for (it =list.begin(); it != list.end(); ++it ) { 116 for (it =list.begin(); it != list.end(); ++it ) {
116 m_conCmb->insertItem( (*it) ); 117 m_conCmb->insertItem( (*it) );
117 } 118 }
118 list = m_fact->terminalWidgets(); 119 list = m_fact->terminalWidgets();
119 for (it =list.begin(); it != list.end(); ++it ) { 120 for (it =list.begin(); it != list.end(); ++it ) {
120 m_termCmb->insertItem( (*it) ); 121 m_termCmb->insertItem( (*it) );
121 } 122 }
122 123
123 // load profile values 124 // load profile values
124 m_name->setText(m_prof.name()); 125 m_name->setText(m_prof.name());
125 slotKeyActivated( "Default Keyboard" ); 126 slotKeyActivated( "Default Keyboard" );
126 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); 127 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
127 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); 128 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
128 slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); 129 slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
129 slotTermActivated( m_fact->external(m_prof.terminalName() ) ); 130 slotTermActivated( m_fact->external(m_prof.terminalName() ) );
130 m_autoConnect->setChecked(m_prof.autoConnect()); 131 m_autoConnect->setChecked(m_prof.autoConnect());
131 132
132 133
133 // signal and slots 134 // signal and slots
134 connect(m_conCmb, SIGNAL(activated(const QString&) ), 135 connect(m_conCmb, SIGNAL(activated(const QString&) ),
135 this, SLOT(slotConActivated(const QString&) ) ); 136 this, SLOT(slotConActivated(const QString&) ) );
136 connect(m_termCmb, SIGNAL(activated(const QString&) ), 137 connect(m_termCmb, SIGNAL(activated(const QString&) ),
137 this, SLOT(slotTermActivated(const QString&) ) ); 138 this, SLOT(slotTermActivated(const QString&) ) );
138 139
139} 140}
140 141
141ProfileEditorDialog::~ProfileEditorDialog() { 142ProfileEditorDialog::~ProfileEditorDialog() {
142 143
143} 144}
144void ProfileEditorDialog::accept() 145void ProfileEditorDialog::accept()
145{ 146{
146 if(profName().isEmpty()) 147 if(profName().isEmpty())
147 { 148 {
148 QMessageBox::information(this, 149 QMessageBox::information(this,
149 QObject::tr("Invalid profile"), 150 QObject::tr("Invalid profile"),
150 QObject::tr("Please enter a profile name.")); 151 QObject::tr("Please enter a profile name."));
151 return; 152 return;
152 } 153 }
153 // Save profile and plugin profile 154 // Save profile and plugin profile
154 //if(plugin_plugin) plugin_plugin->save(); 155 //if(plugin_plugin) plugin_plugin->save();
155 156
156 // Save general values 157 // Save general values
157 m_prof.setName( profName() ); 158 m_prof.setName( profName() );
158 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); 159 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
159 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); 160 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
160 m_prof.setAutoConnect( m_autoConnect->isChecked() ); 161 m_prof.setAutoConnect( m_autoConnect->isChecked() );
161 162
162 if (m_con ) 163 if (m_con )
163 m_con->save( m_prof ); 164 m_con->save( m_prof );
164 if (m_term ) 165 if (m_term )
165 m_term->save( m_prof ); 166 m_term->save( m_prof );
166 if (m_key) 167 if (m_key)
167 m_key->save( m_prof ); 168 m_key->save( m_prof );
168 169
169 QDialog::accept(); 170 QDialog::accept();
170} 171}
171 172
172 173
173QString ProfileEditorDialog::profName()const 174QString ProfileEditorDialog::profName()const
174{ 175{
175 return m_name->text(); 176 return m_name->text();
176} 177}
177 178
178QCString ProfileEditorDialog::profType()const 179QCString ProfileEditorDialog::profType()const
179{ 180{
180 /*QStringList w = m_fact->configWidgets(); 181 /*QStringList w = m_fact->configWidgets();
181 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
182 if(device_box->currentText() == m_fact->name((*it))) return (*it); 183 if(device_box->currentText() == m_fact->name((*it))) return (*it);
183 */ 184 */
184 return QCString(); 185 return QCString();
185} 186}
186/* 187/*
187 * we need to switch the widget 188 * we need to switch the widget
188 */ 189 */
189void ProfileEditorDialog::slotConActivated( const QString& str ) { 190void ProfileEditorDialog::slotConActivated( const QString& str ) {
190 191
191 delete m_con; 192 delete m_con;
192 193
193 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); 194 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() );
194 195
195 if ( !m_con ) { 196 if ( !m_con ) {
196 m_con = new NoOptions( str, m_svCon->viewport(), "name"); 197 m_con = new NoOptions( str, m_svCon->viewport(), "name");
197 } 198 }
198 199
199 // FIXME ugly hack right. Right solution would be to look into the layer and see if it 200 // FIXME ugly hack right. Right solution would be to look into the layer and see if it
200 // supports auto connect and then set it as prefered 201 // supports auto connect and then set it as prefered
201 if ( m_conCmb ->currentText() == tr("Local Console") ) { 202 if ( m_conCmb ->currentText() == tr("Local Console") ) {
202 m_autoConnect->setChecked( true ); 203 m_autoConnect->setChecked( true );
203 m_prof.writeEntry("Terminal", Profile::Linux ); 204 m_prof.writeEntry("Terminal", Profile::Linux );
204 slotTermActivated( m_fact->external (m_prof.terminalName() ) ); 205 slotTermActivated( m_fact->external (m_prof.terminalName() ) );
205 } else { 206 } else {
206 m_prof.writeEntry("Terminal", Profile::VT102 ); 207 m_prof.writeEntry("Terminal", Profile::VT102 );
207 slotTermActivated( m_fact->external (m_prof.terminalName() ) ); 208 slotTermActivated( m_fact->external (m_prof.terminalName() ) );
208 m_autoConnect->setChecked( false ); 209 m_autoConnect->setChecked( false );
209 } 210 }
210 211
211 m_con->load( m_prof ); 212 m_con->load( m_prof );
212 m_svCon->addChild( m_con ); 213 m_svCon->addChild( m_con );
213} 214}
214 215
215 216
216/* 217/*
217 * we need to switch the widget 218 * we need to switch the widget
218 */ 219 */
219void ProfileEditorDialog::slotTermActivated( const QString& str ) { 220void ProfileEditorDialog::slotTermActivated( const QString& str ) {
220 221
221 delete m_term; 222 delete m_term;
222 223
223 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); 224 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() );
224 225
225 if ( m_term ) { 226 if ( m_term ) {
226 m_term->load( m_prof ); 227 m_term->load( m_prof );
227 m_svTerm->addChild( m_term ); 228 m_svTerm->addChild( m_term );
228 } 229 }
229} 230}
230 231
231void ProfileEditorDialog::slotKeyActivated(const QString &str) { 232void ProfileEditorDialog::slotKeyActivated(const QString &str) {
232 delete m_key; 233 delete m_key;
233 m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); 234 m_key = m_fact->newKeyboardPlugin( str, m_tabKey );
234 235
235 if (m_key) { 236 if (m_key) {
236 237
237 m_key->load(m_prof); 238 m_key->load(m_prof);
238 m_layKey->addWidget(m_key); 239 m_layKey->addWidget(m_key);
239 } 240 }
240 241
241} 242}
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 97bd650..e7a88e9 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -1,61 +1,61 @@
1#ifndef PROFILE_EDITOR_DIALOG 1#ifndef PROFILE_EDITOR_DIALOG
2#define PROFILE_EDITOR_DIALOG 2#define PROFILE_EDITOR_DIALOG
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5#include <opie2/otabwidget.h> 5#include <opie2/otabwidget.h>
6 6
7#include "profile.h" 7#include "profile.h"
8 8
9class MetaFactory; 9class MetaFactory;
10class EditBase; 10class EditBase;
11class QTabWidget; 11class QTabWidget;
12class QHBoxLayout; 12class QHBoxLayout;
13class QLineEdit; 13class QLineEdit;
14class QComboBox; 14class QComboBox;
15class QCheckBox; 15class QCheckBox;
16class QLabel; 16class QLabel;
17class QScrollView; 17class QScrollView;
18class ProfileDialogWidget; 18class ProfileDialogWidget;
19 19
20class ProfileEditorDialog : public QDialog { 20class ProfileEditorDialog : public QDialog {
21 Q_OBJECT 21 Q_OBJECT
22public: 22public:
23 ProfileEditorDialog(MetaFactory* fact, 23 ProfileEditorDialog(MetaFactory* fact,
24 const Profile& prof ); 24 const Profile& prof );
25 ProfileEditorDialog(MetaFactory* fact ); 25 ProfileEditorDialog(MetaFactory* fact );
26 ~ProfileEditorDialog(); 26 ~ProfileEditorDialog();
27 Profile profile()const; 27 Profile profile()const;
28 28
29 29
30 30
31public slots: 31public slots:
32 void accept(); 32 void accept();
33 33
34private slots: 34private slots:
35 void slotConActivated(const QString& ); 35 void slotConActivated(const QString& );
36 void slotTermActivated( const QString& ); 36 void slotTermActivated( const QString& );
37 void slotKeyActivated(const QString&); 37 void slotKeyActivated(const QString&);
38private: 38private:
39 void initUI(); 39 void initUI();
40 QString profName()const; 40 QString profName()const;
41 QCString profType()const; 41 QCString profType()const;
42 42
43 MetaFactory* m_fact; 43 MetaFactory* m_fact;
44 QHBoxLayout* m_lay; 44 QHBoxLayout* m_lay;
45 Profile m_prof; 45 Profile m_prof;
46 46
47 QLineEdit *m_name; 47 QLineEdit *m_name;
48 QComboBox *m_conCmb, *m_termCmb; 48 QComboBox *m_conCmb, *m_termCmb;
49 QCheckBox *m_autoConnect; 49 QCheckBox *m_autoConnect;
50 50
51 QScrollView *m_svCon, *m_svTerm; 51 QScrollView *m_svCon, *m_svTerm;
52 52
53 QWidget *m_tabCon, *m_tabTerm, *m_tabKey; 53 QWidget *m_tabCon, *m_tabTerm, *m_tabKey;
54 ProfileDialogWidget* m_con, *m_term, *m_key; 54 ProfileDialogWidget* m_con, *m_term, *m_key;
55 QHBoxLayout *m_layCon, *m_layTerm, *m_layKey; 55 QHBoxLayout *m_layCon, *m_layTerm, *m_layKey;
56 OTabWidget *tabWidget; 56 Opie::Ui::OTabWidget *tabWidget;
57 QWidget *tabprof; 57 QWidget *tabprof;
58 int m_showconntab; 58 int m_showconntab;
59}; 59};
60 60
61#endif 61#endif
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index 2f82417..5958e93 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -1,84 +1,86 @@
1 1
2#include "sz_transfer.h" 2#include "sz_transfer.h"
3#include <qfile.h> 3#include <qfile.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <sys/termios.h> 5#include <sys/termios.h>
6 6
7 7
8 8
9using namespace Opie::Core;
10using namespace Opie::Core;
9SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) 11SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
10{ 12{
11} 13}
12 14
13SzTransfer::~SzTransfer() { 15SzTransfer::~SzTransfer() {
14} 16}
15 17
16void SzTransfer::sendFile(const QFile& file) { 18void SzTransfer::sendFile(const QFile& file) {
17 19
18 sendFile(file.name()); 20 sendFile(file.name());
19} 21}
20 22
21void SzTransfer::sendFile(const QString& file) { 23void SzTransfer::sendFile(const QString& file) {
22 24
23 //setcbreak(2); /* raw no echo */ 25 //setcbreak(2); /* raw no echo */
24 26
25 proc = new OProcess; 27 proc = new OProcess;
26 *proc << "sz"; 28 *proc << "sz";
27 *proc << "-v" << "-v" << "-b" << file; 29 *proc << "-v" << "-v" << "-b" << file;
28 connect(proc, SIGNAL(processExited(OProcess*)), 30 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
29 this, SLOT(sent())); 31 this, SLOT(sent()));
30 connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), 32 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
31 this, SLOT(SzReceivedStdout(OProcess*,char*,int))); 33 this, SLOT(SzReceivedStdout(OProcess*,char*,int)));
32 connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), 34 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
33 this, SLOT(SzReceivedStderr(OProcess*,char*,int))); 35 this, SLOT(SzReceivedStderr(OProcess*,char*,int)));
34 connect(layer(), SIGNAL(received(const QByteArray&)), 36 connect(layer(), SIGNAL(received(const QByteArray&)),
35 this, SLOT(receivedStdin(const QByteArray&))); 37 this, SLOT(receivedStdin(const QByteArray&)));
36 proc->start(OProcess::NotifyOnExit, OProcess::All); 38 proc->start(OProcess::NotifyOnExit, OProcess::All);
37 39
38} 40}
39 41
40void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { 42void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) {
41 43
42 qWarning("recieved from sz on stdout %d bytes", buflen); 44 qWarning("recieved from sz on stdout %d bytes", buflen);
43 45
44 QByteArray data(buflen); 46 QByteArray data(buflen);
45 data.fill(*buffer, buflen); 47 data.fill(*buffer, buflen);
46 for (uint i = 0; i < data.count(); i++ ) { 48 for (uint i = 0; i < data.count(); i++ ) {
47 printf("%c", buffer[i] ); 49 printf("%c", buffer[i] );
48 } 50 }
49 printf("\n"); 51 printf("\n");
50 52
51 // send out through the io layer 53 // send out through the io layer
52 layer()->send(data); 54 layer()->send(data);
53} 55}
54 56
55void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { 57void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) {
56 58
57 // parse and show data in a progress dialog/widget 59 // parse and show data in a progress dialog/widget
58 printf("stderr:\n"); 60 printf("stderr:\n");
59 //for (int i = 0; i < length; i++) 61 //for (int i = 0; i < length; i++)
60 // printf("%c", buffer[i]); 62 // printf("%c", buffer[i]);
61 //printf("\n"); 63 //printf("\n");
62} 64}
63 65
64void SzTransfer::receivedStdin(const QByteArray &data) { 66void SzTransfer::receivedStdin(const QByteArray &data) {
65 67
66 qWarning("recieved from io_serial %d bytes", data.size()); 68 qWarning("recieved from io_serial %d bytes", data.size());
67 69
68 // recieved data from the io layer goes to sz 70 // recieved data from the io layer goes to sz
69 proc->writeStdin(data.data(), data.size()); 71 proc->writeStdin(data.data(), data.size());
70 72
71} 73}
72 74
73void SzTransfer::sent() { 75void SzTransfer::sent() {
74 76
75 qWarning("sent file"); 77 qWarning("sent file");
76 78
77 //setcbreak(0); /* default */ 79 //setcbreak(0); /* default */
78 80
79 81
80 delete proc; 82 delete proc;
81 disconnect(layer(), SIGNAL(received(const QByteArray&)), 83 disconnect(layer(), SIGNAL(received(const QByteArray&)),
82 this, SLOT(receivedStdin(const QByteArray&))); 84 this, SLOT(receivedStdin(const QByteArray&)));
83 85
84} 86}
diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h
index aa97c32..0505215 100644
--- a/noncore/apps/opie-console/sz_transfer.h
+++ b/noncore/apps/opie-console/sz_transfer.h
@@ -1,40 +1,40 @@
1#ifndef OPIE_FL_SZ_H 1#ifndef OPIE_FL_SZ_H
2#define OPIE_FL_SZ_H 2#define OPIE_FL_SZ_H
3 3
4#include "file_layer.h" 4#include "file_layer.h"
5#include <opie2/oprocess.h> 5#include <opie2/oprocess.h>
6 6
7class SzTransfer : public FileTransferLayer { 7class SzTransfer : public FileTransferLayer {
8 8
9 Q_OBJECT 9 Q_OBJECT
10 10
11public: 11public:
12 enum Type { 12 enum Type {
13 SZ=0, 13 SZ=0,
14 SX, 14 SX,
15 SY 15 SY
16 }; 16 };
17 17
18 SzTransfer( Type t, IOLayer * ); 18 SzTransfer( Type t, IOLayer * );
19 ~SzTransfer(); 19 ~SzTransfer();
20 20
21public slots: 21public slots:
22 /** 22 /**
23 * send a file over the layer 23 * send a file over the layer
24 */ 24 */
25 void sendFile( const QString& file ) ; 25 void sendFile( const QString& file ) ;
26 void sendFile( const QFile& ); 26 void sendFile( const QFile& );
27 void sent(); 27 void sent();
28 28
29private slots: 29private slots:
30 void SzReceivedStdout(OProcess *, char *, int); 30 void SzReceivedStdout(Opie::Core::OProcess *, char *, int);
31 void SzReceivedStderr(OProcess *, char *, int); 31 void SzReceivedStderr(Opie::Core::OProcess *, char *, int);
32 void receivedStdin(const QByteArray &); 32 void receivedStdin(const QByteArray &);
33 33
34private: 34private:
35 OProcess *proc; 35 Opie::Core::OProcess *proc;
36 Type m_t; 36 Type m_t;
37 37
38}; 38};
39 39
40#endif 40#endif
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 419f8ac..6429e3c 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -1,44 +1,45 @@
1 1
2#include "tabwidget.h" 2#include "tabwidget.h"
3 3
4using namespace Opie::Ui;
4TabWidget::TabWidget( QWidget* parent, const char* name ) 5TabWidget::TabWidget( QWidget* parent, const char* name )
5 : OTabWidget( parent, name ) { 6 : OTabWidget( parent, name ) {
6 connect(this, SIGNAL( currentChanged(QWidget*) ), 7 connect(this, SIGNAL( currentChanged(QWidget*) ),
7 this, SLOT( slotCurChanged(QWidget*) ) ); 8 this, SLOT( slotCurChanged(QWidget*) ) );
8} 9}
9 10
10TabWidget::~TabWidget() { 11TabWidget::~TabWidget() {
11} 12}
12 13
13void TabWidget::add( Session* ses ) { 14void TabWidget::add( Session* ses ) {
14 qWarning("session ses " + ses->name() ); 15 qWarning("session ses " + ses->name() );
15 if ( !ses->widgetStack() ) return; 16 if ( !ses->widgetStack() ) return;
16 //reparent( ses->widgetStack(), QPoint() ); 17 //reparent( ses->widgetStack(), QPoint() );
17 addTab( ses->widgetStack(), "console/konsole", ses->name() ); 18 addTab( ses->widgetStack(), "console/konsole", ses->name() );
18 //addTab( ses->widgetStack(), ses->name() ); 19 //addTab( ses->widgetStack(), ses->name() );
19 m_map.insert( ses->widgetStack(), ses ); 20 m_map.insert( ses->widgetStack(), ses );
20} 21}
21 22
22void TabWidget::remove( Session* ses ) { 23void TabWidget::remove( Session* ses ) {
23 m_map.remove( ses->widgetStack() ); 24 m_map.remove( ses->widgetStack() );
24 removePage( ses->widgetStack() ); 25 removePage( ses->widgetStack() );
25} 26}
26 27
27void TabWidget::slotCurChanged( QWidget* wid ) { 28void TabWidget::slotCurChanged( QWidget* wid ) {
28 QMap<QWidget*, Session*>::Iterator it; 29 QMap<QWidget*, Session*>::Iterator it;
29 it = m_map.find( wid ); 30 it = m_map.find( wid );
30 if ( it == m_map.end() ) { 31 if ( it == m_map.end() ) {
31 return; 32 return;
32 } 33 }
33 34
34 emit activated( it.data() ); 35 emit activated( it.data() );
35} 36}
36void TabWidget::setCurrent( Session* ses ) { 37void TabWidget::setCurrent( Session* ses ) {
37 if (!ses ) 38 if (!ses )
38 return; 39 return;
39 40
40 //showPage( ses->widgetStack() ); 41 //showPage( ses->widgetStack() );
41 setCurrentTab( ses->widgetStack() ); 42 setCurrentTab( ses->widgetStack() );
42} 43}
43 44
44 45
diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h
index 98450a3..0138645 100644
--- a/noncore/apps/opie-console/tabwidget.h
+++ b/noncore/apps/opie-console/tabwidget.h
@@ -1,29 +1,29 @@
1#ifndef OPIE_TAB_WIDGET_H 1#ifndef OPIE_TAB_WIDGET_H
2#define OPIE_TAB_WIDGET_H 2#define OPIE_TAB_WIDGET_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <opie2/otabwidget.h> 5#include <opie2/otabwidget.h>
6 6
7#include "session.h" 7#include "session.h"
8/** 8/**
9 * This is our central tab widget 9 * This is our central tab widget
10 * we can add sessions here 10 * we can add sessions here
11 */ 11 */
12class TabWidget : public OTabWidget{ 12class TabWidget : public Opie::Ui::OTabWidget{
13 Q_OBJECT 13 Q_OBJECT
14public: 14public:
15 TabWidget(QWidget *parent, const char* name ); 15 TabWidget(QWidget *parent, const char* name );
16 ~TabWidget(); 16 ~TabWidget();
17 void add( Session* ); 17 void add( Session* );
18 void remove( Session* ); 18 void remove( Session* );
19 void setCurrent( Session* ); 19 void setCurrent( Session* );
20 20
21signals: 21signals:
22 void activated(Session* ses ); 22 void activated(Session* ses );
23private slots: 23private slots:
24 void slotCurChanged( QWidget* wid ); 24 void slotCurChanged( QWidget* wid );
25private: 25private:
26 QMap<QWidget*, Session*> m_map; 26 QMap<QWidget*, Session*> m_map;
27}; 27};
28 28
29#endif 29#endif
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp
index b1725db..df27055 100644
--- a/noncore/apps/opie-console/test/senderui.cpp
+++ b/noncore/apps/opie-console/test/senderui.cpp
@@ -1,77 +1,79 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <fcntl.h> 3#include <fcntl.h>
4#include <sys/termios.h> 4#include <sys/termios.h>
5 5
6#include <qmultilineedit.h> 6#include <qmultilineedit.h>
7#include <qsocketnotifier.h> 7#include <qsocketnotifier.h>
8 8
9#include "../profile.h" 9#include "../profile.h"
10#include "../io_serial.h" 10#include "../io_serial.h"
11#include "../filetransfer.h" 11#include "../filetransfer.h"
12#include "../filereceive.h" 12#include "../filereceive.h"
13 13
14#include <opie2/oprocess.h> 14#include <opie2/oprocess.h>
15 15
16#include "senderui.h" 16#include "senderui.h"
17 17
18using namespace Opie::Core;
19using namespace Opie::Core;
18SenderUI::SenderUI() 20SenderUI::SenderUI()
19 : Sender() { 21 : Sender() {
20 22
21 /* we do that manually */ 23 /* we do that manually */
22 Profile prof; 24 Profile prof;
23 QString str = "/dev/bty0"; 25 QString str = "/dev/bty0";
24 prof.writeEntry("Device",str ); 26 prof.writeEntry("Device",str );
25 prof.writeEntry("Baud", 19200 ); 27 prof.writeEntry("Baud", 19200 );
26 28
27 qWarning("prof " + prof.readEntry("Device") + " " + str); 29 qWarning("prof " + prof.readEntry("Device") + " " + str);
28 ser = new IOSerial(prof); 30 ser = new IOSerial(prof);
29 connect(ser, SIGNAL(received(const QByteArray&) ), 31 connect(ser, SIGNAL(received(const QByteArray&) ),
30 this, SLOT(got(const QByteArray&) ) ); 32 this, SLOT(got(const QByteArray&) ) );
31 33
32 if ( ser->open() ) 34 if ( ser->open() )
33 qWarning("opened!!!"); 35 qWarning("opened!!!");
34 else 36 else
35 qWarning("could not open"); 37 qWarning("could not open");
36 38
37 39
38} 40}
39SenderUI::~SenderUI() { 41SenderUI::~SenderUI() {
40 42
41} 43}
42void SenderUI::slotSendFile() { 44void SenderUI::slotSendFile() {
43 45
44 sz = new FileTransfer(FileTransfer::SY, ser); 46 sz = new FileTransfer(FileTransfer::SY, ser);
45 sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); 47 sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
46 48
47 connect (sz, SIGNAL(sent()), 49 connect (sz, SIGNAL(sent()),
48 this, SLOT(fileTransComplete())); 50 this, SLOT(fileTransComplete()));
49} 51}
50 52
51void SenderUI::slotSend() { 53void SenderUI::slotSend() {
52 QCString str = MultiLineEdit1->text().utf8(); 54 QCString str = MultiLineEdit1->text().utf8();
53 qWarning("sending: %s", str.data() ); 55 qWarning("sending: %s", str.data() );
54 str = str.replace( QRegExp("\n"), "\r"); 56 str = str.replace( QRegExp("\n"), "\r");
55 ser->send( str ); 57 ser->send( str );
56} 58}
57void SenderUI::got(const QByteArray& ar) { 59void SenderUI::got(const QByteArray& ar) {
58 qWarning("got:"); 60 qWarning("got:");
59 for ( uint i = 0; i < ar.count(); i++ ) { 61 for ( uint i = 0; i < ar.count(); i++ ) {
60 printf("%c", ar[i] ); 62 printf("%c", ar[i] );
61 } 63 }
62 printf("\n"); 64 printf("\n");
63} 65}
64 66
65void SenderUI::fileTransComplete() { 67void SenderUI::fileTransComplete() {
66 68
67 qWarning("file transfer complete"); 69 qWarning("file transfer complete");
68} 70}
69void SenderUI::send() { 71void SenderUI::send() {
70 72
71} 73}
72void SenderUI::slotRev(){ 74void SenderUI::slotRev(){
73qWarning("Going to receive!"); 75qWarning("Going to receive!");
74FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); 76FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
75rev->receive(); 77rev->receive();
76 78
77} 79}
diff --git a/noncore/apps/opie-console/test/senderui.h b/noncore/apps/opie-console/test/senderui.h
index c130dcf..15f0743 100644
--- a/noncore/apps/opie-console/test/senderui.h
+++ b/noncore/apps/opie-console/test/senderui.h
@@ -1,34 +1,34 @@
1#ifndef SENDER_UI_H 1#ifndef SENDER_UI_H
2#define SENDER_UI_H 2#define SENDER_UI_H
3 3
4#include <qcstring.h> 4#include <qcstring.h>
5 5
6#include "sender.h" 6#include "sender.h"
7 7
8class IOSerial; 8class IOSerial;
9class FileTransfer; 9class FileTransfer;
10class QSocketNotifier; 10class QSocketNotifier;
11class OProcess; 11namespace Opie {namespace Core {class Opie::Core::OProcess;}}
12class SenderUI : public Sender { 12class SenderUI : public Sender {
13 Q_OBJECT 13 Q_OBJECT
14public: 14public:
15 SenderUI(); 15 SenderUI();
16 ~SenderUI(); 16 ~SenderUI();
17 17
18public slots: 18public slots:
19 void send(); 19 void send();
20 void slotSendFile(); 20 void slotSendFile();
21 void slotSend(); 21 void slotSend();
22 void slotRev(); 22 void slotRev();
23 void got(const QByteArray& ); 23 void got(const QByteArray& );
24 void fileTransComplete(); 24 void fileTransComplete();
25private: 25private:
26 IOSerial* ser; 26 IOSerial* ser;
27 FileTransfer* sz; 27 FileTransfer* sz;
28 int m_fd; 28 int m_fd;
29 QSocketNotifier* m_sock; 29 QSocketNotifier* m_sock;
30 OProcess* m_proc; 30 Opie::Core::OProcess* m_proc;
31}; 31};
32 32
33 33
34#endif 34#endif
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index d494a6c..75eb443 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -1,275 +1,276 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qcombobox.h> 2#include <qcombobox.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qbuttongroup.h> 9#include <qbuttongroup.h>
10 10
11#include <opie2/ofiledialog.h> 11#include <opie2/ofiledialog.h>
12 12
13#include "metafactory.h" 13#include "metafactory.h"
14#include "mainwindow.h" 14#include "mainwindow.h"
15 15
16#include "transferdialog.h" 16#include "transferdialog.h"
17 17
18using namespace Opie::Ui;
18TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) 19TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *)
19: QDialog(parent, 0l, false), m_win(mainwindow) 20: QDialog(parent, 0l, false), m_win(mainwindow)
20{ 21{
21 m_lay = 0l; 22 m_lay = 0l;
22 m_recvlay = 0l; 23 m_recvlay = 0l;
23 QVBoxLayout *vbox, *vbox2; 24 QVBoxLayout *vbox, *vbox2;
24 QHBoxLayout *hbox, *hbox2, *hbox3; 25 QHBoxLayout *hbox, *hbox2, *hbox3;
25 QLabel *file, *mode, *progress, *status; 26 QLabel *file, *mode, *progress, *status;
26 QButtonGroup *group; 27 QButtonGroup *group;
27 QRadioButton *mode_send, *mode_receive; 28 QRadioButton *mode_send, *mode_receive;
28 29
29 m_autocleanup = 0; 30 m_autocleanup = 0;
30 m_running = true; 31 m_running = true;
31 32
32 group = new QButtonGroup(QObject::tr("Transfer mode"), this); 33 group = new QButtonGroup(QObject::tr("Transfer mode"), this);
33 mode_send = new QRadioButton(QObject::tr("Send"), group); 34 mode_send = new QRadioButton(QObject::tr("Send"), group);
34 mode_receive = new QRadioButton(QObject::tr("Receive"), group); 35 mode_receive = new QRadioButton(QObject::tr("Receive"), group);
35 group->insert(mode_send, id_send); 36 group->insert(mode_send, id_send);
36 group->insert(mode_receive, id_receive); 37 group->insert(mode_receive, id_receive);
37 vbox2 = new QVBoxLayout(group, 2); 38 vbox2 = new QVBoxLayout(group, 2);
38 vbox2->addSpacing(10); 39 vbox2->addSpacing(10);
39 hbox3 = new QHBoxLayout(vbox2, 2); 40 hbox3 = new QHBoxLayout(vbox2, 2);
40 hbox3->add(mode_send); 41 hbox3->add(mode_send);
41 hbox3->add(mode_receive); 42 hbox3->add(mode_receive);
42 mode_send->setChecked(true); 43 mode_send->setChecked(true);
43 m_transfermode = id_send; 44 m_transfermode = id_send;
44 45
45 file = new QLabel(QObject::tr("Send file"), this); 46 file = new QLabel(QObject::tr("Send file"), this);
46 mode = new QLabel(QObject::tr("Transfer protocol"), this); 47 mode = new QLabel(QObject::tr("Transfer protocol"), this);
47 progress = new QLabel(QObject::tr("Progress"), this); 48 progress = new QLabel(QObject::tr("Progress"), this);
48 status = new QLabel(QObject::tr("Status"), this); 49 status = new QLabel(QObject::tr("Status"), this);
49 50
50 statusbar = new QLabel(QObject::tr("Ready"), this); 51 statusbar = new QLabel(QObject::tr("Ready"), this);
51 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); 52 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
52 53
53 protocol = new QComboBox(this); 54 protocol = new QComboBox(this);
54 QStringList list = m_win->factory()->fileTransferLayers(); 55 QStringList list = m_win->factory()->fileTransferLayers();
55 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 56 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
56 protocol->insertItem((*it)); 57 protocol->insertItem((*it));
57 58
58 filename = new QLineEdit(this); 59 filename = new QLineEdit(this);
59 60
60 progressbar = new QProgressBar(this); 61 progressbar = new QProgressBar(this);
61 progressbar->setProgress(0); 62 progressbar->setProgress(0);
62 63
63 selector = new QPushButton("...", this); 64 selector = new QPushButton("...", this);
64 ok = new QPushButton(QObject::tr("Start transfer"), this); 65 ok = new QPushButton(QObject::tr("Start transfer"), this);
65 cancel = new QPushButton(QObject::tr("Cancel"), this); 66 cancel = new QPushButton(QObject::tr("Cancel"), this);
66 67
67 vbox = new QVBoxLayout(this, 2); 68 vbox = new QVBoxLayout(this, 2);
68 vbox->add(group); 69 vbox->add(group);
69 vbox->add(file); 70 vbox->add(file);
70 hbox = new QHBoxLayout(vbox, 0); 71 hbox = new QHBoxLayout(vbox, 0);
71 hbox->add(filename); 72 hbox->add(filename);
72 hbox->add(selector); 73 hbox->add(selector);
73 vbox->add(mode); 74 vbox->add(mode);
74 vbox->add(protocol); 75 vbox->add(protocol);
75 vbox->add(progress); 76 vbox->add(progress);
76 vbox->add(progressbar); 77 vbox->add(progressbar);
77 vbox->add(status); 78 vbox->add(status);
78 vbox->add(statusbar); 79 vbox->add(statusbar);
79 vbox->addStretch(1); 80 vbox->addStretch(1);
80 hbox2 = new QHBoxLayout(vbox, 2); 81 hbox2 = new QHBoxLayout(vbox, 2);
81 hbox2->add(ok); 82 hbox2->add(ok);
82 hbox2->add(cancel); 83 hbox2->add(cancel);
83 84
84 setCaption(QObject::tr("File transfer")); 85 setCaption(QObject::tr("File transfer"));
85 show(); 86 show();
86 87
87 connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); 88 connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
88 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); 89 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
89 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 90 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
90 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); 91 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
91} 92}
92 93
93TransferDialog::~TransferDialog() 94TransferDialog::~TransferDialog()
94{ 95{
95} 96}
96 97
97void TransferDialog::slotFilename() 98void TransferDialog::slotFilename()
98{ 99{
99 QString f; 100 QString f;
100 101
101 f = Opie::OFileDialog::getOpenFileName(0); 102 f = OFileDialog::getOpenFileName(0);
102 if(!f.isNull()) filename->setText(f); 103 if(!f.isNull()) filename->setText(f);
103} 104}
104 105
105void TransferDialog::slotTransfer() 106void TransferDialog::slotTransfer()
106{ 107{
107 if((m_transfermode == id_send) && (filename->text().isEmpty())) 108 if((m_transfermode == id_send) && (filename->text().isEmpty()))
108 { 109 {
109 QMessageBox::information(this, 110 QMessageBox::information(this,
110 QObject::tr("Attention"), 111 QObject::tr("Attention"),
111 QObject::tr("No file has been specified.")); 112 QObject::tr("No file has been specified."));
112 return; 113 return;
113 } 114 }
114 115
115 ok->setEnabled(false); 116 ok->setEnabled(false);
116 117
117 cleanup(); 118 cleanup();
118 m_autocleanup = 0; 119 m_autocleanup = 0;
119 120
120 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); 121 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
121 else statusbar->setText(QObject::tr("Receiving...")); 122 else statusbar->setText(QObject::tr("Receiving..."));
122 123
123 if(m_transfermode == id_send) 124 if(m_transfermode == id_send)
124 { 125 {
125 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); 126 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
126 m_lay->sendFile(filename->text()); 127 m_lay->sendFile(filename->text());
127 128
128 connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)), 129 connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)),
129 SLOT(slotProgress(const QString&,int,int,int,int,int))); 130 SLOT(slotProgress(const QString&,int,int,int,int,int)));
130 connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); 131 connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&)));
131 connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); 132 connect(m_lay, SIGNAL(sent()), SLOT(slotSent()));
132 } 133 }
133 else 134 else
134 { 135 {
135 m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); 136 m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
136 m_recvlay->receive(); 137 m_recvlay->receive();
137 138
138 connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)), 139 connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)),
139 SLOT(slotProgress(const QString&,int,int,int,int,int))); 140 SLOT(slotProgress(const QString&,int,int,int,int,int)));
140 connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); 141 connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&)));
141 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); 142 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
142 } 143 }
143} 144}
144 145
145void TransferDialog::cleanup() 146void TransferDialog::cleanup()
146{ 147{
147 if(m_lay) 148 if(m_lay)
148 { 149 {
149 m_lay->cancel(); 150 m_lay->cancel();
150 delete m_lay; 151 delete m_lay;
151 m_lay = 0l; 152 m_lay = 0l;
152 } 153 }
153 if(m_recvlay) 154 if(m_recvlay)
154 { 155 {
155 m_recvlay->cancel(); 156 m_recvlay->cancel();
156 delete m_recvlay; 157 delete m_recvlay;
157 m_recvlay = 0l; 158 m_recvlay = 0l;
158 } 159 }
159} 160}
160 161
161void TransferDialog::slotCancel() 162void TransferDialog::slotCancel()
162{ 163{
163 ok->setEnabled(true); 164 ok->setEnabled(true);
164 statusbar->setText(QObject::tr("Ready")); 165 statusbar->setText(QObject::tr("Ready"));
165 166
166 if((m_lay) || (m_recvlay)) 167 if((m_lay) || (m_recvlay))
167 { 168 {
168 cleanup(); 169 cleanup();
169 if(m_autocleanup) 170 if(m_autocleanup)
170 { 171 {
171 m_running = false; 172 m_running = false;
172 close(); 173 close();
173 } 174 }
174 else 175 else
175 { 176 {
176 QMessageBox::information(this, 177 QMessageBox::information(this,
177 QObject::tr("Cancelled"), 178 QObject::tr("Cancelled"),
178 QObject::tr("The file transfer has been cancelled.")); 179 QObject::tr("The file transfer has been cancelled."));
179 } 180 }
180 } 181 }
181 else 182 else
182 { 183 {
183 m_running = false; 184 m_running = false;
184 close(); 185 close();
185 } 186 }
186} 187}
187 188
188void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) 189void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int )
189{ 190{
190 progressbar->setProgress(progress); 191 progressbar->setProgress(progress);
191} 192}
192 193
193void TransferDialog::slotError(int error, const QString& ) 194void TransferDialog::slotError(int error, const QString& )
194{ 195{
195 statusbar->setText(QObject::tr("Ready")); 196 statusbar->setText(QObject::tr("Ready"));
196 197
197 switch(error) 198 switch(error)
198 { 199 {
199 case FileTransferLayer::NotSupported: 200 case FileTransferLayer::NotSupported:
200 QMessageBox::critical(this, 201 QMessageBox::critical(this,
201 QObject::tr("Error"), 202 QObject::tr("Error"),
202 QObject::tr("Operation not supported.")); 203 QObject::tr("Operation not supported."));
203 break; 204 break;
204 case FileTransferLayer::StartError: 205 case FileTransferLayer::StartError:
205 QMessageBox::critical(this, 206 QMessageBox::critical(this,
206 QObject::tr("Error"), 207 QObject::tr("Error"),
207 QObject::tr("Transfer could not be started.")); 208 QObject::tr("Transfer could not be started."));
208 break; 209 break;
209 case FileTransferLayer::NoError: 210 case FileTransferLayer::NoError:
210 QMessageBox::critical(this, 211 QMessageBox::critical(this,
211 QObject::tr("Error"), 212 QObject::tr("Error"),
212 QObject::tr("No error.")); 213 QObject::tr("No error."));
213 break; 214 break;
214 case FileTransferLayer::Undefined: 215 case FileTransferLayer::Undefined:
215 QMessageBox::critical(this, 216 QMessageBox::critical(this,
216 QObject::tr("Error"), 217 QObject::tr("Error"),
217 QObject::tr("Undefined error occured.")); 218 QObject::tr("Undefined error occured."));
218 break; 219 break;
219 case FileTransferLayer::Incomplete: 220 case FileTransferLayer::Incomplete:
220 QMessageBox::critical(this, 221 QMessageBox::critical(this,
221 QObject::tr("Error"), 222 QObject::tr("Error"),
222 QObject::tr("Incomplete transfer.")); 223 QObject::tr("Incomplete transfer."));
223 break; 224 break;
224 case FileTransferLayer::Unknown: 225 case FileTransferLayer::Unknown:
225 default: 226 default:
226 QMessageBox::critical(this, 227 QMessageBox::critical(this,
227 QObject::tr("Error"), 228 QObject::tr("Error"),
228 QObject::tr("Unknown error occured.")); 229 QObject::tr("Unknown error occured."));
229 break; 230 break;
230 } 231 }
231 232
232 m_autocleanup = 1; 233 m_autocleanup = 1;
233} 234}
234 235
235void TransferDialog::slotSent() 236void TransferDialog::slotSent()
236{ 237{
237 progressbar->setProgress(100); 238 progressbar->setProgress(100);
238 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); 239 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
239 ok->setEnabled(true); 240 ok->setEnabled(true);
240 progressbar->setProgress(0); 241 progressbar->setProgress(0);
241 statusbar->setText(QObject::tr("Ready")); 242 statusbar->setText(QObject::tr("Ready"));
242 m_autocleanup = 1; 243 m_autocleanup = 1;
243} 244}
244 245
245void TransferDialog::slotReceived(const QString& ) 246void TransferDialog::slotReceived(const QString& )
246{ 247{
247 progressbar->setProgress(100); 248 progressbar->setProgress(100);
248 QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); 249 QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received."));
249 //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); 250 //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
250 ok->setEnabled(true); 251 ok->setEnabled(true);
251 progressbar->setProgress(0); 252 progressbar->setProgress(0);
252 statusbar->setText(QObject::tr("Ready")); 253 statusbar->setText(QObject::tr("Ready"));
253 m_autocleanup = 1; 254 m_autocleanup = 1;
254} 255}
255 256
256void TransferDialog::slotMode(int id) 257void TransferDialog::slotMode(int id)
257{ 258{
258 if(id == id_send) 259 if(id == id_send)
259 { 260 {
260 selector->setEnabled(true); 261 selector->setEnabled(true);
261 filename->setEnabled(true); 262 filename->setEnabled(true);
262 } 263 }
263 else 264 else
264 { 265 {
265 selector->setEnabled(false); 266 selector->setEnabled(false);
266 filename->setEnabled(false); 267 filename->setEnabled(false);
267 } 268 }
268 m_transfermode = id; 269 m_transfermode = id;
269} 270}
270 271
271bool TransferDialog::isRunning() 272bool TransferDialog::isRunning()
272{ 273{
273 return m_running; 274 return m_running;
274} 275}
275 276
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index b0d589e..b072854 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -1,2074 +1,2074 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. Allrights reserved. 2** Copyright (C) 2000 Trolltech AS. Allrights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop 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 "useqpe.h" 20#include "useqpe.h"
21#include <qregexp.h> 21#include <qregexp.h>
22#include <qclipboard.h> 22#include <qclipboard.h>
23#include <qwidgetstack.h> 23#include <qwidgetstack.h>
24#ifdef USEQPE 24#ifdef USEQPE
25#include <qmenubar.h> 25#include <qmenubar.h>
26#include <qpe/qpetoolbar.h> 26#include <qtoolbar.h>
27#endif 27#endif
28#include <qmenubar.h> 28#include <qmenubar.h>
29#include <qtoolbar.h> 29#include <qtoolbar.h>
30#ifdef USEQPE 30#ifdef USEQPE
31#include <qpe/menubutton.h> 31#include <qpe/menubutton.h>
32#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33#endif 33#endif
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qtoolbutton.h> 39#include <qtoolbutton.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qobjectlist.h> 41#include <qobjectlist.h>
42#ifdef USEQPE 42#ifdef USEQPE
43#include <qpe/global.h> 43#include <qpe/global.h>
44#include <qpe/applnk.h> 44#include <qpe/applnk.h>
45#endif 45#endif
46#include <qfileinfo.h> 46#include <qfileinfo.h>
47#include <stdlib.h> //getenv 47#include <stdlib.h> //getenv
48#include <qprogressbar.h> 48#include <qprogressbar.h>
49#ifdef USEQPE 49#ifdef USEQPE
50#include <qpe/config.h> 50#include <qpe/config.h>
51#endif 51#endif
52#include <qbuttongroup.h> 52#include <qbuttongroup.h>
53#include <qradiobutton.h> 53#include <qradiobutton.h>
54#ifdef USEQPE 54#ifdef USEQPE
55#include <qpe/qcopenvelope_qws.h> 55#include <qpe/qcopenvelope_qws.h>
56#endif 56#endif
57#include "QTReader.h" 57#include "QTReader.h"
58#include "GraphicWin.h" 58#include "GraphicWin.h"
59#include "Bkmks.h" 59#include "Bkmks.h"
60#include "cbkmkselector.h" 60#include "cbkmkselector.h"
61#include "infowin.h" 61#include "infowin.h"
62#include "ToolbarPrefs.h" 62#include "ToolbarPrefs.h"
63#include "Prefs.h" 63#include "Prefs.h"
64#include "CAnnoEdit.h" 64#include "CAnnoEdit.h"
65#include "QFloatBar.h" 65#include "QFloatBar.h"
66#include "FixedFont.h" 66#include "FixedFont.h"
67#include "URLDialog.h" 67#include "URLDialog.h"
68//#include <qpe/fontdatabase.h> 68//#include <qpe/fontdatabase.h>
69 69
70#ifdef USEQPE 70#ifdef USEQPE
71#include <qpe/resource.h> 71#include <qpe/resource.h>
72#include <qpe/qpeapplication.h> 72#include <qpe/qpeapplication.h>
73#include "fileBrowser.h" 73#include "fileBrowser.h"
74#else 74#else
75#include "qfiledialog.h" 75#include "qfiledialog.h"
76#endif 76#endif
77 77
78#include "QTReaderApp.h" 78#include "QTReaderApp.h"
79#include "CDrawBuffer.h" 79#include "CDrawBuffer.h"
80#include "Filedata.h" 80#include "Filedata.h"
81#include "opie.h" 81#include "opie.h"
82#include "names.h" 82#include "names.h"
83#include "CEncoding_tables.h" 83#include "CEncoding_tables.h"
84#include "CloseDialog.h" 84#include "CloseDialog.h"
85 85
86bool CheckVersion(int&, int&, char&); 86bool CheckVersion(int&, int&, char&);
87 87
88#ifdef _WINDOWS 88#ifdef _WINDOWS
89#define PICDIR "c:\\uqtreader\\pics\\" 89#define PICDIR "c:\\uqtreader\\pics\\"
90#else 90#else
91#ifdef USEQPE 91#ifdef USEQPE
92#define PICDIR "opie-reader/" 92#define PICDIR "opie-reader/"
93#else 93#else
94#define PICDIR "/home/tim/uqtreader/pics/" 94#define PICDIR "/home/tim/uqtreader/pics/"
95#endif 95#endif
96#endif 96#endif
97 97
98unsigned long QTReaderApp::m_uid = 0; 98unsigned long QTReaderApp::m_uid = 0;
99 99
100void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 100void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
101 101
102#ifdef USEQPE 102#ifdef USEQPE
103#define geticon(iconname) Resource::loadPixmap( iconname ) 103#define geticon(iconname) Resource::loadPixmap( iconname )
104#define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) 104#define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname )
105#else 105#else
106#define geticon(iconname) QPixmap(PICDIR iconname ".png") 106#define geticon(iconname) QPixmap(PICDIR iconname ".png")
107#define getmyicon(iconname) geticon(iconname) 107#define getmyicon(iconname) geticon(iconname)
108//#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) 108//#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) )
109#endif 109#endif
110 110
111#ifndef _WINDOWS 111#ifndef _WINDOWS
112#include <unistd.h> 112#include <unistd.h>
113#endif 113#endif
114#include <stddef.h> 114#include <stddef.h>
115#ifndef _WINDOWS 115#ifndef _WINDOWS
116#include <dirent.h> 116#include <dirent.h>
117#endif 117#endif
118 118
119void QTReaderApp::listBkmkFiles() 119void QTReaderApp::listBkmkFiles()
120{ 120{
121 bkmkselector->clear(); 121 bkmkselector->clear();
122 bkmkselector->setText("Cancel"); 122 bkmkselector->setText("Cancel");
123#ifndef USEQPE 123#ifndef USEQPE
124 int cnt = 0; 124 int cnt = 0;
125 125
126 QDir d = QDir::home(); // "/" 126 QDir d = QDir::home(); // "/"
127 if ( !d.cd(APPDIR) ) { // "/tmp" 127 if ( !d.cd(APPDIR) ) { // "/tmp"
128 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 128 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
129 d = QDir::home(); 129 d = QDir::home();
130 d.mkdir(APPDIR); 130 d.mkdir(APPDIR);
131 d.cd(APPDIR); 131 d.cd(APPDIR);
132 } 132 }
133 133
134 134
135 135
136 136
137 d.setFilter( QDir::Files | QDir::NoSymLinks ); 137 d.setFilter( QDir::Files | QDir::NoSymLinks );
138// d.setSorting( QDir::Size | QDir::Reversed ); 138// d.setSorting( QDir::Size | QDir::Reversed );
139 139
140 const QFileInfoList *list = d.entryInfoList(); 140 const QFileInfoList *list = d.entryInfoList();
141 QFileInfoListIterator it( *list ); // create list iterator 141 QFileInfoListIterator it( *list ); // create list iterator
142 QFileInfo *fi; // pointer for traversing 142 QFileInfo *fi; // pointer for traversing
143 143
144 while ( (fi=it.current()) ) { // for each file... 144 while ( (fi=it.current()) ) { // for each file...
145 145
146 bkmkselector->insertItem(fi->fileName()); 146 bkmkselector->insertItem(fi->fileName());
147 cnt++; 147 cnt++;
148 148
149 //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); 149 //qDebug( "%10li %s", fi->size(), fi->fileName().data() );
150 ++it; // goto next list element 150 ++it; // goto next list element
151 } 151 }
152 152
153#else /* USEQPE */ 153#else /* USEQPE */
154 int cnt = 0; 154 int cnt = 0;
155 DIR *d; 155 DIR *d;
156 d = opendir((const char *)Global::applicationFileName(APPDIR,"")); 156 d = opendir((const char *)Global::applicationFileName(APPDIR,""));
157 157
158 while(1) 158 while(1)
159 { 159 {
160 struct dirent* de; 160 struct dirent* de;
161 struct stat buf; 161 struct stat buf;
162 de = readdir(d); 162 de = readdir(d);
163 if (de == NULL) break; 163 if (de == NULL) break;
164 164
165 if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) 165 if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
166 { 166 {
167 bkmkselector->insertItem(de->d_name); 167 bkmkselector->insertItem(de->d_name);
168 cnt++; 168 cnt++;
169 } 169 }
170 } 170 }
171 171
172 closedir(d); 172 closedir(d);
173#endif 173#endif
174 if (cnt > 0) 174 if (cnt > 0)
175 { 175 {
176//tjw menu->hide(); 176//tjw menu->hide();
177 editorStack->raiseWidget( bkmkselector ); 177 editorStack->raiseWidget( bkmkselector );
178 hidetoolbars(); 178 hidetoolbars();
179 m_nBkmkAction = cRmBkmkFile; 179 m_nBkmkAction = cRmBkmkFile;
180 } 180 }
181 else 181 else
182 QMessageBox::information(this, PROGNAME, "No bookmark files"); 182 QMessageBox::information(this, PROGNAME, "No bookmark files");
183} 183}
184 184
185void QTReaderApp::hidetoolbars() 185void QTReaderApp::hidetoolbars()
186{ 186{
187 menubar->hide(); 187 menubar->hide();
188 if (fileBar != NULL) fileBar->hide(); 188 if (fileBar != NULL) fileBar->hide();
189 if (viewBar != NULL) viewBar->hide(); 189 if (viewBar != NULL) viewBar->hide();
190 if (navBar != NULL) navBar->hide(); 190 if (navBar != NULL) navBar->hide();
191 if (markBar != NULL) markBar->hide(); 191 if (markBar != NULL) markBar->hide();
192 if (m_fontVisible) m_fontBar->hide(); 192 if (m_fontVisible) m_fontBar->hide();
193 if (regVisible) 193 if (regVisible)
194 { 194 {
195#ifdef USEQPE 195#ifdef USEQPE
196 Global::hideInputMethod(); 196 Global::hideInputMethod();
197#endif 197#endif
198 regBar->hide(); 198 regBar->hide();
199 } 199 }
200 if (searchVisible) 200 if (searchVisible)
201 { 201 {
202#ifdef USEQPE 202#ifdef USEQPE
203 Global::hideInputMethod(); 203 Global::hideInputMethod();
204#endif 204#endif
205 searchBar->hide(); 205 searchBar->hide();
206 } 206 }
207} 207}
208 208
209QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 209QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
210 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), 210 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
211 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) 211 fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
212{ 212{
213 m_url_clipboard = false; 213 m_url_clipboard = false;
214 m_url_localfile = false; 214 m_url_localfile = false;
215 m_url_globalfile = false; 215 m_url_globalfile = false;
216 ftime(&m_lastkeytime); 216 ftime(&m_lastkeytime);
217//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 217//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
218//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 218//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
219 219
220 m_bcloseDisabled = true; 220 m_bcloseDisabled = true;
221 m_disableesckey = false; 221 m_disableesckey = false;
222 pBkmklist = NULL; 222 pBkmklist = NULL;
223 pOpenlist = NULL; 223 pOpenlist = NULL;
224// doc = 0; 224// doc = 0;
225 225
226 m_fBkmksChanged = false; 226 m_fBkmksChanged = false;
227 227
228 QString lang = getenv( "LANG" ); 228 QString lang = getenv( "LANG" );
229 QString rot = getenv( "QWS_DISPLAY" ); 229 QString rot = getenv( "QWS_DISPLAY" );
230 230
231/* 231/*
232 int m_rot = 0; 232 int m_rot = 0;
233 if (rot.contains("Rot90")) 233 if (rot.contains("Rot90"))
234 { 234 {
235 m_rot = 90; 235 m_rot = 90;
236 } 236 }
237 else if (rot.contains("Rot180")) 237 else if (rot.contains("Rot180"))
238 { 238 {
239 m_rot = 180; 239 m_rot = 180;
240 } 240 }
241 else if (rot.contains("Rot270")) 241 else if (rot.contains("Rot270"))
242 { 242 {
243 m_rot = 270; 243 m_rot = 270;
244 } 244 }
245 245
246// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); 246// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
247*/ 247*/
248 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 248 m_autogenstr = "^ *[A-Z].*[a-z] *$";
249 249
250#ifdef USEQPE 250#ifdef USEQPE
251 setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); 251 setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
252#else 252#else
253 setIcon( QPixmap (PICDIR "uqtreader.png") ); 253 setIcon( QPixmap (PICDIR "uqtreader.png") );
254#endif /* USEQPE */ 254#endif /* USEQPE */
255 255
256// QToolBar *bar = new QToolBar( this ); 256// QToolBar *bar = new QToolBar( this );
257// menubar = new QToolBar( this ); 257// menubar = new QToolBar( this );
258#ifdef USEQPE 258#ifdef USEQPE
259 Config config( APPDIR ); 259 Config config( APPDIR );
260#else 260#else
261 QDir d = QDir::home(); // "/" 261 QDir d = QDir::home(); // "/"
262 if ( !d.cd(APPDIR) ) { // "/tmp" 262 if ( !d.cd(APPDIR) ) { // "/tmp"
263 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 263 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
264 d = QDir::home(); 264 d = QDir::home();
265 d.mkdir(APPDIR); 265 d.mkdir(APPDIR);
266 d.cd(APPDIR); 266 d.cd(APPDIR);
267 } 267 }
268 QFileInfo fi(d, INIFILE); 268 QFileInfo fi(d, INIFILE);
269// qDebug("Path:%s", (const char*)fi.absFilePath()); 269// qDebug("Path:%s", (const char*)fi.absFilePath());
270 Config config(fi.absFilePath()); 270 Config config(fi.absFilePath());
271#endif 271#endif
272 config.setGroup("Toolbar"); 272 config.setGroup("Toolbar");
273 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); 273 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
274 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); 274 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
275 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); 275 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
276 menubar = new QToolBar("Menus", this, m_tbposition); 276 menubar = new QToolBar("Menus", this, m_tbposition);
277 277
278// fileBar = new QToolBar("File", this); 278// fileBar = new QToolBar("File", this);
279// QToolBar* viewBar = new QToolBar("File", this); 279// QToolBar* viewBar = new QToolBar("File", this);
280// QToolBar* navBar = new QToolBar("File", this); 280// QToolBar* navBar = new QToolBar("File", this);
281// QToolBar* markBar = new QToolBar("File", this); 281// QToolBar* markBar = new QToolBar("File", this);
282 282
283#ifdef USEQPE 283#ifdef USEQPE
284 mb = new QMenuBar( menubar ); 284 mb = new QMenuBar( menubar );
285#else 285#else
286 mb = new QMenuBar( menubar ); 286 mb = new QMenuBar( menubar );
287#endif 287#endif
288 288
289//#ifdef USEQPE 289//#ifdef USEQPE
290 QPopupMenu* tmp = new QPopupMenu(mb); 290 QPopupMenu* tmp = new QPopupMenu(mb);
291 mb->insertItem( geticon( "AppsIcon" ), tmp ); 291 mb->insertItem( geticon( "AppsIcon" ), tmp );
292//#else 292//#else
293// QMenuBar* tmp = mb; 293// QMenuBar* tmp = mb;
294//#endif 294//#endif
295 295
296 QPopupMenu *file = new QPopupMenu( mb ); 296 QPopupMenu *file = new QPopupMenu( mb );
297 tmp->insertItem( tr( "File" ), file ); 297 tmp->insertItem( tr( "File" ), file );
298 298
299 QPopupMenu *navigation = new QPopupMenu(mb); 299 QPopupMenu *navigation = new QPopupMenu(mb);
300 tmp->insertItem( tr( "Navigation" ), navigation ); 300 tmp->insertItem( tr( "Navigation" ), navigation );
301 301
302 QPopupMenu *view = new QPopupMenu( mb ); 302 QPopupMenu *view = new QPopupMenu( mb );
303 tmp->insertItem( tr( "View" ), view ); 303 tmp->insertItem( tr( "View" ), view );
304 304
305 QPopupMenu *marks = new QPopupMenu( this ); 305 QPopupMenu *marks = new QPopupMenu( this );
306 tmp->insertItem( tr( "Marks" ), marks ); 306 tmp->insertItem( tr( "Marks" ), marks );
307 307
308 QPopupMenu *settings = new QPopupMenu( this ); 308 QPopupMenu *settings = new QPopupMenu( this );
309 tmp->insertItem( tr( "Settings" ), settings ); 309 tmp->insertItem( tr( "Settings" ), settings );
310 310
311// addToolBar(menubar, "Menus",QMainWindow::Top); 311// addToolBar(menubar, "Menus",QMainWindow::Top);
312// addToolBar(fileBar, "Toolbar",QMainWindow::Top); 312// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
313 313
314 // QPopupMenu *edit = new QPopupMenu( this ); 314 // QPopupMenu *edit = new QPopupMenu( this );
315 315
316 /* 316 /*
317 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 317 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
318 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 318 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
319 a->addTo( bar ); 319 a->addTo( bar );
320 a->addTo( file ); 320 a->addTo( file );
321 */ 321 */
322 322
323 editorStack = new QWidgetStack( this ); 323 editorStack = new QWidgetStack( this );
324 setCentralWidget( editorStack ); 324 setCentralWidget( editorStack );
325 325
326 searchVisible = FALSE; 326 searchVisible = FALSE;
327 regVisible = FALSE; 327 regVisible = FALSE;
328 m_fontVisible = false; 328 m_fontVisible = false;
329 329
330 m_annoWin = new CAnnoEdit(editorStack); 330 m_annoWin = new CAnnoEdit(editorStack);
331 editorStack->addWidget(m_annoWin, get_unique_id()); 331 editorStack->addWidget(m_annoWin, get_unique_id());
332 connect( m_annoWin, SIGNAL( finished(const QString&,const QString&) ), this, SLOT( addAnno(const QString&,const QString&) ) ); 332 connect( m_annoWin, SIGNAL( finished(const QString&,const QString&) ), this, SLOT( addAnno(const QString&,const QString&) ) );
333 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); 333 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
334 334
335 m_infoWin = new infowin(editorStack); 335 m_infoWin = new infowin(editorStack);
336 editorStack->addWidget(m_infoWin, get_unique_id()); 336 editorStack->addWidget(m_infoWin, get_unique_id());
337 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); 337 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
338 338
339 m_graphicwin = new GraphicWin(editorStack); 339 m_graphicwin = new GraphicWin(editorStack);
340 editorStack->addWidget(m_graphicwin, get_unique_id()); 340 editorStack->addWidget(m_graphicwin, get_unique_id());
341 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); 341 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
342 342
343// bkmkselector = new QListBox(editorStack, "Bookmarks"); 343// bkmkselector = new QListBox(editorStack, "Bookmarks");
344 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 344 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
345 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 345 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
346 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 346 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
347 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 347 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
348 editorStack->addWidget( bkmkselector, get_unique_id() ); 348 editorStack->addWidget( bkmkselector, get_unique_id() );
349 349
350/* 350/*
351 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 351 importSelector = new FileSelector( "*", editorStack, "importselector", false );
352 connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) ); 352 connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) );
353 353
354 editorStack->addWidget( importSelector, get_unique_id() ); 354 editorStack->addWidget( importSelector, get_unique_id() );
355 355
356 // don't need the close visible, it is redundant... 356 // don't need the close visible, it is redundant...
357 importSelector->setCloseVisible( FALSE ); 357 importSelector->setCloseVisible( FALSE );
358*/ 358*/
359// qDebug("Reading file list"); 359// qDebug("Reading file list");
360 readfilelist(); 360 readfilelist();
361 361
362 reader = new QTReader( editorStack ); 362 reader = new QTReader( editorStack );
363 363
364 reader->bDoUpdates = false; 364 reader->bDoUpdates = false;
365 365
366#ifdef USEQPE 366#ifdef USEQPE
367 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 367 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
368#endif 368#endif
369 369
370// qDebug("Reading config"); 370// qDebug("Reading config");
371// Config config( APPDIR ); 371// Config config( APPDIR );
372 config.setGroup( "View" ); 372 config.setGroup( "View" );
373 m_debounce = config.readNumEntry("Debounce", 0); 373 m_debounce = config.readNumEntry("Debounce", 0);
374#ifdef USEQPE 374#ifdef USEQPE
375 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); 375 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
376#else 376#else
377 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); 377 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
378#endif 378#endif
379 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 379 reader->bstripcr = config.readBoolEntry( "StripCr", true );
380 reader->bfulljust = config.readBoolEntry( "FullJust", false ); 380 reader->bfulljust = config.readBoolEntry( "FullJust", false );
381 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); 381 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
382 reader->setlead(config.readNumEntry( "ExtraLead", 0 )); 382 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
383 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 383 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
384 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 384 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
385 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 385 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
386 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 386 reader->bpeanut = config.readBoolEntry( "Peanut", false );
387 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 387 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
388 reader->bdepluck = config.readBoolEntry( "Depluck", false ); 388 reader->bdepluck = config.readBoolEntry( "Depluck", false );
389 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); 389 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
390 reader->bonespace = config.readBoolEntry( "OneSpace", false ); 390 reader->bonespace = config.readBoolEntry( "OneSpace", false );
391 reader->bunindent = config.readBoolEntry( "Unindent", false ); 391 reader->bunindent = config.readBoolEntry( "Unindent", false );
392 reader->brepara = config.readBoolEntry( "Repara", false ); 392 reader->brepara = config.readBoolEntry( "Repara", false );
393 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 393 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
394 reader->bindenter = config.readNumEntry( "Indent", 0 ); 394 reader->bindenter = config.readNumEntry( "Indent", 0 );
395 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 395 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
396 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 396 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
397 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 397 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
398 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 398 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
399 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 399 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
400 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 400 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
401 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); 401 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
402 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 402 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
403 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 403 reader->m_encd = config.readNumEntry( "Encoding", 0 );
404 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 404 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
405 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 405 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
406 reader->m_border = config.readNumEntry( "Margin", 6 ); 406 reader->m_border = config.readNumEntry( "Margin", 6 );
407#ifdef REPALM 407#ifdef REPALM
408 reader->brepalm = config.readBoolEntry( "Repalm", true ); 408 reader->brepalm = config.readBoolEntry( "Repalm", true );
409#endif 409#endif
410 reader->bremap = config.readBoolEntry( "Remap", true ); 410 reader->bremap = config.readBoolEntry( "Remap", true );
411 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 411 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
412 reader->setContinuous(config.readBoolEntry( "Continuous", true )); 412 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
413 m_targetapp = config.readEntry( "TargetApp", QString::null ); 413 m_targetapp = config.readEntry( "TargetApp", QString::null );
414 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 414 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
415#ifdef _SCROLLPIPE 415#ifdef _SCROLLPIPE
416 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); 416 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
417 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); 417 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
418#endif 418#endif
419 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 419 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
420 m_doAnnotation = config.readBoolEntry( "Annotation", false); 420 m_doAnnotation = config.readBoolEntry( "Annotation", false);
421 m_doDictionary = config.readBoolEntry( "Dictionary", false); 421 m_doDictionary = config.readBoolEntry( "Dictionary", false);
422 m_doClipboard = config.readBoolEntry( "Clipboard", false); 422 m_doClipboard = config.readBoolEntry( "Clipboard", false);
423 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 423 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
424 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); 424 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
425 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); 425 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
426 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); 426 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
427 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); 427 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
428 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); 428 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
429 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); 429 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
430 430
431 m_leftScroll = config.readBoolEntry("LeftScroll", false); 431 m_leftScroll = config.readBoolEntry("LeftScroll", false);
432 m_rightScroll = config.readBoolEntry("RightScroll", false); 432 m_rightScroll = config.readBoolEntry("RightScroll", false);
433 m_upScroll = config.readBoolEntry("UpScroll", true); 433 m_upScroll = config.readBoolEntry("UpScroll", true);
434 m_downScroll = config.readBoolEntry("DownScroll", true); 434 m_downScroll = config.readBoolEntry("DownScroll", true);
435 435
436 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); 436 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
437 reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); 437 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
438 438
439#ifndef USEQPE 439#ifndef USEQPE
440 config.setGroup( "Geometry" ); 440 config.setGroup( "Geometry" );
441 setGeometry(0,0, 441 setGeometry(0,0,
442 config.readNumEntry( "width", QApplication::desktop()->width()/2 ), 442 config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
443 config.readNumEntry( "height", QApplication::desktop()->height()/2 )); 443 config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
444 move( 444 move(
445 config.readNumEntry( "x", 20 ), 445 config.readNumEntry( "x", 20 ),
446 config.readNumEntry( "y", 20 )); 446 config.readNumEntry( "y", 20 ));
447#endif 447#endif
448 448
449 449
450 450
451 setTwoTouch(m_twoTouch); 451 setTwoTouch(m_twoTouch);
452 452
453 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); 453 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
454 454
455 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 455 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
456 connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) ); 456 connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) );
457 connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); 457 connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
458 editorStack->addWidget( reader, get_unique_id() ); 458 editorStack->addWidget( reader, get_unique_id() );
459 459
460 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); 460 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
461 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); 461 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
462 m_preferences_action->addTo( settings ); 462 m_preferences_action->addTo( settings );
463 463
464 m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); 464 m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
465 connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); 465 connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
466 m_saveconfig_action->addTo( settings ); 466 m_saveconfig_action->addTo( settings );
467 467
468 m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); 468 m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
469 connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); 469 connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
470 m_loadconfig_action->addTo( settings ); 470 m_loadconfig_action->addTo( settings );
471 471
472 m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); 472 m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
473 connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); 473 connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
474 m_tidyconfig_action->addTo( settings ); 474 m_tidyconfig_action->addTo( settings );
475 475
476 settings->insertSeparator(); 476 settings->insertSeparator();
477 m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); 477 m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
478 connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); 478 connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
479 m_toolbarprefs_action->addTo( settings ); 479 m_toolbarprefs_action->addTo( settings );
480 480
481 m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); 481 m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
482 connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 482 connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
483 m_open_action->addTo( file ); 483 m_open_action->addTo( file );
484 484
485 m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); 485 m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
486 connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); 486 connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
487 m_close_action->addTo( file ); 487 m_close_action->addTo( file );
488 488
489#ifdef _SCRIPT 489#ifdef _SCRIPT
490 a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); 490 a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
491 connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); 491 connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
492 a->addTo( file ); 492 a->addTo( file );
493#endif 493#endif
494 /* 494 /*
495 a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); 495 a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
496 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 496 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
497 a->addTo( file ); 497 a->addTo( file );
498 498
499 a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); 499 a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
500 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 500 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
501 a->addTo( filebar() ); 501 a->addTo( filebar() );
502 a->addTo( edit ); 502 a->addTo( edit );
503 */ 503 */
504 504
505 m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); 505 m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
506 connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); 506 connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
507 m_info_action->addTo( file ); 507 m_info_action->addTo( file );
508 508
509 m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); 509 m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
510 connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); 510 connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
511 m_touch_action->setOn(m_twoTouch); 511 m_touch_action->setOn(m_twoTouch);
512 m_touch_action->addTo( file ); 512 m_touch_action->addTo( file );
513 513
514 m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); 514 m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
515 connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); 515 connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
516 file->insertSeparator(); 516 file->insertSeparator();
517// a->addTo( bar ); 517// a->addTo( bar );
518 m_find_action->addTo( file ); 518 m_find_action->addTo( file );
519 519
520 m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); 520 m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
521 connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); 521 connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
522 m_exportlinks_action->addTo( file ); 522 m_exportlinks_action->addTo( file );
523 523
524 m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); 524 m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
525 connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 525 connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
526 m_scrollButton->addTo(navigation); 526 m_scrollButton->addTo(navigation);
527 m_scrollButton->setOn(false); 527 m_scrollButton->setOn(false);
528 528
529 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); 529 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
530 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); 530 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
531 m_start_action->addTo(navigation); 531 m_start_action->addTo(navigation);
532 532
533 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); 533 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
534 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); 534 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
535 m_end_action->addTo(navigation); 535 m_end_action->addTo(navigation);
536 536
537 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); 537 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
538 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); 538 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
539 m_jump_action->addTo(navigation); 539 m_jump_action->addTo(navigation);
540 540
541 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); 541 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
542 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 542 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
543 m_pageline_action->addTo(navigation); 543 m_pageline_action->addTo(navigation);
544 m_pageline_action->setOn(reader->m_bpagemode); 544 m_pageline_action->setOn(reader->m_bpagemode);
545 545
546 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); 546 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
547 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); 547 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
548 m_pageup_action->addTo( navigation ); 548 m_pageup_action->addTo( navigation );
549 549
550 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); 550 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
551 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 551 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
552 m_pagedn_action->addTo( navigation ); 552 m_pagedn_action->addTo( navigation );
553 553
554 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); 554 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
555 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); 555 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
556 m_back_action->addTo( navigation ); 556 m_back_action->addTo( navigation );
557 557
558 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); 558 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
559 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); 559 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
560 m_home_action->addTo( navigation ); 560 m_home_action->addTo( navigation );
561 561
562 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); 562 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
563 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); 563 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
564 m_forward_action->addTo( navigation ); 564 m_forward_action->addTo( navigation );
565 565
566 /* 566 /*
567 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 567 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
568 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 568 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
569 a->addTo( file ); 569 a->addTo( file );
570 570
571 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); 571 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
572 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 572 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
573 a->addTo( file ); 573 a->addTo( file );
574 */ 574 */
575 575
576// file->insertSeparator(); 576// file->insertSeparator();
577 577
578#ifdef _SCROLLPIPE 578#ifdef _SCROLLPIPE
579 579
580 QActionGroup* ag = new QActionGroup(this); 580 QActionGroup* ag = new QActionGroup(this);
581 ag->setExclusive(false); 581 ag->setExclusive(false);
582 spacemenu = new QPopupMenu(this); 582 spacemenu = new QPopupMenu(this);
583 file->insertItem( tr( "Scrolling" ), spacemenu ); 583 file->insertItem( tr( "Scrolling" ), spacemenu );
584 584
585 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); 585 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
586 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); 586 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
587 587
588 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); 588 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
589 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); 589 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
590 a->setOn(reader->m_pauseAfterEachPara); 590 a->setOn(reader->m_pauseAfterEachPara);
591 591
592 ag->addTo(spacemenu); 592 ag->addTo(spacemenu);
593// file->insertSeparator(); 593// file->insertSeparator();
594 594
595#endif 595#endif
596 596
597/* 597/*
598 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); 598 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
599 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); 599 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
600 a->addTo( file ); 600 a->addTo( file );
601*/ 601*/
602 602
603 /* 603 /*
604 a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); 604 a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
605 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 605 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
606 a->addTo( fileBar ); 606 a->addTo( fileBar );
607 a->addTo( edit ); 607 a->addTo( edit );
608 */ 608 */
609 609
610// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); 610// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
611 611
612 m_fullscreen = false; 612 m_fullscreen = false;
613 m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); 613 m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
614 connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); 614 connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
615 m_actFullscreen->setOn(m_fullscreen); 615 m_actFullscreen->setOn(m_fullscreen);
616 m_actFullscreen->addTo( view ); 616 m_actFullscreen->addTo( view );
617 617
618 view->insertSeparator(); 618 view->insertSeparator();
619 619
620 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); 620 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
621 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); 621 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
622 m_zoomin_action->addTo( view ); 622 m_zoomin_action->addTo( view );
623 623
624 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); 624 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
625 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); 625 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
626 m_zoomout_action->addTo( view ); 626 m_zoomout_action->addTo( view );
627 627
628 view->insertSeparator(); 628 view->insertSeparator();
629 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); 629 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
630 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); 630 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
631 m_setfont_action->addTo( view ); 631 m_setfont_action->addTo( view );
632 632
633 view->insertSeparator(); 633 view->insertSeparator();
634 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); 634 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
635 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); 635 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
636 m_setenc_action->addTo( view ); 636 m_setenc_action->addTo( view );
637 637
638 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); 638 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
639 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 639 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
640 m_setmono_action->addTo( view ); 640 m_setmono_action->addTo( view );
641 m_setmono_action->setOn(reader->m_bMonoSpaced); 641 m_setmono_action->setOn(reader->m_bMonoSpaced);
642 642
643 643
644 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); 644 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
645 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); 645 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
646 646
647 647
648 648
649 // a->addTo( filebar() ); 649 // a->addTo( filebar() );
650// view->insertSeparator(); 650// view->insertSeparator();
651 651
652/* 652/*
653 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 653 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
654 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 654 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
655 a->setOn(reader->m_bMonoSpaced); 655 a->setOn(reader->m_bMonoSpaced);
656 a->addTo( view ); 656 a->addTo( view );
657*/ 657*/
658/* 658/*
659 a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); 659 a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
660 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 660 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
661 a->addTo( view ); 661 a->addTo( view );
662*/ 662*/
663 663
664 m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); 664 m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
665 connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); 665 connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
666 m_mark_action->addTo( marks ); 666 m_mark_action->addTo( marks );
667 667
668 m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); 668 m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
669 connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); 669 connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
670 m_annotate_action->addTo( marks ); 670 m_annotate_action->addTo( marks );
671 671
672 m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); 672 m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
673 connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); 673 connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
674 m_goto_action->addTo( marks ); 674 m_goto_action->addTo( marks );
675 675
676 m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); 676 m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
677 connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); 677 connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
678 m_delete_action->addTo( marks ); 678 m_delete_action->addTo( marks );
679 679
680 m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); 680 m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
681 connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); 681 connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
682 marks->insertSeparator(); 682 marks->insertSeparator();
683 m_autogen_action->addTo( marks ); 683 m_autogen_action->addTo( marks );
684 684
685 m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); 685 m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
686 connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); 686 connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
687 m_clear_action->addTo( marks ); 687 m_clear_action->addTo( marks );
688 688
689 m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); 689 m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
690 connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); 690 connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
691 m_save_action->addTo( marks ); 691 m_save_action->addTo( marks );
692 692
693 m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); 693 m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
694 connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); 694 connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
695 marks->insertSeparator(); 695 marks->insertSeparator();
696 m_tidy_action->addTo( marks ); 696 m_tidy_action->addTo( marks );
697 697
698 m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); 698 m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
699 connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); 699 connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
700 marks->insertSeparator(); 700 marks->insertSeparator();
701 m_startBlock_action->addTo( marks ); 701 m_startBlock_action->addTo( marks );
702 702
703 m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); 703 m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
704 connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 704 connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
705 m_endBlock_action->addTo( marks ); 705 m_endBlock_action->addTo( marks );
706 706
707 m_bkmkAvail = NULL; 707 m_bkmkAvail = NULL;
708 708
709 709
710 setToolBarsMovable(m_tbmove); 710 setToolBarsMovable(m_tbmove);
711 addtoolbars(&config); 711 addtoolbars(&config);
712 712
713 pbar = new QProgressBar(this); 713 pbar = new QProgressBar(this);
714 pbar->hide(); 714 pbar->hide();
715 715
716 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 716 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
717 717
718 searchBar->setHorizontalStretchable( TRUE ); 718 searchBar->setHorizontalStretchable( TRUE );
719 719
720 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 720 connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
721 721
722 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 722 searchEdit = new QLineEdit( searchBar, "searchEdit" );
723// QFont f("unifont", 16 /*, QFont::Bold*/); 723// QFont f("unifont", 16 /*, QFont::Bold*/);
724// searchEdit->setFont( f ); 724// searchEdit->setFont( f );
725 searchBar->setStretchableWidget( searchEdit ); 725 searchBar->setStretchableWidget( searchEdit );
726 726
727 727
728#ifdef __ISEARCH 728#ifdef __ISEARCH
729 connect( searchEdit, SIGNAL( textChanged(const QString&) ), 729 connect( searchEdit, SIGNAL( textChanged(const QString&) ),
730 this, SLOT( search(const QString&) ) ); 730 this, SLOT( search(const QString&) ) );
731#else 731#else
732 connect( searchEdit, SIGNAL( returnPressed() ), 732 connect( searchEdit, SIGNAL( returnPressed() ),
733 this, SLOT( search() ) ); 733 this, SLOT( search() ) );
734#endif 734#endif
735 QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); 735 QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
736 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 736 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
737 a->addTo( searchBar ); 737 a->addTo( searchBar );
738 738
739 a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); 739 a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
740 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 740 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
741 a->addTo( searchBar ); 741 a->addTo( searchBar );
742 742
743 searchBar->hide(); 743 searchBar->hide();
744 744
745 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); 745 regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
746 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); 746 connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
747 747
748 regBar->setHorizontalStretchable( TRUE ); 748 regBar->setHorizontalStretchable( TRUE );
749 749
750 regEdit = new QLineEdit( regBar, "regEdit" ); 750 regEdit = new QLineEdit( regBar, "regEdit" );
751// regEdit->setFont( f ); 751// regEdit->setFont( f );
752 752
753 regBar->setStretchableWidget( regEdit ); 753 regBar->setStretchableWidget( regEdit );
754 754
755 connect( regEdit, SIGNAL( returnPressed() ), 755 connect( regEdit, SIGNAL( returnPressed() ),
756 this, SLOT( do_regaction() ) ); 756 this, SLOT( do_regaction() ) );
757 757
758 a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); 758 a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
759 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 759 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
760 a->addTo( regBar ); 760 a->addTo( regBar );
761 761
762 a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); 762 a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
763 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 763 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
764 a->addTo( regBar ); 764 a->addTo( regBar );
765 765
766 regBar->hide(); 766 regBar->hide();
767 767
768 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); 768 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
769 769
770 m_fontBar->setHorizontalStretchable( TRUE ); 770 m_fontBar->setHorizontalStretchable( TRUE );
771 771
772// qDebug("Font selector"); 772// qDebug("Font selector");
773 m_fontSelector = new QComboBox(false, m_fontBar); 773 m_fontSelector = new QComboBox(false, m_fontBar);
774 m_fontBar->setStretchableWidget( m_fontSelector ); 774 m_fontBar->setStretchableWidget( m_fontSelector );
775 { 775 {
776#ifndef USEQPE 776#ifndef USEQPE
777 QFontDatabase f; 777 QFontDatabase f;
778#else 778#else
779 FontDatabase f; 779 FontDatabase f;
780#endif 780#endif
781 QStringList flist = f.families(); 781 QStringList flist = f.families();
782 bool realfont = false; 782 bool realfont = false;
783 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 783 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
784 { 784 {
785 if (reader->m_fontname == *nm) 785 if (reader->m_fontname == *nm)
786 { 786 {
787 realfont = true; 787 realfont = true;
788 } 788 }
789 if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); 789 if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
790 } 790 }
791 if (!realfont) reader->m_fontname = flist[0]; 791 if (!realfont) reader->m_fontname = flist[0];
792 } // delete the FontDatabase!!! 792 } // delete the FontDatabase!!!
793 connect( m_fontSelector, SIGNAL( activated(const QString&) ), 793 connect( m_fontSelector, SIGNAL( activated(const QString&) ),
794 this, SLOT( do_setfont(const QString&) ) ); 794 this, SLOT( do_setfont(const QString&) ) );
795 connect( m_fontSelector, SIGNAL( activated(int) ), 795 connect( m_fontSelector, SIGNAL( activated(int) ),
796 this, SLOT( do_setencoding(int) ) ); 796 this, SLOT( do_setencoding(int) ) );
797 797
798 m_fontBar->hide(); 798 m_fontBar->hide();
799 m_fontVisible = false; 799 m_fontVisible = false;
800#ifdef USEMSGS 800#ifdef USEMSGS
801 connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 801 connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
802 this, SLOT( msgHandler(const QCString&,const QByteArray&) ) ); 802 this, SLOT( msgHandler(const QCString&,const QByteArray&) ) );
803#endif 803#endif
804// qDebug("Initing"); 804// qDebug("Initing");
805 reader->init(); 805 reader->init();
806// qDebug("Inited"); 806// qDebug("Inited");
807// m_buttonAction[m_spaceTarget]->setOn(true); 807// m_buttonAction[m_spaceTarget]->setOn(true);
808// qDebug("fonting"); 808// qDebug("fonting");
809 do_setfont(reader->m_fontname); 809 do_setfont(reader->m_fontname);
810 if (!reader->m_lastfile.isEmpty()) 810 if (!reader->m_lastfile.isEmpty())
811 { 811 {
812 //qDebug("doclnk"); 812 //qDebug("doclnk");
813 //doc = new DocLnk(reader->m_lastfile); 813 //doc = new DocLnk(reader->m_lastfile);
814 //qDebug("doclnk done"); 814 //qDebug("doclnk done");
815 if (pOpenlist != NULL) 815 if (pOpenlist != NULL)
816 { 816 {
817 817
818/* 818/*
819 int ind = 0; 819 int ind = 0;
820 Bkmk* p = (*pOpenlist)[ind]; 820 Bkmk* p = (*pOpenlist)[ind];
821 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 821 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
822 { 822 {
823 p = (*pOpenlist)[++ind]; 823 p = (*pOpenlist)[++ind];
824 } 824 }
825*/ 825*/
826 Bkmk* p = NULL; 826 Bkmk* p = NULL;
827 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 827 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
828 { 828 {
829 p = iter.pContent(); 829 p = iter.pContent();
830 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) 830 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
831 { 831 {
832 break; 832 break;
833 } 833 }
834 // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); 834 // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
835 p = NULL; 835 p = NULL;
836 } 836 }
837 if (p != NULL) 837 if (p != NULL)
838 { 838 {
839 //qDebug("openfrombkmk"); 839 //qDebug("openfrombkmk");
840 if (!openfrombkmk(p)) 840 if (!openfrombkmk(p))
841 showEditTools(); 841 showEditTools();
842 } 842 }
843 else 843 else
844 { 844 {
845 //qDebug("openfile"); 845 //qDebug("openfile");
846 openFile( reader->m_lastfile ); 846 openFile( reader->m_lastfile );
847 } 847 }
848 } 848 }
849 else 849 else
850 { 850 {
851 // qDebug("Openfile 2"); 851 // qDebug("Openfile 2");
852 if (!reader->m_lastfile.isEmpty()) 852 if (!reader->m_lastfile.isEmpty())
853 openFile( reader->m_lastfile ); 853 openFile( reader->m_lastfile );
854 } 854 }
855 } 855 }
856 else 856 else
857 { 857 {
858 showEditTools(); 858 showEditTools();
859 } 859 }
860// qApp->processEvents(); 860// qApp->processEvents();
861 reader->bDoUpdates = true; 861 reader->bDoUpdates = true;
862 reader->update(); 862 reader->update();
863 config.setGroup("Version"); 863 config.setGroup("Version");
864 int major = config.readNumEntry("Major", 0); 864 int major = config.readNumEntry("Major", 0);
865 int bkmktype = config.readNumEntry("BkmkType", 0); 865 int bkmktype = config.readNumEntry("BkmkType", 0);
866 char minor = config.readNumEntry("Minor", 0); 866 char minor = config.readNumEntry("Minor", 0);
867 if (CheckVersion(major, bkmktype, minor)) 867 if (CheckVersion(major, bkmktype, minor))
868 { 868 {
869 config.writeEntry("Major", major); 869 config.writeEntry("Major", major);
870 config.writeEntry("BkmkType", bkmktype); 870 config.writeEntry("BkmkType", bkmktype);
871 config.writeEntry("Minor", (int)minor); 871 config.writeEntry("Minor", (int)minor);
872 } 872 }
873// qDebug("finished update"); 873// qDebug("finished update");
874} 874}
875 875
876void QTReaderApp::addtoolbars(Config* config) 876void QTReaderApp::addtoolbars(Config* config)
877{ 877{
878 config->setGroup("Toolbar"); 878 config->setGroup("Toolbar");
879 879
880 if (fileBar != NULL) 880 if (fileBar != NULL)
881 { 881 {
882 if (fileBar != menubar) 882 if (fileBar != menubar)
883 { 883 {
884 fileBar->clear(); 884 fileBar->clear();
885 } 885 }
886 else 886 else
887 { 887 {
888 m_preferences_action->removeFrom( filebar() ); 888 m_preferences_action->removeFrom( filebar() );
889 m_open_action->removeFrom( filebar() ); 889 m_open_action->removeFrom( filebar() );
890 m_close_action->removeFrom( filebar() ); 890 m_close_action->removeFrom( filebar() );
891 m_info_action->removeFrom( filebar() ); 891 m_info_action->removeFrom( filebar() );
892 m_touch_action->removeFrom( filebar() ); 892 m_touch_action->removeFrom( filebar() );
893 m_find_action->removeFrom( filebar() ); 893 m_find_action->removeFrom( filebar() );
894 } 894 }
895 } 895 }
896 896
897 m_preferences_action->addTo( filebar() ); 897 m_preferences_action->addTo( filebar() );
898 addfilebar(config, "Open", m_open_action); 898 addfilebar(config, "Open", m_open_action);
899 addfilebar(config, "Close", m_close_action); 899 addfilebar(config, "Close", m_close_action);
900 addfilebar(config, "Info", m_info_action); 900 addfilebar(config, "Info", m_info_action);
901 addfilebar(config, "Two/One Touch", m_touch_action); 901 addfilebar(config, "Two/One Touch", m_touch_action);
902 addfilebar(config, "Find", m_find_action); 902 addfilebar(config, "Find", m_find_action);
903 903
904 if (navBar != NULL) 904 if (navBar != NULL)
905 { 905 {
906 if ((navBar == fileBar) && (fileBar == menubar)) 906 if ((navBar == fileBar) && (fileBar == menubar))
907 { 907 {
908 m_scrollButton->removeFrom( navbar() ); 908 m_scrollButton->removeFrom( navbar() );
909 m_start_action->removeFrom( navbar() ); 909 m_start_action->removeFrom( navbar() );
910 m_end_action->removeFrom( navbar() ); 910 m_end_action->removeFrom( navbar() );
911 m_jump_action->removeFrom( navbar() ); 911 m_jump_action->removeFrom( navbar() );
912 m_pageline_action->removeFrom( navbar() ); 912 m_pageline_action->removeFrom( navbar() );
913 m_pageup_action->removeFrom( navbar() ); 913 m_pageup_action->removeFrom( navbar() );
914 m_pagedn_action->removeFrom( navbar() ); 914 m_pagedn_action->removeFrom( navbar() );
915 m_back_action->removeFrom( navbar() ); 915 m_back_action->removeFrom( navbar() );
916 m_home_action->removeFrom( navbar() ); 916 m_home_action->removeFrom( navbar() );
917 m_forward_action->removeFrom( navbar() ); 917 m_forward_action->removeFrom( navbar() );
918 } 918 }
919 else if (navBar != fileBar) 919 else if (navBar != fileBar)
920 { 920 {
921 navBar->clear(); 921 navBar->clear();
922 } 922 }
923 } 923 }
924 924
925 addnavbar(config, "Scroll", m_scrollButton); 925 addnavbar(config, "Scroll", m_scrollButton);
926 addnavbar(config, "Goto Start", m_start_action); 926 addnavbar(config, "Goto Start", m_start_action);
927 addnavbar(config, "Goto End", m_end_action); 927 addnavbar(config, "Goto End", m_end_action);
928 928
929 addnavbar(config, "Jump", m_jump_action); 929 addnavbar(config, "Jump", m_jump_action);
930 addnavbar(config, "Page/Line Scroll", m_pageline_action); 930 addnavbar(config, "Page/Line Scroll", m_pageline_action);
931 931
932 addnavbar(config, "Page Up", m_pageup_action); 932 addnavbar(config, "Page Up", m_pageup_action);
933 addnavbar(config, "Page Down", m_pagedn_action); 933 addnavbar(config, "Page Down", m_pagedn_action);
934 934
935 addnavbar(config, "Back", m_back_action); 935 addnavbar(config, "Back", m_back_action);
936 addnavbar(config, "Home", m_home_action); 936 addnavbar(config, "Home", m_home_action);
937 addnavbar(config, "Forward", m_forward_action); 937 addnavbar(config, "Forward", m_forward_action);
938 938
939 if (viewBar != NULL) 939 if (viewBar != NULL)
940 { 940 {
941 if ((viewBar == fileBar) && (fileBar == menubar)) 941 if ((viewBar == fileBar) && (fileBar == menubar))
942 { 942 {
943 m_actFullscreen->removeFrom( filebar() ); 943 m_actFullscreen->removeFrom( filebar() );
944 m_zoomin_action->removeFrom( viewbar() ); 944 m_zoomin_action->removeFrom( viewbar() );
945 m_zoomout_action->removeFrom( viewbar() ); 945 m_zoomout_action->removeFrom( viewbar() );
946 m_setfont_action->removeFrom( viewbar() ); 946 m_setfont_action->removeFrom( viewbar() );
947 m_setenc_action->removeFrom( viewbar() ); 947 m_setenc_action->removeFrom( viewbar() );
948 m_setmono_action->removeFrom( viewbar() ); 948 m_setmono_action->removeFrom( viewbar() );
949 } 949 }
950 else if (viewBar != fileBar) 950 else if (viewBar != fileBar)
951 { 951 {
952 viewBar->clear(); 952 viewBar->clear();
953 } 953 }
954 } 954 }
955 955
956 addviewbar(config, "Fullscreen", m_actFullscreen); 956 addviewbar(config, "Fullscreen", m_actFullscreen);
957 addviewbar(config, "Zoom In", m_zoomin_action); 957 addviewbar(config, "Zoom In", m_zoomin_action);
958 addviewbar(config, "Zoom Out", m_zoomout_action); 958 addviewbar(config, "Zoom Out", m_zoomout_action);
959 addviewbar(config, "Set Font", m_setfont_action); 959 addviewbar(config, "Set Font", m_setfont_action);
960 addviewbar(config, "Encoding Select", m_setenc_action); 960 addviewbar(config, "Encoding Select", m_setenc_action);
961 addviewbar(config, "Ideogram Mode", m_setmono_action); 961 addviewbar(config, "Ideogram Mode", m_setmono_action);
962 962
963 if (markBar != NULL) 963 if (markBar != NULL)
964 { 964 {
965 if ((markBar == fileBar) && (fileBar == menubar)) 965 if ((markBar == fileBar) && (fileBar == menubar))
966 { 966 {
967 m_mark_action->removeFrom( markbar() ); 967 m_mark_action->removeFrom( markbar() );
968 m_annotate_action->removeFrom( markbar()); 968 m_annotate_action->removeFrom( markbar());
969 m_goto_action->removeFrom( markbar() ); 969 m_goto_action->removeFrom( markbar() );
970 m_delete_action->removeFrom( markbar() ); 970 m_delete_action->removeFrom( markbar() );
971 m_autogen_action->removeFrom( markbar() ); 971 m_autogen_action->removeFrom( markbar() );
972 m_clear_action->removeFrom( markbar() ); 972 m_clear_action->removeFrom( markbar() );
973 m_save_action->removeFrom( markbar() ); 973 m_save_action->removeFrom( markbar() );
974 m_tidy_action->removeFrom( markbar() ); 974 m_tidy_action->removeFrom( markbar() );
975 m_startBlock_action->removeFrom( markbar() ); 975 m_startBlock_action->removeFrom( markbar() );
976 m_endBlock_action->removeFrom( markbar() ); 976 m_endBlock_action->removeFrom( markbar() );
977 } 977 }
978 else if (markBar != fileBar) 978 else if (markBar != fileBar)
979 { 979 {
980 markBar->clear(); 980 markBar->clear();
981 } 981 }
982 } 982 }
983 addmarkbar(config, "Mark", m_mark_action); 983 addmarkbar(config, "Mark", m_mark_action);
984 addmarkbar(config, "Annotate", m_annotate_action); 984 addmarkbar(config, "Annotate", m_annotate_action);
985 addmarkbar(config, "Goto", m_goto_action); 985 addmarkbar(config, "Goto", m_goto_action);
986 addmarkbar(config, "Delete", m_delete_action); 986 addmarkbar(config, "Delete", m_delete_action);
987 addmarkbar(config, "Autogen", m_autogen_action); 987 addmarkbar(config, "Autogen", m_autogen_action);
988 addmarkbar(config, "Clear", m_clear_action); 988 addmarkbar(config, "Clear", m_clear_action);
989 addmarkbar(config, "Save", m_save_action); 989 addmarkbar(config, "Save", m_save_action);
990 addmarkbar(config, "Tidy", m_tidy_action); 990 addmarkbar(config, "Tidy", m_tidy_action);
991 addmarkbar(config, "Start Block", m_startBlock_action); 991 addmarkbar(config, "Start Block", m_startBlock_action);
992 addmarkbar(config, "Copy Block", m_endBlock_action); 992 addmarkbar(config, "Copy Block", m_endBlock_action);
993 if (checkbar(config, "Annotation indicator")) 993 if (checkbar(config, "Annotation indicator"))
994 { 994 {
995 if (m_bkmkAvail == NULL) 995 if (m_bkmkAvail == NULL)
996 { 996 {
997 m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); 997 m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 );
998 connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 998 connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
999 999
1000 m_bkmkAvail->setEnabled(false); 1000 m_bkmkAvail->setEnabled(false);
1001 } 1001 }
1002 QLabel *spacer = new QLabel(markBar, ""); 1002 QLabel *spacer = new QLabel(markBar, "");
1003 markbar()->setStretchableWidget(spacer); 1003 markbar()->setStretchableWidget(spacer);
1004 m_bkmkAvail->removeFrom( markbar() ); 1004 m_bkmkAvail->removeFrom( markbar() );
1005 m_bkmkAvail->addTo( markbar() ); 1005 m_bkmkAvail->addTo( markbar() );
1006 } 1006 }
1007 else 1007 else
1008 { 1008 {
1009 if (m_bkmkAvail != NULL) 1009 if (m_bkmkAvail != NULL)
1010 { 1010 {
1011 m_bkmkAvail->removeFrom( markbar() ); 1011 m_bkmkAvail->removeFrom( markbar() );
1012 delete m_bkmkAvail; 1012 delete m_bkmkAvail;
1013 m_bkmkAvail = NULL; 1013 m_bkmkAvail = NULL;
1014 } 1014 }
1015 } 1015 }
1016} 1016}
1017 1017
1018bool QTReaderApp::checkbar(Config* _config, const QString& key) 1018bool QTReaderApp::checkbar(Config* _config, const QString& key)
1019{ 1019{
1020 return _config->readBoolEntry(key, false); 1020 return _config->readBoolEntry(key, false);
1021} 1021}
1022 1022
1023 1023
1024QToolBar* QTReaderApp::filebar() 1024QToolBar* QTReaderApp::filebar()
1025{ 1025{
1026 if (fileBar == NULL) 1026 if (fileBar == NULL)
1027 { 1027 {
1028 switch (m_tbpol) 1028 switch (m_tbpol)
1029 { 1029 {
1030 case cesSingle: 1030 case cesSingle:
1031 // qDebug("Setting filebar to menubar"); 1031 // qDebug("Setting filebar to menubar");
1032 fileBar = menubar; 1032 fileBar = menubar;
1033 break; 1033 break;
1034 default: 1034 default:
1035 qDebug("Incorrect toolbar policy set"); 1035 qDebug("Incorrect toolbar policy set");
1036 case cesMenuTool: 1036 case cesMenuTool:
1037 case cesMultiple: 1037 case cesMultiple:
1038 // qDebug("Creating new file bar"); 1038 // qDebug("Creating new file bar");
1039 fileBar = new QToolBar("File", this, m_tbposition); 1039 fileBar = new QToolBar("File", this, m_tbposition);
1040 break; 1040 break;
1041 } 1041 }
1042 //fileBar->setHorizontalStretchable( true ); 1042 //fileBar->setHorizontalStretchable( true );
1043 } 1043 }
1044 return fileBar; 1044 return fileBar;
1045} 1045}
1046QToolBar* QTReaderApp::viewbar() 1046QToolBar* QTReaderApp::viewbar()
1047{ 1047{
1048 if (viewBar == NULL) 1048 if (viewBar == NULL)
1049 { 1049 {
1050 switch (m_tbpol) 1050 switch (m_tbpol)
1051 { 1051 {
1052 case cesMultiple: 1052 case cesMultiple:
1053 viewBar = new QToolBar("View", this, m_tbposition); 1053 viewBar = new QToolBar("View", this, m_tbposition);
1054 break; 1054 break;
1055 default: 1055 default:
1056 qDebug("Incorrect toolbar policy set"); 1056 qDebug("Incorrect toolbar policy set");
1057 case cesSingle: 1057 case cesSingle:
1058 case cesMenuTool: 1058 case cesMenuTool:
1059 viewBar = fileBar; 1059 viewBar = fileBar;
1060 break; 1060 break;
1061 } 1061 }
1062 } 1062 }
1063 return viewBar; 1063 return viewBar;
1064} 1064}
1065QToolBar* QTReaderApp::navbar() 1065QToolBar* QTReaderApp::navbar()
1066{ 1066{
1067 if (navBar == NULL) 1067 if (navBar == NULL)
1068 { 1068 {
1069 switch (m_tbpol) 1069 switch (m_tbpol)
1070 { 1070 {
1071 case cesMultiple: 1071 case cesMultiple:
1072 // qDebug("Creating new nav bar"); 1072 // qDebug("Creating new nav bar");
1073 navBar = new QToolBar("Navigation", this, m_tbposition); 1073 navBar = new QToolBar("Navigation", this, m_tbposition);
1074 break; 1074 break;
1075 default: 1075 default:
1076 qDebug("Incorrect toolbar policy set"); 1076 qDebug("Incorrect toolbar policy set");
1077 case cesSingle: 1077 case cesSingle:
1078 case cesMenuTool: 1078 case cesMenuTool:
1079 navBar = fileBar; 1079 navBar = fileBar;
1080 // qDebug("Setting navbar to filebar"); 1080 // qDebug("Setting navbar to filebar");
1081 break; 1081 break;
1082 } 1082 }
1083 } 1083 }
1084 return navBar; 1084 return navBar;
1085} 1085}
1086QToolBar* QTReaderApp::markbar() 1086QToolBar* QTReaderApp::markbar()
1087{ 1087{
1088 if (markBar == NULL) 1088 if (markBar == NULL)
1089 { 1089 {
1090 switch (m_tbpol) 1090 switch (m_tbpol)
1091 { 1091 {
1092 case cesMultiple: 1092 case cesMultiple:
1093 markBar = new QToolBar("Marks", this, m_tbposition); 1093 markBar = new QToolBar("Marks", this, m_tbposition);
1094 break; 1094 break;
1095 default: 1095 default:
1096 qDebug("Incorrect toolbar policy set"); 1096 qDebug("Incorrect toolbar policy set");
1097 case cesSingle: 1097 case cesSingle:
1098 case cesMenuTool: 1098 case cesMenuTool:
1099 markBar = fileBar; 1099 markBar = fileBar;
1100 break; 1100 break;
1101 } 1101 }
1102 } 1102 }
1103 return markBar; 1103 return markBar;
1104} 1104}
1105 1105
1106void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) 1106void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a)
1107{ 1107{
1108 if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); 1108 if (_config->readBoolEntry(key, false)) a->addTo( filebar() );
1109} 1109}
1110void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) 1110void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a)
1111{ 1111{
1112 if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); 1112 if (_config->readBoolEntry(key, false)) a->addTo( navbar() );
1113} 1113}
1114void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) 1114void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a)
1115{ 1115{
1116 if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); 1116 if (_config->readBoolEntry(key, false)) a->addTo( markbar() );
1117} 1117}
1118void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) 1118void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a)
1119{ 1119{
1120 if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); 1120 if (_config->readBoolEntry(key, false)) a->addTo( viewbar() );
1121} 1121}
1122 1122
1123void QTReaderApp::suspend() { reader->suspend(); } 1123void QTReaderApp::suspend() { reader->suspend(); }
1124 1124
1125#ifdef USEMSGS 1125#ifdef USEMSGS
1126void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 1126void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
1127{ 1127{
1128 QString msg = QString::fromUtf8(_msg); 1128 QString msg = QString::fromUtf8(_msg);
1129 1129
1130//// qDebug("Received:%s", (const char*)msg); 1130//// qDebug("Received:%s", (const char*)msg);
1131 1131
1132 QDataStream stream( _data, IO_ReadOnly ); 1132 QDataStream stream( _data, IO_ReadOnly );
1133 if ( msg == "info(QString)" ) 1133 if ( msg == "info(QString)" )
1134 { 1134 {
1135 QString info; 1135 QString info;
1136 stream >> info; 1136 stream >> info;
1137 QMessageBox::information(this, PROGNAME, info); 1137 QMessageBox::information(this, PROGNAME, info);
1138 } 1138 }
1139 else if ( msg == "Update(int)" ) 1139 else if ( msg == "Update(int)" )
1140 { 1140 {
1141 int info; 1141 int info;
1142 stream >> info; 1142 stream >> info;
1143 if (info) 1143 if (info)
1144 { 1144 {
1145 reader->bDoUpdates = true; 1145 reader->bDoUpdates = true;
1146 reader->refresh(); 1146 reader->refresh();
1147 } 1147 }
1148 else 1148 else
1149 { 1149 {
1150 reader->bDoUpdates = false; 1150 reader->bDoUpdates = false;
1151 } 1151 }
1152 } 1152 }
1153 else if ( msg == "warn(QString)" ) 1153 else if ( msg == "warn(QString)" )
1154 { 1154 {
1155 QString info; 1155 QString info;
1156 stream >> info; 1156 stream >> info;
1157 QMessageBox::warning(this, PROGNAME, info); 1157 QMessageBox::warning(this, PROGNAME, info);
1158 } 1158 }
1159 else if ( msg == "exit()" ) 1159 else if ( msg == "exit()" )
1160 { 1160 {
1161 m_dontSave = true; 1161 m_dontSave = true;
1162 close(); 1162 close();
1163 } 1163 }
1164 else if ( msg == "pageDown()" ) 1164 else if ( msg == "pageDown()" )
1165 { 1165 {
1166 reader->dopagedn(); 1166 reader->dopagedn();
1167 } 1167 }
1168 else if ( msg == "pageUp()" ) 1168 else if ( msg == "pageUp()" )
1169 { 1169 {
1170 reader->dopageup(); 1170 reader->dopageup();
1171 } 1171 }
1172 else if ( msg == "lineDown()" ) 1172 else if ( msg == "lineDown()" )
1173 { 1173 {
1174 reader->lineDown(); 1174 reader->lineDown();
1175 } 1175 }
1176 else if ( msg == "lineUp()" ) 1176 else if ( msg == "lineUp()" )
1177 { 1177 {
1178 reader->lineUp(); 1178 reader->lineUp();
1179 } 1179 }
1180 else if ( msg == "showText()" ) 1180 else if ( msg == "showText()" )
1181 { 1181 {
1182 showEditTools(); 1182 showEditTools();
1183 } 1183 }
1184 else if ( msg == "home()" ) 1184 else if ( msg == "home()" )
1185 { 1185 {
1186 reader->goHome(); 1186 reader->goHome();
1187 } 1187 }
1188 else if ( msg == "back()" ) 1188 else if ( msg == "back()" )
1189 { 1189 {
1190 reader->goBack(); 1190 reader->goBack();
1191 } 1191 }
1192 else if ( msg == "forward()" ) 1192 else if ( msg == "forward()" )
1193 { 1193 {
1194 reader->goForward(); 1194 reader->goForward();
1195 } 1195 }
1196 else if ( msg == "File/Open(QString)" ) 1196 else if ( msg == "File/Open(QString)" )
1197 { 1197 {
1198 QString info; 1198 QString info;
1199 stream >> info; 1199 stream >> info;
1200 openFile( info ); 1200 openFile( info );
1201 } 1201 }
1202 else if ( msg == "File/Info()" ) 1202 else if ( msg == "File/Info()" )
1203 { 1203 {
1204 showinfo(); 1204 showinfo();
1205 } 1205 }
1206 else if ( msg == "File/Action(QString)" ) 1206 else if ( msg == "File/Action(QString)" )
1207 { 1207 {
1208 QString info; 1208 QString info;
1209 stream >> info; 1209 stream >> info;
1210 m_spaceTarget = ActNameToInt(info); 1210 m_spaceTarget = ActNameToInt(info);
1211 } 1211 }
1212 else if ( msg == "Navigation/Scroll(int)" ) 1212 else if ( msg == "Navigation/Scroll(int)" )
1213 { 1213 {
1214 int info; 1214 int info;
1215 stream >> info; 1215 stream >> info;
1216 autoScroll(info); 1216 autoScroll(info);
1217 } 1217 }
1218 1218
1219 else if ( msg == "Navigation/GotoStart()" ) 1219 else if ( msg == "Navigation/GotoStart()" )
1220 { 1220 {
1221 gotoStart(); 1221 gotoStart();
1222 } 1222 }
1223 else if ( msg == "Navigation/GotoEnd()" ) 1223 else if ( msg == "Navigation/GotoEnd()" )
1224 { 1224 {
1225 gotoEnd(); 1225 gotoEnd();
1226 } 1226 }
1227 else if ( msg == "Navigation/Jump(int)" ) 1227 else if ( msg == "Navigation/Jump(int)" )
1228 { 1228 {
1229 int info; 1229 int info;
1230 stream >> info; 1230 stream >> info;
1231 reader->locate(info); 1231 reader->locate(info);
1232 } 1232 }
1233 else if ( msg == "Navigation/Page/LineScroll(int)" ) 1233 else if ( msg == "Navigation/Page/LineScroll(int)" )
1234 { 1234 {
1235 int info; 1235 int info;
1236 stream >> info; 1236 stream >> info;
1237 pagemode(info); 1237 pagemode(info);
1238 } 1238 }
1239 else if ( msg == "Navigation/SetOverlap(int)" ) 1239 else if ( msg == "Navigation/SetOverlap(int)" )
1240 { 1240 {
1241 int info; 1241 int info;
1242 stream >> info; 1242 stream >> info;
1243 reader->m_overlap = info; 1243 reader->m_overlap = info;
1244 } 1244 }
1245 else if ( msg == "Navigation/SetMargin(int)" ) 1245 else if ( msg == "Navigation/SetMargin(int)" )
1246 { 1246 {
1247 int info; 1247 int info;
1248 stream >> info; 1248 stream >> info;
1249 do_margin(info); 1249 do_margin(info);
1250 } 1250 }
1251 else if ( msg == "File/SetDictionary(QString)" ) 1251 else if ( msg == "File/SetDictionary(QString)" )
1252 { 1252 {
1253 QString info; 1253 QString info;
1254 stream >> info; 1254 stream >> info;
1255 do_settarget(info); 1255 do_settarget(info);
1256 } 1256 }
1257#ifdef _SCROLLPIPE 1257#ifdef _SCROLLPIPE
1258 else if ( msg == "File/SetScrollTarget(QString)" ) 1258 else if ( msg == "File/SetScrollTarget(QString)" )
1259 { 1259 {
1260 QString info; 1260 QString info;
1261 stream >> info; 1261 stream >> info;
1262 reader->m_pipetarget = info; 1262 reader->m_pipetarget = info;
1263 } 1263 }
1264#endif 1264#endif
1265 else if ( msg == "File/Two/OneTouch(int)" ) 1265 else if ( msg == "File/Two/OneTouch(int)" )
1266 { 1266 {
1267 int info; 1267 int info;
1268 stream >> info; 1268 stream >> info;
1269 setTwoTouch(info); 1269 setTwoTouch(info);
1270 } 1270 }
1271 else if ( msg == "Target/Annotation(int)" ) 1271 else if ( msg == "Target/Annotation(int)" )
1272 { 1272 {
1273 int info; 1273 int info;
1274 stream >> info; 1274 stream >> info;
1275 OnAnnotation(info); 1275 OnAnnotation(info);
1276 } 1276 }
1277 else if ( msg == "Target/Dictionary(int)" ) 1277 else if ( msg == "Target/Dictionary(int)" )
1278 { 1278 {
1279 int info; 1279 int info;
1280 stream >> info; 1280 stream >> info;
1281 OnDictionary(info); 1281 OnDictionary(info);
1282 } 1282 }
1283 else if ( msg == "Target/Clipboard(int)" ) 1283 else if ( msg == "Target/Clipboard(int)" )
1284 { 1284 {
1285 int info; 1285 int info;
1286 stream >> info; 1286 stream >> info;
1287 OnClipboard(info); 1287 OnClipboard(info);
1288 } 1288 }
1289 else if ( msg == "File/Find(QString)" ) 1289 else if ( msg == "File/Find(QString)" )
1290 { 1290 {
1291 QString info; 1291 QString info;
1292 stream >> info; 1292 stream >> info;
1293 QRegExp arg(info); 1293 QRegExp arg(info);
1294 size_t pos = reader->pagelocate(); 1294 size_t pos = reader->pagelocate();
1295 size_t start = pos; 1295 size_t start = pos;
1296 CDrawBuffer test(&(reader->m_fontControl)); 1296 CDrawBuffer test(&(reader->m_fontControl));
1297 reader->getline(&test); 1297 reader->getline(&test);
1298 while (arg.match(toQString(test.data())) == -1) 1298 while (arg.match(toQString(test.data())) == -1)
1299 { 1299 {
1300 pos = reader->locate(); 1300 pos = reader->locate();
1301 if (!reader->getline(&test)) 1301 if (!reader->getline(&test))
1302 { 1302 {
1303 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); 1303 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
1304 pos = start; 1304 pos = start;
1305 break; 1305 break;
1306 } 1306 }
1307 } 1307 }
1308 reader->locate(pos); 1308 reader->locate(pos);
1309 } 1309 }
1310 else if ( msg == "File/Fullscreen(int)" ) 1310 else if ( msg == "File/Fullscreen(int)" )
1311 { 1311 {
1312 int info; 1312 int info;
1313 stream >> info; 1313 stream >> info;
1314 setfullscreen(info); 1314 setfullscreen(info);
1315 } 1315 }
1316 else if ( msg == "File/Continuous(int)" ) 1316 else if ( msg == "File/Continuous(int)" )
1317 { 1317 {
1318 int info; 1318 int info;
1319 stream >> info; 1319 stream >> info;
1320 setcontinuous(info); 1320 setcontinuous(info);
1321 } 1321 }
1322 else if ( msg == "Markup(QString)" ) 1322 else if ( msg == "Markup(QString)" )
1323 { 1323 {
1324 QString info; 1324 QString info;
1325 stream >> info; 1325 stream >> info;
1326 if (info == "Auto") 1326 if (info == "Auto")
1327 { 1327 {
1328 autofmt(true); 1328 autofmt(true);
1329 } 1329 }
1330 if (info == "None") 1330 if (info == "None")
1331 { 1331 {
1332 autofmt(false); 1332 autofmt(false);
1333 textfmt(false); 1333 textfmt(false);
1334 striphtml(false); 1334 striphtml(false);
1335 peanut(false); 1335 peanut(false);
1336 } 1336 }
1337 if (info == "Text") 1337 if (info == "Text")
1338 { 1338 {
1339 textfmt(true); 1339 textfmt(true);
1340 } 1340 }
1341 if (info == "HTML") 1341 if (info == "HTML")
1342 { 1342 {
1343 striphtml(true); 1343 striphtml(true);
1344 } 1344 }
1345 if (info == "Peanut/PML") 1345 if (info == "Peanut/PML")
1346 { 1346 {
1347 peanut(true); 1347 peanut(true);
1348 } 1348 }
1349 } 1349 }
1350 else if ( msg == "Layout/StripCR(int)" ) 1350 else if ( msg == "Layout/StripCR(int)" )
1351 { 1351 {
1352 int info; 1352 int info;
1353 stream >> info; 1353 stream >> info;
1354 stripcr(info); 1354 stripcr(info);
1355 } 1355 }
1356 else if ( msg == "Layout/Dehyphen(int)" ) 1356 else if ( msg == "Layout/Dehyphen(int)" )
1357 { 1357 {
1358 int info; 1358 int info;
1359 stream >> info; 1359 stream >> info;
1360 dehyphen(info); 1360 dehyphen(info);
1361 } 1361 }
1362 else if ( msg == "Layout/Depluck(int)" ) 1362 else if ( msg == "Layout/Depluck(int)" )
1363 { 1363 {
1364 int info; 1364 int info;
1365 stream >> info; 1365 stream >> info;
1366 depluck(info); 1366 depluck(info);
1367 } 1367 }
1368 else if ( msg == "Layout/Dejpluck(int)" ) 1368 else if ( msg == "Layout/Dejpluck(int)" )
1369 { 1369 {
1370 int info; 1370 int info;
1371 stream >> info; 1371 stream >> info;
1372 dejpluck(info); 1372 dejpluck(info);
1373 } 1373 }
1374 else if ( msg == "Layout/SingleSpace(int)" ) 1374 else if ( msg == "Layout/SingleSpace(int)" )
1375 { 1375 {
1376 int info; 1376 int info;
1377 stream >> info; 1377 stream >> info;
1378 onespace(info); 1378 onespace(info);
1379 } 1379 }
1380#ifdef REPALM 1380#ifdef REPALM
1381 else if ( msg == "Layout/Repalm(int)" ) 1381 else if ( msg == "Layout/Repalm(int)" )
1382 { 1382 {
1383 int info; 1383 int info;
1384 stream >> info; 1384 stream >> info;
1385 repalm(info); 1385 repalm(info);
1386 } 1386 }
1387#endif 1387#endif
1388 else if ( msg == "Layout/Unindent(int)" ) 1388 else if ( msg == "Layout/Unindent(int)" )
1389 { 1389 {
1390 int info; 1390 int info;
1391 stream >> info; 1391 stream >> info;
1392 unindent(info); 1392 unindent(info);
1393 } 1393 }
1394 else if ( msg == "Layout/Re-paragraph(int)" ) 1394 else if ( msg == "Layout/Re-paragraph(int)" )
1395 { 1395 {
1396 int info; 1396 int info;
1397 stream >> info; 1397 stream >> info;
1398 repara(info); 1398 repara(info);
1399 } 1399 }
1400 else if ( msg == "Layout/DoubleSpace(int)" ) 1400 else if ( msg == "Layout/DoubleSpace(int)" )
1401 { 1401 {
1402 int info; 1402 int info;
1403 stream >> info; 1403 stream >> info;
1404 dblspce(info); 1404 dblspce(info);
1405 } 1405 }
1406 else if ( msg == "Layout/Indent(int)" ) 1406 else if ( msg == "Layout/Indent(int)" )
1407 { 1407 {
1408 int info; 1408 int info;
1409 stream >> info; 1409 stream >> info;
1410 reader->bindenter = info; 1410 reader->bindenter = info;
1411 reader->setfilter(reader->getfilter()); 1411 reader->setfilter(reader->getfilter());
1412 } 1412 }
1413 else if ( msg == "Layout/Remap(int)" ) 1413 else if ( msg == "Layout/Remap(int)" )
1414 { 1414 {
1415 int info; 1415 int info;
1416 stream >> info; 1416 stream >> info;
1417 remap(info); 1417 remap(info);
1418 } 1418 }
1419 else if ( msg == "Layout/Embolden(int)" ) 1419 else if ( msg == "Layout/Embolden(int)" )
1420 { 1420 {
1421 int info; 1421 int info;
1422 stream >> info; 1422 stream >> info;
1423 embolden(info); 1423 embolden(info);
1424 } 1424 }
1425 else if ( msg == "Format/Ideogram/Word(int)" ) 1425 else if ( msg == "Format/Ideogram/Word(int)" )
1426 { 1426 {
1427 int info; 1427 int info;
1428 stream >> info; 1428 stream >> info;
1429 monospace(info); 1429 monospace(info);
1430 } 1430 }
1431 else if ( msg == "Format/SetWidth(int)" ) 1431 else if ( msg == "Format/SetWidth(int)" )
1432 { 1432 {
1433 int info; 1433 int info;
1434 stream >> info; 1434 stream >> info;
1435 reader->m_charpc = info; 1435 reader->m_charpc = info;
1436 reader->setfont(); 1436 reader->setfont();
1437 reader->refresh(); 1437 reader->refresh();
1438 } 1438 }
1439 else if ( msg == "Format/SetFont(QString,int)" ) 1439 else if ( msg == "Format/SetFont(QString,int)" )
1440 { 1440 {
1441 QString fontname; 1441 QString fontname;
1442 int size; 1442 int size;
1443 stream >> fontname; 1443 stream >> fontname;
1444 stream >> size; 1444 stream >> size;
1445 setfontHelper(fontname, size); 1445 setfontHelper(fontname, size);
1446 } 1446 }
1447 else if ( msg == "Marks/Autogen(QString)" ) 1447 else if ( msg == "Marks/Autogen(QString)" )
1448 { 1448 {
1449 QString info; 1449 QString info;
1450 stream >> info; 1450 stream >> info;
1451 do_autogen(info); 1451 do_autogen(info);
1452 } 1452 }
1453 else if ( msg == "File/StartBlock()" ) 1453 else if ( msg == "File/StartBlock()" )
1454 { 1454 {
1455 editMark(); 1455 editMark();
1456 } 1456 }
1457 else if ( msg == "File/CopyBlock()" ) 1457 else if ( msg == "File/CopyBlock()" )
1458 { 1458 {
1459 editCopy(); 1459 editCopy();
1460 } 1460 }
1461} 1461}
1462#endif 1462#endif
1463ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1463ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
1464{ 1464{
1465 for (int i = 0; i < MAX_ACTIONS; i++) 1465 for (int i = 0; i < MAX_ACTIONS; i++)
1466 { 1466 {
1467 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; 1467 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
1468 } 1468 }
1469 return cesAutoScroll; 1469 return cesAutoScroll;
1470} 1470}
1471 1471
1472void QTReaderApp::setfullscreen(bool sfs) 1472void QTReaderApp::setfullscreen(bool sfs)
1473{ 1473{
1474 reader->bDoUpdates = false; 1474 reader->bDoUpdates = false;
1475 m_fullscreen = sfs; 1475 m_fullscreen = sfs;
1476 showEditTools(); 1476 showEditTools();
1477// qApp->processEvents(); 1477// qApp->processEvents();
1478 reader->bDoUpdates = true; 1478 reader->bDoUpdates = true;
1479 reader->update(); 1479 reader->update();
1480} 1480}
1481 1481
1482void QTReaderApp::buttonActionSelected(QAction* _a) 1482void QTReaderApp::buttonActionSelected(QAction* _a)
1483{ 1483{
1484//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 1484//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
1485 m_spaceTarget = ActNameToInt(_a->text()); 1485 m_spaceTarget = ActNameToInt(_a->text());
1486} 1486}
1487 1487
1488QTReaderApp::~QTReaderApp() 1488QTReaderApp::~QTReaderApp()
1489{ 1489{
1490} 1490}
1491 1491
1492void QTReaderApp::autoScroll(bool _b) 1492void QTReaderApp::autoScroll(bool _b)
1493{ 1493{
1494 reader->setautoscroll(_b); 1494 reader->setautoscroll(_b);
1495 setScrollState(reader->m_autoScroll); 1495 setScrollState(reader->m_autoScroll);
1496} 1496}
1497 1497
1498void QTReaderApp::zoomin() 1498void QTReaderApp::zoomin()
1499{ 1499{
1500 reader->zoomin(); 1500 reader->zoomin();
1501} 1501}
1502 1502
1503void QTReaderApp::zoomout() 1503void QTReaderApp::zoomout()
1504{ 1504{
1505 reader->zoomout(); 1505 reader->zoomout();
1506} 1506}
1507 1507
1508void QTReaderApp::clearBkmkList() 1508void QTReaderApp::clearBkmkList()
1509{ 1509{
1510 delete pBkmklist; 1510 delete pBkmklist;
1511 pBkmklist = NULL; 1511 pBkmklist = NULL;
1512 m_fBkmksChanged = false; 1512 m_fBkmksChanged = false;
1513} 1513}
1514 1514
1515void QTReaderApp::fileClose() 1515void QTReaderApp::fileClose()
1516{ 1516{
1517 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); 1517 CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
1518 if (cd->exec()) 1518 if (cd->exec())
1519 { 1519 {
1520 if (pOpenlist != NULL) 1520 if (pOpenlist != NULL)
1521 { 1521 {
1522 int ind = 0; 1522 int ind = 0;
1523 Bkmk* p = (*pOpenlist)[ind]; 1523 Bkmk* p = (*pOpenlist)[ind];
1524 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) 1524 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1525 { 1525 {
1526 p = (*pOpenlist)[++ind]; 1526 p = (*pOpenlist)[++ind];
1527 } 1527 }
1528 if (p != NULL) pOpenlist->erase(ind); 1528 if (p != NULL) pOpenlist->erase(ind);
1529 if (cd->delFile()) 1529 if (cd->delFile())
1530 { 1530 {
1531 unlink((const char*)reader->m_lastfile); 1531 unlink((const char*)reader->m_lastfile);
1532 } 1532 }
1533 if (cd->delMarks()) 1533 if (cd->delMarks())
1534 { 1534 {
1535#ifndef USEQPE 1535#ifndef USEQPE
1536 QDir d = QDir::home(); // "/" 1536 QDir d = QDir::home(); // "/"
1537 d.cd(APPDIR); 1537 d.cd(APPDIR);
1538 d.remove(reader->m_string); 1538 d.remove(reader->m_string);
1539#else /* USEQPE */ 1539#else /* USEQPE */
1540 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); 1540 unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
1541#endif /* USEQPE */ 1541#endif /* USEQPE */
1542 } 1542 }
1543 if (cd->delConfig()) 1543 if (cd->delConfig())
1544 { 1544 {
1545#ifndef USEQPE 1545#ifndef USEQPE
1546 QDir d = QDir::home(); // "/" 1546 QDir d = QDir::home(); // "/"
1547 d.cd(APPDIR "/configs"); 1547 d.cd(APPDIR "/configs");
1548 d.remove(reader->m_string); 1548 d.remove(reader->m_string);
1549#else /* USEQPE */ 1549#else /* USEQPE */
1550 unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); 1550 unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string));
1551#endif /* USEQPE */ 1551#endif /* USEQPE */
1552 } 1552 }
1553 } 1553 }
1554 1554
1555 fileOpen2(); 1555 fileOpen2();
1556 } 1556 }
1557 delete cd; 1557 delete cd;
1558} 1558}
1559 1559
1560void QTReaderApp::updatefileinfo() 1560void QTReaderApp::updatefileinfo()
1561{ 1561{
1562 if (reader->m_string.isEmpty()) return; 1562 if (reader->m_string.isEmpty()) return;
1563 if (reader->m_lastfile.isEmpty()) return; 1563 if (reader->m_lastfile.isEmpty()) return;
1564 tchar* nm = fromQString(reader->m_string); 1564 tchar* nm = fromQString(reader->m_string);
1565 tchar* fl = fromQString(reader->m_lastfile); 1565 tchar* fl = fromQString(reader->m_lastfile);
1566// qDebug("Lastfile:%x", fl); 1566// qDebug("Lastfile:%x", fl);
1567 bool notadded = true; 1567 bool notadded = true;
1568 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; 1568 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
1569 else 1569 else
1570 { 1570 {
1571 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) 1571 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
1572 { 1572 {
1573 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) 1573 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
1574 { 1574 {
1575 iter->value(reader->pagelocate()); 1575 iter->value(reader->pagelocate());
1576 unsigned short dlen; 1576 unsigned short dlen;
1577 unsigned char* data; 1577 unsigned char* data;
1578 CFiledata fd(iter->anno()); 1578 CFiledata fd(iter->anno());
1579 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1579 reader->setSaveData(data, dlen, fd.content(), fd.length());
1580 // qDebug("Filedata(1):%u, %u", fd.length(), dlen); 1580 // qDebug("Filedata(1):%u, %u", fd.length(), dlen);
1581 // getstate(data, dlen); 1581 // getstate(data, dlen);
1582 iter->setAnno(data, dlen); 1582 iter->setAnno(data, dlen);
1583 notadded = false; 1583 notadded = false;
1584 delete [] data; 1584 delete [] data;
1585 break; 1585 break;
1586 } 1586 }
1587 } 1587 }
1588 } 1588 }
1589// qDebug("Added?:%x", notadded); 1589// qDebug("Added?:%x", notadded);
1590 if (notadded) 1590 if (notadded)
1591 { 1591 {
1592 struct stat fnstat; 1592 struct stat fnstat;
1593 stat((const char *)reader->m_lastfile, &fnstat); 1593 stat((const char *)reader->m_lastfile, &fnstat);
1594 CFiledata fd(fnstat.st_mtime, fl); 1594 CFiledata fd(fnstat.st_mtime, fl);
1595 unsigned short dlen; 1595 unsigned short dlen;
1596 unsigned char* data; 1596 unsigned char* data;
1597 reader->setSaveData(data, dlen, fd.content(), fd.length()); 1597 reader->setSaveData(data, dlen, fd.content(), fd.length());
1598 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); 1598 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
1599 //qDebug("Filedata(2):%u, %u", fd.length(), dlen); 1599 //qDebug("Filedata(2):%u, %u", fd.length(), dlen);
1600 delete [] data; 1600 delete [] data;
1601 } 1601 }
1602 delete [] nm; 1602 delete [] nm;
1603 delete [] fl; 1603 delete [] fl;
1604} 1604}
1605 1605
1606void QTReaderApp::fileOpen() 1606void QTReaderApp::fileOpen()
1607{ 1607{
1608/* 1608/*
1609 menu->hide(); 1609 menu->hide();
1610 fileBar->hide(); 1610 fileBar->hide();
1611 if (regVisible) regBar->hide(); 1611 if (regVisible) regBar->hide();
1612 if (searchVisible) searchBar->hide(); 1612 if (searchVisible) searchBar->hide();
1613*/ 1613*/
1614// qDebug("fileOpen"); 1614// qDebug("fileOpen");
1615// if (!reader->m_lastfile.isEmpty()) 1615// if (!reader->m_lastfile.isEmpty())
1616 updatefileinfo(); 1616 updatefileinfo();
1617 fileOpen2(); 1617 fileOpen2();
1618} 1618}
1619 1619
1620void QTReaderApp::fileOpen2() 1620void QTReaderApp::fileOpen2()
1621{ 1621{
1622 if (pBkmklist != NULL) 1622 if (pBkmklist != NULL)
1623 { 1623 {
1624 if (m_fBkmksChanged) 1624 if (m_fBkmksChanged)
1625 { 1625 {
1626 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 1626 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1627 savebkmks(); 1627 savebkmks();
1628 } 1628 }
1629 delete pBkmklist; 1629 delete pBkmklist;
1630 pBkmklist = NULL; 1630 pBkmklist = NULL;
1631 m_fBkmksChanged = false; 1631 m_fBkmksChanged = false;
1632 } 1632 }
1633 reader->disableAutoscroll(); 1633 reader->disableAutoscroll();
1634/* 1634/*
1635 editorStack->raiseWidget( fileSelector ); 1635 editorStack->raiseWidget( fileSelector );
1636 fileSelector->reread(); 1636 fileSelector->reread();
1637*/ 1637*/
1638 bool usebrowser = true; 1638 bool usebrowser = true;
1639 if (pOpenlist != NULL) 1639 if (pOpenlist != NULL)
1640 { 1640 {
1641 m_nBkmkAction = cOpenFile; 1641 m_nBkmkAction = cOpenFile;
1642 if (listbkmk(pOpenlist, "Browse")) usebrowser = false; 1642 if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
1643 } 1643 }
1644 if (usebrowser) 1644 if (usebrowser)
1645 { 1645 {
1646 QString fn = usefilebrowser(); 1646 QString fn = usefilebrowser();
1647 //qApp->processEvents(); 1647 //qApp->processEvents();
1648 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 1648 if (!fn.isEmpty() && QFileInfo(fn).isFile())
1649 { 1649 {
1650 openFile(fn); 1650 openFile(fn);
1651 } 1651 }
1652 reader->setFocus(); 1652 reader->setFocus();
1653 } 1653 }
1654// reader->refresh(); 1654// reader->refresh();
1655// qDebug("HEIGHT:%d", reader->m_lastheight); 1655// qDebug("HEIGHT:%d", reader->m_lastheight);
1656} 1656}
1657 1657
1658QString QTReaderApp::usefilebrowser() 1658QString QTReaderApp::usefilebrowser()
1659{ 1659{
1660#ifndef USEQPE 1660#ifndef USEQPE
1661 QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); 1661 QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
1662 return s; 1662 return s;
1663#else 1663#else
1664 fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, 1664 fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog,
1665 0, 1665 0,
1666 // WStyle_Customize | WStyle_NoBorderEx, 1666 // WStyle_Customize | WStyle_NoBorderEx,
1667 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 1667 "*", QFileInfo(reader->m_lastfile).dirPath(true));
1668 1668
1669 1669
1670 QString fn; 1670 QString fn;
1671 if (fb->exec()) 1671 if (fb->exec())
1672 { 1672 {
1673 fn = fb->getCurrentFile(); 1673 fn = fb->getCurrentFile();
1674 } 1674 }
1675// qDebug("Selected %s", (const char*)fn); 1675// qDebug("Selected %s", (const char*)fn);
1676 delete fb; 1676 delete fb;
1677 showEditTools(); 1677 showEditTools();
1678 return fn; 1678 return fn;
1679#endif 1679#endif
1680} 1680}
1681 1681
1682void QTReaderApp::showgraphic(QImage& pm) 1682void QTReaderApp::showgraphic(QImage& pm)
1683{ 1683{
1684 QPixmap pc; 1684 QPixmap pc;
1685 pc.convertFromImage(pm); 1685 pc.convertFromImage(pm);
1686 m_graphicwin->setPixmap(pc); 1686 m_graphicwin->setPixmap(pc);
1687 editorStack->raiseWidget( m_graphicwin ); 1687 editorStack->raiseWidget( m_graphicwin );
1688 m_graphicwin->setFocus(); 1688 m_graphicwin->setFocus();
1689} 1689}
1690 1690
1691 1691
1692void QTReaderApp::showprefs() 1692void QTReaderApp::showprefs()
1693{ 1693{
1694 CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); 1694 CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this);
1695 1695
1696 prefwin->twotouch(m_twoTouch); 1696 prefwin->twotouch(m_twoTouch);
1697 prefwin->propfontchange(m_propogatefontchange); 1697 prefwin->propfontchange(m_propogatefontchange);
1698 prefwin->StripCR(reader->bstripcr); 1698 prefwin->StripCR(reader->bstripcr);
1699 prefwin->Dehyphen(reader->bdehyphen); 1699 prefwin->Dehyphen(reader->bdehyphen);
1700 prefwin->SingleSpace(reader->bonespace); 1700 prefwin->SingleSpace(reader->bonespace);
1701 prefwin->Unindent(reader->bunindent); 1701 prefwin->Unindent(reader->bunindent);
1702 prefwin->Reparagraph(reader->brepara); 1702 prefwin->Reparagraph(reader->brepara);
1703 prefwin->DoubleSpace(reader->bdblspce); 1703 prefwin->DoubleSpace(reader->bdblspce);
1704 prefwin->Remap(reader->bremap); 1704 prefwin->Remap(reader->bremap);
1705 prefwin->Embolden(reader->bmakebold); 1705 prefwin->Embolden(reader->bmakebold);
1706 prefwin->FullJustify(reader->bfulljust); 1706 prefwin->FullJustify(reader->bfulljust);
1707 prefwin->ParaLead(reader->getextraspace()); 1707 prefwin->ParaLead(reader->getextraspace());
1708 prefwin->LineLead(reader->getlead()); 1708 prefwin->LineLead(reader->getlead());
1709 prefwin->Margin(reader->m_border); 1709 prefwin->Margin(reader->m_border);
1710 prefwin->Indent(reader->bindenter); 1710 prefwin->Indent(reader->bindenter);
1711 if (reader->bautofmt) 1711 if (reader->bautofmt)
1712 { 1712 {
1713 prefwin->Markup(0); 1713 prefwin->Markup(0);
1714 } 1714 }
1715 else if (reader->btextfmt) 1715 else if (reader->btextfmt)
1716 { 1716 {
1717 prefwin->Markup(2); 1717 prefwin->Markup(2);
1718 } 1718 }
1719 else if (reader->bstriphtml) 1719 else if (reader->bstriphtml)
1720 { 1720 {
1721 prefwin->Markup(3); 1721 prefwin->Markup(3);
1722 } 1722 }
1723 else if (reader->bpeanut) 1723 else if (reader->bpeanut)
1724 { 1724 {
1725 prefwin->Markup(4); 1725 prefwin->Markup(4);
1726 } 1726 }
1727 else 1727 else
1728 { 1728 {
1729 prefwin->Markup(1); 1729 prefwin->Markup(1);
1730 } 1730 }
1731 prefwin->Depluck(reader->bdepluck); 1731 prefwin->Depluck(reader->bdepluck);
1732 prefwin->Dejpluck(reader->bdejpluck); 1732 prefwin->Dejpluck(reader->bdejpluck);
1733 prefwin->Continuous(reader->m_continuousDocument); 1733 prefwin->Continuous(reader->m_continuousDocument);
1734 1734
1735 prefwin->dictApplication(m_targetapp); 1735 prefwin->dictApplication(m_targetapp);
1736 prefwin->dictMessage(m_targetmsg); 1736 prefwin->dictMessage(m_targetmsg);
1737 1737
1738 prefwin->spaceAction(m_spaceTarget); 1738 prefwin->spaceAction(m_spaceTarget);
1739 prefwin->escapeAction(m_escapeTarget); 1739 prefwin->escapeAction(m_escapeTarget);
1740 prefwin->returnAction(m_returnTarget); 1740 prefwin->returnAction(m_returnTarget);
1741 prefwin->leftAction(m_leftTarget); 1741 prefwin->leftAction(m_leftTarget);
1742 prefwin->rightAction(m_rightTarget); 1742 prefwin->rightAction(m_rightTarget);
1743 prefwin->upAction(m_upTarget); 1743 prefwin->upAction(m_upTarget);
1744 prefwin->downAction(m_downTarget); 1744 prefwin->downAction(m_downTarget);
1745 1745
1746 prefwin->leftScroll(m_leftScroll); 1746 prefwin->leftScroll(m_leftScroll);
1747 prefwin->rightScroll(m_rightScroll); 1747 prefwin->rightScroll(m_rightScroll);
1748 prefwin->upScroll(m_upScroll); 1748 prefwin->upScroll(m_upScroll);
1749 prefwin->downScroll(m_downScroll); 1749 prefwin->downScroll(m_downScroll);
1750 1750
1751 prefwin->miscannotation(m_doAnnotation); 1751 prefwin->miscannotation(m_doAnnotation);
1752 prefwin->miscdictionary(m_doDictionary); 1752 prefwin->miscdictionary(m_doDictionary);
1753 prefwin->miscclipboard(m_doClipboard); 1753 prefwin->miscclipboard(m_doClipboard);
1754 1754
1755 prefwin->SwapMouse(reader->m_swapmouse); 1755 prefwin->SwapMouse(reader->m_swapmouse);
1756 1756
1757 prefwin->Font(reader->m_fontname); 1757 prefwin->Font(reader->m_fontname);
1758 1758
1759 prefwin->gfxsize(reader->getBaseSize()); 1759 prefwin->gfxsize(reader->getBaseSize());
1760 1760
1761 prefwin->pageoverlap(reader->m_overlap); 1761 prefwin->pageoverlap(reader->m_overlap);
1762 1762
1763 prefwin->ideogram(reader->m_bMonoSpaced); 1763 prefwin->ideogram(reader->m_bMonoSpaced);
1764 1764
1765 prefwin->encoding(reader->m_encd); 1765 prefwin->encoding(reader->m_encd);
1766 1766
1767 prefwin->ideogramwidth(reader->m_charpc); 1767 prefwin->ideogramwidth(reader->m_charpc);
1768 1768
1769 if (prefwin->exec()) 1769 if (prefwin->exec())
1770 { 1770 {
1771 m_twoTouch = prefwin->twotouch(); 1771 m_twoTouch = prefwin->twotouch();
1772 reader->setTwoTouch(m_twoTouch); 1772 reader->setTwoTouch(m_twoTouch);
1773 m_touch_action->setOn(m_twoTouch); 1773 m_touch_action->setOn(m_twoTouch);
1774 1774
1775 reader->bstripcr = prefwin->StripCR(); 1775 reader->bstripcr = prefwin->StripCR();
1776 reader->bdehyphen = prefwin->Dehyphen(); 1776 reader->bdehyphen = prefwin->Dehyphen();
1777 reader->bonespace = prefwin->SingleSpace(); 1777 reader->bonespace = prefwin->SingleSpace();
1778 reader->bunindent = prefwin->Unindent(); 1778 reader->bunindent = prefwin->Unindent();
1779 reader->brepara = prefwin->Reparagraph(); 1779 reader->brepara = prefwin->Reparagraph();
1780 reader->bdblspce = prefwin->DoubleSpace(); 1780 reader->bdblspce = prefwin->DoubleSpace();
1781 reader->bremap = prefwin->Remap(); 1781 reader->bremap = prefwin->Remap();
1782 reader->bmakebold = prefwin->Embolden(); 1782 reader->bmakebold = prefwin->Embolden();
1783 reader->bfulljust = prefwin->FullJustify(); 1783 reader->bfulljust = prefwin->FullJustify();
1784 reader->setextraspace(prefwin->ParaLead()); 1784 reader->setextraspace(prefwin->ParaLead());
1785 reader->setlead(prefwin->LineLead()); 1785 reader->setlead(prefwin->LineLead());
1786 reader->m_border = prefwin->Margin(); 1786 reader->m_border = prefwin->Margin();
1787 reader->bindenter = prefwin->Indent(); 1787 reader->bindenter = prefwin->Indent();
1788 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; 1788 reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
1789 switch (prefwin->Markup()) 1789 switch (prefwin->Markup())
1790 { 1790 {
1791 case 0: 1791 case 0:
1792 reader->bautofmt = true; 1792 reader->bautofmt = true;
1793 break; 1793 break;
1794 case 1: 1794 case 1:
1795 break; 1795 break;
1796 case 2: 1796 case 2:
1797 reader->btextfmt = true; 1797 reader->btextfmt = true;
1798 break; 1798 break;
1799 case 3: 1799 case 3:
1800 reader->bstriphtml = true; 1800 reader->bstriphtml = true;
1801 break; 1801 break;
1802 case 4: 1802 case 4:
1803 reader->bpeanut = true; 1803 reader->bpeanut = true;
1804 break; 1804 break;
1805 default: 1805 default:
1806 qDebug("Format out of range"); 1806 qDebug("Format out of range");
1807 } 1807 }
1808 reader->bdepluck = prefwin->Depluck(); 1808 reader->bdepluck = prefwin->Depluck();
1809 reader->bdejpluck = prefwin->Dejpluck(); 1809 reader->bdejpluck = prefwin->Dejpluck();
1810 reader->setContinuous(prefwin->Continuous()); 1810 reader->setContinuous(prefwin->Continuous());
1811 1811
1812 m_spaceTarget = (ActionTypes)prefwin->spaceAction(); 1812 m_spaceTarget = (ActionTypes)prefwin->spaceAction();
1813 m_escapeTarget = (ActionTypes)prefwin->escapeAction(); 1813 m_escapeTarget = (ActionTypes)prefwin->escapeAction();
1814 m_returnTarget = (ActionTypes)prefwin->returnAction(); 1814 m_returnTarget = (ActionTypes)prefwin->returnAction();
1815 m_leftTarget = (ActionTypes)prefwin->leftAction(); 1815 m_leftTarget = (ActionTypes)prefwin->leftAction();
1816 m_rightTarget = (ActionTypes)prefwin->rightAction(); 1816 m_rightTarget = (ActionTypes)prefwin->rightAction();
1817 m_upTarget = (ActionTypes)prefwin->upAction(); 1817 m_upTarget = (ActionTypes)prefwin->upAction();
1818 m_downTarget = (ActionTypes)prefwin->downAction(); 1818 m_downTarget = (ActionTypes)prefwin->downAction();
1819 m_leftScroll = prefwin->leftScroll(); 1819 m_leftScroll = prefwin->leftScroll();
1820 m_rightScroll = prefwin->rightScroll(); 1820 m_rightScroll = prefwin->rightScroll();
1821 m_upScroll = prefwin->upScroll(); 1821 m_upScroll = prefwin->upScroll();
1822 m_downScroll = prefwin->downScroll(); 1822 m_downScroll = prefwin->downScroll();
1823 1823
1824 m_targetapp = prefwin->dictApplication(); 1824 m_targetapp = prefwin->dictApplication();
1825 m_targetmsg = prefwin->dictMessage(); 1825 m_targetmsg = prefwin->dictMessage();
1826 1826
1827 m_doAnnotation = prefwin->miscannotation(); 1827 m_doAnnotation = prefwin->miscannotation();
1828 m_doDictionary = prefwin->miscdictionary(); 1828 m_doDictionary = prefwin->miscdictionary();
1829 m_doClipboard = prefwin->miscclipboard(); 1829 m_doClipboard = prefwin->miscclipboard();
1830 reader->m_swapmouse = prefwin->SwapMouse(); 1830 reader->m_swapmouse = prefwin->SwapMouse();
1831 reader->setBaseSize(prefwin->gfxsize()); 1831 reader->setBaseSize(prefwin->gfxsize());
1832 reader->m_overlap = prefwin->pageoverlap(); 1832 reader->m_overlap = prefwin->pageoverlap();
1833 reader->m_bMonoSpaced = prefwin->ideogram(); 1833 reader->m_bMonoSpaced = prefwin->ideogram();
1834 m_setmono_action->setOn(reader->m_bMonoSpaced); 1834 m_setmono_action->setOn(reader->m_bMonoSpaced);
1835 reader->m_encd = prefwin->encoding(); 1835 reader->m_encd = prefwin->encoding();
1836 reader->m_charpc = prefwin->ideogramwidth(); 1836 reader->m_charpc = prefwin->ideogramwidth();
1837 1837
1838 if ( 1838 if (
1839 reader->m_fontname != prefwin->Font() 1839 reader->m_fontname != prefwin->Font()
1840 || 1840 ||
1841 m_propogatefontchange != prefwin->propfontchange()) 1841 m_propogatefontchange != prefwin->propfontchange())
1842 { 1842 {
1843 m_propogatefontchange = prefwin->propfontchange(); 1843 m_propogatefontchange = prefwin->propfontchange();
1844 setfontHelper(prefwin->Font()); 1844 setfontHelper(prefwin->Font());
1845 } 1845 }
1846 delete prefwin; 1846 delete prefwin;
1847 reader->setfilter(reader->getfilter()); 1847 reader->setfilter(reader->getfilter());
1848 reader->refresh(); 1848 reader->refresh();
1849 1849
1850 } 1850 }
1851 else 1851 else
1852 { 1852 {
1853 delete prefwin; 1853 delete prefwin;
1854 } 1854 }
1855} 1855}
1856 1856
1857void QTReaderApp::showtoolbarprefs() 1857void QTReaderApp::showtoolbarprefs()
1858{ 1858{
1859#ifdef USEQPE 1859#ifdef USEQPE
1860 CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); 1860 CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this);
1861#else 1861#else
1862 QFileInfo fi; 1862 QFileInfo fi;
1863 QDir d = QDir::home(); // "/" 1863 QDir d = QDir::home(); // "/"
1864 if ( !d.cd(APPDIR) ) 1864 if ( !d.cd(APPDIR) )
1865 { // "/tmp" 1865 { // "/tmp"
1866 qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); 1866 qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
1867 d = QDir::home(); 1867 d = QDir::home();
1868 d.mkdir(APPDIR); 1868 d.mkdir(APPDIR);
1869 d.cd(APPDIR); 1869 d.cd(APPDIR);
1870 } 1870 }
1871 fi.setFile(d, INIFILE); 1871 fi.setFile(d, INIFILE);
1872 CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); 1872 CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this);
1873#endif 1873#endif
1874 prefwin->tbpolicy(m_tbpolsave); 1874 prefwin->tbpolicy(m_tbpolsave);
1875 prefwin->tbposition(m_tbposition-2); 1875 prefwin->tbposition(m_tbposition-2);
1876 prefwin->tbmovable(m_tbmovesave); 1876 prefwin->tbmovable(m_tbmovesave);
1877 prefwin->floating(m_bFloatingDialog); 1877 prefwin->floating(m_bFloatingDialog);
1878 if (prefwin->exec()) 1878 if (prefwin->exec())
1879 { 1879 {
1880 m_bFloatingDialog = prefwin->floating(); 1880 m_bFloatingDialog = prefwin->floating();
1881 if ( 1881 if (
1882 m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() 1882 m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy()
1883 || 1883 ||
1884 m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) 1884 m_tbposition != (ToolBarDock)(prefwin->tbposition()+2)
1885 || 1885 ||
1886 m_tbmovesave != prefwin->tbmovable() 1886 m_tbmovesave != prefwin->tbmovable()
1887 ) 1887 )
1888 { 1888 {
1889 QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); 1889 QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started");
1890 } 1890 }
1891 m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); 1891 m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy();
1892 m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); 1892 m_tbposition = (ToolBarDock)(prefwin->tbposition()+2);
1893 m_tbmovesave = prefwin->tbmovable(); 1893 m_tbmovesave = prefwin->tbmovable();
1894 bool isChanged = prefwin->isChanged(); 1894 bool isChanged = prefwin->isChanged();
1895 delete prefwin; 1895 delete prefwin;
1896#ifdef USEQPE 1896#ifdef USEQPE
1897 Config config( APPDIR ); 1897 Config config( APPDIR );
1898#else 1898#else
1899 QFileInfo fi; 1899 QFileInfo fi;
1900 QDir d = QDir::home(); // "/" 1900 QDir d = QDir::home(); // "/"
1901 if ( !d.cd(APPDIR) ) 1901 if ( !d.cd(APPDIR) )
1902 { // "/tmp" 1902 { // "/tmp"
1903 qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); 1903 qWarning( "Cannot find the \"~/%s\" directory", APPDIR );
1904 d = QDir::home(); 1904 d = QDir::home();
1905 d.mkdir(APPDIR); 1905 d.mkdir(APPDIR);
1906 d.cd(APPDIR); 1906 d.cd(APPDIR);
1907 } 1907 }
1908 fi.setFile(d, INIFILE); 1908 fi.setFile(d, INIFILE);
1909 Config config( fi.absFilePath() ); 1909 Config config( fi.absFilePath() );
1910#endif 1910#endif
1911 if (isChanged) addtoolbars(&config); 1911 if (isChanged) addtoolbars(&config);
1912 } 1912 }
1913 else 1913 else
1914 { 1914 {
1915 delete prefwin; 1915 delete prefwin;
1916 } 1916 }
1917} 1917}
1918 1918
1919void QTReaderApp::showinfo() 1919void QTReaderApp::showinfo()
1920{ 1920{
1921 unsigned long fs, ts, pl; 1921 unsigned long fs, ts, pl;
1922 if (reader->empty()) 1922 if (reader->empty())
1923 { 1923 {
1924 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 1924 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1925 } 1925 }
1926 else 1926 else
1927 { 1927 {
1928 reader->sizes(fs,ts); 1928 reader->sizes(fs,ts);
1929 pl = reader->pagelocate(); 1929 pl = reader->pagelocate();
1930 m_infoWin->setFileSize(fs); 1930 m_infoWin->setFileSize(fs);
1931 m_infoWin->setTextSize(ts); 1931 m_infoWin->setTextSize(ts);
1932 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); 1932 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
1933 m_infoWin->setLocation(pl); 1933 m_infoWin->setLocation(pl);
1934 m_infoWin->setRead((100*pl + (ts >> 1))/ts); 1934 m_infoWin->setRead((100*pl + (ts >> 1))/ts);
1935 editorStack->raiseWidget( m_infoWin ); 1935 editorStack->raiseWidget( m_infoWin );
1936 m_infoWin->setFocus(); 1936 m_infoWin->setFocus();
1937 } 1937 }
1938} 1938}
1939 1939
1940void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) 1940void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
1941{ 1941{
1942 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 1942 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
1943#ifdef _UNICODE 1943#ifdef _UNICODE
1944 CBuffer buff(name.length()+1); 1944 CBuffer buff(name.length()+1);
1945 int i; 1945 int i;
1946 for (i = 0; i < name.length(); i++) 1946 for (i = 0; i < name.length(); i++)
1947 { 1947 {
1948 buff[i] = name[i].unicode(); 1948 buff[i] = name[i].unicode();
1949 } 1949 }
1950 buff[i] = 0; 1950 buff[i] = 0;
1951 CBuffer buff2(text.length()+1); 1951 CBuffer buff2(text.length()+1);
1952 for (i = 0; i < text.length(); i++) 1952 for (i = 0; i < text.length(); i++)
1953 { 1953 {
1954 buff2[i] = text[i].unicode(); 1954 buff2[i] = text[i].unicode();
1955 } 1955 }
1956 buff2[i] = 0; 1956 buff2[i] = 0;
1957 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); 1957 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
1958#else 1958#else
1959 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1959 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1960#endif 1960#endif
1961 m_fBkmksChanged = true; 1961 m_fBkmksChanged = true;
1962 pBkmklist->sort(); 1962 pBkmklist->sort();
1963} 1963}
1964 1964
1965void QTReaderApp::addAnno(const QString& name, const QString& text) 1965void QTReaderApp::addAnno(const QString& name, const QString& text)
1966{ 1966{
1967 if (m_annoIsEditing) 1967 if (m_annoIsEditing)
1968 { 1968 {
1969 if (name.isEmpty()) 1969 if (name.isEmpty())
1970 { 1970 {
1971 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); 1971 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1);
1972 } 1972 }
1973 else 1973 else
1974 { 1974 {
1975 addAnno(name, text, m_annoWin->getPosn()); 1975 addAnno(name, text, m_annoWin->getPosn());
1976 } 1976 }
1977 showEditTools(); 1977 showEditTools();
1978 } 1978 }
1979 else 1979 else
1980 { 1980 {
1981 if (m_annoWin->edited()) 1981 if (m_annoWin->edited())
1982 { 1982 {
1983 CBuffer buff(text.length()+1); 1983 CBuffer buff(text.length()+1);
1984 int i; 1984 int i;
1985 for (i = 0; i < text.length(); i++) 1985 for (i = 0; i < text.length(); i++)
1986 { 1986 {
1987 buff[i] = text[i].unicode(); 1987 buff[i] = text[i].unicode();
1988 } 1988 }
1989 buff[i] = 0; 1989 buff[i] = 0;
1990 m_fBkmksChanged = true; 1990 m_fBkmksChanged = true;
1991 m_anno->setAnno(buff.data()); 1991 m_anno->setAnno(buff.data());
1992 } 1992 }
1993 bool found = findNextBookmark(m_anno->value()+1); 1993 bool found = findNextBookmark(m_anno->value()+1);
1994 if (found) 1994 if (found)
1995 { 1995 {
1996 m_annoWin->setName(toQString(m_anno->name())); 1996 m_annoWin->setName(toQString(m_anno->name()));
1997 m_annoWin->setAnno(toQString(m_anno->anno())); 1997 m_annoWin->setAnno(toQString(m_anno->anno()));
1998 } 1998 }
1999 else 1999 else
2000 { 2000 {
2001 showEditTools(); 2001 showEditTools();
2002 } 2002 }
2003 } 2003 }
2004} 2004}
2005 2005
2006bool QTReaderApp::findNextBookmark(size_t start) 2006bool QTReaderApp::findNextBookmark(size_t start)
2007{ 2007{
2008 bool found = false; 2008 bool found = false;
2009 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) 2009 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
2010 { 2010 {
2011 if (iter->value() >= start) 2011 if (iter->value() >= start)
2012 { 2012 {
2013 if (iter->value() < reader->locate()) 2013 if (iter->value() < reader->locate())
2014 { 2014 {
2015 found = true; 2015 found = true;
2016 m_anno = iter.pContent(); 2016 m_anno = iter.pContent();
2017 } 2017 }
2018 break; 2018 break;
2019 } 2019 }
2020 } 2020 }
2021 return found; 2021 return found;
2022} 2022}
2023 2023
2024void QTReaderApp::addanno() 2024void QTReaderApp::addanno()
2025{ 2025{
2026 if (reader->empty()) 2026 if (reader->empty())
2027 { 2027 {
2028 QMessageBox::information(this, PROGNAME, "No file loaded", 1); 2028 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
2029 } 2029 }
2030 else 2030 else
2031 { 2031 {
2032 m_annoWin->setName(""); 2032 m_annoWin->setName("");
2033 m_annoWin->setAnno(""); 2033 m_annoWin->setAnno("");
2034 m_annoWin->setPosn(reader->pagelocate()); 2034 m_annoWin->setPosn(reader->pagelocate());
2035 m_annoIsEditing = true; 2035 m_annoIsEditing = true;
2036 editorStack->raiseWidget( m_annoWin ); 2036 editorStack->raiseWidget( m_annoWin );
2037#ifdef USEQPE 2037#ifdef USEQPE
2038 Global::showInputMethod(); 2038 Global::showInputMethod();
2039#endif 2039#endif
2040 m_annoWin->setFocus(); 2040 m_annoWin->setFocus();
2041 } 2041 }
2042} 2042}
2043 2043
2044void QTReaderApp::infoClose() 2044void QTReaderApp::infoClose()
2045{ 2045{
2046 showEditTools(); 2046 showEditTools();
2047} 2047}
2048 2048
2049/* 2049/*
2050void QTReaderApp::fileRevert() 2050void QTReaderApp::fileRevert()
2051{ 2051{
2052 clear(); 2052 clear();
2053 fileOpen(); 2053 fileOpen();
2054} 2054}
2055 2055
2056void QTReaderApp::editCut() 2056void QTReaderApp::editCut()
2057{ 2057{
2058#ifndef QT_NO_CLIPBOARD 2058#ifndef QT_NO_CLIPBOARD
2059 editor->cut(); 2059 editor->cut();
2060#endif 2060#endif
2061} 2061}
2062*/ 2062*/
2063void QTReaderApp::editMark() 2063void QTReaderApp::editMark()
2064{ 2064{
2065 m_savedpos = reader->pagelocate(); 2065 m_savedpos = reader->pagelocate();
2066} 2066}
2067 2067
2068void QTReaderApp::editCopy() 2068void QTReaderApp::editCopy()
2069{ 2069{
2070 QClipboard* cb = QApplication::clipboard(); 2070 QClipboard* cb = QApplication::clipboard();
2071 QString text; 2071 QString text;
2072 int ch; 2072 int ch;
2073 unsigned long currentpos = reader->pagelocate(); 2073 unsigned long currentpos = reader->pagelocate();
2074 unsigned long endpos = reader->locate(); 2074 unsigned long endpos = reader->locate();
diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp
index c7a7d88..861473e 100644
--- a/noncore/apps/opie-sheet/main.cpp
+++ b/noncore/apps/opie-sheet/main.cpp
@@ -1,20 +1,23 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10/* 10/*
11 * Opie Sheet (formerly Sheet/Qt) 11 * Opie Sheet (formerly Sheet/Qt)
12 * by Serdar Ozler <sozler@sitebest.com> 12 * by Serdar Ozler <sozler@sitebest.com>
13 */ 13 */
14 14
15
15#include "mainwindow.h" 16#include "mainwindow.h"
16 17
17#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
18 19
20using namespace Opie::Core;
21
19OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 22OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
20 23
diff --git a/noncore/apps/opie-write/main.cpp b/noncore/apps/opie-write/main.cpp
index 6a8aaaa..036fe48 100644
--- a/noncore/apps/opie-write/main.cpp
+++ b/noncore/apps/opie-write/main.cpp
@@ -1,28 +1,30 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** Licensees holding valid Qtopia Developer license may use this 6** Licensees holding valid Qtopia Developer license may use this
7** file in accordance with the Qtopia Developer License Agreement 7** file in accordance with the Qtopia Developer License Agreement
8** provided with the Software. 8** provided with the Software.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12** PURPOSE. 12** PURPOSE.
13** 13**
14** email sales@trolltech.com for information about Qtopia License 14** email sales@trolltech.com for information about Qtopia License
15** Agreements. 15** Agreements.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22
22#include "mainwindow.h" 23#include "mainwindow.h"
23 24
24#include <opie2/oapplicationfactory.h> 25#include <opie2/oapplicationfactory.h>
25 26
27using namespace Opie::Core;
26OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 28OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
27 29
28 30
diff --git a/noncore/apps/oxygen/main.cpp b/noncore/apps/oxygen/main.cpp
index 276b90d..e2a602b 100644
--- a/noncore/apps/oxygen/main.cpp
+++ b/noncore/apps/oxygen/main.cpp
@@ -1,23 +1,25 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : Oxygen 2 application: : Oxygen
3 3
4 begin : September 2002 4 begin : September 2002
5 copyright : ( C ) 2002 by Carsten Niehaus 5 copyright : ( C ) 2002 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17 17
18#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
19 19
20#include "oxygen.h" 20#include "oxygen.h"
21 21
22 22
23using namespace Opie::Core;
24using namespace Opie::Core;
23OPIE_EXPORT_APP( OApplicationFactory<Oxygen> ) 25OPIE_EXPORT_APP( OApplicationFactory<Oxygen> )
diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp
index 80a76e0..7ef281c 100644
--- a/noncore/apps/tableviewer/main.cpp
+++ b/noncore/apps/tableviewer/main.cpp
@@ -1,25 +1,27 @@
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 "tableviewer.h" 20#include "tableviewer.h"
21 21
22#include <opie2/oapplicationfactory.h> 22#include <opie2/oapplicationfactory.h>
23 23
24using namespace Opie::Core;
24OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> ) 25OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> )
26using namespace Opie::Core;
25 27
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp
index 4c6d809..102b94c 100644
--- a/noncore/apps/tableviewer/tableviewer.cpp
+++ b/noncore/apps/tableviewer/tableviewer.cpp
@@ -1,480 +1,480 @@
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/* local includes */ 21/* local includes */
22#include "tableviewer.h" 22#include "tableviewer.h"
23#include "ui/tvbrowseview.h" 23#include "ui/tvbrowseview.h"
24#include "ui/tvfilterview.h" 24#include "ui/tvfilterview.h"
25#include "ui/tvlistview.h" 25#include "ui/tvlistview.h"
26#include "ui/tveditview.h" 26#include "ui/tveditview.h"
27#include "ui/tvkeyedit.h" 27#include "ui/tvkeyedit.h"
28#include "db/datacache.h" 28#include "db/datacache.h"
29 29
30/* QPE includes */ 30/* QPE includes */
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qpe/qpetoolbar.h> 33#include <qtoolbar.h>
34 34
35/* QTE includes */ 35/* QTE includes */
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qwidgetstack.h> 39#include <qwidgetstack.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
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
45 45
46 This is the main widget of the table viewer application. 46 This is the main widget of the table viewer application.
47 It is the co-ordination point. 47 It is the co-ordination point.
48*/ 48*/
49 49
50/*! 50/*!
51 Constructs a new TableViewerWindow 51 Constructs a new TableViewerWindow
52*/ 52*/
53TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) 53TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f)
54 : QMainWindow(parent, name, f) 54 : QMainWindow(parent, name, f)
55{ 55{
56 setCaption(tr("Table Viewer")); 56 setCaption(tr("Table Viewer"));
57 57
58/* Build data */ 58/* Build data */
59 ds = new DBStore(); 59 ds = new DBStore();
60 doc.setType("text/x-xml-tableviewer"); 60 doc.setType("text/x-xml-tableviewer");
61 doc.setName("table"); 61 doc.setName("table");
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*/
177TableViewerWindow::~TableViewerWindow() 177TableViewerWindow::~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*/
186void TableViewerWindow::selectDocument() 186void 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
195void TableViewerWindow::saveDocument() 195void 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
211void TableViewerWindow::newDocument() 211void 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
237void TableViewerWindow::setDocument(const QString &f) 237void TableViewerWindow::setDocument(const QString &f)
238{ 238{
239 openDocument(DocLnk(f, TRUE)); 239 openDocument(DocLnk(f, TRUE));
240} 240}
241 241
242void TableViewerWindow::openDocument(const DocLnk &f) 242void 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
262 /* set up new table state and ensure sub widgets have a reference */ 262 /* set up new table state and ensure sub widgets have a reference */
263 ts.current_column = 0; 263 ts.current_column = 0;
264 ts.kRep = ds->getKeys(); 264 ts.kRep = ds->getKeys();
265 browseView->rebuildKeys(); 265 browseView->rebuildKeys();
266 listView->rebuildKeys(); 266 listView->rebuildKeys();
267 filterView->rebuildKeys(); 267 filterView->rebuildKeys();
268 268
269 ds->first(); 269 ds->first();
270 /* set up the list view */ 270 /* set up the list view */
271 listView->clearItems(); 271 listView->clearItems();
272 do { 272 do {
273 d = ds->getCurrentData(); 273 d = ds->getCurrentData();
274 if(d) 274 if(d)
275 listView->addItem(d); 275 listView->addItem(d);
276 } while(ds->next()); 276 } while(ds->next());
277 277
278 /* Set up browse view, Will be based of structure of listView */ 278 /* Set up browse view, Will be based of structure of listView */
279 listView->first(); 279 listView->first();
280 ts.current_elem = listView->getCurrentData(); 280 ts.current_elem = listView->getCurrentData();
281 browseView->rebuildData(); 281 browseView->rebuildData();
282 listView->rebuildData(); 282 listView->rebuildData();
283 283
284 QString scratch = "Table Viewer";/* later take from constant */ 284 QString scratch = "Table Viewer";/* later take from constant */
285 scratch += " - "; 285 scratch += " - ";
286 scratch += ds->getName(); 286 scratch += ds->getName();
287 setCaption(tr(scratch)); 287 setCaption(tr(scratch));
288 288
289 dirty = FALSE; 289 dirty = FALSE;
290 } else { 290 } else {
291 qWarning(tr("could not load Document")); 291 qWarning(tr("could not load Document"));
292 } 292 }
293 dev->close(); 293 dev->close();
294} 294}
295 295
296/*! 296/*!
297 Moves to the first item of the current table 297 Moves to the first item of the current table
298*/ 298*/
299void TableViewerWindow::firstItem() 299void TableViewerWindow::firstItem()
300{ 300{
301 listView->first(); 301 listView->first();
302 ts.current_elem = listView->getCurrentData(); 302 ts.current_elem = listView->getCurrentData();
303 browseView->rebuildData(); 303 browseView->rebuildData();
304} 304}
305 305
306/*! 306/*!
307 Moves to the lat item of the current table 307 Moves to the lat item of the current table
308*/ 308*/
309void TableViewerWindow::lastItem() 309void TableViewerWindow::lastItem()
310{ 310{
311 listView->last(); 311 listView->last();
312 ts.current_elem = listView->getCurrentData(); 312 ts.current_elem = listView->getCurrentData();
313 browseView->rebuildData(); 313 browseView->rebuildData();
314} 314}
315 315
316/*! 316/*!
317 Moves to the next item of the current table 317 Moves to the next item of the current table
318*/ 318*/
319void TableViewerWindow::nextItem() 319void TableViewerWindow::nextItem()
320{ 320{
321 listView->next(); 321 listView->next();
322 ts.current_elem = listView->getCurrentData(); 322 ts.current_elem = listView->getCurrentData();
323 browseView->rebuildData(); 323 browseView->rebuildData();
324} 324}
325 325
326/*! 326/*!
327 Moves to the previous item of the current table 327 Moves to the previous item of the current table
328*/ 328*/
329void TableViewerWindow::previousItem() 329void TableViewerWindow::previousItem()
330{ 330{
331 listView->previous(); 331 listView->previous();
332 ts.current_elem = listView->getCurrentData(); 332 ts.current_elem = listView->getCurrentData();
333 browseView->rebuildData(); 333 browseView->rebuildData();
334} 334}
335 335
336/*! 336/*!
337 Raises the List View. This is a mode change for the application. 337 Raises the List View. This is a mode change for the application.
338*/ 338*/
339void TableViewerWindow::listViewSlot() 339void TableViewerWindow::listViewSlot()
340{ 340{
341 if(current_view == FilterState) 341 if(current_view == FilterState)
342 applyFilter(); 342 applyFilter();
343 current_view = ListState; 343 current_view = ListState;
344 cw->raiseWidget(current_view); 344 cw->raiseWidget(current_view);
345} 345}
346 346
347void TableViewerWindow::applyFilter() 347void TableViewerWindow::applyFilter()
348{ 348{
349 DataElem *d; 349 DataElem *d;
350 350
351 listView->clearItems(); 351 listView->clearItems();
352 ds->first(); 352 ds->first();
353 do { 353 do {
354 d = ds->getCurrentData(); 354 d = ds->getCurrentData();
355 if(d) 355 if(d)
356 if(filterView->passesFilter(d)) 356 if(filterView->passesFilter(d))
357 listView->addItem(d); 357 listView->addItem(d);
358 } while(ds->next()); 358 } while(ds->next());
359 listView->first(); 359 listView->first();
360 listView->rebuildData(); 360 listView->rebuildData();
361} 361}
362 362
363/*! 363/*!
364 Raises the Browse View. This is a mode change for the application. 364 Raises the Browse View. This is a mode change for the application.
365*/ 365*/
366void TableViewerWindow::browseViewSlot() 366void TableViewerWindow::browseViewSlot()
367{ 367{
368 if(current_view == FilterState) 368 if(current_view == FilterState)
369 applyFilter(); 369 applyFilter();
370 370
371 ts.current_elem = listView->getCurrentData(); 371 ts.current_elem = listView->getCurrentData();
372 browseView->rebuildData(); 372 browseView->rebuildData();
373 373
374 current_view = BrowseState; 374 current_view = BrowseState;
375 cw->raiseWidget(current_view); 375 cw->raiseWidget(current_view);
376} 376}
377 377
378/*! 378/*!
379 Raises the List View. This is a mode change for the application. 379 Raises the List View. This is a mode change for the application.
380*/ 380*/
381void TableViewerWindow::filterViewSlot() 381void TableViewerWindow::filterViewSlot()
382{ 382{
383 current_view = FilterState; 383 current_view = FilterState;
384 cw->raiseWidget(current_view); 384 cw->raiseWidget(current_view);
385} 385}
386 386
387 387
388 388
389 389
390void TableViewerWindow::editItemSlot() 390void TableViewerWindow::editItemSlot()
391{ 391{
392 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { 392 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) {
393 listView->rebuildData(); 393 listView->rebuildData();
394 browseView->rebuildData(); 394 browseView->rebuildData();
395 dirty = TRUE; 395 dirty = TRUE;
396 } 396 }
397} 397}
398 398
399void TableViewerWindow::newItemSlot() 399void TableViewerWindow::newItemSlot()
400{ 400{
401 DataElem *d = new DataElem(ds); 401 DataElem *d = new DataElem(ds);
402 if (TVEditView::openEditItemDialog(&ts, d, this)) { 402 if (TVEditView::openEditItemDialog(&ts, d, this)) {
403 403
404 ds->addItem(d); 404 ds->addItem(d);
405 ts.current_elem = d; 405 ts.current_elem = d;
406 applyFilter(); 406 applyFilter();
407 listView->rebuildData(); 407 listView->rebuildData();
408 browseView->rebuildData(); 408 browseView->rebuildData();
409 dirty = TRUE; 409 dirty = TRUE;
410 } 410 }
411} 411}
412 412
413void TableViewerWindow::deleteItemSlot() 413void TableViewerWindow::deleteItemSlot()
414{ 414{
415 /* delete the actual item, then do a 'filter' */ 415 /* delete the actual item, then do a 'filter' */
416 DataElem *to_remove = ts.current_elem; 416 DataElem *to_remove = ts.current_elem;
417 417
418 if(!to_remove) 418 if(!to_remove)
419 return; 419 return;
420 420
421 listView->removeItem(); 421 listView->removeItem();
422 ds->removeItem(to_remove); 422 ds->removeItem(to_remove);
423 423
424 applyFilter(); 424 applyFilter();
425 listView->rebuildData(); 425 listView->rebuildData();
426 browseView->rebuildData(); 426 browseView->rebuildData();
427 dirty = TRUE; 427 dirty = TRUE;
428} 428}
429 429
430void TableViewerWindow::editKeysSlot() 430void TableViewerWindow::editKeysSlot()
431{ 431{
432 DataElem *d; 432 DataElem *d;
433 KeyList *k = TVKeyEdit::openEditKeysDialog(&ts, this); 433 KeyList *k = TVKeyEdit::openEditKeysDialog(&ts, this);
434 434
435 if(k) { 435 if(k) {
436 /* set as new keys */ 436 /* set as new keys */
437 ds->setKeys(k); 437 ds->setKeys(k);
438 438
439 ts.current_column = 0; 439 ts.current_column = 0;
440 ts.kRep = k; 440 ts.kRep = k;
441 441
442 browseView->reset(); 442 browseView->reset();
443 listView->reset(); 443 listView->reset();
444 filterView->reset(); 444 filterView->reset();
445 445
446 browseView->rebuildKeys(); 446 browseView->rebuildKeys();
447 listView->rebuildKeys(); 447 listView->rebuildKeys();
448 filterView->rebuildKeys(); 448 filterView->rebuildKeys();
449 449
450 ds->first(); 450 ds->first();
451 /* set up the list view */ 451 /* set up the list view */
452 listView->clearItems(); 452 listView->clearItems();
453 do { 453 do {
454 d = ds->getCurrentData(); 454 d = ds->getCurrentData();
455 if(d) 455 if(d)
456 listView->addItem(d); 456 listView->addItem(d);
457 } while(ds->next()); 457 } while(ds->next());
458 458
459 /* Set up browse view, Will be based of structure of listView */ 459 /* Set up browse view, Will be based of structure of listView */
460 dirty = TRUE; 460 dirty = TRUE;
461 } 461 }
462} 462}
463 463
464/*! 464/*!
465 A Slot that allows for widgets above to indicate a search should be 465 A Slot that allows for widgets above to indicate a search should be
466 done on a specified key index for a specified value 466 done on a specified key index for a specified value
467*/ 467*/
468void TableViewerWindow::searchOnKey(int i, TVVariant v) 468void TableViewerWindow::searchOnKey(int i, TVVariant v)
469{ 469{
470 listView->findItem(i, v); 470 listView->findItem(i, v);
471 ts.current_elem = listView->getCurrentData(); 471 ts.current_elem = listView->getCurrentData();
472 browseView->rebuildData(); 472 browseView->rebuildData();
473} 473}
474 474
475void TableViewerWindow::setPrimaryKey(int i) 475void TableViewerWindow::setPrimaryKey(int i)
476{ 476{
477 ts.current_column = i; 477 ts.current_column = i;
478 listView->rebuildData(); 478 listView->rebuildData();
479 browseView->rebuildData(); 479 browseView->rebuildData();
480} 480}
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
index 8e68262..c3a0a2e 100644
--- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
@@ -1,571 +1,573 @@
1/*************************************************************************** 1/***************************************************************************
2 kateviewdialog.cpp - description 2 kateviewdialog.cpp - description
3 ------------------- 3 -------------------
4 copyright : (C) 2001 by The Kate Team 4 copyright : (C) 2001 by The Kate Team
5 (C) 2002 by Joseph Wenninger 5 (C) 2002 by Joseph Wenninger
6 email : kwrite-devel@kde.org 6 email : kwrite-devel@kde.org
7 jowenn@kde.org 7 jowenn@kde.org
8 8
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19// Dialogs 19// Dialogs
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24#include <qgrid.h> 24#include <qgrid.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcollection.h> 31#include <qcollection.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qobjectlist.h> 33#include <qobjectlist.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kcolorbtn.h> 38#include <kcolorbtn.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <qvbox.h> 40#include <qvbox.h>
41#include <qspinbox.h> 41#include <qspinbox.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <kfontdialog.h> 43#include <kfontdialog.h>
44 44
45#include "../document/katedocument.h" 45#include "../document/katedocument.h"
46#include "kateviewdialog.h" 46#include "kateviewdialog.h"
47#include <opie2/ofontselector.h> 47#include <opie2/ofontselector.h>
48 48
49 49
50using namespace Opie::Ui;
51using namespace Opie::Ui;
50SearchDialog::SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags ) 52SearchDialog::SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags )
51 : KDialogBase( parent, 0L, true, i18n( "Find Text" ), Ok | Cancel, Ok ) 53 : KDialogBase( parent, 0L, true, i18n( "Find Text" ), Ok | Cancel, Ok )
52 , m_replace( 0L ) 54 , m_replace( 0L )
53{ 55{
54 QWidget *page = new QWidget( this ); 56 QWidget *page = new QWidget( this );
55 setMainWidget( page ); 57 setMainWidget( page );
56 58
57 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); 59 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
58 60
59 m_search = new QComboBox( true, page ); 61 m_search = new QComboBox( true, page );
60 m_search->insertStringList( searchFor ); 62 m_search->insertStringList( searchFor );
61 m_search->setMinimumWidth( m_search->sizeHint().width() ); 63 m_search->setMinimumWidth( m_search->sizeHint().width() );
62 m_search->lineEdit()->selectAll(); 64 m_search->lineEdit()->selectAll();
63 QLabel *label = new QLabel( m_search, i18n( "&Text To Find:" ), page ); 65 QLabel *label = new QLabel( m_search, i18n( "&Text To Find:" ), page );
64 m_optRegExp = new QCheckBox( i18n( "Regular Expression" ), page ); 66 m_optRegExp = new QCheckBox( i18n( "Regular Expression" ), page );
65 topLayout->addWidget( label ); 67 topLayout->addWidget( label );
66 topLayout->addWidget( m_search ); 68 topLayout->addWidget( m_search );
67 topLayout->addWidget( m_optRegExp ); 69 topLayout->addWidget( m_optRegExp );
68 70
69 if( flags & KateView::sfReplace ) 71 if( flags & KateView::sfReplace )
70 { 72 {
71 // make it a replace dialog 73 // make it a replace dialog
72 setCaption( i18n( "Replace Text" ) ); 74 setCaption( i18n( "Replace Text" ) );
73 m_replace = new QComboBox( true, page ); 75 m_replace = new QComboBox( true, page );
74 m_replace->insertStringList( replaceWith ); 76 m_replace->insertStringList( replaceWith );
75 m_replace->setMinimumWidth( m_search->sizeHint().width() ); 77 m_replace->setMinimumWidth( m_search->sizeHint().width() );
76 label = new QLabel( m_replace, i18n( "&Replace With:" ), page ); 78 label = new QLabel( m_replace, i18n( "&Replace With:" ), page );
77 //m_optPlaceholders = new QCheckBox( i18n( "&Use Placeholders" ), page ); 79 //m_optPlaceholders = new QCheckBox( i18n( "&Use Placeholders" ), page );
78 topLayout->addWidget( label ); 80 topLayout->addWidget( label );
79 topLayout->addWidget( m_replace ); 81 topLayout->addWidget( m_replace );
80 //topLayout->addWidget( m_optPlaceholders ); 82 //topLayout->addWidget( m_optPlaceholders );
81 } 83 }
82 84
83 QGroupBox *group = new QGroupBox( i18n( "Options" ), page ); 85 QGroupBox *group = new QGroupBox( i18n( "Options" ), page );
84 topLayout->addWidget( group, 10 ); 86 topLayout->addWidget( group, 10 );
85 87
86 QGridLayout *gbox = new QGridLayout( group, 5, 2, spacingHint() ); 88 QGridLayout *gbox = new QGridLayout( group, 5, 2, spacingHint() );
87 gbox->addRowSpacing( 0, fontMetrics().lineSpacing() ); 89 gbox->addRowSpacing( 0, fontMetrics().lineSpacing() );
88 gbox->setRowStretch( 4, 10 ); 90 gbox->setRowStretch( 4, 10 );
89 91
90 m_opt1 = new QCheckBox( i18n( "C&ase Sensitive" ), group ); 92 m_opt1 = new QCheckBox( i18n( "C&ase Sensitive" ), group );
91 gbox->addWidget( m_opt1, 1, 0 ); 93 gbox->addWidget( m_opt1, 1, 0 );
92 94
93 m_opt2 = new QCheckBox(i18n("&Whole Words Only" ), group ); 95 m_opt2 = new QCheckBox(i18n("&Whole Words Only" ), group );
94 gbox->addWidget( m_opt2, 2, 0 ); 96 gbox->addWidget( m_opt2, 2, 0 );
95 97
96 m_opt3 = new QCheckBox(i18n("&From Beginning" ), group ); 98 m_opt3 = new QCheckBox(i18n("&From Beginning" ), group );
97 gbox->addWidget( m_opt3, 3, 0 ); 99 gbox->addWidget( m_opt3, 3, 0 );
98 100
99 m_opt4 = new QCheckBox(i18n("Find &Backwards" ), group ); 101 m_opt4 = new QCheckBox(i18n("Find &Backwards" ), group );
100 gbox->addWidget( m_opt4, 1, 1 ); 102 gbox->addWidget( m_opt4, 1, 1 );
101 103
102 m_opt5 = new QCheckBox(i18n("&Selected Text" ), group ); 104 m_opt5 = new QCheckBox(i18n("&Selected Text" ), group );
103 gbox->addWidget( m_opt5, 2, 1 ); 105 gbox->addWidget( m_opt5, 2, 1 );
104 106
105 m_opt1->setChecked( flags & KateView::sfCaseSensitive ); 107 m_opt1->setChecked( flags & KateView::sfCaseSensitive );
106 m_opt2->setChecked( flags & KateView::sfWholeWords ); 108 m_opt2->setChecked( flags & KateView::sfWholeWords );
107 m_opt3->setChecked( flags & KateView::sfFromBeginning ); 109 m_opt3->setChecked( flags & KateView::sfFromBeginning );
108 m_optRegExp->setChecked( flags & KateView::sfRegularExpression ); 110 m_optRegExp->setChecked( flags & KateView::sfRegularExpression );
109 m_opt4->setChecked( flags & KateView::sfBackward ); 111 m_opt4->setChecked( flags & KateView::sfBackward );
110 m_opt5->setChecked( flags & KateView::sfSelected ); 112 m_opt5->setChecked( flags & KateView::sfSelected );
111 113
112 if( m_replace ) 114 if( m_replace )
113 { 115 {
114 m_opt6 = new QCheckBox( i18n( "&Prompt On Replace" ), group ); 116 m_opt6 = new QCheckBox( i18n( "&Prompt On Replace" ), group );
115 m_opt6->setChecked( flags & KateView::sfPrompt ); 117 m_opt6->setChecked( flags & KateView::sfPrompt );
116 gbox->addWidget( m_opt6, 3, 1 ); 118 gbox->addWidget( m_opt6, 3, 1 );
117 } 119 }
118 120
119 m_search->setFocus(); 121 m_search->setFocus();
120} 122}
121 123
122QString SearchDialog::getSearchFor() 124QString SearchDialog::getSearchFor()
123{ 125{
124 return m_search->currentText(); 126 return m_search->currentText();
125} 127}
126 128
127QString SearchDialog::getReplaceWith() 129QString SearchDialog::getReplaceWith()
128{ 130{
129 return m_replace->currentText(); 131 return m_replace->currentText();
130} 132}
131 133
132int SearchDialog::getFlags() 134int SearchDialog::getFlags()
133{ 135{
134 int flags = 0; 136 int flags = 0;
135 137
136 if( m_opt1->isChecked() ) flags |= KateView::sfCaseSensitive; 138 if( m_opt1->isChecked() ) flags |= KateView::sfCaseSensitive;
137 if( m_opt2->isChecked() ) flags |= KateView::sfWholeWords; 139 if( m_opt2->isChecked() ) flags |= KateView::sfWholeWords;
138 if( m_opt3->isChecked() ) flags |= KateView::sfFromBeginning; 140 if( m_opt3->isChecked() ) flags |= KateView::sfFromBeginning;
139 if( m_opt4->isChecked() ) flags |= KateView::sfBackward; 141 if( m_opt4->isChecked() ) flags |= KateView::sfBackward;
140 if( m_opt5->isChecked() ) flags |= KateView::sfSelected; 142 if( m_opt5->isChecked() ) flags |= KateView::sfSelected;
141 if( m_optRegExp->isChecked() ) flags |= KateView::sfRegularExpression; 143 if( m_optRegExp->isChecked() ) flags |= KateView::sfRegularExpression;
142 if( m_replace ) 144 if( m_replace )
143 { 145 {
144 if( m_opt6->isChecked() ) 146 if( m_opt6->isChecked() )
145 flags |= KateView::sfPrompt; 147 flags |= KateView::sfPrompt;
146 148
147 flags |= KateView::sfReplace; 149 flags |= KateView::sfReplace;
148 } 150 }
149 151
150 return flags; 152 return flags;
151} 153}
152 154
153void SearchDialog::slotOk() 155void SearchDialog::slotOk()
154{ 156{
155 if ( !m_search->currentText().isEmpty() ) 157 if ( !m_search->currentText().isEmpty() )
156 { 158 {
157 if ( !m_optRegExp->isChecked() ) 159 if ( !m_optRegExp->isChecked() )
158 { 160 {
159 accept(); 161 accept();
160 } 162 }
161 else 163 else
162 { 164 {
163 // Check for a valid regular expression. 165 // Check for a valid regular expression.
164 166
165 QRegExp regExp( m_search->currentText() ); 167 QRegExp regExp( m_search->currentText() );
166 168
167 if ( regExp.isValid() ) 169 if ( regExp.isValid() )
168 accept(); 170 accept();
169 } 171 }
170 } 172 }
171} 173}
172 174
173void SearchDialog::setSearchText( const QString &searchstr ) 175void SearchDialog::setSearchText( const QString &searchstr )
174 { 176 {
175 m_search->insertItem( searchstr, 0 ); 177 m_search->insertItem( searchstr, 0 );
176 m_search->setCurrentItem( 0 ); 178 m_search->setCurrentItem( 0 );
177 m_search->lineEdit()->selectAll(); 179 m_search->lineEdit()->selectAll();
178 } 180 }
179 181
180// this dialog is not modal 182// this dialog is not modal
181ReplacePrompt::ReplacePrompt( QWidget *parent ) 183ReplacePrompt::ReplacePrompt( QWidget *parent )
182 : KDialogBase(parent, 0L, false, i18n( "Replace Text" ), 184 : KDialogBase(parent, 0L, false, i18n( "Replace Text" ),
183 User3 | User2 | User1 | Close, User3, true, 185 User3 | User2 | User1 | Close, User3, true,
184 i18n("&All"), i18n("&No"), i18n("&Yes")) { 186 i18n("&All"), i18n("&No"), i18n("&Yes")) {
185 187
186 QWidget *page = new QWidget(this); 188 QWidget *page = new QWidget(this);
187 setMainWidget(page); 189 setMainWidget(page);
188 190
189 QBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); 191 QBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
190 QLabel *label = new QLabel(i18n("Replace this occurence?"),page); 192 QLabel *label = new QLabel(i18n("Replace this occurence?"),page);
191 topLayout->addWidget(label ); 193 topLayout->addWidget(label );
192} 194}
193 195
194void ReplacePrompt::slotUser1( void ) { // All 196void ReplacePrompt::slotUser1( void ) { // All
195 done(KateView::srAll); 197 done(KateView::srAll);
196} 198}
197 199
198void ReplacePrompt::slotUser2( void ) { // No 200void ReplacePrompt::slotUser2( void ) { // No
199 done(KateView::srNo); 201 done(KateView::srNo);
200} 202}
201 203
202void ReplacePrompt::slotUser3( void ) { // Yes 204void ReplacePrompt::slotUser3( void ) { // Yes
203 accept(); 205 accept();
204} 206}
205 207
206void ReplacePrompt::done(int r) { 208void ReplacePrompt::done(int r) {
207 setResult(r); 209 setResult(r);
208 emit clicked(); 210 emit clicked();
209} 211}
210 212
211void ReplacePrompt::closeEvent(QCloseEvent *) { 213void ReplacePrompt::closeEvent(QCloseEvent *) {
212 reject(); 214 reject();
213} 215}
214 216
215GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max) 217GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max)
216 : KDialogBase(parent, 0L, true, i18n("Goto Line"), Ok | Cancel, Ok) { 218 : KDialogBase(parent, 0L, true, i18n("Goto Line"), Ok | Cancel, Ok) {
217 219
218 QWidget *page = new QWidget(this); 220 QWidget *page = new QWidget(this);
219 setMainWidget(page); 221 setMainWidget(page);
220 222
221 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); 223 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
222 e1 = new QSpinBox(page); 224 e1 = new QSpinBox(page);
223 e1->setMinValue(1); 225 e1->setMinValue(1);
224 e1->setMaxValue(max); 226 e1->setMaxValue(max);
225 e1->setValue((int)line); 227 e1->setValue((int)line);
226 228
227 QLabel *label = new QLabel( e1,i18n("&Goto Line:"), page ); 229 QLabel *label = new QLabel( e1,i18n("&Goto Line:"), page );
228 topLayout->addWidget(label); 230 topLayout->addWidget(label);
229 topLayout->addWidget(e1); 231 topLayout->addWidget(e1);
230 topLayout->addSpacing(spacingHint()); // A little bit extra space 232 topLayout->addSpacing(spacingHint()); // A little bit extra space
231 topLayout->addStretch(10); 233 topLayout->addStretch(10);
232 e1->setFocus(); 234 e1->setFocus();
233} 235}
234 236
235int GotoLineDialog::getLine() { 237int GotoLineDialog::getLine() {
236 return e1->value(); 238 return e1->value();
237} 239}
238 240
239const int IndentConfigTab::flags[] = {KateView::cfAutoIndent, KateView::cfSpaceIndent, 241const int IndentConfigTab::flags[] = {KateView::cfAutoIndent, KateView::cfSpaceIndent,
240 KateView::cfBackspaceIndents,KateView::cfTabIndents, KateView::cfKeepIndentProfile, KateView::cfKeepExtraSpaces}; 242 KateView::cfBackspaceIndents,KateView::cfTabIndents, KateView::cfKeepIndentProfile, KateView::cfKeepExtraSpaces};
241 243
242IndentConfigTab::IndentConfigTab(QWidget *parent, KateView *view) 244IndentConfigTab::IndentConfigTab(QWidget *parent, KateView *view)
243 : QWidget(parent, 0L) 245 : QWidget(parent, 0L)
244{ 246{
245 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() ); 247 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
246 int configFlags = view->config(); 248 int configFlags = view->config();
247 249
248 opt[0] = new QCheckBox(i18n("&Auto Indent"), this); 250 opt[0] = new QCheckBox(i18n("&Auto Indent"), this);
249 layout->addWidget(opt[0], 0, AlignLeft); 251 layout->addWidget(opt[0], 0, AlignLeft);
250 opt[0]->setChecked(configFlags & flags[0]); 252 opt[0]->setChecked(configFlags & flags[0]);
251 253
252 opt[1] = new QCheckBox(i18n("Indent With &Spaces"), this); 254 opt[1] = new QCheckBox(i18n("Indent With &Spaces"), this);
253 layout->addWidget(opt[1], 0, AlignLeft); 255 layout->addWidget(opt[1], 0, AlignLeft);
254 opt[1]->setChecked(configFlags & flags[1]); 256 opt[1]->setChecked(configFlags & flags[1]);
255 257
256 opt[2] = new QCheckBox(i18n("&Backspace Key Indents"), this); 258 opt[2] = new QCheckBox(i18n("&Backspace Key Indents"), this);
257 layout->addWidget(opt[2], 0, AlignLeft); 259 layout->addWidget(opt[2], 0, AlignLeft);
258 opt[2]->setChecked(configFlags & flags[2]); 260 opt[2]->setChecked(configFlags & flags[2]);
259 261
260 opt[3] = new QCheckBox(i18n("&Tab Key Indents"), this); 262 opt[3] = new QCheckBox(i18n("&Tab Key Indents"), this);
261 layout->addWidget(opt[3], 0, AlignLeft); 263 layout->addWidget(opt[3], 0, AlignLeft);
262 opt[3]->setChecked(configFlags & flags[3]); 264 opt[3]->setChecked(configFlags & flags[3]);
263 265
264 opt[4] = new QCheckBox(i18n("Keep Indent &Profile"), this); 266 opt[4] = new QCheckBox(i18n("Keep Indent &Profile"), this);
265 layout->addWidget(opt[4], 0, AlignLeft); 267 layout->addWidget(opt[4], 0, AlignLeft);
266// opt[4]->setChecked(configFlags & flags[4]); 268// opt[4]->setChecked(configFlags & flags[4]);
267 opt[4]->setChecked(true); 269 opt[4]->setChecked(true);
268 opt[4]->hide(); 270 opt[4]->hide();
269 271
270 opt[5] = new QCheckBox(i18n("&Keep Extra Spaces"), this); 272 opt[5] = new QCheckBox(i18n("&Keep Extra Spaces"), this);
271 layout->addWidget(opt[5], 0, AlignLeft); 273 layout->addWidget(opt[5], 0, AlignLeft);
272 opt[5]->setChecked(configFlags & flags[5]); 274 opt[5]->setChecked(configFlags & flags[5]);
273 275
274 layout->addStretch(); 276 layout->addStretch();
275 277
276 // What is this? help 278 // What is this? help
277 QWhatsThis::add(opt[0], i18n("When <b>Auto indent</b> is on, KateView will indent new lines to equal the indent on the previous line.<p>If the previous line is blank, the nearest line above with text is used")); 279 QWhatsThis::add(opt[0], i18n("When <b>Auto indent</b> is on, KateView will indent new lines to equal the indent on the previous line.<p>If the previous line is blank, the nearest line above with text is used"));
278 QWhatsThis::add(opt[1], i18n("Check this if you want to indent with spaces rather than tabs.<br>A Tab will be converted to <u>Tab-width</u> as set in the <b>edit</b> options")); 280 QWhatsThis::add(opt[1], i18n("Check this if you want to indent with spaces rather than tabs.<br>A Tab will be converted to <u>Tab-width</u> as set in the <b>edit</b> options"));
279 QWhatsThis::add(opt[2], i18n("This allows the <b>backspace</b> key to be used to indent.")); 281 QWhatsThis::add(opt[2], i18n("This allows the <b>backspace</b> key to be used to indent."));
280 QWhatsThis::add(opt[3], i18n("This allows the <b>tab</b> key to be used to indent.")); 282 QWhatsThis::add(opt[3], i18n("This allows the <b>tab</b> key to be used to indent."));
281 QWhatsThis::add(opt[4], i18n("This retains current indentation settings for future documents.")); 283 QWhatsThis::add(opt[4], i18n("This retains current indentation settings for future documents."));
282 QWhatsThis::add(opt[5], i18n("Indentations of more than the selected number of spaces will not be shortened.")); 284 QWhatsThis::add(opt[5], i18n("Indentations of more than the selected number of spaces will not be shortened."));
283} 285}
284 286
285void IndentConfigTab::getData(KateView *view) { 287void IndentConfigTab::getData(KateView *view) {
286 int configFlags, z; 288 int configFlags, z;
287 289
288 configFlags = view->config(); 290 configFlags = view->config();
289 for (z = 0; z < numFlags; z++) { 291 for (z = 0; z < numFlags; z++) {
290 configFlags &= ~flags[z]; 292 configFlags &= ~flags[z];
291 if (opt[z]->isChecked()) configFlags |= flags[z]; 293 if (opt[z]->isChecked()) configFlags |= flags[z];
292 } 294 }
293 view->setConfig(configFlags); 295 view->setConfig(configFlags);
294} 296}
295 297
296const int SelectConfigTab::flags[] = {KateView::cfPersistent, KateView::cfDelOnInput, 298const int SelectConfigTab::flags[] = {KateView::cfPersistent, KateView::cfDelOnInput,
297 KateView::cfMouseAutoCopy, KateView::cfSingleSelection, KateView::cfVerticalSelect, KateView::cfXorSelect}; 299 KateView::cfMouseAutoCopy, KateView::cfSingleSelection, KateView::cfVerticalSelect, KateView::cfXorSelect};
298 300
299SelectConfigTab::SelectConfigTab(QWidget *parent, KateView *view) 301SelectConfigTab::SelectConfigTab(QWidget *parent, KateView *view)
300 : QWidget(parent, 0L) 302 : QWidget(parent, 0L)
301{ 303{
302 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() ); 304 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
303 int configFlags = view->config(); 305 int configFlags = view->config();
304 306
305 opt[0] = new QCheckBox(i18n("&Persistent Selections"), this); 307 opt[0] = new QCheckBox(i18n("&Persistent Selections"), this);
306 layout->addWidget(opt[0], 0, AlignLeft); 308 layout->addWidget(opt[0], 0, AlignLeft);
307 opt[0]->setChecked(configFlags & flags[0]); 309 opt[0]->setChecked(configFlags & flags[0]);
308 310
309 opt[1] = new QCheckBox(i18n("&Overwrite Selections"), this); 311 opt[1] = new QCheckBox(i18n("&Overwrite Selections"), this);
310 layout->addWidget(opt[1], 0, AlignLeft); 312 layout->addWidget(opt[1], 0, AlignLeft);
311 opt[1]->setChecked(configFlags & flags[1]); 313 opt[1]->setChecked(configFlags & flags[1]);
312 314
313 opt[2] = new QCheckBox(i18n("Mouse &Autocopy"), this); 315 opt[2] = new QCheckBox(i18n("Mouse &Autocopy"), this);
314 layout->addWidget(opt[2], 0, AlignLeft); 316 layout->addWidget(opt[2], 0, AlignLeft);
315 opt[2]->setChecked(configFlags & flags[2]); 317 opt[2]->setChecked(configFlags & flags[2]);
316 318
317 opt[3] = new QCheckBox(i18n("&X11-like Single Selection"), this); 319 opt[3] = new QCheckBox(i18n("&X11-like Single Selection"), this);
318 layout->addWidget(opt[3], 0, AlignLeft); 320 layout->addWidget(opt[3], 0, AlignLeft);
319 opt[3]->setChecked(configFlags & flags[3]); 321 opt[3]->setChecked(configFlags & flags[3]);
320 322
321 opt[4] = new QCheckBox(i18n("&Vertical Selections"), this); 323 opt[4] = new QCheckBox(i18n("&Vertical Selections"), this);
322 layout->addWidget(opt[4], 0, AlignLeft); 324 layout->addWidget(opt[4], 0, AlignLeft);
323 opt[4]->setChecked(configFlags & flags[4]); 325 opt[4]->setChecked(configFlags & flags[4]);
324 326
325 opt[5] = new QCheckBox(i18n("&Toggle Old"), this); 327 opt[5] = new QCheckBox(i18n("&Toggle Old"), this);
326 layout->addWidget(opt[5], 0, AlignLeft); 328 layout->addWidget(opt[5], 0, AlignLeft);
327 opt[5]->setChecked(configFlags & flags[5]); 329 opt[5]->setChecked(configFlags & flags[5]);
328 330
329 layout->addStretch(); 331 layout->addStretch();
330 332
331 // What is this? help 333 // What is this? help
332 QWhatsThis::add(opt[0], i18n("Enabling this prevents key input or cursor movement by way of the arrow keys from causing the elimination of text selection.<p><b>Note:</b> If the Overwrite Selections option is activated then any typed character input or paste operation will replace the selected text.")); 334 QWhatsThis::add(opt[0], i18n("Enabling this prevents key input or cursor movement by way of the arrow keys from causing the elimination of text selection.<p><b>Note:</b> If the Overwrite Selections option is activated then any typed character input or paste operation will replace the selected text."));
333 QWhatsThis::add(opt[1], i18n("When this is on, any keyed character input or paste operation will replace the selected text.")); 335 QWhatsThis::add(opt[1], i18n("When this is on, any keyed character input or paste operation will replace the selected text."));
334 QWhatsThis::add(opt[2], i18n("When this is on, any text selected with the mouse will be automatically copied to the clipboard.")); 336 QWhatsThis::add(opt[2], i18n("When this is on, any text selected with the mouse will be automatically copied to the clipboard."));
335 QWhatsThis::add(opt[3], i18n("Not implemented yet.")); 337 QWhatsThis::add(opt[3], i18n("Not implemented yet."));
336 QWhatsThis::add(opt[4], i18n("Enabling this allows you to make vertical selections.")); 338 QWhatsThis::add(opt[4], i18n("Enabling this allows you to make vertical selections."));
337 QWhatsThis::add(opt[5], i18n("Not yet implemented.")); 339 QWhatsThis::add(opt[5], i18n("Not yet implemented."));
338} 340}
339 341
340void SelectConfigTab::getData(KateView *view) { 342void SelectConfigTab::getData(KateView *view) {
341 int configFlags, z; 343 int configFlags, z;
342 344
343 configFlags = view->config(); 345 configFlags = view->config();
344 for (z = 0; z < numFlags; z++) { 346 for (z = 0; z < numFlags; z++) {
345 configFlags &= ~flags[z]; // clear flag 347 configFlags &= ~flags[z]; // clear flag
346 if (opt[z]->isChecked()) configFlags |= flags[z]; // set flag if checked 348 if (opt[z]->isChecked()) configFlags |= flags[z]; // set flag if checked
347 } 349 }
348 view->setConfig(configFlags); 350 view->setConfig(configFlags);
349} 351}
350 352
351const int EditConfigTab::flags[] = {KateView::cfWordWrap, KateView::cfReplaceTabs, KateView::cfRemoveSpaces, 353const int EditConfigTab::flags[] = {KateView::cfWordWrap, KateView::cfReplaceTabs, KateView::cfRemoveSpaces,
352 KateView::cfAutoBrackets, KateView::cfGroupUndo, KateView::cfShowTabs, KateView::cfSmartHome, 354 KateView::cfAutoBrackets, KateView::cfGroupUndo, KateView::cfShowTabs, KateView::cfSmartHome,
353 KateView::cfPageUDMovesCursor, KateView::cfWrapCursor}; 355 KateView::cfPageUDMovesCursor, KateView::cfWrapCursor};
354 356
355EditConfigTab::EditConfigTab(QWidget *parent, KateView *view) 357EditConfigTab::EditConfigTab(QWidget *parent, KateView *view)
356 : QWidget(parent, 0L) { 358 : QWidget(parent, 0L) {
357 359
358 QHBoxLayout *mainLayout; 360 QHBoxLayout *mainLayout;
359 QVBoxLayout *cbLayout, *leLayout; 361 QVBoxLayout *cbLayout, *leLayout;
360 int configFlags; 362 int configFlags;
361 363
362 mainLayout = new QHBoxLayout(this, 0, KDialog::spacingHint() ); 364 mainLayout = new QHBoxLayout(this, 0, KDialog::spacingHint() );
363 365
364 // checkboxes 366 // checkboxes
365 cbLayout = new QVBoxLayout( mainLayout ); 367 cbLayout = new QVBoxLayout( mainLayout );
366 configFlags = view->config(); 368 configFlags = view->config();
367 369
368 opt[0] = new QCheckBox(i18n("&Word wrap"), this); 370 opt[0] = new QCheckBox(i18n("&Word wrap"), this);
369 cbLayout->addWidget(opt[0], 0, AlignLeft); 371 cbLayout->addWidget(opt[0], 0, AlignLeft);
370 opt[0]->setChecked(view->doc()->wordWrap()); 372 opt[0]->setChecked(view->doc()->wordWrap());
371 373
372 opt[1] = new QCheckBox(i18n("Replace &tabs with spaces"), this); 374 opt[1] = new QCheckBox(i18n("Replace &tabs with spaces"), this);
373 cbLayout->addWidget(opt[1], 0, AlignLeft); 375 cbLayout->addWidget(opt[1], 0, AlignLeft);
374 opt[1]->setChecked(configFlags & flags[1]); 376 opt[1]->setChecked(configFlags & flags[1]);
375 377
376 opt[2] = new QCheckBox(i18n("&Remove trailing spaces"), this); 378 opt[2] = new QCheckBox(i18n("&Remove trailing spaces"), this);
377 cbLayout->addWidget(opt[2], 0, AlignLeft); 379 cbLayout->addWidget(opt[2], 0, AlignLeft);
378 opt[2]->setChecked(configFlags & flags[2]); 380 opt[2]->setChecked(configFlags & flags[2]);
379 381
380 opt[3] = new QCheckBox(i18n("&Auto brackets"), this); 382 opt[3] = new QCheckBox(i18n("&Auto brackets"), this);
381 cbLayout->addWidget(opt[3], 0, AlignLeft); 383 cbLayout->addWidget(opt[3], 0, AlignLeft);
382 opt[3]->setChecked(configFlags & flags[3]); 384 opt[3]->setChecked(configFlags & flags[3]);
383 385
384 opt[4] = new QCheckBox(i18n("Group &undos"), this); 386 opt[4] = new QCheckBox(i18n("Group &undos"), this);
385 cbLayout->addWidget(opt[4], 0, AlignLeft); 387 cbLayout->addWidget(opt[4], 0, AlignLeft);
386 opt[4]->setChecked(configFlags & flags[4]); 388 opt[4]->setChecked(configFlags & flags[4]);
387 389
388 opt[5] = new QCheckBox(i18n("&Show tabs"), this); 390 opt[5] = new QCheckBox(i18n("&Show tabs"), this);
389 cbLayout->addWidget(opt[5], 0, AlignLeft); 391 cbLayout->addWidget(opt[5], 0, AlignLeft);
390 opt[5]->setChecked(configFlags & flags[5]); 392 opt[5]->setChecked(configFlags & flags[5]);
391 393
392 opt[6] = new QCheckBox(i18n("Smart &home"), this); 394 opt[6] = new QCheckBox(i18n("Smart &home"), this);
393 cbLayout->addWidget(opt[6], 0, AlignLeft); 395 cbLayout->addWidget(opt[6], 0, AlignLeft);
394 opt[6]->setChecked(configFlags & flags[6]); 396 opt[6]->setChecked(configFlags & flags[6]);
395 397
396 opt[7] = new QCheckBox(i18n("&Page up/down moves cursor"), this); 398 opt[7] = new QCheckBox(i18n("&Page up/down moves cursor"), this);
397 cbLayout->addWidget(opt[7], 0, AlignLeft); 399 cbLayout->addWidget(opt[7], 0, AlignLeft);
398 opt[7]->setChecked(configFlags & flags[7]); 400 opt[7]->setChecked(configFlags & flags[7]);
399 401
400 opt[8] = new QCheckBox(i18n("Wrap &cursor"), this); 402 opt[8] = new QCheckBox(i18n("Wrap &cursor"), this);
401 cbLayout->addWidget(opt[8], 0, AlignLeft); 403 cbLayout->addWidget(opt[8], 0, AlignLeft);
402 opt[8]->setChecked(configFlags & flags[8]); 404 opt[8]->setChecked(configFlags & flags[8]);
403 405
404 cbLayout->addStretch(); 406 cbLayout->addStretch();
405 407
406 // edit lines 408 // edit lines
407 leLayout = new QVBoxLayout(); 409 leLayout = new QVBoxLayout();
408 mainLayout->addLayout(leLayout,10); 410 mainLayout->addLayout(leLayout,10);
409 411
410 e1 = new QSpinBox(this); 412 e1 = new QSpinBox(this);
411 e1->setMinValue(20); 413 e1->setMinValue(20);
412 e1->setMaxValue( 200); 414 e1->setMaxValue( 200);
413 e1->setValue((int)(view->doc()->wordWrapAt())); 415 e1->setValue((int)(view->doc()->wordWrapAt()));
414#warning fixme e1->setLabel(i18n("Wrap Words At:")); 416#warning fixme e1->setLabel(i18n("Wrap Words At:"));
415 417
416 e2 = new QSpinBox(this); 418 e2 = new QSpinBox(this);
417 e2->setMinValue(1); 419 e2->setMinValue(1);
418 e2->setMaxValue(16); 420 e2->setMaxValue(16);
419 e2->setValue((int)view->tabWidth()); 421 e2->setValue((int)view->tabWidth());
420 422
421#warning fixme e2->setLabel(i18n("Tab/Indent Width:")); 423#warning fixme e2->setLabel(i18n("Tab/Indent Width:"));
422 424
423 e3 = new QSpinBox(this); 425 e3 = new QSpinBox(this);
424 e3->setMinValue(5); 426 e3->setMinValue(5);
425 e3->setMaxValue( 30000); 427 e3->setMaxValue( 30000);
426#warning fixme e3->setLabel(i18n("Undo steps:")); 428#warning fixme e3->setLabel(i18n("Undo steps:"));
427 e3->setValue((int)view->undoSteps()); 429 e3->setValue((int)view->undoSteps());
428 430
429 leLayout->addWidget(e1, 0, AlignLeft); 431 leLayout->addWidget(e1, 0, AlignLeft);
430 leLayout->addWidget(e2, 0, AlignLeft); 432 leLayout->addWidget(e2, 0, AlignLeft);
431 leLayout->addWidget(e3, 0, AlignLeft); 433 leLayout->addWidget(e3, 0, AlignLeft);
432 434
433 435
434 QVBox *box = new QVBox (this); 436 QVBox *box = new QVBox (this);
435 leLayout->addWidget (box, 0, AlignLeft); 437 leLayout->addWidget (box, 0, AlignLeft);
436 438
437 new QLabel (i18n("Encoding:"), box); 439 new QLabel (i18n("Encoding:"), box);
438 440
439 encoding = new QComboBox(box); 441 encoding = new QComboBox(box);
440#warning fixme 442#warning fixme
441#if 0 443#if 0
442 encoding->insertStringList (KGlobal::charsets()->availableEncodingNames()); 444 encoding->insertStringList (KGlobal::charsets()->availableEncodingNames());
443 encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding())); 445 encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding()));
444#endif 446#endif
445 leLayout->addStretch(); 447 leLayout->addStretch();
446 448
447 // What is this? help 449 // What is this? help
448 QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications.")); 450 QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications."));
449 QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line.")); 451 QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line."));
450 QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry.")); 452 QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry."));
451 QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs.")); 453 QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs."));
452 QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text.")); 454 QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text."));
453 QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor.")); 455 QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor."));
454 QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once.")); 456 QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once."));
455 QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text.")); 457 QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text."));
456 QWhatsThis::add(opt[6], i18n("Not yet implemented.")); 458 QWhatsThis::add(opt[6], i18n("Not yet implemented."));
457 QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text.")); 459 QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text."));
458 QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory.")); 460 QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory."));
459 QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers.")); 461 QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers."));
460} 462}
461 463
462void EditConfigTab::getData(KateView *view) 464void EditConfigTab::getData(KateView *view)
463{ 465{
464 int configFlags, z; 466 int configFlags, z;
465 467
466 configFlags = view->config(); 468 configFlags = view->config();
467 for (z = 1; z < numFlags; z++) { 469 for (z = 1; z < numFlags; z++) {
468 configFlags &= ~flags[z]; 470 configFlags &= ~flags[z];
469 if (opt[z]->isChecked()) configFlags |= flags[z]; 471 if (opt[z]->isChecked()) configFlags |= flags[z];
470 } 472 }
471 view->setConfig(configFlags); 473 view->setConfig(configFlags);
472 474
473 view->setEncoding (encoding->currentText()); 475 view->setEncoding (encoding->currentText());
474 view->doc()->setWordWrapAt(e1->value()); 476 view->doc()->setWordWrapAt(e1->value());
475 view->doc()->setWordWrap (opt[0]->isChecked()); 477 view->doc()->setWordWrap (opt[0]->isChecked());
476 view->setTabWidth(e2->value()); 478 view->setTabWidth(e2->value());
477 view->setUndoSteps(e3->value()); 479 view->setUndoSteps(e3->value());
478} 480}
479 481
480ColorConfig::ColorConfig( QWidget *parent, char *name ) 482ColorConfig::ColorConfig( QWidget *parent, char *name )
481 : QWidget( parent, name ) 483 : QWidget( parent, name )
482{ 484{
483 QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint()); 485 QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint());
484 glay->setColStretch(1,1); 486 glay->setColStretch(1,1);
485 glay->setRowStretch(5,1); 487 glay->setRowStretch(5,1);
486 488
487 QLabel *label; 489 QLabel *label;
488 490
489 label = new QLabel( i18n("Background:"), this); 491 label = new QLabel( i18n("Background:"), this);
490 label->setAlignment( AlignRight|AlignVCenter ); 492 label->setAlignment( AlignRight|AlignVCenter );
491 m_back = new KColorButton( this ); 493 m_back = new KColorButton( this );
492 glay->addWidget( label, 0, 0 ); 494 glay->addWidget( label, 0, 0 );
493 glay->addWidget( m_back, 0, 1 ); 495 glay->addWidget( m_back, 0, 1 );
494 496
495 label = new QLabel( i18n("Selected:"), this); 497 label = new QLabel( i18n("Selected:"), this);
496 label->setAlignment( AlignRight|AlignVCenter ); 498 label->setAlignment( AlignRight|AlignVCenter );
497 m_selected = new KColorButton( this ); 499 m_selected = new KColorButton( this );
498 glay->addWidget( label, 2, 0 ); 500 glay->addWidget( label, 2, 0 );
499 glay->addWidget( m_selected, 2, 1 ); 501 glay->addWidget( m_selected, 2, 1 );
500 502
501 // QWhatsThis help 503 // QWhatsThis help
502 QWhatsThis::add(m_back, i18n("Sets the background color of the editing area")); 504 QWhatsThis::add(m_back, i18n("Sets the background color of the editing area"));
503 QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the &quot;<b>Configure Highlighting</b>&quot; dialog.")); 505 QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the &quot;<b>Configure Highlighting</b>&quot; dialog."));
504} 506}
505 507
506 508
507ColorConfig::~ColorConfig() 509ColorConfig::~ColorConfig()
508{ 510{
509} 511}
510 512
511void ColorConfig::setColors(QColor *colors) 513void ColorConfig::setColors(QColor *colors)
512{ 514{
513 m_back->setColor( colors[0] ); 515 m_back->setColor( colors[0] );
514 m_selected->setColor( colors[1] ); 516 m_selected->setColor( colors[1] );
515} 517}
516 518
517void ColorConfig::getColors(QColor *colors) 519void ColorConfig::getColors(QColor *colors)
518{ 520{
519 colors[0] = m_back->color(); 521 colors[0] = m_back->color();
520 colors[1] = m_selected->color(); 522 colors[1] = m_selected->color();
521} 523}
522 524
523FontConfig::FontConfig( QWidget *parent, char *name ) 525FontConfig::FontConfig( QWidget *parent, char *name )
524 : QWidget( parent, name ) 526 : QWidget( parent, name )
525{ 527{
526 // sizemanagment 528 // sizemanagment
527 QGridLayout *grid = new QGridLayout( this, 1, 1 ); 529 QGridLayout *grid = new QGridLayout( this, 1, 1 );
528// QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); 530// QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
529// QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); 531// QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
530// int size = cfg. readNumEntry ( "FontSize", 10 ); 532// int size = cfg. readNumEntry ( "FontSize", 10 );
531// OFontSelector *m_fontselect; 533// OFontSelector *m_fontselect;
532 534
533 m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" ); 535 m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" );
534// m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); 536// m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
535// QWhatsThis::add( m_fontselect, 537// QWhatsThis::add( m_fontselect,
536// tr( "Select the desired name, style and size of the default font applications will use." ) ); 538// tr( "Select the desired name, style and size of the default font applications will use." ) );
537 539
538 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), 540 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)),
539 this, SLOT( slotFontSelected(const QFont&))); 541 this, SLOT( slotFontSelected(const QFont&)));
540 grid->addWidget( m_fontselect, 0, 0); 542 grid->addWidget( m_fontselect, 0, 0);
541 543
542 544
543// #if 0 545// #if 0
544// m_fontchooser = new KFontChooser ( this ); 546// m_fontchooser = new KFontChooser ( this );
545// m_fontchooser->enableColumn(KFontChooser::StyleList, false); 547// m_fontchooser->enableColumn(KFontChooser::StyleList, false);
546// grid->addWidget( m_fontchooser, 0, 0); 548// grid->addWidget( m_fontchooser, 0, 0);
547 549
548// connect (m_fontchooser, SIGNAL (fontSelected(const QFont&)), this, SLOT (slotFontSelected(const QFont&))); 550// connect (m_fontchooser, SIGNAL (fontSelected(const QFont&)), this, SLOT (slotFontSelected(const QFont&)));
549// #endif 551// #endif
550} 552}
551 553
552FontConfig::~FontConfig() 554FontConfig::~FontConfig()
553{ 555{
554} 556}
555 557
556void FontConfig::setFont ( const QFont &font ) 558void FontConfig::setFont ( const QFont &font )
557{ 559{
558//#if 0 560//#if 0
559m_fontselect->setFont (font); 561m_fontselect->setFont (font);
560 myFont = font; 562 myFont = font;
561//#endif 563//#endif
562} 564}
563 565
564void FontConfig::slotFontSelected( const QFont &font ) 566void FontConfig::slotFontSelected( const QFont &font )
565{ 567{
566 myFont = font; 568 myFont = font;
567} 569}
568 570
569 571
570 572
571 573
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.h b/noncore/apps/tinykate/libkate/view/kateviewdialog.h
index 98d8799..d081152 100644
--- a/noncore/apps/tinykate/libkate/view/kateviewdialog.h
+++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.h
@@ -1,196 +1,196 @@
1/*************************************************************************** 1/***************************************************************************
2 kateviewdialog.h - description 2 kateviewdialog.h - description
3 ------------------- 3 -------------------
4 copyright : (C) 2001 by The Kate Team 4 copyright : (C) 2001 by The Kate Team
5 (C) 2002 by Joseph Wenninger 5 (C) 2002 by Joseph Wenninger
6 email : kwrite-devel@kde.org 6 email : kwrite-devel@kde.org
7 jowenn@kde.org 7 jowenn@kde.org
8 8
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19// Dialogs 19// Dialogs
20 20
21#ifndef _KWDIALOG_H_ 21#ifndef _KWDIALOG_H_
22#define _KWDIALOG_H_ 22#define _KWDIALOG_H_
23 23
24 24
25class QCheckBox; 25class QCheckBox;
26class QLineEdit; 26class QLineEdit;
27class QPushButton; 27class QPushButton;
28class QRadioButton; 28class QRadioButton;
29class QSpinBox; 29class QSpinBox;
30class KColorButton; 30class KColorButton;
31class QComboBox; 31class QComboBox;
32 32
33#include <kdialogbase.h> 33#include <kdialogbase.h>
34#include <opie2/ofontselector.h> 34#include <opie2/ofontselector.h>
35#include "kateview.h" 35#include "kateview.h"
36 36
37class SearchDialog : public KDialogBase 37class SearchDialog : public KDialogBase
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41 public: 41 public:
42 SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags ); 42 SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags );
43 QString getSearchFor(); 43 QString getSearchFor();
44 QString getReplaceWith(); 44 QString getReplaceWith();
45 int getFlags(); 45 int getFlags();
46 void setSearchText( const QString &searchstr ); 46 void setSearchText( const QString &searchstr );
47 47
48 protected slots: 48 protected slots:
49 void slotOk(); 49 void slotOk();
50 50
51 protected: 51 protected:
52 QComboBox *m_search; 52 QComboBox *m_search;
53 QComboBox *m_replace; 53 QComboBox *m_replace;
54 QCheckBox *m_opt1; 54 QCheckBox *m_opt1;
55 QCheckBox *m_opt2; 55 QCheckBox *m_opt2;
56 QCheckBox *m_opt3; 56 QCheckBox *m_opt3;
57 QCheckBox *m_optRegExp; 57 QCheckBox *m_optRegExp;
58 QCheckBox *m_opt4; 58 QCheckBox *m_opt4;
59 QCheckBox *m_opt5; 59 QCheckBox *m_opt5;
60 QCheckBox *m_opt6; 60 QCheckBox *m_opt6;
61}; 61};
62 62
63class ReplacePrompt : public KDialogBase 63class ReplacePrompt : public KDialogBase
64{ 64{
65 Q_OBJECT 65 Q_OBJECT
66 66
67 public: 67 public:
68 68
69 ReplacePrompt(QWidget *parent); 69 ReplacePrompt(QWidget *parent);
70 70
71 signals: 71 signals:
72 72
73 void clicked(); 73 void clicked();
74 74
75 protected slots: 75 protected slots:
76 76
77 void slotUser1( void ); // All 77 void slotUser1( void ); // All
78 void slotUser2( void ); // No 78 void slotUser2( void ); // No
79 void slotUser3( void ); // Yes 79 void slotUser3( void ); // Yes
80 virtual void done(int); 80 virtual void done(int);
81 81
82 protected: 82 protected:
83 83
84 void closeEvent(QCloseEvent *); 84 void closeEvent(QCloseEvent *);
85}; 85};
86 86
87class GotoLineDialog : public KDialogBase 87class GotoLineDialog : public KDialogBase
88{ 88{
89 Q_OBJECT 89 Q_OBJECT
90 90
91 public: 91 public:
92 92
93 GotoLineDialog(QWidget *parent, int line, int max); 93 GotoLineDialog(QWidget *parent, int line, int max);
94 int getLine(); 94 int getLine();
95 95
96 protected: 96 protected:
97 97
98 QSpinBox *e1; 98 QSpinBox *e1;
99 QPushButton *btnOK; 99 QPushButton *btnOK;
100}; 100};
101 101
102class IndentConfigTab : public QWidget 102class IndentConfigTab : public QWidget
103{ 103{
104 Q_OBJECT 104 Q_OBJECT
105 105
106 public: 106 public:
107 107
108 IndentConfigTab(QWidget *parent, KateView *); 108 IndentConfigTab(QWidget *parent, KateView *);
109 void getData(KateView *); 109 void getData(KateView *);
110 110
111 protected: 111 protected:
112 112
113 static const int numFlags = 6; 113 static const int numFlags = 6;
114 static const int flags[numFlags]; 114 static const int flags[numFlags];
115 QCheckBox *opt[numFlags]; 115 QCheckBox *opt[numFlags];
116}; 116};
117 117
118class SelectConfigTab : public QWidget 118class SelectConfigTab : public QWidget
119{ 119{
120 Q_OBJECT 120 Q_OBJECT
121 121
122 public: 122 public:
123 123
124 SelectConfigTab(QWidget *parent, KateView *); 124 SelectConfigTab(QWidget *parent, KateView *);
125 void getData(KateView *); 125 void getData(KateView *);
126 126
127 protected: 127 protected:
128 128
129 static const int numFlags = 6; 129 static const int numFlags = 6;
130 static const int flags[numFlags]; 130 static const int flags[numFlags];
131 QCheckBox *opt[numFlags]; 131 QCheckBox *opt[numFlags];
132}; 132};
133 133
134class EditConfigTab : public QWidget 134class EditConfigTab : public QWidget
135{ 135{
136 Q_OBJECT 136 Q_OBJECT
137 137
138 public: 138 public:
139 139
140 EditConfigTab(QWidget *parent, KateView *); 140 EditConfigTab(QWidget *parent, KateView *);
141 void getData(KateView *); 141 void getData(KateView *);
142 142
143 protected: 143 protected:
144 144
145 static const int numFlags = 9; 145 static const int numFlags = 9;
146 static const int flags[numFlags]; 146 static const int flags[numFlags];
147 QCheckBox *opt[numFlags]; 147 QCheckBox *opt[numFlags];
148 QComboBox *encoding; 148 QComboBox *encoding;
149 149
150 150
151 QSpinBox *e1; 151 QSpinBox *e1;
152 QSpinBox *e2; 152 QSpinBox *e2;
153 QSpinBox *e3; 153 QSpinBox *e3;
154}; 154};
155 155
156class ColorConfig : public QWidget 156class ColorConfig : public QWidget
157{ 157{
158 Q_OBJECT 158 Q_OBJECT
159 159
160public: 160public:
161 161
162 ColorConfig( QWidget *parent = 0, char *name = 0 ); 162 ColorConfig( QWidget *parent = 0, char *name = 0 );
163 ~ColorConfig(); 163 ~ColorConfig();
164 164
165 void setColors( QColor * ); 165 void setColors( QColor * );
166 void getColors( QColor * ); 166 void getColors( QColor * );
167 167
168private: 168private:
169 169
170 KColorButton *m_back; 170 KColorButton *m_back;
171 KColorButton *m_selected; 171 KColorButton *m_selected;
172}; 172};
173 173
174class FontConfig : public QWidget 174class FontConfig : public QWidget
175{ 175{
176 Q_OBJECT 176 Q_OBJECT
177 177
178public: 178public:
179 179
180 FontConfig( QWidget *parent = 0, char *name = 0 ); 180 FontConfig( QWidget *parent = 0, char *name = 0 );
181 ~FontConfig(); 181 ~FontConfig();
182 182
183 void setFont ( const QFont &font ); 183 void setFont ( const QFont &font );
184 QFont getFont ( ) { return myFont; }; 184 QFont getFont ( ) { return myFont; };
185 185
186 private: 186 private:
187 Opie::OFontSelector *m_fontselect; 187 Opie::Opie::Ui::OFontSelector *m_fontselect;
188// class KFontChooser *m_fontchooser; 188// class KFontChooser *m_fontchooser;
189 QFont myFont; 189 QFont myFont;
190 190
191 private slots: 191 private slots:
192 void slotFontSelected( const QFont &font ); 192 void slotFontSelected( const QFont &font );
193}; 193};
194 194
195 195
196#endif //_KWDIALOG_H_ 196#endif //_KWDIALOG_H_
diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp
index e62930c..c14d10a 100644
--- a/noncore/apps/tinykate/main.cpp
+++ b/noncore/apps/tinykate/main.cpp
@@ -1,22 +1,25 @@
1/*************************************************************************** 1/***************************************************************************
2
2 main.cpp 3 main.cpp
3 ------------------- 4 -------------------
4 begin : November 2002 5 begin : November 2002
5 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
6 ***************************************************************************/ 7 ***************************************************************************/
7 8
8/*************************************************************************** 9/***************************************************************************
9 * * 10 * *
10 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation. * 13 * the Free Software Foundation. *
13 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
14 * * 15 * *
15 ***************************************************************************/ 16 ***************************************************************************/
16 17
17#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
18 19
19#include "tinykate.h" 20#include "tinykate.h"
20 21
22using namespace Opie::Core;
23
21OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) 24OPIE_EXPORT_APP( OApplicationFactory<TinyKate> )
22 25
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 32c1eab..3c9a637 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -1,278 +1,279 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.cpp 2 tinykate.cpp
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free softwaSre; you can redistribute it and/or modify * 11 * This program is free softwaSre; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <qaction.h> 17#include <qaction.h>
18#include <qtoolbutton.h> 18#include <qtoolbutton.h>
19#include <qmenubar.h> 19#include <qmenubar.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <opie2/ofiledialog.h> 23#include <opie2/ofiledialog.h>
24 24
25#include "tinykate.h" 25#include "tinykate.h"
26 26
27#include <katedocument.h> 27#include <katedocument.h>
28#include <kglobal.h> 28#include <kglobal.h>
29 29
30using namespace Opie::Ui;
30TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 31TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
31 QMainWindow( parent, name, f ) 32 QMainWindow( parent, name, f )
32{ 33{
33 shutDown=false; 34 shutDown=false;
34 nextUnnamed=0; 35 nextUnnamed=0;
35 currentView=0; 36 currentView=0;
36 viewCount=0; 37 viewCount=0;
37 setCaption(tr("TinyKATE")); 38 setCaption(tr("TinyKATE"));
38 KGlobal::setAppName("TinyKATE"); 39 KGlobal::setAppName("TinyKATE");
39 40
40 QMenuBar *mb = new QMenuBar( this ); 41 QMenuBar *mb = new QMenuBar( this );
41 mb->setMargin( 0 ); 42 mb->setMargin( 0 );
42 43
43 tabwidget=new OTabWidget(this); 44 tabwidget=new OTabWidget(this);
44 setCentralWidget(tabwidget); 45 setCentralWidget(tabwidget);
45 connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); 46 connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*)));
46 47
47//FILE ACTIONS 48//FILE ACTIONS
48 QPopupMenu *popup = new QPopupMenu( this ); 49 QPopupMenu *popup = new QPopupMenu( this );
49 50
50 // Action for creating a new document 51 // Action for creating a new document
51 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 52 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
52 a->addTo( popup ); 53 a->addTo( popup );
53 connect(a, SIGNAL(activated()), this, SLOT(slotNew())); 54 connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
54 55
55 // Action for opening an exisiting document 56 // Action for opening an exisiting document
56 a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); 57 a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 );
57 a->addTo(popup); 58 a->addTo(popup);
58 connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); 59 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
59 60
60 61
61 // Action for saving document 62 // Action for saving document
62 a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); 63 a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
63 a->addTo(popup); 64 a->addTo(popup);
64 connect(a, SIGNAL(activated()), this, SLOT(slotSave())); 65 connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
65 66
66 // Action for saving document to a new name 67 // Action for saving document to a new name
67 a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); 68 a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
68 a->addTo(popup); 69 a->addTo(popup);
69 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); 70 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
70 71
71 // Action for closing the currently active document 72 // Action for closing the currently active document
72 a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); 73 a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 );
73 a->addTo(popup); 74 a->addTo(popup);
74 connect(a, SIGNAL(activated()), this, SLOT(slotClose())); 75 connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
75 76
76 77
77 mb->insertItem(tr("File"),popup); 78 mb->insertItem(tr("File"),popup);
78 79
79//EDIT ACTIONS 80//EDIT ACTIONS
80 81
81 // Action for cutting text 82 // Action for cutting text
82 editCut = new QToolButton( 0 ); 83 editCut = new QToolButton( 0 );
83 editCut->setAutoRaise( true ); 84 editCut->setAutoRaise( true );
84 editCut->setIconSet( Resource::loadPixmap( "cut" ) ); 85 editCut->setIconSet( Resource::loadPixmap( "cut" ) );
85 86
86 // Action for Copying text 87 // Action for Copying text
87 editCopy = new QToolButton( 0 ); 88 editCopy = new QToolButton( 0 );
88 editCopy->setAutoRaise( true ); 89 editCopy->setAutoRaise( true );
89 editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); 90 editCopy->setIconSet( Resource::loadPixmap( "copy" ) );
90 91
91 // Action for pasting text 92 // Action for pasting text
92 editPaste = new QToolButton( 0 ); 93 editPaste = new QToolButton( 0 );
93 editPaste->setAutoRaise( true ); 94 editPaste->setAutoRaise( true );
94 editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); 95 editPaste->setIconSet( Resource::loadPixmap( "paste" ) );
95 96
96 // Action for finding / replacing text 97 // Action for finding / replacing text
97 editFindReplace = new QToolButton( 0 ); 98 editFindReplace = new QToolButton( 0 );
98 editFindReplace->setAutoRaise( true ); 99 editFindReplace->setAutoRaise( true );
99 editFindReplace->setIconSet( Resource::loadPixmap("find") ); 100 editFindReplace->setIconSet( Resource::loadPixmap("find") );
100 101
101 // Action for undo 102 // Action for undo
102 editUndo = new QToolButton( 0 ); 103 editUndo = new QToolButton( 0 );
103 editUndo->setAutoRaise( true ); 104 editUndo->setAutoRaise( true );
104 editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); 105 editUndo->setIconSet( Resource::loadPixmap( "undo" ) );
105 106
106 // Action for redo 107 // Action for redo
107 editRedo = new QToolButton( 0 ); 108 editRedo = new QToolButton( 0 );
108 editRedo->setAutoRaise( true ); 109 editRedo->setAutoRaise( true );
109 editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); 110 editRedo->setIconSet( Resource::loadPixmap( "redo" ) );
110 111
111//VIEW ACITONS 112//VIEW ACITONS
112 popup = new QPopupMenu( this ); 113 popup = new QPopupMenu( this );
113 114
114 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); 115 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
115 viewIncFontSizes->addTo( popup ); 116 viewIncFontSizes->addTo( popup );
116 117
117 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); 118 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
118 viewDecFontSizes->addTo( popup ); 119 viewDecFontSizes->addTo( popup );
119 120
120 mb->insertItem(tr("View"),popup); 121 mb->insertItem(tr("View"),popup);
121 122
122 popup = new QPopupMenu( this ); 123 popup = new QPopupMenu( this );
123 mb->insertItem(tr("Utils"),popup); 124 mb->insertItem(tr("Utils"),popup);
124 125
125 126
126 mb->insertItem( editCut ); 127 mb->insertItem( editCut );
127 mb->insertItem( editCopy ); 128 mb->insertItem( editCopy );
128 mb->insertItem( editPaste ); 129 mb->insertItem( editPaste );
129 mb->insertItem( editFindReplace ); 130 mb->insertItem( editFindReplace );
130 mb->insertItem( editUndo ); 131 mb->insertItem( editUndo );
131 mb->insertItem( editRedo ); 132 mb->insertItem( editRedo );
132 133
133 134
134//Highlight management 135//Highlight management
135 hlmenu=new QPopupMenu(this); 136 hlmenu=new QPopupMenu(this);
136 HlManager *hlm=HlManager::self(); 137 HlManager *hlm=HlManager::self();
137 for (int i=0;i<hlm->highlights();i++) 138 for (int i=0;i<hlm->highlights();i++)
138 { 139 {
139 hlmenu->insertItem(hlm->hlName(i),i); 140 hlmenu->insertItem(hlm->hlName(i),i);
140 } 141 }
141 popup->insertItem(tr("Highlighting"),hlmenu); 142 popup->insertItem(tr("Highlighting"),hlmenu);
142 143
143 144
144 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 145 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
145 utilSettings->addTo( popup); 146 utilSettings->addTo( popup);
146 147
147 if( qApp->argc() > 1) open(qApp->argv()[1]); 148 if( qApp->argc() > 1) open(qApp->argv()[1]);
148 else slotNew(); 149 else slotNew();
149 150
150} 151}
151 152
152TinyKate::~TinyKate( ) 153TinyKate::~TinyKate( )
153{ 154{
154 qWarning("TinyKate destructor\n"); 155 qWarning("TinyKate destructor\n");
155 156
156 shutDown=true; 157 shutDown=true;
157 while (currentView!=0) { 158 while (currentView!=0) {
158 slotClose(); 159 slotClose();
159 } 160 }
160 161
161 if( KGlobal::config() != 0 ) { 162 if( KGlobal::config() != 0 ) {
162 qWarning("deleting KateConfig object..\n"); 163 qWarning("deleting KateConfig object..\n");
163 delete KGlobal::config(); 164 delete KGlobal::config();
164 } 165 }
165} 166}
166 167
167void TinyKate::slotOpen( ) 168void TinyKate::slotOpen( )
168{ 169{
169 QString filename = Opie::OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 170 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
170 QString::null); 171 QString::null);
171 if (!filename.isEmpty()) { 172 if (!filename.isEmpty()) {
172 open(filename); 173 open(filename);
173 } 174 }
174} 175}
175 176
176void TinyKate::open(const QString & filename) 177void TinyKate::open(const QString & filename)
177{ 178{
178 KateDocument *kd= new KateDocument(false, false, this,0,this); 179 KateDocument *kd= new KateDocument(false, false, this,0,this);
179 KTextEditor::View *kv; 180 KTextEditor::View *kv;
180 QFileInfo fi(filename); 181 QFileInfo fi(filename);
181 QString filenamed = fi.fileName(); 182 QString filenamed = fi.fileName();
182 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 183 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
183 qDebug(filename); 184 qDebug(filename);
184 185
185 kd->setDocName( filenamed); 186 kd->setDocName( filenamed);
186 kd->open( filename ); 187 kd->open( filename );
187 viewCount++; 188 viewCount++;
188} 189}
189 190
190void TinyKate::setDocument(const QString& fileref) 191void TinyKate::setDocument(const QString& fileref)
191{ 192{
192 open( fileref ); 193 open( fileref );
193} 194}
194 195
195void TinyKate::slotCurrentChanged( QWidget * view) 196void TinyKate::slotCurrentChanged( QWidget * view)
196{ 197{
197 if (currentView) { 198 if (currentView) {
198 199
199 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); 200 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
200 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); 201 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
201 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); 202 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
202 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); 203 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
203 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); 204 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
204 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 205 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
205 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 206 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
206 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 207 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
207 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 208 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
208 } 209 }
209 210
210 currentView=(KTextEditor::View*)view; 211 currentView=(KTextEditor::View*)view;
211 212
212 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); 213 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
213 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); 214 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
214 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); 215 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
215 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); 216 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
216 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); 217 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
217 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 218 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
218 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 219 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
219 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 220 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
220 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 221 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
221 222
222} 223}
223 224
224void TinyKate::slotNew( ) 225void TinyKate::slotNew( )
225{ 226{
226 KateDocument *kd= new KateDocument(false, false, this,0,this); 227 KateDocument *kd= new KateDocument(false, false, this,0,this);
227 KTextEditor::View *kv; 228 KTextEditor::View *kv;
228 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), 229 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
229 "tinykate/tinykate", 230 "tinykate/tinykate",
230 tr("Unnamed %1").arg(nextUnnamed++)); 231 tr("Unnamed %1").arg(nextUnnamed++));
231 viewCount++; 232 viewCount++;
232} 233}
233 234
234void TinyKate::slotClose( ) 235void TinyKate::slotClose( )
235{ 236{
236 if (currentView==0) return; 237 if (currentView==0) return;
237 KTextEditor::View *dv=currentView; 238 KTextEditor::View *dv=currentView;
238 currentView=0; 239 currentView=0;
239 tabwidget->removePage(dv); 240 tabwidget->removePage(dv);
240 delete dv->document(); 241 delete dv->document();
241 viewCount--; 242 viewCount--;
242 if ((!viewCount) && (!shutDown)) slotNew(); 243 if ((!viewCount) && (!shutDown)) slotNew();
243} 244}
244 245
245void TinyKate::slotSave() { 246void TinyKate::slotSave() {
246 // feel free to make this how you want 247 // feel free to make this how you want
247 if (currentView==0) return; 248 if (currentView==0) return;
248 249
249 // KateView *kv = (KateView*) currentView; 250 // KateView *kv = (KateView*) currentView;
250 KateDocument *kd = (KateDocument*) currentView->document(); 251 KateDocument *kd = (KateDocument*) currentView->document();
251 // qDebug("saving file "+kd->docName()); 252 // qDebug("saving file "+kd->docName());
252 if( kd->docName().isEmpty()) 253 if( kd->docName().isEmpty())
253 slotSaveAs(); 254 slotSaveAs();
254 else 255 else
255 kd->saveFile(); 256 kd->saveFile();
256 // kv->save(); 257 // kv->save();
257 // kd->saveFile(); 258 // kd->saveFile();
258} 259}
259 260
260void TinyKate::slotSaveAs() { 261void TinyKate::slotSaveAs() {
261 if (currentView==0) return; 262 if (currentView==0) return;
262 KateDocument *kd = (KateDocument*) currentView->document(); 263 KateDocument *kd = (KateDocument*) currentView->document();
263 264
264 QString filename= Opie::OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 265 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
265 QString::null); 266 QString::null);
266 if (!filename.isEmpty()) { 267 if (!filename.isEmpty()) {
267 qDebug("saving file "+filename); 268 qDebug("saving file "+filename);
268 QFileInfo fi(filename); 269 QFileInfo fi(filename);
269 QString filenamed = fi.fileName(); 270 QString filenamed = fi.fileName();
270 kd->setDocFile( filename); 271 kd->setDocFile( filename);
271 kd->setDocName( filenamed); 272 kd->setDocName( filenamed);
272 kd->saveFile(); 273 kd->saveFile();
273// KTextEditor::View *dv = currentView; 274// KTextEditor::View *dv = currentView;
274// tabwidget->changeTab( dv, filenamed); 275// tabwidget->changeTab( dv, filenamed);
275 // need to change tab label here 276 // need to change tab label here
276 } 277 }
277 278
278} 279}
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h
index f844c55..f435c03 100644
--- a/noncore/apps/tinykate/tinykate.h
+++ b/noncore/apps/tinykate/tinykate.h
@@ -1,66 +1,66 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.h 2 tinykate.h
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef __TINYKATE_H__ 18#ifndef __TINYKATE_H__
19#define __TINYKATE_H__ 19#define __TINYKATE_H__
20 20
21 21
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <opie2/otabwidget.h> 23#include <opie2/otabwidget.h>
24#include <ktexteditor.h> 24#include <ktexteditor.h>
25 25
26class QToolButton; 26class QToolButton;
27class QAction; 27class QAction;
28class QPopupMenu; 28class QPopupMenu;
29 29
30class TinyKate : public QMainWindow 30class TinyKate : public QMainWindow
31{ 31{
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); 34 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
35 ~TinyKate( ); 35 ~TinyKate( );
36 static QString appName() { return QString::fromLatin1( "kate" ); }; 36 static QString appName() { return QString::fromLatin1( "kate" ); };
37 37
38 38
39public slots: 39public slots:
40 void slotNew(); 40 void slotNew();
41 void setDocument(const QString& fileref); 41 void setDocument(const QString& fileref);
42 42
43protected slots: 43protected slots:
44 void slotOpen(); 44 void slotOpen();
45 void slotClose(); 45 void slotClose();
46 void slotCurrentChanged(QWidget *); 46 void slotCurrentChanged(QWidget *);
47 void slotSave(); 47 void slotSave();
48 void slotSaveAs(); 48 void slotSaveAs();
49protected: 49protected:
50 void open(const QString&); 50 void open(const QString&);
51private: 51private:
52 QString currentFileName; 52 QString currentFileName;
53 OTabWidget *tabwidget; 53 Opie::Ui::OTabWidget *tabwidget;
54 KTextEditor::View *currentView; 54 KTextEditor::View *currentView;
55 bool shutDown; 55 bool shutDown;
56 56
57 QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; 57 QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace;
58 QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; 58 QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings;
59 59
60 QPopupMenu *hlmenu; 60 QPopupMenu *hlmenu;
61 uint nextUnnamed; 61 uint nextUnnamed;
62 uint viewCount; 62 uint viewCount;
63}; 63};
64 64
65 65
66#endif // __TINYKATE_H__ 66#endif // __TINYKATE_H__
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index a3467e5..3df55eb 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1,2082 +1,2081 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Sat Apr 6 17:57:45 2002 3** Created: Sat Apr 6 17:57:45 2002
4** 4**
5** Author: Carsten Schneider <CarstenSchneider@t-online.de> 5** Author: Carsten Schneider <CarstenSchneider@t-online.de>
6** 6**
7** $Id$ 7** $Id$
8** 8**
9** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html 9** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html
10** 10**
11** Compile Flags: 11** Compile Flags:
12** Zaurus arm : -DNO_OPIE 12** Zaurus arm : -DNO_OPIE
13** Zaurus Opie arm: none 13** Zaurus Opie arm: none
14** Linux Desktop : -DDESKTOP 14** Linux Desktop : -DDESKTOP
15** Windows Desktop: -DDESKTOP -DWIN32 15** Windows Desktop: -DDESKTOP -DWIN32
16** 16**
17** for japanese version additional use: -DJPATCH_HDE 17** for japanese version additional use: -DJPATCH_HDE
18** 18**
19****************************************************************************/ 19****************************************************************************/
20#include "zsafe.h" 20#include "zsafe.h"
21#include "newdialog.h" 21#include "newdialog.h"
22#include "searchdialog.h" 22#include "searchdialog.h"
23#include "categorydialog.h" 23#include "categorydialog.h"
24#include "passworddialog.h" 24#include "passworddialog.h"
25#include "infoform.h" 25#include "infoform.h"
26#include "zlistview.h" 26#include "zlistview.h"
27#include "shadedlistitem.h" 27#include "shadedlistitem.h"
28 28
29#ifndef DESKTOP 29#ifndef DESKTOP
30#ifndef NO_OPIE 30#ifndef NO_OPIE
31#include <opie2/ofiledialog.h> 31#include <opie2/ofiledialog.h>
32 32
33using Opie::OFileDialog; 33using namespace Opie::Ui;
34using Opie::OFileSelector;
35#else 34#else
36#include "scqtfileedit.h" 35#include "scqtfileedit.h"
37#endif 36#endif
38#endif 37#endif
39 38
40#include <qclipboard.h> 39#include <qclipboard.h>
41 40
42#include <stdio.h> 41#include <stdio.h>
43 42
44#include <sys/types.h> 43#include <sys/types.h>
45#include <sys/stat.h> 44#include <sys/stat.h>
46#include <fcntl.h> 45#include <fcntl.h>
47#include <stdlib.h> 46#include <stdlib.h>
48#ifndef WIN32 47#ifndef WIN32
49#include <unistd.h> 48#include <unistd.h>
50#endif 49#endif
51#include <string.h> 50#include <string.h>
52#include <errno.h> 51#include <errno.h>
53 52
54#include <qmenubar.h> 53#include <qmenubar.h>
55#include <qpopupmenu.h> 54#include <qpopupmenu.h>
56 55
57#ifdef DESKTOP 56#ifdef DESKTOP
58#include <qfiledialog.h> 57#include <qfiledialog.h>
59#ifndef WIN32 58#ifndef WIN32
60#include <qsettings.h> 59#include <qsettings.h>
61#else 60#else
62#include "qsettings.h" 61#include "qsettings.h"
63#endif 62#endif
64#include <qapplication.h> 63#include <qapplication.h>
65#else 64#else
66#include <qfile.h> 65#include <qfile.h>
67#include <qpe/fileselector.h> 66#include <qpe/fileselector.h>
68#include <qpe/global.h> 67#include <qpe/global.h>
69#include <qpe/qpeapplication.h> 68#include <qpe/qpeapplication.h>
70#include <qpe/resource.h> 69#include <qpe/resource.h>
71#include <qpe/config.h> 70#include <qpe/config.h>
72#endif 71#endif
73 72
74#include <qtimer.h> 73#include <qtimer.h>
75#include <qlayout.h> 74#include <qlayout.h>
76#include <qmessagebox.h> 75#include <qmessagebox.h>
77#include <qfile.h> 76#include <qfile.h>
78#include <qtextstream.h> 77#include <qtextstream.h>
79#include <qheader.h> 78#include <qheader.h>
80#include <qlistview.h> 79#include <qlistview.h>
81#include <qtoolbutton.h> 80#include <qtoolbutton.h>
82#include <qvariant.h> 81#include <qvariant.h>
83#include <qtooltip.h> 82#include <qtooltip.h>
84#include <qwhatsthis.h> 83#include <qwhatsthis.h>
85#include <qimage.h> 84#include <qimage.h>
86#include <qpixmap.h> 85#include <qpixmap.h>
87#include <qlineedit.h> 86#include <qlineedit.h>
88#include <qmultilineedit.h> 87#include <qmultilineedit.h>
89#include <qregexp.h> 88#include <qregexp.h>
90#include <qdir.h> 89#include <qdir.h>
91#include <qtextbrowser.h> 90#include <qtextbrowser.h>
92#include <qlabel.h> 91#include <qlabel.h>
93#include <qcombobox.h> 92#include <qcombobox.h>
94 93
95#include "krc2.h" 94#include "krc2.h"
96 95
97#include "wait.h" 96#include "wait.h"
98 97
99extern int DeskW, DeskH; 98extern int DeskW, DeskH;
100#ifdef DESKTOP 99#ifdef DESKTOP
101extern QApplication *appl; 100extern QApplication *appl;
102#else 101#else
103extern QPEApplication *appl; 102extern QPEApplication *appl;
104#endif 103#endif
105 104
106#ifdef JPATCH_HDE 105#ifdef JPATCH_HDE
107#define tr(arg) arg 106#define tr(arg) arg
108#endif 107#endif
109 108
110 109
111#ifdef DESKTOP 110#ifdef DESKTOP
112#ifndef WIN32 111#ifndef WIN32
113const QString APP_KEY="/.zsafe/"; 112const QString APP_KEY="/.zsafe/";
114#else 113#else
115const QString APP_KEY=""; 114const QString APP_KEY="";
116#endif 115#endif
117#else 116#else
118const QString APP_KEY=""; 117const QString APP_KEY="";
119#endif 118#endif
120 119
121// include xmp images 120// include xmp images
122#include "pics/zsafe/copy.xpm" 121#include "pics/zsafe/copy.xpm"
123#include "pics/zsafe/cut.xpm" 122#include "pics/zsafe/cut.xpm"
124#include "pics/zsafe/edit.xpm" 123#include "pics/zsafe/edit.xpm"
125#include "pics/zsafe/editdelete.xpm" 124#include "pics/zsafe/editdelete.xpm"
126#include "pics/zsafe/find.xpm" 125#include "pics/zsafe/find.xpm"
127#include "pics/zsafe/folder_open.xpm" 126#include "pics/zsafe/folder_open.xpm"
128#include "pics/zsafe/help_icon.xpm" 127#include "pics/zsafe/help_icon.xpm"
129#include "pics/zsafe/new.xpm" 128#include "pics/zsafe/new.xpm"
130#include "pics/zsafe/paste.xpm" 129#include "pics/zsafe/paste.xpm"
131#include "pics/zsafe/quit_icon.xpm" 130#include "pics/zsafe/quit_icon.xpm"
132#include "pics/zsafe/save.xpm" 131#include "pics/zsafe/save.xpm"
133#include "pics/zsafe/trash.xpm" 132#include "pics/zsafe/trash.xpm"
134#include "pics/zsafe/expand.xpm" 133#include "pics/zsafe/expand.xpm"
135#include "pics/zsafe/export.xpm" 134#include "pics/zsafe/export.xpm"
136#include "pics/zsafe/import.xpm" 135#include "pics/zsafe/import.xpm"
137#include "pics/zsafe/zsafe.xpm" 136#include "pics/zsafe/zsafe.xpm"
138 137
139static const char* const bank_cards_data[] = { 138static const char* const bank_cards_data[] = {
140"14 14 16 1", 139"14 14 16 1",
141". c None", 140". c None",
142"# c #000000", 141"# c #000000",
143"b c #0000de", 142"b c #0000de",
144"a c #0000e6", 143"a c #0000e6",
145"j c #41de83", 144"j c #41de83",
146"k c #4acecd", 145"k c #4acecd",
147"h c #4aced5", 146"h c #4aced5",
148"g c #5a40cd", 147"g c #5a40cd",
149"d c #5a44d5", 148"d c #5a44d5",
150"l c #9440d5", 149"l c #9440d5",
151"m c #b4ce4a", 150"m c #b4ce4a",
152"n c #cd4883", 151"n c #cd4883",
153"e c #d5ae10", 152"e c #d5ae10",
154"f c #de3ce6", 153"f c #de3ce6",
155"i c #e640e6", 154"i c #e640e6",
156"c c #ffffff", 155"c c #ffffff",
157"..............", 156"..............",
158".###########..", 157".###########..",
159".#ababababa#..", 158".#ababababa#..",
160".#babbbabbb#..", 159".#babbbabbb#..",
161".#ccccccccc#..", 160".#ccccccccc#..",
162".#cdcefcghc#..", 161".#cdcefcghc#..",
163".#ccccccccc#..", 162".#ccccccccc#..",
164".#cicjkclic#..", 163".#cicjkclic#..",
165".#ccccccccc#..", 164".#ccccccccc#..",
166".#cmchlcnec#..", 165".#cmchlcnec#..",
167".#ccccccccc#..", 166".#ccccccccc#..",
168".###########..", 167".###########..",
169"..............", 168"..............",
170".............."}; 169".............."};
171 170
172 171
173static const char* const passwords_data[] = { 172static const char* const passwords_data[] = {
174"16 16 20 1", 173"16 16 20 1",
175". c None", 174". c None",
176"# c #000000", 175"# c #000000",
177"r c #000083", 176"r c #000083",
178"p c #0000c5", 177"p c #0000c5",
179"q c #0000ff", 178"q c #0000ff",
180"n c #008100", 179"n c #008100",
181"l c #00c200", 180"l c #00c200",
182"m c #00ff00", 181"m c #00ff00",
183"j c #838100", 182"j c #838100",
184"a c #c55900", 183"a c #c55900",
185"h c #c5c200", 184"h c #c5c200",
186"o c #c5c2ff", 185"o c #c5c2ff",
187"k c #c5ffc5", 186"k c #c5ffc5",
188"f c #ff0000", 187"f c #ff0000",
189"d c #ff8100", 188"d c #ff8100",
190"b c #ffaa5a", 189"b c #ffaa5a",
191"e c #ffc2c5", 190"e c #ffc2c5",
192"c c #ffdeac", 191"c c #ffdeac",
193"i c #ffff00", 192"i c #ffff00",
194"g c #ffffc5", 193"g c #ffffc5",
195"............###.", 194"............###.",
196"...........#abb#", 195"...........#abb#",
197"..........#cbab#", 196"..........#cbab#",
198".........#cbdd#.", 197".........#cbdd#.",
199"######..#cbdd#..", 198"######..#cbdd#..",
200"#eeff#..#add#...", 199"#eeff#..#add#...",
201"#eeff#######....", 200"#eeff#######....",
202"#ccdbdd#........", 201"#ccdbdd#........",
203"#dddbdd###......", 202"#dddbdd###......",
204"#gghihhjj#......", 203"#gghihhjj#......",
205"#hhhihhjj###....", 204"#hhhihhjj###....",
206"#kklmllnnnn#....", 205"#kklmllnnnn#....",
207"#lllmllnnnn#....", 206"#lllmllnnnn#....",
208"#oopqpprprr#....", 207"#oopqpprprr#....",
209"#oopqpprprr#....", 208"#oopqpprprr#....",
210"############...."}; 209"############...."};
211 210
212static const char* const software_data[] = { 211static const char* const software_data[] = {
213"16 16 5 1", 212"16 16 5 1",
214". c None", 213". c None",
215"# c #000000", 214"# c #000000",
216"b c #838183", 215"b c #838183",
217"c c #c5ffff", 216"c c #c5ffff",
218"a c #ffffff", 217"a c #ffffff",
219"................", 218"................",
220".##############.", 219".##############.",
221"#aaaaaaaaaaaaaa#", 220"#aaaaaaaaaaaaaa#",
222"#abbbbbbbbbbbbb#", 221"#abbbbbbbbbbbbb#",
223"#ab##########ab#", 222"#ab##########ab#",
224"#ab#c########ab#", 223"#ab#c########ab#",
225"#ab#c#c######ab#", 224"#ab#c#c######ab#",
226"#ab##########ab#", 225"#ab##########ab#",
227"#ab##########ab#", 226"#ab##########ab#",
228"#ab##########ab#", 227"#ab##########ab#",
229"#ab##########ab#", 228"#ab##########ab#",
230"#ab##########ab#", 229"#ab##########ab#",
231"#aaaaaaaaaaaaab#", 230"#aaaaaaaaaaaaab#",
232"#bbbbbbbbbbbbbb#", 231"#bbbbbbbbbbbbbb#",
233".##############.", 232".##############.",
234"................"}; 233"................"};
235 234
236static const char* const general_data[] = { 235static const char* const general_data[] = {
237"14 14 98 2", 236"14 14 98 2",
238"Qt c None", 237"Qt c None",
239".k c #000000", 238".k c #000000",
240"#x c #080808", 239"#x c #080808",
241"#F c #101008", 240"#F c #101008",
242"#q c #101010", 241"#q c #101010",
243"#i c #101410", 242"#i c #101410",
244"## c #101810", 243"## c #101810",
245".m c #181818", 244".m c #181818",
246".3 c #181c18", 245".3 c #181c18",
247".I c #182018", 246".I c #182018",
248".T c #202420", 247".T c #202420",
249"#D c #202820", 248"#D c #202820",
250"#y c #292c29", 249"#y c #292c29",
251".c c #293029", 250".c c #293029",
252".d c #313031", 251".d c #313031",
253"#E c #313429", 252"#E c #313429",
254"#r c #313831", 253"#r c #313831",
255".j c #393c31", 254".j c #393c31",
256"#j c #394039", 255"#j c #394039",
257"#C c #414841", 256"#C c #414841",
258".w c #4a554a", 257".w c #4a554a",
259".a c #4a594a", 258".a c #4a594a",
260".# c #525052", 259".# c #525052",
261".l c #52594a", 260".l c #52594a",
262"#f c #525952", 261"#f c #525952",
263"#v c #525d52", 262"#v c #525d52",
264".O c #5a4c4a", 263".O c #5a4c4a",
265".9 c #5a595a", 264".9 c #5a595a",
266".A c #5a5d52", 265".A c #5a5d52",
267".B c #624c52", 266".B c #624c52",
268".0 c #625552", 267".0 c #625552",
269"#o c #626562", 268"#o c #626562",
270".R c #626962", 269".R c #626962",
271"#. c #626d5a", 270"#. c #626d5a",
272"#p c #626d62", 271"#p c #626d62",
273".2 c #627162", 272".2 c #627162",
274"#h c #6a6d62", 273"#h c #6a6d62",
275"#z c #6a7562", 274"#z c #6a7562",
276"#w c #6a756a", 275"#w c #6a756a",
277".C c #73656a", 276".C c #73656a",
278".P c #73696a", 277".P c #73696a",
279"#a c #737d6a", 278"#a c #737d6a",
280".U c #738573", 279".U c #738573",
281".E c #7b817b", 280".E c #7b817b",
282"#B c #7b857b", 281"#B c #7b857b",
283"#s c #7b897b", 282"#s c #7b897b",
284"#n c #7b917b", 283"#n c #7b917b",
285".b c #838d83", 284".b c #838d83",
286".7 c #839583", 285".7 c #839583",
287".n c #8b7d7b", 286".n c #8b7d7b",
288"#g c #8b8583", 287"#g c #8b8583",
289".g c #8b858b", 288".g c #8b858b",
290".r c #8b898b", 289".r c #8b898b",
291".s c #8b8d8b", 290".s c #8b8d8b",
292".i c #8b9183", 291".i c #8b9183",
293".8 c #8b918b", 292".8 c #8b918b",
294"#A c #8b9d8b", 293"#A c #8b9d8b",
295".S c #8ba183", 294".S c #8ba183",
296".Z c #94918b", 295".Z c #94918b",
297".N c #949994", 296".N c #949994",
298".F c #949d94", 297".F c #949d94",
299".x c #94a18b", 298".x c #94a18b",
300".v c #94a194", 299".v c #94a194",
301".Y c #94aa94", 300".Y c #94aa94",
302".h c #9c999c", 301".h c #9c999c",
303".Q c #9ca19c", 302".Q c #9ca19c",
304"#u c #9ca59c", 303"#u c #9ca59c",
305".H c #9caa9c", 304".H c #9caa9c",
306"#e c #9cb29c", 305"#e c #9cb29c",
307"#m c #a4b29c", 306"#m c #a4b29c",
308"#t c #a4b2a4", 307"#t c #a4b2a4",
309".M c #a4b69c", 308".M c #a4b69c",
310"#l c #a4b6a4", 309"#l c #a4b6a4",
311".z c #a4baa4", 310".z c #a4baa4",
312".f c #aca5ac", 311".f c #aca5ac",
313".q c #acaaac", 312".q c #acaaac",
314"#d c #acbeac", 313"#d c #acbeac",
315".6 c #acc2ac", 314".6 c #acc2ac",
316".o c #b4b2b4", 315".o c #b4b2b4",
317".t c #b4beb4", 316".t c #b4beb4",
318"#k c #b4c2ac", 317"#k c #b4c2ac",
319".5 c #b4cab4", 318".5 c #b4cab4",
320".D c #bdb6bd", 319".D c #bdb6bd",
321".G c #bdc6b4", 320".G c #bdc6b4",
322"#c c #bdceb4", 321"#c c #bdceb4",
323".X c #bdd2bd", 322".X c #bdd2bd",
324".4 c #bdd6bd", 323".4 c #bdd6bd",
325".1 c #c5bec5", 324".1 c #c5bec5",
326".e c #c5c2c5", 325".e c #c5c2c5",
327".u c #c5cac5", 326".u c #c5cac5",
328"#b c #c5d6c5", 327"#b c #c5d6c5",
329".J c #c5dec5", 328".J c #c5dec5",
330".p c #cdcacd", 329".p c #cdcacd",
331".W c #cddecd", 330".W c #cddecd",
332".L c #cde2cd", 331".L c #cde2cd",
333".K c #d5eacd", 332".K c #d5eacd",
334".V c #d5ead5", 333".V c #d5ead5",
335".y c #d5eed5", 334".y c #d5eed5",
336"QtQtQtQtQtQtQtQtQtQtQtQtQtQt", 335"QtQtQtQtQtQtQtQtQtQtQtQtQtQt",
337"QtQtQt.#.a.b.cQtQtQtQtQtQtQt", 336"QtQtQt.#.a.b.cQtQtQtQtQtQtQt",
338"QtQt.d.e.f.g.h.i.c.j.dQt.kQt", 337"QtQt.d.e.f.g.h.i.c.j.dQt.kQt",
339".a.l.m.n.o.p.q.r.s.t.u.v.wQt", 338".a.l.m.n.o.p.q.r.s.t.u.v.wQt",
340".x.y.z.A.B.C.D.p.q.E.F.G.H.I", 339".x.y.z.A.B.C.D.p.q.E.F.G.H.I",
341".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", 340".I.J.K.L.M.N.O.P.o.p.Q.R.S.T",
342"Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", 341"Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3",
343"Qt.3.X.W.4.X.5.6.7.8.9.s#.##", 342"Qt.3.X.W.4.X.5.6.7.8.9.s#.##",
344"QtQt#a.X#b#c.5.6#d#e#f#g#h#i", 343"QtQt#a.X#b#c.5.6#d#e#f#g#h#i",
345"QtQtQt#j.7#k.6#d#l#m#n#o#p#q", 344"QtQtQt#j.7#k.6#d#l#m#n#o#p#q",
346"QtQtQtQt.k#r#s#m#t.H#u#v#w#x", 345"QtQtQtQt.k#r#s#m#t.H#u#v#w#x",
347"QtQtQtQtQtQt.k#y#z.v#A#B#C#x", 346"QtQtQtQtQtQt.k#y#z.v#A#B#C#x",
348"QtQtQtQtQtQtQtQt.k#D.w#s#E.k", 347"QtQtQtQtQtQtQtQt.k#D.w#s#E.k",
349"QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; 348"QtQtQtQtQtQtQtQtQtQtQt#x#FQt"};
350 349
351// exit ZSafe and clear the clipboard for security reasons 350// exit ZSafe and clear the clipboard for security reasons
352 void ZSafe::exitZs (int ec) 351 void ZSafe::exitZs (int ec)
353 { 352 {
354 QClipboard *cb = QApplication::clipboard(); 353 QClipboard *cb = QApplication::clipboard();
355 cb->clear(); 354 cb->clear();
356 355
357 exit (ec); 356 exit (ec);
358 } 357 }
359 358
360 359
361// save the configuration into the file 360// save the configuration into the file
362 void ZSafe::saveConf () 361 void ZSafe::saveConf ()
363 { 362 {
364 if (conf) 363 if (conf)
365 { 364 {
366 delete conf; 365 delete conf;
367 366
368#ifdef DESKTOP 367#ifdef DESKTOP
369#ifndef WIN32 368#ifndef WIN32
370 conf = new QSettings (); 369 conf = new QSettings ();
371 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 370 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
372#else 371#else
373 conf = new QSettings (cfgFile); 372 conf = new QSettings (cfgFile);
374 conf->insertSearchPath (QSettings::Unix, cfgFile); 373 conf->insertSearchPath (QSettings::Unix, cfgFile);
375#endif 374#endif
376#else 375#else
377 conf = new Config (cfgFile, Config::File); 376 conf = new Config (cfgFile, Config::File);
378 conf->setGroup ("zsafe"); 377 conf->setGroup ("zsafe");
379#endif 378#endif
380 } 379 }
381 } 380 }
382 381
383 382
384/* 383/*
385 * Constructs a ZSafe which is a child of 'parent', with the 384 * Constructs a ZSafe which is a child of 'parent', with the
386 * name 'name' and widget flags set to 'f' 385 * name 'name' and widget flags set to 'f'
387 * 386 *
388 * The dialog will by default be modeless, unless you set 'modal' to 387 * The dialog will by default be modeless, unless you set 'modal' to
389 * TRUE to construct a modal dialog. 388 * TRUE to construct a modal dialog.
390 */ 389 */
391ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 390ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
392 : QDialog( parent, name, modal, fl ), 391 : QDialog( parent, name, modal, fl ),
393 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) 392 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l)
394{ 393{
395 IsCut = false; 394 IsCut = false;
396 IsCopy = false; 395 IsCopy = false;
397 modified = false; 396 modified = false;
398 397
399 // set the config file 398 // set the config file
400 cfgFile=QDir::homeDirPath(); 399 cfgFile=QDir::homeDirPath();
401 cfgFile += "/.zsafe.cfg"; 400 cfgFile += "/.zsafe.cfg";
402 // set the icon path 401 // set the icon path
403#ifdef NO_OPIE 402#ifdef NO_OPIE
404 QString qpedir ((const char *)getenv("QPEDIR")); 403 QString qpedir ((const char *)getenv("QPEDIR"));
405#else 404#else
406 QString qpedir ((const char *)getenv("OPIEDIR")); 405 QString qpedir ((const char *)getenv("OPIEDIR"));
407#endif 406#endif
408 407
409#ifdef DESKTOP 408#ifdef DESKTOP
410 iconPath = QDir::homeDirPath() + "/pics/"; 409 iconPath = QDir::homeDirPath() + "/pics/";
411#else 410#else
412 if (qpedir.isEmpty()) 411 if (qpedir.isEmpty())
413 iconPath = "/home/QtPalmtop/pics/"; 412 iconPath = "/home/QtPalmtop/pics/";
414 else 413 else
415 iconPath = qpedir + "/pics/"; 414 iconPath = qpedir + "/pics/";
416#endif 415#endif
417 416
418 // create a zsafe configuration object 417 // create a zsafe configuration object
419#ifdef DESKTOP 418#ifdef DESKTOP
420#ifndef WIN32 419#ifndef WIN32
421 conf = new QSettings (); 420 conf = new QSettings ();
422 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 421 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
423#else 422#else
424 conf = new QSettings (cfgFile); 423 conf = new QSettings (cfgFile);
425 conf->insertSearchPath (QSettings::Unix, cfgFile); 424 conf->insertSearchPath (QSettings::Unix, cfgFile);
426#endif 425#endif
427#else 426#else
428 conf = new Config (cfgFile, Config::File); 427 conf = new Config (cfgFile, Config::File);
429 conf->setGroup ("zsafePrefs"); 428 conf->setGroup ("zsafePrefs");
430#endif 429#endif
431#ifdef DESKTOP 430#ifdef DESKTOP
432// #ifndef WIN32 431// #ifndef WIN32
433 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); 432 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
434// #endif 433// #endif
435#else 434#else
436 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); 435 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
437#endif 436#endif
438#ifndef DESKTOP 437#ifndef DESKTOP
439 conf->setGroup ("zsafe"); 438 conf->setGroup ("zsafe");
440#endif 439#endif
441 440
442 QPixmap copy_img((const char**) copy_xpm); 441 QPixmap copy_img((const char**) copy_xpm);
443 QPixmap cut_img((const char**) cut_xpm); 442 QPixmap cut_img((const char**) cut_xpm);
444 QPixmap edit_img((const char**) edit_xpm); 443 QPixmap edit_img((const char**) edit_xpm);
445 QPixmap editdelete_img((const char**) editdelete_xpm); 444 QPixmap editdelete_img((const char**) editdelete_xpm);
446 QPixmap find_img((const char**) find_xpm); 445 QPixmap find_img((const char**) find_xpm);
447 QPixmap folder_open_img((const char**) folder_open_xpm); 446 QPixmap folder_open_img((const char**) folder_open_xpm);
448 QPixmap help_icon_img((const char**) help_icon_xpm); 447 QPixmap help_icon_img((const char**) help_icon_xpm);
449 QPixmap new_img((const char**) new_xpm); 448 QPixmap new_img((const char**) new_xpm);
450 QPixmap paste_img((const char**) paste_xpm); 449 QPixmap paste_img((const char**) paste_xpm);
451 QPixmap quit_icon_img((const char**) quit_icon_xpm); 450 QPixmap quit_icon_img((const char**) quit_icon_xpm);
452 QPixmap save_img((const char**) save_xpm); 451 QPixmap save_img((const char**) save_xpm);
453 QPixmap trash_img((const char**) trash_xpm); 452 QPixmap trash_img((const char**) trash_xpm);
454 QPixmap expand_img((const char**) expand_xpm); 453 QPixmap expand_img((const char**) expand_xpm);
455 QPixmap export_img((const char**) export_xpm); 454 QPixmap export_img((const char**) export_xpm);
456 QPixmap import_img((const char**) import_xpm); 455 QPixmap import_img((const char**) import_xpm);
457 456
458 QPixmap bank_cards( ( const char** ) bank_cards_data ); 457 QPixmap bank_cards( ( const char** ) bank_cards_data );
459 QPixmap passwords( ( const char** ) passwords_data ); 458 QPixmap passwords( ( const char** ) passwords_data );
460 QPixmap software( ( const char** ) software_data ); 459 QPixmap software( ( const char** ) software_data );
461 QPixmap general( ( const char** ) general_data ); 460 QPixmap general( ( const char** ) general_data );
462 if ( !name ) 461 if ( !name )
463 setName( "ZSafe" ); 462 setName( "ZSafe" );
464 463
465#ifdef DESKTOP 464#ifdef DESKTOP
466#ifdef WIN32 465#ifdef WIN32
467 setGeometry(100, 150, DeskW, DeskH-30 ); 466 setGeometry(100, 150, DeskW, DeskH-30 );
468#else 467#else
469 resize( DeskW, DeskH-30 ); 468 resize( DeskW, DeskH-30 );
470#endif 469#endif
471 470
472#else 471#else
473 472
474#ifdef JPATCH_HDE 473#ifdef JPATCH_HDE
475 int DeskS; 474 int DeskS;
476 if(DeskW > DeskH) 475 if(DeskW > DeskH)
477 { 476 {
478 DeskS = DeskW; 477 DeskS = DeskW;
479 } 478 }
480 else 479 else
481 { 480 {
482 DeskS = DeskH; 481 DeskS = DeskH;
483 } 482 }
484 resize( DeskW, DeskH ); 483 resize( DeskW, DeskH );
485 setMinimumSize( QSize( DeskS, DeskS ) ); 484 setMinimumSize( QSize( DeskS, DeskS ) );
486 setMaximumSize( QSize( DeskS, DeskS ) ); 485 setMaximumSize( QSize( DeskS, DeskS ) );
487#else 486#else
488 resize( DeskW, DeskH-30 ); 487 resize( DeskW, DeskH-30 );
489#endif 488#endif
490 489
491#endif 490#endif
492 // setCaption( tr( "ZSafe" ) ); 491 // setCaption( tr( "ZSafe" ) );
493 492
494 filename = conf->readEntry(APP_KEY+"document"); 493 filename = conf->readEntry(APP_KEY+"document");
495 if (filename.isEmpty() || filename.isNull()) 494 if (filename.isEmpty() || filename.isNull())
496 { 495 {
497 496
498 // check if the directory application exists, if not 497 // check if the directory application exists, if not
499 // create it 498 // create it
500// #ifndef WIN32 499// #ifndef WIN32
501 // QString d1("Documents/application"); 500 // QString d1("Documents/application");
502// #else 501// #else
503 QString d1(QDir::homeDirPath() + "/Documents/application"); 502 QString d1(QDir::homeDirPath() + "/Documents/application");
504// #endif 503// #endif
505 QDir pd1(d1); 504 QDir pd1(d1);
506 if (!pd1.exists()) 505 if (!pd1.exists())
507 { 506 {
508 QDir pd1("Documents"); 507 QDir pd1("Documents");
509 if (!pd1.mkdir("application", FALSE)) 508 if (!pd1.mkdir("application", FALSE))
510 { 509 {
511 QMessageBox::critical( 0, tr("ZSafe"), 510 QMessageBox::critical( 0, tr("ZSafe"),
512#ifdef JPATCH_HDE 511#ifdef JPATCH_HDE
513 tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); 512 tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit."));
514#else 513#else
515 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); 514 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
516#endif 515#endif
517 exitZs (1); 516 exitZs (1);
518 } 517 }
519 } 518 }
520 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); 519 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
521 QDir pd2(d2); 520 QDir pd2(d2);
522 if (!pd2.exists()) 521 if (!pd2.exists())
523 { 522 {
524 QDir pd2(QDir::homeDirPath() + "Documents/application"); 523 QDir pd2(QDir::homeDirPath() + "Documents/application");
525 if (!pd2.mkdir("zsafe", FALSE)) 524 if (!pd2.mkdir("zsafe", FALSE))
526 { 525 {
527 QMessageBox::critical( 0, tr("ZSafe"), 526 QMessageBox::critical( 0, tr("ZSafe"),
528#ifdef JPATCH_HDE 527#ifdef JPATCH_HDE
529 tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); 528 tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit."));
530#else 529#else
531 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); 530 tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
532#endif 531#endif
533 exitZs (1); 532 exitZs (1);
534 } 533 }
535 } 534 }
536 535
537 536
538 // set the default filename 537 // set the default filename
539 filename=d2 + "/passwords.zsf"; 538 filename=d2 + "/passwords.zsf";
540 539
541 // save the current filename to the config file 540 // save the current filename to the config file
542 conf->writeEntry(APP_KEY+"document", filename); 541 conf->writeEntry(APP_KEY+"document", filename);
543 saveConf(); 542 saveConf();
544 } 543 }
545 544
546 //if (filename == "INVALIDPWD") 545 //if (filename == "INVALIDPWD")
547 //filename = ""; 546 //filename = "";
548 547
549 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 548 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
550#ifdef WIN32 549#ifdef WIN32
551 this->setCaption("Qt ZSafe: " + ti); 550 this->setCaption("Qt ZSafe: " + ti);
552#else 551#else
553 this->setCaption("ZSafe: " + ti); 552 this->setCaption("ZSafe: " + ti);
554#endif 553#endif
555 554
556 selectedItem = NULL; 555 selectedItem = NULL;
557 lastSearchedCategory = NULL; 556 lastSearchedCategory = NULL;
558 lastSearchedItem = NULL; 557 lastSearchedItem = NULL;
559 lastSearchedName = ""; 558 lastSearchedName = "";
560 lastSearchedUsername = ""; 559 lastSearchedUsername = "";
561 lastSearchedComment = ""; 560 lastSearchedComment = "";
562 561
563 infoForm = new InfoForm(); 562 infoForm = new InfoForm();
564 categoryDialog = NULL; 563 categoryDialog = NULL;
565 564
566 // add a menu bar 565 // add a menu bar
567 QMenuBar *menu = new QMenuBar( this ); 566 QMenuBar *menu = new QMenuBar( this );
568 567
569 // add file menu 568 // add file menu
570 // QPopupMenu *file = new QPopupMenu( this ); 569 // QPopupMenu *file = new QPopupMenu( this );
571 file = new QPopupMenu( this ); 570 file = new QPopupMenu( this );
572 571
573// #ifdef DESKTOP 572// #ifdef DESKTOP
574 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); 573 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
575 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); 574 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
576 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); 575 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
577 file->insertSeparator(); 576 file->insertSeparator();
578// #endif 577// #endif
579 578
580 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); 579 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
581 file->insertItem( save_img, tr("S&ave document with new Password"), this, 580 file->insertItem( save_img, tr("S&ave document with new Password"), this,
582 SLOT(saveDocumentWithPwd()) ); 581 SLOT(saveDocumentWithPwd()) );
583 file->insertSeparator(); 582 file->insertSeparator();
584 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); 583 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
585 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); 584 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
586 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); 585 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
587 file->insertSeparator(); 586 file->insertSeparator();
588 file->insertItem( expand_img, tr("&Open entries expanded"), this, 587 file->insertItem( expand_img, tr("&Open entries expanded"), this,
589 SLOT(setExpandFlag()), 0, 'o'); 588 SLOT(setExpandFlag()), 0, 'o');
590 file->setItemChecked('o', expandTree); 589 file->setItemChecked('o', expandTree);
591 file->insertSeparator(); 590 file->insertSeparator();
592 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); 591 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
593 menu->insertItem( tr("&File"), file ); 592 menu->insertItem( tr("&File"), file );
594 593
595 QPopupMenu *cat = new QPopupMenu( this ); 594 QPopupMenu *cat = new QPopupMenu( this );
596 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); 595 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
597 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); 596 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
598 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); 597 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
599 menu->insertItem( tr("&Category"), cat ); 598 menu->insertItem( tr("&Category"), cat );
600 599
601 QPopupMenu *it = new QPopupMenu( this ); 600 QPopupMenu *it = new QPopupMenu( this );
602 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); 601 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
603 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); 602 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
604 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); 603 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
605 it->insertSeparator(); 604 it->insertSeparator();
606 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 605 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
607 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); 606 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
608 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); 607 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
609 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); 608 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
610 menu->insertItem( tr("&Entry"), it ); 609 menu->insertItem( tr("&Entry"), it );
611 610
612 QPopupMenu *help = new QPopupMenu( this ); 611 QPopupMenu *help = new QPopupMenu( this );
613 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); 612 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
614 menu->insertItem( tr("&Help"), help ); 613 menu->insertItem( tr("&Help"), help );
615 614
616 // toolbar icons 615 // toolbar icons
617 616
618 New = new QToolButton( menu, "New" ); 617 New = new QToolButton( menu, "New" );
619 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); 618 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
620 New->setMouseTracking( TRUE ); 619 New->setMouseTracking( TRUE );
621 New->setText( tr( "" ) ); 620 New->setText( tr( "" ) );
622 New->setPixmap( new_img ); 621 New->setPixmap( new_img );
623 QToolTip::add( New, tr( "New entry" ) ); 622 QToolTip::add( New, tr( "New entry" ) );
624 623
625 Edit = new QToolButton( menu, "Edit" ); 624 Edit = new QToolButton( menu, "Edit" );
626 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); 625 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
627 Edit->setText( tr( "" ) ); 626 Edit->setText( tr( "" ) );
628 Edit->setPixmap( edit_img ); 627 Edit->setPixmap( edit_img );
629 QToolTip::add( Edit, tr( "Edit category or entry" ) ); 628 QToolTip::add( Edit, tr( "Edit category or entry" ) );
630 629
631 Delete = new QToolButton( menu, "Delete" ); 630 Delete = new QToolButton( menu, "Delete" );
632 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 631 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
633 Delete->setText( tr( "" ) ); 632 Delete->setText( tr( "" ) );
634 Delete->setPixmap( trash_img ); 633 Delete->setPixmap( trash_img );
635 QToolTip::add( Delete, tr( "Delete category or entry" ) ); 634 QToolTip::add( Delete, tr( "Delete category or entry" ) );
636 635
637 Find = new QToolButton( menu, "Find" ); 636 Find = new QToolButton( menu, "Find" );
638 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); 637 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
639 Find->setText( tr( "" ) ); 638 Find->setText( tr( "" ) );
640 Find->setPixmap( find_img ); 639 Find->setPixmap( find_img );
641 QToolTip::add( Find, tr( "Find entry" ) ); 640 QToolTip::add( Find, tr( "Find entry" ) );
642 641
643/* 642/*
644 QBoxLayout * h = new QHBoxLayout( this ); 643 QBoxLayout * h = new QHBoxLayout( this );
645 h->addWidget (menu); 644 h->addWidget (menu);
646 h->addWidget (New); 645 h->addWidget (New);
647 h->addWidget (Edit); 646 h->addWidget (Edit);
648 h->addWidget (Delete); 647 h->addWidget (Delete);
649 h->addWidget (Find); 648 h->addWidget (Find);
650*/ 649*/
651 650
652 ListView = new ZListView( this, "ListView" ); 651 ListView = new ZListView( this, "ListView" );
653 ListView->addColumn( tr( "Name" ) ); 652 ListView->addColumn( tr( "Name" ) );
654 ListView->addColumn( tr( "Field 2" ) ); 653 ListView->addColumn( tr( "Field 2" ) );
655 ListView->addColumn( tr( "Field 3" ) ); 654 ListView->addColumn( tr( "Field 3" ) );
656 ListView->addColumn( tr( "Comment" ) ); 655 ListView->addColumn( tr( "Comment" ) );
657 ListView->addColumn( tr( "Field 4" ) ); 656 ListView->addColumn( tr( "Field 4" ) );
658 ListView->addColumn( tr( "Field 5" ) ); 657 ListView->addColumn( tr( "Field 5" ) );
659 ListView->setAllColumnsShowFocus(TRUE); 658 ListView->setAllColumnsShowFocus(TRUE);
660 659
661#ifdef DESKTOP 660#ifdef DESKTOP
662 ListView->setResizePolicy(QScrollView::AutoOneFit); 661 ListView->setResizePolicy(QScrollView::AutoOneFit);
663 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); 662 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
664#else 663#else
665 ListView->setResizePolicy(QScrollView::AutoOneFit); 664 ListView->setResizePolicy(QScrollView::AutoOneFit);
666 // ListView->setGeometry( QRect( 0, 22, 665 // ListView->setGeometry( QRect( 0, 22,
667 // this->width(), this->height() - 30 ) ); 666 // this->width(), this->height() - 30 ) );
668 // ListView->setMaximumSize( QSize( 440, 290 ) ); 667 // ListView->setMaximumSize( QSize( 440, 290 ) );
669#endif 668#endif
670 ListView->setVScrollBarMode( QListView::Auto ); 669 ListView->setVScrollBarMode( QListView::Auto );
671 670
672 QBoxLayout * l = new QVBoxLayout( this ); 671 QBoxLayout * l = new QVBoxLayout( this );
673 l->addWidget (menu); 672 l->addWidget (menu);
674 l->addWidget (ListView); 673 l->addWidget (ListView);
675 674
676#ifndef DESKTOP 675#ifndef DESKTOP
677 // start a timer (100 ms) to load the default document 676 // start a timer (100 ms) to load the default document
678 docuTimer.start( 100, true ); 677 docuTimer.start( 100, true );
679 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); 678 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) );
680 raiseFlag = true; 679 raiseFlag = true;
681 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); 680 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) );
682#else 681#else
683 // open the default document 682 // open the default document
684 openDocument(filename); 683 openDocument(filename);
685#endif 684#endif
686 685
687 // signals and slots connections for QTollButton 686 // signals and slots connections for QTollButton
688 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); 687 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) );
689 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); 688 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) );
690 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); 689 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) );
691 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); 690 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) );
692 // signals and slots connections for QListView 691 // signals and slots connections for QListView
693 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), 692 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ),
694 this, SLOT( listViewSelected(QListViewItem*) ) ); 693 this, SLOT( listViewSelected(QListViewItem*) ) );
695 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), 694 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ),
696 this, SLOT( showInfo(QListViewItem*) ) ); 695 this, SLOT( showInfo(QListViewItem*) ) );
697 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), 696 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ),
698 this, SLOT( showInfo(QListViewItem*) ) ); 697 this, SLOT( showInfo(QListViewItem*) ) );
699 698
700} 699}
701 700
702const QColor *ZSafe::evenRowColor = &Qt::white; 701const QColor *ZSafe::evenRowColor = &Qt::white;
703// const QColor *ZSafe::oddRowColor = &Qt::lightGray; 702// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
704const QColor *ZSafe::oddRowColor = new QColor(216,240,255); 703const QColor *ZSafe::oddRowColor = new QColor(216,240,255);
705 704
706/* 705/*
707 * Destroys the object and frees any allocated resources 706 * Destroys the object and frees any allocated resources
708 */ 707 */
709ZSafe::~ZSafe() 708ZSafe::~ZSafe()
710{ 709{
711 // no need to delete child widgets, Qt does it all for us 710 // no need to delete child widgets, Qt does it all for us
712 quitMe(); 711 quitMe();
713} 712}
714 713
715// load the default document 714// load the default document
716void ZSafe::slotLoadDocu() 715void ZSafe::slotLoadDocu()
717{ 716{
718 openDocument (filename); 717 openDocument (filename);
719} 718}
720 719
721void ZSafe::deletePwd() 720void ZSafe::deletePwd()
722{ 721{
723 722
724 if (!selectedItem) 723 if (!selectedItem)
725 return; 724 return;
726 if (!isCategory(selectedItem)) 725 if (!isCategory(selectedItem))
727 { 726 {
728 switch( QMessageBox::information( this, tr("ZSafe"), 727 switch( QMessageBox::information( this, tr("ZSafe"),
729 tr("Do you want to delete?"), 728 tr("Do you want to delete?"),
730 tr("&Delete"), tr("D&on't Delete"), 729 tr("&Delete"), tr("D&on't Delete"),
731 0 // Enter == button 0 730 0 // Enter == button 0
732 ) ) { // Escape == button 2 731 ) ) { // Escape == button 2
733 case 0: // Delete clicked, Alt-S or Enter pressed. 732 case 0: // Delete clicked, Alt-S or Enter pressed.
734 // Delete 733 // Delete
735 modified = true; 734 modified = true;
736 selectedItem->parent()->takeItem(selectedItem); 735 selectedItem->parent()->takeItem(selectedItem);
737 selectedItem = NULL; 736 selectedItem = NULL;
738 break; 737 break;
739 case 1: // Don't delete 738 case 1: // Don't delete
740 break; 739 break;
741 } 740 }
742 } 741 }
743 else 742 else
744 { 743 {
745 delCategory(); 744 delCategory();
746 } 745 }
747} 746}
748 747
749void ZSafe::editPwd() 748void ZSafe::editPwd()
750{ 749{
751 if (!selectedItem) 750 if (!selectedItem)
752 return; 751 return;
753 if (!isCategory(selectedItem)) 752 if (!isCategory(selectedItem))
754 { 753 {
755 // open the 'New Entry' dialog 754 // open the 'New Entry' dialog
756 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); 755 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
757#ifdef WIN32 756#ifdef WIN32
758 dialog->setCaption ("Qt " + tr("Edit Entry")); 757 dialog->setCaption ("Qt " + tr("Edit Entry"));
759 dialog->setGeometry(200, 250, 220, 310 ); 758 dialog->setGeometry(200, 250, 220, 310 );
760#endif 759#endif
761 760
762 // set the labels 761 // set the labels
763 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 762 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
764 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 763 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
765 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 764 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
766 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 765 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
767 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 766 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
768 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 767 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
769 768
770 // set the fields 769 // set the fields
771 dialog->NameField->setText(selectedItem->text (0)); 770 dialog->NameField->setText(selectedItem->text (0));
772 dialog->UsernameField->setText(selectedItem->text (1)); 771 dialog->UsernameField->setText(selectedItem->text (1));
773 dialog->PasswordField->setText(selectedItem->text (2)); 772 dialog->PasswordField->setText(selectedItem->text (2));
774 QString comment = selectedItem->text (3); 773 QString comment = selectedItem->text (3);
775 comment.replace (QRegExp("<br>"), "\n"); 774 comment.replace (QRegExp("<br>"), "\n");
776 dialog->Field5->setText(selectedItem->text (4)); 775 dialog->Field5->setText(selectedItem->text (4));
777 dialog->Field6->setText(selectedItem->text (5)); 776 dialog->Field6->setText(selectedItem->text (5));
778 dialog->CommentField->insertLine(comment); 777 dialog->CommentField->insertLine(comment);
779 dialog->CommentField->setCursorPosition(0,0); 778 dialog->CommentField->setCursorPosition(0,0);
780 779
781 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); 780 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
782 781
783#ifdef DESKTOP 782#ifdef DESKTOP
784 result = Accepted; 783 result = Accepted;
785#endif 784#endif
786 if (result == Accepted) 785 if (result == Accepted)
787 { 786 {
788 modified = true; 787 modified = true;
789 // edit the selected item 788 // edit the selected item
790 QString name = dialog->NameField->text(); 789 QString name = dialog->NameField->text();
791 selectedItem->setText (0, tr (name)); 790 selectedItem->setText (0, tr (name));
792 QString user = dialog->UsernameField->text(); 791 QString user = dialog->UsernameField->text();
793 selectedItem->setText (1, tr (user)); 792 selectedItem->setText (1, tr (user));
794 QString pwd = dialog->PasswordField->text(); 793 QString pwd = dialog->PasswordField->text();
795 selectedItem->setText (2, tr (pwd)); 794 selectedItem->setText (2, tr (pwd));
796 QString comment = dialog->CommentField->text(); 795 QString comment = dialog->CommentField->text();
797 comment.replace (QRegExp("\n"), "<br>"); 796 comment.replace (QRegExp("\n"), "<br>");
798 selectedItem->setText (3, tr (comment)); 797 selectedItem->setText (3, tr (comment));
799 QString f5 = dialog->Field5->text(); 798 QString f5 = dialog->Field5->text();
800 selectedItem->setText (4, tr (f5)); 799 selectedItem->setText (4, tr (f5));
801 QString f6 = dialog->Field6->text(); 800 QString f6 = dialog->Field6->text();
802 selectedItem->setText (5, tr (f6)); 801 selectedItem->setText (5, tr (f6));
803 } 802 }
804 803
805 delete dialog; 804 delete dialog;
806 } 805 }
807 else 806 else
808 { 807 {
809 editCategory(); 808 editCategory();
810 } 809 }
811} 810}
812 811
813void ZSafe::newPwd() 812void ZSafe::newPwd()
814{ 813{
815 if (!selectedItem) 814 if (!selectedItem)
816 return; 815 return;
817 816
818 if (!isCategory(selectedItem)) 817 if (!isCategory(selectedItem))
819 selectedItem = selectedItem->parent(); 818 selectedItem = selectedItem->parent();
820 819
821 if (isCategory(selectedItem)) 820 if (isCategory(selectedItem))
822 { 821 {
823 QString cat = selectedItem->text(0); 822 QString cat = selectedItem->text(0);
824 823
825 // open the 'New Entry' dialog 824 // open the 'New Entry' dialog
826 NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); 825 NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
827#ifdef WIN32 826#ifdef WIN32
828 dialog->setCaption ("Qt " + tr("New Entry")); 827 dialog->setCaption ("Qt " + tr("New Entry"));
829 dialog->setGeometry(200, 250, 220, 310 ); 828 dialog->setGeometry(200, 250, 220, 310 );
830#endif 829#endif
831 // set the labels 830 // set the labels
832 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 831 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
833 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 832 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
834 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 833 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
835 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 834 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
836 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 835 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
837 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 836 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
838retype: 837retype:
839 838
840 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); 839 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
841#ifdef DESKTOP 840#ifdef DESKTOP
842 result = Accepted; 841 result = Accepted;
843#endif 842#endif
844 843
845 if (result == Accepted) 844 if (result == Accepted)
846 { 845 {
847 846
848 QString name = dialog->NameField->text(); 847 QString name = dialog->NameField->text();
849 if (cat == name) 848 if (cat == name)
850 { 849 {
851 QMessageBox::critical( 0, tr("ZSafe"), 850 QMessageBox::critical( 0, tr("ZSafe"),
852 tr("Entry name must be different\nfrom the category name.") ); 851 tr("Entry name must be different\nfrom the category name.") );
853 goto retype; // it's not a good programming style :-) 852 goto retype; // it's not a good programming style :-)
854 } 853 }
855 854
856 modified = true; 855 modified = true;
857 // add the new item 856 // add the new item
858 QListViewItem *i = new ShadedListItem (0, selectedItem); 857 QListViewItem *i = new ShadedListItem (0, selectedItem);
859 i->setOpen (TRUE); 858 i->setOpen (TRUE);
860 859
861 i->setText (0, tr (name)); 860 i->setText (0, tr (name));
862 QString user = dialog->UsernameField->text(); 861 QString user = dialog->UsernameField->text();
863 i->setText (1, tr (user)); 862 i->setText (1, tr (user));
864 QString pwd = dialog->PasswordField->text(); 863 QString pwd = dialog->PasswordField->text();
865 i->setText (2, tr (pwd)); 864 i->setText (2, tr (pwd));
866 QString comment = dialog->CommentField->text(); 865 QString comment = dialog->CommentField->text();
867 comment.replace (QRegExp("\n"), "<br>"); 866 comment.replace (QRegExp("\n"), "<br>");
868 i->setText (3, tr (comment)); 867 i->setText (3, tr (comment));
869 QString f5 = dialog->Field5->text(); 868 QString f5 = dialog->Field5->text();
870 i->setText (4, tr (f5)); 869 i->setText (4, tr (f5));
871 QString f6 = dialog->Field6->text(); 870 QString f6 = dialog->Field6->text();
872 i->setText (5, tr (f6)); 871 i->setText (5, tr (f6));
873 } 872 }
874 873
875 delete dialog; 874 delete dialog;
876 } 875 }
877} 876}
878 877
879void ZSafe::findPwd() 878void ZSafe::findPwd()
880{ 879{
881 880
882 // open the 'Search' dialog 881 // open the 'Search' dialog
883 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); 882 SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
884#ifdef WIN32 883#ifdef WIN32
885 dialog->setCaption ("Qt " + tr("Search")); 884 dialog->setCaption ("Qt " + tr("Search"));
886#endif 885#endif
887 886
888#ifdef DESKTOP 887#ifdef DESKTOP
889#endif 888#endif
890 if (lastSearchedName) 889 if (lastSearchedName)
891 dialog->NameField->setText(lastSearchedName); 890 dialog->NameField->setText(lastSearchedName);
892 else 891 else
893 dialog->NameField->setText(""); 892 dialog->NameField->setText("");
894 if (lastSearchedUsername) 893 if (lastSearchedUsername)
895 dialog->UsernameField->setText(lastSearchedUsername); 894 dialog->UsernameField->setText(lastSearchedUsername);
896 else 895 else
897 dialog->UsernameField->setText(""); 896 dialog->UsernameField->setText("");
898 if (lastSearchedComment) 897 if (lastSearchedComment)
899 dialog->CommentField->setText(lastSearchedComment); 898 dialog->CommentField->setText(lastSearchedComment);
900 else 899 else
901 dialog->CommentField->setText(""); 900 dialog->CommentField->setText("");
902 DialogCode result = (DialogCode) dialog->exec(); 901 DialogCode result = (DialogCode) dialog->exec();
903#ifdef DESKTOP 902#ifdef DESKTOP
904 result = Accepted; 903 result = Accepted;
905#endif 904#endif
906 905
907 QString name; 906 QString name;
908 QString username; 907 QString username;
909 QString comment; 908 QString comment;
910 if (result == Accepted) 909 if (result == Accepted)
911 { 910 {
912 name = dialog->NameField->text(); 911 name = dialog->NameField->text();
913 username = dialog->UsernameField->text(); 912 username = dialog->UsernameField->text();
914 comment = dialog->CommentField->text(); 913 comment = dialog->CommentField->text();
915 qWarning (name); 914 qWarning (name);
916 } 915 }
917 else 916 else
918 { 917 {
919 delete dialog; 918 delete dialog;
920 return; 919 return;
921 } 920 }
922 921
923 if (!name.isEmpty() && name != lastSearchedName || 922 if (!name.isEmpty() && name != lastSearchedName ||
924 lastSearchedName.isEmpty() && !name.isEmpty()) 923 lastSearchedName.isEmpty() && !name.isEmpty())
925 { 924 {
926 // set search at the beginning if a new name is given 925 // set search at the beginning if a new name is given
927 lastSearchedCategory = NULL; 926 lastSearchedCategory = NULL;
928 lastSearchedItem = NULL; 927 lastSearchedItem = NULL;
929 } 928 }
930 lastSearchedName = name; 929 lastSearchedName = name;
931 if (!username.isEmpty() && username != lastSearchedUsername || 930 if (!username.isEmpty() && username != lastSearchedUsername ||
932 lastSearchedUsername.isEmpty() && !username.isEmpty()) 931 lastSearchedUsername.isEmpty() && !username.isEmpty())
933 { 932 {
934 // set search at the beginning if a new name is given 933 // set search at the beginning if a new name is given
935 lastSearchedCategory = NULL; 934 lastSearchedCategory = NULL;
936 lastSearchedItem = NULL; 935 lastSearchedItem = NULL;
937 } 936 }
938 lastSearchedUsername = username; 937 lastSearchedUsername = username;
939 if (!comment.isEmpty() && comment != lastSearchedComment || 938 if (!comment.isEmpty() && comment != lastSearchedComment ||
940 lastSearchedComment.isEmpty() && !comment.isEmpty()) 939 lastSearchedComment.isEmpty() && !comment.isEmpty())
941 { 940 {
942 // set search at the beginning if a new name is given 941 // set search at the beginning if a new name is given
943 lastSearchedCategory = NULL; 942 lastSearchedCategory = NULL;
944 lastSearchedItem = NULL; 943 lastSearchedItem = NULL;
945 } 944 }
946 lastSearchedComment = comment; 945 lastSearchedComment = comment;
947 946
948 ListView->clearSelection(); 947 ListView->clearSelection();
949 948
950 bool found=FALSE; 949 bool found=FALSE;
951 // step through all categories 950 // step through all categories
952 QListViewItem *i; 951 QListViewItem *i;
953 if (lastSearchedCategory) 952 if (lastSearchedCategory)
954 i = lastSearchedCategory; 953 i = lastSearchedCategory;
955 else 954 else
956 i = ListView->firstChild(); 955 i = ListView->firstChild();
957 for (; 956 for (;
958 i != NULL; 957 i != NULL;
959 i = i->nextSibling()) 958 i = i->nextSibling())
960 { 959 {
961 qWarning (i->text(0)); 960 qWarning (i->text(0));
962 i->setSelected(FALSE); 961 i->setSelected(FALSE);
963 962
964 // step through all subitems 963 // step through all subitems
965 QListViewItem *si; 964 QListViewItem *si;
966 if (lastSearchedItem) 965 if (lastSearchedItem)
967 si = lastSearchedItem; 966 si = lastSearchedItem;
968 else 967 else
969 si = i->firstChild(); 968 si = i->firstChild();
970 // for (si = i->firstChild(); 969 // for (si = i->firstChild();
971 for (; 970 for (;
972 si != NULL; 971 si != NULL;
973 si = si->nextSibling()) 972 si = si->nextSibling())
974 { 973 {
975 qWarning (si->text(0)); 974 qWarning (si->text(0));
976 if (si->isSelected()) 975 if (si->isSelected())
977 si->setSelected(FALSE); 976 si->setSelected(FALSE);
978 // ListView->repaintItem(si); 977 // ListView->repaintItem(si);
979 978
980 bool n=TRUE; 979 bool n=TRUE;
981 bool u=TRUE; 980 bool u=TRUE;
982 bool c=TRUE; 981 bool c=TRUE;
983 if (!name.isEmpty()) 982 if (!name.isEmpty())
984 n = (si->text(0)).contains (name, FALSE); 983 n = (si->text(0)).contains (name, FALSE);
985 if (!username.isEmpty()) 984 if (!username.isEmpty())
986 u = (si->text(1)).contains (username, FALSE); 985 u = (si->text(1)).contains (username, FALSE);
987 if (!comment.isEmpty()) 986 if (!comment.isEmpty())
988 c = (si->text(3)).contains (comment, FALSE); 987 c = (si->text(3)).contains (comment, FALSE);
989 988
990 if ((n && u && c ) && !found) 989 if ((n && u && c ) && !found)
991 { 990 {
992 qWarning ("Found"); 991 qWarning ("Found");
993 selectedItem = si; 992 selectedItem = si;
994 si->setSelected(TRUE); 993 si->setSelected(TRUE);
995 ListView->setCurrentItem(si); 994 ListView->setCurrentItem(si);
996 ListView->ensureItemVisible(si); 995 ListView->ensureItemVisible(si);
997 ListView->triggerUpdate(); 996 ListView->triggerUpdate();
998 997
999 lastSearchedCategory = i; 998 lastSearchedCategory = i;
1000 // set to the next item 999 // set to the next item
1001 lastSearchedItem = si->nextSibling(); 1000 lastSearchedItem = si->nextSibling();
1002 if (!lastSearchedItem) 1001 if (!lastSearchedItem)
1003 { 1002 {
1004 // no next item within category -> set next category 1003 // no next item within category -> set next category
1005 lastSearchedCategory = i->nextSibling(); 1004 lastSearchedCategory = i->nextSibling();
1006 if (!lastSearchedCategory) 1005 if (!lastSearchedCategory)
1007 lastSearchedItem = NULL; // END 1006 lastSearchedItem = NULL; // END
1008 } 1007 }
1009 1008
1010 found = TRUE; 1009 found = TRUE;
1011 delete dialog; 1010 delete dialog;
1012 update(); 1011 update();
1013 return; 1012 return;
1014 } 1013 }
1015 } 1014 }
1016 lastSearchedCategory = i->nextSibling(); 1015 lastSearchedCategory = i->nextSibling();
1017 lastSearchedItem = NULL; 1016 lastSearchedItem = NULL;
1018 } 1017 }
1019 lastSearchedCategory = NULL; 1018 lastSearchedCategory = NULL;
1020 lastSearchedItem = NULL; 1019 lastSearchedItem = NULL;
1021 delete dialog; 1020 delete dialog;
1022 update(); 1021 update();
1023 QMessageBox::information( this, tr("ZSafe"), 1022 QMessageBox::information( this, tr("ZSafe"),
1024 tr("Entry not found"), tr("&OK"), 0); 1023 tr("Entry not found"), tr("&OK"), 0);
1025 1024
1026} 1025}
1027 1026
1028QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) 1027QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
1029{ 1028{
1030 QString category; 1029 QString category;
1031 if (_item) 1030 if (_item)
1032 { 1031 {
1033 if (isCategory(_item)) 1032 if (isCategory(_item))
1034 { 1033 {
1035 category = _item->text(0); 1034 category = _item->text(0);
1036 } 1035 }
1037 else 1036 else
1038 { 1037 {
1039 QListViewItem *cat = _item->parent(); 1038 QListViewItem *cat = _item->parent();
1040 category = cat->text(0); 1039 category = cat->text(0);
1041 } 1040 }
1042 } 1041 }
1043 else 1042 else
1044 { 1043 {
1045 return def; 1044 return def;
1046 } 1045 }
1047 1046
1048 QString app_key = APP_KEY; 1047 QString app_key = APP_KEY;
1049#ifndef DESKTOP 1048#ifndef DESKTOP
1050#ifndef WIN32 1049#ifndef WIN32
1051 conf->setGroup ("fieldDefs"); 1050 conf->setGroup ("fieldDefs");
1052#endif 1051#endif
1053#else 1052#else
1054#ifndef WIN32 1053#ifndef WIN32
1055 app_key += "/fieldDefs/"; 1054 app_key += "/fieldDefs/";
1056#endif 1055#endif
1057#endif 1056#endif
1058// #ifndef WIN32 1057// #ifndef WIN32
1059 QString label = conf->readEntry(app_key+category+"-field"+field,def); 1058 QString label = conf->readEntry(app_key+category+"-field"+field,def);
1060// #else 1059// #else
1061// QString label(def); 1060// QString label(def);
1062// #endif 1061// #endif
1063 1062
1064#ifndef DESKTOP 1063#ifndef DESKTOP
1065 conf->setGroup ("zsafe"); 1064 conf->setGroup ("zsafe");
1066#endif 1065#endif
1067 return label; 1066 return label;
1068} 1067}
1069 1068
1070QString ZSafe::getFieldLabel (QString category, QString field, QString def) 1069QString ZSafe::getFieldLabel (QString category, QString field, QString def)
1071{ 1070{
1072 QString app_key = APP_KEY; 1071 QString app_key = APP_KEY;
1073#ifndef DESKTOP 1072#ifndef DESKTOP
1074 conf->setGroup ("fieldDefs"); 1073 conf->setGroup ("fieldDefs");
1075#else 1074#else
1076#ifndef WIN32 1075#ifndef WIN32
1077 app_key += "/fieldDefs/"; 1076 app_key += "/fieldDefs/";
1078#endif 1077#endif
1079#endif 1078#endif
1080// #ifndef WIN32 1079// #ifndef WIN32
1081 QString label = conf->readEntry(app_key+category+"-field"+field, 1080 QString label = conf->readEntry(app_key+category+"-field"+field,
1082 def); 1081 def);
1083// #else 1082// #else
1084 // QString label(def); 1083 // QString label(def);
1085// #endif 1084// #endif
1086#ifndef DESKTOP 1085#ifndef DESKTOP
1087 conf->setGroup ("zsafe"); 1086 conf->setGroup ("zsafe");
1088#endif 1087#endif
1089 return label; 1088 return label;
1090} 1089}
1091 1090
1092void ZSafe::showInfo( QListViewItem *_item) 1091void ZSafe::showInfo( QListViewItem *_item)
1093{ 1092{
1094 if (!_item) 1093 if (!_item)
1095 return; 1094 return;
1096 if (selectedItem != NULL) 1095 if (selectedItem != NULL)
1097 selectedItem->setSelected(FALSE); 1096 selectedItem->setSelected(FALSE);
1098 1097
1099 selectedItem = _item; 1098 selectedItem = _item;
1100 selectedItem->setSelected(TRUE); 1099 selectedItem->setSelected(TRUE);
1101 1100
1102 if (!isCategory(_item)) 1101 if (!isCategory(_item))
1103 { 1102 {
1104/* 1103/*
1105 QString label=selectedItem->text(0); 1104 QString label=selectedItem->text(0);
1106 label+="\n"; 1105 label+="\n";
1107 label+=selectedItem->text(1); 1106 label+=selectedItem->text(1);
1108 label+="\n"; 1107 label+="\n";
1109 label+=selectedItem->text(2); 1108 label+=selectedItem->text(2);
1110 label+="\n"; 1109 label+="\n";
1111 label+=selectedItem->text(3); 1110 label+=selectedItem->text(3);
1112*/ 1111*/
1113 1112
1114 QString text; 1113 QString text;
1115 QString entry; 1114 QString entry;
1116 1115
1117 text = "<html><body><div align=""center""><u><b>"; 1116 text = "<html><body><div align=""center""><u><b>";
1118 text += selectedItem->text(0); 1117 text += selectedItem->text(0);
1119 text += "</b></u><br></div><br>"; 1118 text += "</b></u><br></div><br>";
1120 1119
1121 entry = selectedItem->text(1); 1120 entry = selectedItem->text(1);
1122 if (!entry.isEmpty() && entry.compare(" ")) 1121 if (!entry.isEmpty() && entry.compare(" "))
1123 { 1122 {
1124 text += "<u><b>"; 1123 text += "<u><b>";
1125 text += getFieldLabel (selectedItem, "2", tr("Username")); 1124 text += getFieldLabel (selectedItem, "2", tr("Username"));
1126 text += ":<br></b></u><blockquote>"; 1125 text += ":<br></b></u><blockquote>";
1127 text += entry; 1126 text += entry;
1128 text += "</blockquote>"; 1127 text += "</blockquote>";
1129 // text += "<br>"; 1128 // text += "<br>";
1130 } 1129 }
1131 1130
1132 entry = selectedItem->text(2); 1131 entry = selectedItem->text(2);
1133 if (!entry.isEmpty() && entry.compare(" ")) 1132 if (!entry.isEmpty() && entry.compare(" "))
1134 { 1133 {
1135 text += "<u><b>"; 1134 text += "<u><b>";
1136 text += getFieldLabel (selectedItem, "3", tr("Password")); 1135 text += getFieldLabel (selectedItem, "3", tr("Password"));
1137 text += ":<br> </b></u><blockquote>"; 1136 text += ":<br> </b></u><blockquote>";
1138 text += entry; 1137 text += entry;
1139 text += "</blockquote>"; 1138 text += "</blockquote>";
1140 // text += "<br>"; 1139 // text += "<br>";
1141 } 1140 }
1142 1141
1143 entry = selectedItem->text(4); 1142 entry = selectedItem->text(4);
1144 if (!entry.isEmpty() && entry.compare(" ")) 1143 if (!entry.isEmpty() && entry.compare(" "))
1145 { 1144 {
1146 text += "<u><b>"; 1145 text += "<u><b>";
1147 text += getFieldLabel (selectedItem, "5", tr("Field 4")); 1146 text += getFieldLabel (selectedItem, "5", tr("Field 4"));
1148 text += ":<br> </b></u><blockquote>"; 1147 text += ":<br> </b></u><blockquote>";
1149 text += entry; 1148 text += entry;
1150 text += "</blockquote>"; 1149 text += "</blockquote>";
1151 // text += "<br>"; 1150 // text += "<br>";
1152 } 1151 }
1153 1152
1154 entry = selectedItem->text(5); 1153 entry = selectedItem->text(5);
1155 if (!entry.isEmpty() && entry.compare(" ")) 1154 if (!entry.isEmpty() && entry.compare(" "))
1156 { 1155 {
1157 text += "<u><b>"; 1156 text += "<u><b>";
1158 text += getFieldLabel (selectedItem, "6", tr("Field 5")); 1157 text += getFieldLabel (selectedItem, "6", tr("Field 5"));
1159 text += ":<br> </b></u><blockquote>"; 1158 text += ":<br> </b></u><blockquote>";
1160 text += entry; 1159 text += entry;
1161 text += "</blockquote>"; 1160 text += "</blockquote>";
1162 // text += "<br>"; 1161 // text += "<br>";
1163 } 1162 }
1164 1163
1165 entry = selectedItem->text(3); 1164 entry = selectedItem->text(3);
1166 if (!entry.isEmpty() && entry.compare(" ")) 1165 if (!entry.isEmpty() && entry.compare(" "))
1167 { 1166 {
1168 text += "<u><b>"; 1167 text += "<u><b>";
1169 text += getFieldLabel (selectedItem, "4", tr("Comment")); 1168 text += getFieldLabel (selectedItem, "4", tr("Comment"));
1170 text += ":<br> </b></u>"; 1169 text += ":<br> </b></u>";
1171 QString comment = selectedItem->text(3); 1170 QString comment = selectedItem->text(3);
1172 comment.replace (QRegExp("\n"), "<br>"); 1171 comment.replace (QRegExp("\n"), "<br>");
1173 text += comment; 1172 text += comment;
1174 // text += "<br>"; 1173 // text += "<br>";
1175 } 1174 }
1176 1175
1177 text += "</body></html>"; 1176 text += "</body></html>";
1178 1177
1179 infoForm->InfoText->setText(text); 1178 infoForm->InfoText->setText(text);
1180 infoForm->hide(); 1179 infoForm->hide();
1181 QPEApplication::showDialog( infoForm ); 1180 QPEApplication::showDialog( infoForm );
1182 } 1181 }
1183} 1182}
1184 1183
1185void ZSafe::listViewSelected( QListViewItem *_item) 1184void ZSafe::listViewSelected( QListViewItem *_item)
1186{ 1185{
1187 if (!_item) 1186 if (!_item)
1188 return; 1187 return;
1189 if (selectedItem != NULL) 1188 if (selectedItem != NULL)
1190 selectedItem->setSelected(FALSE); 1189 selectedItem->setSelected(FALSE);
1191 1190
1192 selectedItem = _item; 1191 selectedItem = _item;
1193 1192
1194#ifndef DESKTOP 1193#ifndef DESKTOP
1195 // set the column text dependent on the selected item 1194 // set the column text dependent on the selected item
1196 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1195 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1197 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1196 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1198 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1197 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1199 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1198 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1200 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1199 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1201 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1200 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1202#endif 1201#endif
1203#ifdef WIN32 1202#ifdef WIN32
1204 // set the column text dependent on the selected item 1203 // set the column text dependent on the selected item
1205 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1204 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1206 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1205 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1207 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1206 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1208 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1207 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1209 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1208 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1210 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1209 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1211#endif 1210#endif
1212 1211
1213} 1212}
1214 1213
1215bool ZSafe::isCategory(QListViewItem *_item) 1214bool ZSafe::isCategory(QListViewItem *_item)
1216{ 1215{
1217 if (_item == NULL) 1216 if (_item == NULL)
1218 return FALSE; 1217 return FALSE;
1219 1218
1220 QString categoryName = _item->text (0); 1219 QString categoryName = _item->text (0);
1221 if (categories.find (categoryName)) 1220 if (categories.find (categoryName))
1222 return TRUE; 1221 return TRUE;
1223 else 1222 else
1224 return FALSE; 1223 return FALSE;
1225} 1224}
1226 1225
1227void ZSafe::removeAsciiFile() 1226void ZSafe::removeAsciiFile()
1228{ 1227{
1229 // QString fn = filename + ".txt"; 1228 // QString fn = filename + ".txt";
1230 // open the file dialog 1229 // open the file dialog
1231#ifndef DESKTOP 1230#ifndef DESKTOP
1232#ifndef NO_OPIE 1231#ifndef NO_OPIE
1233 QMap<QString, QStringList> mimeTypes; 1232 QMap<QString, QStringList> mimeTypes;
1234 mimeTypes.insert(tr("All"), QStringList() ); 1233 mimeTypes.insert(tr("All"), QStringList() );
1235 mimeTypes.insert(tr("Text"), "text/*" ); 1234 mimeTypes.insert(tr("Text"), "text/*" );
1236 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1235 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1237 QDir::homeDirPath() + "/Documents/application/zsafe", 1236 QDir::homeDirPath() + "/Documents/application/zsafe",
1238 QString::null, 1237 QString::null,
1239 mimeTypes, 1238 mimeTypes,
1240 this, 1239 this,
1241 tr ("Remove text file")); 1240 tr ("Remove text file"));
1242#else 1241#else
1243 QString fn = ScQtFileEdit::getOpenFileName(this, 1242 QString fn = ScQtFileEdit::getOpenFileName(this,
1244 tr ("Remove text file"), 1243 tr ("Remove text file"),
1245 QDir::homeDirPath() + "/Documents/application/zsafe", 1244 QDir::homeDirPath() + "/Documents/application/zsafe",
1246 "*.txt"); 1245 "*.txt");
1247#endif 1246#endif
1248#else 1247#else
1249 QString fn = QFileDialog::getOpenFileName( 1248 QString fn = QFileDialog::getOpenFileName(
1250 QDir::homeDirPath() + "/Documents/application/zsafe", 1249 QDir::homeDirPath() + "/Documents/application/zsafe",
1251 "ZSafe (*.txt)", 1250 "ZSafe (*.txt)",
1252 this, 1251 this,
1253 "ZSafe File Dialog" 1252 "ZSafe File Dialog"
1254 "Choose a text file" ); 1253 "Choose a text file" );
1255#endif 1254#endif
1256 1255
1257 if (fn && fn.length() > 0 ) 1256 if (fn && fn.length() > 0 )
1258 { 1257 {
1259 QFile f( fn ); 1258 QFile f( fn );
1260 if ( !f.remove() ) 1259 if ( !f.remove() )
1261 { 1260 {
1262 qWarning( QString("Could not remove file %1").arg(fn), 1261 qWarning( QString("Could not remove file %1").arg(fn),
1263 2000 ); 1262 2000 );
1264 QMessageBox::critical( 0, tr("ZSafe"), 1263 QMessageBox::critical( 0, tr("ZSafe"),
1265 tr("Could not remove text file.") ); 1264 tr("Could not remove text file.") );
1266 return; 1265 return;
1267 } 1266 }
1268 } 1267 }
1269} 1268}
1270 1269
1271void ZSafe::writeAllEntries() 1270void ZSafe::writeAllEntries()
1272{ 1271{
1273 if (filename.isEmpty()) 1272 if (filename.isEmpty())
1274 { 1273 {
1275 QMessageBox::critical( 0, tr("ZSafe"), 1274 QMessageBox::critical( 0, tr("ZSafe"),
1276 tr("No document defined.\nYou have to create a new document")); 1275 tr("No document defined.\nYou have to create a new document"));
1277 return; 1276 return;
1278 } 1277 }
1279 1278
1280 // open the file dialog 1279 // open the file dialog
1281#ifndef DESKTOP 1280#ifndef DESKTOP
1282#ifndef NO_OPIE 1281#ifndef NO_OPIE
1283 QMap<QString, QStringList> mimeTypes; 1282 QMap<QString, QStringList> mimeTypes;
1284 mimeTypes.insert(tr("All"), QStringList() ); 1283 mimeTypes.insert(tr("All"), QStringList() );
1285 mimeTypes.insert(tr("Text"), "text/*" ); 1284 mimeTypes.insert(tr("Text"), "text/*" );
1286 QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, 1285 QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
1287 QDir::homeDirPath() + "/Documents/application/zsafe", 1286 QDir::homeDirPath() + "/Documents/application/zsafe",
1288 QString::null, 1287 QString::null,
1289 mimeTypes, 1288 mimeTypes,
1290 this, 1289 this,
1291 tr ("Export text file")); 1290 tr ("Export text file"));
1292#else 1291#else
1293 QString fn = ScQtFileEdit::getSaveAsFileName(this, 1292 QString fn = ScQtFileEdit::getSaveAsFileName(this,
1294 tr ("Export text file"), 1293 tr ("Export text file"),
1295 QDir::homeDirPath() + "/Documents/application/zsafe", 1294 QDir::homeDirPath() + "/Documents/application/zsafe",
1296 "*.txt"); 1295 "*.txt");
1297#endif 1296#endif
1298#else 1297#else
1299 QString fn = QFileDialog::getSaveFileName( 1298 QString fn = QFileDialog::getSaveFileName(
1300 QDir::homeDirPath() + "/Documents/application/zsafe", 1299 QDir::homeDirPath() + "/Documents/application/zsafe",
1301 "ZSafe (*.txt)", 1300 "ZSafe (*.txt)",
1302 this, 1301 this,
1303 "ZSafe File Dialog" 1302 "ZSafe File Dialog"
1304 "Choose a text file" ); 1303 "Choose a text file" );
1305#endif 1304#endif
1306 1305
1307 // open the new document 1306 // open the new document
1308 if (fn && fn.length() > 0 ) 1307 if (fn && fn.length() > 0 )
1309 { 1308 {
1310 QFile f( fn ); 1309 QFile f( fn );
1311 if ( !f.open( IO_WriteOnly ) ) { 1310 if ( !f.open( IO_WriteOnly ) ) {
1312 qWarning( QString("Could not write to file %1").arg(fn), 1311 qWarning( QString("Could not write to file %1").arg(fn),
1313 2000 ); 1312 2000 );
1314 QMessageBox::critical( 0, "ZSafe", 1313 QMessageBox::critical( 0, "ZSafe",
1315 QString("Could not export to text file.") ); 1314 QString("Could not export to text file.") );
1316 return; 1315 return;
1317 } 1316 }
1318 QTextStream t( &f ); 1317 QTextStream t( &f );
1319 1318
1320 QListViewItem *i; 1319 QListViewItem *i;
1321 // step through all categories 1320 // step through all categories
1322 for (i = ListView->firstChild(); 1321 for (i = ListView->firstChild();
1323 i != NULL; 1322 i != NULL;
1324 i = i->nextSibling()) 1323 i = i->nextSibling())
1325 { 1324 {
1326 // step through all subitems 1325 // step through all subitems
1327 QListViewItem *si; 1326 QListViewItem *si;
1328 for (si = i->firstChild(); 1327 for (si = i->firstChild();
1329 si != NULL; 1328 si != NULL;
1330 si = si->nextSibling()) 1329 si = si->nextSibling())
1331 { 1330 {
1332 QString oneEntry; 1331 QString oneEntry;
1333 oneEntry += "\""; 1332 oneEntry += "\"";
1334 oneEntry += i->text(0); 1333 oneEntry += i->text(0);
1335 oneEntry += "\";"; 1334 oneEntry += "\";";
1336 oneEntry += "\""; 1335 oneEntry += "\"";
1337 oneEntry += si->text(0); 1336 oneEntry += si->text(0);
1338 oneEntry += "\";"; 1337 oneEntry += "\";";
1339 oneEntry += "\""; 1338 oneEntry += "\"";
1340 oneEntry += si->text(1); 1339 oneEntry += si->text(1);
1341 oneEntry += "\";"; 1340 oneEntry += "\";";
1342 oneEntry += "\""; 1341 oneEntry += "\"";
1343 oneEntry += si->text(2); 1342 oneEntry += si->text(2);
1344 oneEntry += "\";"; 1343 oneEntry += "\";";
1345 oneEntry += "\""; 1344 oneEntry += "\"";
1346 QString comment = si->text(3); 1345 QString comment = si->text(3);
1347 comment.replace (QRegExp("\n"), "<br>"); 1346 comment.replace (QRegExp("\n"), "<br>");
1348 oneEntry += comment; 1347 oneEntry += comment;
1349 oneEntry += "\";"; 1348 oneEntry += "\";";
1350 oneEntry += "\""; 1349 oneEntry += "\"";
1351 oneEntry += si->text(4); 1350 oneEntry += si->text(4);
1352 oneEntry += "\";"; 1351 oneEntry += "\";";
1353 oneEntry += "\""; 1352 oneEntry += "\"";
1354 oneEntry += si->text(5); 1353 oneEntry += si->text(5);
1355 oneEntry += "\""; 1354 oneEntry += "\"";
1356 // qWarning (oneEntry); 1355 // qWarning (oneEntry);
1357 t << oneEntry << endl; 1356 t << oneEntry << endl;
1358 1357
1359 // qWarning (si->text(0)); 1358 // qWarning (si->text(0));
1360 } 1359 }
1361 } 1360 }
1362 f.close(); 1361 f.close();
1363 } 1362 }
1364} 1363}
1365 1364
1366void ZSafe::readAllEntries() 1365void ZSafe::readAllEntries()
1367{ 1366{
1368 if (filename.isEmpty()) 1367 if (filename.isEmpty())
1369 { 1368 {
1370 QMessageBox::critical( 0, tr("ZSafe"), 1369 QMessageBox::critical( 0, tr("ZSafe"),
1371 tr("No document defined.\nYou have to create a new document")); 1370 tr("No document defined.\nYou have to create a new document"));
1372 return; 1371 return;
1373 } 1372 }
1374 1373
1375 // open the file dialog 1374 // open the file dialog
1376#ifndef DESKTOP 1375#ifndef DESKTOP
1377#ifndef NO_OPIE 1376#ifndef NO_OPIE
1378 QMap<QString, QStringList> mimeTypes; 1377 QMap<QString, QStringList> mimeTypes;
1379 mimeTypes.insert(tr("All"), QStringList() ); 1378 mimeTypes.insert(tr("All"), QStringList() );
1380 mimeTypes.insert(tr("Text"), "text/*" ); 1379 mimeTypes.insert(tr("Text"), "text/*" );
1381 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1380 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1382 QDir::homeDirPath() + "/Documents/application/zsafe", 1381 QDir::homeDirPath() + "/Documents/application/zsafe",
1383 QString::null, 1382 QString::null,
1384 mimeTypes, 1383 mimeTypes,
1385 this, 1384 this,
1386 tr ("Import text file")); 1385 tr ("Import text file"));
1387#else 1386#else
1388 QString fn = ScQtFileEdit::getOpenFileName(this, 1387 QString fn = ScQtFileEdit::getOpenFileName(this,
1389 tr ("Import text file"), 1388 tr ("Import text file"),
1390 QDir::homeDirPath() + "/Documents/application/zsafe", 1389 QDir::homeDirPath() + "/Documents/application/zsafe",
1391 "*.txt"); 1390 "*.txt");
1392#endif 1391#endif
1393#else 1392#else
1394 QString fn = QFileDialog::getOpenFileName( 1393 QString fn = QFileDialog::getOpenFileName(
1395 QDir::homeDirPath() + "/Documents/application/zsafe", 1394 QDir::homeDirPath() + "/Documents/application/zsafe",
1396 "ZSafe (*.txt)", 1395 "ZSafe (*.txt)",
1397 this, 1396 this,
1398 "ZSafe File Dialog" 1397 "ZSafe File Dialog"
1399 "Choose a text file" ); 1398 "Choose a text file" );
1400#endif 1399#endif
1401 1400
1402 if (fn && fn.length() > 0 ) 1401 if (fn && fn.length() > 0 )
1403 { 1402 {
1404 QFile f( fn ); 1403 QFile f( fn );
1405 if ( !f.open( IO_ReadOnly ) ) 1404 if ( !f.open( IO_ReadOnly ) )
1406 { 1405 {
1407 qWarning( QString("Could not read file %1").arg(fn), 1406 qWarning( QString("Could not read file %1").arg(fn),
1408 2000 ); 1407 2000 );
1409 QMessageBox::critical( 0, "ZSafe", 1408 QMessageBox::critical( 0, "ZSafe",
1410 QString("Could not import text file.") ); 1409 QString("Could not import text file.") );
1411 return; 1410 return;
1412 } 1411 }
1413 1412
1414 modified = true; 1413 modified = true;
1415 1414
1416 // clear the password list 1415 // clear the password list
1417 selectedItem = NULL; 1416 selectedItem = NULL;
1418 QListViewItem *i; 1417 QListViewItem *i;
1419 // step through all categories 1418 // step through all categories
1420 for (i = ListView->firstChild(); 1419 for (i = ListView->firstChild();
1421 i != NULL; 1420 i != NULL;
1422 i = i->nextSibling()) 1421 i = i->nextSibling())
1423 { 1422 {
1424 // step through all subitems 1423 // step through all subitems
1425 QListViewItem *si; 1424 QListViewItem *si;
1426 for (si = i->firstChild(); 1425 for (si = i->firstChild();
1427 si != NULL; ) 1426 si != NULL; )
1428 // si = si->nextSibling()) 1427 // si = si->nextSibling())
1429 { 1428 {
1430 QListViewItem *_si = si; 1429 QListViewItem *_si = si;
1431 si = si->nextSibling(); 1430 si = si->nextSibling();
1432 i->takeItem(_si); // remove from view list 1431 i->takeItem(_si); // remove from view list
1433 if (_si) delete _si; 1432 if (_si) delete _si;
1434 } 1433 }
1435 } 1434 }
1436 1435
1437 qWarning ("ReadAllEntries(): "); 1436 qWarning ("ReadAllEntries(): ");
1438 1437
1439 QTextStream t(&f); 1438 QTextStream t(&f);
1440 while ( !t.eof() ) 1439 while ( !t.eof() )
1441 { 1440 {
1442 QString s = t.readLine(); 1441 QString s = t.readLine();
1443 s.replace (QRegExp("\";\""), "\"|\""); 1442 s.replace (QRegExp("\";\""), "\"|\"");
1444 // char buffer[1024]; 1443 // char buffer[1024];
1445#ifndef WIN32 1444#ifndef WIN32
1446 char buffer[s.length()+1]; 1445 char buffer[s.length()+1];
1447#else 1446#else
1448 char buffer[4048]; 1447 char buffer[4048];
1449#endif 1448#endif
1450 1449
1451 1450
1452 /* modify QString -> QCString::utf8 */ 1451 /* modify QString -> QCString::utf8 */
1453 1452
1454 strcpy (buffer, s.utf8()); 1453 strcpy (buffer, s.utf8());
1455 1454
1456 QString name; 1455 QString name;
1457 QString user; 1456 QString user;
1458 QString password; 1457 QString password;
1459 QString comment; 1458 QString comment;
1460 QString field5=""; 1459 QString field5="";
1461 QString field6=""; 1460 QString field6="";
1462 1461
1463 // separete the entries 1462 // separete the entries
1464 char *i = strtok (buffer, "|"); 1463 char *i = strtok (buffer, "|");
1465 QString category(QString::fromUtf8(&i[1])); 1464 QString category(QString::fromUtf8(&i[1]));
1466 category.truncate(category.length() -1); 1465 category.truncate(category.length() -1);
1467 1466
1468 int idx=0; 1467 int idx=0;
1469 while ((i = strtok (NULL, "|")) != NULL) 1468 while ((i = strtok (NULL, "|")) != NULL)
1470 { 1469 {
1471 switch (idx) 1470 switch (idx)
1472 { 1471 {
1473 case 0: 1472 case 0:
1474 name = QString::fromUtf8(&i[1]); 1473 name = QString::fromUtf8(&i[1]);
1475 name.truncate(name.length() -1); 1474 name.truncate(name.length() -1);
1476 // name 1475 // name
1477 break; 1476 break;
1478 case 1: 1477 case 1:
1479 // user 1478 // user
1480 user = QString::fromUtf8(&i[1]); 1479 user = QString::fromUtf8(&i[1]);
1481 user.truncate(user.length() -1); 1480 user.truncate(user.length() -1);
1482 break; 1481 break;
1483 case 2: 1482 case 2:
1484 // password 1483 // password
1485 password = QString::fromUtf8(&i[1]); 1484 password = QString::fromUtf8(&i[1]);
1486 password.truncate(password.length() -1); 1485 password.truncate(password.length() -1);
1487 break; 1486 break;
1488 case 3: 1487 case 3:
1489 // comment 1488 // comment
1490 comment = QString::fromUtf8(&i[1]); 1489 comment = QString::fromUtf8(&i[1]);
1491 comment.truncate(comment.length() -1); 1490 comment.truncate(comment.length() -1);
1492 break; 1491 break;
1493 case 4: 1492 case 4:
1494 // field5 1493 // field5
1495 field5 = QString::fromUtf8(&i[1]); 1494 field5 = QString::fromUtf8(&i[1]);
1496 field5.truncate(field5.length() -1); 1495 field5.truncate(field5.length() -1);
1497 break; 1496 break;
1498 case 5: 1497 case 5:
1499 // field6 1498 // field6
1500 field6 = QString::fromUtf8(&i[1]); 1499 field6 = QString::fromUtf8(&i[1]);
1501 field6.truncate(field6.length() -1); 1500 field6.truncate(field6.length() -1);
1502 break; 1501 break;
1503 } 1502 }
1504 idx++; 1503 idx++;
1505 } 1504 }
1506 1505
1507 Category *cat= categories.find (category); 1506 Category *cat= categories.find (category);
1508 if (cat) 1507 if (cat)
1509 { 1508 {
1510 // use the existend item 1509 // use the existend item
1511 QListViewItem *catItem = cat->getListItem(); 1510 QListViewItem *catItem = cat->getListItem();
1512 if (catItem) 1511 if (catItem)
1513 { 1512 {
1514 QListViewItem * item = new ShadedListItem( 0, catItem ); 1513 QListViewItem * item = new ShadedListItem( 0, catItem );
1515 item->setText( 0, tr( name ) ); 1514 item->setText( 0, tr( name ) );
1516 item->setText( 1, tr( user ) ); 1515 item->setText( 1, tr( user ) );
1517 item->setText( 2, tr( password ) ); 1516 item->setText( 2, tr( password ) );
1518 item->setText( 3, tr( comment ) ); 1517 item->setText( 3, tr( comment ) );
1519 item->setText( 4, tr( field5 ) ); 1518 item->setText( 4, tr( field5 ) );
1520 item->setText( 5, tr( field6 ) ); 1519 item->setText( 5, tr( field6 ) );
1521 catItem->setOpen( TRUE ); 1520 catItem->setOpen( TRUE );
1522 } 1521 }
1523 } 1522 }
1524 else 1523 else
1525 { 1524 {
1526 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1525 QListViewItem *catI = new ShadedListItem( 1, ListView );
1527 // create and insert a new item 1526 // create and insert a new item
1528 QListViewItem * item = new ShadedListItem( 0, catI ); 1527 QListViewItem * item = new ShadedListItem( 0, catI );
1529 item->setText( 0, tr( name ) ); 1528 item->setText( 0, tr( name ) );
1530 item->setText( 1, tr( user ) ); 1529 item->setText( 1, tr( user ) );
1531 item->setText( 2, tr( password ) ); 1530 item->setText( 2, tr( password ) );
1532 item->setText( 3, tr( comment ) ); 1531 item->setText( 3, tr( comment ) );
1533 item->setText( 4, tr( field5 ) ); 1532 item->setText( 4, tr( field5 ) );
1534 item->setText( 5, tr( field6 ) ); 1533 item->setText( 5, tr( field6 ) );
1535 1534
1536 catI->setOpen( TRUE ); 1535 catI->setOpen( TRUE );
1537 1536
1538 Category *c1 = new Category(); 1537 Category *c1 = new Category();
1539 c1->setCategoryName(category); 1538 c1->setCategoryName(category);
1540 1539
1541 QString icon; 1540 QString icon;
1542 QString fullIconPath; 1541 QString fullIconPath;
1543 QPixmap *pix; 1542 QPixmap *pix;
1544// #ifndef WIN32 1543// #ifndef WIN32
1545 icon = conf->readEntry(APP_KEY+category); 1544 icon = conf->readEntry(APP_KEY+category);
1546// #endif 1545// #endif
1547 bool isIconAv = false; 1546 bool isIconAv = false;
1548 if (!icon.isEmpty() && !icon.isNull()) 1547 if (!icon.isEmpty() && !icon.isNull())
1549 { 1548 {
1550 // build the full path 1549 // build the full path
1551 fullIconPath = iconPath + icon; 1550 fullIconPath = iconPath + icon;
1552 pix = new QPixmap (fullIconPath); 1551 pix = new QPixmap (fullIconPath);
1553 if (pix) 1552 if (pix)
1554 { 1553 {
1555 QImage img = pix->convertToImage(); 1554 QImage img = pix->convertToImage();
1556 pix->convertFromImage(img.smoothScale(14,14)); 1555 pix->convertFromImage(img.smoothScale(14,14));
1557 c1->setIconName (icon); 1556 c1->setIconName (icon);
1558 c1->setIcon (*pix); 1557 c1->setIcon (*pix);
1559 isIconAv = true; 1558 isIconAv = true;
1560 } 1559 }
1561 } 1560 }
1562 if (!isIconAv) 1561 if (!isIconAv)
1563 { 1562 {
1564 c1->setIcon (*getPredefinedIcon(category)); 1563 c1->setIcon (*getPredefinedIcon(category));
1565 } 1564 }
1566 c1->setListItem (catI); 1565 c1->setListItem (catI);
1567 c1->initListItem(); 1566 c1->initListItem();
1568 categories.insert (c1->getCategoryName(), c1); 1567 categories.insert (c1->getCategoryName(), c1);
1569 } 1568 }
1570 1569
1571 } 1570 }
1572 f.close(); 1571 f.close();
1573 1572
1574 } 1573 }
1575 else 1574 else
1576 { 1575 {
1577 } 1576 }
1578 1577
1579} 1578}
1580 1579
1581#ifdef UNUSED 1580#ifdef UNUSED
1582void ZSafe::writeAllEntries() 1581void ZSafe::writeAllEntries()
1583{ 1582{
1584 // open the file for writing 1583 // open the file for writing
1585 QString fn = filename + ".txt"; 1584 QString fn = filename + ".txt";
1586 QFile f( fn ); 1585 QFile f( fn );
1587 if ( !f.open( IO_WriteOnly ) ) { 1586 if ( !f.open( IO_WriteOnly ) ) {
1588 qWarning( QString("Could not write to file %1").arg(fn), 1587 qWarning( QString("Could not write to file %1").arg(fn),
1589 2000 ); 1588 2000 );
1590 QMessageBox::critical( 0, tr("ZSafe"), 1589 QMessageBox::critical( 0, tr("ZSafe"),
1591 tr("Could not export to text file.") ); 1590 tr("Could not export to text file.") );
1592 return; 1591 return;
1593 } 1592 }
1594 QTextStream t( &f ); 1593 QTextStream t( &f );
1595 1594
1596 QListViewItem *i; 1595 QListViewItem *i;
1597 // step through all categories 1596 // step through all categories
1598 for (i = ListView->firstChild(); 1597 for (i = ListView->firstChild();
1599 i != NULL; 1598 i != NULL;
1600 i = i->nextSibling()) 1599 i = i->nextSibling())
1601 { 1600 {
1602 // step through all subitems 1601 // step through all subitems
1603 QListViewItem *si; 1602 QListViewItem *si;
1604 for (si = i->firstChild(); 1603 for (si = i->firstChild();
1605 si != NULL; 1604 si != NULL;
1606 si = si->nextSibling()) 1605 si = si->nextSibling())
1607 { 1606 {
1608 QString oneEntry; 1607 QString oneEntry;
1609 oneEntry += "\""; 1608 oneEntry += "\"";
1610 oneEntry += i->text(0); 1609 oneEntry += i->text(0);
1611 oneEntry += "\";"; 1610 oneEntry += "\";";
1612 oneEntry += "\""; 1611 oneEntry += "\"";
1613 oneEntry += si->text(0); 1612 oneEntry += si->text(0);
1614 oneEntry += "\";"; 1613 oneEntry += "\";";
1615 oneEntry += "\""; 1614 oneEntry += "\"";
1616 oneEntry += si->text(1); 1615 oneEntry += si->text(1);
1617 oneEntry += "\";"; 1616 oneEntry += "\";";
1618 oneEntry += "\""; 1617 oneEntry += "\"";
1619 oneEntry += si->text(2); 1618 oneEntry += si->text(2);
1620 oneEntry += "\";"; 1619 oneEntry += "\";";
1621 oneEntry += "\""; 1620 oneEntry += "\"";
1622 // oneEntry += si->text(3); 1621 // oneEntry += si->text(3);
1623 QString comment = si->text(3); 1622 QString comment = si->text(3);
1624 comment.replace (QRegExp("\n"), "<br>"); 1623 comment.replace (QRegExp("\n"), "<br>");
1625 oneEntry += comment; 1624 oneEntry += comment;
1626 oneEntry += "\""; 1625 oneEntry += "\"";
1627 // qWarning (oneEntry); 1626 // qWarning (oneEntry);
1628 t << oneEntry << endl; 1627 t << oneEntry << endl;
1629 1628
1630 // qWarning (si->text(0)); 1629 // qWarning (si->text(0));
1631 } 1630 }
1632 } 1631 }
1633 f.close(); 1632 f.close();
1634} 1633}
1635 1634
1636void ZSafe::readAllEntries() 1635void ZSafe::readAllEntries()
1637{ 1636{
1638 QString fn = filename + ".txt"; 1637 QString fn = filename + ".txt";
1639 QFile f( fn ); 1638 QFile f( fn );
1640 if ( !f.open( IO_ReadOnly ) ) 1639 if ( !f.open( IO_ReadOnly ) )
1641 { 1640 {
1642 qWarning( QString("Could not read file %1").arg(fn), 1641 qWarning( QString("Could not read file %1").arg(fn),
1643 2000 ); 1642 2000 );
1644 QMessageBox::critical( 0, tr("ZSafe"), 1643 QMessageBox::critical( 0, tr("ZSafe"),
1645 tr("Could not import text file.") ); 1644 tr("Could not import text file.") );
1646 return; 1645 return;
1647 } 1646 }
1648 1647
1649 modified = true; 1648 modified = true;
1650 1649
1651 // clear the password list 1650 // clear the password list
1652 selectedItem = NULL; 1651 selectedItem = NULL;
1653 QListViewItem *i; 1652 QListViewItem *i;
1654 // step through all categories 1653 // step through all categories
1655 for (i = ListView->firstChild(); 1654 for (i = ListView->firstChild();
1656 i != NULL; 1655 i != NULL;
1657 i = i->nextSibling()) 1656 i = i->nextSibling())
1658 { 1657 {
1659 // step through all subitems 1658 // step through all subitems
1660 QListViewItem *si; 1659 QListViewItem *si;
1661 for (si = i->firstChild(); 1660 for (si = i->firstChild();
1662 si != NULL; ) 1661 si != NULL; )
1663 // si = si->nextSibling()) 1662 // si = si->nextSibling())
1664 { 1663 {
1665 QListViewItem *_si = si; 1664 QListViewItem *_si = si;
1666 si = si->nextSibling(); 1665 si = si->nextSibling();
1667 i->takeItem(_si); // remove from view list 1666 i->takeItem(_si); // remove from view list
1668 if (_si) delete _si; 1667 if (_si) delete _si;
1669 } 1668 }
1670 } 1669 }
1671 1670
1672 qWarning ("ReadAllEntries(): "); 1671 qWarning ("ReadAllEntries(): ");
1673 1672
1674 QTextStream t(&f); 1673 QTextStream t(&f);
1675 while ( !t.eof() ) 1674 while ( !t.eof() )
1676 { 1675 {
1677 QString s = t.readLine(); 1676 QString s = t.readLine();
1678 s.replace (QRegExp("\";\""), "\"|\""); 1677 s.replace (QRegExp("\";\""), "\"|\"");
1679 // char buffer[1024]; 1678 // char buffer[1024];
1680 int len=s.length()+1; 1679 int len=s.length()+1;
1681#ifdef WIN32 1680#ifdef WIN32
1682 char buffer[512]; 1681 char buffer[512];
1683#else 1682#else
1684 char buffer[len]; 1683 char buffer[len];
1685#endif 1684#endif
1686 strcpy (buffer, s); 1685 strcpy (buffer, s);
1687 1686
1688 QString name; 1687 QString name;
1689 QString user; 1688 QString user;
1690 QString password; 1689 QString password;
1691 QString comment; 1690 QString comment;
1692 1691
1693 // separete the entries 1692 // separete the entries
1694 char *i = strtok (buffer, "|"); 1693 char *i = strtok (buffer, "|");
1695 QString category(&i[1]); 1694 QString category(&i[1]);
1696 category.truncate(category.length() -1); 1695 category.truncate(category.length() -1);
1697 1696
1698 int idx=0; 1697 int idx=0;
1699 while (i = strtok (NULL, "|")) 1698 while (i = strtok (NULL, "|"))
1700 { 1699 {
1701 switch (idx) 1700 switch (idx)
1702 { 1701 {
1703 case 0: 1702 case 0:
1704 name = &i[1]; 1703 name = &i[1];
1705 name.truncate(name.length() -1); 1704 name.truncate(name.length() -1);
1706 // name 1705 // name
1707 break; 1706 break;
1708 case 1: 1707 case 1:
1709 // user 1708 // user
1710 user = &i[1]; 1709 user = &i[1];
1711 user.truncate(user.length() -1); 1710 user.truncate(user.length() -1);
1712 break; 1711 break;
1713 case 2: 1712 case 2:
1714 // password 1713 // password
1715 password = &i[1]; 1714 password = &i[1];
1716 password.truncate(password.length() -1); 1715 password.truncate(password.length() -1);
1717 break; 1716 break;
1718 case 3: 1717 case 3:
1719 // comment 1718 // comment
1720 comment = &i[1]; 1719 comment = &i[1];
1721 comment.truncate(comment.length() -1); 1720 comment.truncate(comment.length() -1);
1722 break; 1721 break;
1723 } 1722 }
1724 idx++; 1723 idx++;
1725 } 1724 }
1726 1725
1727 Category *cat= categories.find (category); 1726 Category *cat= categories.find (category);
1728 if (cat) 1727 if (cat)
1729 { 1728 {
1730 // use the existend item 1729 // use the existend item
1731 QListViewItem *catItem = cat->getListItem(); 1730 QListViewItem *catItem = cat->getListItem();
1732 if (catItem) 1731 if (catItem)
1733 { 1732 {
1734 QListViewItem * item = new ShadedListItem( 0, catItem ); 1733 QListViewItem * item = new ShadedListItem( 0, catItem );
1735 item->setText( 0, tr( name ) ); 1734 item->setText( 0, tr( name ) );
1736 item->setText( 1, tr( user ) ); 1735 item->setText( 1, tr( user ) );
1737 item->setText( 2, tr( password ) ); 1736 item->setText( 2, tr( password ) );
1738 item->setText( 3, tr( comment ) ); 1737 item->setText( 3, tr( comment ) );
1739 1738
1740 catItem->setOpen( TRUE ); 1739 catItem->setOpen( TRUE );
1741 } 1740 }
1742 } 1741 }
1743 else 1742 else
1744 { 1743 {
1745 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1744 QListViewItem *catI = new ShadedListItem( 1, ListView );
1746 // create and insert a new item 1745 // create and insert a new item
1747 QListViewItem * item = new ShadedListItem( 0, catI ); 1746 QListViewItem * item = new ShadedListItem( 0, catI );
1748 item->setText( 0, tr( name ) ); 1747 item->setText( 0, tr( name ) );
1749 item->setText( 1, tr( user ) ); 1748 item->setText( 1, tr( user ) );
1750 item->setText( 2, tr( password ) ); 1749 item->setText( 2, tr( password ) );
1751 item->setText( 3, tr( comment ) ); 1750 item->setText( 3, tr( comment ) );
1752 1751
1753 catI->setOpen( TRUE ); 1752 catI->setOpen( TRUE );
1754 1753
1755 Category *c1 = new Category(); 1754 Category *c1 = new Category();
1756 c1->setCategoryName(category); 1755 c1->setCategoryName(category);
1757 1756
1758 QString icon; 1757 QString icon;
1759 QString fullIconPath; 1758 QString fullIconPath;
1760 QPixmap *pix; 1759 QPixmap *pix;
1761// #ifndef WIN32 1760// #ifndef WIN32
1762 icon = conf->readEntry(APP_KEY+category); 1761 icon = conf->readEntry(APP_KEY+category);
1763// #endif 1762// #endif
1764 bool isIconAv = false; 1763 bool isIconAv = false;
1765 if (!icon.isEmpty() && !icon.isNull()) 1764 if (!icon.isEmpty() && !icon.isNull())
1766 { 1765 {
1767 // build the full path 1766 // build the full path
1768 fullIconPath = iconPath + icon; 1767 fullIconPath = iconPath + icon;
1769 pix = new QPixmap (fullIconPath); 1768 pix = new QPixmap (fullIconPath);
1770 if (pix) 1769 if (pix)
1771 { 1770 {
1772 QImage img = pix->convertToImage(); 1771 QImage img = pix->convertToImage();
1773 pix->convertFromImage(img.smoothScale(14,14)); 1772 pix->convertFromImage(img.smoothScale(14,14));
1774 c1->setIconName (icon); 1773 c1->setIconName (icon);
1775 c1->setIcon (*pix); 1774 c1->setIcon (*pix);
1776 isIconAv = true; 1775 isIconAv = true;
1777 } 1776 }
1778 } 1777 }
1779 if (!isIconAv) 1778 if (!isIconAv)
1780 { 1779 {
1781 c1->setIcon (*getPredefinedIcon(category)); 1780 c1->setIcon (*getPredefinedIcon(category));
1782 } 1781 }
1783 c1->setListItem (catI); 1782 c1->setListItem (catI);
1784 c1->initListItem(); 1783 c1->initListItem();
1785 categories.insert (c1->getCategoryName(), c1); 1784 categories.insert (c1->getCategoryName(), c1);
1786 } 1785 }
1787 1786
1788 } 1787 }
1789 f.close(); 1788 f.close();
1790 1789
1791} 1790}
1792#endif // UNUSED 1791#endif // UNUSED
1793 1792
1794void ZSafe::resume(int) 1793void ZSafe::resume(int)
1795{ 1794{
1796 qWarning ("Resume"); 1795 qWarning ("Resume");
1797 // hide the main window 1796 // hide the main window
1798 1797
1799 infoForm->hide(); 1798 infoForm->hide();
1800 // open zsafe again 1799 // open zsafe again
1801 m_password = ""; 1800 m_password = "";
1802 selectedItem = NULL; 1801 selectedItem = NULL;
1803 1802
1804 // clear the password list 1803 // clear the password list
1805 QListViewItem *i; 1804 QListViewItem *i;
1806 // step through all categories 1805 // step through all categories
1807 for (i = ListView->firstChild(); 1806 for (i = ListView->firstChild();
1808 i != NULL; 1807 i != NULL;
1809 i = i->nextSibling()) 1808 i = i->nextSibling())
1810 { 1809 {
1811 // step through all subitems 1810 // step through all subitems
1812 QListViewItem *si; 1811 QListViewItem *si;
1813 for (si = i->firstChild(); 1812 for (si = i->firstChild();
1814 si != NULL; ) 1813 si != NULL; )
1815 { 1814 {
1816 QListViewItem *_si = si; 1815 QListViewItem *_si = si;
1817 si = si->nextSibling(); 1816 si = si->nextSibling();
1818 i->takeItem(_si); // remove from view list 1817 i->takeItem(_si); // remove from view list
1819 if (_si) delete _si; 1818 if (_si) delete _si;
1820 } 1819 }
1821 } 1820 }
1822 1821
1823 // ask for password and read again 1822 // ask for password and read again
1824 openDocument(filename); 1823 openDocument(filename);
1825} 1824}
1826 1825
1827//--------------------------------------------- 1826//---------------------------------------------
1828 1827
1829 1828
1830bool ZSafe::openDocument(const char* _filename, const char* ) 1829bool ZSafe::openDocument(const char* _filename, const char* )
1831{ 1830{
1832 int retval; 1831 int retval;
1833 char* entry[FIELD_SIZE]; 1832 char* entry[FIELD_SIZE];
1834// #ifndef WIN32 1833// #ifndef WIN32
1835 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); 1834 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
1836// #else 1835// #else
1837 // int validationFlag = 1; 1836 // int validationFlag = 1;
1838// #endif 1837// #endif
1839 1838
1840 int pwdOk = 0; 1839 int pwdOk = 0;
1841 int numberOfTries = 3; 1840 int numberOfTries = 3;
1842 for (int i=0; i < numberOfTries; i++) 1841 for (int i=0; i < numberOfTries; i++)
1843 { 1842 {
1844 QFile f(_filename); 1843 QFile f(_filename);
1845 if (f.exists()) 1844 if (f.exists())
1846 { 1845 {
1847 // ask with a dialog for the password 1846 // ask with a dialog for the password
1848 if (m_password.isEmpty()) 1847 if (m_password.isEmpty())
1849 getDocPassword(tr("Enter Password")); 1848 getDocPassword(tr("Enter Password"));
1850 if (m_password.isEmpty() && validationFlag == 0) 1849 if (m_password.isEmpty() && validationFlag == 0)
1851 { 1850 {
1852 qWarning ("Wrong password"); 1851 qWarning ("Wrong password");
1853 QMessageBox::critical( 0, tr("ZSafe"), 1852 QMessageBox::critical( 0, tr("ZSafe"),
1854 tr("Wrong password.\n\nZSafe will now exit.") ); 1853 tr("Wrong password.\n\nZSafe will now exit.") );
1855 exitZs (1); 1854 exitZs (1);
1856 } 1855 }
1857 1856
1858 retval = loadInit(_filename, m_password); 1857 retval = loadInit(_filename, m_password);
1859 if (retval != PWERR_GOOD) 1858 if (retval != PWERR_GOOD)
1860 { 1859 {
1861 qWarning ("Error loading Document"); 1860 qWarning ("Error loading Document");
1862 return false; 1861 return false;
1863 } 1862 }
1864 } 1863 }
1865 else 1864 else
1866 { 1865 {
1867#ifdef WIN32 1866#ifdef WIN32
1868 this->setCaption("Qt ZSafe"); 1867 this->setCaption("Qt ZSafe");
1869#else 1868#else
1870 this->setCaption("ZSafe"); 1869 this->setCaption("ZSafe");
1871#endif 1870#endif
1872 filename = ""; 1871 filename = "";
1873 return false; 1872 return false;
1874 } 1873 }
1875 1874
1876 1875
1877 // load the validation entry 1876 // load the validation entry
1878 if (validationFlag == 0) 1877 if (validationFlag == 0)
1879 { 1878 {
1880 pwdOk = 1; 1879 pwdOk = 1;
1881 break; 1880 break;
1882 } 1881 }
1883 1882
1884 retval = loadEntry(entry); 1883 retval = loadEntry(entry);
1885 if (retval == 1 && 1884 if (retval == 1 &&
1886 !strcmp (entry[0], "ZSAFECATEGORY") && 1885 !strcmp (entry[0], "ZSAFECATEGORY") &&
1887 !strcmp (entry[1], "name") && 1886 !strcmp (entry[1], "name") &&
1888 !strcmp (entry[2], "username") && 1887 !strcmp (entry[2], "username") &&
1889 !strcmp (entry[3], "password") && 1888 !strcmp (entry[3], "password") &&
1890 !strcmp (entry[4], "comment") ) 1889 !strcmp (entry[4], "comment") )
1891 { 1890 {
1892 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1891 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1893 pwdOk = 1; 1892 pwdOk = 1;
1894 break; 1893 break;
1895 } 1894 }
1896 else 1895 else
1897 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1896 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1898 fclose (fd); 1897 fclose (fd);
1899 m_password = ""; 1898 m_password = "";
1900 1899
1901 if (i < numberOfTries - 1) 1900 if (i < numberOfTries - 1)
1902 { 1901 {
1903 switch( QMessageBox::warning( this, tr("ZSafe"), 1902 switch( QMessageBox::warning( this, tr("ZSafe"),
1904 tr("Wrong password.\nEnter again?"), 1903 tr("Wrong password.\nEnter again?"),
1905 tr("&Yes"), tr("&No."), 1904 tr("&Yes"), tr("&No."),
1906 0 1905 0
1907 ) ) 1906 ) )
1908 { 1907 {
1909 case 1: // No 1908 case 1: // No
1910 exitZs (1); 1909 exitZs (1);
1911 break; 1910 break;
1912 case 0: // Yes 1911 case 0: // Yes
1913 continue; 1912 continue;
1914 } 1913 }
1915 } 1914 }
1916 } 1915 }
1917 if (pwdOk == 0) 1916 if (pwdOk == 0)
1918 { 1917 {
1919 // unset the document entry 1918 // unset the document entry
1920 conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); 1919 conf->writeEntry(APP_KEY+"document", "INVALIDPWD");
1921 if (conf) 1920 if (conf)
1922 delete conf; 1921 delete conf;
1923 1922
1924 exitZs (1); 1923 exitZs (1);
1925 } 1924 }
1926 1925
1927 1926
1928 retval = loadEntry(entry); 1927 retval = loadEntry(entry);
1929 1928
1930 int numberOfEntries=0; 1929 int numberOfEntries=0;
1931 while (retval == 1) { 1930 while (retval == 1) {
1932 1931
1933 QString category( QString::fromUtf8(entry[0]) ); 1932 QString category( QString::fromUtf8(entry[0]) );
1934 QString name( QString::fromUtf8(entry[1]) ); 1933 QString name( QString::fromUtf8(entry[1]) );
1935 QString user( QString::fromUtf8(entry[2]) ); 1934 QString user( QString::fromUtf8(entry[2]) );
1936 QString password( QString::fromUtf8(entry[3]) ); 1935 QString password( QString::fromUtf8(entry[3]) );
1937 QString comment( QString::fromUtf8(entry[4]) ); 1936 QString comment( QString::fromUtf8(entry[4]) );
1938 QString field5( QString::fromUtf8(entry[5]) ); 1937 QString field5( QString::fromUtf8(entry[5]) );
1939 QString field6( QString::fromUtf8(entry[6]) ); 1938 QString field6( QString::fromUtf8(entry[6]) );
1940 // add the subitems to the categories 1939 // add the subitems to the categories
1941 1940
1942 Category *cat= categories.find (category); 1941 Category *cat= categories.find (category);
1943 if (cat) 1942 if (cat)
1944 { 1943 {
1945 // use the existend item 1944 // use the existend item
1946 QListViewItem *catItem = cat->getListItem(); 1945 QListViewItem *catItem = cat->getListItem();
1947 if (catItem) 1946 if (catItem)
1948 { 1947 {
1949 QListViewItem * item = new ShadedListItem( 0, catItem ); 1948 QListViewItem * item = new ShadedListItem( 0, catItem );
1950 item->setText( 0, tr( name ) ); 1949 item->setText( 0, tr( name ) );
1951 item->setText( 1, tr( user ) ); 1950 item->setText( 1, tr( user ) );
1952 item->setText( 2, tr( password ) ); 1951 item->setText( 2, tr( password ) );
1953 item->setText( 3, tr( comment ) ); 1952 item->setText( 3, tr( comment ) );
1954 item->setText( 4, tr( field5 ) ); 1953 item->setText( 4, tr( field5 ) );
1955 item->setText( 5, tr( field6 ) ); 1954 item->setText( 5, tr( field6 ) );
1956 1955
1957 if (expandTree) 1956 if (expandTree)
1958 catItem->setOpen( TRUE ); 1957 catItem->setOpen( TRUE );
1959 numberOfEntries++; 1958 numberOfEntries++;
1960 } 1959 }
1961 } 1960 }
1962 else 1961 else
1963 { 1962 {
1964 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1963 QListViewItem *catI = new ShadedListItem( 1, ListView );
1965 // create and insert a new item 1964 // create and insert a new item
1966 QListViewItem * item = new ShadedListItem( 0, catI ); 1965 QListViewItem * item = new ShadedListItem( 0, catI );
1967 1966
1968 item->setText( 0, tr( name ) ); 1967 item->setText( 0, tr( name ) );
1969 item->setText( 1, tr( user ) ); 1968 item->setText( 1, tr( user ) );
1970 item->setText( 2, tr( password ) ); 1969 item->setText( 2, tr( password ) );
1971 item->setText( 3, tr( comment ) ); 1970 item->setText( 3, tr( comment ) );
1972 item->setText( 4, tr( field5 ) ); 1971 item->setText( 4, tr( field5 ) );
1973 item->setText( 5, tr( field6 ) ); 1972 item->setText( 5, tr( field6 ) );
1974 1973
1975 if (expandTree) 1974 if (expandTree)
1976 catI->setOpen( TRUE ); 1975 catI->setOpen( TRUE );
1977 1976
1978 Category *c1 = new Category(); 1977 Category *c1 = new Category();
1979 c1->setCategoryName(category); 1978 c1->setCategoryName(category);
1980 1979
1981 QString icon; 1980 QString icon;
1982 QString fullIconPath; 1981 QString fullIconPath;
1983 QPixmap *pix; 1982 QPixmap *pix;
1984// #ifndef WIN32 1983// #ifndef WIN32
1985 icon = conf->readEntry(APP_KEY+category); 1984 icon = conf->readEntry(APP_KEY+category);
1986// #endif 1985// #endif
1987 bool isIconAv = false; 1986 bool isIconAv = false;
1988 if (!icon.isEmpty() && !icon.isNull()) 1987 if (!icon.isEmpty() && !icon.isNull())
1989 { 1988 {
1990 // build the full path 1989 // build the full path
1991 fullIconPath = iconPath + icon; 1990 fullIconPath = iconPath + icon;
1992 pix = new QPixmap (fullIconPath); 1991 pix = new QPixmap (fullIconPath);
1993 if (pix) 1992 if (pix)
1994 { 1993 {
1995 QImage img = pix->convertToImage(); 1994 QImage img = pix->convertToImage();
1996 pix->convertFromImage(img.smoothScale(14,14)); 1995 pix->convertFromImage(img.smoothScale(14,14));
1997 c1->setIconName (icon); 1996 c1->setIconName (icon);
1998 c1->setIcon (*pix); 1997 c1->setIcon (*pix);
1999 isIconAv = true; 1998 isIconAv = true;
2000 } 1999 }
2001 } 2000 }
2002 if (!isIconAv) 2001 if (!isIconAv)
2003 { 2002 {
2004 c1->setIcon (*getPredefinedIcon(category)); 2003 c1->setIcon (*getPredefinedIcon(category));
2005 } 2004 }
2006 2005
2007 c1->setListItem (catI); 2006 c1->setListItem (catI);
2008 c1->initListItem(); 2007 c1->initListItem();
2009 categories.insert (c1->getCategoryName(), c1); 2008 categories.insert (c1->getCategoryName(), c1);
2010 numberOfEntries++; 2009 numberOfEntries++;
2011 } 2010 }
2012 2011
2013 for (int count = 0; count < FIELD_SIZE; count++) { 2012 for (int count = 0; count < FIELD_SIZE; count++) {
2014 free(entry[count]); 2013 free(entry[count]);
2015 } 2014 }
2016 retval = loadEntry(entry); 2015 retval = loadEntry(entry);
2017 if (retval == 2) { 2016 if (retval == 2) {
2018 // m_parent->slotStatusHelpMsg("Last entry loaded"); 2017 // m_parent->slotStatusHelpMsg("Last entry loaded");
2019 } 2018 }
2020 } // end while 2019 } // end while
2021 2020
2022 if (numberOfEntries == 0) 2021 if (numberOfEntries == 0)
2023 { 2022 {
2024 2023
2025 switch( QMessageBox::warning( this, tr("ZSafe"), 2024 switch( QMessageBox::warning( this, tr("ZSafe"),
2026 tr("Empty document or\nwrong password.\nContinue?"), 2025 tr("Empty document or\nwrong password.\nContinue?"),
2027 tr("&No"), tr("&Yes."), 2026 tr("&No"), tr("&Yes."),
2028 0 2027 0
2029 ) ) { 2028 ) ) {
2030 case 0: // No 2029 case 0: // No
2031 retval = loadFinalize(); 2030 retval = loadFinalize();
2032 exitZs (1); 2031 exitZs (1);
2033 break; 2032 break;
2034 case 1: // Yes 2033 case 1: // Yes
2035 break; 2034 break;
2036 } 2035 }
2037 } 2036 }
2038 2037
2039 retval = loadFinalize(); 2038 retval = loadFinalize();
2040 2039
2041 return true; 2040 return true;
2042} 2041}
2043 2042
2044int ZSafe::loadInit(const char* _filename, const char *password) 2043int ZSafe::loadInit(const char* _filename, const char *password)
2045{ 2044{
2046 unsigned int j = 0; 2045 unsigned int j = 0;
2047 unsigned int keylength=0; 2046 unsigned int keylength=0;
2048 int count=0, count2=0, count3=0; 2047 int count=0, count2=0, count3=0;
2049 unsigned char charbuf[8]; 2048 unsigned char charbuf[8];
2050 unsigned short ciphertext[4]; 2049 unsigned short ciphertext[4];
2051 char key[128]; 2050 char key[128];
2052 Krc2* krc2 = new Krc2(); 2051 Krc2* krc2 = new Krc2();
2053 2052
2054 fd = fopen (_filename, "rb"); 2053 fd = fopen (_filename, "rb");
2055 2054
2056 QFileInfo f (_filename); 2055 QFileInfo f (_filename);
2057 load_buffer_length = f.size(); 2056 load_buffer_length = f.size();
2058 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; 2057 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2;
2059 2058
2060 if (fd == NULL) 2059 if (fd == NULL)
2061 return PWERR_OPEN; 2060 return PWERR_OPEN;
2062 2061
2063 buffer = (char *)malloc(load_buffer_length); 2062 buffer = (char *)malloc(load_buffer_length);
2064 for (j = 0; password[j] != '\0'; j++) { 2063 for (j = 0; password[j] != '\0'; j++) {
2065 key[j] = password[j]; 2064 key[j] = password[j];
2066 } 2065 }
2067 keylength = j; 2066 keylength = j;
2068 krc2->rc2_expandkey (key, keylength, 128); 2067 krc2->rc2_expandkey (key, keylength, 128);
2069 2068
2070#ifndef WIN32 2069#ifndef WIN32
2071 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); 2070 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
2072#else 2071#else
2073 printf ("LoadInit() read1"); 2072 printf ("LoadInit() read1");
2074 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); 2073 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
2075#endif 2074#endif
2076 2075
2077 if (size < 8) 2076 if (size < 8)
2078 return PWERR_DATA; 2077 return PWERR_DATA;
2079 2078
2080 for (count = 0; count < 4; count++) { 2079 for (count = 0; count < 4; count++) {
2081 count2 = count << 1; 2080 count2 = count << 1;
2082 iv[count] = charbuf[count2] << 8; 2081 iv[count] = charbuf[count2] << 8;