summaryrefslogtreecommitdiff
path: root/noncore/apps
Unidiff
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp44
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro24
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp12
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp1681
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp2
-rw-r--r--noncore/apps/advancedfm/output.cpp23
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/listedit.cpp11
-rw-r--r--noncore/apps/checkbook/tabledef.cpp6
-rw-r--r--noncore/apps/checkbook/transaction.cpp6
-rw-r--r--noncore/apps/confedit/confedit.pro24
-rw-r--r--noncore/apps/confedit/config.in2
-rw-r--r--noncore/apps/confedit/listviewconfdir.cpp12
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp24
-rw-r--r--noncore/apps/confedit/mainwindow.cpp19
-rw-r--r--noncore/apps/keyz-cfg/cfgfile.cpp12
-rw-r--r--noncore/apps/keyz-cfg/config.in2
-rw-r--r--noncore/apps/keyz-cfg/keyz-cfg.pro16
-rw-r--r--noncore/apps/keyz-cfg/zkb.cpp4
-rw-r--r--noncore/apps/keyz-cfg/zkbcfg.cpp15
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp35
-rw-r--r--noncore/apps/opie-bartender/bartender.pro7
-rw-r--r--noncore/apps/opie-bartender/config.in3
-rw-r--r--noncore/apps/opie-console/MyPty.cpp14
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp6
-rw-r--r--noncore/apps/opie-console/TEmulation.cpp8
-rw-r--r--noncore/apps/opie-console/atconfigdialog.cpp13
-rw-r--r--noncore/apps/opie-console/dialer.cpp27
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp14
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp10
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp9
-rw-r--r--noncore/apps/opie-console/io_bt.cpp7
-rw-r--r--noncore/apps/opie-console/io_irda.cpp8
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/main.cpp2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp39
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp11
-rw-r--r--noncore/apps/opie-console/opie-console.pro4
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp6
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp7
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp11
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp14
-rw-r--r--noncore/apps/opie-console/widget.cpp6
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp4
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp12
-rw-r--r--noncore/apps/opie-write/opie-write.pro3
-rw-r--r--noncore/apps/opie-write/qcomplextext.cpp4
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp28
-rw-r--r--noncore/apps/opie-write/qrichtext_p.cpp15
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp13
-rw-r--r--noncore/apps/qashmoney/config.in2
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.pro2
-rw-r--r--noncore/apps/tableviewer/db/common.cpp28
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp12
-rw-r--r--noncore/apps/tableviewer/db/xmlsource.cpp30
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp14
-rw-r--r--noncore/apps/tableviewer/tableviewer.pro8
-rw-r--r--noncore/apps/tableviewer/ui/tvlistview.cpp9
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro147
-rw-r--r--noncore/apps/tinykate/tinykate.pro26
-rw-r--r--noncore/apps/zsafe/config.in2
-rw-r--r--noncore/apps/zsafe/scqtfiledlg.cpp29
-rw-r--r--noncore/apps/zsafe/zsafe.cpp15
-rw-r--r--noncore/apps/zsafe/zsafe.pro14
64 files changed, 1360 insertions, 1267 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index a60d6ce..a47edd8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -26,406 +26,406 @@
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; 36using namespace Opie::Ui;
37 37
38#ifdef NOQUICKLAUNCH 38#ifdef NOQUICKLAUNCH
39AdvancedFm::AdvancedFm( ) 39AdvancedFm::AdvancedFm( )
40#else 40#else
41AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) 41AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
42#endif 42#endif
43 : QMainWindow( ) { 43 : QMainWindow( ) {
44 init(); 44 init();
45 renameBox = 0; 45 renameBox = 0;
46 46
47 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 47 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
48 48
49 initConnections(); 49 initConnections();
50 whichTab=1; 50 whichTab=1;
51 rePopulate(); 51 rePopulate();
52 currentPathCombo->setFocus(); 52 currentPathCombo->setFocus();
53 channel = new QCopChannel( "QPE/Application/advancedfm", this ); 53 channel = new QCopChannel( "QPE/Application/advancedfm", this );
54 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 54 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
55 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 55 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
56} 56}
57 57
58AdvancedFm::~AdvancedFm() { 58AdvancedFm::~AdvancedFm() {
59} 59}
60 60
61 61
62void AdvancedFm::cleanUp() { 62void AdvancedFm::cleanUp() {
63 QString sfile=QDir::homeDirPath(); 63 QString sfile=QDir::homeDirPath();
64 if(sfile.right(1) != "/") 64 if(sfile.right(1) != "/")
65 sfile+="/._temp"; 65 sfile+="/._temp";
66 else 66 else
67 sfile+="._temp"; 67 sfile+="._temp";
68 QFile file( sfile); 68 QFile file( sfile);
69 if(file.exists()) 69 if(file.exists())
70 file.remove(); 70 file.remove();
71} 71}
72 72
73void AdvancedFm::tabChanged(QWidget *) { 73void AdvancedFm::tabChanged(QWidget *) {
74// qWarning("tab changed"); 74// owarn << "tab changed" << oendl;
75 QString path = CurrentDir()->canonicalPath(); 75 QString path = CurrentDir()->canonicalPath();
76 currentPathCombo->lineEdit()->setText( path ); 76 currentPathCombo->lineEdit()->setText( path );
77 77
78 if(whichTab == 1) { 78 if(whichTab == 1) {
79 viewMenu->setItemChecked(viewMenu->idAt(0), true); 79 viewMenu->setItemChecked(viewMenu->idAt(0), true);
80 viewMenu->setItemChecked(viewMenu->idAt(1), false); 80 viewMenu->setItemChecked(viewMenu->idAt(1), false);
81 } else { 81 } else {
82 viewMenu->setItemChecked(viewMenu->idAt(0), false); 82 viewMenu->setItemChecked(viewMenu->idAt(0), false);
83 viewMenu->setItemChecked(viewMenu->idAt(1), true); 83 viewMenu->setItemChecked(viewMenu->idAt(1), true);
84 } 84 }
85 85
86 QString fs= getFileSystemType( (const QString &) path); 86 QString fs= getFileSystemType( (const QString &) path);
87 87
88 setCaption(tr("AdvancedFm :: ")+fs+" :: " 88 setCaption(tr("AdvancedFm :: ")+fs+" :: "
89 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 89 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
90 chdir( path.latin1()); 90 chdir( path.latin1());
91} 91}
92 92
93 93
94void AdvancedFm::populateView() { 94void AdvancedFm::populateView() {
95 95
96// qWarning("PopulateView"); 96// owarn << "PopulateView" << oendl;
97 QPixmap pm; 97 QPixmap pm;
98 QListView *thisView = CurrentView(); 98 QListView *thisView = CurrentView();
99 QDir *thisDir = CurrentDir(); 99 QDir *thisDir = CurrentDir();
100 QString path = thisDir->canonicalPath(); 100 QString path = thisDir->canonicalPath();
101 101
102//qWarning("path is "+path); 102//owarn << "path is "+path << oendl;
103 thisView->clear(); 103 thisView->clear();
104 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 104 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
105 thisDir->setMatchAllDirs(TRUE); 105 thisDir->setMatchAllDirs(TRUE);
106 thisDir->setNameFilter(filterStr); 106 thisDir->setNameFilter(filterStr);
107 QString fileL, fileS, fileDate; 107 QString fileL, fileS, fileDate;
108 QString fs= getFileSystemType((const QString &) path); 108 QString fs= getFileSystemType((const QString &) path);
109 setCaption(tr("AdvancedFm :: ")+fs+" :: " 109 setCaption(tr("AdvancedFm :: ")+fs+" :: "
110 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 110 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
111 bool isDir=FALSE; 111 bool isDir=FALSE;
112 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 112 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
113 QFileInfoListIterator it(*list); 113 QFileInfoListIterator it(*list);
114 QFileInfo *fi; 114 QFileInfo *fi;
115 while ( (fi=it.current()) ) { 115 while ( (fi=it.current()) ) {
116 if (fi->isSymLink() ) { 116 if (fi->isSymLink() ) {
117 QString symLink=fi->readLink(); 117 QString symLink=fi->readLink();
118 QFileInfo sym( symLink); 118 QFileInfo sym( symLink);
119 fileS.sprintf( "%10i", sym.size() ); 119 fileS.sprintf( "%10i", sym.size() );
120 fileL = fi->fileName() +" -> " + sym.filePath().data(); 120 fileL = fi->fileName() +" -> " + sym.filePath().data();
121 fileDate = sym.lastModified().toString(); 121 fileDate = sym.lastModified().toString();
122 } else { 122 } else {
123 fileS.sprintf( "%10i", fi->size() ); 123 fileS.sprintf( "%10i", fi->size() );
124 fileL = fi->fileName(); 124 fileL = fi->fileName();
125 fileDate= fi->lastModified().toString(); 125 fileDate= fi->lastModified().toString();
126 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 126 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
127// if(fileL == "..") 127// if(fileL == "..")
128 fileL += "/"; 128 fileL += "/";
129 isDir=TRUE; 129 isDir=TRUE;
130 } 130 }
131 } 131 }
132 QFileInfo fileInfo( path + "/" + fileL); 132 QFileInfo fileInfo( path + "/" + fileL);
133 133
134 if(fileL !="./" && fi->exists()) { 134 if(fileL !="./" && fi->exists()) {
135 item = new QListViewItem( thisView, fileL, fileS , fileDate); 135 item = new QListViewItem( thisView, fileL, fileS , fileDate);
136 136
137 if(isDir || fileL.find("/",0,TRUE) != -1) { 137 if(isDir || fileL.find("/",0,TRUE) != -1) {
138 138
139 if( !QDir( fi->filePath() ).isReadable()) //is directory 139 if( !QDir( fi->filePath() ).isReadable()) //is directory
140 pm = Resource::loadPixmap( "lockedfolder" ); 140 pm = Resource::loadPixmap( "lockedfolder" );
141 else 141 else
142 pm= Resource::loadPixmap( "folder" ); 142 pm= Resource::loadPixmap( "folder" );
143 } 143 }
144 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 144 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
145 pm = Resource::loadPixmap( "exec"); 145 pm = Resource::loadPixmap( "exec");
146 } 146 }
147 else if( (fileInfo.permission( QFileInfo::ExeUser) 147 else if( (fileInfo.permission( QFileInfo::ExeUser)
148 | fileInfo.permission( QFileInfo::ExeGroup) 148 | fileInfo.permission( QFileInfo::ExeGroup)
149 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 149 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
150 pm = Resource::loadPixmap( "exec"); 150 pm = Resource::loadPixmap( "exec");
151 } 151 }
152 else if( !fi->isReadable() ) { 152 else if( !fi->isReadable() ) {
153 pm = Resource::loadPixmap( "locked" ); 153 pm = Resource::loadPixmap( "locked" );
154 } 154 }
155 else { //everything else goes by mimetype 155 else { //everything else goes by mimetype
156 MimeType mt(fi->filePath()); 156 MimeType mt(fi->filePath());
157 pm=mt.pixmap(); //sets the correct pixmap for mimetype 157 pm=mt.pixmap(); //sets the correct pixmap for mimetype
158 if(pm.isNull()) { 158 if(pm.isNull()) {
159 pm = unknownXpm; 159 pm = unknownXpm;
160 } 160 }
161 } 161 }
162 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 162 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
163 // qDebug(" overlay link image"); 163 // odebug << " overlay link image" << oendl;
164 pm= Resource::loadPixmap( "advancedfm/symlink" ); 164 pm= Resource::loadPixmap( "advancedfm/symlink" );
165 // pm= Resource::loadPixmap( "folder" ); 165 // pm= Resource::loadPixmap( "folder" );
166// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 166// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
167// QPainter painter( &pm ); 167// QPainter painter( &pm );
168// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 168// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
169// pm.setMask( pm.createHeuristicMask( FALSE ) ); 169// pm.setMask( pm.createHeuristicMask( FALSE ) );
170 } 170 }
171 item->setPixmap( 0,pm); 171 item->setPixmap( 0,pm);
172 172
173 } 173 }
174 isDir=FALSE; 174 isDir=FALSE;
175 ++it; 175 ++it;
176 } 176 }
177 177
178 if( path.find("dev",0,TRUE) != -1) { 178 if( path.find("dev",0,TRUE) != -1) {
179 struct stat buf; 179 struct stat buf;
180 dev_t devT; 180 dev_t devT;
181 DIR *dir; 181 DIR *dir;
182 struct dirent *mydirent; 182 struct dirent *mydirent;
183 183
184 if((dir = opendir( path.latin1())) != NULL) 184 if((dir = opendir( path.latin1())) != NULL)
185 while ((mydirent = readdir(dir)) != NULL) { 185 while ((mydirent = readdir(dir)) != NULL) {
186 lstat( mydirent->d_name, &buf); 186 lstat( mydirent->d_name, &buf);
187// qDebug(mydirent->d_name); 187// odebug << mydirent->d_name << oendl;
188 fileL.sprintf("%s", mydirent->d_name); 188 fileL.sprintf("%s", mydirent->d_name);
189 devT = buf.st_dev; 189 devT = buf.st_dev;
190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
191 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 191 fileDate.sprintf("%s", ctime( &buf.st_mtime));
192 if( fileL.find(".") == -1 ) { 192 if( fileL.find(".") == -1 ) {
193 item= new QListViewItem( thisView, fileL, fileS, fileDate); 193 item= new QListViewItem( thisView, fileL, fileS, fileDate);
194 pm = unknownXpm; 194 pm = unknownXpm;
195 item->setPixmap( 0,pm); 195 item->setPixmap( 0,pm);
196 } 196 }
197 } 197 }
198 198
199 closedir(dir); 199 closedir(dir);
200 } 200 }
201 201
202 thisView->setSorting( 3,FALSE); 202 thisView->setSorting( 3,FALSE);
203 fillCombo( (const QString &) path ); 203 fillCombo( (const QString &) path );
204} 204}
205 205
206void AdvancedFm::rePopulate() { 206void AdvancedFm::rePopulate() {
207 populateView(); 207 populateView();
208 setOtherTabCurrent(); 208 setOtherTabCurrent();
209 populateView(); 209 populateView();
210 210
211// int tmpTab = whichTab; 211// int tmpTab = whichTab;
212// // qDebug("%d", tmpTab); 212// // odebug << "" << tmpTab << "" << oendl;
213 213
214// for(int i =1; i < 3; i++) { 214// for(int i =1; i < 3; i++) {
215// TabWidget->setCurrentWidget(i - 1); 215// TabWidget->setCurrentWidget(i - 1);
216// populateView(); 216// populateView();
217// } 217// }
218// TabWidget->setCurrentWidget( tmpTab - 1); 218// TabWidget->setCurrentWidget( tmpTab - 1);
219} 219}
220 220
221void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 221void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
222//qWarning("listclicked"); 222//owarn << "listclicked" << oendl;
223 if(selectedItem) { 223 if(selectedItem) {
224 QString strItem=selectedItem->text(0); 224 QString strItem=selectedItem->text(0);
225// qWarning(strItem); 225// owarn << strItem << oendl;
226 QString strSize=selectedItem->text(1); 226 QString strSize=selectedItem->text(1);
227 strSize=strSize.stripWhiteSpace(); 227 strSize=strSize.stripWhiteSpace();
228 bool isDirectory = false; 228 bool isDirectory = false;
229 QString strItem2; 229 QString strItem2;
230 230
231 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
232 strItem2 = dealWithSymName((const QString&)strItem); 232 strItem2 = dealWithSymName((const QString&)strItem);
233 if(QDir(strItem2).exists() ) 233 if(QDir(strItem2).exists() )
234 strItem = strItem2; 234 strItem = strItem2;
235 } 235 }
236 236
237 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 237 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
238 238
239 if(QDir(strItem).exists()) 239 if(QDir(strItem).exists())
240 isDirectory = true; 240 isDirectory = true;
241 } 241 }
242 242
243 if( isDirectory ) { 243 if( isDirectory ) {
244 CurrentDir()->cd( strItem, TRUE); 244 CurrentDir()->cd( strItem, TRUE);
245 populateView(); 245 populateView();
246 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 246 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
247 } 247 }
248 chdir( strItem.latin1()); 248 chdir( strItem.latin1());
249 } 249 }
250} 250}
251 251
252void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { 252void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
253 dealWithSchmooSchmaa( item->listView()); 253 dealWithSchmooSchmaa( item->listView());
254 switch (mouse) { 254 switch (mouse) {
255 case 1: 255 case 1:
256 { 256 {
257 if(renameBox != 0 ) { 257 if(renameBox != 0 ) {
258 cancelRename(); 258 cancelRename();
259 } 259 }
260 } 260 }
261 break; 261 break;
262 case 2: 262 case 2:
263 menuTimer.start( 500, TRUE ); 263 menuTimer.start( 500, TRUE );
264 break; 264 break;
265 }; 265 };
266} 266}
267 267
268 268
269void AdvancedFm::switchToLocalTab() { 269void AdvancedFm::switchToLocalTab() {
270//qWarning("switch to local view"); 270//owarn << "switch to local view" << oendl;
271 TabWidget->setCurrentWidget(0); 271 TabWidget->setCurrentWidget(0);
272 Local_View->setFocus(); 272 Local_View->setFocus();
273} 273}
274 274
275void AdvancedFm::switchToRemoteTab() { 275void AdvancedFm::switchToRemoteTab() {
276//qWarning("switch to local view"); 276//owarn << "switch to local view" << oendl;
277 TabWidget->setCurrentWidget(1); 277 TabWidget->setCurrentWidget(1);
278 Remote_View->setFocus(); 278 Remote_View->setFocus();
279} 279}
280 280
281void AdvancedFm::readConfig() { 281void AdvancedFm::readConfig() {
282 Config cfg("AdvancedFm"); 282 Config cfg("AdvancedFm");
283} 283}
284 284
285void AdvancedFm::writeConfig() { 285void AdvancedFm::writeConfig() {
286 Config cfg("AdvancedFm"); 286 Config cfg("AdvancedFm");
287} 287}
288 288
289void AdvancedFm::currentPathComboChanged() { 289void AdvancedFm::currentPathComboChanged() {
290 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 290 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
291 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 291 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
292 populateView(); 292 populateView();
293 } else { 293 } else {
294 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 294 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
295 } 295 }
296} 296}
297 297
298void AdvancedFm::fillCombo(const QString &currentPath) { 298void AdvancedFm::fillCombo(const QString &currentPath) {
299 299
300 if ( whichTab == 1) { 300 if ( whichTab == 1) {
301 currentPathCombo->lineEdit()->setText( currentPath); 301 currentPathCombo->lineEdit()->setText( currentPath);
302 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 302 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
303 currentPathCombo->clear(); 303 currentPathCombo->clear();
304 localDirPathStringList.prepend( currentPath ); 304 localDirPathStringList.prepend( currentPath );
305 currentPathCombo->insertStringList( localDirPathStringList,-1); 305 currentPathCombo->insertStringList( localDirPathStringList,-1);
306 } 306 }
307 } else { 307 } else {
308 currentPathCombo->lineEdit()->setText( currentPath); 308 currentPathCombo->lineEdit()->setText( currentPath);
309 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 309 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
310 currentPathCombo->clear(); 310 currentPathCombo->clear();
311 remoteDirPathStringList.prepend( currentPath ); 311 remoteDirPathStringList.prepend( currentPath );
312 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 312 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
313 } 313 }
314 } 314 }
315} 315}
316 316
317void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 317void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
318 chdir( currentPath.latin1() ); 318 chdir( currentPath.latin1() );
319 CurrentDir()->cd( currentPath, TRUE); 319 CurrentDir()->cd( currentPath, TRUE);
320 populateView(); 320 populateView();
321 update(); 321 update();
322} 322}
323 323
324QStringList AdvancedFm::getPath() { 324QStringList AdvancedFm::getPath() {
325 QStringList strList; 325 QStringList strList;
326 QListView *thisView=CurrentView(); 326 QListView *thisView=CurrentView();
327 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 327 QList<QListViewItem> * getSelectedItems( QListView * thisView );
328 QListViewItemIterator it( thisView ); 328 QListViewItemIterator it( thisView );
329 for ( ; it.current(); ++it ) { 329 for ( ; it.current(); ++it ) {
330 if ( it.current()->isSelected() ) { 330 if ( it.current()->isSelected() ) {
331 strList << it.current()->text(0); 331 strList << it.current()->text(0);
332// qDebug(it.current()->text(0)); 332// odebug << it.current()->text(0) << oendl;
333 } 333 }
334 } 334 }
335 return strList; 335 return strList;
336} 336}
337 337
338void AdvancedFm::homeButtonPushed() { 338void AdvancedFm::homeButtonPushed() {
339 QString current = QDir::homeDirPath(); 339 QString current = QDir::homeDirPath();
340 chdir( current.latin1() ); 340 chdir( current.latin1() );
341 CurrentDir()->cd( current, TRUE); 341 CurrentDir()->cd( current, TRUE);
342 populateView(); 342 populateView();
343 update(); 343 update();
344} 344}
345 345
346void AdvancedFm::docButtonPushed() { 346void AdvancedFm::docButtonPushed() {
347 QString current = QPEApplication::documentDir(); 347 QString current = QPEApplication::documentDir();
348 chdir( current.latin1() ); 348 chdir( current.latin1() );
349 CurrentDir()->cd( current, TRUE); 349 CurrentDir()->cd( current, TRUE);
350 populateView(); 350 populateView();
351 update(); 351 update();
352} 352}
353 353
354void AdvancedFm::SDButtonPushed() { 354void AdvancedFm::SDButtonPushed() {
355 QString current = "/mnt/card";// this can change so fix 355 QString current = "/mnt/card";// this can change so fix
356 chdir( current.latin1() ); 356 chdir( current.latin1() );
357 CurrentDir()->cd( current, TRUE); 357 CurrentDir()->cd( current, TRUE);
358 populateView(); 358 populateView();
359 update(); 359 update();
360} 360}
361 361
362void AdvancedFm::CFButtonPushed() { 362void AdvancedFm::CFButtonPushed() {
363 QString current; 363 QString current;
364 if(zaurusDevice) 364 if(zaurusDevice)
365 current= "/mnt/cf"; //zaurus 365 current= "/mnt/cf"; //zaurus
366 else 366 else
367 current = "/mnt/hda"; //ipaq 367 current = "/mnt/hda"; //ipaq
368 chdir( current.latin1() ); 368 chdir( current.latin1() );
369 CurrentDir()->cd( current, TRUE); 369 CurrentDir()->cd( current, TRUE);
370 populateView(); 370 populateView();
371 update(); 371 update();
372} 372}
373 373
374 374
375void AdvancedFm::doAbout() { 375void AdvancedFm::doAbout() {
376 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 376 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
377 "is copyright 2002-2003 by\n" 377 "is copyright 2002-2003 by\n"
378 "L.J.Potter<llornkcor@handhelds.org>\n" 378 "L.J.Potter<llornkcor@handhelds.org>\n"
379 "and is licensed by the GPL")); 379 "and is licensed by the GPL"));
380} 380}
381 381
382void AdvancedFm::keyPressEvent( QKeyEvent *e) { 382void AdvancedFm::keyPressEvent( QKeyEvent *e) {
383// qWarning("key %d", e->key()); 383// owarn << "key " << e->key() << "" << oendl;
384// if( CurrentView()->hasFocus() ) 384// if( CurrentView()->hasFocus() )
385 { 385 {
386 switch ( e->key() ) { 386 switch ( e->key() ) {
387 case Key_Left: 387 case Key_Left:
388 upDir(); 388 upDir();
389 break; 389 break;
390 case Key_Next: 390 case Key_Next:
391 break; 391 break;
392 case Key_Return: 392 case Key_Return:
393 case Key_Enter: 393 case Key_Enter:
394 navigateToSelected(); 394 navigateToSelected();
395 break; 395 break;
396 case Key_Tab: { 396 case Key_Tab: {
397 setOtherTabCurrent(); 397 setOtherTabCurrent();
398 } 398 }
399 break; 399 break;
400 case Key_Delete: 400 case Key_Delete:
401 del(); 401 del();
402 break; 402 break;
403 case Key_A: 403 case Key_A:
404 copyAs(); 404 copyAs();
405 break; 405 break;
406 case Key_C: 406 case Key_C:
407 copy(); 407 copy();
408 break; 408 break;
409 case Key_E: 409 case Key_E:
410 runThis(); 410 runThis();
411 break; 411 break;
412 case Key_G: 412 case Key_G:
413 { 413 {
414 currentPathCombo->lineEdit()->setFocus(); 414 currentPathCombo->lineEdit()->setFocus();
415 } 415 }
416 break; 416 break;
417 417
418 case Key_H: 418 case Key_H:
419 showHidden(); 419 showHidden();
420 break; 420 break;
421 case Key_I: 421 case Key_I:
422 fileStatus(); 422 fileStatus();
423 break; 423 break;
424 case Key_M: 424 case Key_M:
425 move(); 425 move();
426 break; 426 break;
427 case Key_N: 427 case Key_N:
428 mkDir(); 428 mkDir();
429 break; 429 break;
430 case Key_P: 430 case Key_P:
431 filePerms(); 431 filePerms();
@@ -593,293 +593,293 @@ void AdvancedFm::showFileMenu() {
593 m->setCheckable(TRUE); 593 m->setCheckable(TRUE);
594 if (!b) 594 if (!b)
595 m->setItemChecked(m->idAt(0),TRUE); 595 m->setItemChecked(m->idAt(0),TRUE);
596 else 596 else
597 m->setItemChecked(m->idAt(0),FALSE); 597 m->setItemChecked(m->idAt(0),FALSE);
598 598
599 if(Ir::supported()) 599 if(Ir::supported())
600 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 600 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
601 m->setFocus(); 601 m->setFocus();
602 602
603 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 603 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
604 604
605 if(m) delete m; 605 if(m) delete m;
606} 606}
607 607
608 608
609void AdvancedFm::cancelMenuTimer() { 609void AdvancedFm::cancelMenuTimer() {
610 610
611 if( menuTimer.isActive() ) 611 if( menuTimer.isActive() )
612 menuTimer.stop(); 612 menuTimer.stop();
613} 613}
614 614
615QString AdvancedFm::checkDiskSpace(const QString &path) { 615QString AdvancedFm::checkDiskSpace(const QString &path) {
616 struct statfs fss; 616 struct statfs fss;
617 if ( !statfs( path.latin1(), &fss ) ) { 617 if ( !statfs( path.latin1(), &fss ) ) {
618 int blkSize = fss.f_bsize; 618 int blkSize = fss.f_bsize;
619// int totalBlks = fs.f_blocks; 619// int totalBlks = fs.f_blocks;
620 int availBlks = fss.f_bavail; 620 int availBlks = fss.f_bavail;
621 621
622 long mult = blkSize / 1024; 622 long mult = blkSize / 1024;
623 long div = 1024 / blkSize; 623 long div = 1024 / blkSize;
624 if ( !mult ) mult = 1; 624 if ( !mult ) mult = 1;
625 if ( !div ) div = 1; 625 if ( !div ) div = 1;
626 626
627 627
628 return QString::number(availBlks * mult / div); 628 return QString::number(availBlks * mult / div);
629 } 629 }
630 return ""; 630 return "";
631} 631}
632 632
633void AdvancedFm::addToDocs() { 633void AdvancedFm::addToDocs() {
634 QStringList strListPaths = getPath(); 634 QStringList strListPaths = getPath();
635 QDir *thisDir = CurrentDir(); 635 QDir *thisDir = CurrentDir();
636 636
637 if( strListPaths.count() > 0) { 637 if( strListPaths.count() > 0) {
638 QString curFile; 638 QString curFile;
639 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 639 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
640 curFile = thisDir->canonicalPath()+"/"+(*it); 640 curFile = thisDir->canonicalPath()+"/"+(*it);
641// qDebug(curFile); 641// odebug << curFile << oendl;
642 QFileInfo fi(curFile); 642 QFileInfo fi(curFile);
643 DocLnk f; 643 DocLnk f;
644// curFile.replace(QRegExp("\\..*"),""); 644// curFile.replace(QRegExp("\\..*"),"");
645 f.setName(fi.baseName() ); 645 f.setName(fi.baseName() );
646 f.setFile( curFile); 646 f.setFile( curFile);
647 f.writeLink(); 647 f.writeLink();
648 } 648 }
649 } 649 }
650} 650}
651 651
652 652
653void AdvancedFm::customDirsToMenu() { 653void AdvancedFm::customDirsToMenu() {
654 654
655 Config cfg("AdvancedFm"); 655 Config cfg("AdvancedFm");
656 cfg.setGroup("Menu"); 656 cfg.setGroup("Menu");
657 657
658 QStringList list = cfg.readListEntry( "CustomDir", ','); 658 QStringList list = cfg.readListEntry( "CustomDir", ',');
659 menuButton->insertItems(list ); 659 menuButton->insertItems(list );
660 660
661// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 661// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
662// { 662// {
663// customDirMenu->insertItem(*it ); 663// customDirMenu->insertItem(*it );
664// } 664// }
665} 665}
666 666
667void AdvancedFm::dirMenuSelected(int item) { 667void AdvancedFm::dirMenuSelected(int item) {
668 switch(item) 668 switch(item)
669 { 669 {
670 670
671 case -21: 671 case -21:
672 case 0: 672 case 0:
673 addCustomDir(); 673 addCustomDir();
674 break; 674 break;
675 case -22: 675 case -22:
676 case 1: 676 case 1:
677 removeCustomDir(); 677 removeCustomDir();
678 break; 678 break;
679 default: 679 default:
680 { 680 {
681// gotoCustomDir( menuButton->text(item)); 681// gotoCustomDir( menuButton->text(item));
682// gotoCustomDir( customDirMenu->text(item)); 682// gotoCustomDir( customDirMenu->text(item));
683 } 683 }
684 break; 684 break;
685 685
686 }; 686 };
687} 687}
688 688
689void AdvancedFm::addCustomDir() { 689void AdvancedFm::addCustomDir() {
690 Config cfg("AdvancedFm"); 690 Config cfg("AdvancedFm");
691 cfg.setGroup("Menu"); 691 cfg.setGroup("Menu");
692 QString dir; 692 QString dir;
693 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 693 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
694 694
695 dir = CurrentDir()->canonicalPath(); 695 dir = CurrentDir()->canonicalPath();
696 696
697 bool addIt=true; 697 bool addIt=true;
698 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 698 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
699 if( dir == (*it)) { 699 if( dir == (*it)) {
700 addIt=false; 700 addIt=false;
701 } 701 }
702 } 702 }
703 if(addIt) { 703 if(addIt) {
704 menuButton->insertItem(dir); 704 menuButton->insertItem(dir);
705// customDirMenu->insertItem(dir); 705// customDirMenu->insertItem(dir);
706 list << dir; 706 list << dir;
707 } 707 }
708 708
709 cfg.writeEntry("CustomDir", list, ','); 709 cfg.writeEntry("CustomDir", list, ',');
710 cfg.write(); 710 cfg.write();
711} 711}
712 712
713void AdvancedFm::removeCustomDir() { 713void AdvancedFm::removeCustomDir() {
714// qDebug("remove custom dir"); 714// odebug << "remove custom dir" << oendl;
715 Config cfg("AdvancedFm"); 715 Config cfg("AdvancedFm");
716 cfg.setGroup("Menu"); 716 cfg.setGroup("Menu");
717 QString dir; 717 QString dir;
718 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 718 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
719 QStringList list2; 719 QStringList list2;
720 dir = CurrentDir()->canonicalPath(); 720 dir = CurrentDir()->canonicalPath();
721 int ramble=2; 721 int ramble=2;
722// int ramble=-24; 722// int ramble=-24;
723//first remove list 723//first remove list
724 if(list.grep(dir,true).isEmpty()) { 724 if(list.grep(dir,true).isEmpty()) {
725 QMessageBox::message(tr( "AdvancedFm" ), 725 QMessageBox::message(tr( "AdvancedFm" ),
726 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 726 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
727 } else { 727 } else {
728 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 728 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
729 if((*it) != dir) { 729 if((*it) != dir) {
730//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
731 list2 <<(*it); 731 list2 <<(*it);
732 } else { 732 } else {
733// customDirMenu->removeItem( ramble); 733// customDirMenu->removeItem( ramble);
734 menuButton->remove( ramble); 734 menuButton->remove( ramble);
735 735
736 } 736 }
737 ramble++; 737 ramble++;
738// ramble--; 738// ramble--;
739 } 739 }
740 740
741 cfg.writeEntry("CustomDir", list2, ','); 741 cfg.writeEntry("CustomDir", list2, ',');
742 cfg.write(); 742 cfg.write();
743 } 743 }
744// customDirsToMenu(); 744// customDirsToMenu();
745 745
746} 746}
747 747
748void AdvancedFm::gotoCustomDir(const QString &dir) { 748void AdvancedFm::gotoCustomDir(const QString &dir) {
749// qDebug("gotoCustomDir(const QString &dir) " +dir ); 749// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl;
750// QString curDir = dir; 750// QString curDir = dir;
751// QDir *thisDir = CurrentDir(); 751// QDir *thisDir = CurrentDir();
752// if( curDir.isEmpty()) { 752// if( curDir.isEmpty()) {
753// } 753// }
754 if( dir == s_addBookmark) { 754 if( dir == s_addBookmark) {
755 addCustomDir(); 755 addCustomDir();
756 } 756 }
757 if( dir == s_removeBookmark) { 757 if( dir == s_removeBookmark) {
758 removeCustomDir( ); 758 removeCustomDir( );
759 } else { 759 } else {
760 gotoDirectory( dir); 760 gotoDirectory( dir);
761// if(QDir( curDir).exists() ) 761// if(QDir( curDir).exists() )
762// { 762// {
763// thisDir->setPath( curDir ); 763// thisDir->setPath( curDir );
764// chdir( curDir.latin1() ); 764// chdir( curDir.latin1() );
765// thisDir->cd( curDir, TRUE); 765// thisDir->cd( curDir, TRUE);
766// populateView(); 766// populateView();
767// } 767// }
768 } 768 }
769} 769}
770 770
771QDir *AdvancedFm::CurrentDir() { 771QDir *AdvancedFm::CurrentDir() {
772 772
773 if ( whichTab == 1) { 773 if ( whichTab == 1) {
774 return &currentDir; 774 return &currentDir;
775 } else { 775 } else {
776 return &currentRemoteDir; 776 return &currentRemoteDir;
777 } 777 }
778} 778}
779 779
780QDir *AdvancedFm::OtherDir() { 780QDir *AdvancedFm::OtherDir() {
781 if ( whichTab == 1) { 781 if ( whichTab == 1) {
782 return &currentRemoteDir; 782 return &currentRemoteDir;
783 } else { 783 } else {
784 return &currentDir; 784 return &currentDir;
785 } 785 }
786} 786}
787 787
788QListView * AdvancedFm::CurrentView() { 788QListView * AdvancedFm::CurrentView() {
789 if ( whichTab == 1) { 789 if ( whichTab == 1) {
790// qWarning("CurrentView Tab 1"); 790// owarn << "CurrentView Tab 1" << oendl;
791 return Local_View; 791 return Local_View;
792 } else { 792 } else {
793// qWarning("CurrentView Tab 2"); 793// owarn << "CurrentView Tab 2" << oendl;
794 return Remote_View; 794 return Remote_View;
795 } 795 }
796} 796}
797 797
798QListView * AdvancedFm::OtherView() { 798QListView * AdvancedFm::OtherView() {
799 if ( whichTab == 1) 799 if ( whichTab == 1)
800 return Remote_View; 800 return Remote_View;
801 else 801 else
802 return Local_View; 802 return Local_View;
803} 803}
804 804
805void AdvancedFm::setOtherTabCurrent() { 805void AdvancedFm::setOtherTabCurrent() {
806// qWarning("setOtherTabCurrent() %d", whichTab); 806// owarn << "setOtherTabCurrent() " << whichTab << "" << oendl;
807 if ( whichTab == 1) { 807 if ( whichTab == 1) {
808 TabWidget->setCurrentWidget(1); 808 TabWidget->setCurrentWidget(1);
809 } else { 809 } else {
810 TabWidget->setCurrentWidget(0); 810 TabWidget->setCurrentWidget(0);
811 } 811 }
812 OtherView()->setFocus(); 812 OtherView()->setFocus();
813 OtherView()->setSelected( CurrentView()->firstChild(), true); 813 OtherView()->setSelected( CurrentView()->firstChild(), true);
814} 814}
815 815
816void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 816void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
817// qDebug("qcop message "+msg ); 817// odebug << "qcop message "+msg << oendl;
818 QDataStream stream ( data, IO_ReadOnly ); 818 QDataStream stream ( data, IO_ReadOnly );
819 if ( msg == "openDirectory(QString)" ) { 819 if ( msg == "openDirectory(QString)" ) {
820// qDebug("received"); 820// odebug << "received" << oendl;
821 QString file; 821 QString file;
822 stream >> file; 822 stream >> file;
823 gotoDirectory( (const QString &) file); 823 gotoDirectory( (const QString &) file);
824 } 824 }
825} 825}
826 826
827void AdvancedFm::setDocument(const QString &file) { 827void AdvancedFm::setDocument(const QString &file) {
828 gotoDirectory( file); 828 gotoDirectory( file);
829 829
830} 830}
831 831
832void AdvancedFm::gotoDirectory(const QString &file) { 832void AdvancedFm::gotoDirectory(const QString &file) {
833// qWarning("goto dir "+file); 833// owarn << "goto dir "+file << oendl;
834 QString curDir = file; 834 QString curDir = file;
835 QDir *thisDir = CurrentDir(); 835 QDir *thisDir = CurrentDir();
836 if(QDir( curDir).exists() ) { 836 if(QDir( curDir).exists() ) {
837 thisDir->setPath( curDir ); 837 thisDir->setPath( curDir );
838 chdir( curDir.latin1() ); 838 chdir( curDir.latin1() );
839 thisDir->cd( curDir, TRUE); 839 thisDir->cd( curDir, TRUE);
840 populateView(); 840 populateView();
841 } 841 }
842 else if(QFileInfo(curDir).exists()) { 842 else if(QFileInfo(curDir).exists()) {
843 QFileInfo fileInfo(curDir); 843 QFileInfo fileInfo(curDir);
844 curDir=fileInfo.dirPath(); 844 curDir=fileInfo.dirPath();
845 if(QDir( curDir).exists() ) { 845 if(QDir( curDir).exists() ) {
846 thisDir->setPath( curDir ); 846 thisDir->setPath( curDir );
847 chdir( curDir.latin1() ); 847 chdir( curDir.latin1() );
848 thisDir->cd( curDir, TRUE); 848 thisDir->cd( curDir, TRUE);
849 populateView(); 849 populateView();
850 } 850 }
851 findFile(file); 851 findFile(file);
852 } 852 }
853 853
854} 854}
855 855
856void AdvancedFm::findFile(const QString &fileName) { 856void AdvancedFm::findFile(const QString &fileName) {
857 QFileInfo fi(fileName); 857 QFileInfo fi(fileName);
858 QListView *thisView = CurrentView(); 858 QListView *thisView = CurrentView();
859 QListViewItemIterator it( thisView ); 859 QListViewItemIterator it( thisView );
860 for ( ; it.current(); ++it ) { 860 for ( ; it.current(); ++it ) {
861 if(it.current()->text(0) == fi.fileName()) { 861 if(it.current()->text(0) == fi.fileName()) {
862 it.current()->setSelected(true); 862 it.current()->setSelected(true);
863 thisView->ensureItemVisible(it.current()); 863 thisView->ensureItemVisible(it.current());
864 } 864 }
865 } 865 }
866} 866}
867 867
868void AdvancedFm::slotSwitchMenu(int ) { 868void AdvancedFm::slotSwitchMenu(int ) {
869// qDebug("Switch %d", item); 869// odebug << "Switch " << item << "" << oendl;
870 // viewMenu->setItemChecked(item, true); 870 // viewMenu->setItemChecked(item, true);
871} 871}
872 872
873void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { 873void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
874 tabChanged( w); 874 tabChanged( w);
875 if( w == Local_View) { 875 if( w == Local_View) {
876 Remote_View->clearFocus(); 876 Remote_View->clearFocus();
877 } else { 877 } else {
878 Local_View->clearFocus(); 878 Local_View->clearFocus();
879 } 879 }
880} 880}
881 881
882void AdvancedFm::navigateToSelected() { 882void AdvancedFm::navigateToSelected() {
883 if( !CurrentView()->currentItem()) return; 883 if( !CurrentView()->currentItem()) return;
884 doDirChange(); 884 doDirChange();
885} 885}
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 716343d..f1c518e 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,35 +1,15 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on quick-app 2CONFIG += qt warn_on quick-app
3# CONFIG += qt warn_on
4HEADERS = advancedfm.h filePermissions.h output.h 3HEADERS = advancedfm.h filePermissions.h output.h
5SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp 4SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
6TARGET = advancedfm 5TARGET = advancedfm
7INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 7DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopiecore2 -lopieui2 8LIBS += -lqpe -lopiecore2 -lopieui2
10
11TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
12 ../../../i18n/nl/advancedfm.ts \
13 ../../../i18n/da/advancedfm.ts \
14 ../../../i18n/xx/advancedfm.ts \
15 ../../../i18n/en/advancedfm.ts \
16 ../../../i18n/es/advancedfm.ts \
17 ../../../i18n/fr/advancedfm.ts \
18 ../../../i18n/hu/advancedfm.ts \
19 ../../../i18n/ja/advancedfm.ts \
20 ../../../i18n/ko/advancedfm.ts \
21 ../../../i18n/no/advancedfm.ts \
22 ../../../i18n/pl/advancedfm.ts \
23 ../../../i18n/pt/advancedfm.ts \
24 ../../../i18n/pt_BR/advancedfm.ts \
25 ../../../i18n/sl/advancedfm.ts \
26 ../../../i18n/zh_CN/advancedfm.ts \
27 ../../../i18n/zh_TW/advancedfm.ts
28
29 9
30!contains(CONFIG,quick-app) { 10!contains(CONFIG,quick-app) {
31 DESTDIR = $(OPIEDIR)/bin 11 DESTDIR = $(OPIEDIR)/bin
32 DEFINES += NOQUICKLAUNCH 12 DEFINES += NOQUICKLAUNCH
33} 13}
34 14
35include ( $(OPIEDIR)/include.pro ) 15include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 2997c55..29335f8 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -1,78 +1,82 @@
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/* OPIE */
15#include <opie2/odebug.h>
14#include <qpe/storage.h> 16#include <qpe/storage.h>
15#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
16#include <qpe/resource.h> 18#include <qpe/resource.h>
17#include <qpe/menubutton.h> 19#include <qpe/menubutton.h>
20using namespace Opie::Core;
21using namespace Opie::Ui;
18 22
23/* QT */
19#include <qlayout.h> 24#include <qlayout.h>
20#include <qhbox.h> 25#include <qhbox.h>
21#include <qmenubar.h> 26#include <qmenubar.h>
22#include <qcombobox.h> 27#include <qcombobox.h>
23#include <qtoolbutton.h> 28#include <qtoolbutton.h>
24#include <qlineedit.h> 29#include <qlineedit.h>
25#include <qlistview.h> 30#include <qlistview.h>
26 31
32/* STD */
27#include <sys/utsname.h> 33#include <sys/utsname.h>
28 34
29
30using namespace Opie::Ui;
31void AdvancedFm::init() { 35void AdvancedFm::init() {
32 b = false; 36 b = false;
33 setCaption( tr( "AdvancedFm" ) ); 37 setCaption( tr( "AdvancedFm" ) );
34 38
35 QVBoxLayout *layout = new QVBoxLayout( this ); 39 QVBoxLayout *layout = new QVBoxLayout( this );
36 layout->setSpacing( 2); 40 layout->setSpacing( 2);
37 layout->setMargin( 0); // squeeze 41 layout->setMargin( 0); // squeeze
38 42
39 QMenuBar *menuBar = new QMenuBar(this); 43 QMenuBar *menuBar = new QMenuBar(this);
40 menuBar->setMargin( 0 ); // squeeze 44 menuBar->setMargin( 0 ); // squeeze
41 fileMenu = new QPopupMenu( this ); 45 fileMenu = new QPopupMenu( this );
42 viewMenu = new QPopupMenu( this ); 46 viewMenu = new QPopupMenu( this );
43// customDirMenu = new QPopupMenu( this ); 47// customDirMenu = new QPopupMenu( this );
44 48
45 layout->addWidget( menuBar ); 49 layout->addWidget( menuBar );
46 50
47 menuBar->insertItem( tr( "File" ), fileMenu); 51 menuBar->insertItem( tr( "File" ), fileMenu);
48 menuBar->insertItem( tr( "View" ), viewMenu); 52 menuBar->insertItem( tr( "View" ), viewMenu);
49 53
50 cdUpButton = new QToolButton( 0,"cdUpButton"); 54 cdUpButton = new QToolButton( 0,"cdUpButton");
51 cdUpButton->setPixmap(Resource::loadPixmap("up")); 55 cdUpButton->setPixmap(Resource::loadPixmap("up"));
52 cdUpButton->setAutoRaise( true ); 56 cdUpButton->setAutoRaise( true );
53 menuBar->insertItem( cdUpButton ); 57 menuBar->insertItem( cdUpButton );
54 58
55 59
56 60
57 qpeDirButton= new QToolButton( 0,"QPEButton"); 61 qpeDirButton= new QToolButton( 0,"QPEButton");
58 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); 62 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
59 qpeDirButton->setAutoRaise( true ); 63 qpeDirButton->setAutoRaise( true );
60 menuBar->insertItem( qpeDirButton ); 64 menuBar->insertItem( qpeDirButton );
61 65
62 cfButton = new QToolButton( 0, "CFButton"); 66 cfButton = new QToolButton( 0, "CFButton");
63 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); 67 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
64 cfButton->setAutoRaise( true ); 68 cfButton->setAutoRaise( true );
65 menuBar->insertItem( cfButton ); 69 menuBar->insertItem( cfButton );
66 70
67 sdButton = new QToolButton( 0, "SDButton"); 71 sdButton = new QToolButton( 0, "SDButton");
68 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); 72 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard"));
69 sdButton->setAutoRaise( true ); 73 sdButton->setAutoRaise( true );
70 menuBar->insertItem( sdButton ); 74 menuBar->insertItem( sdButton );
71 75
72 docButton = new QToolButton( 0,"docsButton"); 76 docButton = new QToolButton( 0,"docsButton");
73 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 77 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
74 docButton->setAutoRaise( true ); 78 docButton->setAutoRaise( true );
75 menuBar->insertItem( docButton ); 79 menuBar->insertItem( docButton );
76 80
77 homeButton = new QToolButton( 0, "homeButton"); 81 homeButton = new QToolButton( 0, "homeButton");
78 homeButton->setPixmap(Resource::loadPixmap("home")); 82 homeButton->setPixmap(Resource::loadPixmap("home"));
@@ -174,101 +178,101 @@ void AdvancedFm::init() {
174 Remote_View->addColumn( tr("Size"),-1); 178 Remote_View->addColumn( tr("Size"),-1);
175 Remote_View->setColumnAlignment(1,QListView::AlignRight); 179 Remote_View->setColumnAlignment(1,QListView::AlignRight);
176 Remote_View->addColumn( tr("Date"),-1); 180 Remote_View->addColumn( tr("Date"),-1);
177 Remote_View->setColumnAlignment(2,QListView::AlignRight); 181 Remote_View->setColumnAlignment(2,QListView::AlignRight);
178 Remote_View->setAllColumnsShowFocus(TRUE); 182 Remote_View->setAllColumnsShowFocus(TRUE);
179 Remote_View->setMultiSelection( TRUE ); 183 Remote_View->setMultiSelection( TRUE );
180 Remote_View->setSelectionMode(QListView::Extended); 184 Remote_View->setSelectionMode(QListView::Extended);
181 Remote_View->setFocusPolicy(StrongFocus); 185 Remote_View->setFocusPolicy(StrongFocus);
182 Remote_View->installEventFilter( this ); 186 Remote_View->installEventFilter( this );
183 187
184 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 188 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
185 189
186 tabLayout_2->addWidget( Remote_View, 0, 0 ); 190 tabLayout_2->addWidget( Remote_View, 0, 0 );
187 191
188 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); 192 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
189 TabWidget->setSizeChange( 370 ); 193 TabWidget->setSizeChange( 370 );
190// TabWidget->insertTab( tab_2, tr( "2")); 194// TabWidget->insertTab( tab_2, tr( "2"));
191 195
192 /* tab_3 = new QWidget( TabWidget, "tab_3" ); 196 /* tab_3 = new QWidget( TabWidget, "tab_3" );
193 tabLayout_3 = new QGridLayout( tab_3 ); 197 tabLayout_3 = new QGridLayout( tab_3 );
194 tabLayout_3->setSpacing( 2); 198 tabLayout_3->setSpacing( 2);
195 tabLayout_3->setMargin( 2); 199 tabLayout_3->setMargin( 2);
196 200
197 201
198 // OFileDialog fileDialog; 202 // OFileDialog fileDialog;
199 // fileDialog; 203 // fileDialog;
200 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy 204 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
201 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); 205 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
202 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); 206 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
203 207
204 QListView *fileTree; 208 QListView *fileTree;
205 fileTree = new QListView( tab_3, "tree" ); 209 fileTree = new QListView( tab_3, "tree" );
206 210
207 211
208 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); 212 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
209 213
210 TabWidget->insertTab( tab_3, tr( "Remote" ) ); 214 TabWidget->insertTab( tab_3, tr( "Remote" ) );
211 */ 215 */
212 216
213 /////////////// 217 ///////////////
214 218
215 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 219 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
216 zaurusDevice=TRUE; 220 zaurusDevice=TRUE;
217 else 221 else
218 zaurusDevice=FALSE; 222 zaurusDevice=FALSE;
219 223
220 224
221 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { 225 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
222 qDebug("not have sd"); 226 odebug << "not have sd" << oendl;
223 sdButton->hide(); 227 sdButton->hide();
224 } 228 }
225 if( !StorageInfo::hasCf() ) { 229 if( !StorageInfo::hasCf() ) {
226 qDebug("not have cf"); 230 odebug << "not have cf" << oendl;
227 cfButton->hide(); 231 cfButton->hide();
228 } 232 }
229 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 233 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
230 currentDir.setPath( QDir::currentDirPath()); 234 currentDir.setPath( QDir::currentDirPath());
231 235
232 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 236 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
233 currentRemoteDir.setPath( QDir::currentDirPath()); 237 currentRemoteDir.setPath( QDir::currentDirPath());
234 238
235 // b = TRUE; 239 // b = TRUE;
236 240
237 filterStr="*"; 241 filterStr="*";
238 showMenuHidden(); 242 showMenuHidden();
239 TabWidget->setCurrentWidget(0); 243 TabWidget->setCurrentWidget(0);
240 244
241} 245}
242 246
243void AdvancedFm::initConnections() 247void AdvancedFm::initConnections()
244{ 248{
245 249
246 connect( qApp,SIGNAL( aboutToQuit()), 250 connect( qApp,SIGNAL( aboutToQuit()),
247 this, SLOT( cleanUp()) ); 251 this, SLOT( cleanUp()) );
248 connect( qpeDirButton ,SIGNAL(released()), 252 connect( qpeDirButton ,SIGNAL(released()),
249 this,SLOT( QPEButtonPushed()) ); 253 this,SLOT( QPEButtonPushed()) );
250 connect( cfButton ,SIGNAL(released()), 254 connect( cfButton ,SIGNAL(released()),
251 this,SLOT( CFButtonPushed()) ); 255 this,SLOT( CFButtonPushed()) );
252 connect( sdButton ,SIGNAL(released()), 256 connect( sdButton ,SIGNAL(released()),
253 this,SLOT( SDButtonPushed()) ); 257 this,SLOT( SDButtonPushed()) );
254 connect( cdUpButton ,SIGNAL(released()), 258 connect( cdUpButton ,SIGNAL(released()),
255 this,SLOT( upDir()) ); 259 this,SLOT( upDir()) );
256 connect( docButton,SIGNAL(released()), 260 connect( docButton,SIGNAL(released()),
257 this,SLOT( docButtonPushed()) ); 261 this,SLOT( docButtonPushed()) );
258 connect( homeButton,SIGNAL(released()), 262 connect( homeButton,SIGNAL(released()),
259 this,SLOT( homeButtonPushed()) ); 263 this,SLOT( homeButtonPushed()) );
260 connect( currentPathCombo, SIGNAL( activated(const QString&) ), 264 connect( currentPathCombo, SIGNAL( activated(const QString&) ),
261 this, SLOT( currentPathComboActivated(const QString&) ) ); 265 this, SLOT( currentPathComboActivated(const QString&) ) );
262 266
263 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 267 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
264 this,SLOT(currentPathComboChanged())); 268 this,SLOT(currentPathComboChanged()));
265 269
266 connect( Local_View, SIGNAL( clicked(QListViewItem*)), 270 connect( Local_View, SIGNAL( clicked(QListViewItem*)),
267 this,SLOT( ListClicked(QListViewItem*)) ); 271 this,SLOT( ListClicked(QListViewItem*)) );
268 272
269 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 273 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
270 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); 274 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
271 275
272 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 276 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
273 277
274 connect( Remote_View, SIGNAL( clicked(QListViewItem*)), 278 connect( Remote_View, SIGNAL( clicked(QListViewItem*)),
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 81a4318..d34f330 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,839 +1,842 @@
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
13#include "output.h" 13#include "advancedfm.h"
14#include "filePermissions.h" 14#include "output.h"
15 15#include "filePermissions.h"
16#include <qpe/lnkproperties.h> 16
17#include <qpe/qpeapplication.h> 17/* OPIE */
18#include <qpe/applnk.h> 18#include <opie2/odebug.h>
19 19#include <qpe/lnkproperties.h>
20#include <qmessagebox.h> 20#include <qpe/qpeapplication.h>
21 21#include <qpe/applnk.h>
22 22using namespace Opie::Core;
23#include <qpopupmenu.h> 23
24#include <qlistview.h> 24/* QT*/
25 25
26#include <errno.h> 26#include <qmessagebox.h>
27#include <stdlib.h> 27#include <qpopupmenu.h>
28#include <unistd.h> 28#include <qlistview.h>
29#include <sys/stat.h> 29
30#include <dirent.h> 30/* STD */
31#include <sys/sendfile.h> 31
32#include <fcntl.h> 32#include <errno.h>
33 33#include <stdlib.h>
34 34#include <unistd.h>
35using namespace Opie::Core; 35#include <sys/stat.h>
36using namespace Opie::Core; 36#include <dirent.h>
37void AdvancedFm::doDirChange() { 37#include <sys/sendfile.h>
38 QString pathItem = CurrentView()->currentItem()->text(0); 38#include <fcntl.h>
39 if( pathItem == "../") { 39
40 ListClicked( CurrentView()->currentItem()); 40void AdvancedFm::doDirChange() {
41 } else { 41 QString pathItem = CurrentView()->currentItem()->text(0);
42 if( pathItem.find(" -> ",0,TRUE) != -1) 42 if( pathItem == "../") {
43 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 43 ListClicked( CurrentView()->currentItem());
44// qWarning(pathItem); 44 } else {
45 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 45 if( pathItem.find(" -> ",0,TRUE) != -1)
46 } 46 pathItem = dealWithSymName((const QString&)pathItem)+"/";
47} 47// owarn << pathItem << oendl;
48 48 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
49void AdvancedFm::showMenuHidden() { 49 }
50 if (b) { 50}
51 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 51
52 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 52void AdvancedFm::showMenuHidden() {
53 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 53 if (b) {
54 } else { 54 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
55 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 55 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
56 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 56 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
57 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 57 } else {
58 } 58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
59 b = !b; 59 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
60 populateView(); 60 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
61} 61 }
62 62 b = !b;
63void AdvancedFm::showHidden() { 63 populateView();
64 if (b) { 64}
65 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 65
66 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 66void AdvancedFm::showHidden() {
67 } else { 67 if (b) {
68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 68 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
69 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 69 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
70 } 70 } else {
71 populateView(); 71 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
72} 72 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
73 73 }
74QString AdvancedFm::dealWithSymName(const QString &fileName) { 74 populateView();
75 QString strItem = fileName; 75}
76 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 76
77} 77QString AdvancedFm::dealWithSymName(const QString &fileName) {
78 78 QString strItem = fileName;
79void AdvancedFm::runThis() { 79 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
80 if( !CurrentView()->currentItem()) return; 80}
81 QString fs; 81
82 QDir *thisDir = CurrentDir(); 82void AdvancedFm::runThis() {
83 83 if( !CurrentView()->currentItem()) return;
84 QString curFile = CurrentView()->currentItem()->text(0); 84 QString fs;
85 QString path = thisDir->canonicalPath(); 85 QDir *thisDir = CurrentDir();
86 86
87 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 87 QString curFile = CurrentView()->currentItem()->text(0);
88 88 QString path = thisDir->canonicalPath();
89 curFile = dealWithSymName((const QString&)curFile); 89
90 90 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
91 if(curFile != "../") { 91
92 92 curFile = dealWithSymName((const QString&)curFile);
93 fs = getFileSystemType((const QString &) path); 93
94 QFileInfo fileInfo( path + "/" + curFile); 94 if(curFile != "../") {
95// qDebug( fileInfo.owner()); 95
96 96 fs = getFileSystemType((const QString &) path);
97 if( (fileInfo.permission( QFileInfo::ExeUser) 97 QFileInfo fileInfo( path + "/" + curFile);
98 | fileInfo.permission( QFileInfo::ExeGroup) 98// odebug << fileInfo.owner() << oendl;
99 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 99
100 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 100 if( (fileInfo.permission( QFileInfo::ExeUser)
101 QCopEnvelope e("QPE/System", "execute(QString)" ); 101 | fileInfo.permission( QFileInfo::ExeGroup)
102 e << curFile; 102 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
103 } else { 103 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
104 curFile = path + "/" + curFile; 104 QCopEnvelope e("QPE/System", "execute(QString)" );
105 DocLnk nf(curFile); 105 e << curFile;
106 QString execStr = nf.exec(); 106 } else {
107// qDebug( execStr); 107 curFile = path + "/" + curFile;
108 if( execStr.isEmpty() ) { 108 DocLnk nf(curFile);
109 } else { 109 QString execStr = nf.exec();
110 nf.execute(); 110// odebug << execStr << oendl;
111 } 111 if( execStr.isEmpty() ) {
112 } 112 } else {
113 } 113 nf.execute();
114} 114 }
115 115 }
116void AdvancedFm::runText() { 116 }
117 if( !CurrentView()->currentItem()) return; 117}
118 QString curFile = CurrentView()->currentItem()->text(0); 118
119 if(curFile != "../") { 119void AdvancedFm::runText() {
120 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 120 if( !CurrentView()->currentItem()) return;
121 curFile = dealWithSymName((const QString&)curFile); 121 QString curFile = CurrentView()->currentItem()->text(0);
122 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 122 if(curFile != "../") {
123 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 123 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
124 e << curFile; 124 curFile = dealWithSymName((const QString&)curFile);
125 } 125 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
126} 126 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
127 127 e << curFile;
128void AdvancedFm::makeDir() { 128 }
129 InputDialog *fileDlg; 129}
130 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 130
131 fileDlg->exec(); 131void AdvancedFm::makeDir() {
132 if( fileDlg->result() == 1 ) { 132 InputDialog *fileDlg;
133 QDir *thisDir = CurrentDir(); 133 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
134 QString filename = fileDlg->LineEdit1->text(); 134 fileDlg->exec();
135 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 135 if( fileDlg->result() == 1 ) {
136 } 136 QDir *thisDir = CurrentDir();
137 populateView(); 137 QString filename = fileDlg->LineEdit1->text();
138} 138 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
139 139 }
140void AdvancedFm::doDelete() { 140 populateView();
141 QStringList curFileList = getPath(); 141}
142 bool doMsg=true; 142
143 int count = curFileList.count(); 143void AdvancedFm::doDelete() {
144 if( count > 0) { 144 QStringList curFileList = getPath();
145 if(count > 1 ) { 145 bool doMsg=true;
146 QString msg; 146 int count = curFileList.count();
147 msg=tr("Really delete\n%1 files?").arg(count); 147 if( count > 0) {
148 switch ( QMessageBox::warning(this,tr("Delete"),msg 148 if(count > 1 ) {
149 ,tr("Yes"),tr("No"),0,0,1) ) 149 QString msg;
150 { 150 msg=tr("Really delete\n%1 files?").arg(count);
151 case 0: 151 switch ( QMessageBox::warning(this,tr("Delete"),msg
152 doMsg=false; 152 ,tr("Yes"),tr("No"),0,0,1) )
153 break; 153 {
154 case 1: 154 case 0:
155 return; 155 doMsg=false;
156 break; 156 break;
157 }; 157 case 1:
158 } 158 return;
159 159 break;
160 QString myFile; 160 };
161 161 }
162 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 162
163 myFile = (*it); 163 QString myFile;
164 if( myFile.find(" -> ",0,TRUE) != -1) 164
165 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 165 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
166 166 myFile = (*it);
167 QString f = CurrentDir()->canonicalPath(); 167 if( myFile.find(" -> ",0,TRUE) != -1)
168 if(f.right(1).find("/",0,TRUE) == -1) 168 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
169 f += "/"; 169
170 f += myFile; 170 QString f = CurrentDir()->canonicalPath();
171 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 171 if(f.right(1).find("/",0,TRUE) == -1)
172 //if file is a directory 172 f += "/";
173 173 f += myFile;
174 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 174 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
175 tr("Really delete %1\nand all it's contents ?" ).arg( f ) , 175 //if file is a directory
176 tr("Yes"), tr("No"), 0, 0, 1) ) { 176
177 case 0: 177 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
178 { 178 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
179 f=f.left(f.length()-1); 179 tr("Yes"), tr("No"), 0, 0, 1) ) {
180 QString cmd="rm -rf "+f; 180 case 0:
181 startProcess( (const QString)cmd.latin1() ); 181 {
182 populateView(); 182 f=f.left(f.length()-1);
183 } 183 QString cmd="rm -rf "+f;
184 break; 184 startProcess( (const QString)cmd.latin1() );
185 case 1: 185 populateView();
186 // exit 186 }
187 break; 187 break;
188 }; 188 case 1:
189 189 // exit
190 } else { 190 break;
191 if(doMsg) { 191 };
192 switch ( QMessageBox::warning(this,tr("Delete"), 192
193 tr("Really delete\n%1?").arg( myFile ), 193 } else {
194 tr("Yes"), tr("No"), 0, 0, 1) ) { 194 if(doMsg) {
195 case 1: 195 switch ( QMessageBox::warning(this,tr("Delete"),
196 return; 196 tr("Really delete\n%1?").arg( myFile ),
197 break; 197 tr("Yes"), tr("No"), 0, 0, 1) ) {
198 }; 198 case 1:
199 } 199 return;
200 200 break;
201 QString cmd="rm "+f; 201 };
202 QFile file(f); 202 }
203 QFileInfo fi(myFile); 203
204 if( fi.fileName().find("../",0,TRUE)==-1) { 204 QString cmd="rm "+f;
205// qDebug("remove link files "+myFile); 205 QFile file(f);
206 206 QFileInfo fi(myFile);
207// DocLnk lnk(f); 207 if( fi.fileName().find("../",0,TRUE)==-1) {
208 DocLnk *lnk; 208// odebug << "remove link files "+myFile << oendl;
209 lnk = new DocLnk(f); 209
210// qDebug("Deleting doclnk " + lnk->linkFile()); 210// DocLnk lnk(f);
211 if(lnk->isValid()) 211 DocLnk *lnk;
212 lnk->removeLinkFile(); 212 lnk = new DocLnk(f);
213 // delete lnk; 213// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
214 file.remove(); 214 if(lnk->isValid())
215 } 215 lnk->removeLinkFile();
216 } 216 // delete lnk;
217 } 217 file.remove();
218 } 218 }
219 populateView(); 219 }
220} 220 }
221 221 }
222void AdvancedFm::filePerms() { 222 populateView();
223 QStringList curFileList = getPath(); 223}
224 QString filePath; 224
225 225void AdvancedFm::filePerms() {
226 filePath = CurrentDir()->canonicalPath()+"/"; 226 QStringList curFileList = getPath();
227 227 QString filePath;
228 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 228
229 filePermissions *filePerm; 229 filePath = CurrentDir()->canonicalPath()+"/";
230 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 230
231 QPEApplication::execDialog( filePerm ); 231 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
232 if( filePerm ) 232 filePermissions *filePerm;
233 delete filePerm; 233 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
234 } 234 QPEApplication::execDialog( filePerm );
235 populateView(); 235 if( filePerm )
236} 236 delete filePerm;
237 237 }
238void AdvancedFm::doProperties() { 238 populateView();
239#if defined(QT_QWS_OPIE) 239}
240 240
241 QStringList curFileList = getPath(); 241void AdvancedFm::doProperties() {
242 242#if defined(QT_QWS_OPIE)
243 QString filePath; 243
244 filePath = CurrentDir()->canonicalPath()+"/"; 244 QStringList curFileList = getPath();
245 245
246// qDebug("%d",curFileList.count()); 246 QString filePath;
247 247 filePath = CurrentDir()->canonicalPath()+"/";
248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 248
249// qDebug((filePath+*it)); 249// odebug << "" << curFileList.count() << "" << oendl;
250 DocLnk lnk( (filePath+*it)); 250
251 LnkProperties prop( &lnk ); 251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
252 QPEApplication::execDialog( &prop ); 252// odebug << (filePath+*it) << oendl;
253 } 253 DocLnk lnk( (filePath+*it));
254#endif 254 LnkProperties prop( &lnk );
255 255 QPEApplication::execDialog( &prop );
256} 256 }
257 257#endif
258void AdvancedFm::upDir() { 258
259 QDir *thisDir = CurrentDir(); 259}
260 QString current = thisDir->canonicalPath(); 260
261 QDir dir(current); 261void AdvancedFm::upDir() {
262 dir.cdUp(); 262 QDir *thisDir = CurrentDir();
263 current = dir.canonicalPath(); 263 QString current = thisDir->canonicalPath();
264 chdir( current.latin1() ); 264 QDir dir(current);
265 thisDir->cd( current, TRUE); 265 dir.cdUp();
266 266 current = dir.canonicalPath();
267 populateView(); 267 chdir( current.latin1() );
268 update(); 268 thisDir->cd( current, TRUE);
269} 269
270 270 populateView();
271void AdvancedFm::copy() { 271 update();
272 qApp->processEvents(); 272}
273 QStringList curFileList = getPath(); 273
274 274void AdvancedFm::copy() {
275 QDir *thisDir = CurrentDir(); 275 qApp->processEvents();
276 QDir *thatDir = OtherDir(); 276 QStringList curFileList = getPath();
277 277
278 bool doMsg=true; 278 QDir *thisDir = CurrentDir();
279 int count=curFileList.count(); 279 QDir *thatDir = OtherDir();
280 if( count > 0) { 280
281 if(count > 1 ){ 281 bool doMsg=true;
282 QString msg; 282 int count=curFileList.count();
283 msg=tr("Really copy\n%1 files?").arg(count); 283 if( count > 0) {
284 switch ( QMessageBox::warning(this,tr("Copy"),msg 284 if(count > 1 ){
285 ,tr("Yes"),tr("No"),0,0,1) ) 285 QString msg;
286 { 286 msg=tr("Really copy\n%1 files?").arg(count);
287 case 0: 287 switch ( QMessageBox::warning(this,tr("Copy"),msg
288 doMsg=false; 288 ,tr("Yes"),tr("No"),0,0,1) )
289 break; 289 {
290 case 1: 290 case 0:
291 return; 291 doMsg=false;
292 break; 292 break;
293 }; 293 case 1:
294 } 294 return;
295 295 break;
296 QString curFile, item, destFile; 296 };
297 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 297 }
298 item=(*it); 298
299 if(item.find("->",0,TRUE)) //symlink 299 QString curFile, item, destFile;
300 item = item.left(item.find("->",0,TRUE)); 300 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
301 301 item=(*it);
302 curFile = thisDir->canonicalPath()+"/"+ item; 302 if(item.find("->",0,TRUE)) //symlink
303 destFile = thatDir->canonicalPath()+"/"+ item; 303 item = item.left(item.find("->",0,TRUE));
304 304
305// qDebug("Destination file is "+destFile); 305 curFile = thisDir->canonicalPath()+"/"+ item;
306// qDebug("CurrentFile file is " + curFile); 306 destFile = thatDir->canonicalPath()+"/"+ item;
307 307
308 QFile f(destFile); 308// odebug << "Destination file is "+destFile << oendl;
309 if( f.exists()) { 309// odebug << "CurrentFile file is " + curFile << oendl;
310 if(doMsg) { 310
311 switch ( QMessageBox::warning(this,tr("File Exists!"), 311 QFile f(destFile);
312 tr("%1 exists. Ok to overwrite?").arg( item ), 312 if( f.exists()) {
313 tr("Yes"),tr("No"),0,0,1) ) { 313 if(doMsg) {
314 case 1: 314 switch ( QMessageBox::warning(this,tr("File Exists!"),
315 return; 315 tr("%1 exists. Ok to overwrite?").arg( item ),
316 break; 316 tr("Yes"),tr("No"),0,0,1) ) {
317 }; 317 case 1:
318 } 318 return;
319 f.remove(); 319 break;
320 } 320 };
321 321 }
322 if( !copyFile( curFile, destFile) ) { 322 f.remove();
323 QMessageBox::message("AdvancedFm", 323 }
324 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 324
325 return; 325 if( !copyFile( curFile, destFile) ) {
326 } 326 QMessageBox::message("AdvancedFm",
327 } 327 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
328 setOtherTabCurrent(); 328 return;
329 rePopulate(); 329 }
330 } 330 }
331} 331 setOtherTabCurrent();
332 332 rePopulate();
333void AdvancedFm::copyAs() { 333 }
334 qApp->processEvents(); 334}
335 335
336 QStringList curFileList = getPath(); 336void AdvancedFm::copyAs() {
337 QString curFile, item; 337 qApp->processEvents();
338 InputDialog *fileDlg; 338
339 339 QStringList curFileList = getPath();
340 QDir *thisDir = CurrentDir(); 340 QString curFile, item;
341 QDir *thatDir = OtherDir(); 341 InputDialog *fileDlg;
342 342
343 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 343 QDir *thisDir = CurrentDir();
344 QString destFile; 344 QDir *thatDir = OtherDir();
345 item=(*it); 345
346 curFile = thisDir->canonicalPath()+"/"+(*it); 346 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
347 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 347 QString destFile;
348 348 item=(*it);
349 fileDlg->setInputText((const QString &) destFile ); 349 curFile = thisDir->canonicalPath()+"/"+(*it);
350 fileDlg->exec(); 350 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
351 351
352 if( fileDlg->result() == 1 ) { 352 fileDlg->setInputText((const QString &) destFile );
353 QString filename = fileDlg->LineEdit1->text(); 353 fileDlg->exec();
354 destFile = thatDir->canonicalPath()+"/"+filename; 354
355 355 if( fileDlg->result() == 1 ) {
356 QFile f( destFile); 356 QString filename = fileDlg->LineEdit1->text();
357 if( f.exists()) { 357 destFile = thatDir->canonicalPath()+"/"+filename;
358 switch (QMessageBox::warning(this,tr("File Exists!"), 358
359 item+tr("\nexists. Ok to overwrite?"), 359 QFile f( destFile);
360 tr("Yes"),tr("No"),0,0,1) ) { 360 if( f.exists()) {
361 case 0: 361 switch (QMessageBox::warning(this,tr("File Exists!"),
362 f.remove(); 362 item+tr("\nexists. Ok to overwrite?"),
363 break; 363 tr("Yes"),tr("No"),0,0,1) ) {
364 case 1: 364 case 0:
365 return; 365 f.remove();
366 break; 366 break;
367 }; 367 case 1:
368 } 368 return;
369 if( !copyFile( curFile, destFile) ) { 369 break;
370 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 370 };
371 +curFile +tr("to\n")+destFile); 371 }
372 return; 372 if( !copyFile( curFile, destFile) ) {
373 } 373 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
374 } 374 +curFile +tr("to\n")+destFile);
375 delete fileDlg; 375 return;
376 376 }
377 } 377 }
378 rePopulate(); 378 delete fileDlg;
379 setOtherTabCurrent(); 379
380} 380 }
381 381 rePopulate();
382void AdvancedFm::copySameDir() { 382 setOtherTabCurrent();
383 qApp->processEvents(); 383}
384 QStringList curFileList = getPath(); 384
385 QString curFile, item, destFile; 385void AdvancedFm::copySameDir() {
386 InputDialog *fileDlg; 386 qApp->processEvents();
387 387 QStringList curFileList = getPath();
388 QDir *thisDir = CurrentDir(); 388 QString curFile, item, destFile;
389 389 InputDialog *fileDlg;
390 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 390
391 item=(*it); 391 QDir *thisDir = CurrentDir();
392 curFile = thisDir->canonicalPath()+"/"+ item; 392
393 393 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
394 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 394 item=(*it);
395 fileDlg->setInputText((const QString &) destFile ); 395 curFile = thisDir->canonicalPath()+"/"+ item;
396 fileDlg->exec(); 396
397 397 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
398 if( fileDlg->result() == 1 ) { 398 fileDlg->setInputText((const QString &) destFile );
399 399 fileDlg->exec();
400 QString filename = fileDlg->LineEdit1->text(); 400
401 destFile = thisDir->canonicalPath()+"/"+filename; 401 if( fileDlg->result() == 1 ) {
402 402
403 QFile f(destFile); 403 QString filename = fileDlg->LineEdit1->text();
404 if( f.exists()) { 404 destFile = thisDir->canonicalPath()+"/"+filename;
405 switch (QMessageBox::warning(this,tr("Delete"), 405
406 destFile+tr(" already exists.\nDo you really want to delete it?"), 406 QFile f(destFile);
407 tr("Yes"),tr("No"),0,0,1) ) { 407 if( f.exists()) {
408 case 0: 408 switch (QMessageBox::warning(this,tr("Delete"),
409 409 destFile+tr(" already exists.\nDo you really want to delete it?"),
410 f.remove(); 410 tr("Yes"),tr("No"),0,0,1) ) {
411 break; 411 case 0:
412 case 1: 412
413 return; 413 f.remove();
414 break; 414 break;
415 }; 415 case 1:
416 } 416 return;
417 if(!copyFile( curFile,destFile) ) { 417 break;
418 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 418 };
419 +curFile +tr("to\n")+destFile); 419 }
420 return; 420 if(!copyFile( curFile,destFile) ) {
421 } 421 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
422 422 +curFile +tr("to\n")+destFile);
423// qDebug("copy "+curFile+" as "+destFile); 423 return;
424 } 424 }
425 delete fileDlg; 425
426 } 426// odebug << "copy "+curFile+" as "+destFile << oendl;
427 rePopulate(); 427 }
428} 428 delete fileDlg;
429 429 }
430void AdvancedFm::move() { 430 rePopulate();
431 qApp->processEvents(); 431}
432 432
433 QStringList curFileList = getPath(); 433void AdvancedFm::move() {
434 if( curFileList.count() > 0) { 434 qApp->processEvents();
435 QString curFile, destFile, item; 435
436 436 QStringList curFileList = getPath();
437 QDir *thisDir = CurrentDir(); 437 if( curFileList.count() > 0) {
438 QDir *thatDir = OtherDir(); 438 QString curFile, destFile, item;
439 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 439
440 item=(*it); 440 QDir *thisDir = CurrentDir();
441 QString destFile = thatDir->canonicalPath(); 441 QDir *thatDir = OtherDir();
442 442 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
443 if(destFile.right(1).find("/",0,TRUE) == -1) 443 item=(*it);
444 destFile+="/"; 444 QString destFile = thatDir->canonicalPath();
445 destFile += item; 445
446// qDebug("Destination file is "+destFile); 446 if(destFile.right(1).find("/",0,TRUE) == -1)
447 447 destFile+="/";
448 curFile = thisDir->canonicalPath(); 448 destFile += item;
449 if(curFile.right(1).find("/",0,TRUE) == -1) 449// odebug << "Destination file is "+destFile << oendl;
450 curFile +="/"; 450
451 curFile+= item; 451 curFile = thisDir->canonicalPath();
452// qDebug("CurrentFile file is " + curFile); 452 if(curFile.right(1).find("/",0,TRUE) == -1)
453 453 curFile +="/";
454 if(QFileInfo(curFile).isDir()) { 454 curFile+= item;
455 moveDirectory( curFile, destFile ); 455// odebug << "CurrentFile file is " + curFile << oendl;
456 rePopulate(); 456
457 return; 457 if(QFileInfo(curFile).isDir()) {
458 } 458 moveDirectory( curFile, destFile );
459 459 rePopulate();
460 QFile f( curFile); 460 return;
461 if( f.exists()) { 461 }
462 if( !copyFile( curFile, destFile) ) { 462
463 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 463 QFile f( curFile);
464 return; 464 if( f.exists()) {
465 } else 465 if( !copyFile( curFile, destFile) ) {
466 QFile::remove(curFile); 466 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
467 } 467 return;
468 } 468 } else
469 469 QFile::remove(curFile);
470 } 470 }
471 rePopulate(); 471 }
472 setOtherTabCurrent(); 472
473} 473 }
474 474 rePopulate();
475bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 475 setOtherTabCurrent();
476 int err = 0; 476}
477 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; 477
478 err = system((const char*)cmd); 478bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
479 } else 479 int err = 0;
480 err = -1; 480 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
481 481 err = system((const char*)cmd);
482 if(err!=0) { 482 } else
483 QMessageBox::message(tr("Note"),tr("Could not move\n") + src); 483 err = -1;
484 return false; 484
485 } 485 if(err!=0) {
486 return true; 486 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
487} 487 return false;
488 488 }
489bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 489 return true;
490 490}
491 QString cmd = "/bin/cp -fpR " + src + " " + dest; 491
492 qWarning(cmd); 492bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
493 int err = system( (const char *) cmd ); 493
494 if ( err != 0 ) { 494 QString cmd = "/bin/cp -fpR " + src + " " + dest;
495 QMessageBox::message("AdvancedFm", 495 owarn << cmd << oendl;
496 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); 496 int err = system( (const char *) cmd );
497 return false; 497 if ( err != 0 ) {
498 } 498 QMessageBox::message("AdvancedFm",
499 499 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
500 return true; 500 return false;
501} 501 }
502 502
503 503 return true;
504bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 504}
505 505
506 506
507 if(QFileInfo(src).isDir()) { 507bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
508 if( copyDirectory( src, dest )) { 508
509 setOtherTabCurrent(); 509
510 populateView(); 510 if(QFileInfo(src).isDir()) {
511 return true; 511 if( copyDirectory( src, dest )) {
512 } 512 setOtherTabCurrent();
513 else 513 populateView();
514 return false; 514 return true;
515 } 515 }
516 516 else
517 517 return false;
518 bool success = true; 518 }
519 struct stat status; 519
520 QFile srcFile(src); 520
521 QFile destFile(dest); 521 bool success = true;
522 int err=0; 522 struct stat status;
523 int read_fd=0; 523 QFile srcFile(src);
524 int write_fd=0; 524 QFile destFile(dest);
525 struct stat stat_buf; 525 int err=0;
526 off_t offset = 0; 526 int read_fd=0;
527 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 527 int write_fd=0;
528// qWarning("open failed"); 528 struct stat stat_buf;
529 return success = false; 529 off_t offset = 0;
530 } 530 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
531 read_fd = srcFile.handle(); 531// owarn << "open failed" << oendl;
532 if(read_fd != -1) { 532 return success = false;
533 fstat (read_fd, &stat_buf); 533 }
534 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 534 read_fd = srcFile.handle();
535// qWarning("destfile open failed"); 535 if(read_fd != -1) {
536 return success = false; 536 fstat (read_fd, &stat_buf);
537 } 537 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
538 write_fd = destFile.handle(); 538// owarn << "destfile open failed" << oendl;
539 if(write_fd != -1) { 539 return success = false;
540 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 540 }
541 if( err == -1) { 541 write_fd = destFile.handle();
542 QString msg; 542 if(write_fd != -1) {
543 switch(err) { 543 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
544 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 544 if( err == -1) {
545 case EINVAL: msg = "Descriptor is not valid or locked. "; 545 QString msg;
546 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 546 switch(err) {
547 case EIO: msg = "Unspecified error while reading from in_fd."; 547 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
548 }; 548 case EINVAL: msg = "Descriptor is not valid or locked. ";
549 success = false; 549 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
550// qWarning(msg); 550 case EIO: msg = "Unspecified error while reading from in_fd.";
551 } 551 };
552 } else { 552 success = false;
553 success = false; 553// owarn << msg << oendl;
554 } 554 }
555 } else { 555 } else {
556 success = false; 556 success = false;
557 } 557 }
558 srcFile.close(); 558 } else {
559 destFile.close(); 559 success = false;
560 // Set file permissions 560 }
561 if( stat( (const char *) src, &status ) == 0 ) { 561 srcFile.close();
562 chmod( (const char *) dest, status.st_mode ); 562 destFile.close();
563 } 563 // Set file permissions
564 564 if( stat( (const char *) src, &status ) == 0 ) {
565 return success; 565 chmod( (const char *) dest, status.st_mode );
566} 566 }
567 567
568void AdvancedFm::runCommand() { 568 return success;
569 if( !CurrentView()->currentItem()) return; 569}
570 QDir *thisDir = CurrentDir(); 570
571 571void AdvancedFm::runCommand() {
572 QString curFile; 572 if( !CurrentView()->currentItem()) return;
573 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 573 QDir *thisDir = CurrentDir();
574 574
575 InputDialog *fileDlg; 575 QString curFile;
576 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 576 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
577 fileDlg->setInputText(curFile); 577
578 fileDlg->exec(); 578 InputDialog *fileDlg;
579 //QString command; 579 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
580 580 fileDlg->setInputText(curFile);
581 if( fileDlg->result() == 1 ) { 581 fileDlg->exec();
582// qDebug(fileDlg->LineEdit1->text()); 582 //QString command;
583 QStringList command; 583
584 584 if( fileDlg->result() == 1 ) {
585 command << "/bin/sh"; 585// odebug << fileDlg->LineEdit1->text() << oendl;
586 command << "-c"; 586 QStringList command;
587 command << fileDlg->LineEdit1->text(); 587
588 Output *outDlg; 588 command << "/bin/sh";
589 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 589 command << "-c";
590 QPEApplication::execDialog( outDlg ); 590 command << fileDlg->LineEdit1->text();
591 qApp->processEvents(); 591 Output *outDlg;
592 592 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
593 } 593 QPEApplication::execDialog( outDlg );
594} 594 qApp->processEvents();
595 595
596void AdvancedFm::runCommandStd() { 596 }
597 if( !CurrentView()->currentItem()) return; 597}
598 QString curFile; 598
599 QDir *thisDir = CurrentDir(); 599void AdvancedFm::runCommandStd() {
600 QListView *thisView = CurrentView(); 600 if( !CurrentView()->currentItem()) return;
601 if( thisView->currentItem()) 601 QString curFile;
602 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 602 QDir *thisDir = CurrentDir();
603 603 QListView *thisView = CurrentView();
604 InputDialog *fileDlg; 604 if( thisView->currentItem())
605 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 605 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
606 fileDlg->setInputText(curFile); 606
607 fileDlg->exec(); 607 InputDialog *fileDlg;
608 608 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
609 if( fileDlg->result() == 1 ) { 609 fileDlg->setInputText(curFile);
610 qApp->processEvents(); 610 fileDlg->exec();
611 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 611
612 } 612 if( fileDlg->result() == 1 ) {
613} 613 qApp->processEvents();
614 614 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
615void AdvancedFm::fileStatus() { 615 }
616 if( !CurrentView()->currentItem()) return; 616}
617 QString curFile; 617
618 curFile = CurrentView()->currentItem()->text(0); 618void AdvancedFm::fileStatus() {
619 619 if( !CurrentView()->currentItem()) return;
620 QStringList command; 620 QString curFile;
621 command << "/bin/sh"; 621 curFile = CurrentView()->currentItem()->text(0);
622 command << "-c"; 622
623 command << "stat -l "+ curFile; 623 QStringList command;
624 624 command << "/bin/sh";
625 Output *outDlg; 625 command << "-c";
626 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 626 command << "stat -l "+ curFile;
627 QPEApplication::execDialog( outDlg ); 627
628 qApp->processEvents(); 628 Output *outDlg;
629} 629 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
630 630 QPEApplication::execDialog( outDlg );
631 631 qApp->processEvents();
632void AdvancedFm::mkDir() { 632}
633 makeDir(); 633
634} 634
635 635void AdvancedFm::mkDir() {
636void AdvancedFm::rn() { 636 makeDir();
637 renameIt(); 637}
638} 638
639 639void AdvancedFm::rn() {
640void AdvancedFm::del() { 640 renameIt();
641 doDelete(); 641}
642} 642
643 643void AdvancedFm::del() {
644void AdvancedFm::mkSym() { 644 doDelete();
645 QString cmd; 645}
646 QStringList curFileList = getPath(); 646
647 if( curFileList.count() > 0) { 647void AdvancedFm::mkSym() {
648 QDir *thisDir = CurrentDir(); 648 QString cmd;
649 QDir * thatDir = OtherDir(); 649 QStringList curFileList = getPath();
650 650 if( curFileList.count() > 0) {
651 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 651 QDir *thisDir = CurrentDir();
652 652 QDir * thatDir = OtherDir();
653 QString destName = thatDir->canonicalPath()+"/"+(*it); 653
654 if(destName.right(1) == "/") { 654 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
655 destName = destName.left( destName.length() -1); 655
656 } 656 QString destName = thatDir->canonicalPath()+"/"+(*it);
657 657 if(destName.right(1) == "/") {
658 QString curFile = thisDir->canonicalPath()+"/"+(*it); 658 destName = destName.left( destName.length() -1);
659 659 }
660 if( curFile.right(1) == "/") { 660
661 curFile = curFile.left( curFile.length() -1); 661 QString curFile = thisDir->canonicalPath()+"/"+(*it);
662 } 662
663 663 if( curFile.right(1) == "/") {
664 cmd = "ln -s "+curFile+" "+destName; 664 curFile = curFile.left( curFile.length() -1);
665// qDebug(cmd); 665 }
666 startProcess( (const QString)cmd ); 666
667 } 667 cmd = "ln -s "+curFile+" "+destName;
668 rePopulate(); 668// odebug << cmd << oendl;
669 setOtherTabCurrent(); 669 startProcess( (const QString)cmd );
670 } 670 }
671} 671 rePopulate();
672 672 setOtherTabCurrent();
673void AdvancedFm::doBeam() { 673 }
674 Ir ir; 674}
675 if(!ir.supported()) { 675
676 } else { 676void AdvancedFm::doBeam() {
677 QStringList curFileList = getPath(); 677 Ir ir;
678 if( curFileList.count() > 0) { 678 if(!ir.supported()) {
679 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 679 } else {
680 QString curFile = (*it); 680 QStringList curFileList = getPath();
681 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 681 if( curFileList.count() > 0) {
682 if( curFilePath.right(1) == "/") { 682 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
683 curFilePath = curFilePath.left( curFilePath.length() -1); 683 QString curFile = (*it);
684 } 684 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
685 Ir *file = new Ir(this, "IR"); 685 if( curFilePath.right(1) == "/") {
686 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); 686 curFilePath = curFilePath.left( curFilePath.length() -1);
687 file->send( curFilePath, curFile ); 687 }
688 } 688 Ir *file = new Ir(this, "IR");
689 } 689 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
690 } 690 file->send( curFilePath, curFile );
691} 691 }
692 692 }
693void AdvancedFm::fileBeamFinished( Ir *) { 693 }
694 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 694}
695} 695
696 696void AdvancedFm::fileBeamFinished( Ir *) {
697void AdvancedFm::selectAll() { 697 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
698 QListView *thisView = CurrentView(); 698}
699 thisView->selectAll(true); 699
700 thisView->setSelected( thisView->firstChild(),false); 700void AdvancedFm::selectAll() {
701} 701 QListView *thisView = CurrentView();
702 702 thisView->selectAll(true);
703void AdvancedFm::startProcess(const QString & cmd) { 703 thisView->setSelected( thisView->firstChild(),false);
704 QStringList command; 704}
705 OProcess *process; 705
706 process = new OProcess(); 706void AdvancedFm::startProcess(const QString & cmd) {
707 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), 707 QStringList command;
708 this, SLOT( processEnded(Opie::Core::OProcess*))); 708 OProcess *process;
709 709 process = new OProcess();
710 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), 710 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
711 this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); 711 this, SLOT( processEnded(Opie::Core::OProcess*)));
712 712
713 command << "/bin/sh"; 713 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
714 command << "-c"; 714 this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
715 command << cmd.latin1(); 715
716 *process << command; 716 command << "/bin/sh";
717 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 717 command << "-c";
718 qDebug("could not start process"); 718 command << cmd.latin1();
719} 719 *process << command;
720 720 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
721void AdvancedFm::processEnded(OProcess *) { 721 odebug << "could not start process" << oendl;
722 rePopulate(); 722}
723} 723
724 724void AdvancedFm::processEnded(OProcess *) {
725void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 725 rePopulate();
726// qWarning("received stderrt %d bytes", buflen); 726}
727 727
728 QString lineStr = buffer; 728void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
729 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 729// owarn << "received stderrt " << buflen << " bytes" << oendl;
730} 730
731 731 QString lineStr = buffer;
732bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 732 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
733 if ( o->inherits( "QLineEdit" ) ) { 733}
734 if ( e->type() == QEvent::KeyPress ) { 734
735 QKeyEvent *ke = (QKeyEvent*)e; 735bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
736 if ( ke->key() == Key_Return || 736 if ( o->inherits( "QLineEdit" ) ) {
737 ke->key() == Key_Enter ) { 737 if ( e->type() == QEvent::KeyPress ) {
738 okRename(); 738 QKeyEvent *ke = (QKeyEvent*)e;
739 return true; 739 if ( ke->key() == Key_Return ||
740 } 740 ke->key() == Key_Enter ) {
741 else if ( ke->key() == Key_Escape ) { 741 okRename();
742 cancelRename(); 742 return true;
743 return true; 743 }
744 } 744 else if ( ke->key() == Key_Escape ) {
745 } 745 cancelRename();
746 else if ( e->type() == QEvent::FocusOut ) { 746 return true;
747 cancelRename(); 747 }
748 return true; 748 }
749 } 749 else if ( e->type() == QEvent::FocusOut ) {
750 } 750 cancelRename();
751 if ( o->inherits( "QListView" ) ) { 751 return true;
752 if ( e->type() == QEvent::FocusIn ) { 752 }
753 if( o == Local_View) { //keep track of which view 753 }
754 whichTab=1; 754 if ( o->inherits( "QListView" ) ) {
755 } 755 if ( e->type() == QEvent::FocusIn ) {
756 else { 756 if( o == Local_View) { //keep track of which view
757 whichTab=2; 757 whichTab=1;
758 } 758 }
759 } 759 else {
760 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 760 whichTab=2;
761 } 761 }
762 762 }
763 return QWidget::eventFilter( o, e ); 763 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
764} 764 }
765 765
766 766 return QWidget::eventFilter( o, e );
767void AdvancedFm::cancelRename() { 767}
768// qDebug("cancel rename"); 768
769 QListView * view; 769
770 view = CurrentView(); 770void AdvancedFm::cancelRename() {
771 771// odebug << "cancel rename" << oendl;
772 bool resetFocus = view->viewport()->focusProxy() == renameBox; 772 QListView * view;
773 delete renameBox; 773 view = CurrentView();
774 renameBox = 0; 774
775 if ( resetFocus ) { 775 bool resetFocus = view->viewport()->focusProxy() == renameBox;
776 view->viewport()->setFocusProxy( view); 776 delete renameBox;
777 view->setFocus(); 777 renameBox = 0;
778 } 778 if ( resetFocus ) {
779} 779 view->viewport()->setFocusProxy( view);
780 780 view->setFocus();
781void AdvancedFm::doRename(QListView * view) { 781 }
782 if( !CurrentView()->currentItem()) return; 782}
783 783
784 QRect r = view->itemRect( view->currentItem( )); 784void AdvancedFm::doRename(QListView * view) {
785 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 785 if( !CurrentView()->currentItem()) return;
786 r.setX( view->contentsX() ); 786
787 787 QRect r = view->itemRect( view->currentItem( ));
788 if ( r.width() > view->visibleWidth() ) 788 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
789 r.setWidth( view->visibleWidth() ); 789 r.setX( view->contentsX() );
790 790
791 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 791 if ( r.width() > view->visibleWidth() )
792 renameBox->setFrame(true); 792 r.setWidth( view->visibleWidth() );
793 793
794 renameBox->setText( view->currentItem()->text(0) ); 794 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
795 795 renameBox->setFrame(true);
796 renameBox->selectAll(); 796
797 renameBox->installEventFilter( this ); 797 renameBox->setText( view->currentItem()->text(0) );
798 798
799 view->addChild( renameBox, r.x(), r.y() ); 799 renameBox->selectAll();
800 800 renameBox->installEventFilter( this );
801 renameBox->resize( r.size() ); 801
802 802 view->addChild( renameBox, r.x(), r.y() );
803 view->viewport()->setFocusProxy( renameBox ); 803
804 804 renameBox->resize( r.size() );
805 renameBox->setFocus(); 805
806 renameBox->show(); 806 view->viewport()->setFocusProxy( renameBox );
807} 807
808 808 renameBox->setFocus();
809 809 renameBox->show();
810void AdvancedFm::renameIt() { 810}
811 if( !CurrentView()->currentItem()) return; 811
812 812
813 QListView *thisView = CurrentView(); 813void AdvancedFm::renameIt() {
814 oldName = thisView->currentItem()->text(0); 814 if( !CurrentView()->currentItem()) return;
815 doRename( thisView ); 815
816} 816 QListView *thisView = CurrentView();
817 817 oldName = thisView->currentItem()->text(0);
818void AdvancedFm::okRename() { 818 doRename( thisView );
819 if( !renameBox) return; 819}
820 820
821 QString newName = renameBox->text(); 821void AdvancedFm::okRename() {
822 cancelRename(); 822 if( !renameBox) return;
823 QListView * view = CurrentView(); 823
824 QString path = CurrentDir()->canonicalPath() + "/"; 824 QString newName = renameBox->text();
825 oldName = path + oldName; 825 cancelRename();
826 newName = path + newName; 826 QListView * view = CurrentView();
827 if( rename( oldName.latin1(), newName.latin1())== -1) 827 QString path = CurrentDir()->canonicalPath() + "/";
828 QMessageBox::message(tr("Note"),tr("Could not rename")); 828 oldName = path + oldName;
829 else 829 newName = path + newName;
830 oldName = ""; 830 if( rename( oldName.latin1(), newName.latin1())== -1)
831 QListViewItem *item = view->currentItem(); 831 QMessageBox::message(tr("Note"),tr("Could not rename"));
832 view->takeItem( item ); 832 else
833 delete item; 833 oldName = "";
834 rePopulate(); 834 QListViewItem *item = view->currentItem();
835} 835 view->takeItem( item );
836 836 delete item;
837void AdvancedFm::openSearch() { 837 rePopulate();
838 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 838}
839} 839
840void AdvancedFm::openSearch() {
841 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
842}
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp
index 9698de7..b7d48e8 100644
--- a/noncore/apps/advancedfm/filePermissions.cpp
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -1,83 +1,83 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2002 ljp ljp@llornkcor.com 2** copyright 2002 ljp ljp@llornkcor.com
3** Created: Sat Feb 23 19:44:40 2002 L.J. Potter 3** Created: Sat Feb 23 19:44:40 2002 L.J. Potter
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <qfileinfo.h> 16#include <qfileinfo.h>
17 17
18#include <qcheckbox.h> 18#include <qcheckbox.h>
19#include <qlabel.h> 19#include <qlabel.h>
20#include <qlineedit.h> 20#include <qlineedit.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22 22
23#include <unistd.h> 23#include <unistd.h>
24#include <sys/stat.h> 24#include <sys/stat.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h> 26#include <sys/types.h>
27#include <pwd.h> 27#include <pwd.h>
28#include <grp.h> 28#include <grp.h>
29 29
30filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) 30filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
31 : QDialog( parent, name, modal, fl ) 31 : QDialog( parent, name, modal, fl )
32{ 32{
33 if ( !name ) 33 if ( !name )
34 setName( tr("filePermissions") ); 34 setName( tr("filePermissions") );
35// qDebug("FilePermissions "+fileName); 35// odebug << "FilePermissions "+fileName << oendl;
36/* resize( 236, 210 ); 36/* resize( 236, 210 );
37 setMaximumSize( QSize( 236, 210 ) ); 37 setMaximumSize( QSize( 236, 210 ) );
38*/ setCaption( tr( "Set File Permissions" ) ); 38*/ setCaption( tr( "Set File Permissions" ) );
39 39
40 TextLabel1 = new QLabel( this, "TextLabel1" ); 40 TextLabel1 = new QLabel( this, "TextLabel1" );
41 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); 41 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
42 TextLabel1->setText( tr( "Set file permissions for:" ) ); 42 TextLabel1->setText( tr( "Set file permissions for:" ) );
43 43
44 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 44 LineEdit1 = new QLineEdit( this, "LineEdit1" );
45 LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); 45 LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
46 LineEdit1->setReadOnly(true); 46 LineEdit1->setReadOnly(true);
47 47
48 TextLabel4 = new QLabel( this, "TextLabel4" ); 48 TextLabel4 = new QLabel( this, "TextLabel4" );
49 TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); 49 TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
50 TextLabel4->setText( tr( "owner" ) ); 50 TextLabel4->setText( tr( "owner" ) );
51 51
52 TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); 52 TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
53 TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); 53 TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
54 TextLabel4_2->setText( tr( "group" ) ); 54 TextLabel4_2->setText( tr( "group" ) );
55 55
56 TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); 56 TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
57 TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); 57 TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
58 TextLabel4_3->setText( tr( "others" ) ); 58 TextLabel4_3->setText( tr( "others" ) );
59 59
60 CheckBox1 = new QCheckBox( this, "CheckBox1" ); 60 CheckBox1 = new QCheckBox( this, "CheckBox1" );
61 CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); 61 CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) );
62 connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); 62 connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck()));
63 63
64 CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); 64 CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" );
65 CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); 65 CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) );
66 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); 66 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
67 67
68 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); 68 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
69 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); 69 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
70 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); 70 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
71 71
72 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); 72 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
73 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); 73 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
74 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); 74 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
75 75
76 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); 76 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
77 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); 77 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
78 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); 78 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
79 79
80 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); 80 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
81 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); 81 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
82 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); 82 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
83 83
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 6906298..8c585f4 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,68 +1,71 @@
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/* OPIE */
9#include <opie2/odebug.h>
8#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
9#include <qpe/applnk.h> 11#include <qpe/applnk.h>
12using namespace Opie::Core;
10 13
14/* QT */
11#include <qfile.h> 15#include <qfile.h>
12#include <qmultilineedit.h> 16#include <qmultilineedit.h>
13#include <qpushbutton.h> 17#include <qpushbutton.h>
14#include <qlayout.h> 18#include <qlayout.h>
15 19
20/* STD */
16#include <errno.h> 21#include <errno.h>
17 22
18/* XPM */ 23/* XPM */
19using namespace Opie::Core;
20using namespace Opie::Core;
21static char * filesave_xpm[] = { 24static char * filesave_xpm[] = {
22"16 16 78 1", 25"16 16 78 1",
23" c None", 26" c None",
24". c #343434", 27". c #343434",
25"+ c #A0A0A0", 28"+ c #A0A0A0",
26"@ c #565656", 29"@ c #565656",
27"# c #9E9E9E", 30"# c #9E9E9E",
28"$ c #525252", 31"$ c #525252",
29"% c #929292", 32"% c #929292",
30"& c #676767", 33"& c #676767",
31"* c #848484", 34"* c #848484",
32"= c #666666", 35"= c #666666",
33"- c #D8D8D8", 36"- c #D8D8D8",
34"; c #FFFFFF", 37"; c #FFFFFF",
35"> c #DBDBDB", 38"> c #DBDBDB",
36", c #636363", 39", c #636363",
37"' c #989898", 40"' c #989898",
38") c #2D2D2D", 41") c #2D2D2D",
39"! c #909090", 42"! c #909090",
40"~ c #AEAEAE", 43"~ c #AEAEAE",
41"{ c #EAEAEA", 44"{ c #EAEAEA",
42"] c #575757", 45"] c #575757",
43"^ c #585858", 46"^ c #585858",
44"/ c #8A8A8A", 47"/ c #8A8A8A",
45"( c #828282", 48"( c #828282",
46"_ c #6F6F6F", 49"_ c #6F6F6F",
47": c #C9C9C9", 50": c #C9C9C9",
48"< c #050505", 51"< c #050505",
49"[ c #292929", 52"[ c #292929",
50"} c #777777", 53"} c #777777",
51"| c #616161", 54"| c #616161",
52"1 c #3A3A3A", 55"1 c #3A3A3A",
53"2 c #BEBEBE", 56"2 c #BEBEBE",
54"3 c #2C2C2C", 57"3 c #2C2C2C",
55"4 c #7C7C7C", 58"4 c #7C7C7C",
56"5 c #F6F6F6", 59"5 c #F6F6F6",
57"6 c #FCFCFC", 60"6 c #FCFCFC",
58"7 c #6B6B6B", 61"7 c #6B6B6B",
59"8 c #959595", 62"8 c #959595",
60"9 c #4F4F4F", 63"9 c #4F4F4F",
61"0 c #808080", 64"0 c #808080",
62"a c #767676", 65"a c #767676",
63"b c #818181", 66"b c #818181",
64"c c #B8B8B8", 67"c c #B8B8B8",
65"d c #FBFBFB", 68"d c #FBFBFB",
66"e c #F9F9F9", 69"e c #F9F9F9",
67"f c #CCCCCC", 70"f c #CCCCCC",
68"g c #030303", 71"g c #030303",
@@ -76,203 +79,203 @@ static char * filesave_xpm[] = {
76"o c #333333", 79"o c #333333",
77"p c #7B7B7B", 80"p c #7B7B7B",
78"q c #787878", 81"q c #787878",
79"r c #696969", 82"r c #696969",
80"s c #494949", 83"s c #494949",
81"t c #555555", 84"t c #555555",
82"u c #949494", 85"u c #949494",
83"v c #E6E6E6", 86"v c #E6E6E6",
84"w c #424242", 87"w c #424242",
85"x c #515151", 88"x c #515151",
86"y c #535353", 89"y c #535353",
87"z c #3E3E3E", 90"z c #3E3E3E",
88"A c #D4D4D4", 91"A c #D4D4D4",
89"B c #0C0C0C", 92"B c #0C0C0C",
90"C c #353535", 93"C c #353535",
91"D c #474747", 94"D c #474747",
92"E c #ECECEC", 95"E c #ECECEC",
93"F c #919191", 96"F c #919191",
94"G c #7D7D7D", 97"G c #7D7D7D",
95"H c #000000", 98"H c #000000",
96"I c #404040", 99"I c #404040",
97"J c #858585", 100"J c #858585",
98"K c #323232", 101"K c #323232",
99"L c #D0D0D0", 102"L c #D0D0D0",
100"M c #1C1C1C", 103"M c #1C1C1C",
101" ...+ ", 104" ...+ ",
102" @#$%&..+ ", 105" @#$%&..+ ",
103" .*=-;;>,..+ ", 106" .*=-;;>,..+ ",
104" ')!~;;;;;;{]..", 107" ')!~;;;;;;{]..",
105" ^/(-;;;;;;;_:<", 108" ^/(-;;;;;;;_:<",
106" [}|;;;;;;;{12$", 109" [}|;;;;;;;{12$",
107" #34-55;;;;678$+", 110" #34-55;;;;678$+",
108" 90ab=c;dd;e1fg ", 111" 90ab=c;dd;e1fg ",
109" [ahij((kbl0mn$ ", 112" [ahij((kbl0mn$ ",
110" op^q^^7r&]s/$+ ", 113" op^q^^7r&]s/$+ ",
111"@btu;vbwxy]zAB ", 114"@btu;vbwxy]zAB ",
112"CzDEvEv;;DssF$ ", 115"CzDEvEv;;DssF$ ",
113"G.H{E{E{IxsJ$+ ", 116"G.H{E{E{IxsJ$+ ",
114" +...vEKxzLM ", 117" +...vEKxzLM ",
115" +...z]n$ ", 118" +...z]n$ ",
116" +... "}; 119" +... "};
117 120
118Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 121Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
119 : QDialog( parent, name, modal, fl ) 122 : QDialog( parent, name, modal, fl )
120{ 123{
121 QStringList cmmds; 124 QStringList cmmds;
122// cmmds=QStringList::split( " ", commands, false); 125// cmmds=QStringList::split( " ", commands, false);
123 cmmds=commands; 126 cmmds=commands;
124// qDebug("count %d", cmmds.count()); 127// odebug << "count " << cmmds.count() << "" << oendl;
125 if ( !name ) 128 if ( !name )
126 setName( tr("Output")); 129 setName( tr("Output"));
127 resize( 196, 269 ); 130 resize( 196, 269 );
128 setCaption( name ); 131 setCaption( name );
129 132
130 OutputLayout = new QGridLayout( this ); 133 OutputLayout = new QGridLayout( this );
131 OutputLayout->setSpacing( 2); 134 OutputLayout->setSpacing( 2);
132 OutputLayout->setMargin( 2); 135 OutputLayout->setMargin( 2);
133 136
134 QPushButton *docButton; 137 QPushButton *docButton;
135 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 138 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
136 docButton->setFixedSize( QSize( 20, 20 ) ); 139 docButton->setFixedSize( QSize( 20, 20 ) );
137 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 140 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
138 // docButton->setFlat(TRUE); 141 // docButton->setFlat(TRUE);
139 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 142 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
140 143
141 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 144 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
142 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 145 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
143 146
144 proc = new OProcess(); 147 proc = new OProcess();
145 148
146 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), 149 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
147 this, SLOT( processFinished())); 150 this, SLOT( processFinished()));
148 151
149 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), 152 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
150 this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); 153 this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int)));
151 154
152 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), 155 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
153 this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); 156 this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int)));
154 157
155// connect( , SIGNAL(received(const QByteArray&)), 158// connect( , SIGNAL(received(const QByteArray&)),
156// this, SLOT(commandStdin(const QByteArray&))); 159// this, SLOT(commandStdin(const QByteArray&)));
157 160
158// * proc << commands.latin1(); 161// * proc << commands.latin1();
159 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 162 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
160 qDebug( "%s", (*it).latin1() ); 163 odebug << "" << (*it).latin1() << "" << oendl;
161 * proc << (*it).latin1(); 164 * proc << (*it).latin1();
162 } 165 }
163 166
164 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 167 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
165 168
166 OutputEdit->append(tr("Process could not start") ); 169 OutputEdit->append(tr("Process could not start") );
167 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 170 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
168 perror("Error: "); 171 perror("Error: ");
169 QString errorMsg=tr("Error\n")+(QString)strerror(errno); 172 QString errorMsg=tr("Error\n")+(QString)strerror(errno);
170 OutputEdit->append( errorMsg); 173 OutputEdit->append( errorMsg);
171 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 174 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
172 } 175 }
173} 176}
174 177
175Output::~Output() { 178Output::~Output() {
176} 179}
177 180
178void Output::saveOutput() { 181void Output::saveOutput() {
179 182
180 InputDialog *fileDlg; 183 InputDialog *fileDlg;
181 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 184 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
182 fileDlg->exec(); 185 fileDlg->exec();
183 if( fileDlg->result() == 1 ) { 186 if( fileDlg->result() == 1 ) {
184 QString filename = QPEApplication::documentDir(); 187 QString filename = QPEApplication::documentDir();
185 if(filename.right(1).find('/') == -1) 188 if(filename.right(1).find('/') == -1)
186 filename+="/"; 189 filename+="/";
187 QString name = fileDlg->LineEdit1->text(); 190 QString name = fileDlg->LineEdit1->text();
188 filename+="text/plain/"+name; 191 filename+="text/plain/"+name;
189 qDebug(filename); 192 odebug << filename << oendl;
190 193
191 QFile f(filename); 194 QFile f(filename);
192 f.open( IO_WriteOnly); 195 f.open( IO_WriteOnly);
193 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 196 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
194 DocLnk lnk; 197 DocLnk lnk;
195 lnk.setName(name); //sets file name 198 lnk.setName(name); //sets file name
196 lnk.setFile(filename); //sets File property 199 lnk.setFile(filename); //sets File property
197 lnk.setType("text/plain"); 200 lnk.setType("text/plain");
198 if(!lnk.writeLink()) { 201 if(!lnk.writeLink()) {
199 qDebug("Writing doclink did not work"); 202 odebug << "Writing doclink did not work" << oendl;
200 } 203 }
201 } else 204 } else
202 qWarning("Could not write file"); 205 owarn << "Could not write file" << oendl;
203 f.close(); 206 f.close();
204 } 207 }
205} 208}
206 209
207void Output::commandStdout(OProcess*, char *buffer, int buflen) { 210void Output::commandStdout(OProcess*, char *buffer, int buflen) {
208 qWarning("received stdout %d bytes", buflen); 211 owarn << "received stdout " << buflen << " bytes" << oendl;
209 212
210// QByteArray data(buflen); 213// QByteArray data(buflen);
211// data.fill(*buffer, buflen); 214// data.fill(*buffer, buflen);
212// for (uint i = 0; i < data.count(); i++ ) { 215// for (uint i = 0; i < data.count(); i++ ) {
213// printf("%c", buffer[i] ); 216// printf("%c", buffer[i] );
214// } 217// }
215// printf("\n"); 218// printf("\n");
216 219
217 QString lineStr = buffer; 220 QString lineStr = buffer;
218 lineStr=lineStr.left(lineStr.length()-1); 221 lineStr=lineStr.left(lineStr.length()-1);
219 OutputEdit->append(lineStr); 222 OutputEdit->append(lineStr);
220 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 223 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
221} 224}
222 225
223 226
224void Output::commandStdin( const QByteArray &data) { 227void Output::commandStdin( const QByteArray &data) {
225 qWarning("received stdin %d bytes", data.size()); 228 owarn << "received stdin " << data.size() << " bytes" << oendl;
226 // recieved data from the io layer goes to sz 229 // recieved data from the io layer goes to sz
227 proc->writeStdin(data.data(), data.size()); 230 proc->writeStdin(data.data(), data.size());
228} 231}
229 232
230void Output::commandStderr(OProcess*, char *buffer, int buflen) { 233void Output::commandStderr(OProcess*, char *buffer, int buflen) {
231 qWarning("received stderrt %d bytes", buflen); 234 owarn << "received stderrt " << buflen << " bytes" << oendl;
232 235
233 QString lineStr = buffer; 236 QString lineStr = buffer;
234// lineStr=lineStr.left(lineStr.length()-1); 237// lineStr=lineStr.left(lineStr.length()-1);
235 OutputEdit->append(lineStr); 238 OutputEdit->append(lineStr);
236 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 239 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
237} 240}
238 241
239void Output::processFinished() { 242void Output::processFinished() {
240 243
241 delete proc; 244 delete proc;
242 OutputEdit->append( tr("\nFinished\n") ); 245 OutputEdit->append( tr("\nFinished\n") );
243 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 246 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
244// close(); 247// close();
245// disconnect( layer(), SIGNAL(received(const QByteArray&)), 248// disconnect( layer(), SIGNAL(received(const QByteArray&)),
246// this, SLOT(commandStdin(const QByteArray&))); 249// this, SLOT(commandStdin(const QByteArray&)));
247} 250}
248 251
249//============================== 252//==============================
250 253
251InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 254InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
252 : QDialog( parent, name, modal, fl ) 255 : QDialog( parent, name, modal, fl )
253{ 256{
254 if ( !name ) 257 if ( !name )
255 setName( "InputDialog" ); 258 setName( "InputDialog" );
256 resize( 234, 50 ); 259 resize( 234, 50 );
257 setMaximumSize( QSize( 240, 50 ) ); 260 setMaximumSize( QSize( 240, 50 ) );
258 setCaption( tr(name ) ); 261 setCaption( tr(name ) );
259 262
260 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 263 LineEdit1 = new QLineEdit( this, "LineEdit1" );
261 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 264 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
262 LineEdit1->setFocus(); 265 LineEdit1->setFocus();
263 LineEdit1->setFocus(); 266 LineEdit1->setFocus();
264 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 267 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
265} 268}
266 269
267InputDialog::~InputDialog() { 270InputDialog::~InputDialog() {
268 inputText = LineEdit1->text(); 271 inputText = LineEdit1->text();
269} 272}
270 273
271void InputDialog::setInputText(const QString &string) { 274void InputDialog::setInputText(const QString &string) {
272 LineEdit1->setText( string); 275 LineEdit1->setText( string);
273} 276}
274 277
275void InputDialog::returned() { 278void InputDialog::returned() {
276 inputText = LineEdit1->text(); 279 inputText = LineEdit1->text();
277 this->accept(); 280 this->accept();
278} 281}
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index 34641f4..1472df6 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,32 +1,32 @@
1CONFIG = qt warn_on quick-app 1CONFIG = qt warn_on quick-app
2HEADERS = mainwindow.h \ 2HEADERS = mainwindow.h \
3 cbinfo.h \ 3 cbinfo.h \
4 traninfo.h \ 4 traninfo.h \
5 graphinfo.h \ 5 graphinfo.h \
6 configuration.h \ 6 configuration.h \
7 password.h \ 7 password.h \
8 checkbook.h \ 8 checkbook.h \
9 transaction.h \ 9 transaction.h \
10 tabledef.h \ 10 tabledef.h \
11 listedit.h \ 11 listedit.h \
12 cfg.h \ 12 cfg.h \
13 graph.h 13 graph.h
14SOURCES = main.cpp \ 14SOURCES = main.cpp \
15 mainwindow.cpp \ 15 mainwindow.cpp \
16 cbinfo.cpp \ 16 cbinfo.cpp \
17 traninfo.cpp \ 17 traninfo.cpp \
18 graphinfo.cpp \ 18 graphinfo.cpp \
19 configuration.cpp \ 19 configuration.cpp \
20 password.cpp \ 20 password.cpp \
21 checkbook.cpp \ 21 checkbook.cpp \
22 transaction.cpp \ 22 transaction.cpp \
23 tabledef.cpp \ 23 tabledef.cpp \
24 listedit.cpp \ 24 listedit.cpp \
25 cfg.cpp \ 25 cfg.cpp \
26 graph.cpp 26 graph.cpp
27INCLUDEPATH += $(OPIEDIR)/include 27INCLUDEPATH += $(OPIEDIR)/include
28DEPENDPATH += $(OPIEDIR)/include 28DEPENDPATH += $(OPIEDIR)/include
29LIBS += -lqpe -lopiecore2 -lopieui2 29LIBS += -lqpe -lopiecore2 -lopieui2
30TARGET = checkbook 30TARGET = checkbook
31 31
32include ( $(OPIEDIR)/include.pro ) 32include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp
index d00e305..5026c9d 100644
--- a/noncore/apps/checkbook/listedit.cpp
+++ b/noncore/apps/checkbook/listedit.cpp
@@ -1,85 +1,90 @@
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 "listedit.h" 29#include "listedit.h"
30
31/* OPIE */
32#include <opie2/odebug.h>
33#include <qpe/resource.h>
34using namespace Opie::Core;
35
36/* QT */
30#include <qlayout.h> 37#include <qlayout.h>
31#include <qlineedit.h> 38#include <qlineedit.h>
32#include <qlistview.h> 39#include <qlistview.h>
33#include <qwidgetstack.h> 40#include <qwidgetstack.h>
34#include <qcombobox.h> 41#include <qcombobox.h>
35#include <qpushbutton.h> 42#include <qpushbutton.h>
36#include <qpe/resource.h>
37
38 43
39// --- ListEdit --------------------------------------------------------------- 44// --- ListEdit ---------------------------------------------------------------
40ListEdit::ListEdit( QWidget *parent, const char *sName ) 45ListEdit::ListEdit( QWidget *parent, const char *sName )
41 : QWidget(parent, sName), TableDef(sName) 46 : QWidget(parent, sName), TableDef(sName)
42{ 47{
43 // get font height 48 // get font height
44 int fh = fontMetrics().height(); 49 int fh = fontMetrics().height();
45 50
46 // create layout 51 // create layout
47 QGridLayout *layout=new QGridLayout(this); 52 QGridLayout *layout=new QGridLayout(this);
48 layout->setSpacing( 2 ); 53 layout->setSpacing( 2 );
49 layout->setMargin( 4 ); 54 layout->setMargin( 4 );
50 55
51 // type table 56 // type table
52 _typeTable = new QListView( this ); 57 _typeTable = new QListView( this );
53 ColumnDef *def=first(); 58 ColumnDef *def=first();
54 while( def ) { 59 while( def ) {
55 _typeTable->addColumn( def->getName() ); 60 _typeTable->addColumn( def->getName() );
56 def=next(); 61 def=next();
57 } 62 }
58 connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) ); 63 connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) );
59 layout->addMultiCellWidget(_typeTable, 0,4,0,4); 64 layout->addMultiCellWidget(_typeTable, 0,4,0,4);
60 _currentItem=NULL; 65 _currentItem=NULL;
61 66
62 // edit field 67 // edit field
63 _stack=new QWidgetStack( this ); 68 _stack=new QWidgetStack( this );
64 _stack->setMaximumHeight(fh+5); 69 _stack->setMaximumHeight(fh+5);
65 layout->addMultiCellWidget(_stack, 5,5,0,2); 70 layout->addMultiCellWidget(_stack, 5,5,0,2);
66 _typeEdit = new QLineEdit( _stack ); 71 _typeEdit = new QLineEdit( _stack );
67 _stack->raiseWidget(_typeEdit ); 72 _stack->raiseWidget(_typeEdit );
68 connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) ); 73 connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) );
69 74
70 // combo box 75 // combo box
71 _box=new QComboBox( _stack ); 76 _box=new QComboBox( _stack );
72 connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); 77 connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) );
73 78
74 79
75 // add button 80 // add button
76 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); 81 QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this );
77 connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); 82 connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
78 layout->addWidget( btn, 5, 3 ); 83 layout->addWidget( btn, 5, 3 );
79 84
80 // delete button 85 // delete button
81 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 86 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
82 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); 87 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) );
83 layout->addWidget( btn, 5, 4 ); 88 layout->addWidget( btn, 5, 4 );
84} 89}
85 90
@@ -257,88 +262,88 @@ void ListEdit::storeInList(QStringList &lst)
257 if( i>=1 ) sAdd+=";"; 262 if( i>=1 ) sAdd+=";";
258 sAdd += itm->text(i); 263 sAdd += itm->text(i);
259 } 264 }
260 lst.append( sAdd ); 265 lst.append( sAdd );
261 itm=itm->nextSibling(); 266 itm=itm->nextSibling();
262 } 267 }
263} 268}
264 269
265 270
266// --- slotClicked ------------------------------------------------------------ 271// --- slotClicked ------------------------------------------------------------
267void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) 272void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col)
268{ 273{
269 (void)pnt; // get rid of unused warning; 274 (void)pnt; // get rid of unused warning;
270 275
271 // save values 276 // save values
272 _currentItem=itm; 277 _currentItem=itm;
273 _currentColumn=col; 278 _currentColumn=col;
274 if( itm==NULL ) { 279 if( itm==NULL ) {
275 _typeEdit->setText(""); 280 _typeEdit->setText("");
276 _stack->raiseWidget(_typeEdit); 281 _stack->raiseWidget(_typeEdit);
277 return; 282 return;
278 } 283 }
279 284
280 // display value 285 // display value
281 if( _currentColumn<0 ) _currentColumn=0; 286 if( _currentColumn<0 ) _currentColumn=0;
282 ColumnDef *pDef=this->at(_currentColumn); 287 ColumnDef *pDef=this->at(_currentColumn);
283 if( pDef->isType(ColumnDef::typeString) ) { 288 if( pDef->isType(ColumnDef::typeString) ) {
284 _typeEdit->setText( _currentItem->text(_currentColumn) ); 289 _typeEdit->setText( _currentItem->text(_currentColumn) );
285 _stack->raiseWidget(_typeEdit); 290 _stack->raiseWidget(_typeEdit);
286 } else if( pDef->isType(ColumnDef::typeList) ){ 291 } else if( pDef->isType(ColumnDef::typeList) ){
287 _box->clear(); 292 _box->clear();
288 _box->insertStringList( pDef->getValueList() ); 293 _box->insertStringList( pDef->getValueList() );
289 QStringList::Iterator itr; 294 QStringList::Iterator itr;
290 int i=0; 295 int i=0;
291 for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { 296 for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) {
292 if( (*itr)==_currentItem->text(_currentColumn) ) { 297 if( (*itr)==_currentItem->text(_currentColumn) ) {
293 _box->setCurrentItem(i); 298 _box->setCurrentItem(i);
294 i=-1; 299 i=-1;
295 break; 300 break;
296 } 301 }
297 i++; 302 i++;
298 } 303 }
299 if( i>=0 ) { 304 if( i>=0 ) {
300 _box->insertItem( _currentItem->text(_currentColumn) ); 305 _box->insertItem( _currentItem->text(_currentColumn) );
301 _box->setCurrentItem(i); 306 _box->setCurrentItem(i);
302 } 307 }
303 _stack->raiseWidget(_box); 308 _stack->raiseWidget(_box);
304 } else { 309 } else {
305 qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() ); 310 odebug << "Unsupported column type for column " << (const char *)pDef->getName() << "" << oendl;
306 _typeEdit->setText(""); 311 _typeEdit->setText("");
307 _stack->raiseWidget(_typeEdit); 312 _stack->raiseWidget(_typeEdit);
308 } 313 }
309} 314}
310 315
311 316
312// --- addColumnDef ----------------------------------------------------------- 317// --- addColumnDef -----------------------------------------------------------
313void ListEdit::addColumnDef(ColumnDef *pDef) 318void ListEdit::addColumnDef(ColumnDef *pDef)
314{ 319{
315 _typeTable->addColumn( pDef->getName() ); 320 _typeTable->addColumn( pDef->getName() );
316 _vColumns.append(pDef); 321 _vColumns.append(pDef);
317} 322}
318 323
319// --- addData ---------------------------------------------------------------- 324// --- addData ----------------------------------------------------------------
320void ListEdit::addData(QStringList &lst) 325void ListEdit::addData(QStringList &lst)
321{ 326{
322 // run through list 327 // run through list
323 QStringList::Iterator itr; 328 QStringList::Iterator itr;
324 for(itr=lst.begin(); itr!=lst.end(); itr++) { 329 for(itr=lst.begin(); itr!=lst.end(); itr++) {
325 QStringList split=QStringList::split(";", *itr, true); 330 QStringList split=QStringList::split(";", *itr, true);
326 QStringList::Iterator entry; 331 QStringList::Iterator entry;
327 QString args[8]; 332 QString args[8];
328 int i=0; 333 int i=0;
329 for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { 334 for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) {
330 args[i]= (*entry); 335 args[i]= (*entry);
331 } 336 }
332 while(i<8) { 337 while(i<8) {
333 args[i++]=""; 338 args[i++]="";
334 } 339 }
335 new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); 340 new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
336 } 341 }
337} 342}
338 343
339// --- slotActivated ---------------------------------------------------------- 344// --- slotActivated ----------------------------------------------------------
340void ListEdit::slotActivated(const QString &str) 345void ListEdit::slotActivated(const QString &str)
341{ 346{
342 if( _currentItem==NULL || _currentColumn<0 ) return; 347 if( _currentItem==NULL || _currentColumn<0 ) return;
343 _currentItem->setText(_currentColumn, str); 348 _currentItem->setText(_currentColumn, str);
344} 349}
diff --git a/noncore/apps/checkbook/tabledef.cpp b/noncore/apps/checkbook/tabledef.cpp
index 9a42308..745cd80 100644
--- a/noncore/apps/checkbook/tabledef.cpp
+++ b/noncore/apps/checkbook/tabledef.cpp
@@ -1,74 +1,76 @@
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 "tabledef.h" 29#include "tabledef.h"
30 30
31#include <opie2/odebug.h>
32using namespace Opie::Core;
31 33
32// --- ColumnDef -------------------------------------------------------------- 34// --- ColumnDef --------------------------------------------------------------
33ColumnDef::ColumnDef(const char *sName, ColumnType type, const char *sNewValue) 35ColumnDef::ColumnDef(const char *sName, ColumnType type, const char *sNewValue)
34{ 36{
35 _sName=sName; 37 _sName=sName;
36 _type=type; 38 _type=type;
37 _sNewValue=sNewValue; 39 _sNewValue=sNewValue;
38} 40}
39 41
40 42
41// --- addColumnValue --------------------------------------------------------- 43// --- addColumnValue ---------------------------------------------------------
42void ColumnDef::addColumnValue(const QString &sValue) 44void ColumnDef::addColumnValue(const QString &sValue)
43{ 45{
44 if( (_type & 0x00ffffff) !=typeList ) 46 if( (_type & 0x00ffffff) !=typeList )
45 qDebug("Column %s is not a list", (const char *)_sName); 47 odebug << "Column " << (const char *)_sName << " is not a list" << oendl;
46 else 48 else
47 _valueList.append(sValue); 49 _valueList.append(sValue);
48} 50}
49void ColumnDef::addColumnValue(const char *sValue) 51void ColumnDef::addColumnValue(const char *sValue)
50{ 52{
51 if( (_type & 0x00ffffff)!=typeList ) 53 if( (_type & 0x00ffffff)!=typeList )
52 qDebug("Column %s is not a list", (const char *)_sName); 54 odebug << "Column " << (const char *)_sName << " is not a list" << oendl;
53 else 55 else
54 _valueList.append(sValue); 56 _valueList.append(sValue);
55} 57}
56 58
57// --- TableDef --------------------------------------------------------------- 59// --- TableDef ---------------------------------------------------------------
58TableDef::TableDef(const char *sName) 60TableDef::TableDef(const char *sName)
59{ 61{
60 _sName=sName; 62 _sName=sName;
61 _vColumns.setAutoDelete(TRUE); 63 _vColumns.setAutoDelete(TRUE);
62} 64}
63 65
64 66
65// --- ~TableDef -------------------------------------------------------------- 67// --- ~TableDef --------------------------------------------------------------
66TableDef::~TableDef() 68TableDef::~TableDef()
67{ 69{
68} 70}
69 71
70// --- addColumnDef ----------------------------------------------------------- 72// --- addColumnDef -----------------------------------------------------------
71void TableDef::addColumnDef(ColumnDef *pDef) 73void TableDef::addColumnDef(ColumnDef *pDef)
72{ 74{
73 _vColumns.append(pDef); 75 _vColumns.append(pDef);
74} 76}
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 1b08b24..aafb588 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -1,83 +1,87 @@
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 "transaction.h" 29#include "transaction.h"
30#include "traninfo.h" 30#include "traninfo.h"
31#include "cfg.h" 31#include "cfg.h"
32#include "checkbook.h" 32#include "checkbook.h"
33 33
34/* OPIE */
35#include <opie2/odebug.h>
34#include <qpe/datebookmonth.h> 36#include <qpe/datebookmonth.h>
37using namespace Opie::Core;
35 38
39/* QT */
36#include <qbuttongroup.h> 40#include <qbuttongroup.h>
37#include <qcombobox.h> 41#include <qcombobox.h>
38#include <qlabel.h> 42#include <qlabel.h>
39#include <qlayout.h> 43#include <qlayout.h>
40#include <qlineedit.h> 44#include <qlineedit.h>
41#include <qmultilineedit.h> 45#include <qmultilineedit.h>
42#include <qradiobutton.h> 46#include <qradiobutton.h>
43#include <qwhatsthis.h> 47#include <qwhatsthis.h>
44 48
45Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, 49Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname,
46 TranInfo *info, Cfg *pCfg ) 50 TranInfo *info, Cfg *pCfg )
47 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 51 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
48{ 52{
49 QString tempstr = tr( "Transaction for " ); 53 QString tempstr = tr( "Transaction for " );
50 tempstr.append( acctname ); 54 tempstr.append( acctname );
51 setCaption( tempstr ); 55 setCaption( tempstr );
52 56
53 _bNew=bNew; 57 _bNew=bNew;
54 tran = info; 58 tran = info;
55 _pCfg=pCfg; 59 _pCfg=pCfg;
56 60
57 QVBoxLayout *vb = new QVBoxLayout( this ); 61 QVBoxLayout *vb = new QVBoxLayout( this );
58 62
59 QScrollView *sv = new QScrollView( this ); 63 QScrollView *sv = new QScrollView( this );
60 vb->addWidget( sv, 0, 0 ); 64 vb->addWidget( sv, 0, 0 );
61 sv->setResizePolicy( QScrollView::AutoOneFit ); 65 sv->setResizePolicy( QScrollView::AutoOneFit );
62 sv->setFrameStyle( QFrame::NoFrame ); 66 sv->setFrameStyle( QFrame::NoFrame );
63 67
64 QWidget *container = new QWidget( sv->viewport() ); 68 QWidget *container = new QWidget( sv->viewport() );
65 sv->addChild( container ); 69 sv->addChild( container );
66 70
67 QGridLayout *layout = new QGridLayout( container ); 71 QGridLayout *layout = new QGridLayout( container );
68 layout->setSpacing( 2 ); 72 layout->setSpacing( 2 );
69 layout->setMargin( 4 ); 73 layout->setMargin( 4 );
70 74
71 // Withdrawal/Deposit 75 // Withdrawal/Deposit
72 QButtonGroup *btngrp = new QButtonGroup( container ); 76 QButtonGroup *btngrp = new QButtonGroup( container );
73 btngrp->setColumnLayout(0, Qt::Vertical ); 77 btngrp->setColumnLayout(0, Qt::Vertical );
74 btngrp->layout()->setSpacing( 0 ); 78 btngrp->layout()->setSpacing( 0 );
75 btngrp->layout()->setMargin( 0 ); 79 btngrp->layout()->setMargin( 0 );
76 btngrp->setMaximumWidth( 220 ); 80 btngrp->setMaximumWidth( 220 );
77 QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); 81 QGridLayout *layout2 = new QGridLayout( btngrp->layout() );
78 layout2->setSpacing( 2 ); 82 layout2->setSpacing( 2 );
79 layout2->setMargin( 2 ); 83 layout2->setMargin( 2 );
80 withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); 84 withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp );
81 QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); 85 QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
82 layout2->addWidget( withBtn, 0, 0 ); 86 layout2->addWidget( withBtn, 0, 0 );
83 connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); 87 connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) );
@@ -287,51 +291,51 @@ void Transaction::slotWithdrawalClicked()
287void Transaction::slotDepositClicked() 291void Transaction::slotDepositClicked()
288{ 292{
289 catList->clear(); 293 catList->clear();
290 CategoryList *pCatList=_pCfg->getCategoryList(); 294 CategoryList *pCatList=_pCfg->getCategoryList();
291 for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { 295 for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) {
292 if( pCat->isIncome() ) 296 if( pCat->isIncome() )
293 catList->insertItem( pCat->getName() ); 297 catList->insertItem( pCat->getName() );
294 } 298 }
295 catList->setCurrentItem( 0 ); 299 catList->setCurrentItem( 0 );
296 300
297 typeList->clear(); 301 typeList->clear();
298 typeList->insertItem( tr( "Written Check" ) ); 302 typeList->insertItem( tr( "Written Check" ) );
299 typeList->insertItem( tr( "Automatic Payment" ) ); 303 typeList->insertItem( tr( "Automatic Payment" ) );
300 typeList->insertItem( tr( "Transfer" ) ); 304 typeList->insertItem( tr( "Transfer" ) );
301 typeList->insertItem( tr( "Cash" ) ); 305 typeList->insertItem( tr( "Cash" ) );
302} 306}
303 307
304// --- slotDateChanged -------------------------------------------------------- 308// --- slotDateChanged --------------------------------------------------------
305void Transaction::slotDateChanged( int y, int m, int d ) 309void Transaction::slotDateChanged( int y, int m, int d )
306{ 310{
307 QDate date; 311 QDate date;
308 date.setYMD( y, m, d ); 312 date.setYMD( y, m, d );
309 dateBtn->setText( TimeString::shortDate( date ) ); 313 dateBtn->setText( TimeString::shortDate( date ) );
310} 314}
311 315
312 316
313 317
314// --- slotActivated ---------------------------------------------------------- 318// --- slotActivated ----------------------------------------------------------
315// Search for the most recent transaction with this description/payee and 319// Search for the most recent transaction with this description/payee and
316// fill amount etc here, as long the new flag is set 320// fill amount etc here, as long the new flag is set
317void Transaction::slotActivated(const QString &arg ) 321void Transaction::slotActivated(const QString &arg )
318{ 322{
319 if( !_bNew ) return; 323 if( !_bNew ) return;
320 TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList(); 324 TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList();
321 if( pTl ) { 325 if( pTl ) {
322 TranInfo *pTi=pTl->findMostRecentByDesc( arg ); 326 TranInfo *pTi=pTl->findMostRecentByDesc( arg );
323 if( pTi ) { 327 if( pTi ) {
324 initFromInfo( pTi, true ); 328 initFromInfo( pTi, true );
325 amtEdit->setFocus(); 329 amtEdit->setFocus();
326 amtEdit->setSelection(0, amtEdit->text().length() ); 330 amtEdit->setSelection(0, amtEdit->text().length() );
327 amtEdit->setCursorPosition(0); 331 amtEdit->setCursorPosition(0);
328 } 332 }
329 } 333 }
330} 334}
331 335
332// slotNotNew ----------------------------------------------------------------- 336// slotNotNew -----------------------------------------------------------------
333void Transaction::slotNotNew() 337void Transaction::slotNotNew()
334{ 338{
335 qDebug("Not new"); 339 odebug << "Not new" << oendl;
336 _bNew=false; 340 _bNew=false;
337} 341}
diff --git a/noncore/apps/confedit/confedit.pro b/noncore/apps/confedit/confedit.pro
index 5a71680..785c588 100644
--- a/noncore/apps/confedit/confedit.pro
+++ b/noncore/apps/confedit/confedit.pro
@@ -1,21 +1,9 @@
1CONFIG = qt warn_on quick-app 1CONFIG = qt warn_on quick-app
2HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h 2HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h
3SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp 3SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp
4INCLUDEPATH += $(OPIEDIR)/include 4INCLUDEPATH += $(OPIEDIR)/include
5DEPENDPATH += $(OPIEDIR)/include 5DEPENDPATH += $(OPIEDIR)/include
6INTERFACES = 6LIBS += -lqpe -lopiecore2
7LIBS += -lopiecore2
8TARGET = confedit 7TARGET = confedit
9 8
10!contains( platform, x11 ) { 9include ( $(OPIEDIR)/include.pro )
11
12 include ( $(OPIEDIR)/include.pro )
13 LIBS += -lqpe
14}
15
16contains( platform, x11 ) {
17 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
18}
19
20
21
diff --git a/noncore/apps/confedit/config.in b/noncore/apps/confedit/config.in
index e377307..d7682dc 100644
--- a/noncore/apps/confedit/config.in
+++ b/noncore/apps/confedit/config.in
@@ -1,4 +1,4 @@
1 config CONFEDIT 1 config CONFEDIT
2 boolean "opie-confeditor (generic editor for all Opie settings)" 2 boolean "opie-confedit (generic editor for all Opie settings)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp
index 0c2feeb..33bffe1 100644
--- a/noncore/apps/confedit/listviewconfdir.cpp
+++ b/noncore/apps/confedit/listviewconfdir.cpp
@@ -1,61 +1,65 @@
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 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> 9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10 10
11#include "listviewconfdir.h" 11#include "listviewconfdir.h"
12#include "listviewitemconffile.h"
12 13
13#include <qmessagebox.h> 14/* OPIE */
15#include <opie2/odebug.h>
16using namespace Opie::Core;
14 17
15#include "listviewitemconffile.h" 18/* QT */
19#include <qmessagebox.h>
16 20
17ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name ) 21ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name )
18 : QListView(parent,name), confDir(settingsPath) 22 : QListView(parent,name), confDir(settingsPath)
19{ 23{
20 24
21 setRootIsDecorated( true ); 25 setRootIsDecorated( true );
22 addColumn(tr("Files")); 26 addColumn(tr("Files"));
23 27
24 if (!confDir.isReadable()) 28 if (!confDir.isReadable())
25 QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); 29 QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0);
26 readConfFiles(); 30 readConfFiles();
27 31
28 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 32 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
29} 33}
30 34
31 35
32ListViewConfDir::~ListViewConfDir() 36ListViewConfDir::~ListViewConfDir()
33{ 37{
34} 38}
35 39
36void ListViewConfDir::readConfFiles() 40void ListViewConfDir::readConfFiles()
37{ 41{
38 42
39 confDir.setFilter( QDir::Files | QDir::NoSymLinks ); 43 confDir.setFilter( QDir::Files | QDir::NoSymLinks );
40 confDir.setSorting( QDir::Name ); 44 confDir.setSorting( QDir::Name );
41 confDir.setNameFilter("*.conf"); 45 confDir.setNameFilter("*.conf");
42 const QFileInfoList *list = confDir.entryInfoList(); 46 const QFileInfoList *list = confDir.entryInfoList();
43 QFileInfoListIterator it( *list ); 47 QFileInfoListIterator it( *list );
44 QFileInfo *fi; 48 QFileInfo *fi;
45 49
46 ListViewItemConfFile *fileEntry; 50 ListViewItemConfFile *fileEntry;
47 51
48 while ( (fi=it.current()) ) 52 while ( (fi=it.current()) )
49 { 53 {
50 qDebug( "opening: >%s<", fi->fileName().data() ); 54 odebug << "opening: >" << fi->fileName().data() << "<" << oendl;
51 fileEntry = new ListViewItemConfFile( fi, this ); 55 fileEntry = new ListViewItemConfFile( fi, this );
52 QListViewItem *dummy = new QListViewItem(fileEntry, "dummy"); 56 QListViewItem *dummy = new QListViewItem(fileEntry, "dummy");
53 ++it; 57 ++it;
54 } 58 }
55} 59}
56 60
57void ListViewConfDir::expand(QListViewItem *item) 61void ListViewConfDir::expand(QListViewItem *item)
58{ 62{
59 ((ListViewItemConf*)item)->expand(); 63 ((ListViewItemConf*)item)->expand();
60} 64}
61 65
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
index 1ff2c44..2958cf5 100644
--- a/noncore/apps/confedit/listviewitemconffile.cpp
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -1,127 +1,133 @@
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// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10 10
11#include "listviewitemconffile.h" 11#include "listviewitemconffile.h"
12#include "listviewitemconfigentry.h"
13
14/* OPIE */
15#include <opie2/odebug.h>
16using namespace Opie::Core;
17
18/* QT */
12#include <qmessagebox.h> 19#include <qmessagebox.h>
13#include <qtextstream.h> 20#include <qtextstream.h>
14#include "listviewitemconfigentry.h"
15 21
16#define tr QObject::tr 22#define tr QObject::tr
17 23
18ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) 24ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent)
19 : ListViewItemConf(parent), _valid(false) 25 : ListViewItemConf(parent), _valid(false)
20{ 26{
21 confFileInfo = file; 27 confFileInfo = file;
22// parseFile(); 28 // parseFile();
23 displayText(); 29 displayText();
24} 30}
25 31
26ListViewItemConfFile::~ListViewItemConfFile() 32ListViewItemConfFile::~ListViewItemConfFile()
27{ 33{
28} 34}
29 35
30 36
31void ListViewItemConfFile::displayText() 37void ListViewItemConfFile::displayText()
32{ 38{
33 setText(0,(_changed?"*":"")+confFileInfo->fileName()); 39 setText(0,(_changed?"*":"")+confFileInfo->fileName());
34} 40}
35 41
36QString ListViewItemConfFile::fileName() 42QString ListViewItemConfFile::fileName()
37{ 43{
38 return confFileInfo->fileName(); 44 return confFileInfo->fileName();
39} 45}
40 46
41void ListViewItemConfFile::parseFile() 47void ListViewItemConfFile::parseFile()
42{ 48{
43 //qDebug("ListViewItemConfFile::parseFile BEGIN"); 49 //odebug << "ListViewItemConfFile::parseFile BEGIN" << oendl;
44 QFile confFile(confFileInfo->absFilePath()); 50 QFile confFile(confFileInfo->absFilePath());
45 if(! confFile.open(IO_ReadOnly)) 51 if(! confFile.open(IO_ReadOnly))
46 QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); 52 QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0);
47 QTextStream t( &confFile ); 53 QTextStream t( &confFile );
48 QString s; 54 QString s;
49 QString group; 55 QString group;
50 ListViewItemConfigEntry *groupItem; 56 ListViewItemConfigEntry *groupItem;
51 ListViewItemConfigEntry *item; 57 ListViewItemConfigEntry *item;
52 while ( !t.atEnd() ) 58 while ( !t.atEnd() )
53 { 59 {
54 s = t.readLine().stripWhiteSpace(); 60 s = t.readLine().stripWhiteSpace();
55 //qDebug( "line: >%s<\n", s.latin1() ); 61 //odebug << "line: >" << s.latin1() << "<\n" << oendl;
56 if (s.contains("<?xml")) 62 if (s.contains("<?xml"))
57 { 63 {
58 _valid = false; 64 _valid = false;
59 break; 65 break;
60 }else 66 }else
61 if ( s[0] == '[' && s[s.length()-1] == ']' ) 67 if ( s[0] == '[' && s[s.length()-1] == ']' )
62 { 68 {
63 // qDebug("got group"+s); 69 // odebug << "got group"+s << oendl;
64 group = s.mid(1,s.length()-2); 70 group = s.mid(1,s.length()-2);
65 if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") ); 71 if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") );
66 groupItem = new ListViewItemConfigEntry(this, group ); 72 groupItem = new ListViewItemConfigEntry(this, group );
67 insertItem( groupItem ); 73 insertItem( groupItem );
68 } else 74 } else
69 if ( int pos = s.find('=') ) 75 if ( int pos = s.find('=') )
70 { 76 {
71// qDebug("got key"+s); 77// odebug << "got key"+s << oendl;
72 if (!groupItem) qDebug("PANIK NO GROUP! >%s<",group.latin1()); 78 if (!groupItem) odebug << "PANIK NO GROUP! >" << group.latin1() << "<" << oendl;
73 item = new ListViewItemConfigEntry(this, group, s ); 79 item = new ListViewItemConfigEntry(this, group, s );
74 groupItem->insertItem( item ); 80 groupItem->insertItem( item );
75 } 81 }
76 } 82 }
77 confFile.close(); 83 confFile.close();
78 setExpandable( _valid ); 84 setExpandable( _valid );
79 //qDebug("ListViewItemConfFile::parseFile END"); 85 //odebug << "ListViewItemConfFile::parseFile END" << oendl;
80} 86}
81 87
82 88
83void ListViewItemConfFile::remove() 89void ListViewItemConfFile::remove()
84{ 90{
85 QFile::remove(confFileInfo->absFilePath()); 91 QFile::remove(confFileInfo->absFilePath());
86 QFile::remove(backupFileName()); 92 QFile::remove(backupFileName());
87 delete this; 93 delete this;
88} 94}
89 95
90void ListViewItemConfFile::revert() 96void ListViewItemConfFile::revert()
91{ 97{
92 if (!_changed) 98 if (!_changed)
93 { 99 {
94 // read the backup file 100 // read the backup file
95 QFile conf(confFileInfo->absFilePath()); 101 QFile conf(confFileInfo->absFilePath());
96 QFile back(backupFileName()); 102 QFile back(backupFileName());
97 103
98 if (!back.open(IO_ReadOnly)) return; 104 if (!back.open(IO_ReadOnly)) return;
99 if (!conf.open(IO_WriteOnly)) return; 105 if (!conf.open(IO_WriteOnly)) return;
100 106
101 #define SIZE 124 107 #define SIZE 124
102 char buf[SIZE]; 108 char buf[SIZE];
103 while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); 109 while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c);
104 conf.close(); 110 conf.close();
105 back.close(); 111 back.close();
106 } 112 }
107 parseFile(); 113 parseFile();
108 expand(); 114 expand();
109} 115}
110 116
111void ListViewItemConfFile::save() 117void ListViewItemConfFile::save()
112{ 118{
113 if (!_changed) return; 119 if (!_changed) return;
114 QFile conf(confFileInfo->absFilePath()); 120 QFile conf(confFileInfo->absFilePath());
115 QFile back(backupFileName()); 121 QFile back(backupFileName());
116 122
117 if (!conf.open(IO_ReadOnly)) return; 123 if (!conf.open(IO_ReadOnly)) return;
118 if (!back.open(IO_WriteOnly)) return; 124 if (!back.open(IO_WriteOnly)) return;
119 125
120 char buf[SIZE]; 126 char buf[SIZE];
121 while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); 127 while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c);
122 conf.close(); 128 conf.close();
123 back.close(); 129 back.close();
124 130
125 131
126 if (!conf.open(IO_WriteOnly)) return; 132 if (!conf.open(IO_WriteOnly)) return;
127 QTextStream *t = new QTextStream( &conf ); 133 QTextStream *t = new QTextStream( &conf );
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 6ef1043..4b04c97 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,189 +1,192 @@
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// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13#include "mainwindow.h" 13#include "mainwindow.h"
14#include "listviewconfdir.h"
15#include "listviewitemconfigentry.h"
14 16
17/* OPIE */
18#include <opie2/odebug.h>
19using namespace Opie::Core;
20
21/* QT */
15#include <qlabel.h> 22#include <qlabel.h>
16#include <qlayout.h> 23#include <qlayout.h>
17#include <qlineedit.h> 24#include <qlineedit.h>
18 25
19#include "listviewconfdir.h"
20#include "listviewitemconfigentry.h"
21
22
23MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
24 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) 27 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
25{ 28{
26 setCaption( tr("Conf File Editor") ); 29 setCaption( tr("Conf File Editor") );
27 30
28 //setBaseSize( qApp->globalStrut() ); 31 //setBaseSize( qApp->globalStrut() );
29 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 32 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
30 33
31 mainLayout = new QVBoxLayout( this ); 34 mainLayout = new QVBoxLayout( this );
32 mainLayout->setSpacing( 0 ); 35 mainLayout->setSpacing( 0 );
33 mainLayout->setMargin( 0 ); 36 mainLayout->setMargin( 0 );
34 37
35 38
36 qDebug("creating settingList"); 39 odebug << "creating settingList" << oendl;
37 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); 40 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
38 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 41 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
39 mainLayout->addWidget( settingList, 0); 42 mainLayout->addWidget( settingList, 0);
40 43
41 qDebug("creating editor"); 44 odebug << "creating editor" << oendl;
42 editor = new EditWidget(this); 45 editor = new EditWidget(this);
43 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); 46 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
44 mainLayout->addWidget( editor, 1 ); 47 mainLayout->addWidget( editor, 1 );
45 editor->layoutType( ListViewItemConf::File ); 48 editor->layoutType( ListViewItemConf::File );
46 49
47 makeMenu(); 50 makeMenu();
48 51
49 connect(settingList, SIGNAL( pressed(QListViewItem*) ), 52 connect(settingList, SIGNAL( pressed(QListViewItem*) ),
50 this, SLOT(setCurrent(QListViewItem*))); 53 this, SLOT(setCurrent(QListViewItem*)));
51 connect( settingList, SIGNAL( clicked(QListViewItem*) ), 54 connect( settingList, SIGNAL( clicked(QListViewItem*) ),
52 this, SLOT( stopTimer(QListViewItem*) ) ); 55 this, SLOT( stopTimer(QListViewItem*) ) );
53 56
54 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), 57 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
55 SLOT( groupChanged(const QString&) ) ); 58 SLOT( groupChanged(const QString&) ) );
56 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), 59 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
57 SLOT( keyChanged(const QString&) ) ); 60 SLOT( keyChanged(const QString&) ) );
58 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), 61 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
59 SLOT( valueChanged(const QString&) ) ); 62 SLOT( valueChanged(const QString&) ) );
60 63
61 setCurrent(0); 64 setCurrent(0);
62 editor->layoutType(EditWidget::File); 65 editor->layoutType(EditWidget::File);
63} 66}
64 67
65void MainWindow::makeMenu() 68void MainWindow::makeMenu()
66{ 69{
67 popupTimer = new QTimer(this); 70 popupTimer = new QTimer(this);
68 popupMenuFile = new QPopupMenu(this); 71 popupMenuFile = new QPopupMenu(this);
69 popupMenuEntry = new QPopupMenu(this); 72 popupMenuEntry = new QPopupMenu(this);
70 73
71 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); 74 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
72 popupActionSave->addTo( popupMenuFile ); 75 popupActionSave->addTo( popupMenuFile );
73 // popupActionSave->addTo( popupMenuEntry ); 76 // popupActionSave->addTo( popupMenuEntry );
74 connect( popupActionSave, SIGNAL( activated() ), 77 connect( popupActionSave, SIGNAL( activated() ),
75 this , SLOT( saveConfFile() ) ); 78 this , SLOT( saveConfFile() ) );
76 79
77 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); 80 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
78 popupActionRevert->addTo( popupMenuFile ); 81 popupActionRevert->addTo( popupMenuFile );
79 popupActionRevert->addTo( popupMenuEntry ); 82 popupActionRevert->addTo( popupMenuEntry );
80 connect( popupActionRevert, SIGNAL( activated() ), 83 connect( popupActionRevert, SIGNAL( activated() ),
81 this , SLOT( revertConfFile() ) ); 84 this , SLOT( revertConfFile() ) );
82 85
83 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); 86 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
84 popupActionDelete->addTo( popupMenuFile ); 87 popupActionDelete->addTo( popupMenuFile );
85 popupActionDelete->addTo( popupMenuEntry ); 88 popupActionDelete->addTo( popupMenuEntry );
86 connect( popupActionDelete, SIGNAL( activated() ), 89 connect( popupActionDelete, SIGNAL( activated() ),
87 this , SLOT( removeConfFile() ) ); 90 this , SLOT( removeConfFile() ) );
88 91
89 connect( popupTimer, SIGNAL(timeout()), 92 connect( popupTimer, SIGNAL(timeout()),
90 this, SLOT(showPopup()) ); 93 this, SLOT(showPopup()) );
91} 94}
92 95
93MainWindow::~MainWindow() 96MainWindow::~MainWindow()
94{ 97{
95} 98}
96 99
97 100
98 101
99void MainWindow::setCurrent(QListViewItem *item) 102void MainWindow::setCurrent(QListViewItem *item)
100{ 103{
101 //qDebug("MainWindow::setCurrent"); 104 //odebug << "MainWindow::setCurrent" << oendl;
102 if (!item) return; 105 if (!item) return;
103 _item = (ListViewItemConf*) item; 106 _item = (ListViewItemConf*) item;
104 if (!_item) return; 107 if (!_item) return;
105 popupTimer->start( 750, true ); 108 popupTimer->start( 750, true );
106 if (_item->getType() == ListViewItemConf::File) 109 if (_item->getType() == ListViewItemConf::File)
107 { 110 {
108 editor->layoutType(EditWidget::File); 111 editor->layoutType(EditWidget::File);
109 _currentItem=0; 112 _currentItem=0;
110 _fileItem = (ListViewItemConfFile*)item; 113 _fileItem = (ListViewItemConfFile*)item;
111 return; 114 return;
112 } 115 }
113 _fileItem = 0; 116 _fileItem = 0;
114 _currentItem = (ListViewItemConfigEntry*)item; 117 _currentItem = (ListViewItemConfigEntry*)item;
115 if (!_currentItem) return; 118 if (!_currentItem) return;
116 QString file = _currentItem->getFile(); 119 QString file = _currentItem->getFile();
117 QString group = _currentItem->getGroup(); 120 QString group = _currentItem->getGroup();
118 QString key = _currentItem->getKey(); 121 QString key = _currentItem->getKey();
119 QString val = _currentItem->getValue(); 122 QString val = _currentItem->getValue();
120 editor->TextFileName->setText(file); 123 editor->TextFileName->setText(file);
121 editor->LineEditGroup->setText(group); 124 editor->LineEditGroup->setText(group);
122 if (!key.isEmpty()) 125 if (!key.isEmpty())
123 { 126 {
124 editor->layoutType(EditWidget::Entry); 127 editor->layoutType(EditWidget::Entry);
125 editor->LineEditKey->setText(key); 128 editor->LineEditKey->setText(key);
126 editor->LineEditValue->setText(val); 129 editor->LineEditValue->setText(val);
127 }else{ 130 }else{
128 editor->layoutType(EditWidget::Group); 131 editor->layoutType(EditWidget::Group);
129 } 132 }
130} 133}
131 134
132 135
133void MainWindow::groupChanged(const QString &g) 136void MainWindow::groupChanged(const QString &g)
134{ 137{
135 if (!_currentItem) return; 138 if (!_currentItem) return;
136 _currentItem->setGroup(g); 139 _currentItem->setGroup(g);
137} 140}
138 141
139void MainWindow::keyChanged(const QString &k) 142void MainWindow::keyChanged(const QString &k)
140{ 143{
141 if (!_currentItem) return; 144 if (!_currentItem) return;
142 _currentItem->keyChanged(k); 145 _currentItem->keyChanged(k);
143} 146}
144 147
145void MainWindow::valueChanged(const QString &v) 148void MainWindow::valueChanged(const QString &v)
146{ 149{
147 if (!_currentItem) return; 150 if (!_currentItem) return;
148 _currentItem->valueChanged(v); 151 _currentItem->valueChanged(v);
149} 152}
150 153
151 154
152void MainWindow::stopTimer( QListViewItem* ) 155void MainWindow::stopTimer( QListViewItem* )
153{ 156{
154 popupTimer->stop(); 157 popupTimer->stop();
155} 158}
156 159
157void MainWindow::saveConfFile() 160void MainWindow::saveConfFile()
158{ 161{
159 if (!_fileItem) return; 162 if (!_fileItem) return;
160 _fileItem->save(); 163 _fileItem->save();
161} 164}
162 165
163void MainWindow::revertConfFile() 166void MainWindow::revertConfFile()
164{ 167{
165 if (!_item) return; 168 if (!_item) return;
166 _item->revert(); 169 _item->revert();
167} 170}
168 171
169void MainWindow::removeConfFile() 172void MainWindow::removeConfFile()
170{ 173{
171 if (!_item) return; 174 if (!_item) return;
172 _item->remove(); 175 _item->remove();
173} 176}
174 177
175void MainWindow::showPopup() 178void MainWindow::showPopup()
176{ 179{
177qDebug("showPopup"); 180odebug << "showPopup" << oendl;
178 if (!_item) return; 181 if (!_item) return;
179 popupActionRevert->setEnabled(_item->revertable()); 182 popupActionRevert->setEnabled(_item->revertable());
180 popupActionSave->setEnabled(_item->isChanged()); 183 popupActionSave->setEnabled(_item->isChanged());
181 if (_fileItem) 184 if (_fileItem)
182 { 185 {
183 popupActionSave->setEnabled(_fileItem->isChanged()); 186 popupActionSave->setEnabled(_fileItem->isChanged());
184 popupMenuFile->popup( QCursor::pos() ); 187 popupMenuFile->popup( QCursor::pos() );
185 }else if(_currentItem) 188 }else if(_currentItem)
186 { 189 {
187 popupMenuEntry->popup( QCursor::pos() ); 190 popupMenuEntry->popup( QCursor::pos() );
188 } 191 }
189} 192}
diff --git a/noncore/apps/keyz-cfg/cfgfile.cpp b/noncore/apps/keyz-cfg/cfgfile.cpp
index b0dc968..81d1ee1 100644
--- a/noncore/apps/keyz-cfg/cfgfile.cpp
+++ b/noncore/apps/keyz-cfg/cfgfile.cpp
@@ -1,157 +1,163 @@
1#include <qmessagebox.h>
2#include "cfgfile.h" 1#include "cfgfile.h"
3 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
8#include <qmessagebox.h>
9
4// CfgEntry implementation 10// CfgEntry implementation
5CfgEntry::CfgEntry() { 11CfgEntry::CfgEntry() {
6} 12}
7 13
8CfgEntry::CfgEntry(const QString& f, const QString& l): 14CfgEntry::CfgEntry(const QString& f, const QString& l):
9 file(f), label(l) { 15 file(f), label(l) {
10} 16}
11 17
12const QString& CfgEntry::getFile() const { 18const QString& CfgEntry::getFile() const {
13 return file; 19 return file;
14} 20}
15 21
16void CfgEntry::setFile(const QString& f) { 22void CfgEntry::setFile(const QString& f) {
17 file = f; 23 file = f;
18} 24}
19 25
20const QString& CfgEntry::getLabel() const { 26const QString& CfgEntry::getLabel() const {
21 return label; 27 return label;
22} 28}
23 29
24void CfgEntry::setLabel(const QString& f) { 30void CfgEntry::setLabel(const QString& f) {
25 label = f; 31 label = f;
26} 32}
27 33
28// CfgFile implementation 34// CfgFile implementation
29CfgFile::CfgFile():ardelay(400), arperiod(80) { 35CfgFile::CfgFile():ardelay(400), arperiod(80) {
30} 36}
31 37
32CfgFile::~CfgFile() { 38CfgFile::~CfgFile() {
33} 39}
34 40
35QList<CfgEntry>& CfgFile::getEntries() { 41QList<CfgEntry>& CfgFile::getEntries() {
36 return entries; 42 return entries;
37} 43}
38 44
39bool CfgFile::replaceEntry(const QString& file, const QString& label, int index) { 45bool CfgFile::replaceEntry(const QString& file, const QString& label, int index) {
40 deleteEntry(file); 46 deleteEntry(file);
41 47
42 CfgEntry* entry = new CfgEntry(file, label); 48 CfgEntry* entry = new CfgEntry(file, label);
43 if (index >= 0) { 49 if (index >= 0) {
44 entries.insert(index, entry); 50 entries.insert(index, entry);
45 } else { 51 } else {
46 entries.append(entry); 52 entries.append(entry);
47 } 53 }
48 54
49 return true; 55 return true;
50} 56}
51 57
52bool CfgFile::deleteEntry(const QString& file) { 58bool CfgFile::deleteEntry(const QString& file) {
53 for(int i = 0; i < (int) entries.count(); i++) { 59 for(int i = 0; i < (int) entries.count(); i++) {
54 CfgEntry* entry = entries.at(i); 60 CfgEntry* entry = entries.at(i);
55 if (entry->getFile() == file) { 61 if (entry->getFile() == file) {
56 entries.remove(i); 62 entries.remove(i);
57 return true; 63 return true;
58 } 64 }
59 } 65 }
60 return false; 66 return false;
61} 67}
62 68
63int CfgFile::getAutorepeatDelay() const { 69int CfgFile::getAutorepeatDelay() const {
64 return ardelay; 70 return ardelay;
65} 71}
66 72
67void CfgFile::setAutorepeatDelay(int n) { 73void CfgFile::setAutorepeatDelay(int n) {
68 ardelay = n; 74 ardelay = n;
69} 75}
70 76
71int CfgFile::getAutorepeatPeriod() const { 77int CfgFile::getAutorepeatPeriod() const {
72 return arperiod; 78 return arperiod;
73} 79}
74 80
75void CfgFile::setAutorepeatPeriod(int n) { 81void CfgFile::setAutorepeatPeriod(int n) {
76 arperiod = n; 82 arperiod = n;
77} 83}
78 84
79// CfgParser implementation 85// CfgParser implementation
80CfgParser::CfgParser() { 86CfgParser::CfgParser() {
81} 87}
82 88
83bool CfgParser::load(QString file, CfgFile& cfg) { 89bool CfgParser::load(QString file, CfgFile& cfg) {
84 QFile f(file); 90 QFile f(file);
85 QXmlInputSource is(f); 91 QXmlInputSource is(f);
86 QXmlSimpleReader reader; 92 QXmlSimpleReader reader;
87 CfgHandler p(*this); 93 CfgHandler p(*this);
88 94
89 reader.setErrorHandler(this); 95 reader.setErrorHandler(this);
90 reader.setContentHandler(&p); 96 reader.setContentHandler(&p);
91 97
92 err = ""; 98 err = "";
93 ardelay = -1; 99 ardelay = -1;
94 arperiod = -1; 100 arperiod = -1;
95 reader.parse(is); 101 reader.parse(is);
96 102
97 if (!err.isEmpty()) { 103 if (!err.isEmpty()) {
98 qDebug(err); 104 odebug << err << oendl;
99 return false; 105 return false;
100 } 106 }
101 107
102 QMap<QString, QString>::Iterator fit, lit; 108 QMap<QString, QString>::Iterator fit, lit;
103 for(uint i = 0; i < includeList.count(); i++) { 109 for(uint i = 0; i < includeList.count(); i++) {
104 QString file = *includeList.at(i); 110 QString file = *includeList.at(i);
105 fit = includes.find(file); 111 fit = includes.find(file);
106 QString prefix = fit.data(); 112 QString prefix = fit.data();
107 QString label = ""; 113 QString label = "";
108 114
109 qDebug("include: file=" + fit.key() + ", prefix=" + fit.data()); 115 odebug << "include: file=" + fit.key() + ", prefix=" + fit.data() << oendl;
110 lit = labels.find(prefix+":*"); 116 lit = labels.find(prefix+":*");
111 if (lit != labels.end()) { 117 if (lit != labels.end()) {
112 label = lit.data(); 118 label = lit.data();
113 } 119 }
114 120
115 cfg.replaceEntry(file, label); 121 cfg.replaceEntry(file, label);
116 } 122 }
117 123
118 if (ardelay != -1) { 124 if (ardelay != -1) {
119 cfg.setAutorepeatDelay(ardelay); 125 cfg.setAutorepeatDelay(ardelay);
120 } 126 }
121 127
122 if (arperiod != -1) { 128 if (arperiod != -1) {
123 cfg.setAutorepeatPeriod(arperiod); 129 cfg.setAutorepeatPeriod(arperiod);
124 } 130 }
125 131
126 return true; 132 return true;
127} 133}
128 134
129bool CfgParser::save(QString file, CfgFile& cfg) { 135bool CfgParser::save(QString file, CfgFile& cfg) {
130 FILE* f = fopen((const char*) file.local8Bit(), "w"); 136 FILE* f = fopen((const char*) file.local8Bit(), "w");
131 137
132 fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" " 138 fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" "
133 "author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(), 139 "author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(),
134 cfg.getAutorepeatPeriod()); 140 cfg.getAutorepeatPeriod());
135 141
136 QList<CfgEntry>& entries = cfg.getEntries(); 142 QList<CfgEntry>& entries = cfg.getEntries();
137 int n; 143 int n;
138 144
139 for(n=0; n < (int) entries.count(); n++) { 145 for(n=0; n < (int) entries.count(); n++) {
140 CfgEntry* entry = entries.at(n); 146 CfgEntry* entry = entries.at(n);
141 QString l = entry->getLabel(); 147 QString l = entry->getLabel();
142 if (!l.isEmpty()) { 148 if (!l.isEmpty()) {
143 fprintf(f, "\t<label name=\"%s\" state=\"km%d:*\"/>\n", 149 fprintf(f, "\t<label name=\"%s\" state=\"km%d:*\"/>\n",
144 (const char*) l.utf8(), n); 150 (const char*) l.utf8(), n);
145 } 151 }
146 } 152 }
147 153
148 for(n=0; n < (int) entries.count(); n++) { 154 for(n=0; n < (int) entries.count(); n++) {
149 CfgEntry* entry = entries.at(n); 155 CfgEntry* entry = entries.at(n);
150 fprintf(f, "\t<include file=\"%s\" prefix=\"km%d\"/>\n", 156 fprintf(f, "\t<include file=\"%s\" prefix=\"km%d\"/>\n",
151 (const char*) entry->getFile().utf8(), n); 157 (const char*) entry->getFile().utf8(), n);
152 } 158 }
153 159
154 int k = n-1; 160 int k = n-1;
155 char* states[] = { "LShift", "LShift-Caps", "LShift-Num", 161 char* states[] = { "LShift", "LShift-Caps", "LShift-Num",
156 "LShift-Num-Caps", 0}; 162 "LShift-Num-Caps", 0};
157 163
diff --git a/noncore/apps/keyz-cfg/config.in b/noncore/apps/keyz-cfg/config.in
index 29a10f5..8e1be2d 100644
--- a/noncore/apps/keyz-cfg/config.in
+++ b/noncore/apps/keyz-cfg/config.in
@@ -1,4 +1,4 @@
1 config KEYZCFG 1 config KEYZCFG
2 boolean "keyz-cfg (configuration tool for keyz applet)" 2 boolean "keyz-cfg (configuration tool for keyz applet)"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/keyz-cfg/keyz-cfg.pro b/noncore/apps/keyz-cfg/keyz-cfg.pro
index 44bbb5f..7ac604b 100644
--- a/noncore/apps/keyz-cfg/keyz-cfg.pro
+++ b/noncore/apps/keyz-cfg/keyz-cfg.pro
@@ -1,24 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2DESTDIR = $(OPIEDIR)/bin 2DESTDIR = $(OPIEDIR)/bin
3 CONFIG = qt warn_on 3 CONFIG = qt warn_on
4 HEADERS = zkb.h \ 4 HEADERS = zkb.h \
5 zkbcfg.h \ 5 zkbcfg.h \
6 zkbnames.h \ 6 zkbnames.h \
7 zkbxml.h \ 7 zkbxml.h \
8 cfgdlg.h \ 8 cfgdlg.h \
9 cfgfile.h 9 cfgfile.h
10 10
11 SOURCES = main.cpp \ 11 SOURCES = main.cpp \
12 cfgdlg.cpp \ 12 cfgdlg.cpp \
13 cfgfile.cpp \ 13 cfgfile.cpp \
14 zkb.cpp \ 14 zkb.cpp \
15 zkbcfg.cpp \ 15 zkbcfg.cpp \
16 zkbnames.cpp \ 16 zkbnames.cpp \
17 zkbxml.cpp 17 zkbxml.cpp
18 18
19INCLUDEPATH += $(OPIEDIR)/include 19INCLUDEPATH += $(OPIEDIR)/include
20DEPENDPATH += $(OPIEDIR)/include 20DEPENDPATH += $(OPIEDIR)/include
21 LIBS += -lqpe 21 LIBS += -lqpe -lopiecore2
22 TARGET = keyz-cfg 22 TARGET = keyz-cfg
23 23
24include ( $(OPIEDIR)/include.pro ) 24include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/keyz-cfg/zkb.cpp b/noncore/apps/keyz-cfg/zkb.cpp
index f315d4b..8382615 100644
--- a/noncore/apps/keyz-cfg/zkb.cpp
+++ b/noncore/apps/keyz-cfg/zkb.cpp
@@ -319,149 +319,149 @@ QStringList Keymap::listStates() {
319 QMap<QString, State*>::Iterator it; 319 QMap<QString, State*>::Iterator it;
320 for(it = states.begin(); it != states.end(); ++it) { 320 for(it = states.begin(); it != states.end(); ++it) {
321 ret.append(it.key()); 321 ret.append(it.key());
322 } 322 }
323 323
324 return ret; 324 return ret;
325} 325}
326 326
327State* Keymap::getStateByName(const QString& name) { 327State* Keymap::getStateByName(const QString& name) {
328 QMap<QString, State*>::Iterator it = states.find(name); 328 QMap<QString, State*>::Iterator it = states.find(name);
329 329
330 if (it == states.end()) { 330 if (it == states.end()) {
331 return 0; 331 return 0;
332 } 332 }
333 333
334 return it.data(); 334 return it.data();
335} 335}
336 336
337QStringList Keymap::listLabels() { 337QStringList Keymap::listLabels() {
338 QStringList ret; 338 QStringList ret;
339 339
340 for(uint i = 0; i < labelList.count(); i++) { 340 for(uint i = 0; i < labelList.count(); i++) {
341 ret.append(*labelList.at(i)); 341 ret.append(*labelList.at(i));
342 } 342 }
343 343
344 return ret; 344 return ret;
345} 345}
346 346
347State* Keymap::getStateByLabel(const QString& label) { 347State* Keymap::getStateByLabel(const QString& label) {
348 QMap<QString, QString>::Iterator lit = labels.find(label); 348 QMap<QString, QString>::Iterator lit = labels.find(label);
349 State* state = 0; 349 State* state = 0;
350 350
351 if (lit == labels.end()) { 351 if (lit == labels.end()) {
352 return 0; 352 return 0;
353 } 353 }
354 354
355 QString name = lit.data(); 355 QString name = lit.data();
356 356
357 int n = name.find(":*"); 357 int n = name.find(":*");
358 if (n>=0 && n==(int)(name.length()-2)) { 358 if (n>=0 && n==(int)(name.length()-2)) {
359 name=name.left(name.length() - 1); 359 name=name.left(name.length() - 1);
360 360
361 n = currentStateName.findRev(":"); 361 n = currentStateName.findRev(":");
362 if (n >= 0) { 362 if (n >= 0) {
363 name += currentStateName.mid(n+1); 363 name += currentStateName.mid(n+1);
364 } 364 }
365 } 365 }
366 366
367 //qDebug("look for: %s\n", (const char*) name.utf8()); 367 //odebug << "look for: " << (const char*) name.utf8() << "\n" << oendl;
368 QMap<QString, State*>::Iterator sit = states.find(name); 368 QMap<QString, State*>::Iterator sit = states.find(name);
369 if (sit != states.end()) { 369 if (sit != states.end()) {
370 state = sit.data(); 370 state = sit.data();
371 } 371 }
372 372
373 return state; 373 return state;
374} 374}
375 375
376bool Keymap::addState(const QString& name, State* state) { 376bool Keymap::addState(const QString& name, State* state) {
377 if (states.find(name) != states.end()) { 377 if (states.find(name) != states.end()) {
378 return false; 378 return false;
379 } 379 }
380 380
381 states.insert(name, state); 381 states.insert(name, state);
382 lsmapInSync = false; 382 lsmapInSync = false;
383 383
384 if (currentState == 0) { 384 if (currentState == 0) {
385 setCurrentState(state); 385 setCurrentState(state);
386 } 386 }
387 387
388 return true; 388 return true;
389} 389}
390 390
391State* Keymap::getCurrentState() const { 391State* Keymap::getCurrentState() const {
392 return currentState; 392 return currentState;
393} 393}
394 394
395QString Keymap::getCurrentLabel() { 395QString Keymap::getCurrentLabel() {
396 return currentLabel; 396 return currentLabel;
397} 397}
398 398
399bool Keymap::setCurrentState(State* state) { 399bool Keymap::setCurrentState(State* state) {
400 QMap<QString, State*>::Iterator it; 400 QMap<QString, State*>::Iterator it;
401 for(it = states.begin(); it != states.end(); ++it) { 401 for(it = states.begin(); it != states.end(); ++it) {
402 State* s = it.data(); 402 State* s = it.data();
403 if (s == state) { 403 if (s == state) {
404 currentState = s; 404 currentState = s;
405 currentStateName = it.key(); 405 currentStateName = it.key();
406 406
407 qDebug("state changed: %s\n", (const char*) 407 qDebug("state changed: %s\n", (const char*)
408 currentStateName.utf8()); 408 currentStateName.utf8());
409 409
410 if (!lsmapInSync) { 410 if (!lsmapInSync) {
411 generateLabelStateMaps(); 411 generateLabelStateMaps();
412 } 412 }
413 413
414 QMap<State*, QString>::Iterator tit; 414 QMap<State*, QString>::Iterator tit;
415 tit = stateLabelMap.find(state); 415 tit = stateLabelMap.find(state);
416 if (tit != stateLabelMap.end()) { 416 if (tit != stateLabelMap.end()) {
417 currentLabel = tit.data(); 417 currentLabel = tit.data();
418 } else { 418 } else {
419 // qDebug("no label for: " + currentStateName + "\n"); 419 // odebug << "no label for: " + currentStateName + "\n" << oendl;
420 currentLabel = ""; 420 currentLabel = "";
421 } 421 }
422 422
423 return true; 423 return true;
424 } 424 }
425 } 425 }
426 426
427 return false; 427 return false;
428} 428}
429 429
430bool Keymap::removeState(const QString& name, bool force) { 430bool Keymap::removeState(const QString& name, bool force) {
431 QMap<QString, State*>::Iterator it = states.find(name); 431 QMap<QString, State*>::Iterator it = states.find(name);
432 432
433 if (it == states.end()) { 433 if (it == states.end()) {
434 return false; 434 return false;
435 } 435 }
436 436
437 State* state = it.data(); 437 State* state = it.data();
438 QList<Action> acts = findStateUsage(state); 438 QList<Action> acts = findStateUsage(state);
439 439
440 if (!acts.isEmpty()) { 440 if (!acts.isEmpty()) {
441 if (!force) { 441 if (!force) {
442 return false; 442 return false;
443 } else { 443 } else {
444 for(Action* a = acts.first(); a != 0; a = acts.next()) { 444 for(Action* a = acts.first(); a != 0; a = acts.next()) {
445 a->setState(0); 445 a->setState(0);
446 } 446 }
447 } 447 }
448 } 448 }
449 449
450 if (state == currentState) { 450 if (state == currentState) {
451 if (states.begin() != states.end()) { 451 if (states.begin() != states.end()) {
452 setCurrentState(states.begin().data()); 452 setCurrentState(states.begin().data());
453 } 453 }
454 } 454 }
455 455
456 states.remove(it); 456 states.remove(it);
457 delete state; 457 delete state;
458 458
459 lsmapInSync = false; 459 lsmapInSync = false;
460 460
461 return true; 461 return true;
462} 462}
463 463
464void Keymap::autoRepeat() { 464void Keymap::autoRepeat() {
465 if (autoRepeatAction != 0) { 465 if (autoRepeatAction != 0) {
466 qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, " 466 qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, "
467 "ispressed=%x\n", autoRepeatAction->getUnicode(), 467 "ispressed=%x\n", autoRepeatAction->getUnicode(),
diff --git a/noncore/apps/keyz-cfg/zkbcfg.cpp b/noncore/apps/keyz-cfg/zkbcfg.cpp
index 0992b9a..f1d53ba 100644
--- a/noncore/apps/keyz-cfg/zkbcfg.cpp
+++ b/noncore/apps/keyz-cfg/zkbcfg.cpp
@@ -1,173 +1,176 @@
1#include <qfileinfo.h>
2
3#include "zkbcfg.h" 1#include "zkbcfg.h"
4 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
8#include <qfileinfo.h>
5 9
6// Implementation of XkbConfig class 10// Implementation of XkbConfig class
7ZkbConfig::ZkbConfig(const QString& dir):path(dir) { 11ZkbConfig::ZkbConfig(const QString& dir):path(dir) {
8} 12}
9 13
10ZkbConfig::~ZkbConfig() { 14ZkbConfig::~ZkbConfig() {
11} 15}
12 16
13bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) { 17bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) {
14 bool ret; 18 bool ret;
15 QFile f(path+"/"+file); 19 QFile f(path+"/"+file);
16 QFileInfo fi(f); 20 QFileInfo fi(f);
17 21
18 qDebug("start loading file=%s\n", (const char*) file.utf8()); 22 odebug << "start loading file=" << (const char*) file.utf8() << "\n" << oendl;
19 if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) { 23 if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) {
20 return false; 24 return false;
21 } 25 }
22 26
23 includedFiles.insert(fi.absFilePath(), 1); 27 includedFiles.insert(fi.absFilePath(), 1);
24 QXmlInputSource is(f); 28 QXmlInputSource is(f);
25 QXmlSimpleReader reader; 29 QXmlSimpleReader reader;
26 ZkbHandler h(*this, keymap, prefix); 30 ZkbHandler h(*this, keymap, prefix);
27 31
28 reader.setContentHandler(&h); 32 reader.setContentHandler(&h);
29 reader.setErrorHandler(this); 33 reader.setErrorHandler(this);
30 ret = reader.parse(is); 34 ret = reader.parse(is);
31 includedFiles.remove(fi.absFilePath()); 35 includedFiles.remove(fi.absFilePath());
32 36
33 qDebug("end loading file=%s : status=%s\n", (const char*) file.utf8(), 37 odebug << "end loading file=" << file.utf8() << ": status=" << err.utf8() << oendl;
34 (const char*) err.utf8());
35 return ret; 38 return ret;
36} 39}
37 40
38bool ZkbConfig::warning(const QXmlParseException& e) { 41bool ZkbConfig::warning(const QXmlParseException& e) {
39 QString tmp; 42 QString tmp;
40 43
41 tmp.sprintf("%d: warning: %s\n", e.lineNumber(), 44 tmp.sprintf("%d: warning: %s\n", e.lineNumber(),
42 (const char*) e.message().utf8()); 45 (const char*) e.message().utf8());
43 46
44 err += tmp; 47 err += tmp;
45 48
46 return true; 49 return true;
47} 50}
48 51
49bool ZkbConfig::error(const QXmlParseException& e) { 52bool ZkbConfig::error(const QXmlParseException& e) {
50 QString tmp; 53 QString tmp;
51 54
52 tmp.sprintf("%d: error: %s\n", e.lineNumber(), 55 tmp.sprintf("%d: error: %s\n", e.lineNumber(),
53 (const char*) e.message().utf8()); 56 (const char*) e.message().utf8());
54 57
55 err += tmp; 58 err += tmp;
56 59
57 return true; 60 return true;
58} 61}
59 62
60bool ZkbConfig::fatalError(const QXmlParseException& e) { 63bool ZkbConfig::fatalError(const QXmlParseException& e) {
61 QString tmp; 64 QString tmp;
62 65
63 tmp.sprintf("%d: fatal error: %s\n", e.lineNumber(), 66 tmp.sprintf("%d: fatal error: %s\n", e.lineNumber(),
64 (const char*) e.message().utf8()); 67 (const char*) e.message().utf8());
65 68
66 err += tmp; 69 err += tmp;
67 70
68 return false; 71 return false;
69} 72}
70 73
71QString ZkbConfig::errorString() { 74QString ZkbConfig::errorString() {
72 return err; 75 return err;
73} 76}
74 77
75// Implementation of ZkbHandler 78// Implementation of ZkbHandler
76ZkbHandler::ZkbHandler(ZkbConfig& z, Keymap& k, const QString& p):zkc(z), keymap(k), 79ZkbHandler::ZkbHandler(ZkbConfig& z, Keymap& k, const QString& p):zkc(z), keymap(k),
77 prefix(p), ardelay(-1), arperiod(-1), currentState(0), currentAction(0) { 80 prefix(p), ardelay(-1), arperiod(-1), currentState(0), currentAction(0) {
78} 81}
79 82
80ZkbHandler::~ZkbHandler() { 83ZkbHandler::~ZkbHandler() {
81} 84}
82 85
83bool ZkbHandler::startKeymapElement(int ard, int arp, const QString&) { 86bool ZkbHandler::startKeymapElement(int ard, int arp, const QString&) {
84 ardelay = ard; 87 ardelay = ard;
85 arperiod = arp; 88 arperiod = arp;
86 89
87 return true; 90 return true;
88} 91}
89 92
90bool ZkbHandler::startIncludeElement(const QString& file, 93bool ZkbHandler::startIncludeElement(const QString& file,
91 const QString& pref) { 94 const QString& pref) {
92 95
93 QString p = prefix; 96 QString p = prefix;
94 97
95 if (!pref.isNull()) { 98 if (!pref.isNull()) {
96 p += pref + ":"; 99 p += pref + ":";
97 } 100 }
98 101
99 102
100 bool ret = zkc.load(file, keymap, p); 103 bool ret = zkc.load(file, keymap, p);
101 if (!ret) { 104 if (!ret) {
102 setError("Error including file: " + file); 105 setError("Error including file: " + file);
103 } 106 }
104 107
105 return ret; 108 return ret;
106} 109}
107 110
108bool ZkbHandler::startLabelElement(const QString& label, 111bool ZkbHandler::startLabelElement(const QString& label,
109 const QString& state) { 112 const QString& state) {
110 113
111 if (!keymap.addLabel(label, prefix + state)) { 114 if (!keymap.addLabel(label, prefix + state)) {
112 err = "label " + label + " already defined"; 115 err = "label " + label + " already defined";
113 return false; 116 return false;
114 } 117 }
115 118
116 return true; 119 return true;
117} 120}
118 121
119bool ZkbHandler::startStateElement(const QString& name, 122bool ZkbHandler::startStateElement(const QString& name,
120 const QString& parentName, bool dflt) { 123 const QString& parentName, bool dflt) {
121 124
122 currentStateName = prefix + name; 125 currentStateName = prefix + name;
123 currentState = keymap.getStateByName(currentStateName); 126 currentState = keymap.getStateByName(currentStateName);
124 127
125 //qDebug("state name=%s\n", (const char*) currentStateName.utf8()); 128 //odebug << "state name=" << (const char*) currentStateName.utf8() << "\n" << oendl;
126 129
127 State* parent = 0; 130 State* parent = 0;
128 if (!parentName.isEmpty()) { 131 if (!parentName.isEmpty()) {
129 QString pn = prefix + parentName; 132 QString pn = prefix + parentName;
130 parent = keymap.getStateByName(pn); 133 parent = keymap.getStateByName(pn);
131 if (parent == 0) { 134 if (parent == 0) {
132 err = currentStateName + 135 err = currentStateName +
133 ": undefined parent state: " + pn; 136 ": undefined parent state: " + pn;
134 return false; 137 return false;
135 } 138 }
136 } 139 }
137 140
138 if (currentState == 0) { 141 if (currentState == 0) {
139 currentState = new State(parent); 142 currentState = new State(parent);
140 keymap.addState(currentStateName, currentState); 143 keymap.addState(currentStateName, currentState);
141 } else { 144 } else {
142 if (parent!=0) { 145 if (parent!=0) {
143 currentState->setParent(parent); 146 currentState->setParent(parent);
144 } 147 }
145 } 148 }
146 149
147 if (dflt) { 150 if (dflt) {
148 keymap.setCurrentState(currentState); 151 keymap.setCurrentState(currentState);
149 } 152 }
150 153
151 return true; 154 return true;
152} 155}
153 156
154bool ZkbHandler::startMapElement(int keycode, bool pressed) { 157bool ZkbHandler::startMapElement(int keycode, bool pressed) {
155 currentAction = currentState->get(keycode, pressed); 158 currentAction = currentState->get(keycode, pressed);
156 if (currentAction == 0) { 159 if (currentAction == 0) {
157 setError("keycode " + QString::number(keycode) + " not supported"); 160 setError("keycode " + QString::number(keycode) + " not supported");
158 return false; 161 return false;
159 } 162 }
160 163
161 currentAction->setEvent(false); 164 currentAction->setEvent(false);
162 currentAction->setState(0); 165 currentAction->setState(0);
163 166
164 return true; 167 return true;
165} 168}
166 169
167bool ZkbHandler::startEventElement(int keycode, int unicode, int modifiers, 170bool ZkbHandler::startEventElement(int keycode, int unicode, int modifiers,
168 bool pressed, bool autorepeat) { 171 bool pressed, bool autorepeat) {
169 172
170 currentAction->setEvent(true); 173 currentAction->setEvent(true);
171 currentAction->setKeycode(keycode); 174 currentAction->setKeycode(keycode);
172 currentAction->setUnicode(unicode); 175 currentAction->setUnicode(unicode);
173 currentAction->setModifiers(modifiers); 176 currentAction->setModifiers(modifiers);
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index e6cb515..59fc242 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -1,91 +1,94 @@
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 <qtoolbar.h> 19/* OPIE */
20#include <qmenubar.h> 20#include <opie2/odebug.h>
21//#include <opie2/colorpopupmenu.h>
22#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 22#include <qpe/resource.h>
23using namespace Opie::Core;
24 24
25/* QT */
25#include <qlineedit.h> 26#include <qlineedit.h>
26#include <qdir.h> 27#include <qdir.h>
27#include <qpushbutton.h> 28#include <qpushbutton.h>
28#include <qlistbox.h> 29#include <qlistbox.h>
29#include <qmultilineedit.h> 30#include <qmultilineedit.h>
30#include <qmessagebox.h> 31#include <qmessagebox.h>
31#include <qtextstream.h> 32#include <qtextstream.h>
32#include <qaction.h> 33#include <qaction.h>
33#include <qheader.h> 34#include <qheader.h>
34#include <qlistview.h> 35#include <qlistview.h>
35#include <qlayout.h> 36#include <qlayout.h>
37#include <qtoolbar.h>
38#include <qmenubar.h>
36 39
40/* STD */
37#include <fcntl.h> 41#include <fcntl.h>
38#include <unistd.h> 42#include <unistd.h>
39#include <stdlib.h> 43#include <stdlib.h>
40#include <stdio.h> 44#include <stdio.h>
41#include <errno.h> 45#include <errno.h>
42 46
43
44Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) 47Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
45 : QMainWindow( parent, name, fl ) { 48 : QMainWindow( parent, name, fl ) {
46 if ( !name ) 49 if ( !name )
47 setName( "Bartender" ); 50 setName( "Bartender" );
48 QGridLayout *layout = new QGridLayout( this ); 51 QGridLayout *layout = new QGridLayout( this );
49 layout->setSpacing( 2); 52 layout->setSpacing( 2);
50 layout->setMargin( 2); 53 layout->setMargin( 2);
51 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 54 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
52 55
53 setCaption( tr( "Bartender" ) ); 56 setCaption( tr( "Bartender" ) );
54 57
55 ToolBar1 = new QToolBar( this, "ToolBar1" ); 58 ToolBar1 = new QToolBar( this, "ToolBar1" );
56 ToolBar1->setFixedHeight(22); 59 ToolBar1->setFixedHeight(22);
57 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); 60 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
58 61
59 QMenuBar *menuBar = new QMenuBar( ToolBar1 ); 62 QMenuBar *menuBar = new QMenuBar( ToolBar1 );
60 QPopupMenu *fileMenu; 63 QPopupMenu *fileMenu;
61 fileMenu = new QPopupMenu( this); 64 fileMenu = new QPopupMenu( this);
62 menuBar->insertItem( tr("File"), fileMenu ); 65 menuBar->insertItem( tr("File"), fileMenu );
63 66
64 fileMenu->insertItem(tr("New Drink")); 67 fileMenu->insertItem(tr("New Drink"));
65 fileMenu->insertItem(tr("Open Drink")); 68 fileMenu->insertItem(tr("Open Drink"));
66 fileMenu->insertItem(tr("Find by Drink Name")); 69 fileMenu->insertItem(tr("Find by Drink Name"));
67 fileMenu->insertItem(tr("Find by Alcohol")); 70 fileMenu->insertItem(tr("Find by Alcohol"));
68 71
69 QPopupMenu *editMenu; 72 QPopupMenu *editMenu;
70 editMenu = new QPopupMenu( this); 73 editMenu = new QPopupMenu( this);
71 menuBar->insertItem( tr("Edit"), editMenu ); 74 menuBar->insertItem( tr("Edit"), editMenu );
72 editMenu->insertItem(tr("edit")); 75 editMenu->insertItem(tr("edit"));
73 76
74 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); 77 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) ));
75 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); 78 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) ));
76 79
77 80
78 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); 81 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 );
79 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 82 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
80 a->addTo( ToolBar1 ); 83 a->addTo( ToolBar1 );
81 84
82 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); 85 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 );
83 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); 86 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) );
84 a->addTo( ToolBar1 ); 87 a->addTo( ToolBar1 );
85 88
86 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); 89 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 );
87 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); 90 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) );
88 a->addTo( ToolBar1 ); 91 a->addTo( ToolBar1 );
89 92
90 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); 93 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 );
91 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); 94 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) );
@@ -99,334 +102,334 @@ Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
99 DrinkView->addColumn( tr( "Name of Drink" ) ); 102 DrinkView->addColumn( tr( "Name of Drink" ) );
100// DrinkView->setRootIsDecorated( TRUE ); 103// DrinkView->setRootIsDecorated( TRUE );
101 DrinkView->header()->hide(); 104 DrinkView->header()->hide();
102 105
103 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); 106 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold);
104 107
105 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); 108 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*)));
106 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 109 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
107 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); 110 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int)));
108 111
109 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); 112 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 );
110 if(QDir("db").exists()) { 113 if(QDir("db").exists()) {
111 dbFile.setName( "db/drinkdb.txt"); 114 dbFile.setName( "db/drinkdb.txt");
112 } else 115 } else
113 dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); 116 dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt");
114 initDrinkDb(); 117 initDrinkDb();
115} 118}
116 119
117Bartender::~Bartender() { 120Bartender::~Bartender() {
118} 121}
119 122
120/* 123/*
121this happens right before exit */ 124this happens right before exit */
122void Bartender::cleanUp() { 125void Bartender::cleanUp() {
123 dbFile.close(); 126 dbFile.close();
124 127
125} 128}
126 129
127void Bartender::initDrinkDb() { 130void Bartender::initDrinkDb() {
128 131
129 if(!dbFile.isOpen()) 132 if(!dbFile.isOpen())
130 if ( !dbFile.open( IO_ReadOnly)) { 133 if ( !dbFile.open( IO_ReadOnly)) {
131 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 134 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
132 return; 135 return;
133 } 136 }
134 fillList(); 137 fillList();
135} 138}
136 139
137void Bartender::fillList() { 140void Bartender::fillList() {
138 dbFile.at(1); 141 dbFile.at(1);
139 DrinkView->clear(); 142 DrinkView->clear();
140 int i=0; 143 int i=0;
141 QListViewItem * item ; 144 QListViewItem * item ;
142 QTextStream t( &dbFile); 145 QTextStream t( &dbFile);
143 QString s; 146 QString s;
144 while ( !t.eof()) { 147 while ( !t.eof()) {
145 s = t.readLine(); 148 s = t.readLine();
146 if(s.find("#",0,TRUE) != -1) { 149 if(s.find("#",0,TRUE) != -1) {
147// qDebug(s.right(s.length()-2)); 150// odebug << s.right(s.length()-2) << oendl;
148 item= new QListViewItem( DrinkView, 0 ); 151 item= new QListViewItem( DrinkView, 0 );
149 item->setText( 0, s.right(s.length()-2)); 152 item->setText( 0, s.right(s.length()-2));
150 i++; 153 i++;
151 } 154 }
152 } 155 }
153 qDebug("there are currently %d of drinks", i); 156 odebug << "there are currently " << i << " of drinks" << oendl;
154} 157}
155 158
156void Bartender::fileNew() { 159void Bartender::fileNew() {
157 160
158 New_Drink *newDrinks; 161 New_Drink *newDrinks;
159 newDrinks = new New_Drink(this,"New Drink....", TRUE); 162 newDrinks = new New_Drink(this,"New Drink....", TRUE);
160 QString newName, newIng; 163 QString newName, newIng;
161 QPEApplication::execDialog( newDrinks ); 164 QPEApplication::execDialog( newDrinks );
162 newName = newDrinks->LineEdit1->text(); 165 newName = newDrinks->LineEdit1->text();
163 newIng= newDrinks->MultiLineEdit1->text(); 166 newIng= newDrinks->MultiLineEdit1->text();
164 167
165 if(dbFile.isOpen()) 168 if(dbFile.isOpen())
166 dbFile.close(); 169 dbFile.close();
167 if ( !dbFile.open( IO_WriteOnly| IO_Append)) { 170 if ( !dbFile.open( IO_WriteOnly| IO_Append)) {
168 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 171 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
169 return; 172 return;
170 } 173 }
171 if(newDrinks ->result() == 1 ) { 174 if(newDrinks ->result() == 1 ) {
172 QString newDrink="\n# "+newName+"\n"; 175 QString newDrink="\n# "+newName+"\n";
173 newDrink.append(newIng+"\n"); 176 newDrink.append(newIng+"\n");
174 qDebug("writing "+newDrink); 177 odebug << "writing "+newDrink << oendl;
175 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 178 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
176 clearList(); 179 clearList();
177 dbFile.close(); 180 dbFile.close();
178 181
179 initDrinkDb(); 182 initDrinkDb();
180 } 183 }
181 delete newDrinks; 184 delete newDrinks;
182} 185}
183 186
184void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { 187void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) {
185 switch (mouse) { 188 switch (mouse) {
186 case 1: 189 case 1:
187// showDrink(item); 190// showDrink(item);
188 break; 191 break;
189 case 2: 192 case 2:
190 showDrink(item); 193 showDrink(item);
191 break; 194 break;
192 } 195 }
193} 196}
194 197
195void Bartender::showDrink( QListViewItem *item) { 198void Bartender::showDrink( QListViewItem *item) {
196 if(item==NULL) return; 199 if(item==NULL) return;
197 dbFile.at(0); 200 dbFile.at(0);
198 Show_Drink *showDrinks; 201 Show_Drink *showDrinks;
199 QString myDrink=item->text(0); 202 QString myDrink=item->text(0);
200 showDrinks = new Show_Drink(this, myDrink, TRUE); 203 showDrinks = new Show_Drink(this, myDrink, TRUE);
201 QTextStream t( &dbFile); 204 QTextStream t( &dbFile);
202 205
203 QString s, s2; 206 QString s, s2;
204 while ( !t.eof()) { 207 while ( !t.eof()) {
205 s = t.readLine(); 208 s = t.readLine();
206 if(s.find( myDrink, 0, TRUE) != -1) { 209 if(s.find( myDrink, 0, TRUE) != -1) {
207 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { 210 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
208 s2 = t.readLine(); 211 s2 = t.readLine();
209 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { 212 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
210// qDebug(s2); 213// odebug << s2 << oendl;
211 showDrinks->MultiLineEdit1->append(s2); 214 showDrinks->MultiLineEdit1->append(s2);
212 } 215 }
213 if( dbFile.atEnd() ) break; 216 if( dbFile.atEnd() ) break;
214 } 217 }
215 } 218 }
216 } 219 }
217 QPEApplication::execDialog( showDrinks ); 220 QPEApplication::execDialog( showDrinks );
218 221
219 if(showDrinks ->result() ==0) { 222 if(showDrinks ->result() ==0) {
220 doEdit(); 223 doEdit();
221 } 224 }
222 delete showDrinks; 225 delete showDrinks;
223} 226}
224 227
225void Bartender::askSearch() { 228void Bartender::askSearch() {
226 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ 229 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+
227 "\nor alcohol ?" 230 "\nor alcohol ?"
228 ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { 231 ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) {
229 case 0: 232 case 0:
230 doSearchByName(); 233 doSearchByName();
231 break; 234 break;
232 case 1: 235 case 1:
233 doSearchByDrink(); 236 doSearchByDrink();
234 break; 237 break;
235 }; 238 };
236} 239}
237 240
238/* search by name */ 241/* search by name */
239void Bartender::doSearchByName() { 242void Bartender::doSearchByName() {
240// if( DrinkView->currentItem() == NULL) return; 243// if( DrinkView->currentItem() == NULL) return;
241 QStringList searchList; 244 QStringList searchList;
242 QString searchForDrinkName; 245 QString searchForDrinkName;
243 InputDialog *fileDlg; 246 InputDialog *fileDlg;
244 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); 247 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0);
245 fileDlg->exec(); 248 fileDlg->exec();
246 if( fileDlg->result() == 1 ) { 249 if( fileDlg->result() == 1 ) {
247 searchForDrinkName = fileDlg->LineEdit1->text(); 250 searchForDrinkName = fileDlg->LineEdit1->text();
248 QListViewItemIterator it( DrinkView ); 251 QListViewItemIterator it( DrinkView );
249 for ( ; it.current(); ++it ) { 252 for ( ; it.current(); ++it ) {
250 if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { 253 if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) {
251// qDebug( it.current()->text(0)); 254// odebug << it.current()->text(0) << oendl;
252 searchList.append(it.current()->text(0)); 255 searchList.append(it.current()->text(0));
253 } 256 }
254 } 257 }
255 if(searchList.count() >0) 258 if(searchList.count() >0)
256 showSearchResult(searchList); 259 showSearchResult(searchList);
257 else 260 else
258 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); 261 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName);
259 }//end Inputdialog 262 }//end Inputdialog
260 delete fileDlg; 263 delete fileDlg;
261} 264}
262 265
263void Bartender::doSearchByDrink() { 266void Bartender::doSearchByDrink() {
264// if( DrinkView->currentItem() == NULL) return; 267// if( DrinkView->currentItem() == NULL) return;
265 QStringList searchList; 268 QStringList searchList;
266 QString searchForDrinkName, lastDrinkName, tempName; 269 QString searchForDrinkName, lastDrinkName, tempName;
267 270
268 InputDialog *fileDlg; 271 InputDialog *fileDlg;
269 fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); 272 fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0);
270 fileDlg->exec(); 273 fileDlg->exec();
271 if( fileDlg->result() == 1 ) { 274 if( fileDlg->result() == 1 ) {
272 searchForDrinkName = fileDlg->LineEdit1->text(); 275 searchForDrinkName = fileDlg->LineEdit1->text();
273 276
274 dbFile.at(0); 277 dbFile.at(0);
275 QTextStream t( &dbFile); 278 QTextStream t( &dbFile);
276 279
277 QString s, s2; 280 QString s, s2;
278 while ( !t.eof()) { 281 while ( !t.eof()) {
279 s = t.readLine(); 282 s = t.readLine();
280 if(s.find("#",0,TRUE) != -1) { 283 if(s.find("#",0,TRUE) != -1) {
281 lastDrinkName=s.right(s.length()-2); 284 lastDrinkName=s.right(s.length()-2);
282// qDebug("last drink name "+lastDrinkName); 285// odebug << "last drink name "+lastDrinkName << oendl;
283 } 286 }
284 else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { 287 else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) {
285// qDebug("appending "+lastDrinkName); 288// odebug << "appending "+lastDrinkName << oendl;
286 searchList.append( lastDrinkName); 289 searchList.append( lastDrinkName);
287 tempName=lastDrinkName; 290 tempName=lastDrinkName;
288 } 291 }
289// if( dbFile.atEnd() ) break; 292// if( dbFile.atEnd() ) break;
290 293
291 } //oef 294 } //oef
292 if(searchList.count() >0) 295 if(searchList.count() >0)
293 showSearchResult(searchList); 296 showSearchResult(searchList);
294 else 297 else
295 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); 298 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName);
296 } 299 }
297 delete fileDlg; 300 delete fileDlg;
298} 301}
299 302
300void Bartender::showSearchResult(QStringList &searchList) { 303void Bartender::showSearchResult(QStringList &searchList) {
301 QString result; 304 QString result;
302 Search_Results *searchDlg; 305 Search_Results *searchDlg;
303 306
304 searchList.sort(); 307 searchList.sort();
305 308
306 searchDlg = new Search_Results(this, "Search Results", TRUE); 309 searchDlg = new Search_Results(this, "Search Results", TRUE);
307 searchDlg->ListBox1->insertStringList( searchList,-1); 310 searchDlg->ListBox1->insertStringList( searchList,-1);
308 QPEApplication::execDialog( searchDlg ); 311 QPEApplication::execDialog( searchDlg );
309 312
310 if( searchDlg->result() == 1 ) { 313 if( searchDlg->result() == 1 ) {
311 result= searchDlg->ListBox1->currentText(); 314 result= searchDlg->ListBox1->currentText();
312 } 315 }
313 QListViewItemIterator it2( DrinkView ); 316 QListViewItemIterator it2( DrinkView );
314 for ( ; it2.current(); ++it2 ) { 317 for ( ; it2.current(); ++it2 ) {
315 if ( it2.current()->text(0)== result ) { 318 if ( it2.current()->text(0)== result ) {
316// qDebug( it2.current()->text(0)); 319// odebug << it2.current()->text(0) << oendl;
317 showDrink(it2.current()); 320 showDrink(it2.current());
318 } 321 }
319 } 322 }
320delete searchDlg; 323delete searchDlg;
321} 324}
322 325
323void Bartender::doEdit() { 326void Bartender::doEdit() {
324 if(DrinkView->currentItem() == NULL) { 327 if(DrinkView->currentItem() == NULL) {
325 fileNew(); 328 fileNew();
326 } 329 }
327 330
328 QString myDrink; 331 QString myDrink;
329 myDrink= DrinkView->currentItem()->text(0); 332 myDrink= DrinkView->currentItem()->text(0);
330 dbFile.at(0); 333 dbFile.at(0);
331 int foundAt=0; 334 int foundAt=0;
332 New_Drink *newDrinks; 335 New_Drink *newDrinks;
333 newDrinks = new New_Drink(this,"Edit Drink....", TRUE); 336 newDrinks = new New_Drink(this,"Edit Drink....", TRUE);
334 QString newName, newIng; 337 QString newName, newIng;
335 QPEApplication::showDialog( newDrinks ); 338 QPEApplication::showDialog( newDrinks );
336 QTextStream t( &dbFile); 339 QTextStream t( &dbFile);
337 340
338 QString s, s2; 341 QString s, s2;
339 while ( !t.eof()) { 342 while ( !t.eof()) {
340 s = t.readLine(); 343 s = t.readLine();
341 if(s.find( myDrink, 0, TRUE) != -1) { 344 if(s.find( myDrink, 0, TRUE) != -1) {
342 foundAt = dbFile.at() - (s.length()+1); 345 foundAt = dbFile.at() - (s.length()+1);
343 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { 346 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
344 s2 = t.readLine(); 347 s2 = t.readLine();
345 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { 348 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
346// qDebug(s2); 349// odebug << s2 << oendl;
347 newDrinks->MultiLineEdit1->append(s2); 350 newDrinks->MultiLineEdit1->append(s2);
348 newDrinks->LineEdit1->setText(myDrink); 351 newDrinks->LineEdit1->setText(myDrink);
349 } 352 }
350 if( dbFile.atEnd() ) break; 353 if( dbFile.atEnd() ) break;
351 } 354 }
352 } 355 }
353 } 356 }
354 newDrinks->exec(); 357 newDrinks->exec();
355 newName = newDrinks->LineEdit1->text(); 358 newName = newDrinks->LineEdit1->text();
356 newIng= newDrinks->MultiLineEdit1->text(); 359 newIng= newDrinks->MultiLineEdit1->text();
357 360
358 if( newDrinks ->result() == 1 ) { 361 if( newDrinks ->result() == 1 ) {
359 if(dbFile.isOpen()) 362 if(dbFile.isOpen())
360 dbFile.close(); 363 dbFile.close();
361 if ( !dbFile.open( IO_ReadWrite )) { 364 if ( !dbFile.open( IO_ReadWrite )) {
362 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 365 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
363 return; 366 return;
364 } 367 }
365 int fd = dbFile.handle(); 368 int fd = dbFile.handle();
366 lseek( fd, foundAt, SEEK_SET); 369 lseek( fd, foundAt, SEEK_SET);
367 370
368// dbFile.at( foundAt); 371// dbFile.at( foundAt);
369#warning FIXME problems with editing drinks db 372#warning FIXME problems with editing drinks db
370 ////////// FIXME write to user file 373 ////////// FIXME write to user file
371 QString newDrink="# "+newName+"\n"; 374 QString newDrink="# "+newName+"\n";
372 newDrink.append(newIng+"\n"); 375 newDrink.append(newIng+"\n");
373 qDebug("writing "+newDrink); 376 odebug << "writing "+newDrink << oendl;
374 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 377 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
375 clearList(); 378 clearList();
376 379
377 dbFile.flush(); 380 dbFile.flush();
378 381
379 initDrinkDb(); 382 initDrinkDb();
380 } 383 }
381} 384}
382 385
383void Bartender::clearList() { 386void Bartender::clearList() {
384 DrinkView->clear(); 387 DrinkView->clear();
385} 388}
386 389
387void Bartender::doBac() { 390void Bartender::doBac() {
388 BacDialog *bacDlg; 391 BacDialog *bacDlg;
389 bacDlg = new BacDialog(this,"BAC",TRUE); 392 bacDlg = new BacDialog(this,"BAC",TRUE);
390 QPEApplication::execDialog( bacDlg ); 393 QPEApplication::execDialog( bacDlg );
391 delete bacDlg; 394 delete bacDlg;
392} 395}
393 396
394void Bartender::openCurrentDrink() { 397void Bartender::openCurrentDrink() {
395 if(DrinkView->currentItem() == NULL) return; 398 if(DrinkView->currentItem() == NULL) return;
396 showDrink(DrinkView->currentItem()); 399 showDrink(DrinkView->currentItem());
397} 400}
398 401
399void Bartender::fileMenuActivated( int item) { 402void Bartender::fileMenuActivated( int item) {
400 qDebug("Item %d", item); 403 odebug << "Item " << item << "" << oendl;
401 switch(item) { 404 switch(item) {
402 case -3: // new -3 405 case -3: // new -3
403 fileNew(); 406 fileNew();
404 break; 407 break;
405 case -4:// open -4 408 case -4:// open -4
406 openCurrentDrink(); 409 openCurrentDrink();
407 break; 410 break;
408 case -5:// drink -5 411 case -5:// drink -5
409 doSearchByName(); 412 doSearchByName();
410 413
411 break; 414 break;
412 case -6:// alcohol -6 415 case -6:// alcohol -6
413 doSearchByDrink(); 416 doSearchByDrink();
414 417
415 break; 418 break;
416 419
417 } 420 }
418} 421}
419 422
420void Bartender::editMenuActivated(int item) { 423void Bartender::editMenuActivated(int item) {
421 qDebug("Item %d", item); 424 odebug << "Item " << item << "" << oendl;
422 /* 425 /*
423 edit -8 426 edit -8
424 */ 427 */
425 switch(item) { 428 switch(item) {
426 case -8: 429 case -8:
427 doEdit() ; 430 doEdit() ;
428 break; 431 break;
429 432
430 } 433 }
431} 434}
432 435
diff --git a/noncore/apps/opie-bartender/bartender.pro b/noncore/apps/opie-bartender/bartender.pro
index 4ad3c31..41fc0e5 100644
--- a/noncore/apps/opie-bartender/bartender.pro
+++ b/noncore/apps/opie-bartender/bartender.pro
@@ -1,12 +1,11 @@
1TEMPLATE = app 1TEMPLATE = app
2#CONFIG = qt warn_on
3CONFIG = qt warn_on 2CONFIG = qt warn_on
4HEADERS = bartender.h newdrinks.h showdrinks.h inputDialog.h searchresults.h bac.h 3HEADERS = bartender.h newdrinks.h showdrinks.h inputDialog.h searchresults.h bac.h
5SOURCES = main.cpp bartender.cpp newdrinks.cpp showdrinks.cpp inputDialog.cpp searchresults.cpp bac.cpp 4SOURCES = main.cpp bartender.cpp newdrinks.cpp showdrinks.cpp inputDialog.cpp searchresults.cpp bac.cpp
6INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lqpe 7LIBS += -lqpe -lopiecore2
9DESTDIR = $(OPIEDIR)/bin 8DESTDIR = $(OPIEDIR)/bin
10TARGET = bartender 9TARGET = bartender
11 10
12include ( $(OPIEDIR)/include.pro ) 11include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-bartender/config.in b/noncore/apps/opie-bartender/config.in
index c6ca2e6..c39a7d6 100644
--- a/noncore/apps/opie-bartender/config.in
+++ b/noncore/apps/opie-bartender/config.in
@@ -1,4 +1,5 @@
1 config BARTENDER 1 config BARTENDER
2 boolean "bartender - bar receipe and blood alcohol estimator" 2 boolean "bartender - bar receipe and blood alcohol estimator"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
5
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index a37f980..6d57703 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -18,131 +18,135 @@
18/* If you're compiling konsole on non-Linux platforms and find 18/* If you're compiling konsole on non-Linux platforms and find
19 problems that you can track down to this file, please have 19 problems that you can track down to this file, please have
20 a look into ../README.ports, too. 20 a look into ../README.ports, too.
21*/ 21*/
22 22
23/*! \file 23/*! \file
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66#include "procctl.h"
67#include "MyPty.h"
66 68
69/* OPIE */
70#include <opie2/odebug.h>
71using namespace Opie::Core;
72
73/* QT */
67#include <qsocketnotifier.h> 74#include <qsocketnotifier.h>
68#include <qfile.h> 75#include <qfile.h>
69 76
77/* STD */
70#include <stdlib.h> 78#include <stdlib.h>
71#include <stdio.h> 79#include <stdio.h>
72#include <signal.h> 80#include <signal.h>
73#include <fcntl.h> 81#include <fcntl.h>
74#include <unistd.h> 82#include <unistd.h>
75#include <termios.h> 83#include <termios.h>
76#include <sys/types.h> 84#include <sys/types.h>
77#include <sys/ioctl.h> 85#include <sys/ioctl.h>
78#include <sys/wait.h> 86#include <sys/wait.h>
79 87
80#ifdef HAVE_OPENPTY 88#ifdef HAVE_OPENPTY
81#include <pty.h> 89#include <pty.h>
82#endif 90#endif
83 91
84#include "procctl.h"
85#include "MyPty.h"
86
87
88#undef VERBOSE_DEBUG 92#undef VERBOSE_DEBUG
89 93
90 94
91/* -------------------------------------------------------------------------- */ 95/* -------------------------------------------------------------------------- */
92 96
93/*! 97/*!
94 Informs the client program about the 98 Informs the client program about the
95 actual size of the window. 99 actual size of the window.
96*/ 100*/
97 101
98void MyPty::setSize(int lines, int columns) 102void MyPty::setSize(int lines, int columns)
99{ 103{
100 qWarning("setting size"); 104 owarn << "setting size" << oendl;
101 struct winsize wsize; 105 struct winsize wsize;
102 wsize.ws_row = (unsigned short)lines; 106 wsize.ws_row = (unsigned short)lines;
103 wsize.ws_col = (unsigned short)columns; 107 wsize.ws_col = (unsigned short)columns;
104 if(m_fd < 0) return; 108 if(m_fd < 0) return;
105 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 109 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
106} 110}
107 111
108 112
109void MyPty::donePty() 113void MyPty::donePty()
110{ 114{
111 // This is code from the Qt DumbTerminal example 115 // This is code from the Qt DumbTerminal example
112 116
113 ::close(m_fd); 117 ::close(m_fd);
114 118
115 if (m_cpid) { 119 if (m_cpid) {
116 kill(m_cpid, SIGHUP); 120 kill(m_cpid, SIGHUP);
117 //waitpid(m_cpid, &status, 0); 121 //waitpid(m_cpid, &status, 0);
118 delete m_sn_e; 122 delete m_sn_e;
119 delete m_sn_r; 123 delete m_sn_r;
120 m_sn_e = 0l; 124 m_sn_e = 0l;
121 m_sn_r = 0l; 125 m_sn_r = 0l;
122 } 126 }
123 127
124 m_cpid = 0; 128 m_cpid = 0;
125 m_fd = -1; 129 m_fd = -1;
126// emit done(status); 130// emit done(status);
127} 131}
128 132
129 133
130const char* MyPty::deviceName() 134const char* MyPty::deviceName()
131{ 135{
132 return m_ttynam; 136 return m_ttynam;
133} 137}
134 138
135 139
136void MyPty::error() 140void MyPty::error()
137{ 141{
138 // This is code from the Qt DumbTerminal example 142 // This is code from the Qt DumbTerminal example
139 donePty(); 143 donePty();
140} 144}
141 145
142void MyPty::start() { 146void MyPty::start() {
143 QStrList lis; 147 QStrList lis;
144 int r =run(m_cmd.latin1(), lis, 0, 0); 148 int r =run(m_cmd.latin1(), lis, 0, 0);
145 r = r; 149 r = r;
146} 150}
147/*! 151/*!
148 start the client program. 152 start the client program.
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index e535296..d168a5e 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -984,140 +984,140 @@ void TEWidget::setSelection(const QString& t)
984} 984}
985 985
986void TEWidget::onClearSelection() 986void TEWidget::onClearSelection()
987{ 987{
988 emit clearSelectionSignal(); 988 emit clearSelectionSignal();
989} 989}
990 990
991/* ------------------------------------------------------------------------- */ 991/* ------------------------------------------------------------------------- */
992/* */ 992/* */
993/* Keyboard */ 993/* Keyboard */
994/* */ 994/* */
995/* ------------------------------------------------------------------------- */ 995/* ------------------------------------------------------------------------- */
996 996
997//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 997//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
998// due to a bug in `QT' or the ignorance of the author to prevent 998// due to a bug in `QT' or the ignorance of the author to prevent
999// repaint events being emitted to the screen whenever one leaves 999// repaint events being emitted to the screen whenever one leaves
1000// or reenters the screen to/from another application. 1000// or reenters the screen to/from another application.
1001// 1001//
1002// Troll says one needs to change focusInEvent() and focusOutEvent(), 1002// Troll says one needs to change focusInEvent() and focusOutEvent(),
1003// which would also let you have an in-focus cursor and an out-focus 1003// which would also let you have an in-focus cursor and an out-focus
1004// cursor like xterm does. 1004// cursor like xterm does.
1005 1005
1006// for the auto-hide cursor feature, I added empty focusInEvent() and 1006// for the auto-hide cursor feature, I added empty focusInEvent() and
1007// focusOutEvent() so that update() isn't called. 1007// focusOutEvent() so that update() isn't called.
1008// For auto-hide, we need to get keypress-events, but we only get them when 1008// For auto-hide, we need to get keypress-events, but we only get them when
1009// we have focus. 1009// we have focus.
1010 1010
1011void TEWidget::doScroll(int lines) 1011void TEWidget::doScroll(int lines)
1012{ 1012{
1013 scrollbar->setValue(scrollbar->value()+lines); 1013 scrollbar->setValue(scrollbar->value()+lines);
1014} 1014}
1015 1015
1016bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1016bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1017{ 1017{
1018 if ( (e->type() == QEvent::Accel || 1018 if ( (e->type() == QEvent::Accel ||
1019 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1019 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1020 static_cast<QKeyEvent *>( e )->ignore(); 1020 static_cast<QKeyEvent *>( e )->ignore();
1021 return true; 1021 return true;
1022 } 1022 }
1023 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1023 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1024 return FALSE; // not us 1024 return FALSE; // not us
1025 if ( e->type() == QEvent::Wheel) { 1025 if ( e->type() == QEvent::Wheel) {
1026 QApplication::sendEvent(scrollbar, e); 1026 QApplication::sendEvent(scrollbar, e);
1027 } 1027 }
1028 1028
1029#ifdef FAKE_CTRL_AND_ALT 1029#ifdef FAKE_CTRL_AND_ALT
1030 static bool control = FALSE; 1030 static bool control = FALSE;
1031 static bool alt = FALSE; 1031 static bool alt = FALSE;
1032// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1032// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
1033 bool dele=FALSE; 1033 bool dele=FALSE;
1034 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1034 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1035 QKeyEvent* ke = (QKeyEvent*)e; 1035 QKeyEvent* ke = (QKeyEvent*)e;
1036 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1036 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1037 switch (ke->key()) { 1037 switch (ke->key()) {
1038 case Key_F9: // let this be "Control" 1038 case Key_F9: // let this be "Control"
1039 control = keydown; 1039 control = keydown;
1040 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1040 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1041 dele=TRUE; 1041 dele=TRUE;
1042 break; 1042 break;
1043 case Key_F13: // let this be "Alt" 1043 case Key_F13: // let this be "Alt"
1044 alt = keydown; 1044 alt = keydown;
1045 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1045 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1046 dele=TRUE; 1046 dele=TRUE;
1047 break; 1047 break;
1048 default: 1048 default:
1049 if ( control ) { 1049 if ( control ) {
1050 int a = toupper(ke->ascii())-64; 1050 int a = toupper(ke->ascii())-64;
1051 if ( a >= 0 && a < ' ' ) { 1051 if ( a >= 0 && a < ' ' ) {
1052 e = new QKeyEvent(e->type(), ke->key(), 1052 e = new QKeyEvent(e->type(), ke->key(),
1053 a, ke->state()|ControlButton, QChar(a,0)); 1053 a, ke->state()|ControlButton, QChar(a,0));
1054 dele=TRUE; 1054 dele=TRUE;
1055 } 1055 }
1056 } 1056 }
1057 if ( alt ) { 1057 if ( alt ) {
1058 e = new QKeyEvent(e->type(), ke->key(), 1058 e = new QKeyEvent(e->type(), ke->key(),
1059 ke->ascii(), ke->state()|AltButton, ke->text()); 1059 ke->ascii(), ke->state()|AltButton, ke->text());
1060 dele=TRUE; 1060 dele=TRUE;
1061 } 1061 }
1062 } 1062 }
1063 } 1063 }
1064#endif 1064#endif
1065 1065
1066 if ( e->type() == QEvent::KeyPress ) { 1066 if ( e->type() == QEvent::KeyPress ) {
1067 QKeyEvent* ke = (QKeyEvent*)e; 1067 QKeyEvent* ke = (QKeyEvent*)e;
1068 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1068 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1069 // know where the current selection is. 1069 // know where the current selection is.
1070 1070
1071// qDebug("key pressed is 0x%x",ke->key()); 1071// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
1072 1072
1073 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1073 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1074 1074
1075// qDebug("key pressed 2 is 0x%x",ke->key()); 1075// odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl;
1076 emitText("\\"); // expose 1076 emitText("\\"); // expose
1077 } else 1077 } else
1078 emit keyPressedSignal(ke); // expose 1078 emit keyPressedSignal(ke); // expose
1079 ke->accept(); 1079 ke->accept();
1080#ifdef FAKE_CTRL_AND_ALT 1080#ifdef FAKE_CTRL_AND_ALT
1081 if ( dele ) delete e; 1081 if ( dele ) delete e;
1082#endif 1082#endif
1083 return true; // stop the event 1083 return true; // stop the event
1084 } 1084 }
1085 if ( e->type() == QEvent::Enter ) { 1085 if ( e->type() == QEvent::Enter ) {
1086 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1086 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1087 this, SLOT(onClearSelection()) ); 1087 this, SLOT(onClearSelection()) );
1088 } 1088 }
1089 if ( e->type() == QEvent::Leave ) { 1089 if ( e->type() == QEvent::Leave ) {
1090 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1090 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1091 this, SLOT(onClearSelection()) ); 1091 this, SLOT(onClearSelection()) );
1092 } 1092 }
1093 return QFrame::eventFilter( obj, e ); 1093 return QFrame::eventFilter( obj, e );
1094} 1094}
1095 1095
1096/* ------------------------------------------------------------------------- */ 1096/* ------------------------------------------------------------------------- */
1097/* */ 1097/* */
1098/* Frame */ 1098/* Frame */
1099/* */ 1099/* */
1100/* ------------------------------------------------------------------------- */ 1100/* ------------------------------------------------------------------------- */
1101 1101
1102void TEWidget::frameChanged() 1102void TEWidget::frameChanged()
1103{ 1103{
1104 propagateSize(); 1104 propagateSize();
1105 update(); 1105 update();
1106} 1106}
1107 1107
1108/* ------------------------------------------------------------------------- */ 1108/* ------------------------------------------------------------------------- */
1109/* */ 1109/* */
1110/* Sound */ 1110/* Sound */
1111/* */ 1111/* */
1112/* ------------------------------------------------------------------------- */ 1112/* ------------------------------------------------------------------------- */
1113 1113
1114void TEWidget::Bell() 1114void TEWidget::Bell()
1115{ 1115{
1116 QApplication::beep(); 1116 QApplication::beep();
1117} 1117}
1118 1118
1119/* ------------------------------------------------------------------------- */ 1119/* ------------------------------------------------------------------------- */
1120/* */ 1120/* */
1121/* Auxiluary */ 1121/* Auxiluary */
1122/* */ 1122/* */
1123/* ------------------------------------------------------------------------- */ 1123/* ------------------------------------------------------------------------- */
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp
index d0169d7..6ff73af 100644
--- a/noncore/apps/opie-console/TEmulation.cpp
+++ b/noncore/apps/opie-console/TEmulation.cpp
@@ -25,96 +25,102 @@
25 Thus this module knows mainly about decoding escapes sequences and 25 Thus this module knows mainly about decoding escapes sequences and
26 is a stateless device w.r.t. the semantics. 26 is a stateless device w.r.t. the semantics.
27 27
28 It is also responsible to refresh the TEWidget by certain rules. 28 It is also responsible to refresh the TEWidget by certain rules.
29 29
30 \sa TEWidget \sa TEScreen 30 \sa TEWidget \sa TEScreen
31 31
32 \par A note on refreshing 32 \par A note on refreshing
33 33
34 Although the modifications to the current screen image could immediately 34 Although the modifications to the current screen image could immediately
35 be propagated via `TEWidget' to the graphical surface, we have chosen 35 be propagated via `TEWidget' to the graphical surface, we have chosen
36 another way here. 36 another way here.
37 37
38 The reason for doing so is twofold. 38 The reason for doing so is twofold.
39 39
40 First, experiments show that directly displaying the operation results 40 First, experiments show that directly displaying the operation results
41 in slowing down the overall performance of emulations. Displaying 41 in slowing down the overall performance of emulations. Displaying
42 individual characters using X11 creates a lot of overhead. 42 individual characters using X11 creates a lot of overhead.
43 43
44 Second, by using the following refreshing method, the screen operations 44 Second, by using the following refreshing method, the screen operations
45 can be completely separated from the displaying. This greatly simplifies 45 can be completely separated from the displaying. This greatly simplifies
46 the programmer's task of coding and maintaining the screen operations, 46 the programmer's task of coding and maintaining the screen operations,
47 since one need not worry about differential modifications on the 47 since one need not worry about differential modifications on the
48 display affecting the operation of concern. 48 display affecting the operation of concern.
49 49
50 We use a refreshing algorithm here that has been adoped from rxvt/kvt. 50 We use a refreshing algorithm here that has been adoped from rxvt/kvt.
51 51
52 By this, refreshing is driven by a timer, which is (re)started whenever 52 By this, refreshing is driven by a timer, which is (re)started whenever
53 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. 53 a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'.
54 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger 54 As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger
55 refresh. This rule suits both bulk display operation as done by curses as 55 refresh. This rule suits both bulk display operation as done by curses as
56 well as individual characters typed. 56 well as individual characters typed.
57 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). 57 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
58 58
59 Additionally, we trigger refreshing by newlines comming in to make visual 59 Additionally, we trigger refreshing by newlines comming in to make visual
60 snapshots of lists as produced by `cat', `ls' and likely programs, thereby 60 snapshots of lists as produced by `cat', `ls' and likely programs, thereby
61 producing the illusion of a permanent and immediate display operation. 61 producing the illusion of a permanent and immediate display operation.
62 62
63 As a sort of catch-all needed for cases where none of the above 63 As a sort of catch-all needed for cases where none of the above
64 conditions catch, the screen refresh is also triggered by a count 64 conditions catch, the screen refresh is also triggered by a count
65 of incoming bulks (`bulk_incnt'). 65 of incoming bulks (`bulk_incnt').
66*/ 66*/
67 67
68/* FIXME 68/* FIXME
69 - evtl. the bulk operations could be made more transparent. 69 - evtl. the bulk operations could be made more transparent.
70*/ 70*/
71 71
72#include "TEmulation.h" 72#include "TEmulation.h"
73
74/* OPIE */
75#include <opie2/odebug.h>
76using namespace Opie::Core;
77
78/* STD */
73#include <stdio.h> 79#include <stdio.h>
74#include <stdlib.h> 80#include <stdlib.h>
75#include <unistd.h> 81#include <unistd.h>
76 82
77 83
78/* ------------------------------------------------------------------------- */ 84/* ------------------------------------------------------------------------- */
79/* */ 85/* */
80/* TEmulation */ 86/* TEmulation */
81/* */ 87/* */
82/* ------------------------------------------------------------------------- */ 88/* ------------------------------------------------------------------------- */
83 89
84#define CNTL(c) ((c)-'@') 90#define CNTL(c) ((c)-'@')
85 91
86/*! 92/*!
87*/ 93*/
88 94
89TEmulation::TEmulation(TEWidget* gui) 95TEmulation::TEmulation(TEWidget* gui)
90: decoder((QTextDecoder*)NULL) 96: decoder((QTextDecoder*)NULL)
91{ 97{
92 this->gui = gui; 98 this->gui = gui;
93 99
94 screen[0] = new TEScreen(gui->Lines(),gui->Columns()); 100 screen[0] = new TEScreen(gui->Lines(),gui->Columns());
95 screen[1] = new TEScreen(gui->Lines(),gui->Columns()); 101 screen[1] = new TEScreen(gui->Lines(),gui->Columns());
96 scr = screen[0]; 102 scr = screen[0];
97 103
98 bulk_nlcnt = 0; // reset bulk newline counter 104 bulk_nlcnt = 0; // reset bulk newline counter
99 bulk_incnt = 0; // reset bulk counter 105 bulk_incnt = 0; // reset bulk counter
100 connected = FALSE; 106 connected = FALSE;
101 107
102 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); 108 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
103 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), 109 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
104 this,SLOT(onImageSizeChange(int,int))); 110 this,SLOT(onImageSizeChange(int,int)));
105 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), 111 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
106 this,SLOT(onHistoryCursorChange(int))); 112 this,SLOT(onHistoryCursorChange(int)));
107 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), 113 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
108 this,SLOT(onKeyPress(QKeyEvent*))); 114 this,SLOT(onKeyPress(QKeyEvent*)));
109 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), 115 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
110 this,SLOT(onSelectionBegin(const int,const int)) ); 116 this,SLOT(onSelectionBegin(const int,const int)) );
111 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), 117 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)),
112 this,SLOT(onSelectionExtend(const int,const int)) ); 118 this,SLOT(onSelectionExtend(const int,const int)) );
113 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), 119 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)),
114 this,SLOT(setSelection(const BOOL)) ); 120 this,SLOT(setSelection(const BOOL)) );
115 QObject::connect(gui,SIGNAL(clearSelectionSignal()), 121 QObject::connect(gui,SIGNAL(clearSelectionSignal()),
116 this,SLOT(clearSelection()) ); 122 this,SLOT(clearSelection()) );
117} 123}
118 124
119/*! 125/*!
120*/ 126*/
@@ -159,97 +165,97 @@ void TEmulation::setKeytrans(int no)
159{ 165{
160 keytrans = KeyTrans::find(no); 166 keytrans = KeyTrans::find(no);
161} 167}
162 168
163void TEmulation::setKeytrans(const char * no) 169void TEmulation::setKeytrans(const char * no)
164{ 170{
165 keytrans = KeyTrans::find(no); 171 keytrans = KeyTrans::find(no);
166} 172}
167 173
168// Interpreting Codes --------------------------------------------------------- 174// Interpreting Codes ---------------------------------------------------------
169 175
170/* 176/*
171 This section deals with decoding the incoming character stream. 177 This section deals with decoding the incoming character stream.
172 Decoding means here, that the stream is first seperated into `tokens' 178 Decoding means here, that the stream is first seperated into `tokens'
173 which are then mapped to a `meaning' provided as operations by the 179 which are then mapped to a `meaning' provided as operations by the
174 `Screen' class. 180 `Screen' class.
175*/ 181*/
176 182
177/*! 183/*!
178*/ 184*/
179 185
180void TEmulation::onRcvChar(int c) 186void TEmulation::onRcvChar(int c)
181// process application unicode input to terminal 187// process application unicode input to terminal
182// this is a trivial scanner 188// this is a trivial scanner
183{ 189{
184 c &= 0xff; 190 c &= 0xff;
185 switch (c) 191 switch (c)
186 { 192 {
187 case '\b' : scr->BackSpace(); break; 193 case '\b' : scr->BackSpace(); break;
188 case '\t' : scr->Tabulate(); break; 194 case '\t' : scr->Tabulate(); break;
189 case '\n' : scr->NewLine(); break; 195 case '\n' : scr->NewLine(); break;
190 case '\r' : scr->Return(); break; 196 case '\r' : scr->Return(); break;
191 case 0x07 : gui->Bell(); break; 197 case 0x07 : gui->Bell(); break;
192 default : scr->ShowCharacter(c); break; 198 default : scr->ShowCharacter(c); break;
193 }; 199 };
194} 200}
195 201
196/* ------------------------------------------------------------------------- */ 202/* ------------------------------------------------------------------------- */
197/* */ 203/* */
198/* Keyboard Handling */ 204/* Keyboard Handling */
199/* */ 205/* */
200/* ------------------------------------------------------------------------- */ 206/* ------------------------------------------------------------------------- */
201 207
202/*! 208/*!
203*/ 209*/
204 210
205void TEmulation::onKeyPress( QKeyEvent* ev ) 211void TEmulation::onKeyPress( QKeyEvent* ev )
206{ 212{
207 qWarning("onKeyPress,...."); 213 owarn << "onKeyPress,...." << oendl;
208 if (!connected) return; // someone else gets the keys 214 if (!connected) return; // someone else gets the keys
209 if (scr->getHistCursor() != scr->getHistLines()); 215 if (scr->getHistCursor() != scr->getHistLines());
210 scr->setHistCursor(scr->getHistLines()); 216 scr->setHistCursor(scr->getHistLines());
211 if (!ev->text().isEmpty()) 217 if (!ev->text().isEmpty())
212 { // A block of text 218 { // A block of text
213 // Note that the text is proper unicode. 219 // Note that the text is proper unicode.
214 // We should do a conversion here, but since this 220 // We should do a conversion here, but since this
215 // routine will never be used, we simply emit plain ascii. 221 // routine will never be used, we simply emit plain ascii.
216 emit sndBlock(ev->text().ascii(),ev->text().length()); 222 emit sndBlock(ev->text().ascii(),ev->text().length());
217 } 223 }
218 else if (ev->ascii()>0) 224 else if (ev->ascii()>0)
219 { unsigned char c[1]; 225 { unsigned char c[1];
220 c[0] = ev->ascii(); 226 c[0] = ev->ascii();
221 emit sndBlock((char*)c,1); 227 emit sndBlock((char*)c,1);
222 } 228 }
223} 229}
224 230
225// Unblocking, Byte to Unicode translation --------------------------------- -- 231// Unblocking, Byte to Unicode translation --------------------------------- --
226 232
227/* 233/*
228 We are doing code conversion from locale to unicode first. 234 We are doing code conversion from locale to unicode first.
229*/ 235*/
230 236
231void TEmulation::onRcvBlock(const char *s, int len) 237void TEmulation::onRcvBlock(const char *s, int len)
232{ 238{
233 bulkStart(); 239 bulkStart();
234 bulk_incnt += 1; 240 bulk_incnt += 1;
235 for (int i = 0; i < len; i++) 241 for (int i = 0; i < len; i++)
236 { 242 {
237 QString result = decoder->toUnicode(&s[i],1); 243 QString result = decoder->toUnicode(&s[i],1);
238 int reslen = result.length(); 244 int reslen = result.length();
239 for (int j = 0; j < reslen; j++) 245 for (int j = 0; j < reslen; j++)
240 onRcvChar(result[j].unicode()); 246 onRcvChar(result[j].unicode());
241 if (s[i] == '\n') bulkNewline(); 247 if (s[i] == '\n') bulkNewline();
242 } 248 }
243 bulkEnd(); 249 bulkEnd();
244} 250}
245 251
246// Selection --------------------------------------------------------------- -- 252// Selection --------------------------------------------------------------- --
247 253
248void TEmulation::onSelectionBegin(const int x, const int y) { 254void TEmulation::onSelectionBegin(const int x, const int y) {
249 if (!connected) return; 255 if (!connected) return;
250 scr->setSelBeginXY(x,y); 256 scr->setSelBeginXY(x,y);
251 showBulk(); 257 showBulk();
252} 258}
253 259
254void TEmulation::onSelectionExtend(const int x, const int y) { 260void TEmulation::onSelectionExtend(const int x, const int y) {
255 if (!connected) return; 261 if (!connected) return;
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp
index 8e91b9e..c998f96 100644
--- a/noncore/apps/opie-console/atconfigdialog.cpp
+++ b/noncore/apps/opie-console/atconfigdialog.cpp
@@ -1,61 +1,64 @@
1#include "atconfigdialog.h"
2#include "io_modem.h"
1 3
4/* OPIE */
5#include <opie2/odebug.h>
6using namespace Opie::Core;
7
8/* QT */
2#include <qlineedit.h> 9#include <qlineedit.h>
3#include <qspinbox.h> 10#include <qspinbox.h>
4#include <qlayout.h> 11#include <qlayout.h>
5#include <qcombobox.h> 12#include <qcombobox.h>
6#include <qtabwidget.h> 13#include <qtabwidget.h>
7#include <qlabel.h> 14#include <qlabel.h>
8#include <qscrollview.h> 15#include <qscrollview.h>
9 16
10#include "atconfigdialog.h"
11#include "io_modem.h"
12
13
14ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 17ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
15 : QDialog( parent, name, modal, fl ) { 18 : QDialog( parent, name, modal, fl ) {
16 19
17 20
18 setCaption( tr( "Dialing parameter setup" ) ); 21 setCaption( tr( "Dialing parameter setup" ) );
19 22
20 QVBoxLayout *layout = new QVBoxLayout( this ); 23 QVBoxLayout *layout = new QVBoxLayout( this );
21 QTabWidget *tabWidget = new QTabWidget( this ); 24 QTabWidget *tabWidget = new QTabWidget( this );
22 25
23 tabWidget->addTab( tab0( this ), tr("Settings1") ); 26 tabWidget->addTab( tab0( this ), tr("Settings1") );
24 tabWidget->addTab( tab1( this ), tr("Settings2") ); 27 tabWidget->addTab( tab1( this ), tr("Settings2") );
25 28
26 layout->addWidget( tabWidget ); 29 layout->addWidget( tabWidget );
27 30
28} 31}
29 32
30QWidget* ATConfigDialog::tab0( QWidget* parent) { 33QWidget* ATConfigDialog::tab0( QWidget* parent) {
31 34
32 35
33 QScrollView* sv = new QScrollView( parent ); 36 QScrollView* sv = new QScrollView( parent );
34 37
35 QWidget *returnWidget = new QWidget( sv->viewport() ); 38 QWidget *returnWidget = new QWidget( sv->viewport() );
36 sv->setResizePolicy( QScrollView::AutoOneFit ); 39 sv->setResizePolicy( QScrollView::AutoOneFit );
37// sv->setHScrollBarMode( QScrollView::AlwaysOff ); 40// sv->setHScrollBarMode( QScrollView::AlwaysOff );
38// sv->setFrameShape( QFrame::NoFrame ); 41// sv->setFrameShape( QFrame::NoFrame );
39 42
40 43
41 44
42 45
43 QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 ); 46 QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 );
44 47
45 QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget ); 48 QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget );
46 initStringLine = new QLineEdit( returnWidget ); 49 initStringLine = new QLineEdit( returnWidget );
47 layout->addWidget( initStringLabel, 0, 0 ); 50 layout->addWidget( initStringLabel, 0, 0 );
48 layout->addWidget( initStringLine, 0, 1 ); 51 layout->addWidget( initStringLine, 0, 1 );
49 52
50 QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget ); 53 QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget );
51 resetStringLine = new QLineEdit( returnWidget ); 54 resetStringLine = new QLineEdit( returnWidget );
52 layout->addWidget( resetStringLabel, 1, 0 ); 55 layout->addWidget( resetStringLabel, 1, 0 );
53 layout->addWidget( resetStringLine, 1, 1 ); 56 layout->addWidget( resetStringLine, 1, 1 );
54 57
55 QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget ); 58 QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget );
56 dialPref1Line = new QLineEdit( returnWidget ); 59 dialPref1Line = new QLineEdit( returnWidget );
57 layout->addWidget( dialPref1Label, 2, 0 ); 60 layout->addWidget( dialPref1Label, 2, 0 );
58 layout->addWidget( dialPref1Line, 2, 1 ); 61 layout->addWidget( dialPref1Line, 2, 1 );
59 62
60 QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget ); 63 QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget );
61 dialSuf1Line = new QLineEdit( returnWidget ); 64 dialSuf1Line = new QLineEdit( returnWidget );
@@ -107,97 +110,97 @@ QWidget* ATConfigDialog::tab1( QWidget* parent ) {
107 110
108 QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget ); 111 QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget );
109 dialTimeSpin = new QSpinBox( returnWidget ); 112 dialTimeSpin = new QSpinBox( returnWidget );
110 layout->addWidget( dialTimeLabel, 0, 0 ); 113 layout->addWidget( dialTimeLabel, 0, 0 );
111 layout->addWidget( dialTimeSpin, 0, 1 ); 114 layout->addWidget( dialTimeSpin, 0, 1 );
112 115
113 QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget ); 116 QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget );
114 delayRedialSpin = new QSpinBox( returnWidget ); 117 delayRedialSpin = new QSpinBox( returnWidget );
115 layout->addWidget( delayRedialLabel, 1, 0 ); 118 layout->addWidget( delayRedialLabel, 1, 0 );
116 layout->addWidget( delayRedialSpin, 1, 1 ); 119 layout->addWidget( delayRedialSpin, 1, 1 );
117 120
118 QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget ); 121 QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget );
119 numberTriesSpin = new QSpinBox( returnWidget ); 122 numberTriesSpin = new QSpinBox( returnWidget );
120 layout->addWidget( numberTriesLabel, 2, 0 ); 123 layout->addWidget( numberTriesLabel, 2, 0 );
121 layout->addWidget( numberTriesSpin, 2, 1 ); 124 layout->addWidget( numberTriesSpin, 2, 1 );
122 125
123 QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget ); 126 QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget );
124 dtrDropTimeSpin = new QSpinBox( returnWidget ); 127 dtrDropTimeSpin = new QSpinBox( returnWidget );
125 layout->addWidget( dtrDropTimeLabel, 3, 0 ); 128 layout->addWidget( dtrDropTimeLabel, 3, 0 );
126 layout->addWidget( dtrDropTimeSpin, 3, 1 ); 129 layout->addWidget( dtrDropTimeSpin, 3, 1 );
127 130
128 QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget ); 131 QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget );
129 bpsDetectBox = new QComboBox( returnWidget ); 132 bpsDetectBox = new QComboBox( returnWidget );
130 layout->addWidget( bpsDetectLabel, 4, 0 ); 133 layout->addWidget( bpsDetectLabel, 4, 0 );
131 layout->addWidget( bpsDetectBox, 4, 1 ); 134 layout->addWidget( bpsDetectBox, 4, 1 );
132 bpsDetectBox->insertItem( tr("No") ); 135 bpsDetectBox->insertItem( tr("No") );
133 bpsDetectBox->insertItem( tr("Yes") ); 136 bpsDetectBox->insertItem( tr("Yes") );
134 137
135 QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget ); 138 QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget );
136 dcdLinesBox = new QComboBox( returnWidget ); 139 dcdLinesBox = new QComboBox( returnWidget );
137 layout->addWidget( dcdLinesLabel, 5, 0 ); 140 layout->addWidget( dcdLinesLabel, 5, 0 );
138 layout->addWidget( dcdLinesBox, 5, 1 ); 141 layout->addWidget( dcdLinesBox, 5, 1 );
139 dcdLinesBox->insertItem( tr("No") ); 142 dcdLinesBox->insertItem( tr("No") );
140 dcdLinesBox->insertItem( tr("Yes") ); 143 dcdLinesBox->insertItem( tr("Yes") );
141 144
142 QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget ); 145 QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget );
143 multiLineUntagBox = new QComboBox( returnWidget ); 146 multiLineUntagBox = new QComboBox( returnWidget );
144 layout->addWidget( multiLineUntagLabel, 6, 0 ); 147 layout->addWidget( multiLineUntagLabel, 6, 0 );
145 layout->addWidget( multiLineUntagBox, 6, 1 ); 148 layout->addWidget( multiLineUntagBox, 6, 1 );
146 multiLineUntagBox->insertItem( tr("No") ); 149 multiLineUntagBox->insertItem( tr("No") );
147 multiLineUntagBox->insertItem( tr("Yes") ); 150 multiLineUntagBox->insertItem( tr("Yes") );
148 151
149 return returnWidget; 152 return returnWidget;
150 153
151} 154}
152 155
153 156
154void ATConfigDialog::readConfig( const Profile& config ) { 157void ATConfigDialog::readConfig( const Profile& config ) {
155 qWarning("config in atconfigdialog"); 158 owarn << "config in atconfigdialog" << oendl;
156 159
157 initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); 160 initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
158 resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); 161 resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
159 dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 162 dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
160 dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 163 dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
161 dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 164 dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
162 dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 165 dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
163 dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 166 dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
164 dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 167 dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
165 connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) ); 168 connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) );
166 hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 169 hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
167 dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) ); 170 dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) );
168 delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) ); 171 delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) );
169 numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) ); 172 numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) );
170 dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) ); 173 dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) );
171 bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) ); 174 bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) );
172 dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) ); 175 dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) );
173 multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) ); 176 multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) );
174 177
175 // Not implemented yet 178 // Not implemented yet
176 resetStringLine->setEnabled(false); 179 resetStringLine->setEnabled(false);
177 dialSuf1Line->setEnabled(false); 180 dialSuf1Line->setEnabled(false);
178 dialPref2Line->setEnabled(false); 181 dialPref2Line->setEnabled(false);
179 dialSuf2Line->setEnabled(false); 182 dialSuf2Line->setEnabled(false);
180 dialPref3Line->setEnabled(false); 183 dialPref3Line->setEnabled(false);
181 dialSuf3Line->setEnabled(false); 184 dialSuf3Line->setEnabled(false);
182 dialTimeSpin->setEnabled(false); 185 dialTimeSpin->setEnabled(false);
183 delayRedialSpin->setEnabled(false); 186 delayRedialSpin->setEnabled(false);
184 numberTriesSpin->setEnabled(false); 187 numberTriesSpin->setEnabled(false);
185 dtrDropTimeSpin->setEnabled(false); 188 dtrDropTimeSpin->setEnabled(false);
186 bpsDetectBox->setEnabled(false); 189 bpsDetectBox->setEnabled(false);
187 dcdLinesBox->setEnabled(false); 190 dcdLinesBox->setEnabled(false);
188 multiLineUntagBox->setEnabled(false); 191 multiLineUntagBox->setEnabled(false);
189} 192}
190 193
191void ATConfigDialog::writeConfig( Profile& config ) { 194void ATConfigDialog::writeConfig( Profile& config ) {
192 195
193 config.writeEntry( "InitString", initStringLine->text() ); 196 config.writeEntry( "InitString", initStringLine->text() );
194 config.writeEntry( "ResetString", resetStringLine->text() ); 197 config.writeEntry( "ResetString", resetStringLine->text() );
195 config.writeEntry( "DialPrefix1", dialPref1Line->text() ); 198 config.writeEntry( "DialPrefix1", dialPref1Line->text() );
196 config.writeEntry( "DialSuffix1", dialSuf1Line->text() ); 199 config.writeEntry( "DialSuffix1", dialSuf1Line->text() );
197 config.writeEntry( "DialPrefix2", dialPref2Line->text() ); 200 config.writeEntry( "DialPrefix2", dialPref2Line->text() );
198 config.writeEntry( "DialSuffix2", dialSuf2Line->text() ); 201 config.writeEntry( "DialSuffix2", dialSuf2Line->text() );
199 config.writeEntry( "DialPrefix3", dialPref3Line->text() ); 202 config.writeEntry( "DialPrefix3", dialPref3Line->text() );
200 config.writeEntry( "DialSuffix3", dialSuf3Line->text() ); 203 config.writeEntry( "DialSuffix3", dialSuf3Line->text() );
201 config.writeEntry( "DefaultConnect", connectLine->text() ); 204 config.writeEntry( "DefaultConnect", connectLine->text() );
202 config.writeEntry( "HangupString", hangupLine->text() ); 205 config.writeEntry( "HangupString", hangupLine->text() );
203 config.writeEntry( "DialTime", dialTimeSpin->value() ); 206 config.writeEntry( "DialTime", dialTimeSpin->value() );
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 67ad10e..7010594 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -1,302 +1,307 @@
1#include "dialer.h" 1#include "dialer.h"
2#include "io_modem.h"
3
4/* OPIE */
5#include <opie2/odebug.h>
6using namespace Opie::Core;
2 7
8/* QT */
3#include <qlayout.h> 9#include <qlayout.h>
4#include <qprogressbar.h> 10#include <qprogressbar.h>
5#include <qlabel.h> 11#include <qlabel.h>
6#include <qpushbutton.h> 12#include <qpushbutton.h>
7#include <qapp.h> 13#include <qapp.h>
8#include <qtimer.h> 14#include <qtimer.h>
9#include <qmessagebox.h> 15#include <qmessagebox.h>
10 16
17/* STD */
11#include <unistd.h> 18#include <unistd.h>
12#include <string.h> 19#include <string.h>
13#include <fcntl.h> 20#include <fcntl.h>
14#include <errno.h> 21#include <errno.h>
15 22
16#include "io_modem.h"
17
18// State machine: | When an error occurs, we don't have to 23// State machine: | When an error occurs, we don't have to
19// | reset everything. 24// | reset everything.
20// (init) <------+ | But if the user wants to reset, 25// (init) <------+ | But if the user wants to reset,
21// | | | we stop dialing immediately. 26// | | | we stop dialing immediately.
22// v | | 27// v | |
23// (options) ----+ | Following the state machine is necessary 28// (options) ----+ | Following the state machine is necessary
24// | \ | to get determinable results. 29// | \ | to get determinable results.
25// v ^ | 30// v ^ |
26// (dial) ----+ | 31// (dial) ----+ |
27// | ^ | 32// | ^ |
28// v | | 33// v | |
29// (online) --+ | 34// (online) --+ |
30// | | 35// | |
31// v | 36// v |
32 37
33 38
34// from atconfigdialog 39// from atconfigdialog
35//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); 40//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
36//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); 41//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
37//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 42//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
38//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 43//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
39//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 44//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
40//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 45//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
41//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 46//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
42//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 47//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
43//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); 48//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
44//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 49//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
45 50
46// from modemconfigwidget 51// from modemconfigwidget
47//int rad_flow = prof.readNumEntry("Flow"); 52//int rad_flow = prof.readNumEntry("Flow");
48//int rad_parity = prof.readNumEntry("Parity"); 53//int rad_parity = prof.readNumEntry("Parity");
49//int speed = prof.readNumEntry("Speed"); 54//int speed = prof.readNumEntry("Speed");
50//QString number = prof.readEntry("Number"); 55//QString number = prof.readEntry("Number");
51 56
52Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) 57Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
53: QDialog(parent, name, true), m_fd(fd), m_profile(profile) 58: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
54{ 59{
55 QVBoxLayout *vbox; 60 QVBoxLayout *vbox;
56 QLabel *desc; 61 QLabel *desc;
57 62
58 63
59 usercancel = 0; 64 usercancel = 0;
60 cleanshutdown = 0; 65 cleanshutdown = 0;
61 66
62 67
63 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); 68 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
64 progress = new QProgressBar(this); 69 progress = new QProgressBar(this);
65 status = new QLabel("", this); 70 status = new QLabel("", this);
66 status->setFrameStyle(QFrame::Panel | QFrame::Sunken); 71 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
67 cancel = new QPushButton(QObject::tr("Cancel"), this); 72 cancel = new QPushButton(QObject::tr("Cancel"), this);
68 73
69 vbox = new QVBoxLayout(this, 2); 74 vbox = new QVBoxLayout(this, 2);
70 vbox->add(desc); 75 vbox->add(desc);
71 vbox->add(progress); 76 vbox->add(progress);
72 vbox->add(status); 77 vbox->add(status);
73 vbox->add(cancel); 78 vbox->add(cancel);
74 79
75 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 80 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
76 81
77 show(); 82 show();
78 83
79 QTimer::singleShot(500, this, SLOT(slotAutostart())); 84 QTimer::singleShot(500, this, SLOT(slotAutostart()));
80} 85}
81 86
82Dialer::~Dialer() 87Dialer::~Dialer()
83{ 88{
84} 89}
85 90
86void Dialer::setHangupOnly() 91void Dialer::setHangupOnly()
87{ 92{
88 state = state_cancel; 93 state = state_cancel;
89 usercancel = 1; 94 usercancel = 1;
90 send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" ); 95 send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" );
91} 96}
92 97
93void Dialer::slotCancel() 98void Dialer::slotCancel()
94{ 99{
95 if(state != state_online) 100 if(state != state_online)
96 { 101 {
97 usercancel = 1; 102 usercancel = 1;
98 reset(); 103 reset();
99 } 104 }
100 else { 105 else {
101 accept(); 106 accept();
102 } 107 }
103} 108}
104 109
105void Dialer::reset() 110void Dialer::reset()
106{ 111{
107 qWarning("reset"); 112 owarn << "reset" << oendl;
108 switchState(state_cancel); 113 switchState(state_cancel);
109} 114}
110 115
111void Dialer::slotAutostart() 116void Dialer::slotAutostart()
112{ 117{
113 //state = state_preinit; 118 //state = state_preinit;
114 dial(m_profile.readEntry("Number")); 119 dial(m_profile.readEntry("Number"));
115} 120}
116 121
117void Dialer::dial(const QString& number) 122void Dialer::dial(const QString& number)
118{ 123{
119 while(state != state_online) 124 while(state != state_online)
120 { 125 {
121 if(!usercancel) 126 if(!usercancel)
122 { 127 {
123 state = state_preinit; 128 state = state_preinit;
124 trydial(number); 129 trydial(number);
125 } 130 }
126 else break; 131 else break;
127 } 132 }
128 133
129 if(usercancel) 134 if(usercancel)
130 { 135 {
131 // modem hangup 136 // modem hangup
132 trydial(QString::null); 137 trydial(QString::null);
133 reject(); 138 reject();
134 } 139 }
135} 140}
136 141
137void Dialer::trydial(const QString& number) 142void Dialer::trydial(const QString& number)
138{ 143{
139 qWarning("TryDial:%s", number.latin1() ); 144 owarn << "TryDial:" << number.latin1() << "" << oendl;
140 if(state != state_cancel) switchState(state_preinit); 145 if(state != state_cancel) switchState(state_preinit);
141 if(cleanshutdown) 146 if(cleanshutdown)
142 { 147 {
143 qWarning("HangupString " + m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING)); 148 owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl;
144 send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); 149 send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r");
145 } 150 }
146 151
147 if(state != state_cancel) 152 if(state != state_cancel)
148 { 153 {
149 switchState(state_init); 154 switchState(state_init);
150// qWarning("Init String " + m_profile.readEntry("InitString") ); 155// owarn << "Init String " + m_profile.readEntry("InitString") << oendl;
151 send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); 156 send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r");
152 QString response2 = receive(); 157 QString response2 = receive();
153 if(!response2.contains("\nOK\r")) 158 if(!response2.contains("\nOK\r"))
154 reset(); 159 reset();
155 } 160 }
156 161
157 /*if(state != state_cancel) 162 /*if(state != state_cancel)
158 { 163 {
159 switchState(state_options); 164 switchState(state_options);
160 165
161 qWarning("ATM3l3"); 166 owarn << "ATM3l3" << oendl;
162 send("ATM3L3\r"); 167 send("ATM3L3\r");
163 QString response3 = receive(); 168 QString response3 = receive();
164 if(!response3.contains("\nOK\r")) 169 if(!response3.contains("\nOK\r"))
165 reset(); 170 reset();
166 } 171 }
167*/ 172*/
168 173
169 if(state != state_cancel) 174 if(state != state_cancel)
170 { 175 {
171 switchState(state_dialtone); 176 switchState(state_dialtone);
172 177
173 send("ATX1\r"); 178 send("ATX1\r");
174 QString response4 = receive(); 179 QString response4 = receive();
175 if(!response4.contains("\nOK\r")) 180 if(!response4.contains("\nOK\r"))
176 reset(); 181 reset();
177 } 182 }
178 183
179 if(state != state_cancel) 184 if(state != state_cancel)
180 { 185 {
181 qWarning("progress"); 186 owarn << "progress" << oendl;
182 switchState(state_dialing); 187 switchState(state_dialing);
183 188
184 // send(QString("ATDT %1\r").arg(number)); 189 // send(QString("ATDT %1\r").arg(number));
185 send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) 190 send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ))
186 .arg(number)); 191 .arg(number));
187 192
188 QString response5 = receive(); 193 QString response5 = receive();
189 if(!response5.contains("CONNECT") ) 194 if(!response5.contains("CONNECT") )
190 { 195 {
191 if(response5.contains("BUSY")) 196 if(response5.contains("BUSY"))
192 switchState(state_dialing); 197 switchState(state_dialing);
193 else 198 else
194 { 199 {
195 QMessageBox::warning(this, 200 QMessageBox::warning(this,
196 QObject::tr("Failure"), 201 QObject::tr("Failure"),
197 QObject::tr("Dialing the number failed.")); 202 QObject::tr("Dialing the number failed."));
198 slotCancel(); 203 slotCancel();
199 } 204 }
200 } 205 }
201 } 206 }
202 207
203 208
204 if(state != state_cancel) 209 if(state != state_cancel)
205 { 210 {
206 state = state_online; 211 state = state_online;
207 slotCancel(); 212 slotCancel();
208 } 213 }
209} 214}
210 215
211void Dialer::send(const QString& msg) 216void Dialer::send(const QString& msg)
212{ 217{
213 QString m = msg; 218 QString m = msg;
214 int bytes; 219 int bytes;
215 QString termination; 220 QString termination;
216 221
217 qWarning("Sending: %s", m.latin1()); 222 owarn << "Sending: " << m.latin1() << "" << oendl;
218 223
219 /*termination = "\r"; 224 /*termination = "\r";
220 //termination = m_profile.readEntry("Termination"); 225 //termination = m_profile.readEntry("Termination");
221 if(termination == "\n") m = m + "\n"; 226 if(termination == "\n") m = m + "\n";
222 else if(termination == "\r") m = m + "\r"; 227 else if(termination == "\r") m = m + "\r";
223 else m = m + "\r\n"; 228 else m = m + "\r\n";
224*/ 229*/
225 m = m.replace(QRegExp("\n"), "\r"); 230 m = m.replace(QRegExp("\n"), "\r");
226 231
227 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); 232 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
228 if(bytes < 0) 233 if(bytes < 0)
229 { 234 {
230 reset(); 235 reset();
231 } 236 }
232} 237}
233 238
234QString Dialer::receive() 239QString Dialer::receive()
235{ 240{
236 QString buf; 241 QString buf;
237 char buffer[1024]; 242 char buffer[1024];
238 int ret; 243 int ret;
239 int counter = 0; 244 int counter = 0;
240 245
241 while(1) 246 while(1)
242 { 247 {
243 ret = ::read(m_fd, buffer, sizeof(buffer)); 248 ret = ::read(m_fd, buffer, sizeof(buffer));
244 249
245 if(ret > 0) 250 if(ret > 0)
246 { 251 {
247 for(int i = 0; i < ret; i++) 252 for(int i = 0; i < ret; i++)
248 buffer[i] = buffer[i] & 0x7F; 253 buffer[i] = buffer[i] & 0x7F;
249 buffer[ret] = 0; 254 buffer[ret] = 0;
250 qWarning("Got: %s", buffer); 255 owarn << "Got: " << buffer << "" << oendl;
251 buf.append(QString(buffer)); 256 buf.append(QString(buffer));
252 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) 257 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
253 { 258 {
254 //qWarning("Receiving: '%s'", buf.latin1()); 259 //owarn << "Receiving: '" << buf.latin1() << "'" << oendl;
255 cleanshutdown = 1; 260 cleanshutdown = 1;
256 return buf; 261 return buf;
257 }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { 262 }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) {
258 cleanshutdown = 1; 263 cleanshutdown = 1;
259 return QString::null; 264 return QString::null;
260 } 265 }
261 } 266 }
262 else if(ret < 0) 267 else if(ret < 0)
263 { 268 {
264 if(errno != EAGAIN) reset(); 269 if(errno != EAGAIN) reset();
265 else if(!(counter++ % 100)) qApp->processEvents(); 270 else if(!(counter++ % 100)) qApp->processEvents();
266 } 271 }
267 else if(!(counter++ % 100)) qApp->processEvents(); 272 else if(!(counter++ % 100)) qApp->processEvents();
268 273
269 if(usercancel) return QString::null; 274 if(usercancel) return QString::null;
270 } 275 }
271 276
272 cleanshutdown = 1; 277 cleanshutdown = 1;
273 return QString::null; 278 return QString::null;
274} 279}
275 280
276void Dialer::switchState(int newstate) 281void Dialer::switchState(int newstate)
277{ 282{
278 int oldstate = state; 283 int oldstate = state;
279 state = newstate; 284 state = newstate;
280 285
281 switch(state) 286 switch(state)
282 { 287 {
283 case state_cancel: 288 case state_cancel:
284 status->setText(QObject::tr("Cancelling...")); 289 status->setText(QObject::tr("Cancelling..."));
285 progress->setProgress(0); 290 progress->setProgress(0);
286 break; 291 break;
287 case state_preinit: 292 case state_preinit:
288 status->setText(QObject::tr("Searching modem")); 293 status->setText(QObject::tr("Searching modem"));
289 progress->setProgress(10); 294 progress->setProgress(10);
290 break; 295 break;
291 case state_init: 296 case state_init:
292 status->setText(QObject::tr("Initializing...")); 297 status->setText(QObject::tr("Initializing..."));
293 progress->setProgress(20); 298 progress->setProgress(20);
294 break; 299 break;
295 case state_options: 300 case state_options:
296 status->setText(QObject::tr("Reset speakers")); 301 status->setText(QObject::tr("Reset speakers"));
297 progress->setProgress(30); 302 progress->setProgress(30);
298 break; 303 break;
299 case state_dialtone: 304 case state_dialtone:
300 status->setText(QObject::tr("Turning off dialtone")); 305 status->setText(QObject::tr("Turning off dialtone"));
301 progress->setProgress(40); 306 progress->setProgress(40);
302 break; 307 break;
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 99d069f..89b70c6 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,55 +1,57 @@
1
2#include "TEmuVt102.h" 1#include "TEmuVt102.h"
3
4#include "profile.h" 2#include "profile.h"
5#include "emulation_handler.h" 3#include "emulation_handler.h"
6#include "script.h" 4#include "script.h"
7 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
9
8EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
9 : QObject(0, name ) 11 : QObject(0, name )
10{ 12{
11 m_teWid = new TEWidget( parent, "TerminalMain"); 13 m_teWid = new TEWidget( parent, "TerminalMain");
12 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 14 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
13 // use setWrapAt(80) for normal console with scrollbar 15 // use setWrapAt(80) for normal console with scrollbar
14 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 16 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
15 m_teWid->setMinimumSize(150, 70 ); 17 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0; 18 m_script = 0;
17 parent->resize( m_teWid->calcSize(80, 24 ) ); 19 parent->resize( m_teWid->calcSize(80, 24 ) );
18 m_teEmu = new TEmuVt102(m_teWid ); 20 m_teEmu = new TEmuVt102(m_teWid );
19 21
20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), 22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
21 this, SIGNAL(changeSize(int,int) ) ); 23 this, SIGNAL(changeSize(int,int) ) );
22 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), 24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
23 this, SLOT(recvEmulation(const char*,int) ) ); 25 this, SLOT(recvEmulation(const char*,int) ) );
24 m_teEmu->setConnect( true ); 26 m_teEmu->setConnect( true );
25 m_teEmu->setHistory( TRUE ); 27 m_teEmu->setHistory( TRUE );
26 load( prof ); 28 load( prof );
27 29
28 30
29 31
30} 32}
31TEmulation* EmulationHandler::emulation() { 33TEmulation* EmulationHandler::emulation() {
32 return m_teEmu; 34 return m_teEmu;
33} 35}
34EmulationHandler::~EmulationHandler() { 36EmulationHandler::~EmulationHandler() {
35 if (isRecording()) 37 if (isRecording())
36 clearScript(); 38 clearScript();
37 delete m_teEmu; 39 delete m_teEmu;
38 delete m_teWid; 40 delete m_teWid;
39} 41}
40 42
41void EmulationHandler::load( const Profile& prof) { 43void EmulationHandler::load( const Profile& prof) {
42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 44 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
43 int num = prof.readNumEntry("Color"); 45 int num = prof.readNumEntry("Color");
44 setColor( foreColor(num), backColor(num) ); 46 setColor( foreColor(num), backColor(num) );
45 m_teWid->setBackgroundColor(backColor(num) ); 47 m_teWid->setBackgroundColor(backColor(num) );
46 48
47 int term = prof.readNumEntry("Terminal", 0) ; 49 int term = prof.readNumEntry("Terminal", 0) ;
48 switch(term) { 50 switch(term) {
49 default: 51 default:
50 case Profile::VT102: 52 case Profile::VT102:
51 case Profile::VT100: 53 case Profile::VT100:
52 m_teEmu->setKeytrans("vt100.keytab"); 54 m_teEmu->setKeytrans("vt100.keytab");
53 break; 55 break;
54 case Profile::Linux: 56 case Profile::Linux:
55 m_teEmu->setKeytrans("linux.keytab"); 57 m_teEmu->setKeytrans("linux.keytab");
@@ -83,124 +85,124 @@ void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
83 for (int i = 0; i < TABLE_COLORS; i++ ) { 85 for (int i = 0; i < TABLE_COLORS; i++ ) {
84 if ( i == 0 || i == 10 ) { 86 if ( i == 0 || i == 10 ) {
85 table[i].color = fore; 87 table[i].color = fore;
86 }else if ( i == 1 || i == 11 ) { 88 }else if ( i == 1 || i == 11 ) {
87 table[i].color = back; 89 table[i].color = back;
88 table[i].transparent = 0; 90 table[i].transparent = 0;
89 }else { 91 }else {
90 table[i].color = defaultCt[i].color; 92 table[i].color = defaultCt[i].color;
91 } 93 }
92 } 94 }
93 m_teWid->setColorTable(table ); 95 m_teWid->setColorTable(table );
94 m_teWid->update(); 96 m_teWid->update();
95} 97}
96QFont EmulationHandler::font( int id ) { 98QFont EmulationHandler::font( int id ) {
97 QString name; 99 QString name;
98 int size = 0; 100 int size = 0;
99 switch(id ) { 101 switch(id ) {
100 default: // fall through 102 default: // fall through
101 case 0: 103 case 0:
102 name = QString::fromLatin1("Micro"); 104 name = QString::fromLatin1("Micro");
103 size = 4; 105 size = 4;
104 break; 106 break;
105 case 1: 107 case 1:
106 name = QString::fromLatin1("Fixed"); 108 name = QString::fromLatin1("Fixed");
107 size = 7; 109 size = 7;
108 break; 110 break;
109 case 2: 111 case 2:
110 name = QString::fromLatin1("Fixed"); 112 name = QString::fromLatin1("Fixed");
111 size = 12; 113 size = 12;
112 break; 114 break;
113 } 115 }
114 QFont font(name, size, QFont::Normal ); 116 QFont font(name, size, QFont::Normal );
115 font.setFixedPitch(TRUE ); 117 font.setFixedPitch(TRUE );
116 return font; 118 return font;
117} 119}
118QColor EmulationHandler::foreColor(int col) { 120QColor EmulationHandler::foreColor(int col) {
119 QColor co; 121 QColor co;
120 /* we need to switch it */ 122 /* we need to switch it */
121 switch( col ) { 123 switch( col ) {
122 default: 124 default:
123 case Profile::White: 125 case Profile::White:
124 /* color is black */ 126 /* color is black */
125 co = Qt::white; 127 co = Qt::white;
126 break; 128 break;
127 case Profile::Black: 129 case Profile::Black:
128 co = Qt::black; 130 co = Qt::black;
129 break; 131 break;
130 case Profile::Green: 132 case Profile::Green:
131 qWarning("Foreground green"); 133 owarn << "Foreground green" << oendl;
132 co = Qt::green; 134 co = Qt::green;
133 break; 135 break;
134 case Profile::Orange: 136 case Profile::Orange:
135 qWarning("Foreground orange"); 137 owarn << "Foreground orange" << oendl;
136 co.setRgb( 231, 184, 98 ); 138 co.setRgb( 231, 184, 98 );
137 break; 139 break;
138 } 140 }
139 141
140 return co; 142 return co;
141} 143}
142QColor EmulationHandler::backColor(int col ) { 144QColor EmulationHandler::backColor(int col ) {
143 QColor co; 145 QColor co;
144 /* we need to switch it */ 146 /* we need to switch it */
145 switch( col ) { 147 switch( col ) {
146 default: 148 default:
147 case Profile::White: 149 case Profile::White:
148 /* color is white */ 150 /* color is white */
149 co = Qt::black; 151 co = Qt::black;
150 break; 152 break;
151 case Profile::Black: 153 case Profile::Black:
152 co = Qt::white; 154 co = Qt::white;
153 break; 155 break;
154 case Profile::Green: 156 case Profile::Green:
155 qWarning("Background black"); 157 owarn << "Background black" << oendl;
156 co = Qt::black; 158 co = Qt::black;
157 break; 159 break;
158 case Profile::Orange: 160 case Profile::Orange:
159 qWarning("Background black"); 161 owarn << "Background black" << oendl;
160 co = Qt::black; 162 co = Qt::black;
161 break; 163 break;
162 } 164 }
163 165
164 return co; 166 return co;
165} 167}
166 168
167QPushButton* EmulationHandler::cornerButton() { 169QPushButton* EmulationHandler::cornerButton() {
168 return m_teWid->cornerButton(); 170 return m_teWid->cornerButton();
169} 171}
170 172
171 173
172Script *EmulationHandler::script() { 174Script *EmulationHandler::script() {
173 return m_script; 175 return m_script;
174} 176}
175 177
176bool EmulationHandler::isRecording() { 178bool EmulationHandler::isRecording() {
177 return (m_script != 0); 179 return (m_script != 0);
178} 180}
179 181
180void EmulationHandler::startRecording() { 182void EmulationHandler::startRecording() {
181 if (!isRecording()) 183 if (!isRecording())
182 m_script = new Script(); 184 m_script = new Script();
183} 185}
184 186
185void EmulationHandler::clearScript() { 187void EmulationHandler::clearScript() {
186 if (isRecording()) { 188 if (isRecording()) {
187 delete m_script; 189 delete m_script;
188 m_script = 0; 190 m_script = 0;
189 } 191 }
190} 192}
191 193
192void EmulationHandler::runScript(const Script *script) { 194void EmulationHandler::runScript(const Script *script) {
193 emit send(script->script()); 195 emit send(script->script());
194} 196}
195 197
196void EmulationHandler::copy() { 198void EmulationHandler::copy() {
197 m_teWid->emitSelection(); 199 m_teWid->emitSelection();
198} 200}
199void EmulationHandler::paste() { 201void EmulationHandler::paste() {
200 m_teWid->pasteClipboard(); 202 m_teWid->pasteClipboard();
201} 203}
202 204
203void EmulationHandler::setWrap(int columns) { 205void EmulationHandler::setWrap(int columns) {
204 m_teWid->setWrapAt(columns); 206 m_teWid->setWrapAt(columns);
205} 207}
206 208
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index ad8ecba..4688551 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -179,123 +179,123 @@ void EmulationWidget::paintEvent( QPaintEvent* pe )
179{ 179{
180 QPainter painter; 180 QPainter painter;
181 const QPixmap* pm = backgroundPixmap(); 181 const QPixmap* pm = backgroundPixmap();
182 182
183 painter.begin( this ); 183 painter.begin( this );
184 painter.setBackgroundMode( TransparentMode ); 184 painter.setBackgroundMode( TransparentMode );
185 185
186 QRect rect = pe->rect().intersect( contentsRect() ); 186 QRect rect = pe->rect().intersect( contentsRect() );
187 QPoint tL = contentsRect().topLeft(); 187 QPoint tL = contentsRect().topLeft();
188 int tLx = tL.x(); 188 int tLx = tL.x();
189 int tLy = tL.y(); 189 int tLy = tL.y();
190 190
191 int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); 191 int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width));
192 int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); 192 int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height));
193 int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); 193 int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width));
194 int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); 194 int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height));
195 195
196 QChar *disstrU = new QChar[m_columns]; 196 QChar *disstrU = new QChar[m_columns];
197 for (int y = luy; y <= rly; y++) 197 for (int y = luy; y <= rly; y++)
198 for (int x = lux; x <= rlx; x++) 198 for (int x = lux; x <= rlx; x++)
199 { 199 {
200 int len = 1; 200 int len = 1;
201 disstrU[0] = vt100extended(m_image[loc(x,y)].c); 201 disstrU[0] = vt100extended(m_image[loc(x,y)].c);
202 int cf = m_image[loc(x,y)].f; 202 int cf = m_image[loc(x,y)].f;
203 int cb = m_image[loc(x,y)].b; 203 int cb = m_image[loc(x,y)].b;
204 int cr = m_image[loc(x,y)].r; 204 int cr = m_image[loc(x,y)].r;
205 while (x+len <= rlx && 205 while (x+len <= rlx &&
206 m_image[loc(x+len,y)].f == cf && 206 m_image[loc(x+len,y)].f == cf &&
207 m_image[loc(x+len,y)].b == cb && 207 m_image[loc(x+len,y)].b == cb &&
208 m_image[loc(x+len,y)].r == cr ) 208 m_image[loc(x+len,y)].r == cr )
209 { 209 {
210 disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); 210 disstrU[len] = vt100extended(m_image[loc(x+len,y)].c);
211 len += 1; 211 len += 1;
212 } 212 }
213 QString unistr(disstrU,len); 213 QString unistr(disstrU,len);
214 214
215 drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false ); 215 drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false );
216 x +=len -1; 216 x +=len -1;
217 } 217 }
218 delete [] disstrU; 218 delete [] disstrU;
219 drawFrame( &painter ); 219 drawFrame( &painter );
220 painter.end(); 220 painter.end();
221} 221}
222 222
223void EmulationWidget::calcGeometry() 223void EmulationWidget::calcGeometry()
224{ 224{
225 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); 225 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
226 226
227 qDebug( QString(" TEST").arg( contentsRect().width() ) ); 227 odebug << QString(" TEST").arg( contentsRect().width() ) << oendl;
228 qDebug( QString(" TEST").arg( contentsRect().height() ) ); 228 odebug << QString(" TEST").arg( contentsRect().height() ) << oendl;
229 qDebug("NEUER TESTT!!!!!!!!"); 229 odebug << "NEUER TESTT!!!!!!!!" << oendl;
230 230
231 switch( scrollLoc ) 231 switch( scrollLoc )
232 { 232 {
233 case SCRNONE : 233 case SCRNONE :
234 m_columns = ( contentsRect().width() -2 * rimX ) / f_width; 234 m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
235 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; 235 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
236 m_brX = m_blX; 236 m_brX = m_blX;
237 m_scrollbar->hide(); 237 m_scrollbar->hide();
238 break; 238 break;
239 case SCRLEFT : 239 case SCRLEFT :
240 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 240 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
241 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 241 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
242 m_blX = m_brX + m_scrollbar->width(); 242 m_blX = m_brX + m_scrollbar->width();
243 m_scrollbar->move( contentsRect().topLeft() ); 243 m_scrollbar->move( contentsRect().topLeft() );
244 m_scrollbar->show(); 244 m_scrollbar->show();
245 break; 245 break;
246 case SCRIGHT: 246 case SCRIGHT:
247 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 247 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
248 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 248 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
249 m_brX = m_blX; 249 m_brX = m_blX;
250 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); 250 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) );
251 m_scrollbar->show(); 251 m_scrollbar->show();
252 break; 252 break;
253 } 253 }
254 254
255 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; 255 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
256 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; 256 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
257} 257}
258 258
259void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) 259void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
260{ 260{
261 qWarning("Color1 %s", color_table[attr.b].color.name().latin1() ); 261 owarn << "Color1 " << color_table[attr.b].color.name().latin1() << "" << oendl;
262 if ( usePixmap && color_table[attr.b].transparent ) 262 if ( usePixmap && color_table[attr.b].transparent )
263 { 263 {
264 painter.setBackgroundMode( TransparentMode ); 264 painter.setBackgroundMode( TransparentMode );
265 if ( clear ) 265 if ( clear )
266 erase( rect ); 266 erase( rect );
267 } 267 }
268 else 268 else
269 { 269 {
270 if ( blinking ) 270 if ( blinking )
271 painter.fillRect( rect, color_table[attr.b].color ); 271 painter.fillRect( rect, color_table[attr.b].color );
272 else 272 else
273 { 273 {
274 painter.setBackgroundMode( OpaqueMode ); 274 painter.setBackgroundMode( OpaqueMode );
275 qWarning("Color %s", color_table[attr.b].color.name().latin1() ); 275 owarn << "Color " << color_table[attr.b].color.name().latin1() << "" << oendl;
276 painter.setBackgroundColor( color_table[attr.b].color ); 276 painter.setBackgroundColor( color_table[attr.b].color );
277 } 277 }
278 } 278 }
279 if ( color_table[attr.f].bold ) 279 if ( color_table[attr.f].bold )
280 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); 280 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
281 else 281 else
282 painter.setPen( color_table[attr.f].color ); 282 painter.setPen( color_table[attr.f].color );
283 painter.drawText( rect.x(), rect.y() + f_ascent, string ); 283 painter.drawText( rect.x(), rect.y() + f_ascent, string );
284 284
285} 285}
286 286
287 287
288/////////////////////// 288///////////////////////
289// scrollbar 289// scrollbar
290// //////////////////// 290// ////////////////////
291 291
292void EmulationWidget::scroll( int value ) 292void EmulationWidget::scroll( int value )
293{ 293{
294} 294}
295 295
296void EmulationWidget::setScroll( int cursor, int slines ) 296void EmulationWidget::setScroll( int cursor, int slines )
297{ 297{
298} 298}
299 299
300 300
301 301
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index eb32551..6613183 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,88 +1,93 @@
1#include "function_keyboard.h" 1#include "function_keyboard.h"
2 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
3#include <qlayout.h> 8#include <qlayout.h>
4#include <qlistbox.h> 9#include <qlistbox.h>
5#include <qlabel.h> 10#include <qlabel.h>
6#include <qdir.h> 11#include <qdir.h>
7 12
8#define DEFAULT_ROWS 2 13#define DEFAULT_ROWS 2
9#define DEFAULT_COLS 12 14#define DEFAULT_COLS 12
10 15
11/* FunctionKeyboard {{{1 */ 16/* FunctionKeyboard {{{1 */
12 17
13FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 18FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
14 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), 19 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
15 pressedRow(0), pressedCol(0) { 20 pressedRow(0), pressedCol(0) {
16 21
17 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 22 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
18 23
19 /* 24 /*
20 * all the saving/loading is now done in a profile. downside is that you cant modify 25 * all the saving/loading is now done in a profile. downside is that you cant modify
21 * the keyboard for all profiles, but must do it on a profile-basis 26 * the keyboard for all profiles, but must do it on a profile-basis
22 * 27 *
23 28
24 Config conf("opie-console-keys"); 29 Config conf("opie-console-keys");
25 conf.setGroup("keys"); 30 conf.setGroup("keys");
26 for (uint r = 0; r < numRows; r++) 31 for (uint r = 0; r < numRows; r++)
27 for (uint c = 0; c < numCols; c++) { 32 for (uint c = 0; c < numCols; c++) {
28 33
29 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 34 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
30 QStringList value_list = conf.readListEntry( handle, '|'); 35 QStringList value_list = conf.readListEntry( handle, '|');
31 36
32 if (value_list.isEmpty()) continue; 37 if (value_list.isEmpty()) continue;
33 38
34 keys.insert( 39 keys.insert(
35 40
36 handle, 41 handle,
37 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) 42 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
38 ); 43 );
39 } 44 }
40 //qWarning("loaded %d keys", keys.count()); 45 //owarn << "loaded " << keys.count() << " keys" << oendl;
41 */ 46 */
42 if (keys.isEmpty()) loadDefaults(); 47 if (keys.isEmpty()) loadDefaults();
43 48
44 49
45 50
46} 51}
47 52
48FunctionKeyboard::~FunctionKeyboard() {} 53FunctionKeyboard::~FunctionKeyboard() {}
49 54
50void FunctionKeyboard::changeRows(int r) { 55void FunctionKeyboard::changeRows(int r) {
51 56
52 numRows = r; 57 numRows = r;
53 58
54 // have to do this so the whole thing gets redrawn 59 // have to do this so the whole thing gets redrawn
55 hide(); show(); 60 hide(); show();
56} 61}
57void FunctionKeyboard::changeCols(int c) { 62void FunctionKeyboard::changeCols(int c) {
58 63
59 numCols = c; 64 numCols = c;
60 keyWidth = (double)width()/numCols; // have to reset this thing too 65 keyWidth = (double)width()/numCols; // have to reset this thing too
61 repaint(false); 66 repaint(false);
62} 67}
63void FunctionKeyboard::load (const Profile& prof) { 68void FunctionKeyboard::load (const Profile& prof) {
64 69
65 keys.clear(); 70 keys.clear();
66 71
67 numRows = prof.readNumEntry("keb_rows", 2); 72 numRows = prof.readNumEntry("keb_rows", 2);
68 numCols = prof.readNumEntry("keb_cols", 10); 73 numCols = prof.readNumEntry("keb_cols", 10);
69 keyWidth = (double)width()/numCols; // have to reset this thing too 74 keyWidth = (double)width()/numCols; // have to reset this thing too
70 75
71 /* load all the keys to the keyboard */ 76 /* load all the keys to the keyboard */
72 for (ushort i = 0; i <= numRows - 1; i++) 77 for (ushort i = 0; i <= numRows - 1; i++)
73 for (ushort j = 0; j <= numCols - 1; j++) { 78 for (ushort j = 0; j <= numCols - 1; j++) {
74 79
75 QString h = "r" + QString::number(i) + "c" + QString::number(j); 80 QString h = "r" + QString::number(i) + "c" + QString::number(j);
76 QString values = prof.readEntry("keb_" + h); 81 QString values = prof.readEntry("keb_" + h);
77 82
78 if (!values.isEmpty()) { 83 if (!values.isEmpty()) {
79 84
80 QStringList l = QStringList::split(QChar('|'), values, TRUE); 85 QStringList l = QStringList::split(QChar('|'), values, TRUE);
81 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 86 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
82 87
83 // load pixmap if used 88 // load pixmap if used
84 if (!l[1].isEmpty()) { 89 if (!l[1].isEmpty()) {
85 90
86 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 91 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
87 } 92 }
88 } 93 }
@@ -211,97 +216,97 @@ void FunctionKeyboard::resizeEvent(QResizeEvent*) {
211 216
212} 217}
213 218
214QSize FunctionKeyboard::sizeHint() const { 219QSize FunctionKeyboard::sizeHint() const {
215 220
216 return QSize(width(), keyHeight * numRows + 1); 221 return QSize(width(), keyHeight * numRows + 1);
217} 222}
218 223
219void FunctionKeyboard::loadDefaults() { 224void FunctionKeyboard::loadDefaults() {
220 225
221 numRows = DEFAULT_ROWS; 226 numRows = DEFAULT_ROWS;
222 numCols = DEFAULT_COLS; 227 numCols = DEFAULT_COLS;
223 keyWidth = (double)width()/numCols; // have to reset this thing too 228 keyWidth = (double)width()/numCols; // have to reset this thing too
224 229
225 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 230 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
226 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); 231 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
227 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 232 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
228 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 233 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
229 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 234 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
230 235
231 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 236 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
232 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 237 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
233 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); 238 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0));
234 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); 239 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0));
235 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); 240 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff));
236 241
237 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 242 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
238 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 243 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
239 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 244 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
240 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 245 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
241 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 246 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
242 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 247 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
243 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 248 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
244 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 249 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
245 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 250 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
246 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 251 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
247 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 252 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
248 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); 253 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
249 254
250 255
251} 256}
252 257
253/* FunctionKeyboardConfig {{{1 */ 258/* FunctionKeyboardConfig {{{1 */
254 259
255FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 260FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
256 : ProfileDialogKeyWidget(name, parent, na), 261 : ProfileDialogKeyWidget(name, parent, na),
257 selectedRow(0), selectedCol(0) 262 selectedRow(0), selectedCol(0)
258{ 263{
259 qWarning("FunctionKeyboardConfig"); 264 owarn << "FunctionKeyboardConfig" << oendl;
260 265
261 266
262 kb = new FunctionKeyboard(this); 267 kb = new FunctionKeyboard(this);
263 connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 268 connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
264 this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); 269 this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool)));
265 270
266 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); 271 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this);
267 QLabel *l = new QLabel("Rows", dimentions); 272 QLabel *l = new QLabel("Rows", dimentions);
268 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 273 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
269 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 274 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
270 l = new QLabel("Columns", dimentions); 275 l = new QLabel("Columns", dimentions);
271 m_colBox = new QSpinBox(1, 15, 1, dimentions); 276 m_colBox = new QSpinBox(1, 15, 1, dimentions);
272 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 277 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
273 278
274 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 279 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
275 l = new QLabel("Label", editKey); 280 l = new QLabel("Label", editKey);
276 m_labels = new QComboBox(true, editKey); 281 m_labels = new QComboBox(true, editKey);
277 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 282 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
278 m_labels->insertItem(""); 283 m_labels->insertItem("");
279 284
280 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 285 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
281 286
282 for (uint i = 0; i < files.count(); i++) { 287 for (uint i = 0; i < files.count(); i++) {
283 288
284 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); 289 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
285 } 290 }
286 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 291 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
287 connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); 292 connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&)));
288 293
289 l = new QLabel("Q Keycode", editKey); 294 l = new QLabel("Q Keycode", editKey);
290 m_qvalues = new QComboBox(true, editKey); 295 m_qvalues = new QComboBox(true, editKey);
291 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 296 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
292 m_qvalues->setDuplicatesEnabled(false); 297 m_qvalues->setDuplicatesEnabled(false);
293 m_qvalues->insertItem(""); 298 m_qvalues->insertItem("");
294 connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); 299 connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&)));
295 300
296 l = new QLabel("Unicode Value", editKey); 301 l = new QLabel("Unicode Value", editKey);
297 m_uniValues = new QComboBox(true, editKey); 302 m_uniValues = new QComboBox(true, editKey);
298 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 303 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
299 m_uniValues->setDuplicatesEnabled(false); 304 m_uniValues->setDuplicatesEnabled(false);
300 m_uniValues->insertItem(""); 305 m_uniValues->insertItem("");
301 connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); 306 connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&)));
302 307
303 QVBoxLayout *root = new QVBoxLayout(this, 2); 308 QVBoxLayout *root = new QVBoxLayout(this, 2);
304 root->addWidget(kb); 309 root->addWidget(kb);
305 root->addWidget(dimentions); 310 root->addWidget(dimentions);
306 root->addWidget(editKey); 311 root->addWidget(editKey);
307} 312}
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index a29fa8e..c102427 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,93 +1,96 @@
1 1
2#include "io_bt.h" 2#include "io_bt.h"
3 3
4/* OPIE */
5#include <opie2/odebug.h>
4using namespace Opie::Core; 6using namespace Opie::Core;
7
5IOBt::IOBt( const Profile &config ) : IOSerial( config ) { 8IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
6 m_attach = 0; 9 m_attach = 0;
7} 10}
8 11
9 12
10IOBt::~IOBt() { 13IOBt::~IOBt() {
11 if ( m_attach ) { 14 if ( m_attach ) {
12 delete m_attach; 15 delete m_attach;
13 } 16 }
14} 17}
15 18
16 19
17void IOBt::close() { 20void IOBt::close() {
18 21
19 IOSerial::close(); 22 IOSerial::close();
20 // still need error handling 23 // still need error handling
21 if ( m_attach ) { 24 if ( m_attach ) {
22 delete m_attach; 25 delete m_attach;
23 m_attach = 0; 26 m_attach = 0;
24 } 27 }
25} 28}
26 29
27bool IOBt::open() { 30bool IOBt::open() {
28 bool ret = false; 31 bool ret = false;
29 32
30 // only set up bt stuff if mac address was set, otherwise use the device set 33 // only set up bt stuff if mac address was set, otherwise use the device set
31 if ( !m_mac.isEmpty() ) { 34 if ( !m_mac.isEmpty() ) {
32 35
33 // now it should also be checked, if there is a connection to the device with that mac allready 36 // now it should also be checked, if there is a connection to the device with that mac allready
34 // hciattach here 37 // hciattach here
35 m_attach = new OProcess(); 38 m_attach = new OProcess();
36 *m_attach << "hciattach /dev/ttyS2 any 57600"; 39 *m_attach << "hciattach /dev/ttyS2 any 57600";
37 40
38 // then start hcid, then rcfomm handling (m_mac) 41 // then start hcid, then rcfomm handling (m_mac)
39 42
40 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), 43 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ),
41 this, SLOT( slotExited(Opie::Core::OProcess*) ) ); 44 this, SLOT( slotExited(Opie::Core::OProcess*) ) );
42 45
43 if ( m_attach->start() ) { 46 if ( m_attach->start() ) {
44 ret = IOSerial::open(); 47 ret = IOSerial::open();
45 } else { 48 } else {
46 qWarning("could not attach to device"); 49 owarn << "could not attach to device" << oendl;
47 delete m_attach; 50 delete m_attach;
48 m_attach = 0; 51 m_attach = 0;
49 } 52 }
50 } else { 53 } else {
51 // directly to the normal serial 54 // directly to the normal serial
52 // TODO: look first if the connection really exists. ( is set up ) 55 // TODO: look first if the connection really exists. ( is set up )
53 56
54 ret =IOSerial::open(); 57 ret =IOSerial::open();
55 } 58 }
56 return ret; 59 return ret;
57} 60}
58 61
59void IOBt::reload( const Profile &config ) { 62void IOBt::reload( const Profile &config ) {
60 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); 63 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
61 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); 64 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
62 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); 65 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
63 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); 66 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
64 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); 67 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
65 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); 68 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
66 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); 69 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
67} 70}
68 71
69 72
70QString IOBt::identifier() const { 73QString IOBt::identifier() const {
71 return "bluetooth"; 74 return "bluetooth";
72} 75}
73 76
74QString IOBt::name() const { 77QString IOBt::name() const {
75 return "BLuetooth IO Layer"; 78 return "BLuetooth IO Layer";
76} 79}
77 80
78void IOBt::slotExited( OProcess* proc ){ 81void IOBt::slotExited( OProcess* proc ){
79 close(); 82 close();
80 delete proc; 83 delete proc;
81} 84}
82 85
83QBitArray IOBt::supports() const { 86QBitArray IOBt::supports() const {
84 return QBitArray( 3 ); 87 return QBitArray( 3 );
85} 88}
86 89
87bool IOBt::isConnected() { 90bool IOBt::isConnected() {
88 return false; 91 return false;
89} 92}
90 93
91void IOBt::send(const QByteArray &data) { 94void IOBt::send(const QByteArray &data) {
92 qDebug( "Please overload me..." ); 95 odebug << "Please overload me..." << oendl;
93} 96}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index 07c2b62..38542f5 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,78 +1,80 @@
1
2#include "io_irda.h" 1#include "io_irda.h"
3 2
3/* OPIE */
4#include <opie2/odebug.h>
4using namespace Opie::Core; 5using namespace Opie::Core;
6
5IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { 7IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
6 m_attach = 0; 8 m_attach = 0;
7} 9}
8 10
9 11
10IOIrda::~IOIrda() { 12IOIrda::~IOIrda() {
11 if ( m_attach ) { 13 if ( m_attach ) {
12 delete m_attach; 14 delete m_attach;
13 } 15 }
14} 16}
15 17
16 18
17void IOIrda::close() { 19void IOIrda::close() {
18 20
19 IOSerial::close(); 21 IOSerial::close();
20 // still need error handling 22 // still need error handling
21 delete m_attach; 23 delete m_attach;
22} 24}
23 25
24bool IOIrda::open() { 26bool IOIrda::open() {
25 bool ret; 27 bool ret;
26 28
27 // irdaattach here 29 // irdaattach here
28 m_attach = new OProcess(); 30 m_attach = new OProcess();
29 *m_attach << "irattach /dev/ttyS2 -s"; 31 *m_attach << "irattach /dev/ttyS2 -s";
30 32
31 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), 33 connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ),
32 this, SLOT( slotExited(Opie::Core::OProcess*) ) ); 34 this, SLOT( slotExited(Opie::Core::OProcess*) ) );
33 35
34 if ( m_attach->start() ) { 36 if ( m_attach->start() ) {
35 ret= IOSerial::open(); 37 ret= IOSerial::open();
36 } else { 38 } else {
37 // emit error!!! 39 // emit error!!!
38 qWarning("could not attach to device"); 40 owarn << "could not attach to device" << oendl;
39 delete m_attach; 41 delete m_attach;
40 m_attach = 0l; 42 m_attach = 0l;
41 } 43 }
42 return ret; 44 return ret;
43} 45}
44 46
45void IOIrda::reload( const Profile &config ) { 47void IOIrda::reload( const Profile &config ) {
46 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); 48 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
47 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); 49 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
48 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); 50 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
49 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); 51 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
50 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); 52 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
51 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); 53 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
52} 54}
53 55
54 56
55QString IOIrda::identifier() const { 57QString IOIrda::identifier() const {
56 return "irda"; 58 return "irda";
57} 59}
58 60
59QString IOIrda::name() const { 61QString IOIrda::name() const {
60 return "Irda IO Layer"; 62 return "Irda IO Layer";
61} 63}
62 64
63void IOIrda::slotExited(OProcess* proc ){ 65void IOIrda::slotExited(OProcess* proc ){
64 close(); 66 close();
65 delete proc; 67 delete proc;
66} 68}
67 69
68QBitArray IOIrda::supports()const { 70QBitArray IOIrda::supports()const {
69 return QBitArray( 3 ); 71 return QBitArray( 3 );
70} 72}
71 73
72bool IOIrda::isConnected() { 74bool IOIrda::isConnected() {
73 return false; 75 return false;
74} 76}
75 77
76void IOIrda::send(const QByteArray &data) { 78void IOIrda::send(const QByteArray &data) {
77 qDebug( "Please overload me..." ); 79 odebug << "Please overload me..." << oendl;
78} 80}
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index b74d076..c499dfe 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,108 +1,108 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3
4#include "dialer.h" 3#include "dialer.h"
5 4
5/* OPIE */
6#include <opie2/odebug.h>
6using namespace Opie::Core; 7using namespace Opie::Core;
7using namespace Opie::Core; 8
8IOModem::IOModem( const Profile &profile ) 9IOModem::IOModem( const Profile &profile )
9 : IOSerial( profile ) { 10 : IOSerial( profile ) {
10 m_profile = profile; 11 m_profile = profile;
11} 12}
12 13
13 14
14IOModem::~IOModem() { 15IOModem::~IOModem() {
15
16} 16}
17 17
18 18
19void IOModem::close() { 19void IOModem::close() {
20 // Hangup, discarding result 20 // Hangup, discarding result
21 //int fd = rawIO(); 21 //int fd = rawIO();
22 internDetach(); 22 internDetach();
23 Dialer d(m_profile, m_fd); 23 Dialer d(m_profile, m_fd);
24 d.setHangupOnly(); 24 d.setHangupOnly();
25 //d.exec(); 25 //d.exec();
26 internAttach(); 26 internAttach();
27 //closeRawIO(fd); 27 //closeRawIO(fd);
28 28
29 IOSerial::close(); 29 IOSerial::close();
30} 30}
31 31
32bool IOModem::open() { 32bool IOModem::open() {
33 bool ret = IOSerial::open(); 33 bool ret = IOSerial::open();
34 if(!ret) return false; 34 if(!ret) return false;
35 35
36 //int fd = rawIO(); 36 //int fd = rawIO();
37 internDetach(); 37 internDetach();
38 Dialer d(m_profile, m_fd); 38 Dialer d(m_profile, m_fd);
39 39
40 int result = d.exec(); 40 int result = d.exec();
41 internAttach(); 41 internAttach();
42 //closeRawIO(fd); 42 //closeRawIO(fd);
43 if(result == QDialog::Accepted) 43 if(result == QDialog::Accepted)
44 { 44 {
45 return true; 45 return true;
46 } 46 }
47 else 47 else
48 { 48 {
49 close(); 49 close();
50 return false; 50 return false;
51 } 51 }
52} 52}
53 53
54void IOModem::reload( const Profile &config ) { 54void IOModem::reload( const Profile &config ) {
55 55
56 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); 56 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
57 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); 57 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
58 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); 58 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
59 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); 59 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
60 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); 60 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
61 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); 61 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
62 62
63 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); 63 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
64 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); 64 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
65 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); 65 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
66 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); 66 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
67 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); 67 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
68 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); 68 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
69 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); 69 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
70 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); 70 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
71 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); 71 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
72 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); 72 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
73 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); 73 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
74 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); 74 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
75 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); 75 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL );
76 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); 76 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES );
77 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); 77 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME );
78 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); 78 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT );
79 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); 79 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES );
80 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); 80 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG );
81} 81}
82 82
83 83
84QString IOModem::identifier() const { 84QString IOModem::identifier() const {
85 return "modem"; 85 return "modem";
86} 86}
87 87
88QString IOModem::name() const { 88QString IOModem::name() const {
89 return "Modem IO Layer"; 89 return "Modem IO Layer";
90} 90}
91 91
92void IOModem::slotExited(OProcess* proc ){ 92void IOModem::slotExited(OProcess* proc ){
93 close(); 93 close();
94 /* delete it afterwards */ 94 /* delete it afterwards */
95 delete proc; 95 delete proc;
96} 96}
97 97
98QBitArray IOModem::supports()const { 98QBitArray IOModem::supports()const {
99 return QBitArray( 3 ); 99 return QBitArray( 3 );
100} 100}
101 101
102bool IOModem::isConnected() { 102bool IOModem::isConnected() {
103 return false; 103 return false;
104} 104}
105 105
106void IOModem::send(const QByteArray &data) { 106void IOModem::send(const QByteArray &data) {
107 qDebug( "Please overload me..." ); 107 odebug << "Please overload me..." << oendl;
108} 108}
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index dfb2f83..1bd4338 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -46,65 +46,65 @@ FixIt::FixIt() {
46"" 46""
47"l0:0:wait:/root/etc/rc.d/rc 0" 47"l0:0:wait:/root/etc/rc.d/rc 0"
48"l1:1:wait:/etc/rc.d/rc 1" 48"l1:1:wait:/etc/rc.d/rc 1"
49"l2:2:wait:/etc/rc.d/rc 2" 49"l2:2:wait:/etc/rc.d/rc 2"
50"l3:3:wait:/etc/rc.d/rc 3" 50"l3:3:wait:/etc/rc.d/rc 3"
51"l4:4:wait:/etc/rc.d/rc 4" 51"l4:4:wait:/etc/rc.d/rc 4"
52"l5:5:wait:/etc/rc.d/rc 5" 52"l5:5:wait:/etc/rc.d/rc 5"
53"l6:6:wait:/root/etc/rc.d/rc 6" 53"l6:6:wait:/root/etc/rc.d/rc 6"
54"" 54""
55"# Specify things to do before rebooting" 55"# Specify things to do before rebooting"
56"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" 56"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
57"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" 57"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
58"" 58""
59"# Specify program to run on ttyS0" 59"# Specify program to run on ttyS0"
60"s0:24:respawn:/sbin/getty 9600 ttyS0" 60"s0:24:respawn:/sbin/getty 9600 ttyS0"
61"#pd:5:respawn:/etc/sync/serialctl" 61"#pd:5:respawn:/etc/sync/serialctl"
62"" 62""
63"# Specify program to run on tty1" 63"# Specify program to run on tty1"
64"1:2:respawn:/sbin/getty 9600 tty1" 64"1:2:respawn:/sbin/getty 9600 tty1"
65"ln:345:respawn:survive -l 6 /sbin/launch" 65"ln:345:respawn:survive -l 6 /sbin/launch"
66"#qt:5:respawn:/sbin/qt" 66"#qt:5:respawn:/sbin/qt"
67"" 67""
68"# collie sp." 68"# collie sp."
69"sy::respawn:/sbin/shsync\n"; 69"sy::respawn:/sbin/shsync\n";
70} 70}
71FixIt::~FixIt() { 71FixIt::~FixIt() {
72} 72}
73/* 73/*
74 * the retail Zaurus is broken in many ways 74 * the retail Zaurus is broken in many ways
75 * one is that pppd is listening on our port... 75 * one is that pppd is listening on our port...
76 * we've to stop it from that and then do kill(SIGHUP,1); 76 * we've to stop it from that and then do kill(SIGHUP,1);
77 */ 77 */
78void FixIt::fixIt() { 78void FixIt::fixIt() {
79 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); 79 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
80 QFile file( "/etc/inittab" ); 80 QFile file( "/etc/inittab" );
81 if ( file.open(IO_WriteOnly | IO_Raw ) ) { 81 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
82 file.writeBlock(m_file,strlen(m_file) ); 82 file.writeBlock(m_file,strlen(m_file) );
83 } 83 }
84 file.close(); 84 file.close();
85 ::kill( SIGHUP, 1 ); 85 ::kill( SIGHUP, 1 );
86} 86}
87#endif 87#endif
88 88
89int main(int argc, char **argv) { 89int main(int argc, char **argv) {
90// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole"; 90// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
91 QPEApplication app( argc, argv ); 91 QPEApplication app( argc, argv );
92 92
93#ifdef FSCKED_DISTRIBUTION 93#ifdef FSCKED_DISTRIBUTION
94 qWarning("fscked"); 94 owarn << "fscked" << oendl;
95 FixIt it; 95 FixIt it;
96 it.fixIt(); 96 it.fixIt();
97#endif 97#endif
98 98
99 MainWindow mw; 99 MainWindow mw;
100 mw.setCaption(QObject::tr("Opie Console") ); 100 mw.setCaption(QObject::tr("Opie Console") );
101 app.showMainWidget( &mw ); 101 app.showMainWidget( &mw );
102 102
103 int ap = app.exec(); 103 int ap = app.exec();
104 104
105#ifdef FSCKED_DISTRIBUTION 105#ifdef FSCKED_DISTRIBUTION
106 /* should add a signal handler too */ 106 /* should add a signal handler too */
107 it.breakIt(); 107 it.breakIt();
108#endif 108#endif
109 return ap; 109 return ap;
110} 110}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 06a8f7d..b403b4d 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,75 +1,78 @@
1#include <assert.h>
2
3#include <qaction.h>
4#include <qmenubar.h>
5#include <qtoolbar.h>
6#include <qmessagebox.h>
7#include <qwhatsthis.h>
8#include <qfileinfo.h>
9
10#include <qpe/filemanager.h>
11
12#include <opie2/ofiledialog.h>
13
14#include "TEmulation.h" 1#include "TEmulation.h"
15#include "profileeditordialog.h" 2#include "profileeditordialog.h"
16#include "configdialog.h" 3#include "configdialog.h"
17#include "default.h" 4#include "default.h"
18#include "profilemanager.h" 5#include "profilemanager.h"
19#include "mainwindow.h" 6#include "mainwindow.h"
20#include "tabwidget.h" 7#include "tabwidget.h"
21#include "transferdialog.h" 8#include "transferdialog.h"
22#include "function_keyboard.h" 9#include "function_keyboard.h"
23#include "emulation_handler.h" 10#include "emulation_handler.h"
24#include "script.h" 11#include "script.h"
25 12
26 13/* OPIE */
14#include <opie2/odebug.h>
15#include <opie2/ofiledialog.h>
16#include <qpe/filemanager.h>
17using namespace Opie::Core;
27using namespace Opie::Ui; 18using namespace Opie::Ui;
19
20/* QT */
21#include <qaction.h>
22#include <qmenubar.h>
23#include <qtoolbar.h>
24#include <qmessagebox.h>
25#include <qwhatsthis.h>
26#include <qfileinfo.h>
27
28/* STD */
29#include <assert.h>
30
28MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 31MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
29 KeyTrans::loadAll(); 32 KeyTrans::loadAll();
30 for (int i = 0; i < KeyTrans::count(); i++ ) { 33 for (int i = 0; i < KeyTrans::count(); i++ ) {
31 KeyTrans* s = KeyTrans::find(i ); 34 KeyTrans* s = KeyTrans::find(i );
32 assert( s ); 35 assert( s );
33 } 36 }
34 m_factory = new MetaFactory(); 37 m_factory = new MetaFactory();
35 Default def(m_factory); 38 Default def(m_factory);
36 m_sessions.setAutoDelete( TRUE ); 39 m_sessions.setAutoDelete( TRUE );
37 m_curSession = 0; 40 m_curSession = 0;
38 m_manager = new ProfileManager( m_factory ); 41 m_manager = new ProfileManager( m_factory );
39 m_manager->load(); 42 m_manager->load();
40 m_scriptsData.setAutoDelete(TRUE); 43 m_scriptsData.setAutoDelete(TRUE);
41 44
42 initUI(); 45 initUI();
43 populateProfiles(); 46 populateProfiles();
44 populateScripts(); 47 populateScripts();
45} 48}
46 49
47void MainWindow::initUI() { 50void MainWindow::initUI() {
48 51
49 setToolBarsMovable( FALSE ); 52 setToolBarsMovable( FALSE );
50 53
51 /* tool bar for the menu */ 54 /* tool bar for the menu */
52 m_tool = new QToolBar( this ); 55 m_tool = new QToolBar( this );
53 m_tool->setHorizontalStretchable( TRUE ); 56 m_tool->setHorizontalStretchable( TRUE );
54 57
55 m_bar = new QMenuBar( m_tool ); 58 m_bar = new QMenuBar( m_tool );
56 m_console = new QPopupMenu( this ); 59 m_console = new QPopupMenu( this );
57 m_scripts = new QPopupMenu( this ); 60 m_scripts = new QPopupMenu( this );
58 m_sessionsPop= new QPopupMenu( this ); 61 m_sessionsPop= new QPopupMenu( this );
59 m_scriptsPop = new QPopupMenu( this ); 62 m_scriptsPop = new QPopupMenu( this );
60 63
61 /* add a toolbar for icons */ 64 /* add a toolbar for icons */
62 m_icons = new QToolBar(this); 65 m_icons = new QToolBar(this);
63 66
64 /* 67 /*
65 * the settings action 68 * the settings action
66 */ 69 */
67 m_setProfiles = new QAction(tr("Configure Profiles"), 70 m_setProfiles = new QAction(tr("Configure Profiles"),
68 Resource::loadPixmap( "SettingsIcon" ), 71 Resource::loadPixmap( "SettingsIcon" ),
69 QString::null, 0, this, 0); 72 QString::null, 0, this, 0);
70 m_setProfiles->addTo( m_console ); 73 m_setProfiles->addTo( m_console );
71 connect( m_setProfiles, SIGNAL(activated() ), 74 connect( m_setProfiles, SIGNAL(activated() ),
72 this, SLOT(slotConfigure() ) ); 75 this, SLOT(slotConfigure() ) );
73 76
74 m_console->insertSeparator(); 77 m_console->insertSeparator();
75 /* 78 /*
@@ -401,103 +404,103 @@ void MainWindow::slotTerminate() {
401 if ( currentSession() ) 404 if ( currentSession() )
402 currentSession()->layer()->close(); 405 currentSession()->layer()->close();
403 406
404 slotClose(); 407 slotClose();
405 /* FIXME move to the next session */ 408 /* FIXME move to the next session */
406} 409}
407 410
408 411
409 412
410 413
411 414
412 415
413void MainWindow::slotQuickLaunch() { 416void MainWindow::slotQuickLaunch() {
414 Profile prof = manager()->profile( "default" ); 417 Profile prof = manager()->profile( "default" );
415 if ( prof.name() == "default" ) { 418 if ( prof.name() == "default" ) {
416 create( prof ); 419 create( prof );
417 } else { 420 } else {
418 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 421 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
419 newProf.setAutoConnect( true ); 422 newProf.setAutoConnect( true );
420 create( newProf ); 423 create( newProf );
421 slotSaveSession(); 424 slotSaveSession();
422 } 425 }
423 426
424} 427}
425 428
426void MainWindow::slotConfigure() { 429void MainWindow::slotConfigure() {
427 ConfigDialog conf( manager()->all(), factory() ); 430 ConfigDialog conf( manager()->all(), factory() );
428 431
429 int ret = QPEApplication::execDialog( &conf ); 432 int ret = QPEApplication::execDialog( &conf );
430 433
431 if ( QDialog::Accepted == ret ) { 434 if ( QDialog::Accepted == ret ) {
432 manager()->setProfiles( conf.list() ); 435 manager()->setProfiles( conf.list() );
433 manager()->save(); 436 manager()->save();
434 populateProfiles(); 437 populateProfiles();
435 } 438 }
436} 439}
437/* 440/*
438 * we will remove 441 * we will remove
439 * this window from the tabwidget 442 * this window from the tabwidget
440 * remove it from the list 443 * remove it from the list
441 * delete it 444 * delete it
442 * and set the currentSession() 445 * and set the currentSession()
443 */ 446 */
444void MainWindow::slotClose() { 447void MainWindow::slotClose() {
445 if (!currentSession() ) 448 if (!currentSession() )
446 return; 449 return;
447 450
448 Session* ses = currentSession(); 451 Session* ses = currentSession();
449 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 452 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
450 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 453 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
451 m_curSession = NULL; 454 m_curSession = NULL;
452 tabWidget()->remove( /*currentSession()*/ses ); 455 tabWidget()->remove( /*currentSession()*/ses );
453 /*it's autodelete */ 456 /*it's autodelete */
454 m_sessions.remove( ses ); 457 m_sessions.remove( ses );
455 qWarning("after remove!!"); 458 owarn << "after remove!!" << oendl;
456 459
457 if (!currentSession() ) { 460 if (!currentSession() ) {
458 m_connect->setEnabled( false ); 461 m_connect->setEnabled( false );
459 m_disconnect->setEnabled( false ); 462 m_disconnect->setEnabled( false );
460 m_terminate->setEnabled( false ); 463 m_terminate->setEnabled( false );
461 m_transfer->setEnabled( false ); 464 m_transfer->setEnabled( false );
462 m_recordScript->setEnabled( false ); 465 m_recordScript->setEnabled( false );
463 m_saveScript->setEnabled( false ); 466 m_saveScript->setEnabled( false );
464 m_scripts->setItemEnabled(m_runScript_id, false); 467 m_scripts->setItemEnabled(m_runScript_id, false);
465 m_fullscreen->setEnabled( false ); 468 m_fullscreen->setEnabled( false );
466 m_wrap->setEnabled( false ); 469 m_wrap->setEnabled( false );
467 m_closewindow->setEnabled( false ); 470 m_closewindow->setEnabled( false );
468 } 471 }
469 472
470 m_kb->loadDefaults(); 473 m_kb->loadDefaults();
471} 474}
472 475
473/* 476/*
474 * We will get the name 477 * We will get the name
475 * Then the profile 478 * Then the profile
476 * and then we will make a profile 479 * and then we will make a profile
477 */ 480 */
478void MainWindow::slotProfile( int id) { 481void MainWindow::slotProfile( int id) {
479 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 482 Profile prof = manager()->profile( m_sessionsPop->text( id) );
480 create( prof ); 483 create( prof );
481} 484}
482 485
483 486
484 487
485void MainWindow::create( const Profile& prof ) { 488void MainWindow::create( const Profile& prof ) {
486 if(m_curSession) 489 if(m_curSession)
487 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 490 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
488 491
489 Session *ses = manager()->fromProfile( prof, tabWidget() ); 492 Session *ses = manager()->fromProfile( prof, tabWidget() );
490 493
491 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 494 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
492 { 495 {
493 QMessageBox::warning(this, 496 QMessageBox::warning(this,
494 QObject::tr("Session failed"), 497 QObject::tr("Session failed"),
495 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 498 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
496 //if(ses) delete ses; 499 //if(ses) delete ses;
497 return; 500 return;
498 } 501 }
499 502
500 m_sessions.append( ses ); 503 m_sessions.append( ses );
501 tabWidget()->add( ses ); 504 tabWidget()->add( ses );
502 tabWidget()->repaint(); 505 tabWidget()->repaint();
503 m_curSession = ses; 506 m_curSession = ses;
@@ -525,106 +528,106 @@ void MainWindow::create( const Profile& prof ) {
525 if(w) w->setFocus(); 528 if(w) w->setFocus();
526 529
527 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 530 if(currentSession()->profile().readNumEntry("Wrap", 80)){
528 m_isWrapped = true; 531 m_isWrapped = true;
529 } else { 532 } else {
530 m_isWrapped = false; 533 m_isWrapped = false;
531 } 534 }
532 535
533 m_kb->load(currentSession()->profile()); 536 m_kb->load(currentSession()->profile());
534} 537}
535 538
536void MainWindow::slotTransfer() 539void MainWindow::slotTransfer()
537{ 540{
538 if ( currentSession() ) { 541 if ( currentSession() ) {
539 Session *mysession = currentSession(); 542 Session *mysession = currentSession();
540 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 543 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
541 mysession->setTransferDialog(&dlg); 544 mysession->setTransferDialog(&dlg);
542 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 545 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
543 //dlg.showMaximized(); 546 //dlg.showMaximized();
544 currentSession()->widgetStack()->addWidget(&dlg, -1); 547 currentSession()->widgetStack()->addWidget(&dlg, -1);
545 dlg.show(); 548 dlg.show();
546 //dlg.exec(); 549 //dlg.exec();
547 while(dlg.isRunning()) qApp->processEvents(); 550 while(dlg.isRunning()) qApp->processEvents();
548 mysession->setTransferDialog(0l); 551 mysession->setTransferDialog(0l);
549 } 552 }
550} 553}
551 554
552 555
553void MainWindow::slotOpenKeb(bool state) { 556void MainWindow::slotOpenKeb(bool state) {
554 557
555 if (state) m_keyBar->show(); 558 if (state) m_keyBar->show();
556 else m_keyBar->hide(); 559 else m_keyBar->hide();
557 560
558} 561}
559 562
560 563
561void MainWindow::slotOpenButtons( bool state ) { 564void MainWindow::slotOpenButtons( bool state ) {
562 565
563 if ( state ) { 566 if ( state ) {
564 m_buttonBar->show(); 567 m_buttonBar->show();
565 } else { 568 } else {
566 m_buttonBar->hide(); 569 m_buttonBar->hide();
567 } 570 }
568} 571}
569 572
570 573
571 574
572void MainWindow::slotSessionChanged( Session* ses ) { 575void MainWindow::slotSessionChanged( Session* ses ) {
573 qWarning("changed!"); 576 owarn << "changed!" << oendl;
574 577
575 if(m_curSession) 578 if(m_curSession)
576 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 579 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
577 if(ses) 580 if(ses)
578 if(ses->transferDialog()) ses->transferDialog()->show(); 581 if(ses->transferDialog()) ses->transferDialog()->show();
579 582
580 if ( ses ) { 583 if ( ses ) {
581 m_curSession = ses; 584 m_curSession = ses;
582 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 585 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
583 if ( m_curSession->layer()->isConnected() ) { 586 if ( m_curSession->layer()->isConnected() ) {
584 m_connect->setEnabled( false ); 587 m_connect->setEnabled( false );
585 m_disconnect->setEnabled( true ); 588 m_disconnect->setEnabled( true );
586 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 589 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
587 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 590 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
588 m_scripts->setItemEnabled(m_runScript_id, true); 591 m_scripts->setItemEnabled(m_runScript_id, true);
589 } else { 592 } else {
590 m_connect->setEnabled( true ); 593 m_connect->setEnabled( true );
591 m_disconnect->setEnabled( false ); 594 m_disconnect->setEnabled( false );
592 m_recordScript->setEnabled( false ); 595 m_recordScript->setEnabled( false );
593 m_saveScript->setEnabled( false ); 596 m_saveScript->setEnabled( false );
594 m_scripts->setItemEnabled(m_runScript_id, false); 597 m_scripts->setItemEnabled(m_runScript_id, false);
595 } 598 }
596 599
597 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 600 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
598 m_transfer->setEnabled( false ); 601 m_transfer->setEnabled( false );
599 } else { 602 } else {
600 m_transfer->setEnabled( true ); 603 m_transfer->setEnabled( true );
601 } 604 }
602 605
603 QWidget *w = m_curSession->widget(); 606 QWidget *w = m_curSession->widget();
604 if(w) w->setFocus(); 607 if(w) w->setFocus();
605 608
606 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 609 if(currentSession()->profile().readNumEntry("Wrap", 80)){
607 m_isWrapped = true; 610 m_isWrapped = true;
608 } else { 611 } else {
609 m_isWrapped = false; 612 m_isWrapped = false;
610 } 613 }
611 614
612 m_kb->load(currentSession()->profile()); 615 m_kb->load(currentSession()->profile());
613 } 616 }
614} 617}
615 618
616void MainWindow::slotWrap() 619void MainWindow::slotWrap()
617{ 620{
618 if(m_curSession) 621 if(m_curSession)
619 { 622 {
620 EmulationHandler *e = m_curSession->emulationHandler(); 623 EmulationHandler *e = m_curSession->emulationHandler();
621 if(e) 624 if(e)
622 { 625 {
623 if(m_isWrapped) 626 if(m_isWrapped)
624 { 627 {
625 e->setWrap(80); 628 e->setWrap(80);
626 m_isWrapped = false; 629 m_isWrapped = false;
627 } 630 }
628 else 631 else
629 { 632 {
630 e->setWrap(0); 633 e->setWrap(0);
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 3466e3a..9fdaf73 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,60 +1,63 @@
1#include "modemconfigwidget.h"
2#include "dialdialog.h"
1 3
4/* OPIE */
5#include <opie2/odebug.h>
2#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7using namespace Opie::Core;
3 8
9/* QT */
4#include <qlabel.h> 10#include <qlabel.h>
5#include <qlayout.h> 11#include <qlayout.h>
6#include <qcombobox.h> 12#include <qcombobox.h>
7#include <qpushbutton.h> 13#include <qpushbutton.h>
8#include <qhbox.h> 14#include <qhbox.h>
9 15
10#include "modemconfigwidget.h"
11#include "dialdialog.h"
12
13namespace { 16namespace {
14 void setCurrent( const QString& str, QComboBox* bo ) { 17 void setCurrent( const QString& str, QComboBox* bo ) {
15 uint b = bo->count(); 18 uint b = bo->count();
16 for (int i = 0; i < bo->count(); i++ ) { 19 for (int i = 0; i < bo->count(); i++ ) {
17 if ( bo->text(i) == str ) { 20 if ( bo->text(i) == str ) {
18 bo->setCurrentItem( i ); 21 bo->setCurrentItem( i );
19 return; 22 return;
20 } 23 }
21 } 24 }
22 bo->insertItem( str ); 25 bo->insertItem( str );
23 bo->setCurrentItem( b ); 26 bo->setCurrentItem( b );
24 } 27 }
25} 28}
26 29
27ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, 30ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
28 const char* na ) 31 const char* na )
29 : ProfileDialogConnectionWidget( name, parent, na ) { 32 : ProfileDialogConnectionWidget( name, parent, na ) {
30 33
31 m_lay = new QVBoxLayout( this ); 34 m_lay = new QVBoxLayout( this );
32 m_device = new QLabel(tr( "Modem is attached to:" ), this ); 35 m_device = new QLabel(tr( "Modem is attached to:" ), this );
33 m_deviceCmb = new QComboBox(this ); 36 m_deviceCmb = new QComboBox(this );
34 m_deviceCmb->setEditable( TRUE ); 37 m_deviceCmb->setEditable( TRUE );
35 38
36 QLabel* telLabel = new QLabel( this ); 39 QLabel* telLabel = new QLabel( this );
37 telLabel->setText( tr( "Enter telefon number here:" ) ); 40 telLabel->setText( tr( "Enter telefon number here:" ) );
38 QHBox *buttonBox = new QHBox( this ); 41 QHBox *buttonBox = new QHBox( this );
39 m_telNumber = new QLineEdit( buttonBox ); 42 m_telNumber = new QLineEdit( buttonBox );
40 QPushButton *atButton = new QPushButton( buttonBox ); 43 QPushButton *atButton = new QPushButton( buttonBox );
41 atButton->setText( tr( "AT commands" ) ); 44 atButton->setText( tr( "AT commands" ) );
42 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); 45 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
43 46
44 QPushButton *dialButton = new QPushButton( buttonBox ); 47 QPushButton *dialButton = new QPushButton( buttonBox );
45 dialButton->setText( tr( "Enter number" ) ); 48 dialButton->setText( tr( "Enter number" ) );
46 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); 49 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
47 50
48 m_base = new IOLayerBase( this, "base" ); 51 m_base = new IOLayerBase( this, "base" );
49 52
50 m_lay->addWidget( m_device ); 53 m_lay->addWidget( m_device );
51 m_lay->addWidget( m_deviceCmb ); 54 m_lay->addWidget( m_deviceCmb );
52 m_lay->addWidget( telLabel ); 55 m_lay->addWidget( telLabel );
53 m_lay->addWidget( buttonBox ); 56 m_lay->addWidget( buttonBox );
54 m_lay->addWidget( m_base ); 57 m_lay->addWidget( m_base );
55 m_lay->addStretch( 0 ); 58 m_lay->addStretch( 0 );
56 59
57 m_deviceCmb->insertItem( "/dev/ttyS0" ); 60 m_deviceCmb->insertItem( "/dev/ttyS0" );
58 m_deviceCmb->insertItem( "/dev/ttyS1" ); 61 m_deviceCmb->insertItem( "/dev/ttyS1" );
59 m_deviceCmb->insertItem( "/dev/ttyS2" ); 62 m_deviceCmb->insertItem( "/dev/ttyS2" );
60 63
@@ -90,97 +93,97 @@ void ModemConfigWidget::load( const Profile& prof ) {
90 m_base->setParity( IOLayerBase::Even ); 93 m_base->setParity( IOLayerBase::Even );
91 } else if ( rad_parity == 2 ){ 94 } else if ( rad_parity == 2 ){
92 m_base->setParity( IOLayerBase::Odd ); 95 m_base->setParity( IOLayerBase::Odd );
93 } else { 96 } else {
94 m_base->setParity( IOLayerBase::NonePar ); 97 m_base->setParity( IOLayerBase::NonePar );
95 } 98 }
96 99
97 switch( speed ) { 100 switch( speed ) {
98 case 115200: 101 case 115200:
99 m_base->setSpeed( IOLayerBase::Baud_115200 ); 102 m_base->setSpeed( IOLayerBase::Baud_115200 );
100 break; 103 break;
101 case 57600: 104 case 57600:
102 m_base->setSpeed( IOLayerBase::Baud_57600 ); 105 m_base->setSpeed( IOLayerBase::Baud_57600 );
103 break; 106 break;
104 case 38400: 107 case 38400:
105 m_base->setSpeed( IOLayerBase::Baud_38400 ); 108 m_base->setSpeed( IOLayerBase::Baud_38400 );
106 break; 109 break;
107 case 19200: 110 case 19200:
108 m_base->setSpeed( IOLayerBase::Baud_19200 ); 111 m_base->setSpeed( IOLayerBase::Baud_19200 );
109 break; 112 break;
110 case 9600: 113 case 9600:
111 default: 114 default:
112 m_base->setSpeed( IOLayerBase::Baud_9600 ); 115 m_base->setSpeed( IOLayerBase::Baud_9600 );
113 break; 116 break;
114 } 117 }
115 118
116 119
117 if ( dbits == 5) { 120 if ( dbits == 5) {
118 m_base->setData( IOLayerBase::Data_Five ); 121 m_base->setData( IOLayerBase::Data_Five );
119 } else if (rad_flow == 6) { 122 } else if (rad_flow == 6) {
120 m_base->setData( IOLayerBase::Data_Six ); 123 m_base->setData( IOLayerBase::Data_Six );
121 } else if (rad_flow == 7) { 124 } else if (rad_flow == 7) {
122 m_base->setData( IOLayerBase::Data_Seven ); 125 m_base->setData( IOLayerBase::Data_Seven );
123 } else { 126 } else {
124 m_base->setData( IOLayerBase::Data_Eight ); 127 m_base->setData( IOLayerBase::Data_Eight );
125 } 128 }
126 129
127 if ( sbits == 2) { 130 if ( sbits == 2) {
128 m_base->setStop( IOLayerBase::Stop_Two ); 131 m_base->setStop( IOLayerBase::Stop_Two );
129 } else if ( sbits == 15 ) { 132 } else if ( sbits == 15 ) {
130 m_base->setStop( IOLayerBase::Stop_OnePointFive ); 133 m_base->setStop( IOLayerBase::Stop_OnePointFive );
131 } else { 134 } else {
132 m_base->setStop( IOLayerBase::Stop_One ); 135 m_base->setStop( IOLayerBase::Stop_One );
133 } 136 }
134 137
135 138
136 atConf->readConfig( prof ); 139 atConf->readConfig( prof );
137 if ( prof.readEntry( "Device" ).isEmpty() ) { 140 if ( prof.readEntry( "Device" ).isEmpty() ) {
138 qWarning("device empty!"); 141 owarn << "device empty!" << oendl;
139 return; 142 return;
140 } 143 }
141 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 144 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
142 145
143 146
144} 147}
145 148
146/* 149/*
147 * save speed, 150 * save speed,
148 * flow, 151 * flow,
149 * parity 152 * parity
150 */ 153 */
151void ModemConfigWidget::save( Profile& prof ) { 154void ModemConfigWidget::save( Profile& prof ) {
152 int flow, parity, speed, data, stop; 155 int flow, parity, speed, data, stop;
153 flow = parity = speed = data = stop = 0; 156 flow = parity = speed = data = stop = 0;
154 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 157 prof.writeEntry( "Device", m_deviceCmb->currentText() );
155 158
156 159
157 switch( m_base->flow() ) { 160 switch( m_base->flow() ) {
158 case IOLayerBase::None: 161 case IOLayerBase::None:
159 flow = 0; 162 flow = 0;
160 break; 163 break;
161 case IOLayerBase::Software: 164 case IOLayerBase::Software:
162 flow = 2; 165 flow = 2;
163 break; 166 break;
164 case IOLayerBase::Hardware: 167 case IOLayerBase::Hardware:
165 flow = 1; 168 flow = 1;
166 break; 169 break;
167 } 170 }
168 171
169 switch( m_base->parity() ) { 172 switch( m_base->parity() ) {
170 case IOLayerBase::Odd: 173 case IOLayerBase::Odd:
171 parity = 2; 174 parity = 2;
172 break; 175 break;
173 case IOLayerBase::Even: 176 case IOLayerBase::Even:
174 parity = 1; 177 parity = 1;
175 break; 178 break;
176 case IOLayerBase::NonePar: 179 case IOLayerBase::NonePar:
177 parity = 0; 180 parity = 0;
178 break; 181 break;
179 } 182 }
180 183
181 switch( m_base->speed() ) { 184 switch( m_base->speed() ) {
182 case IOLayerBase::Baud_115200: 185 case IOLayerBase::Baud_115200:
183 speed = 115200; 186 speed = 115200;
184 break; 187 break;
185 case IOLayerBase::Baud_57600: 188 case IOLayerBase::Baud_57600:
186 speed = 57600; 189 speed = 57600;
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 7a15828..f7e33e9 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,76 +1,74 @@
1TEMPLATE = app 1TEMPLATE = app
2TMAKE_CXXFLAGS += -DHAVE_OPENPTY
3CONFIG += qt warn_on 2CONFIG += qt warn_on
4#CONFIG = qt
5DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
6HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ 4HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
7 file_layer.h filetransfer.h \ 5 file_layer.h filetransfer.h \
8 metafactory.h \ 6 metafactory.h \
9 session.h \ 7 session.h \
10 mainwindow.h \ 8 mainwindow.h \
11 profile.h \ 9 profile.h \
12 profileconfig.h \ 10 profileconfig.h \
13 profilemanager.h \ 11 profilemanager.h \
14 tabwidget.h \ 12 tabwidget.h \
15 configdialog.h \ 13 configdialog.h \
16 keytrans.h \ 14 keytrans.h \
17 transferdialog.h \ 15 transferdialog.h \
18 profiledialogwidget.h \ 16 profiledialogwidget.h \
19 profileeditordialog.h \ 17 profileeditordialog.h \
20 default.h \ 18 default.h \
21 iolayerbase.h \ 19 iolayerbase.h \
22 serialconfigwidget.h irdaconfigwidget.h \ 20 serialconfigwidget.h irdaconfigwidget.h \
23 btconfigwidget.h modemconfigwidget.h \ 21 btconfigwidget.h modemconfigwidget.h \
24 atconfigdialog.h dialdialog.h \ 22 atconfigdialog.h dialdialog.h \
25 procctl.h \ 23 procctl.h \
26 function_keyboard.h \ 24 function_keyboard.h \
27 receive_layer.h filereceive.h \ 25 receive_layer.h filereceive.h \
28 script.h \ 26 script.h \
29 dialer.h \ 27 dialer.h \
30 terminalwidget.h \ 28 terminalwidget.h \
31 emulation_handler.h TECommon.h \ 29 emulation_handler.h TECommon.h \
32 TEHistory.h TEScreen.h TEWidget.h \ 30 TEHistory.h TEScreen.h TEWidget.h \
33 TEmuVt102.h TEmulation.h MyPty.h \ 31 TEmuVt102.h TEmulation.h MyPty.h \
34 consoleconfigwidget.h 32 consoleconfigwidget.h
35 33
36SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ 34SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
37 file_layer.cpp filetransfer.cpp \ 35 file_layer.cpp filetransfer.cpp \
38 main.cpp \ 36 main.cpp \
39 metafactory.cpp \ 37 metafactory.cpp \
40 session.cpp \ 38 session.cpp \
41 mainwindow.cpp \ 39 mainwindow.cpp \
42 profile.cpp \ 40 profile.cpp \
43 profileconfig.cpp \ 41 profileconfig.cpp \
44 profilemanager.cpp \ 42 profilemanager.cpp \
45 tabwidget.cpp \ 43 tabwidget.cpp \
46 configdialog.cpp \ 44 configdialog.cpp \
47 keytrans.cpp \ 45 keytrans.cpp \
48 transferdialog.cpp \ 46 transferdialog.cpp \
49 profiledialogwidget.cpp \ 47 profiledialogwidget.cpp \
50 profileeditordialog.cpp \ 48 profileeditordialog.cpp \
51 iolayerbase.cpp \ 49 iolayerbase.cpp \
52 serialconfigwidget.cpp irdaconfigwidget.cpp \ 50 serialconfigwidget.cpp irdaconfigwidget.cpp \
53 btconfigwidget.cpp modemconfigwidget.cpp \ 51 btconfigwidget.cpp modemconfigwidget.cpp \
54 atconfigdialog.cpp dialdialog.cpp \ 52 atconfigdialog.cpp dialdialog.cpp \
55 default.cpp procctl.cpp \ 53 default.cpp procctl.cpp \
56 function_keyboard.cpp \ 54 function_keyboard.cpp \
57 receive_layer.cpp filereceive.cpp \ 55 receive_layer.cpp filereceive.cpp \
58 script.cpp \ 56 script.cpp \
59 dialer.cpp \ 57 dialer.cpp \
60 terminalwidget.cpp \ 58 terminalwidget.cpp \
61 emulation_handler.cpp TEHistory.cpp \ 59 emulation_handler.cpp TEHistory.cpp \
62 TEScreen.cpp TEWidget.cpp \ 60 TEScreen.cpp TEWidget.cpp \
63 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ 61 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
64 consoleconfigwidget.cpp 62 consoleconfigwidget.cpp
65 63
66 64
67INTERFACES = configurebase.ui editbase.ui 65INTERFACES = configurebase.ui editbase.ui
68INCLUDEPATH += $(OPIEDIR)/include 66INCLUDEPATH += $(OPIEDIR)/include
69DEPENDPATH += $(OPIEDIR)/include 67DEPENDPATH += $(OPIEDIR)/include
70LIBS += -lqpe -lopiecore2 -lopieui2 -lutil 68LIBS += -lqpe -lopiecore2 -lopieui2 -lutil
71TARGET = opie-console 69TARGET = opie-console
72 70
73 71DEFINES += HAVE_OPENPTY
74 72
75 73
76include ( $(OPIEDIR)/include.pro ) 74include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index fbc5306..f505998 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -1,86 +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; 9using namespace Opie::Core;
10using namespace Opie::Core; 10using namespace Opie::Core;
11SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) 11SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
12{ 12{
13} 13}
14 14
15SzTransfer::~SzTransfer() { 15SzTransfer::~SzTransfer() {
16} 16}
17 17
18void SzTransfer::sendFile(const QFile& file) { 18void SzTransfer::sendFile(const QFile& file) {
19 19
20 sendFile(file.name()); 20 sendFile(file.name());
21} 21}
22 22
23void SzTransfer::sendFile(const QString& file) { 23void SzTransfer::sendFile(const QString& file) {
24 24
25 //setcbreak(2); /* raw no echo */ 25 //setcbreak(2); /* raw no echo */
26 26
27 proc = new OProcess; 27 proc = new OProcess;
28 *proc << "sz"; 28 *proc << "sz";
29 *proc << "-v" << "-v" << "-b" << file; 29 *proc << "-v" << "-v" << "-b" << file;
30 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), 30 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
31 this, SLOT(sent())); 31 this, SLOT(sent()));
32 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), 32 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
33 this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int))); 33 this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int)));
34 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), 34 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
35 this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); 35 this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int)));
36 connect(layer(), SIGNAL(received(const QByteArray&)), 36 connect(layer(), SIGNAL(received(const QByteArray&)),
37 this, SLOT(receivedStdin(const QByteArray&))); 37 this, SLOT(receivedStdin(const QByteArray&)));
38 proc->start(OProcess::NotifyOnExit, OProcess::All); 38 proc->start(OProcess::NotifyOnExit, OProcess::All);
39 39
40} 40}
41 41
42void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { 42void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) {
43 43
44 qWarning("recieved from sz on stdout %d bytes", buflen); 44 owarn << "recieved from sz on stdout " << buflen << " bytes" << oendl;
45 45
46 QByteArray data(buflen); 46 QByteArray data(buflen);
47 data.fill(*buffer, buflen); 47 data.fill(*buffer, buflen);
48 for (uint i = 0; i < data.count(); i++ ) { 48 for (uint i = 0; i < data.count(); i++ ) {
49 printf("%c", buffer[i] ); 49 printf("%c", buffer[i] );
50 } 50 }
51 printf("\n"); 51 printf("\n");
52 52
53 // send out through the io layer 53 // send out through the io layer
54 layer()->send(data); 54 layer()->send(data);
55} 55}
56 56
57void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { 57void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) {
58 58
59 // parse and show data in a progress dialog/widget 59 // parse and show data in a progress dialog/widget
60 printf("stderr:\n"); 60 printf("stderr:\n");
61 //for (int i = 0; i < length; i++) 61 //for (int i = 0; i < length; i++)
62 // printf("%c", buffer[i]); 62 // printf("%c", buffer[i]);
63 //printf("\n"); 63 //printf("\n");
64} 64}
65 65
66void SzTransfer::receivedStdin(const QByteArray &data) { 66void SzTransfer::receivedStdin(const QByteArray &data) {
67 67
68 qWarning("recieved from io_serial %d bytes", data.size()); 68 owarn << "recieved from io_serial " << data.size() << " bytes" << oendl;
69 69
70 // recieved data from the io layer goes to sz 70 // recieved data from the io layer goes to sz
71 proc->writeStdin(data.data(), data.size()); 71 proc->writeStdin(data.data(), data.size());
72 72
73} 73}
74 74
75void SzTransfer::sent() { 75void SzTransfer::sent() {
76 76
77 qWarning("sent file"); 77 owarn << "sent file" << oendl;
78 78
79 //setcbreak(0); /* default */ 79 //setcbreak(0); /* default */
80 80
81 81
82 delete proc; 82 delete proc;
83 disconnect(layer(), SIGNAL(received(const QByteArray&)), 83 disconnect(layer(), SIGNAL(received(const QByteArray&)),
84 this, SLOT(receivedStdin(const QByteArray&))); 84 this, SLOT(receivedStdin(const QByteArray&)));
85 85
86} 86}
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 6429e3c..41a91ed 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -1,45 +1,48 @@
1
2#include "tabwidget.h" 1#include "tabwidget.h"
3 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
4using namespace Opie::Ui; 6using namespace Opie::Ui;
7
5TabWidget::TabWidget( QWidget* parent, const char* name ) 8TabWidget::TabWidget( QWidget* parent, const char* name )
6 : OTabWidget( parent, name ) { 9 : OTabWidget( parent, name ) {
7 connect(this, SIGNAL( currentChanged(QWidget*) ), 10 connect(this, SIGNAL( currentChanged(QWidget*) ),
8 this, SLOT( slotCurChanged(QWidget*) ) ); 11 this, SLOT( slotCurChanged(QWidget*) ) );
9} 12}
10 13
11TabWidget::~TabWidget() { 14TabWidget::~TabWidget() {
12} 15}
13 16
14void TabWidget::add( Session* ses ) { 17void TabWidget::add( Session* ses ) {
15 qWarning("session ses " + ses->name() ); 18 owarn << "session ses " + ses->name() << oendl;
16 if ( !ses->widgetStack() ) return; 19 if ( !ses->widgetStack() ) return;
17 //reparent( ses->widgetStack(), QPoint() ); 20 //reparent( ses->widgetStack(), QPoint() );
18 addTab( ses->widgetStack(), "console/konsole", ses->name() ); 21 addTab( ses->widgetStack(), "console/konsole", ses->name() );
19 //addTab( ses->widgetStack(), ses->name() ); 22 //addTab( ses->widgetStack(), ses->name() );
20 m_map.insert( ses->widgetStack(), ses ); 23 m_map.insert( ses->widgetStack(), ses );
21} 24}
22 25
23void TabWidget::remove( Session* ses ) { 26void TabWidget::remove( Session* ses ) {
24 m_map.remove( ses->widgetStack() ); 27 m_map.remove( ses->widgetStack() );
25 removePage( ses->widgetStack() ); 28 removePage( ses->widgetStack() );
26} 29}
27 30
28void TabWidget::slotCurChanged( QWidget* wid ) { 31void TabWidget::slotCurChanged( QWidget* wid ) {
29 QMap<QWidget*, Session*>::Iterator it; 32 QMap<QWidget*, Session*>::Iterator it;
30 it = m_map.find( wid ); 33 it = m_map.find( wid );
31 if ( it == m_map.end() ) { 34 if ( it == m_map.end() ) {
32 return; 35 return;
33 } 36 }
34 37
35 emit activated( it.data() ); 38 emit activated( it.data() );
36} 39}
37void TabWidget::setCurrent( Session* ses ) { 40void TabWidget::setCurrent( Session* ses ) {
38 if (!ses ) 41 if (!ses )
39 return; 42 return;
40 43
41 //showPage( ses->widgetStack() ); 44 //showPage( ses->widgetStack() );
42 setCurrentTab( ses->widgetStack() ); 45 setCurrentTab( ses->widgetStack() );
43} 46}
44 47
45 48
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp
index 6870487..087476b 100644
--- a/noncore/apps/opie-console/terminalwidget.cpp
+++ b/noncore/apps/opie-console/terminalwidget.cpp
@@ -1,120 +1,125 @@
1#include "terminalwidget.h"
2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
1#include <qlabel.h> 8#include <qlabel.h>
2#include <qcheckbox.h> 9#include <qcheckbox.h>
3#include <qcombobox.h> 10#include <qcombobox.h>
4#include <qradiobutton.h> 11#include <qradiobutton.h>
5#include <qhgroupbox.h> 12#include <qhgroupbox.h>
6#include <qhbuttongroup.h> 13#include <qhbuttongroup.h>
7#include <qlayout.h> 14#include <qlayout.h>
8 15
9#include "terminalwidget.h"
10
11namespace { 16namespace {
12 enum TermIds { 17 enum TermIds {
13 id_term_vt100 = 0, 18 id_term_vt100 = 0,
14 id_term_vt102, 19 id_term_vt102,
15 id_term_linux, 20 id_term_linux,
16 id_term_xterm 21 id_term_xterm
17 }; 22 };
18 23
19 enum ColourIds { 24 enum ColourIds {
20 id_term_black, 25 id_term_black,
21 id_term_white, 26 id_term_white,
22 id_term_green, 27 id_term_green,
23 id_term_orange 28 id_term_orange
24 }; 29 };
25 30
26 enum FontIds { 31 enum FontIds {
27 id_size_small, 32 id_size_small,
28 id_size_medium, 33 id_size_medium,
29 id_size_large 34 id_size_large
30 }; 35 };
31}; 36};
32 37
33TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, 38TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
34 const char* na ) 39 const char* na )
35 : ProfileDialogTerminalWidget( name, parent, na ) { 40 : ProfileDialogTerminalWidget( name, parent, na ) {
36 41
37 m_terminal = new QLabel(tr("Terminal Type"), this ); 42 m_terminal = new QLabel(tr("Terminal Type"), this );
38 m_terminalBox = new QComboBox(this); 43 m_terminalBox = new QComboBox(this);
39 m_colorLabel = new QLabel(tr("Color scheme"), this); 44 m_colorLabel = new QLabel(tr("Color scheme"), this);
40 m_colorCmb = new QComboBox(this ); 45 m_colorCmb = new QComboBox(this );
41 46
42 m_groupSize = new QHButtonGroup(tr("Font size"), this ); 47 m_groupSize = new QHButtonGroup(tr("Font size"), this );
43 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); 48 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
44 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); 49 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
45 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); 50 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
46 51
47 m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); 52 m_groupConv = new QHGroupBox( tr("Line-break conversions"), this );
48 m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); 53 m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv );
49 m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); 54 m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv );
50 55
51 m_groupOptions = new QHGroupBox( tr("Options"), this ); 56 m_groupOptions = new QHGroupBox( tr("Options"), this );
52 m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); 57 m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions );
53 m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); 58 m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions );
54 59
55 m_lroot = new QVBoxLayout( this ); 60 m_lroot = new QVBoxLayout( this );
56 m_typeBox = new QVBoxLayout( m_lroot ); 61 m_typeBox = new QVBoxLayout( m_lroot );
57 m_colorBox = new QVBoxLayout( m_lroot ); 62 m_colorBox = new QVBoxLayout( m_lroot );
58 63
59 // Layout 64 // Layout
60 m_typeBox->add( m_terminal ); 65 m_typeBox->add( m_terminal );
61 m_typeBox->add( m_terminalBox ); 66 m_typeBox->add( m_terminalBox );
62 m_lroot->add( m_groupSize ); 67 m_lroot->add( m_groupSize );
63 68
64 m_colorBox->add( m_colorLabel ); 69 m_colorBox->add( m_colorLabel );
65 m_colorBox->add( m_colorCmb ); 70 m_colorBox->add( m_colorCmb );
66 71
67 m_lroot->add( m_groupConv ); 72 m_lroot->add( m_groupConv );
68 m_lroot->add( m_groupOptions ); 73 m_lroot->add( m_groupOptions );
69 m_lroot->addStretch( 0 ); 74 m_lroot->addStretch( 0 );
70 75
71 // Fill in some options 76 // Fill in some options
72 qWarning("Options for terminal box"); 77 owarn << "Options for terminal box" << oendl;
73 m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); 78 m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ );
74 m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); 79 m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */);
75 m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); 80 m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux );
76 m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); 81 m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm );
77 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); 82 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
78 83
79 m_colorCmb->insertItem( tr("black on white"), id_term_black ); 84 m_colorCmb->insertItem( tr("black on white"), id_term_black );
80 m_colorCmb->insertItem( tr("white on black"), id_term_white ); 85 m_colorCmb->insertItem( tr("white on black"), id_term_white );
81 m_colorCmb->insertItem( tr("green on black"), id_term_green ); 86 m_colorCmb->insertItem( tr("green on black"), id_term_green );
82 m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); 87 m_colorCmb->insertItem( tr("orange on black"), id_term_orange );
83 88
84 // signals + slots 89 // signals + slots
85 /* 90 /*
86 connect(m_terminalBox, SIGNAL(activated(int) ), 91 connect(m_terminalBox, SIGNAL(activated(int) ),
87 this, SLOT(slotTermTerm(int) ) ); 92 this, SLOT(slotTermTerm(int) ) );
88 connect(m_colorBox, SIGNAL(activated(int) ), 93 connect(m_colorBox, SIGNAL(activated(int) ),
89 tis, SLOT(slotTermColor(int) ) ); 94 tis, SLOT(slotTermColor(int) ) );
90 connect(m_groupSize, SIGNAL(activated(int) ), 95 connect(m_groupSize, SIGNAL(activated(int) ),
91 this, SLOT(slotTermFont(int) ) ); 96 this, SLOT(slotTermFont(int) ) );
92 97
93 connect(m_optionEcho, SIGNAL(toggled(bool) ), 98 connect(m_optionEcho, SIGNAL(toggled(bool) ),
94 this, SLOT(slotTermEcho(bool) ) ); 99 this, SLOT(slotTermEcho(bool) ) );
95 connect(m_optionWrap, SIGNAL(toggled(bool) ), 100 connect(m_optionWrap, SIGNAL(toggled(bool) ),
96 this, SLOT(slotTermWrap(bool) ) ); 101 this, SLOT(slotTermWrap(bool) ) );
97 connect(m_convInbound, SIGNAL(toggled(bool) ), 102 connect(m_convInbound, SIGNAL(toggled(bool) ),
98 this, SLOT(slotTermInbound(bool) ) ); 103 this, SLOT(slotTermInbound(bool) ) );
99 connect(m_convOutbound, SIGNAL(toggled(bool) ), 104 connect(m_convOutbound, SIGNAL(toggled(bool) ),
100 this, SLOT(slotTermOutbound(bool) ) ); 105 this, SLOT(slotTermOutbound(bool) ) );
101*/ 106*/
102} 107}
103TerminalWidget::~TerminalWidget() { 108TerminalWidget::~TerminalWidget() {
104} 109}
105void TerminalWidget::load( const Profile& prof ) { 110void TerminalWidget::load( const Profile& prof ) {
106 int term = prof.readNumEntry("Terminal"); 111 int term = prof.readNumEntry("Terminal");
107 int color = prof.readNumEntry("Color"); 112 int color = prof.readNumEntry("Color");
108 int fontsize = prof.readNumEntry("Font"); 113 int fontsize = prof.readNumEntry("Font");
109 int opt_echo = prof.readNumEntry("Echo"); 114 int opt_echo = prof.readNumEntry("Echo");
110 int opt_wrap = prof.readNumEntry("Wrap"); 115 int opt_wrap = prof.readNumEntry("Wrap");
111 int opt_inbound = prof.readNumEntry("Inbound"); 116 int opt_inbound = prof.readNumEntry("Inbound");
112 int opt_outbound = prof.readNumEntry("Outbound"); 117 int opt_outbound = prof.readNumEntry("Outbound");
113 118
114 switch( term ) { 119 switch( term ) {
115 case Profile::VT100: 120 case Profile::VT100:
116 m_terminalBox->setCurrentItem(id_term_vt100 ); 121 m_terminalBox->setCurrentItem(id_term_vt100 );
117 break; 122 break;
118 case Profile::VT102: 123 case Profile::VT102:
119 m_terminalBox->setCurrentItem(id_term_vt102 ); 124 m_terminalBox->setCurrentItem(id_term_vt102 );
120 break; 125 break;
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp
index df27055..45fd11d 100644
--- a/noncore/apps/opie-console/test/senderui.cpp
+++ b/noncore/apps/opie-console/test/senderui.cpp
@@ -1,79 +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; 18using namespace Opie::Core;
19using namespace Opie::Core; 19using namespace Opie::Core;
20SenderUI::SenderUI() 20SenderUI::SenderUI()
21 : Sender() { 21 : Sender() {
22 22
23 /* we do that manually */ 23 /* we do that manually */
24 Profile prof; 24 Profile prof;
25 QString str = "/dev/bty0"; 25 QString str = "/dev/bty0";
26 prof.writeEntry("Device",str ); 26 prof.writeEntry("Device",str );
27 prof.writeEntry("Baud", 19200 ); 27 prof.writeEntry("Baud", 19200 );
28 28
29 qWarning("prof " + prof.readEntry("Device") + " " + str); 29 owarn << "prof " + prof.readEntry("Device") + " " + str << oendl;
30 ser = new IOSerial(prof); 30 ser = new IOSerial(prof);
31 connect(ser, SIGNAL(received(const QByteArray&) ), 31 connect(ser, SIGNAL(received(const QByteArray&) ),
32 this, SLOT(got(const QByteArray&) ) ); 32 this, SLOT(got(const QByteArray&) ) );
33 33
34 if ( ser->open() ) 34 if ( ser->open() )
35 qWarning("opened!!!"); 35 owarn << "opened!!!" << oendl;
36 else 36 else
37 qWarning("could not open"); 37 owarn << "could not open" << oendl;
38 38
39 39
40} 40}
41SenderUI::~SenderUI() { 41SenderUI::~SenderUI() {
42 42
43} 43}
44void SenderUI::slotSendFile() { 44void SenderUI::slotSendFile() {
45 45
46 sz = new FileTransfer(FileTransfer::SY, ser); 46 sz = new FileTransfer(FileTransfer::SY, ser);
47 sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); 47 sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
48 48
49 connect (sz, SIGNAL(sent()), 49 connect (sz, SIGNAL(sent()),
50 this, SLOT(fileTransComplete())); 50 this, SLOT(fileTransComplete()));
51} 51}
52 52
53void SenderUI::slotSend() { 53void SenderUI::slotSend() {
54 QCString str = MultiLineEdit1->text().utf8(); 54 QCString str = MultiLineEdit1->text().utf8();
55 qWarning("sending: %s", str.data() ); 55 owarn << "sending: " << str.data() << "" << oendl;
56 str = str.replace( QRegExp("\n"), "\r"); 56 str = str.replace( QRegExp("\n"), "\r");
57 ser->send( str ); 57 ser->send( str );
58} 58}
59void SenderUI::got(const QByteArray& ar) { 59void SenderUI::got(const QByteArray& ar) {
60 qWarning("got:"); 60 owarn << "got:" << oendl;
61 for ( uint i = 0; i < ar.count(); i++ ) { 61 for ( uint i = 0; i < ar.count(); i++ ) {
62 printf("%c", ar[i] ); 62 printf("%c", ar[i] );
63 } 63 }
64 printf("\n"); 64 printf("\n");
65} 65}
66 66
67void SenderUI::fileTransComplete() { 67void SenderUI::fileTransComplete() {
68 68
69 qWarning("file transfer complete"); 69 owarn << "file transfer complete" << oendl;
70} 70}
71void SenderUI::send() { 71void SenderUI::send() {
72 72
73} 73}
74void SenderUI::slotRev(){ 74void SenderUI::slotRev(){
75qWarning("Going to receive!"); 75owarn << "Going to receive!" << oendl;
76FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); 76FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
77rev->receive(); 77rev->receive();
78 78
79} 79}
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index e17dfd4..c51983f 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -950,140 +950,140 @@ void Widget::setSelection(const QString& t)
950} 950}
951 951
952void Widget::onClearSelection() 952void Widget::onClearSelection()
953{ 953{
954 emit clearSelectionSignal(); 954 emit clearSelectionSignal();
955} 955}
956 956
957/* ------------------------------------------------------------------------- */ 957/* ------------------------------------------------------------------------- */
958/* */ 958/* */
959/* Keyboard */ 959/* Keyboard */
960/* */ 960/* */
961/* ------------------------------------------------------------------------- */ 961/* ------------------------------------------------------------------------- */
962 962
963//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 963//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
964// due to a bug in `QT' or the ignorance of the author to prevent 964// due to a bug in `QT' or the ignorance of the author to prevent
965// repaint events being emitted to the screen whenever one leaves 965// repaint events being emitted to the screen whenever one leaves
966// or reenters the screen to/from another application. 966// or reenters the screen to/from another application.
967// 967//
968// Troll says one needs to change focusInEvent() and focusOutEvent(), 968// Troll says one needs to change focusInEvent() and focusOutEvent(),
969// which would also let you have an in-focus cursor and an out-focus 969// which would also let you have an in-focus cursor and an out-focus
970// cursor like xterm does. 970// cursor like xterm does.
971 971
972// for the auto-hide cursor feature, I added empty focusInEvent() and 972// for the auto-hide cursor feature, I added empty focusInEvent() and
973// focusOutEvent() so that update() isn't called. 973// focusOutEvent() so that update() isn't called.
974// For auto-hide, we need to get keypress-events, but we only get them when 974// For auto-hide, we need to get keypress-events, but we only get them when
975// we have focus. 975// we have focus.
976 976
977void Widget::doScroll(int lines) 977void Widget::doScroll(int lines)
978{ 978{
979 scrollbar->setValue(scrollbar->value()+lines); 979 scrollbar->setValue(scrollbar->value()+lines);
980} 980}
981 981
982bool Widget::eventFilter( QObject *obj, QEvent *e ) 982bool Widget::eventFilter( QObject *obj, QEvent *e )
983{ 983{
984 if ( (e->type() == QEvent::Accel || 984 if ( (e->type() == QEvent::Accel ||
985 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 985 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
986 static_cast<QKeyEvent *>( e )->ignore(); 986 static_cast<QKeyEvent *>( e )->ignore();
987 return true; 987 return true;
988 } 988 }
989 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 989 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
990 return FALSE; // not us 990 return FALSE; // not us
991 if ( e->type() == QEvent::Wheel) { 991 if ( e->type() == QEvent::Wheel) {
992 QApplication::sendEvent(scrollbar, e); 992 QApplication::sendEvent(scrollbar, e);
993 } 993 }
994 994
995#ifdef FAKE_CTRL_AND_ALT 995#ifdef FAKE_CTRL_AND_ALT
996 static bool control = FALSE; 996 static bool control = FALSE;
997 static bool alt = FALSE; 997 static bool alt = FALSE;
998// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 998// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
999 bool dele=FALSE; 999 bool dele=FALSE;
1000 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1000 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1001 QKeyEvent* ke = (QKeyEvent*)e; 1001 QKeyEvent* ke = (QKeyEvent*)e;
1002 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1002 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1003 switch (ke->key()) { 1003 switch (ke->key()) {
1004 case Key_F9: // let this be "Control" 1004 case Key_F9: // let this be "Control"
1005 control = keydown; 1005 control = keydown;
1006 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1006 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1007 dele=TRUE; 1007 dele=TRUE;
1008 break; 1008 break;
1009 case Key_F13: // let this be "Alt" 1009 case Key_F13: // let this be "Alt"
1010 alt = keydown; 1010 alt = keydown;
1011 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1011 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1012 dele=TRUE; 1012 dele=TRUE;
1013 break; 1013 break;
1014 default: 1014 default:
1015 if ( control ) { 1015 if ( control ) {
1016 int a = toupper(ke->ascii())-64; 1016 int a = toupper(ke->ascii())-64;
1017 if ( a >= 0 && a < ' ' ) { 1017 if ( a >= 0 && a < ' ' ) {
1018 e = new QKeyEvent(e->type(), ke->key(), 1018 e = new QKeyEvent(e->type(), ke->key(),
1019 a, ke->state()|ControlButton, QChar(a,0)); 1019 a, ke->state()|ControlButton, QChar(a,0));
1020 dele=TRUE; 1020 dele=TRUE;
1021 } 1021 }
1022 } 1022 }
1023 if ( alt ) { 1023 if ( alt ) {
1024 e = new QKeyEvent(e->type(), ke->key(), 1024 e = new QKeyEvent(e->type(), ke->key(),
1025 ke->ascii(), ke->state()|AltButton, ke->text()); 1025 ke->ascii(), ke->state()|AltButton, ke->text());
1026 dele=TRUE; 1026 dele=TRUE;
1027 } 1027 }
1028 } 1028 }
1029 } 1029 }
1030#endif 1030#endif
1031 1031
1032 if ( e->type() == QEvent::KeyPress ) { 1032 if ( e->type() == QEvent::KeyPress ) {
1033 QKeyEvent* ke = (QKeyEvent*)e; 1033 QKeyEvent* ke = (QKeyEvent*)e;
1034 actSel=0; // Key stroke implies a screen update, so Widget won't 1034 actSel=0; // Key stroke implies a screen update, so Widget won't
1035 // know where the current selection is. 1035 // know where the current selection is.
1036 1036
1037// qDebug("key pressed is 0x%x",ke->key()); 1037// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
1038 1038
1039 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 1039 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
1040 1040
1041// qDebug("key pressed 2 is 0x%x",ke->key()); 1041// odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl;
1042 emitText("\\"); // expose 1042 emitText("\\"); // expose
1043 } else 1043 } else
1044 emit keyPressedSignal(ke); // expose 1044 emit keyPressedSignal(ke); // expose
1045 ke->accept(); 1045 ke->accept();
1046#ifdef FAKE_CTRL_AND_ALT 1046#ifdef FAKE_CTRL_AND_ALT
1047 if ( dele ) delete e; 1047 if ( dele ) delete e;
1048#endif 1048#endif
1049 return true; // stop the event 1049 return true; // stop the event
1050 } 1050 }
1051 if ( e->type() == QEvent::Enter ) { 1051 if ( e->type() == QEvent::Enter ) {
1052 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1052 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1053 this, SLOT(onClearSelection()) ); 1053 this, SLOT(onClearSelection()) );
1054 } 1054 }
1055 if ( e->type() == QEvent::Leave ) { 1055 if ( e->type() == QEvent::Leave ) {
1056 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1056 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1057 this, SLOT(onClearSelection()) ); 1057 this, SLOT(onClearSelection()) );
1058 } 1058 }
1059 return QFrame::eventFilter( obj, e ); 1059 return QFrame::eventFilter( obj, e );
1060} 1060}
1061 1061
1062/* ------------------------------------------------------------------------- */ 1062/* ------------------------------------------------------------------------- */
1063/* */ 1063/* */
1064/* Frame */ 1064/* Frame */
1065/* */ 1065/* */
1066/* ------------------------------------------------------------------------- */ 1066/* ------------------------------------------------------------------------- */
1067 1067
1068void Widget::frameChanged() 1068void Widget::frameChanged()
1069{ 1069{
1070 propagateSize(); 1070 propagateSize();
1071 update(); 1071 update();
1072} 1072}
1073 1073
1074/* ------------------------------------------------------------------------- */ 1074/* ------------------------------------------------------------------------- */
1075/* */ 1075/* */
1076/* Sound */ 1076/* Sound */
1077/* */ 1077/* */
1078/* ------------------------------------------------------------------------- */ 1078/* ------------------------------------------------------------------------- */
1079 1079
1080void Widget::Bell() 1080void Widget::Bell()
1081{ 1081{
1082 QApplication::beep(); 1082 QApplication::beep();
1083} 1083}
1084 1084
1085/* ------------------------------------------------------------------------- */ 1085/* ------------------------------------------------------------------------- */
1086/* */ 1086/* */
1087/* Auxiluary */ 1087/* Auxiluary */
1088/* */ 1088/* */
1089/* ------------------------------------------------------------------------- */ 1089/* ------------------------------------------------------------------------- */
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp
index 96dda1c..ab25919 100644
--- a/noncore/apps/opie-console/widget_layer.cpp
+++ b/noncore/apps/opie-console/widget_layer.cpp
@@ -30,137 +30,137 @@ WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *na
30 m_lines = 1; 30 m_lines = 1;
31 m_columns = 1; 31 m_columns = 1;
32 m_resizing = false; 32 m_resizing = false;
33 33
34 // just for demonstrating 34 // just for demonstrating
35 //m_image = QArray<Character>( m_lines * m_columns ); 35 //m_image = QArray<Character>( m_lines * m_columns );
36 m_image = QArray<Character>( 1 ); 36 m_image = QArray<Character>( 1 );
37 37
38 // we need to install an event filter, 38 // we need to install an event filter,
39 // to emit keypresses. 39 // to emit keypresses.
40 qApp->installEventFilter( this ); 40 qApp->installEventFilter( this );
41 41
42} 42}
43 43
44 44
45WidgetLayer::~WidgetLayer() 45WidgetLayer::~WidgetLayer()
46{ 46{
47 // clean up 47 // clean up
48 delete m_image; 48 delete m_image;
49} 49}
50 50
51 51
52QSize WidgetLayer::sizeHint() 52QSize WidgetLayer::sizeHint()
53{ 53{
54 return size(); 54 return size();
55} 55}
56 56
57 57
58/* --------------------------------- audio ---------------------------------- */ 58/* --------------------------------- audio ---------------------------------- */
59 59
60void WidgetLayer::bell() 60void WidgetLayer::bell()
61{ 61{
62 QApplication::beep(); 62 QApplication::beep();
63} 63}
64 64
65bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) 65bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
66{ 66{
67 if ( (e->type() == QEvent::Accel || 67 if ( (e->type() == QEvent::Accel ||
68 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 68 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
69 static_cast<QKeyEvent *>( e )->ignore(); 69 static_cast<QKeyEvent *>( e )->ignore();
70 return true; 70 return true;
71 } 71 }
72 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 72 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
73 return false; // not us 73 return false; // not us
74 74
75#ifdef FAKE_CTRL_AND_ALT 75#ifdef FAKE_CTRL_AND_ALT
76 static bool control = false; 76 static bool control = false;
77 static bool alt = false; 77 static bool alt = false;
78// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 78// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
79 bool dele = false; 79 bool dele = false;
80 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 80 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
81 QKeyEvent* ke = (QKeyEvent*)e; 81 QKeyEvent* ke = (QKeyEvent*)e;
82 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 82 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
83 switch (ke->key()) { 83 switch (ke->key()) {
84 case Key_F9: // let this be "Control" 84 case Key_F9: // let this be "Control"
85 control = keydown; 85 control = keydown;
86 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 86 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
87 dele=TRUE; 87 dele=TRUE;
88 break; 88 break;
89 case Key_F13: // let this be "Alt" 89 case Key_F13: // let this be "Alt"
90 alt = keydown; 90 alt = keydown;
91 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 91 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
92 dele=TRUE; 92 dele=TRUE;
93 break; 93 break;
94 default: 94 default:
95 if ( control ) { 95 if ( control ) {
96 int a = toupper(ke->ascii())-64; 96 int a = toupper(ke->ascii())-64;
97 if ( a >= 0 && a < ' ' ) { 97 if ( a >= 0 && a < ' ' ) {
98 e = new QKeyEvent(e->type(), ke->key(), 98 e = new QKeyEvent(e->type(), ke->key(),
99 a, ke->state()|ControlButton, 99 a, ke->state()|ControlButton,
100QChar(a,0)); 100QChar(a,0));
101 dele=TRUE; 101 dele=TRUE;
102 } 102 }
103 } 103 }
104 if ( alt ) { 104 if ( alt ) {
105 e = new QKeyEvent(e->type(), ke->key(), 105 e = new QKeyEvent(e->type(), ke->key(),
106 ke->ascii(), ke->state()|AltButton, ke->text()); 106 ke->ascii(), ke->state()|AltButton, ke->text());
107 dele=TRUE; 107 dele=TRUE;
108 } 108 }
109 } 109 }
110 } 110 }
111#endif 111#endif
112 112
113 if ( e->type() == QEvent::KeyPress ) { 113 if ( e->type() == QEvent::KeyPress ) {
114 QKeyEvent* ke = (QKeyEvent*)e; 114 QKeyEvent* ke = (QKeyEvent*)e;
115 //actSel=0; // Key stroke implies a screen update, so Widget won't 115 //actSel=0; // Key stroke implies a screen update, so Widget won't
116 // know where the current selection is. 116 // know where the current selection is.
117 117
118// qDebug("key pressed is 0x%x",ke->key()); 118// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
119 119
120 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 120 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
121 insertText("\\"); // expose 121 insertText("\\"); // expose
122 } else 122 } else
123 emit keyPressed( ke ); // expose 123 emit keyPressed( ke ); // expose
124 ke->accept(); 124 ke->accept();
125#ifdef FAKE_CTRL_AND_ALT 125#ifdef FAKE_CTRL_AND_ALT
126 if ( dele ) delete e; 126 if ( dele ) delete e;
127#endif 127#endif
128 return true; // stop the event 128 return true; // stop the event
129 } 129 }
130 return QFrame::eventFilter( obj, e ); 130 return QFrame::eventFilter( obj, e );
131} 131}
132 132
133 133
134/* --------------------------------- screen --------------------------------- */ 134/* --------------------------------- screen --------------------------------- */
135 135
136 136
137void WidgetLayer::propagateSize() 137void WidgetLayer::propagateSize()
138{ 138{
139 QArray<Character> oldimage = m_image.copy(); 139 QArray<Character> oldimage = m_image.copy();
140 int oldlines = m_lines; 140 int oldlines = m_lines;
141 int oldcolumns = m_columns; 141 int oldcolumns = m_columns;
142 142
143 makeImage(); 143 makeImage();
144 144
145 // copy old image, to reduce flicker 145 // copy old image, to reduce flicker
146 if ( ! oldimage.isEmpty() ) 146 if ( ! oldimage.isEmpty() )
147 { 147 {
148 int lins = QMIN( oldlines, m_lines ); 148 int lins = QMIN( oldlines, m_lines );
149 int cols = QMIN( oldcolumns, m_columns ); 149 int cols = QMIN( oldcolumns, m_columns );
150 for ( int lin = 0; lin < lins; ++lin ) 150 for ( int lin = 0; lin < lins; ++lin )
151 { 151 {
152 memcpy( (void*) &m_image[m_columns*lin], 152 memcpy( (void*) &m_image[m_columns*lin],
153 (void*) &oldimage[oldcolumns*lin], 153 (void*) &oldimage[oldcolumns*lin],
154 cols*sizeof( Character ) ); 154 cols*sizeof( Character ) );
155 } 155 }
156 } 156 }
157 else 157 else
158 clearImage(); 158 clearImage();
159 159
160 delete oldimage; 160 delete oldimage;
161 161
162 m_resizing = true; 162 m_resizing = true;
163 emit imageSizeChanged( m_lines, m_columns ); 163 emit imageSizeChanged( m_lines, m_columns );
164 m_resizing = false; 164 m_resizing = false;
165} 165}
166 166
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp
index 90e1a70..aa03060 100644
--- a/noncore/apps/opie-write/mainwindow.cpp
+++ b/noncore/apps/opie-write/mainwindow.cpp
@@ -1,76 +1,80 @@
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#include "mainwindow.h" 22#include "mainwindow.h"
23
24/* OPIE */
25#include <opie2/odebug.h>
23#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
24#include <qpe/applnk.h> 27#include <qpe/applnk.h>
25#include <qpe/resource.h> 28#include <qpe/resource.h>
26#include <qpe/fontdatabase.h> 29#include <qpe/fontdatabase.h>
30using namespace Opie::Core;
27 31
28//#include "qspellchecker.h" 32/* QT */
29#include "qtextedit.h" 33#include "qtextedit.h"
30#include <qaction.h> 34#include <qaction.h>
31#include <qtoolbar.h> 35#include <qtoolbar.h>
32#include <qtoolbutton.h> 36#include <qtoolbutton.h>
33#include <qtabwidget.h> 37#include <qtabwidget.h>
34#include <qapplication.h> 38#include <qapplication.h>
35#include <qfontdatabase.h> 39#include <qfontdatabase.h>
36#include <qcombobox.h> 40#include <qcombobox.h>
37#include <qlineedit.h> 41#include <qlineedit.h>
38#include <qfileinfo.h> 42#include <qfileinfo.h>
39#include <qfile.h> 43#include <qfile.h>
40#include <qfiledialog.h> 44#include <qfiledialog.h>
41#include <qprinter.h> 45#include <qprinter.h>
42#include <qpaintdevicemetrics.h> 46#include <qpaintdevicemetrics.h>
43#include <qmenubar.h> 47#include <qmenubar.h>
44#include <qpopupmenu.h> 48#include <qpopupmenu.h>
45#include <qcolordialog.h> 49#include <qcolordialog.h>
46#include <qpainter.h> 50#include <qpainter.h>
47#include <qstyle.h> 51#include <qstyle.h>
48 52
49class ButtonMenu : public QToolButton 53class ButtonMenu : public QToolButton
50{ 54{
51 Q_OBJECT 55 Q_OBJECT
52public: 56public:
53 ButtonMenu( QWidget *parent, const char *name=0 ) 57 ButtonMenu( QWidget *parent, const char *name=0 )
54 : QToolButton( parent, name ), current(0) 58 : QToolButton( parent, name ), current(0)
55 { 59 {
56 setPopup( new QPopupMenu( this ) ); 60 setPopup( new QPopupMenu( this ) );
57 setPopupDelay( 1 ); 61 setPopupDelay( 1 );
58 connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); 62 connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) );
59 } 63 }
60 64
61 int insertItem(const QIconSet &icon, const QString &text, int id ) { 65 int insertItem(const QIconSet &icon, const QString &text, int id ) {
62 if ( !popup()->count() ) { 66 if ( !popup()->count() ) {
63 setIconSet( icon ); 67 setIconSet( icon );
64 current = id; 68 current = id;
65 } 69 }
66 return popup()->insertItem( icon, text, id ); 70 return popup()->insertItem( icon, text, id );
67 } 71 }
68 72
69 void setCurrentItem( int id ) { 73 void setCurrentItem( int id ) {
70 if ( id != current ) { 74 if ( id != current ) {
71 current = id; 75 current = id;
72 setIconSet( *popup()->iconSet( id ) ); 76 setIconSet( *popup()->iconSet( id ) );
73 } 77 }
74 } 78 }
75 79
76 virtual QSize sizeHint() const { 80 virtual QSize sizeHint() const {
@@ -399,128 +403,128 @@ void MainWindow::fontChanged( const QFont &f )
399{ 403{
400 comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) ); 404 comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) );
401 updateFontSizeCombo( f ); 405 updateFontSizeCombo( f );
402 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); 406 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
403 actionTextBold->setOn( f.bold() ); 407 actionTextBold->setOn( f.bold() );
404 actionTextItalic->setOn( f.italic() ); 408 actionTextItalic->setOn( f.italic() );
405 actionTextUnderline->setOn( f.underline() ); 409 actionTextUnderline->setOn( f.underline() );
406} 410}
407 411
408void MainWindow::colorChanged( const QColor & ) 412void MainWindow::colorChanged( const QColor & )
409{ 413{
410} 414}
411 415
412void MainWindow::alignmentChanged( int a ) 416void MainWindow::alignmentChanged( int a )
413{ 417{
414 if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) { 418 if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) {
415 alignMenu->setCurrentItem(AlignLeft); 419 alignMenu->setCurrentItem(AlignLeft);
416 } else if ( ( a & AlignCenter ) ) { 420 } else if ( ( a & AlignCenter ) ) {
417 alignMenu->setCurrentItem(AlignCenter); 421 alignMenu->setCurrentItem(AlignCenter);
418 } else if ( ( a & AlignRight ) ) { 422 } else if ( ( a & AlignRight ) ) {
419 alignMenu->setCurrentItem(AlignRight); 423 alignMenu->setCurrentItem(AlignRight);
420 } else if ( ( a & Qt3::AlignJustify ) ) { 424 } else if ( ( a & Qt3::AlignJustify ) ) {
421 alignMenu->setCurrentItem(Qt3::AlignJustify); 425 alignMenu->setCurrentItem(Qt3::AlignJustify);
422 } 426 }
423} 427}
424 428
425void MainWindow::editorChanged( QWidget * ) 429void MainWindow::editorChanged( QWidget * )
426{ 430{
427 if ( !currentEditor() ) 431 if ( !currentEditor() )
428 return; 432 return;
429 fontChanged( currentEditor()->font() ); 433 fontChanged( currentEditor()->font() );
430 colorChanged( currentEditor()->color() ); 434 colorChanged( currentEditor()->color() );
431 alignmentChanged( currentEditor()->alignment() ); 435 alignmentChanged( currentEditor()->alignment() );
432} 436}
433 437
434void MainWindow::fileOpen() 438void MainWindow::fileOpen()
435{ 439{
436 save(); 440 save();
437 editorStack->raiseWidget( fileSelector ); 441 editorStack->raiseWidget( fileSelector );
438 fileSelector->reread(); 442 fileSelector->reread();
439 hideEditTools(); 443 hideEditTools();
440 fileSelector->setNewVisible( TRUE ); 444 fileSelector->setNewVisible( TRUE );
441 clear(); 445 clear();
442 updateCaption(); 446 updateCaption();
443} 447}
444 448
445void MainWindow::fileRevert() 449void MainWindow::fileRevert()
446{ 450{
447 qDebug( "QMainWindow::fileRevert needs to be done" ); 451 odebug << "QMainWindow::fileRevert needs to be done" << oendl;
448} 452}
449 453
450void MainWindow::fileNew() 454void MainWindow::fileNew()
451{ 455{
452 editor->setTextFormat( Qt::RichText ); 456 editor->setTextFormat( Qt::RichText );
453 save(); 457 save();
454 newFile(DocLnk()); 458 newFile(DocLnk());
455} 459}
456 460
457void MainWindow::insertTable() 461void MainWindow::insertTable()
458{ 462{
459 qDebug( "MainWindow::insertTable() needs to be done" ); 463 odebug << "MainWindow::insertTable() needs to be done" << oendl;
460} 464}
461 465
462void MainWindow::newFile( const DocLnk &dl ) 466void MainWindow::newFile( const DocLnk &dl )
463{ 467{
464 DocLnk nf = dl; 468 DocLnk nf = dl;
465 nf.setType( "text/html" ); 469 nf.setType( "text/html" );
466 clear(); 470 clear();
467 editorStack->raiseWidget( editor ); 471 editorStack->raiseWidget( editor );
468 editor->viewport()->setFocus(); 472 editor->viewport()->setFocus();
469 doc = new DocLnk( nf ); 473 doc = new DocLnk( nf );
470 updateCaption(); 474 updateCaption();
471} 475}
472 476
473void MainWindow::openFile( const DocLnk &dl ) 477void MainWindow::openFile( const DocLnk &dl )
474{ 478{
475 FileManager fm; 479 FileManager fm;
476 QString txt; 480 QString txt;
477 if ( !fm.loadFile( dl, txt ) ) 481 if ( !fm.loadFile( dl, txt ) )
478 qDebug( "couldn't open file" ); 482 odebug << "couldn't open file" << oendl;
479 clear(); 483 clear();
480 editorStack->raiseWidget( editor ); 484 editorStack->raiseWidget( editor );
481 editor->viewport()->setFocus(); 485 editor->viewport()->setFocus();
482 doc = new DocLnk( dl ); 486 doc = new DocLnk( dl );
483 editor->setText( txt ); 487 editor->setText( txt );
484 editor->setModified( FALSE ); 488 editor->setModified( FALSE );
485 updateCaption(); 489 updateCaption();
486} 490}
487 491
488void MainWindow::showEditTools( void ) 492void MainWindow::showEditTools( void )
489{ 493{
490 tbMenu->show(); 494 tbMenu->show();
491 tbEdit->show(); 495 tbEdit->show();
492 tbFont->show(); 496 tbFont->show();
493 tbStyle->show(); 497 tbStyle->show();
494} 498}
495 499
496void MainWindow::hideEditTools( void ) 500void MainWindow::hideEditTools( void )
497{ 501{
498 // let's reset the buttons... 502 // let's reset the buttons...
499 actionTextBold->setOn( FALSE ); 503 actionTextBold->setOn( FALSE );
500 actionTextItalic->setOn( FALSE ); 504 actionTextItalic->setOn( FALSE );
501 actionTextUnderline->setOn( FALSE ); 505 actionTextUnderline->setOn( FALSE );
502 //comboFont->setCurrentText( QApplication::font().family() ); 506 //comboFont->setCurrentText( QApplication::font().family() );
503 comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); 507 comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) );
504 tbMenu->hide(); 508 tbMenu->hide();
505 tbEdit->hide(); 509 tbEdit->hide();
506 tbFont->hide(); 510 tbFont->hide();
507 tbStyle->hide(); 511 tbStyle->hide();
508} 512}
509 513
510 514
511void MainWindow::save() 515void MainWindow::save()
512{ 516{
513 if ( !doc ) 517 if ( !doc )
514 return; 518 return;
515 if ( !editor->isModified() ) 519 if ( !editor->isModified() )
516 return; 520 return;
517 521
518 QString rt = editor->text(); 522 QString rt = editor->text();
519 523
520 // quick hack to get around formatting... 524 // quick hack to get around formatting...
521 editor->setTextFormat( Qt::PlainText ); 525 editor->setTextFormat( Qt::PlainText );
522 QString pt = editor->text(); 526 QString pt = editor->text();
523 editor->setTextFormat( Qt::RichText ); 527 editor->setTextFormat( Qt::RichText );
524 528
525 if ( doc->name().isEmpty() ) { 529 if ( doc->name().isEmpty() ) {
526 unsigned ispace = pt.find( ' ' ); 530 unsigned ispace = pt.find( ' ' );
diff --git a/noncore/apps/opie-write/opie-write.pro b/noncore/apps/opie-write/opie-write.pro
index 044ce7e..8e514d4 100644
--- a/noncore/apps/opie-write/opie-write.pro
+++ b/noncore/apps/opie-write/opie-write.pro
@@ -1,27 +1,26 @@
1 1
2CONFIG += qt warn on quick-app 2CONFIG += qt warn on quick-app
3
4 3
5HEADERS = qcleanuphandler.h \ 4HEADERS = qcleanuphandler.h \
6 qcomplextext_p.h \ 5 qcomplextext_p.h \
7 qrichtext_p.h \ 6 qrichtext_p.h \
8 qstylesheet.h \ 7 qstylesheet.h \
9 qtextedit.h \ 8 qtextedit.h \
10 mainwindow.h 9 mainwindow.h
11 10
12SOURCES = qcomplextext.cpp \ 11SOURCES = qcomplextext.cpp \
13 qstylesheet.cpp \ 12 qstylesheet.cpp \
14 qrichtext_p.cpp \ 13 qrichtext_p.cpp \
15 qrichtext.cpp \ 14 qrichtext.cpp \
16 qtextedit.cpp \ 15 qtextedit.cpp \
17 main.cpp \ 16 main.cpp \
18 mainwindow.cpp 17 mainwindow.cpp
19 18
20INCLUDEPATH += $(OPIEDIR)/include 19INCLUDEPATH += $(OPIEDIR)/include
21DEPENDPATH += $(OPIEDIR)/include 20DEPENDPATH += $(OPIEDIR)/include
22LIBS += -lqpe -lopiecore2 21LIBS += -lqpe -lopiecore2
23 22
24TARGET = opie-write 23TARGET = opie-write
25 24
26 25
27include ( $(OPIEDIR)/include.pro ) 26include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-write/qcomplextext.cpp b/noncore/apps/opie-write/qcomplextext.cpp
index 473f184..00a91c5 100644
--- a/noncore/apps/opie-write/qcomplextext.cpp
+++ b/noncore/apps/opie-write/qcomplextext.cpp
@@ -61,86 +61,86 @@ QBidiContext::~QBidiContext()
61{ 61{
62 if( parent && parent->deref() ) 62 if( parent && parent->deref() )
63 delete parent; 63 delete parent;
64} 64}
65 65
66/* 66/*
67 Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on 67 Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on
68 arabic). 68 arabic).
69 69
70 Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). 70 Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent).
71 transparent joining is not encoded in QChar::joining(), but applies to all combining marks and format marks. 71 transparent joining is not encoded in QChar::joining(), but applies to all combining marks and format marks.
72 72
73 Right join-causing: dual + center 73 Right join-causing: dual + center
74 Left join-causing: dual + right + center 74 Left join-causing: dual + right + center
75 75
76 Rules are as follows (for a string already in visual order, as we have it here): 76 Rules are as follows (for a string already in visual order, as we have it here):
77 77
78 R1 Transparent characters do not affect joining behaviour. 78 R1 Transparent characters do not affect joining behaviour.
79 R2 A right joining character, that has a right join-causing char on the right will get form XRight 79 R2 A right joining character, that has a right join-causing char on the right will get form XRight
80 (R3 A left joining character, that has a left join-causing char on the left will get form XLeft) 80 (R3 A left joining character, that has a left join-causing char on the left will get form XLeft)
81 Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode 81 Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode
82 R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on 82 R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on
83 the right will get form XMedial 83 the right will get form XMedial
84 R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left 84 R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left
85 will get form XRight 85 will get form XRight
86 R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right 86 R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right
87 will get form XLeft 87 will get form XLeft
88 R7 Otherwise the character will get form XIsolated 88 R7 Otherwise the character will get form XIsolated
89 89
90 Additionally we have to do the minimal ligature support for lam-alef ligatures: 90 Additionally we have to do the minimal ligature support for lam-alef ligatures:
91 91
92 L1 Transparent characters do not affect ligature behaviour. 92 L1 Transparent characters do not affect ligature behaviour.
93 L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft) 93 L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft)
94 L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated) 94 L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated)
95 95
96 The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with 96 The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with
97 previous and left with next in the above rules ;-) 97 previous and left with next in the above rules ;-)
98*/ 98*/
99 99
100/* 100/*
101 Two small helper functions for arabic shaping. They get the next shape causing character on either 101 Two small helper functions for arabic shaping. They get the next shape causing character on either
102 side of the char in question. Implements rule R1. 102 side of the char in question. Implements rule R1.
103 103
104 leftChar() returns true if the char to the left is a left join-causing char 104 leftChar() returns true if the char to the left is a left join-causing char
105 rightChar() returns true if the char to the right is a right join-causing char 105 rightChar() returns true if the char to the right is a right join-causing char
106*/ 106*/
107static inline const QChar *prevChar( const QString &str, int pos ) 107static inline const QChar *prevChar( const QString &str, int pos )
108{ 108{
109 //qDebug("leftChar: pos=%d", pos); 109 //odebug << "leftChar: pos=" << pos << "" << oendl;
110 pos--; 110 pos--;
111 const QChar *ch = str.unicode() + pos; 111 const QChar *ch = str.unicode() + pos;
112 while( pos > -1 ) { 112 while( pos > -1 ) {
113 if( !ch->isMark() ) 113 if( !ch->isMark() )
114 return ch; 114 return ch;
115 pos--; 115 pos--;
116 ch--; 116 ch--;
117 } 117 }
118 return &QChar::replacement; 118 return &QChar::replacement;
119} 119}
120 120
121static inline const QChar *nextChar( const QString &str, int pos) 121static inline const QChar *nextChar( const QString &str, int pos)
122{ 122{
123 pos++; 123 pos++;
124 int len = str.length(); 124 int len = str.length();
125 const QChar *ch = str.unicode() + pos; 125 const QChar *ch = str.unicode() + pos;
126 while( pos < len ) { 126 while( pos < len ) {
127 //qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); 127 //odebug << "rightChar: " << pos << " isLetter=" << ch.isLetter() << ", joining=" << ch.joining() << "" << oendl;
128 if( !ch->isMark() ) 128 if( !ch->isMark() )
129 return ch; 129 return ch;
130 // assume it's a transparent char, this might not be 100% correct 130 // assume it's a transparent char, this might not be 100% correct
131 pos++; 131 pos++;
132 ch++; 132 ch++;
133 } 133 }
134 return &QChar::replacement; 134 return &QChar::replacement;
135} 135}
136 136
137static inline bool prevVisualCharJoins( const QString &str, int pos) 137static inline bool prevVisualCharJoins( const QString &str, int pos)
138{ 138{
139 return ( prevChar( str, pos )->joining() != QChar::OtherJoining ); 139 return ( prevChar( str, pos )->joining() != QChar::OtherJoining );
140} 140}
141 141
142static inline bool nextVisualCharJoins( const QString &str, int pos) 142static inline bool nextVisualCharJoins( const QString &str, int pos)
143{ 143{
144 QChar::Joining join = nextChar( str, pos )->joining(); 144 QChar::Joining join = nextChar( str, pos )->joining();
145 return ( join == QChar::Dual || join == QChar::Center ); 145 return ( join == QChar::Dual || join == QChar::Center );
146} 146}
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index b77a0fc..c27eb1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -1,92 +1,98 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of the internal Qt classes dealing with rich text 4** Implementation of the internal Qt classes dealing with rich text
5** 5**
6** Created : 990101 6** Created : 990101
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qrichtext_p.h" 38#include "qrichtext_p.h"
39 39
40/* OPIE */
41#include <opie2/odebug.h>
42using namespace Opie::Core;
43
44/* QT */
40#include "qdragobject.h" 45#include "qdragobject.h"
41#include "qpaintdevicemetrics.h" 46#include "qpaintdevicemetrics.h"
42#include "qdrawutil.h" 47#include "qdrawutil.h"
43#include "qcleanuphandler.h" 48#include "qcleanuphandler.h"
44 49
50/* STD */
45#include <stdlib.h> 51#include <stdlib.h>
46 52
47using namespace Qt3; 53using namespace Qt3;
48 54
49static QTextCursor* richTextExportStart = 0; 55static QTextCursor* richTextExportStart = 0;
50static QTextCursor* richTextExportEnd = 0; 56static QTextCursor* richTextExportEnd = 0;
51 57
52static QTextFormatCollection *qFormatCollection = 0; 58static QTextFormatCollection *qFormatCollection = 0;
53 59
54const int border_tolerance = 2; 60const int border_tolerance = 2;
55 61
56#ifdef Q_WS_WIN 62#ifdef Q_WS_WIN
57#include "qt_windows.h" 63#include "qt_windows.h"
58#endif 64#endif
59 65
60#define QChar_linesep QChar(0x2028U) 66#define QChar_linesep QChar(0x2028U)
61 67
62static inline bool is_printer( QPainter *p ) 68static inline bool is_printer( QPainter *p )
63{ 69{
64 if ( !p || !p->device() ) 70 if ( !p || !p->device() )
65 return FALSE; 71 return FALSE;
66 return p->device()->devType() == QInternal::Printer; 72 return p->device()->devType() == QInternal::Printer;
67} 73}
68 74
69static inline int scale( int value, QPainter *painter ) 75static inline int scale( int value, QPainter *painter )
70{ 76{
71 if ( is_printer( painter ) ) { 77 if ( is_printer( painter ) ) {
72 QPaintDeviceMetrics metrics( painter->device() ); 78 QPaintDeviceMetrics metrics( painter->device() );
73#if defined(Q_WS_X11) 79#if defined(Q_WS_X11)
74 value = value * metrics.logicalDpiY() / QPaintDevice::x11AppDpiY(); 80 value = value * metrics.logicalDpiY() / QPaintDevice::x11AppDpiY();
75#elif defined (Q_WS_WIN) 81#elif defined (Q_WS_WIN)
76 HDC hdc = GetDC( 0 ); 82 HDC hdc = GetDC( 0 );
77 int gdc = GetDeviceCaps( hdc, LOGPIXELSY ); 83 int gdc = GetDeviceCaps( hdc, LOGPIXELSY );
78 if ( gdc ) 84 if ( gdc )
79 value = value * metrics.logicalDpiY() / gdc; 85 value = value * metrics.logicalDpiY() / gdc;
80 ReleaseDC( 0, hdc ); 86 ReleaseDC( 0, hdc );
81#elif defined (Q_WS_MAC) 87#elif defined (Q_WS_MAC)
82 value = value * metrics.logicalDpiY() / 75; // ##### FIXME 88 value = value * metrics.logicalDpiY() / 75; // ##### FIXME
83#elif defined (Q_WS_QWS) 89#elif defined (Q_WS_QWS)
84 value = value * metrics.logicalDpiY() / 75; 90 value = value * metrics.logicalDpiY() / 75;
85#endif 91#endif
86 } 92 }
87 return value; 93 return value;
88} 94}
89 95
90// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 96// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91 97
92void QTextCommandHistory::addCommand( QTextCommand *cmd ) 98void QTextCommandHistory::addCommand( QTextCommand *cmd )
@@ -139,125 +145,125 @@ QTextCursor *QTextCommandHistory::redo( QTextCursor *c )
139 } 145 }
140 return 0; 146 return 0;
141} 147}
142 148
143bool QTextCommandHistory::isUndoAvailable() 149bool QTextCommandHistory::isUndoAvailable()
144{ 150{
145 return current > -1; 151 return current > -1;
146} 152}
147 153
148bool QTextCommandHistory::isRedoAvailable() 154bool QTextCommandHistory::isRedoAvailable()
149{ 155{
150 return current > -1 && current < (int)history.count() - 1 || current == -1 && history.count() > 0; 156 return current > -1 && current < (int)history.count() - 1 || current == -1 && history.count() > 0;
151} 157}
152 158
153// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 159// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
154 160
155QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, 161QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
156 const QByteArray& oldStyleInfo ) 162 const QByteArray& oldStyleInfo )
157 : QTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo ) 163 : QTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo )
158{ 164{
159 for ( int j = 0; j < (int)text.size(); ++j ) { 165 for ( int j = 0; j < (int)text.size(); ++j ) {
160 if ( text[ j ].format() ) 166 if ( text[ j ].format() )
161 text[ j ].format()->addRef(); 167 text[ j ].format()->addRef();
162 } 168 }
163} 169}
164 170
165QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) 171QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
166 : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str ) 172 : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str )
167{ 173{
168 for ( int i = 0; i < (int)text.size(); ++i ) { 174 for ( int i = 0; i < (int)text.size(); ++i ) {
169 if ( text[ i ].format() ) 175 if ( text[ i ].format() )
170 text[ i ].format()->addRef(); 176 text[ i ].format()->addRef();
171 } 177 }
172} 178}
173 179
174QTextDeleteCommand::~QTextDeleteCommand() 180QTextDeleteCommand::~QTextDeleteCommand()
175{ 181{
176 for ( int i = 0; i < (int)text.size(); ++i ) { 182 for ( int i = 0; i < (int)text.size(); ++i ) {
177 if ( text[ i ].format() ) 183 if ( text[ i ].format() )
178 text[ i ].format()->removeRef(); 184 text[ i ].format()->removeRef();
179 } 185 }
180 text.resize( 0 ); 186 text.resize( 0 );
181} 187}
182 188
183QTextCursor *QTextDeleteCommand::execute( QTextCursor *c ) 189QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
184{ 190{
185 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 191 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
186 if ( !s ) { 192 if ( !s ) {
187 qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); 193 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
188 return 0; 194 return 0;
189 } 195 }
190 196
191 cursor.setParagraph( s ); 197 cursor.setParagraph( s );
192 cursor.setIndex( index ); 198 cursor.setIndex( index );
193 int len = text.size(); 199 int len = text.size();
194 if ( c ) 200 if ( c )
195 *c = cursor; 201 *c = cursor;
196 if ( doc ) { 202 if ( doc ) {
197 doc->setSelectionStart( QTextDocument::Temp, cursor ); 203 doc->setSelectionStart( QTextDocument::Temp, cursor );
198 for ( int i = 0; i < len; ++i ) 204 for ( int i = 0; i < len; ++i )
199 cursor.gotoNextLetter(); 205 cursor.gotoNextLetter();
200 doc->setSelectionEnd( QTextDocument::Temp, cursor ); 206 doc->setSelectionEnd( QTextDocument::Temp, cursor );
201 doc->removeSelectedText( QTextDocument::Temp, &cursor ); 207 doc->removeSelectedText( QTextDocument::Temp, &cursor );
202 if ( c ) 208 if ( c )
203 *c = cursor; 209 *c = cursor;
204 } else { 210 } else {
205 s->remove( index, len ); 211 s->remove( index, len );
206 } 212 }
207 213
208 return c; 214 return c;
209} 215}
210 216
211QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c ) 217QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
212{ 218{
213 QTextParagraph *s = doc ? doc->paragAt( id ) : parag; 219 QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
214 if ( !s ) { 220 if ( !s ) {
215 qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() ); 221 owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
216 return 0; 222 return 0;
217 } 223 }
218 224
219 cursor.setParagraph( s ); 225 cursor.setParagraph( s );
220 cursor.setIndex( index ); 226 cursor.setIndex( index );
221 QString str = QTextString::toString( text ); 227 QString str = QTextString::toString( text );
222 cursor.insert( str, TRUE, &text ); 228 cursor.insert( str, TRUE, &text );
223 cursor.setParagraph( s ); 229 cursor.setParagraph( s );
224 cursor.setIndex( index ); 230 cursor.setIndex( index );
225 if ( c ) { 231 if ( c ) {
226 c->setParagraph( s ); 232 c->setParagraph( s );
227 c->setIndex( index ); 233 c->setIndex( index );
228 for ( int i = 0; i < (int)text.size(); ++i ) 234 for ( int i = 0; i < (int)text.size(); ++i )
229 c->gotoNextLetter(); 235 c->gotoNextLetter();
230 } 236 }
231 237
232 if ( !styleInformation.isEmpty() ) { 238 if ( !styleInformation.isEmpty() ) {
233 QDataStream styleStream( styleInformation, IO_ReadOnly ); 239 QDataStream styleStream( styleInformation, IO_ReadOnly );
234 int num; 240 int num;
235 styleStream >> num; 241 styleStream >> num;
236 QTextParagraph *p = s; 242 QTextParagraph *p = s;
237 while ( num-- && p ) { 243 while ( num-- && p ) {
238 p->readStyleInformation( styleStream ); 244 p->readStyleInformation( styleStream );
239 p = p->next(); 245 p = p->next();
240 } 246 }
241 } 247 }
242 s = cursor.paragraph(); 248 s = cursor.paragraph();
243 while ( s ) { 249 while ( s ) {
244 s->format(); 250 s->format();
245 s->setChanged( TRUE ); 251 s->setChanged( TRUE );
246 if ( s == c->paragraph() ) 252 if ( s == c->paragraph() )
247 break; 253 break;
248 s = s->next(); 254 s = s->next();
249 } 255 }
250 256
251 return &cursor; 257 return &cursor;
252} 258}
253 259
254QTextFormatCommand::QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, 260QTextFormatCommand::QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx,
255 const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl ) 261 const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl )
256 : QTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl ) 262 : QTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl )
257{ 263{
258 format = d->formatCollection()->format( f ); 264 format = d->formatCollection()->format( f );
259 for ( int j = 0; j < (int)oldFormats.size(); ++j ) { 265 for ( int j = 0; j < (int)oldFormats.size(); ++j ) {
260 if ( oldFormats[ j ].format() ) 266 if ( oldFormats[ j ].format() )
261 oldFormats[ j ].format()->addRef(); 267 oldFormats[ j ].format()->addRef();
262 } 268 }
263} 269}
@@ -1499,100 +1505,100 @@ void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* curso
1499 hasNewPar = FALSE; // we want an empty li (like most browsers) 1505 hasNewPar = FALSE; // we want an empty li (like most browsers)
1500 if ( !hasNewPar ) { 1506 if ( !hasNewPar ) {
1501 /* do not add new blocks inside 1507 /* do not add new blocks inside
1502 non-empty lis */ 1508 non-empty lis */
1503 while ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ) { 1509 while ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ) {
1504 if ( tags.isEmpty() ) 1510 if ( tags.isEmpty() )
1505 break; 1511 break;
1506 curtag = tags.pop(); 1512 curtag = tags.pop();
1507 } 1513 }
1508 } else if ( canMergeLi ) { 1514 } else if ( canMergeLi ) {
1509 /* we have an empty li and a block 1515 /* we have an empty li and a block
1510 comes along, merge them */ 1516 comes along, merge them */
1511 nstyle = curtag.style; 1517 nstyle = curtag.style;
1512 } 1518 }
1513 canMergeLi = FALSE; 1519 canMergeLi = FALSE;
1514 } 1520 }
1515 } 1521 }
1516 } 1522 }
1517 1523
1518 QTextCustomItem* custom = 0; 1524 QTextCustomItem* custom = 0;
1519 1525
1520 // some well-known tags, some have a nstyle, some not 1526 // some well-known tags, some have a nstyle, some not
1521 if ( wellKnownTags.find( tagname ) != -1 ) { 1527 if ( wellKnownTags.find( tagname ) != -1 ) {
1522 if ( tagname == "br" ) { 1528 if ( tagname == "br" ) {
1523 emptyTag = space = TRUE; 1529 emptyTag = space = TRUE;
1524 int index = QMAX( curpar->length(),1) - 1; 1530 int index = QMAX( curpar->length(),1) - 1;
1525 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); 1531 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
1526 curpar->append( QChar_linesep ); 1532 curpar->append( QChar_linesep );
1527 curpar->setFormat( index, 1, &format ); 1533 curpar->setFormat( index, 1, &format );
1528 } else if ( tagname == "hr" ) { 1534 } else if ( tagname == "hr" ) {
1529 emptyTag = space = TRUE; 1535 emptyTag = space = TRUE;
1530 custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this ); 1536 custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this );
1531 NEWPAR; 1537 NEWPAR;
1532 } else if ( tagname == "table" ) { 1538 } else if ( tagname == "table" ) {
1533 emptyTag = space = TRUE; 1539 emptyTag = space = TRUE;
1534 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor ); 1540 QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
1535 curpar->setAlignment( curtag.alignment ); 1541 curpar->setAlignment( curtag.alignment );
1536 custom = parseTable( attr, format, doc, length, pos, curpar ); 1542 custom = parseTable( attr, format, doc, length, pos, curpar );
1537 } else if ( tagname == "qt" || tagname == "body" ) { 1543 } else if ( tagname == "qt" || tagname == "body" ) {
1538 if ( attr.contains( "bgcolor" ) ) { 1544 if ( attr.contains( "bgcolor" ) ) {
1539 QBrush *b = new QBrush( QColor( attr["bgcolor"] ) ); 1545 QBrush *b = new QBrush( QColor( attr["bgcolor"] ) );
1540 setPaper( b ); 1546 setPaper( b );
1541 } 1547 }
1542 if ( attr.contains( "background" ) ) { 1548 if ( attr.contains( "background" ) ) {
1543 QImage img; 1549 QImage img;
1544 QString bg = attr["background"]; 1550 QString bg = attr["background"];
1545 const QMimeSource* m = factory_->data( bg, contxt ); 1551 const QMimeSource* m = factory_->data( bg, contxt );
1546 if ( !m ) { 1552 if ( !m ) {
1547 qWarning("QRichText: no mimesource for %s", bg.latin1() ); 1553 owarn << "QRichText: no mimesource for " << bg.latin1() << "" << oendl;
1548 } else { 1554 } else {
1549 if ( !QImageDrag::decode( m, img ) ) { 1555 if ( !QImageDrag::decode( m, img ) ) {
1550 qWarning("QTextImage: cannot decode %s", bg.latin1() ); 1556 owarn << "QTextImage: cannot decode " << bg.latin1() << "" << oendl;
1551 } 1557 }
1552 } 1558 }
1553 if ( !img.isNull() ) { 1559 if ( !img.isNull() ) {
1554 QPixmap pm; 1560 QPixmap pm;
1555 pm.convertFromImage( img ); 1561 pm.convertFromImage( img );
1556 QBrush *b = new QBrush( QColor(), pm ); 1562 QBrush *b = new QBrush( QColor(), pm );
1557 setPaper( b ); 1563 setPaper( b );
1558 } 1564 }
1559 } 1565 }
1560 if ( attr.contains( "text" ) ) { 1566 if ( attr.contains( "text" ) ) {
1561 QColor c( attr["text"] ); 1567 QColor c( attr["text"] );
1562 if ( formatCollection()->defaultFormat()->color() != c ) { 1568 if ( formatCollection()->defaultFormat()->color() != c ) {
1563 QDict<QTextFormat> formats = formatCollection()->dict(); 1569 QDict<QTextFormat> formats = formatCollection()->dict();
1564 QDictIterator<QTextFormat> it( formats ); 1570 QDictIterator<QTextFormat> it( formats );
1565 while ( it.current() ) { 1571 while ( it.current() ) {
1566 if ( it.current() == formatCollection()->defaultFormat() ) { 1572 if ( it.current() == formatCollection()->defaultFormat() ) {
1567 ++it; 1573 ++it;
1568 continue; 1574 continue;
1569 } 1575 }
1570 it.current()->setColor( c ); 1576 it.current()->setColor( c );
1571 ++it; 1577 ++it;
1572 } 1578 }
1573 formatCollection()->defaultFormat()->setColor( c ); 1579 formatCollection()->defaultFormat()->setColor( c );
1574 curtag.format.setColor( c ); 1580 curtag.format.setColor( c );
1575 } 1581 }
1576 } 1582 }
1577 if ( attr.contains( "link" ) ) 1583 if ( attr.contains( "link" ) )
1578 linkColor = QColor( attr["link"] ); 1584 linkColor = QColor( attr["link"] );
1579 if ( attr.contains( "title" ) ) 1585 if ( attr.contains( "title" ) )
1580 attribs.replace( "title", attr["title"] ); 1586 attribs.replace( "title", attr["title"] );
1581 1587
1582 if ( textEditMode ) { 1588 if ( textEditMode ) {
1583 if ( attr.contains("style" ) ) { 1589 if ( attr.contains("style" ) ) {
1584 QString a = attr["style"]; 1590 QString a = attr["style"];
1585 for ( int s = 0; s < a.contains(';')+1; s++ ) { 1591 for ( int s = 0; s < a.contains(';')+1; s++ ) {
1586 QString style = QTextDocument::section( a, ";", s, s ); 1592 QString style = QTextDocument::section( a, ";", s, s );
1587 if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) { 1593 if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) {
1588 scaleFontsFactor = double( formatCollection()->defaultFormat()->fn.pointSize() ) / 1594 scaleFontsFactor = double( formatCollection()->defaultFormat()->fn.pointSize() ) /
1589 style.mid( 10, style.length() - 12 ).toInt(); 1595 style.mid( 10, style.length() - 12 ).toInt();
1590 } 1596 }
1591 } 1597 }
1592 } 1598 }
1593 nstyle = 0; // ignore body in textEditMode 1599 nstyle = 0; // ignore body in textEditMode
1594 } 1600 }
1595 // end qt- and body-tag handling 1601 // end qt- and body-tag handling
1596 } else if ( tagname == "meta" ) { 1602 } else if ( tagname == "meta" ) {
1597 if ( attr["name"] == "qrichtext" && attr["content"] == "1" ) 1603 if ( attr["name"] == "qrichtext" && attr["content"] == "1" )
1598 textEditMode = TRUE; 1604 textEditMode = TRUE;
@@ -2107,97 +2113,97 @@ static QString list_style_to_string( int v )
2107 default: 2113 default:
2108 return QString::null; 2114 return QString::null;
2109 } 2115 }
2110} 2116}
2111 2117
2112static inline bool list_is_ordered( int v ) 2118static inline bool list_is_ordered( int v )
2113{ 2119{
2114 return v == QStyleSheetItem::ListDecimal || 2120 return v == QStyleSheetItem::ListDecimal ||
2115 v == QStyleSheetItem::ListLowerAlpha || 2121 v == QStyleSheetItem::ListLowerAlpha ||
2116 v == QStyleSheetItem::ListUpperAlpha; 2122 v == QStyleSheetItem::ListUpperAlpha;
2117} 2123}
2118 2124
2119 2125
2120static QString margin_to_string( QStyleSheetItem* style, int t, int b, int l, int r, int fl ) 2126static QString margin_to_string( QStyleSheetItem* style, int t, int b, int l, int r, int fl )
2121{ 2127{
2122 QString s; 2128 QString s;
2123 if ( l > 0 ) 2129 if ( l > 0 )
2124 s += QString(!!s?";":"") + "margin-left:" + QString::number(l+QMAX(0,style->margin(QStyleSheetItem::MarginLeft))) + "px"; 2130 s += QString(!!s?";":"") + "margin-left:" + QString::number(l+QMAX(0,style->margin(QStyleSheetItem::MarginLeft))) + "px";
2125 if ( r > 0 ) 2131 if ( r > 0 )
2126 s += QString(!!s?";":"") + "margin-right:" + QString::number(r+QMAX(0,style->margin(QStyleSheetItem::MarginRight))) + "px"; 2132 s += QString(!!s?";":"") + "margin-right:" + QString::number(r+QMAX(0,style->margin(QStyleSheetItem::MarginRight))) + "px";
2127 if ( t > 0 ) 2133 if ( t > 0 )
2128 s += QString(!!s?";":"") + "margin-top:" + QString::number(t+QMAX(0,style->margin(QStyleSheetItem::MarginTop))) + "px"; 2134 s += QString(!!s?";":"") + "margin-top:" + QString::number(t+QMAX(0,style->margin(QStyleSheetItem::MarginTop))) + "px";
2129 if ( b > 0 ) 2135 if ( b > 0 )
2130 s += QString(!!s?";":"") + "margin-bottom:" + QString::number(b+QMAX(0,style->margin(QStyleSheetItem::MarginBottom))) + "px"; 2136 s += QString(!!s?";":"") + "margin-bottom:" + QString::number(b+QMAX(0,style->margin(QStyleSheetItem::MarginBottom))) + "px";
2131 if ( fl > 0 ) 2137 if ( fl > 0 )
2132 s += QString(!!s?";":"") + "text-indent:" + QString::number(fl+QMAX(0,style->margin(QStyleSheetItem::MarginFirstLine))) + "px"; 2138 s += QString(!!s?";":"") + "text-indent:" + QString::number(fl+QMAX(0,style->margin(QStyleSheetItem::MarginFirstLine))) + "px";
2133 if ( !!s ) 2139 if ( !!s )
2134 return " style=\"" + s + "\""; 2140 return " style=\"" + s + "\"";
2135 return QString::null; 2141 return QString::null;
2136} 2142}
2137 2143
2138QString QTextDocument::richText() const 2144QString QTextDocument::richText() const
2139{ 2145{
2140 QString s = ""; 2146 QString s = "";
2141 if ( !par ) { 2147 if ( !par ) {
2142 s += "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:" ; 2148 s += "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:" ;
2143 s += QString::number( formatCollection()->defaultFormat()->font().pointSize() ); 2149 s += QString::number( formatCollection()->defaultFormat()->font().pointSize() );
2144 s += "pt;font-family:"; 2150 s += "pt;font-family:";
2145 s += formatCollection()->defaultFormat()->font().family(); 2151 s += formatCollection()->defaultFormat()->font().family();
2146 s +="\">"; 2152 s +="\">";
2147 } 2153 }
2148 QTextParagraph* p = fParag; 2154 QTextParagraph* p = fParag;
2149 2155
2150 QStyleSheetItem* item_p = styleSheet()->item("p"); 2156 QStyleSheetItem* item_p = styleSheet()->item("p");
2151 QStyleSheetItem* item_ul = styleSheet()->item("ul"); 2157 QStyleSheetItem* item_ul = styleSheet()->item("ul");
2152 QStyleSheetItem* item_ol = styleSheet()->item("ol"); 2158 QStyleSheetItem* item_ol = styleSheet()->item("ol");
2153 QStyleSheetItem* item_li = styleSheet()->item("li"); 2159 QStyleSheetItem* item_li = styleSheet()->item("li");
2154 if ( !item_p || !item_ul || !item_ol || !item_li ) { 2160 if ( !item_p || !item_ul || !item_ol || !item_li ) {
2155 qWarning( "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" ); 2161 owarn << "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" << oendl;
2156 return QString::null; 2162 return QString::null;
2157 } 2163 }
2158 int pastListDepth = 0; 2164 int pastListDepth = 0;
2159 int listDepth = 0; 2165 int listDepth = 0;
2160 int futureListDepth = 0; 2166 int futureListDepth = 0;
2161 QMemArray<int> listStyles(10); 2167 QMemArray<int> listStyles(10);
2162 2168
2163 while ( p ) { 2169 while ( p ) {
2164 listDepth = p->listDepth(); 2170 listDepth = p->listDepth();
2165 if ( listDepth < pastListDepth ) { 2171 if ( listDepth < pastListDepth ) {
2166 for ( int i = listDepth+1; i <= pastListDepth; i++ ) 2172 for ( int i = listDepth+1; i <= pastListDepth; i++ )
2167 s += list_is_ordered( listStyles[i] ) ? "</ol>" : "</ul>"; 2173 s += list_is_ordered( listStyles[i] ) ? "</ol>" : "</ul>";
2168 s += '\n'; 2174 s += '\n';
2169 } else if ( listDepth > pastListDepth ) { 2175 } else if ( listDepth > pastListDepth ) {
2170 s += '\n'; 2176 s += '\n';
2171 listStyles.resize( QMAX( (int)listStyles.size(), listDepth+1 ) ); 2177 listStyles.resize( QMAX( (int)listStyles.size(), listDepth+1 ) );
2172 QString list_type; 2178 QString list_type;
2173 listStyles[listDepth] = p->listStyle(); 2179 listStyles[listDepth] = p->listStyle();
2174 if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() ) 2180 if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() )
2175 list_type = " type=" + list_style_to_string( p->listStyle() ); 2181 list_type = " type=" + list_style_to_string( p->listStyle() );
2176 for ( int i = pastListDepth; i < listDepth; i++ ) { 2182 for ( int i = pastListDepth; i < listDepth; i++ ) {
2177 s += list_is_ordered( p->listStyle() ) ? "<ol" : "<ul" ; 2183 s += list_is_ordered( p->listStyle() ) ? "<ol" : "<ul" ;
2178 s += list_type + ">"; 2184 s += list_type + ">";
2179 } 2185 }
2180 } else { 2186 } else {
2181 s += '\n'; 2187 s += '\n';
2182 } 2188 }
2183 2189
2184 QString ps = p->richText(); 2190 QString ps = p->richText();
2185 2191
2186 // for the bottom margin we need to know whether we are at the end of a list 2192 // for the bottom margin we need to know whether we are at the end of a list
2187 futureListDepth = 0; 2193 futureListDepth = 0;
2188 if ( listDepth > 0 && p->next() ) 2194 if ( listDepth > 0 && p->next() )
2189 futureListDepth = p->next()->listDepth(); 2195 futureListDepth = p->next()->listDepth();
2190 2196
2191 if ( richTextExportStart && richTextExportStart->paragraph() ==p && 2197 if ( richTextExportStart && richTextExportStart->paragraph() ==p &&
2192 richTextExportStart->index() == 0 ) 2198 richTextExportStart->index() == 0 )
2193 s += "<selstart/>"; 2199 s += "<selstart/>";
2194 2200
2195 if ( p->isListItem() ) { 2201 if ( p->isListItem() ) {
2196 s += "<li"; 2202 s += "<li";
2197 if ( p->listStyle() != listStyles[listDepth] ) 2203 if ( p->listStyle() != listStyles[listDepth] )
2198 s += " type=" + list_style_to_string( p->listStyle() ); 2204 s += " type=" + list_style_to_string( p->listStyle() );
2199 s +=align_to_string( p->alignment() ); 2205 s +=align_to_string( p->alignment() );
2200 s += margin_to_string( item_li, p->utm, p->ubm, p->ulm, p->urm, p->uflm ); 2206 s += margin_to_string( item_li, p->utm, p->ubm, p->ulm, p->urm, p->uflm );
2201 s += list_value_to_string( p->listValue() ); 2207 s += list_value_to_string( p->listValue() );
2202 s += direction_to_string( p->direction() ); 2208 s += direction_to_string( p->direction() );
2203 s +=">"; 2209 s +=">";
@@ -4051,150 +4057,150 @@ void QTextParagraph::format( int start, bool doMove )
4051 if ( shift && !formattedAgain ) { 4057 if ( shift && !formattedAgain ) {
4052 formattedAgain = TRUE; 4058 formattedAgain = TRUE;
4053 goto formatAgain; 4059 goto formatAgain;
4054 } 4060 }
4055 } 4061 }
4056 4062
4057 if ( n && doMove && n->invalid == -1 && r.y() + r.height() != n->r.y() ) { 4063 if ( n && doMove && n->invalid == -1 && r.y() + r.height() != n->r.y() ) {
4058 int dy = ( r.y() + r.height() ) - n->r.y(); 4064 int dy = ( r.y() + r.height() ) - n->r.y();
4059 QTextParagraph *s = n; 4065 QTextParagraph *s = n;
4060 bool makeInvalid = p && p->lastInFrame; 4066 bool makeInvalid = p && p->lastInFrame;
4061 while ( s && dy ) { 4067 while ( s && dy ) {
4062 if ( !s->isFullWidth() ) 4068 if ( !s->isFullWidth() )
4063 makeInvalid = TRUE; 4069 makeInvalid = TRUE;
4064 if ( makeInvalid ) 4070 if ( makeInvalid )
4065 s->invalidate( 0 ); 4071 s->invalidate( 0 );
4066 s->move( dy ); 4072 s->move( dy );
4067 if ( s->lastInFrame ) 4073 if ( s->lastInFrame )
4068 makeInvalid = TRUE; 4074 makeInvalid = TRUE;
4069 s = s->n; 4075 s = s->n;
4070 } 4076 }
4071 } 4077 }
4072 4078
4073 firstFormat = FALSE; 4079 firstFormat = FALSE;
4074 changed = TRUE; 4080 changed = TRUE;
4075 invalid = -1; 4081 invalid = -1;
4076 //##### string()->setTextChanged( FALSE ); 4082 //##### string()->setTextChanged( FALSE );
4077} 4083}
4078 4084
4079int QTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const 4085int QTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const
4080{ 4086{
4081 if ( !isValid() ) 4087 if ( !isValid() )
4082 ( (QTextParagraph*)this )->format(); 4088 ( (QTextParagraph*)this )->format();
4083 4089
4084 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end(); 4090 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
4085 --it; 4091 --it;
4086 for ( ;; ) { 4092 for ( ;; ) {
4087 if ( i >= it.key() ) { 4093 if ( i >= it.key() ) {
4088 if ( bl ) 4094 if ( bl )
4089 *bl = ( *it )->baseLine; 4095 *bl = ( *it )->baseLine;
4090 if ( y ) 4096 if ( y )
4091 *y = ( *it )->y; 4097 *y = ( *it )->y;
4092 return ( *it )->h; 4098 return ( *it )->h;
4093 } 4099 }
4094 if ( it == lineStarts.begin() ) 4100 if ( it == lineStarts.begin() )
4095 break; 4101 break;
4096 --it; 4102 --it;
4097 } 4103 }
4098 4104
4099 qWarning( "QTextParagraph::lineHeightOfChar: couldn't find lh for %d", i ); 4105 owarn << "QTextParagraph::lineHeightOfChar: couldn't find lh for " << i << "" << oendl;
4100 return 15; 4106 return 15;
4101} 4107}
4102 4108
4103QTextStringChar *QTextParagraph::lineStartOfChar( int i, int *index, int *line ) const 4109QTextStringChar *QTextParagraph::lineStartOfChar( int i, int *index, int *line ) const
4104{ 4110{
4105 if ( !isValid() ) 4111 if ( !isValid() )
4106 ( (QTextParagraph*)this )->format(); 4112 ( (QTextParagraph*)this )->format();
4107 4113
4108 int l = (int)lineStarts.count() - 1; 4114 int l = (int)lineStarts.count() - 1;
4109 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end(); 4115 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
4110 --it; 4116 --it;
4111 for ( ;; ) { 4117 for ( ;; ) {
4112 if ( i >= it.key() ) { 4118 if ( i >= it.key() ) {
4113 if ( index ) 4119 if ( index )
4114 *index = it.key(); 4120 *index = it.key();
4115 if ( line ) 4121 if ( line )
4116 *line = l; 4122 *line = l;
4117 return &str->at( it.key() ); 4123 return &str->at( it.key() );
4118 } 4124 }
4119 if ( it == lineStarts.begin() ) 4125 if ( it == lineStarts.begin() )
4120 break; 4126 break;
4121 --it; 4127 --it;
4122 --l; 4128 --l;
4123 } 4129 }
4124 4130
4125 qWarning( "QTextParagraph::lineStartOfChar: couldn't find %d", i ); 4131 owarn << "QTextParagraph::lineStartOfChar: couldn't find " << i << "" << oendl;
4126 return 0; 4132 return 0;
4127} 4133}
4128 4134
4129int QTextParagraph::lines() const 4135int QTextParagraph::lines() const
4130{ 4136{
4131 if ( !isValid() ) 4137 if ( !isValid() )
4132 ( (QTextParagraph*)this )->format(); 4138 ( (QTextParagraph*)this )->format();
4133 4139
4134 return (int)lineStarts.count(); 4140 return (int)lineStarts.count();
4135} 4141}
4136 4142
4137QTextStringChar *QTextParagraph::lineStartOfLine( int line, int *index ) const 4143QTextStringChar *QTextParagraph::lineStartOfLine( int line, int *index ) const
4138{ 4144{
4139 if ( !isValid() ) 4145 if ( !isValid() )
4140 ( (QTextParagraph*)this )->format(); 4146 ( (QTextParagraph*)this )->format();
4141 4147
4142 if ( line >= 0 && line < (int)lineStarts.count() ) { 4148 if ( line >= 0 && line < (int)lineStarts.count() ) {
4143 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 4149 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
4144 while ( line-- > 0 ) 4150 while ( line-- > 0 )
4145 ++it; 4151 ++it;
4146 int i = it.key(); 4152 int i = it.key();
4147 if ( index ) 4153 if ( index )
4148 *index = i; 4154 *index = i;
4149 return &str->at( i ); 4155 return &str->at( i );
4150 } 4156 }
4151 4157
4152 qWarning( "QTextParagraph::lineStartOfLine: couldn't find %d", line ); 4158 owarn << "QTextParagraph::lineStartOfLine: couldn't find " << line << "" << oendl;
4153 return 0; 4159 return 0;
4154} 4160}
4155 4161
4156int QTextParagraph::leftGap() const 4162int QTextParagraph::leftGap() const
4157{ 4163{
4158 if ( !isValid() ) 4164 if ( !isValid() )
4159 ( (QTextParagraph*)this )->format(); 4165 ( (QTextParagraph*)this )->format();
4160 4166
4161 int line = 0; 4167 int line = 0;
4162 int x = str->at(0).x; /* set x to x of first char */ 4168 int x = str->at(0).x; /* set x to x of first char */
4163 if ( str->isBidi() ) { 4169 if ( str->isBidi() ) {
4164 for ( int i = 1; i < str->length()-1; ++i ) 4170 for ( int i = 1; i < str->length()-1; ++i )
4165 x = QMIN(x, str->at(i).x); 4171 x = QMIN(x, str->at(i).x);
4166 return x; 4172 return x;
4167 } 4173 }
4168 4174
4169 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 4175 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
4170 while (line < (int)lineStarts.count()) { 4176 while (line < (int)lineStarts.count()) {
4171 int i = it.key(); /* char index */ 4177 int i = it.key(); /* char index */
4172 x = QMIN(x, str->at(i).x); 4178 x = QMIN(x, str->at(i).x);
4173 ++it; 4179 ++it;
4174 ++line; 4180 ++line;
4175 } 4181 }
4176 return x; 4182 return x;
4177} 4183}
4178 4184
4179void QTextParagraph::setFormat( int index, int len, QTextFormat *f, bool useCollection, int flags ) 4185void QTextParagraph::setFormat( int index, int len, QTextFormat *f, bool useCollection, int flags )
4180{ 4186{
4181 if ( !f ) 4187 if ( !f )
4182 return; 4188 return;
4183 if ( index < 0 ) 4189 if ( index < 0 )
4184 index = 0; 4190 index = 0;
4185 if ( index > str->length() - 1 ) 4191 if ( index > str->length() - 1 )
4186 index = str->length() - 1; 4192 index = str->length() - 1;
4187 if ( index + len >= str->length() ) 4193 if ( index + len >= str->length() )
4188 len = str->length() - index; 4194 len = str->length() - index;
4189 4195
4190 QTextFormatCollection *fc = 0; 4196 QTextFormatCollection *fc = 0;
4191 if ( useCollection ) 4197 if ( useCollection )
4192 fc = formatCollection(); 4198 fc = formatCollection();
4193 QTextFormat *of; 4199 QTextFormat *of;
4194 for ( int i = 0; i < len; ++i ) { 4200 for ( int i = 0; i < len; ++i ) {
4195 of = str->at( i + index ).format(); 4201 of = str->at( i + index ).format();
4196 if ( !changed && f->key() != of->key() ) 4202 if ( !changed && f->key() != of->key() )
4197 changed = TRUE; 4203 changed = TRUE;
4198 if ( invalid == -1 && 4204 if ( invalid == -1 &&
4199 ( f->font().family() != of->font().family() || 4205 ( f->font().family() != of->font().family() ||
4200 f->font().pointSize() != of->font().pointSize() || 4206 f->font().pointSize() != of->font().pointSize() ||
@@ -5652,97 +5658,97 @@ QTextFormat *QTextFormatCollection::format( QTextFormat *of, QTextFormat *nf, in
5652 else 5658 else
5653 cres->fn.setPointSize( nf->fn.pointSize() ); 5659 cres->fn.setPointSize( nf->fn.pointSize() );
5654 } 5660 }
5655 if ( flags & QTextFormat::Color ) 5661 if ( flags & QTextFormat::Color )
5656 cres->col = nf->col; 5662 cres->col = nf->col;
5657 if ( flags & QTextFormat::Misspelled ) 5663 if ( flags & QTextFormat::Misspelled )
5658 cres->missp = nf->missp; 5664 cres->missp = nf->missp;
5659 if ( flags & QTextFormat::VAlign ) 5665 if ( flags & QTextFormat::VAlign )
5660 cres->ha = nf->ha; 5666 cres->ha = nf->ha;
5661 cres->update(); 5667 cres->update();
5662 5668
5663 QTextFormat *fm = cKey.find( cres->key() ); 5669 QTextFormat *fm = cKey.find( cres->key() );
5664 if ( !fm ) { 5670 if ( !fm ) {
5665 cres->collection = this; 5671 cres->collection = this;
5666 cKey.insert( cres->key(), cres ); 5672 cKey.insert( cres->key(), cres );
5667 } else { 5673 } else {
5668 delete cres; 5674 delete cres;
5669 cres = fm; 5675 cres = fm;
5670 cres->addRef(); 5676 cres->addRef();
5671 } 5677 }
5672 5678
5673 return cres; 5679 return cres;
5674} 5680}
5675 5681
5676QTextFormat *QTextFormatCollection::format( const QFont &f, const QColor &c ) 5682QTextFormat *QTextFormatCollection::format( const QFont &f, const QColor &c )
5677{ 5683{
5678 if ( cachedFormat && cfont == f && ccol == c ) { 5684 if ( cachedFormat && cfont == f && ccol == c ) {
5679 cachedFormat->addRef(); 5685 cachedFormat->addRef();
5680 return cachedFormat; 5686 return cachedFormat;
5681 } 5687 }
5682 5688
5683 QString key = QTextFormat::getKey( f, c, FALSE, QTextFormat::AlignNormal ); 5689 QString key = QTextFormat::getKey( f, c, FALSE, QTextFormat::AlignNormal );
5684 cachedFormat = cKey.find( key ); 5690 cachedFormat = cKey.find( key );
5685 cfont = f; 5691 cfont = f;
5686 ccol = c; 5692 ccol = c;
5687 5693
5688 if ( cachedFormat ) { 5694 if ( cachedFormat ) {
5689 cachedFormat->addRef(); 5695 cachedFormat->addRef();
5690 return cachedFormat; 5696 return cachedFormat;
5691 } 5697 }
5692 5698
5693 if ( key == defFormat->key() ) 5699 if ( key == defFormat->key() )
5694 return defFormat; 5700 return defFormat;
5695 5701
5696 cachedFormat = createFormat( f, c ); 5702 cachedFormat = createFormat( f, c );
5697 cachedFormat->collection = this; 5703 cachedFormat->collection = this;
5698 cKey.insert( cachedFormat->key(), cachedFormat ); 5704 cKey.insert( cachedFormat->key(), cachedFormat );
5699 if ( cachedFormat->key() != key ) 5705 if ( cachedFormat->key() != key )
5700 qWarning("ASSERT: keys for format not identical: '%s '%s'", cachedFormat->key().latin1(), key.latin1() ); 5706 owarn << "ASSERT: keys for format not identical: '" << cachedFormat->key().latin1() << " '" << key.latin1() << "'" << oendl;
5701 return cachedFormat; 5707 return cachedFormat;
5702} 5708}
5703 5709
5704void QTextFormatCollection::remove( QTextFormat *f ) 5710void QTextFormatCollection::remove( QTextFormat *f )
5705{ 5711{
5706 if ( lastFormat == f ) 5712 if ( lastFormat == f )
5707 lastFormat = 0; 5713 lastFormat = 0;
5708 if ( cres == f ) 5714 if ( cres == f )
5709 cres = 0; 5715 cres = 0;
5710 if ( cachedFormat == f ) 5716 if ( cachedFormat == f )
5711 cachedFormat = 0; 5717 cachedFormat = 0;
5712 cKey.remove( f->key() ); 5718 cKey.remove( f->key() );
5713} 5719}
5714 5720
5715#define UPDATE( up, lo, rest ) \ 5721#define UPDATE( up, lo, rest ) \
5716 if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \ 5722 if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \
5717 fm->fn.set##up##rest( font.lo##rest() ) 5723 fm->fn.set##up##rest( font.lo##rest() )
5718 5724
5719void QTextFormatCollection::updateDefaultFormat( const QFont &font, const QColor &color, QStyleSheet *sheet ) 5725void QTextFormatCollection::updateDefaultFormat( const QFont &font, const QColor &color, QStyleSheet *sheet )
5720{ 5726{
5721 QDictIterator<QTextFormat> it( cKey ); 5727 QDictIterator<QTextFormat> it( cKey );
5722 QTextFormat *fm; 5728 QTextFormat *fm;
5723 bool usePixels = font.pointSize() == -1; 5729 bool usePixels = font.pointSize() == -1;
5724 bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() : 5730 bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() :
5725 font.pointSize() != defFormat->fn.pointSize(); 5731 font.pointSize() != defFormat->fn.pointSize();
5726 int base = usePixels ? font.pixelSize() : font.pointSize(); 5732 int base = usePixels ? font.pixelSize() : font.pointSize();
5727 while ( ( fm = it.current() ) ) { 5733 while ( ( fm = it.current() ) ) {
5728 ++it; 5734 ++it;
5729 UPDATE( F, f, amily ); 5735 UPDATE( F, f, amily );
5730 UPDATE( W, w, eight ); 5736 UPDATE( W, w, eight );
5731 UPDATE( B, b, old ); 5737 UPDATE( B, b, old );
5732 UPDATE( I, i, talic ); 5738 UPDATE( I, i, talic );
5733 UPDATE( U, u, nderline ); 5739 UPDATE( U, u, nderline );
5734 if ( changeSize ) { 5740 if ( changeSize ) {
5735 fm->stdSize = base; 5741 fm->stdSize = base;
5736 fm->usePixelSizes = usePixels; 5742 fm->usePixelSizes = usePixels;
5737 if ( usePixels ) 5743 if ( usePixels )
5738 fm->fn.setPixelSize( fm->stdSize ); 5744 fm->fn.setPixelSize( fm->stdSize );
5739 else 5745 else
5740 fm->fn.setPointSize( fm->stdSize ); 5746 fm->fn.setPointSize( fm->stdSize );
5741 sheet->scaleFont( fm->fn, fm->logicalFontSize ); 5747 sheet->scaleFont( fm->fn, fm->logicalFontSize );
5742 } 5748 }
5743 if ( color.isValid() && color != defFormat->col && fm->col == defFormat->col ) 5749 if ( color.isValid() && color != defFormat->col && fm->col == defFormat->col )
5744 fm->col = color; 5750 fm->col = color;
5745 fm->update(); 5751 fm->update();
5746 } 5752 }
5747 5753
5748 defFormat->fn = font; 5754 defFormat->fn = font;
@@ -6038,101 +6044,101 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
6038 } 6044 }
6039 } 6045 }
6040 } 6046 }
6041 6047
6042 format.update(); 6048 format.update();
6043 return format; 6049 return format;
6044} 6050}
6045 6051
6046struct QPixmapInt 6052struct QPixmapInt
6047{ 6053{
6048 QPixmapInt() : ref( 0 ) {} 6054 QPixmapInt() : ref( 0 ) {}
6049 QPixmap pm; 6055 QPixmap pm;
6050 int ref; 6056 int ref;
6051}; 6057};
6052 6058
6053static QMap<QString, QPixmapInt> *pixmap_map = 0; 6059static QMap<QString, QPixmapInt> *pixmap_map = 0;
6054 6060
6055QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
6056 QMimeSourceFactory &factory ) 6062 QMimeSourceFactory &factory )
6057 : QTextCustomItem( p ) 6063 : QTextCustomItem( p )
6058{ 6064{
6059 width = height = 0; 6065 width = height = 0;
6060 if ( attr.contains("width") ) 6066 if ( attr.contains("width") )
6061 width = attr["width"].toInt(); 6067 width = attr["width"].toInt();
6062 if ( attr.contains("height") ) 6068 if ( attr.contains("height") )
6063 height = attr["height"].toInt(); 6069 height = attr["height"].toInt();
6064 6070
6065 reg = 0; 6071 reg = 0;
6066 QString imageName = attr["src"]; 6072 QString imageName = attr["src"];
6067 6073
6068 if (!imageName) 6074 if (!imageName)
6069 imageName = attr["source"]; 6075 imageName = attr["source"];
6070 6076
6071 if ( !imageName.isEmpty() ) { 6077 if ( !imageName.isEmpty() ) {
6072 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); 6078 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
6073 if ( !pixmap_map ) 6079 if ( !pixmap_map )
6074 pixmap_map = new QMap<QString, QPixmapInt>; 6080 pixmap_map = new QMap<QString, QPixmapInt>;
6075 if ( pixmap_map->contains( imgId ) ) { 6081 if ( pixmap_map->contains( imgId ) ) {
6076 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6082 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6077 pm = pmi.pm; 6083 pm = pmi.pm;
6078 pmi.ref++; 6084 pmi.ref++;
6079 width = pm.width(); 6085 width = pm.width();
6080 height = pm.height(); 6086 height = pm.height();
6081 } else { 6087 } else {
6082 QImage img; 6088 QImage img;
6083 const QMimeSource* m = 6089 const QMimeSource* m =
6084 factory.data( imageName, context ); 6090 factory.data( imageName, context );
6085 if ( !m ) { 6091 if ( !m ) {
6086 qWarning("QTextImage: no mimesource for %s", imageName.latin1() ); 6092 owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
6087 } 6093 }
6088 else { 6094 else {
6089 if ( !QImageDrag::decode( m, img ) ) { 6095 if ( !QImageDrag::decode( m, img ) ) {
6090 qWarning("QTextImage: cannot decode %s", imageName.latin1() ); 6096 owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
6091 } 6097 }
6092 } 6098 }
6093 6099
6094 if ( !img.isNull() ) { 6100 if ( !img.isNull() ) {
6095 if ( width == 0 ) { 6101 if ( width == 0 ) {
6096 width = img.width(); 6102 width = img.width();
6097 if ( height != 0 ) { 6103 if ( height != 0 ) {
6098 width = img.width() * height / img.height(); 6104 width = img.width() * height / img.height();
6099 } 6105 }
6100 } 6106 }
6101 if ( height == 0 ) { 6107 if ( height == 0 ) {
6102 height = img.height(); 6108 height = img.height();
6103 if ( width != img.width() ) { 6109 if ( width != img.width() ) {
6104 height = img.height() * width / img.width(); 6110 height = img.height() * width / img.width();
6105 } 6111 }
6106 } 6112 }
6107 if ( img.width() != width || img.height() != height ){ 6113 if ( img.width() != width || img.height() != height ){
6108#ifndef QT_NO_IMAGE_SMOOTHSCALE 6114#ifndef QT_NO_IMAGE_SMOOTHSCALE
6109 img = img.smoothScale(width, height); 6115 img = img.smoothScale(width, height);
6110#endif 6116#endif
6111 width = img.width(); 6117 width = img.width();
6112 height = img.height(); 6118 height = img.height();
6113 } 6119 }
6114 pm.convertFromImage( img ); 6120 pm.convertFromImage( img );
6115 } 6121 }
6116 if ( !pm.isNull() ) { 6122 if ( !pm.isNull() ) {
6117 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6123 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6118 pmi.pm = pm; 6124 pmi.pm = pm;
6119 pmi.ref++; 6125 pmi.ref++;
6120 } 6126 }
6121 } 6127 }
6122 if ( pm.mask() ) { 6128 if ( pm.mask() ) {
6123 QRegion mask( *pm.mask() ); 6129 QRegion mask( *pm.mask() );
6124 QRegion all( 0, 0, pm.width(), pm.height() ); 6130 QRegion all( 0, 0, pm.width(), pm.height() );
6125 reg = new QRegion( all.subtract( mask ) ); 6131 reg = new QRegion( all.subtract( mask ) );
6126 } 6132 }
6127 } 6133 }
6128 6134
6129 if ( pm.isNull() && (width*height)==0 ) 6135 if ( pm.isNull() && (width*height)==0 )
6130 width = height = 50; 6136 width = height = 50;
6131 6137
6132 place = PlaceInline; 6138 place = PlaceInline;
6133 if ( attr["align"] == "left" ) 6139 if ( attr["align"] == "left" )
6134 place = PlaceLeft; 6140 place = PlaceLeft;
6135 else if ( attr["align"] == "right" ) 6141 else if ( attr["align"] == "right" )
6136 place = PlaceRight; 6142 place = PlaceRight;
6137 6143
6138 tmpwidth = width; 6144 tmpwidth = width;
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp
index 6783e0b..2e8b09c 100644
--- a/noncore/apps/opie-write/qrichtext_p.cpp
+++ b/noncore/apps/opie-write/qrichtext_p.cpp
@@ -1,85 +1,88 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of the internal Qt classes dealing with rich text 4** Implementation of the internal Qt classes dealing with rich text
5** 5**
6** Created : 990101 6** Created : 990101
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include <opie2/odebug.h>
39using namespace Opie::Core;
40
38#include "qrichtext_p.h" 41#include "qrichtext_p.h"
39 42
40using namespace Qt3; 43using namespace Qt3;
41 44
42QTextCommand::~QTextCommand() {} 45QTextCommand::~QTextCommand() {}
43QTextCommand::Commands QTextCommand::type() const { return Invalid; } 46QTextCommand::Commands QTextCommand::type() const { return Invalid; }
44 47
45 48
46QTextCustomItem::~QTextCustomItem() {} 49QTextCustomItem::~QTextCustomItem() {}
47void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; } 50void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; }
48QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; } 51QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; }
49 52
50bool QTextCustomItem::ownLine() const { return FALSE; } 53bool QTextCustomItem::ownLine() const { return FALSE; }
51void QTextCustomItem::resize( int nwidth ){ width = nwidth; } 54void QTextCustomItem::resize( int nwidth ){ width = nwidth; }
52void QTextCustomItem::invalidate() {} 55void QTextCustomItem::invalidate() {}
53 56
54bool QTextCustomItem::isNested() const { return FALSE; } 57bool QTextCustomItem::isNested() const { return FALSE; }
55int QTextCustomItem::minimumWidth() const { return 0; } 58int QTextCustomItem::minimumWidth() const { return 0; }
56 59
57QString QTextCustomItem::richText() const { return QString::null; } 60QString QTextCustomItem::richText() const { return QString::null; }
58 61
59bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) 62bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool )
60{ 63{
61 return TRUE; 64 return TRUE;
62} 65}
63bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int &, const QPoint & ) 66bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int &, const QPoint & )
64{ 67{
65 return TRUE; 68 return TRUE;
66} 69}
67bool QTextCustomItem::next( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) 70bool QTextCustomItem::next( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
68{ 71{
69 return TRUE; 72 return TRUE;
70} 73}
71bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) 74bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
72{ 75{
73 return TRUE; 76 return TRUE;
74} 77}
75bool QTextCustomItem::down( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) 78bool QTextCustomItem::down( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
76{ 79{
77 return TRUE; 80 return TRUE;
78} 81}
79bool QTextCustomItem::up( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) 82bool QTextCustomItem::up( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
80{ 83{
81 return TRUE; 84 return TRUE;
82} 85}
83 86
84void QTextFlow::setPageSize( int ps ) { pagesize = ps; } 87void QTextFlow::setPageSize( int ps ) { pagesize = ps; }
85bool QTextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); } 88bool QTextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); }
@@ -92,97 +95,97 @@ QTextParagraphData::~QTextParagraphData() {}
92void QTextParagraphData::join( QTextParagraphData * ) {} 95void QTextParagraphData::join( QTextParagraphData * ) {}
93 96
94QTextFormatter::~QTextFormatter() {} 97QTextFormatter::~QTextFormatter() {}
95void QTextFormatter::setWrapEnabled( bool b ) { wrapEnabled = b; } 98void QTextFormatter::setWrapEnabled( bool b ) { wrapEnabled = b; }
96void QTextFormatter::setWrapAtColumn( int c ) { wrapColumn = c; } 99void QTextFormatter::setWrapAtColumn( int c ) { wrapColumn = c; }
97 100
98 101
99 102
100int QTextCursor::x() const 103int QTextCursor::x() const
101{ 104{
102 QTextStringChar *c = para->at( idx ); 105 QTextStringChar *c = para->at( idx );
103 int curx = c->x; 106 int curx = c->x;
104 if ( !c->rightToLeft && 107 if ( !c->rightToLeft &&
105 c->c.isSpace() && 108 c->c.isSpace() &&
106 idx > 0 && 109 idx > 0 &&
107 !c->lineStart && 110 !c->lineStart &&
108 ( para->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify ) 111 ( para->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify )
109 curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 ); 112 curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 );
110 if ( c->rightToLeft ) 113 if ( c->rightToLeft )
111 curx += para->string()->width( idx ); 114 curx += para->string()->width( idx );
112 return curx; 115 return curx;
113} 116}
114 117
115int QTextCursor::y() const 118int QTextCursor::y() const
116{ 119{
117 int dummy, line; 120 int dummy, line;
118 para->lineStartOfChar( idx, &dummy, &line ); 121 para->lineStartOfChar( idx, &dummy, &line );
119 return para->lineY( line ); 122 return para->lineY( line );
120} 123}
121 124
122int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } 125int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); }
123int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } 126int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); }
124 127
125QTextDocument *QTextCursor::document() const 128QTextDocument *QTextCursor::document() const
126{ 129{
127 return para ? para->document() : 0; 130 return para ? para->document() : 0;
128} 131}
129 132
130void QTextCursor::gotoPosition( QTextParagraph* p, int index ) 133void QTextCursor::gotoPosition( QTextParagraph* p, int index )
131{ 134{
132 if ( para && p != para ) { 135 if ( para && p != para ) {
133 while ( para->document() != p->document() && !indices.isEmpty() ) 136 while ( para->document() != p->document() && !indices.isEmpty() )
134 pop(); 137 pop();
135 Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); 138 Q_ASSERT( indices.isEmpty() || para->document() == p->document() );
136 } 139 }
137 para = p; 140 para = p;
138 if ( index < 0 || index >= para->length() ) { 141 if ( index < 0 || index >= para->length() ) {
139#if defined(QT_CHECK_RANGE) 142#if defined(QT_CHECK_RANGE)
140 qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index ); 143 owarn << "QTextCursor::gotoParagraph Index: " << index << " out of range" << oendl;
141#endif 144#endif
142 index = index < 0 ? 0 : para->length() - 1; 145 index = index < 0 ? 0 : para->length() - 1;
143 } 146 }
144 147
145 tmpIndex = -1; 148 tmpIndex = -1;
146 idx = index; 149 idx = index;
147} 150}
148 151
149bool QTextDocument::hasSelection( int id, bool visible ) const 152bool QTextDocument::hasSelection( int id, bool visible ) const
150{ 153{
151 return ( selections.find( id ) != selections.end() && 154 return ( selections.find( id ) != selections.end() &&
152 ( !visible || 155 ( !visible ||
153 ( (QTextDocument*)this )->selectionStartCursor( id ) != 156 ( (QTextDocument*)this )->selectionStartCursor( id ) !=
154 ( (QTextDocument*)this )->selectionEndCursor( id ) ) ); 157 ( (QTextDocument*)this )->selectionEndCursor( id ) ) );
155} 158}
156 159
157void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) 160void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor )
158{ 161{
159 QTextDocumentSelection sel; 162 QTextDocumentSelection sel;
160 sel.startCursor = cursor; 163 sel.startCursor = cursor;
161 sel.endCursor = cursor; 164 sel.endCursor = cursor;
162 sel.swapped = FALSE; 165 sel.swapped = FALSE;
163 selections[ id ] = sel; 166 selections[ id ] = sel;
164} 167}
165 168
166QTextParagraph *QTextDocument::paragAt( int i ) const 169QTextParagraph *QTextDocument::paragAt( int i ) const
167{ 170{
168 QTextParagraph* p = curParag; 171 QTextParagraph* p = curParag;
169 if ( !p || p->paragId() > i ) 172 if ( !p || p->paragId() > i )
170 p = fParag; 173 p = fParag;
171 while ( p && p->paragId() != i ) 174 while ( p && p->paragId() != i )
172 p = p->next(); 175 p = p->next();
173 ((QTextDocument*)this)->curParag = p; 176 ((QTextDocument*)this)->curParag = p;
174 return p; 177 return p;
175} 178}
176 179
177 180
178QTextFormat::~QTextFormat() 181QTextFormat::~QTextFormat()
179{ 182{
180} 183}
181 184
182QTextFormat::QTextFormat() 185QTextFormat::QTextFormat()
183 : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ) 186 : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() )
184{ 187{
185 ref = 0; 188 ref = 0;
186 189
187 usePixelSizes = FALSE; 190 usePixelSizes = FALSE;
188 if ( stdSize == -1 ) { 191 if ( stdSize == -1 ) {
@@ -432,146 +435,146 @@ void QTextParagraph::setSelection( int id, int start, int end )
432 435
433void QTextParagraph::removeSelection( int id ) 436void QTextParagraph::removeSelection( int id )
434{ 437{
435 if ( !hasSelection( id ) ) 438 if ( !hasSelection( id ) )
436 return; 439 return;
437 if ( mSelections ) 440 if ( mSelections )
438 mSelections->remove( id ); 441 mSelections->remove( id );
439 setChanged( TRUE, TRUE ); 442 setChanged( TRUE, TRUE );
440} 443}
441 444
442int QTextParagraph::selectionStart( int id ) const 445int QTextParagraph::selectionStart( int id ) const
443{ 446{
444 if ( !mSelections ) 447 if ( !mSelections )
445 return -1; 448 return -1;
446 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); 449 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
447 if ( it == mSelections->end() ) 450 if ( it == mSelections->end() )
448 return -1; 451 return -1;
449 return ( *it ).start; 452 return ( *it ).start;
450} 453}
451 454
452int QTextParagraph::selectionEnd( int id ) const 455int QTextParagraph::selectionEnd( int id ) const
453{ 456{
454 if ( !mSelections ) 457 if ( !mSelections )
455 return -1; 458 return -1;
456 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); 459 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
457 if ( it == mSelections->end() ) 460 if ( it == mSelections->end() )
458 return -1; 461 return -1;
459 return ( *it ).end; 462 return ( *it ).end;
460} 463}
461 464
462bool QTextParagraph::hasSelection( int id ) const 465bool QTextParagraph::hasSelection( int id ) const
463{ 466{
464 return mSelections ? mSelections->contains( id ) : FALSE; 467 return mSelections ? mSelections->contains( id ) : FALSE;
465} 468}
466 469
467bool QTextParagraph::fullSelected( int id ) const 470bool QTextParagraph::fullSelected( int id ) const
468{ 471{
469 if ( !mSelections ) 472 if ( !mSelections )
470 return FALSE; 473 return FALSE;
471 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); 474 QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
472 if ( it == mSelections->end() ) 475 if ( it == mSelections->end() )
473 return FALSE; 476 return FALSE;
474 return ( *it ).start == 0 && ( *it ).end == str->length() - 1; 477 return ( *it ).start == 0 && ( *it ).end == str->length() - 1;
475} 478}
476 479
477int QTextParagraph::lineY( int l ) const 480int QTextParagraph::lineY( int l ) const
478{ 481{
479 if ( l > (int)lineStarts.count() - 1 ) { 482 if ( l > (int)lineStarts.count() - 1 ) {
480 qWarning( "QTextParagraph::lineY: line %d out of range!", l ); 483 owarn << "QTextParagraph::lineY: line " << l << " out of range!" << oendl;
481 return 0; 484 return 0;
482 } 485 }
483 486
484 if ( !isValid() ) 487 if ( !isValid() )
485 ( (QTextParagraph*)this )->format(); 488 ( (QTextParagraph*)this )->format();
486 489
487 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 490 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
488 while ( l-- > 0 ) 491 while ( l-- > 0 )
489 ++it; 492 ++it;
490 return ( *it )->y; 493 return ( *it )->y;
491} 494}
492 495
493int QTextParagraph::lineBaseLine( int l ) const 496int QTextParagraph::lineBaseLine( int l ) const
494{ 497{
495 if ( l > (int)lineStarts.count() - 1 ) { 498 if ( l > (int)lineStarts.count() - 1 ) {
496 qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l ); 499 owarn << "QTextParagraph::lineBaseLine: line " << l << " out of range!" << oendl;
497 return 10; 500 return 10;
498 } 501 }
499 502
500 if ( !isValid() ) 503 if ( !isValid() )
501 ( (QTextParagraph*)this )->format(); 504 ( (QTextParagraph*)this )->format();
502 505
503 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 506 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
504 while ( l-- > 0 ) 507 while ( l-- > 0 )
505 ++it; 508 ++it;
506 return ( *it )->baseLine; 509 return ( *it )->baseLine;
507} 510}
508 511
509int QTextParagraph::lineHeight( int l ) const 512int QTextParagraph::lineHeight( int l ) const
510{ 513{
511 if ( l > (int)lineStarts.count() - 1 ) { 514 if ( l > (int)lineStarts.count() - 1 ) {
512 qWarning( "QTextParagraph::lineHeight: line %d out of range!", l ); 515 owarn << "QTextParagraph::lineHeight: line " << l << " out of range!" << oendl;
513 return 15; 516 return 15;
514 } 517 }
515 518
516 if ( !isValid() ) 519 if ( !isValid() )
517 ( (QTextParagraph*)this )->format(); 520 ( (QTextParagraph*)this )->format();
518 521
519 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 522 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
520 while ( l-- > 0 ) 523 while ( l-- > 0 )
521 ++it; 524 ++it;
522 return ( *it )->h; 525 return ( *it )->h;
523} 526}
524 527
525void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const 528void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const
526{ 529{
527 if ( l > (int)lineStarts.count() - 1 ) { 530 if ( l > (int)lineStarts.count() - 1 ) {
528 qWarning( "QTextParagraph::lineInfo: line %d out of range!", l ); 531 owarn << "QTextParagraph::lineInfo: line " << l << " out of range!" << oendl;
529 qDebug( "%d %d", (int)lineStarts.count() - 1, l ); 532 odebug << "" << (int)lineStarts.count() - 1 << " " << l << "" << oendl;
530 y = 0; 533 y = 0;
531 h = 15; 534 h = 15;
532 bl = 10; 535 bl = 10;
533 return; 536 return;
534 } 537 }
535 538
536 if ( !isValid() ) 539 if ( !isValid() )
537 ( (QTextParagraph*)this )->format(); 540 ( (QTextParagraph*)this )->format();
538 541
539 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); 542 QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
540 while ( l-- > 0 ) 543 while ( l-- > 0 )
541 ++it; 544 ++it;
542 y = ( *it )->y; 545 y = ( *it )->y;
543 h = ( *it )->h; 546 h = ( *it )->h;
544 bl = ( *it )->baseLine; 547 bl = ( *it )->baseLine;
545} 548}
546 549
547 550
548void QTextParagraph::setAlignment( int a ) 551void QTextParagraph::setAlignment( int a )
549{ 552{
550 if ( a == (int)align ) 553 if ( a == (int)align )
551 return; 554 return;
552 align = a; 555 align = a;
553 invalidate( 0 ); 556 invalidate( 0 );
554} 557}
555 558
556QTextFormatter *QTextParagraph::formatter() const 559QTextFormatter *QTextParagraph::formatter() const
557{ 560{
558 if ( hasdoc ) 561 if ( hasdoc )
559 return document()->formatter(); 562 return document()->formatter();
560 if ( pseudoDocument()->pFormatter ) 563 if ( pseudoDocument()->pFormatter )
561 return pseudoDocument()->pFormatter; 564 return pseudoDocument()->pFormatter;
562 return ( ( (QTextParagraph*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords ); 565 return ( ( (QTextParagraph*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords );
563} 566}
564 567
565void QTextParagraph::setTabArray( int *a ) 568void QTextParagraph::setTabArray( int *a )
566{ 569{
567 delete [] tArray; 570 delete [] tArray;
568 tArray = a; 571 tArray = a;
569} 572}
570 573
571void QTextParagraph::setTabStops( int tw ) 574void QTextParagraph::setTabStops( int tw )
572{ 575{
573 if ( hasdoc ) 576 if ( hasdoc )
574 document()->setTabStops( tw ); 577 document()->setTabStops( tw );
575 else 578 else
576 tabStopWidth = tw; 579 tabStopWidth = tw;
577} 580}
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index 0fe5b09..046d997 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,57 +1,62 @@
1#include <qmessagebox.h>
2#include <qheader.h>
3
4#include "accountdisplay.h" 1#include "accountdisplay.h"
5#include "newaccount.h" 2#include "newaccount.h"
6#include "transaction.h" 3#include "transaction.h"
7#include "transferdialog.h" 4#include "transferdialog.h"
8#include "transfer.h" 5#include "transfer.h"
9 6
7/* OPIE */
8#include <opie2/odebug.h>
9using namespace Opie::Core;
10
11/* QT */
12#include <qmessagebox.h>
13#include <qheader.h>
14
10extern Account *account; 15extern Account *account;
11extern Transaction *transaction; 16extern Transaction *transaction;
12extern Transfer *transfer; 17extern Transfer *transfer;
13extern Preferences *preferences; 18extern Preferences *preferences;
14 19
15AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) 20AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
16 { 21 {
17 cleared = 0; 22 cleared = 0;
18 23
19 firstline = new QHBox ( this ); 24 firstline = new QHBox ( this );
20 firstline->setSpacing ( 2 ); 25 firstline->setSpacing ( 2 );
21 26
22 newaccount = new QPushButton ( firstline ); 27 newaccount = new QPushButton ( firstline );
23 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); 28 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
24 connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) ); 29 connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) );
25 30
26 editaccount = new QPushButton ( firstline ); 31 editaccount = new QPushButton ( firstline );
27 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); 32 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
28 connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) ); 33 connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) );
29 34
30 deleteaccount = new QPushButton ( firstline ); 35 deleteaccount = new QPushButton ( firstline );
31 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); 36 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
32 connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) ); 37 connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) );
33 38
34 transferbutton = new QPushButton ( firstline ); 39 transferbutton = new QPushButton ( firstline );
35 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") ); 40 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") );
36 transferbutton->setToggleButton ( TRUE ); 41 transferbutton->setToggleButton ( TRUE );
37 connect ( transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( accountTransfer(bool) ) ); 42 connect ( transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( accountTransfer(bool) ) );
38 43
39 listview = new QListView ( this ); 44 listview = new QListView ( this );
40 listview->setAllColumnsShowFocus ( TRUE ); 45 listview->setAllColumnsShowFocus ( TRUE );
41 listview->setShowSortIndicator ( TRUE ); 46 listview->setShowSortIndicator ( TRUE );
42 listview->setRootIsDecorated ( TRUE ); 47 listview->setRootIsDecorated ( TRUE );
43 listview->setMultiSelection ( FALSE ); 48 listview->setMultiSelection ( FALSE );
44 connect ( listview, SIGNAL ( expanded(QListViewItem*) ), this, SLOT ( setAccountExpanded(QListViewItem*) ) ); 49 connect ( listview, SIGNAL ( expanded(QListViewItem*) ), this, SLOT ( setAccountExpanded(QListViewItem*) ) );
45 connect ( listview, SIGNAL ( collapsed(QListViewItem*) ), this, SLOT ( setAccountCollapsed(QListViewItem*) ) ); 50 connect ( listview, SIGNAL ( collapsed(QListViewItem*) ), this, SLOT ( setAccountCollapsed(QListViewItem*) ) );
46 51
47 listview->header()->setTracking ( FALSE ); 52 listview->header()->setTracking ( FALSE );
48 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); 53 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
49 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); 54 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
50 55
51 layout = new QVBoxLayout ( this, 2, 5 ); 56 layout = new QVBoxLayout ( this, 2, 5 );
52 layout->addWidget ( firstline ); 57 layout->addWidget ( firstline );
53 layout->addWidget ( listview ); 58 layout->addWidget ( listview );
54 } 59 }
55 60
56void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) 61void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs )
57 { 62 {
@@ -222,97 +227,97 @@ void AccountDisplay::accountTransfer ( bool state )
222 { 227 {
223 firstaccountid = -1; 228 firstaccountid = -1;
224 secondaccountid = -1; 229 secondaccountid = -1;
225 listview->clearSelection (); 230 listview->clearSelection ();
226 listview->setMultiSelection ( TRUE ); 231 listview->setMultiSelection ( TRUE );
227 disableParentsWithChildren (); 232 disableParentsWithChildren ();
228 connect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); 233 connect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
229 } 234 }
230 else 235 else
231 { 236 {
232 firstaccountid = -1; 237 firstaccountid = -1;
233 secondaccountid = -1; 238 secondaccountid = -1;
234 listview->clearSelection (); 239 listview->clearSelection ();
235 listview->setMultiSelection ( FALSE ); 240 listview->setMultiSelection ( FALSE );
236 enableAccounts (); 241 enableAccounts ();
237 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); 242 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
238 } 243 }
239 } 244 }
240 245
241void AccountDisplay::getTransferAccounts ( QListViewItem * item ) 246void AccountDisplay::getTransferAccounts ( QListViewItem * item )
242 { 247 {
243 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children 248 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children
244 { 249 {
245 if ( firstaccountid == -1 ) 250 if ( firstaccountid == -1 )
246 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account 251 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account
247 else 252 else
248 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first 253 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first
249 secondaccountid = item->text ( getIDColumn() ).toInt(); 254 secondaccountid = item->text ( getIDColumn() ).toInt();
250 } 255 }
251 256
252 // open transfer window if both accounts are set 257 // open transfer window if both accounts are set
253 if ( firstaccountid != -1 && secondaccountid != -1 ) 258 if ( firstaccountid != -1 && secondaccountid != -1 )
254 { 259 {
255 // construct the transferdialog window 260 // construct the transferdialog window
256 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); 261 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid );
257 262
258 // enter today's date in the date box as default 263 // enter today's date in the date box as default
259 QDate today = QDate::currentDate (); 264 QDate today = QDate::currentDate ();
260 int defaultday = today.day(); 265 int defaultday = today.day();
261 int defaultmonth = today.month(); 266 int defaultmonth = today.month();
262 int defaultyear = today.year(); 267 int defaultyear = today.year();
263 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 268 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
264 269
265 if ( td->exec() == QDialog::Accepted ) 270 if ( td->exec() == QDialog::Accepted )
266 { 271 {
267 // set the cleared integer if the checkbox is checked 272 // set the cleared integer if the checkbox is checked
268 if ( td->clearedcheckbox->isChecked() == TRUE ) 273 if ( td->clearedcheckbox->isChecked() == TRUE )
269 cleared = 1; 274 cleared = 1;
270 qDebug("Year from transferdialog = %i",td->getYear()); 275 odebug << "Year from transferdialog = " << td->getYear() << "" << oendl;
271 // add the transfer with a new date if its been edited or use the default date 276 // add the transfer with a new date if its been edited or use the default date
272 if ( td->getDateEdited () == TRUE ) 277 if ( td->getDateEdited () == TRUE )
273 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); 278 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
274 else 279 else
275 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); 280 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
276 281
277 // update account balances of both accounts and parents if necessary 282 // update account balances of both accounts and parents if necessary
278 account->updateAccountBalance ( firstaccountid ); 283 account->updateAccountBalance ( firstaccountid );
279 if ( account->getParentAccountID ( firstaccountid ) != -1 ) 284 if ( account->getParentAccountID ( firstaccountid ) != -1 )
280 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); 285 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
281 account->updateAccountBalance ( secondaccountid ); 286 account->updateAccountBalance ( secondaccountid );
282 if ( account->getParentAccountID ( secondaccountid ) != -1 ) 287 if ( account->getParentAccountID ( secondaccountid ) != -1 )
283 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); 288 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) );
284 289
285 // redisplay accounts 290 // redisplay accounts
286 account->displayAccounts ( listview ); 291 account->displayAccounts ( listview );
287 } 292 }
288 else 293 else
289 { 294 {
290 firstaccountid = -1; 295 firstaccountid = -1;
291 secondaccountid = -1; 296 secondaccountid = -1;
292 listview->clearSelection (); 297 listview->clearSelection ();
293 listview->setMultiSelection ( FALSE ); 298 listview->setMultiSelection ( FALSE );
294 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); 299 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
295 } 300 }
296 301
297 // reset the accounts display window 302 // reset the accounts display window
298 transferbutton->toggle(); // toggling this button with clear the window as well 303 transferbutton->toggle(); // toggling this button with clear the window as well
299 304
300 // reenable all the accounts so the transaction tab will be properly set 305 // reenable all the accounts so the transaction tab will be properly set
301 enableAccounts (); 306 enableAccounts ();
302 } 307 }
303 } 308 }
304 309
305void AccountDisplay::disableParentsWithChildren () 310void AccountDisplay::disableParentsWithChildren ()
306 { 311 {
307 // iterate through accountdisplay listview and disable all the parents that have children 312 // iterate through accountdisplay listview and disable all the parents that have children
308 QListViewItemIterator it ( listview ); 313 QListViewItemIterator it ( listview );
309 for ( ; it.current(); ++it ) 314 for ( ; it.current(); ++it )
310 { 315 {
311 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) 316 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 )
312 it.current()->setSelectable ( FALSE ); 317 it.current()->setSelectable ( FALSE );
313 } 318 }
314 } 319 }
315 320
316void AccountDisplay::enableAccounts () 321void AccountDisplay::enableAccounts ()
317 { 322 {
318 // iterate through accountdisplay listview and enable all accounts 323 // iterate through accountdisplay listview and enable all accounts
diff --git a/noncore/apps/qashmoney/config.in b/noncore/apps/qashmoney/config.in
index 91739fe..aeed298 100644
--- a/noncore/apps/qashmoney/config.in
+++ b/noncore/apps/qashmoney/config.in
@@ -1,4 +1,4 @@
1 config QASHMONEY 1 config QASHMONEY
2 boolean "opie-qashmoney (money manager)" 2 boolean "opie-qashmoney (money manager)"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/qashmoney/qashmoney.pro b/noncore/apps/qashmoney/qashmoney.pro
index 6ad3db3..8a4302f 100755
--- a/noncore/apps/qashmoney/qashmoney.pro
+++ b/noncore/apps/qashmoney/qashmoney.pro
@@ -1,49 +1,49 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on 2CONFIG = qt warn_on
3 HEADERS =qashmoney.h \ 3 HEADERS =qashmoney.h \
4 accountdisplay.h \ 4 accountdisplay.h \
5 account.h \ 5 account.h \
6 transaction.h \ 6 transaction.h \
7 transactiondisplay.h \ 7 transactiondisplay.h \
8 newtransaction.h \ 8 newtransaction.h \
9 transfer.h \ 9 transfer.h \
10 transferdialog.h \ 10 transferdialog.h \
11 preferences.h \ 11 preferences.h \
12 preferencedialogs.h \ 12 preferencedialogs.h \
13 memory.h \ 13 memory.h \
14 memorydialog.h \ 14 memorydialog.h \
15 newaccount.h \ 15 newaccount.h \
16 calculator.h \ 16 calculator.h \
17 datepicker.h \ 17 datepicker.h \
18 budget.h \ 18 budget.h \
19 budgetdisplay.h \ 19 budgetdisplay.h \
20 currency.h 20 currency.h
21 SOURCES =qashmoney.cpp \ 21 SOURCES =qashmoney.cpp \
22 accountdisplay.cpp \ 22 accountdisplay.cpp \
23 account.cpp \ 23 account.cpp \
24 transaction.cpp \ 24 transaction.cpp \
25 transactiondisplay.cpp \ 25 transactiondisplay.cpp \
26 newtransaction.cpp \ 26 newtransaction.cpp \
27 transfer.cpp \ 27 transfer.cpp \
28 transferdialog.cpp \ 28 transferdialog.cpp \
29 preferences.cpp \ 29 preferences.cpp \
30 preferencedialogs.cpp \ 30 preferencedialogs.cpp \
31 memory.cpp \ 31 memory.cpp \
32 memorydialog.cpp \ 32 memorydialog.cpp \
33 newaccount.cpp \ 33 newaccount.cpp \
34 calculator.cpp \ 34 calculator.cpp \
35 datepicker.cpp \ 35 datepicker.cpp \
36 main.cpp \ 36 main.cpp \
37 budget.cpp \ 37 budget.cpp \
38 budgetdisplay.cpp \ 38 budgetdisplay.cpp \
39 currency.cpp 39 currency.cpp
40INCLUDEPATH = $(OPIEDIR)/include 40INCLUDEPATH = $(OPIEDIR)/include
41DEPENDPATH = $(OPIEDIR)/include 41DEPENDPATH = $(OPIEDIR)/include
42 42
43DESTDIR = $(OPIEDIR)/bin 43DESTDIR = $(OPIEDIR)/bin
44 44
45unix:LIBS += -lm 45unix:LIBS += -lm
46LIBS += -lqpe -lqte -lsqlite 46LIBS += -lqpe -lopiecore2 -lsqlite
47 47
48include ( $(OPIEDIR)/include.pro ) 48include ( $(OPIEDIR)/include.pro )
49 49
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp
index dbf9370..6e544ba 100644
--- a/noncore/apps/tableviewer/db/common.cpp
+++ b/noncore/apps/tableviewer/db/common.cpp
@@ -1,76 +1,84 @@
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 <stdlib.h> 20#include "common.h"
21#include "datacache.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
25#include <qpe/timestring.h>
26using namespace Opie::Core;
27
28/* QT */
21#include <qstring.h> 29#include <qstring.h>
22#include <qheader.h> 30#include <qheader.h>
23#include <qvector.h> 31#include <qvector.h>
24#include <qdatetime.h> 32#include <qdatetime.h>
25#include <qpe/timestring.h> 33
26#include "common.h" 34/* STD */
27#include "datacache.h"
28#include <assert.h> 35#include <assert.h>
36#include <stdlib.h>
29 37
30static const int del_flag = 0x1; 38static const int del_flag = 0x1;
31static const int new_flag = 0x2; 39static const int new_flag = 0x2;
32 40
33/* Helper function */ 41/* Helper function */
34 42
35int parseNextNumber(QString *q) { 43int parseNextNumber(QString *q) {
36 QChar c; 44 QChar c;
37 uint i; 45 uint i;
38 int result = 0; 46 int result = 0;
39 47
40 bool found_digits = FALSE; 48 bool found_digits = FALSE;
41 for(i = 0; i < q->length(); i++) { 49 for(i = 0; i < q->length(); i++) {
42 c = q->at(i); 50 c = q->at(i);
43 if (c.isDigit()) { 51 if (c.isDigit()) {
44 if (found_digits) 52 if (found_digits)
45 result *= 10; 53 result *= 10;
46 found_digits = TRUE; 54 found_digits = TRUE;
47 result += c.digitValue(); 55 result += c.digitValue();
48 } else { 56 } else {
49 if (found_digits) 57 if (found_digits)
50 break; 58 break;
51 /* just skip this char */ 59 /* just skip this char */
52 } 60 }
53 } 61 }
54 /* now truncate q */ 62 /* now truncate q */
55 if (found_digits) 63 if (found_digits)
56 q->remove(0, i); 64 q->remove(0, i);
57 return result; 65 return result;
58} 66}
59 67
60/*! 68/*!
61 \class QStringVector 69 \class QStringVector
62 \brief A Vector of QStrings that can be sorted and searched 70 \brief A Vector of QStrings that can be sorted and searched
63 71
64 Implmented in order to allow reverse lookup on the string name 72 Implmented in order to allow reverse lookup on the string name
65 73
66*/ 74*/
67 75
68/*! 76/*!
69 This function implements the compare function in order to allow the 77 This function implements the compare function in order to allow the
70 searching and sorting of the QStringVector to occur 78 searching and sorting of the QStringVector to occur
71 79
72 \returns an int which is either 80 \returns an int which is either
73 <UL> 81 <UL>
74 <LI> < 0 if the first string is smaller than the second,</LI> 82 <LI> < 0 if the first string is smaller than the second,</LI>
75 <LI> > 0 if the first string is bigger then the second,</LI> 83 <LI> > 0 if the first string is bigger then the second,</LI>
76 <LI> == 0 if the first string is equal to the second.</LI> 84 <LI> == 0 if the first string is equal to the second.</LI>
@@ -267,97 +275,97 @@ TVVariant::KeyType TVVariant::nameToType(const QString &name)
267 return Date; 275 return Date;
268 if(!qstrcmp("Time", name)) 276 if(!qstrcmp("Time", name))
269 return Time; 277 return Time;
270 if(!qstrcmp("Int", name)) 278 if(!qstrcmp("Int", name))
271 return Int; 279 return Int;
272 280
273 return Invalid; 281 return Invalid;
274} 282}
275 283
276void TVVariant::load(QDataStream &s ) 284void TVVariant::load(QDataStream &s )
277{ 285{
278 KeyType t; 286 KeyType t;
279 s >> t; 287 s >> t;
280 288
281 d->typ = t; 289 d->typ = t;
282 switch(t) { 290 switch(t) {
283 case Invalid: 291 case Invalid:
284 d->typ = t; 292 d->typ = t;
285 break; 293 break;
286 case String: 294 case String:
287 { 295 {
288 QString *x = new QString; 296 QString *x = new QString;
289 s >> *x; 297 s >> *x;
290 d->value.ptr = x; 298 d->value.ptr = x;
291 } 299 }
292 break; 300 break;
293 case Time: 301 case Time:
294 { 302 {
295 QTime *x = new QTime; 303 QTime *x = new QTime;
296 s >> *x; 304 s >> *x;
297 d->value.ptr = x; 305 d->value.ptr = x;
298 } 306 }
299 break; 307 break;
300 case Date: 308 case Date:
301 { 309 {
302 QDate *x = new QDate; 310 QDate *x = new QDate;
303 s >> *x; 311 s >> *x;
304 d->value.ptr = x; 312 d->value.ptr = x;
305 } 313 }
306 break; 314 break;
307 case Int: 315 case Int:
308 { 316 {
309 int x; 317 int x;
310 s >> x; 318 s >> x;
311 d->value.i = x; 319 d->value.i = x;
312 } 320 }
313 break; 321 break;
314 default: 322 default:
315 qFatal("Unrecognized data type"); 323 ofatal << "Unrecognized data type" << oendl;
316 } 324 }
317} 325}
318 326
319void TVVariant::save( QDataStream &s ) const 327void TVVariant::save( QDataStream &s ) const
320{ 328{
321 s << type(); 329 s << type();
322 330
323 switch( d->typ ) { 331 switch( d->typ ) {
324 case String: 332 case String:
325 s << *((QString *)d->value.ptr); 333 s << *((QString *)d->value.ptr);
326 break; 334 break;
327 case Date: 335 case Date:
328 s << *((QDate *)d->value.ptr); 336 s << *((QDate *)d->value.ptr);
329 break; 337 break;
330 case Time: 338 case Time:
331 s << *((QTime *)d->value.ptr); 339 s << *((QTime *)d->value.ptr);
332 break; 340 break;
333 case Int: 341 case Int:
334 s << d->value.i; 342 s << d->value.i;
335 break; 343 break;
336 case Invalid: 344 case Invalid:
337 break; 345 break;
338 } 346 }
339} 347}
340 348
341QDataStream& operator>>(QDataStream& s, TVVariant& p) 349QDataStream& operator>>(QDataStream& s, TVVariant& p)
342{ 350{
343 p.load( s ); 351 p.load( s );
344 return s; 352 return s;
345} 353}
346 354
347QDataStream& operator<<(QDataStream &s, const TVVariant& p) 355QDataStream& operator<<(QDataStream &s, const TVVariant& p)
348{ 356{
349 p.save( s ); 357 p.save( s );
350 return s; 358 return s;
351} 359}
352 360
353QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p) 361QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p)
354{ 362{
355 Q_UINT8 u = 0; 363 Q_UINT8 u = 0;
356 s >> u; 364 s >> u;
357 p = (TVVariant::KeyType) u; 365 p = (TVVariant::KeyType) u;
358 366
359 return s; 367 return s;
360} 368}
361 369
362QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p) 370QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p)
363{ 371{
@@ -1033,97 +1041,97 @@ QDataStream &operator>>( QDataStream &s, KeyList &k)
1033 1041
1034/*! 1042/*!
1035 Constructs a DataElem. This function needs a container because the 1043 Constructs a DataElem. This function needs a container because the
1036 size, types of keys and primary key are all defined by the containing 1044 size, types of keys and primary key are all defined by the containing
1037 database 1045 database
1038*/ 1046*/
1039DataElem::DataElem(DBStore *c) : values(20) 1047DataElem::DataElem(DBStore *c) : values(20)
1040{ 1048{
1041 int size; 1049 int size;
1042 contained = c; 1050 contained = c;
1043 size = c->getNumFields(); 1051 size = c->getNumFields();
1044 values.setAutoDelete(TRUE); 1052 values.setAutoDelete(TRUE);
1045} 1053}
1046 1054
1047/*! 1055/*!
1048 Destroys a DataElem and frees memory used by the DataElem 1056 Destroys a DataElem and frees memory used by the DataElem
1049*/ 1057*/
1050DataElem::~DataElem() { 1058DataElem::~DataElem() {
1051} 1059}
1052 1060
1053 1061
1054 1062
1055QDataStream &operator<<( QDataStream &s, const DataElem &d) 1063QDataStream &operator<<( QDataStream &s, const DataElem &d)
1056{ 1064{
1057 int size = d.getNumFields(); 1065 int size = d.getNumFields();
1058 1066
1059 s << size; /* redundent data but makes streaming easier */ 1067 s << size; /* redundent data but makes streaming easier */
1060 KeyList k = d.getKeys(); 1068 KeyList k = d.getKeys();
1061 1069
1062 KeyListIterator it(k); 1070 KeyListIterator it(k);
1063 1071
1064 while(it.current()) { 1072 while(it.current()) {
1065 s << (Q_UINT16)it.currentKey(); 1073 s << (Q_UINT16)it.currentKey();
1066 s << d.getField(it.currentKey()); 1074 s << d.getField(it.currentKey());
1067 ++it; 1075 ++it;
1068 } 1076 }
1069 return s; 1077 return s;
1070} 1078}
1071 1079
1072QDataStream &operator>>( QDataStream &s, DataElem &d) 1080QDataStream &operator>>( QDataStream &s, DataElem &d)
1073{ 1081{
1074 int i; 1082 int i;
1075 int size; 1083 int size;
1076 TVVariant t; 1084 TVVariant t;
1077 int index = 0; 1085 int index = 0;
1078 1086
1079 s >> size; /* redundent data but makes streaming easier */ 1087 s >> size; /* redundent data but makes streaming easier */
1080 if (size != d.getNumFields()) { 1088 if (size != d.getNumFields()) {
1081 qWarning("DataSize mis-match"); 1089 owarn << "DataSize mis-match" << oendl;
1082 return s; /* sanity check failed.. don't load */ 1090 return s; /* sanity check failed.. don't load */
1083 } 1091 }
1084 1092
1085 for(i = 0; i < size; i++) { 1093 for(i = 0; i < size; i++) {
1086 s >> (Q_UINT16)index; 1094 s >> (Q_UINT16)index;
1087 s >> t; 1095 s >> t;
1088 d.setField(index, t); 1096 d.setField(index, t);
1089 } 1097 }
1090 return s; 1098 return s;
1091} 1099}
1092 1100
1093/*! Returns the number of possible (not valid) fields in the data element */ 1101/*! Returns the number of possible (not valid) fields in the data element */
1094int DataElem::getNumFields() const 1102int DataElem::getNumFields() const
1095{ 1103{
1096 return contained->getNumFields(); 1104 return contained->getNumFields();
1097} 1105}
1098 1106
1099KeyList DataElem::getKeys() const 1107KeyList DataElem::getKeys() const
1100{ 1108{
1101 return *(contained->getKeys()); 1109 return *(contained->getKeys());
1102} 1110}
1103 1111
1104/*! 1112/*!
1105 This function determines whether field index i of the element has been 1113 This function determines whether field index i of the element has been
1106 set yet. 1114 set yet.
1107 1115
1108 \return A boolean value that is TRUE if the specfied field of this 1116 \return A boolean value that is TRUE if the specfied field of this
1109 element has been set and FALSE if the field has not yet been set 1117 element has been set and FALSE if the field has not yet been set
1110*/ 1118*/
1111bool DataElem::hasValidValue(int i) const 1119bool DataElem::hasValidValue(int i) const
1112{ 1120{
1113 if(!values.find(i)) 1121 if(!values.find(i))
1114 return FALSE; 1122 return FALSE;
1115 if(!contained->getKeys()->validIndex(i)) 1123 if(!contained->getKeys()->validIndex(i))
1116 return FALSE; 1124 return FALSE;
1117 return values.find(i)->isValid(); 1125 return values.find(i)->isValid();
1118} 1126}
1119 1127
1120/*! 1128/*!
1121 This function determines whether field name qs of the element has been 1129 This function determines whether field name qs of the element has been
1122 set yet. 1130 set yet.
1123 1131
1124 \return A boolean value that is TRUE if the specfied field of this 1132 \return A boolean value that is TRUE if the specfied field of this
1125 element has been set and FALSE if the field has not yet been set 1133 element has been set and FALSE if the field has not yet been set
1126*/ 1134*/
1127bool DataElem::hasValidValue(QString qs) const 1135bool DataElem::hasValidValue(QString qs) const
1128{ 1136{
1129 int i = contained->getKeyIndex(qs); 1137 int i = contained->getKeyIndex(qs);
@@ -1332,139 +1340,139 @@ bool DataElem::lessThan(int i, TVVariant v) const
1332 if (getField(i).type() != v.type()) 1340 if (getField(i).type() != v.type())
1333 return FALSE; 1341 return FALSE;
1334 1342
1335 return (getField(i) < v); 1343 return (getField(i) < v);
1336} 1344}
1337 1345
1338bool DataElem::moreThan(int i, TVVariant v) const 1346bool DataElem::moreThan(int i, TVVariant v) const
1339{ 1347{
1340 if (!hasValidValue(i)) return FALSE; 1348 if (!hasValidValue(i)) return FALSE;
1341 1349
1342 if (getField(i).type() != v.type()) 1350 if (getField(i).type() != v.type())
1343 return FALSE; 1351 return FALSE;
1344 1352
1345 return (getField(i) > v); 1353 return (getField(i) > v);
1346} 1354}
1347 1355
1348bool DataElem::equalTo(int i, TVVariant v) const 1356bool DataElem::equalTo(int i, TVVariant v) const
1349{ 1357{
1350 if (!hasValidValue(i)) return FALSE; 1358 if (!hasValidValue(i)) return FALSE;
1351 1359
1352 if (getField(i).type() != v.type()) 1360 if (getField(i).type() != v.type())
1353 return FALSE; 1361 return FALSE;
1354 1362
1355 return (getField(i) == v); 1363 return (getField(i) == v);
1356} 1364}
1357 1365
1358bool DataElem::contains(int i, TVVariant v) const 1366bool DataElem::contains(int i, TVVariant v) const
1359{ 1367{
1360 if (!hasValidValue(i)) return FALSE; 1368 if (!hasValidValue(i)) return FALSE;
1361 1369
1362 if (getField(i).type() != v.type()) 1370 if (getField(i).type() != v.type())
1363 return FALSE; 1371 return FALSE;
1364 1372
1365 switch(getField(i).type()) { 1373 switch(getField(i).type()) {
1366 case TVVariant::String: { 1374 case TVVariant::String: {
1367 QString qs1 = getField(i).toString().lower(); 1375 QString qs1 = getField(i).toString().lower();
1368 QString qs2 = v.toString().lower(); 1376 QString qs2 = v.toString().lower();
1369 if (qs1.contains(qs2) > 0) return TRUE; 1377 if (qs1.contains(qs2) > 0) return TRUE;
1370 break; 1378 break;
1371 } 1379 }
1372 /* meaningless for ints */ 1380 /* meaningless for ints */
1373 /* meaningless for time */ 1381 /* meaningless for time */
1374 /* meaningless for dates */ 1382 /* meaningless for dates */
1375 case TVVariant::Int: 1383 case TVVariant::Int:
1376 case TVVariant::Time: 1384 case TVVariant::Time:
1377 case TVVariant::Date: 1385 case TVVariant::Date:
1378 break; 1386 break;
1379 default: 1387 default:
1380 qWarning("Tried to compare unknown data type"); 1388 owarn << "Tried to compare unknown data type" << oendl;
1381 } 1389 }
1382 return FALSE; 1390 return FALSE;
1383} 1391}
1384 1392
1385bool DataElem::startsWith(int i, TVVariant v) const 1393bool DataElem::startsWith(int i, TVVariant v) const
1386{ 1394{
1387 if (!hasValidValue(i)) return FALSE; 1395 if (!hasValidValue(i)) return FALSE;
1388 1396
1389 if (getField(i).type() != v.type()) 1397 if (getField(i).type() != v.type())
1390 return FALSE; 1398 return FALSE;
1391 1399
1392 switch(getField(i).type()) { 1400 switch(getField(i).type()) {
1393 case TVVariant::String: { 1401 case TVVariant::String: {
1394 QString qs1 = getField(i).toString().lower(); 1402 QString qs1 = getField(i).toString().lower();
1395 QString qs2 = v.toString().lower(); 1403 QString qs2 = v.toString().lower();
1396 return qs1.startsWith(qs2); 1404 return qs1.startsWith(qs2);
1397 } 1405 }
1398 /* meaningless for ints */ 1406 /* meaningless for ints */
1399 /* meaningless for time */ 1407 /* meaningless for time */
1400 /* meaningless for dates */ 1408 /* meaningless for dates */
1401 case TVVariant::Int: 1409 case TVVariant::Int:
1402 case TVVariant::Time: 1410 case TVVariant::Time:
1403 case TVVariant::Date: 1411 case TVVariant::Date:
1404 return FALSE; 1412 return FALSE;
1405 default: 1413 default:
1406 qWarning("Tried to compare unknown data type"); 1414 owarn << "Tried to compare unknown data type" << oendl;
1407 } 1415 }
1408 return FALSE; 1416 return FALSE;
1409} 1417}
1410 1418
1411bool DataElem::endsWith(int i, TVVariant v) const 1419bool DataElem::endsWith(int i, TVVariant v) const
1412{ 1420{
1413 if (!hasValidValue(i)) return FALSE; 1421 if (!hasValidValue(i)) return FALSE;
1414 1422
1415 if (getField(i).type() != v.type()) 1423 if (getField(i).type() != v.type())
1416 return FALSE; 1424 return FALSE;
1417 1425
1418 switch(getField(i).type()) { 1426 switch(getField(i).type()) {
1419 case TVVariant::String: { 1427 case TVVariant::String: {
1420 QString qs1 = getField(i).toString().lower(); 1428 QString qs1 = getField(i).toString().lower();
1421 QString qs2 = v.toString().lower(); 1429 QString qs2 = v.toString().lower();
1422 return qs1.startsWith(qs2); 1430 return qs1.startsWith(qs2);
1423 } 1431 }
1424 /* meaningless for ints */ 1432 /* meaningless for ints */
1425 /* meaningless for time */ 1433 /* meaningless for time */
1426 /* meaningless for dates */ 1434 /* meaningless for dates */
1427 case TVVariant::Int: 1435 case TVVariant::Int:
1428 case TVVariant::Time: 1436 case TVVariant::Time:
1429 case TVVariant::Date: 1437 case TVVariant::Date:
1430 return FALSE; 1438 return FALSE;
1431 default: 1439 default:
1432 qWarning("Tried to compare unknown data type"); 1440 owarn << "Tried to compare unknown data type" << oendl;
1433 } 1441 }
1434 return FALSE; 1442 return FALSE;
1435} 1443}
1436 1444
1437/*! 1445/*!
1438 Determins which of the first to parameters are closer to the third, target 1446 Determins which of the first to parameters are closer to the third, target
1439 parameter. 1447 parameter.
1440 1448
1441 \return 1449 \return
1442 <UL> 1450 <UL>
1443 <LI>TRUE if the first element is a closer match to the target than the 1451 <LI>TRUE if the first element is a closer match to the target than the
1444 second element</LI> 1452 second element</LI>
1445 <LI>FALSE if the first element is not a closer match to the target than 1453 <LI>FALSE if the first element is not a closer match to the target than
1446 the second element</LI> 1454 the second element</LI>
1447 </UL> 1455 </UL>
1448*/ 1456*/
1449bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) 1457bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column)
1450{ 1458{
1451 int type; 1459 int type;
1452 1460
1453 if(!d1) return FALSE; 1461 if(!d1) return FALSE;
1454 1462
1455 if (!d1->hasValidValue(column)) return FALSE; 1463 if (!d1->hasValidValue(column)) return FALSE;
1456 1464
1457 if(!target.isValid()) return FALSE; 1465 if(!target.isValid()) return FALSE;
1458 1466
1459 type = d1->getField(column).type(); 1467 type = d1->getField(column).type();
1460 1468
1461 if(d2) { 1469 if(d2) {
1462 if (type != d2->getField(column).type()) { 1470 if (type != d2->getField(column).type()) {
1463 /* can't do compare */ 1471 /* can't do compare */
1464 qWarning("Tried to compare two incompatable types"); 1472 owarn << "Tried to compare two incompatable types" << oendl;
1465 return FALSE; 1473 return FALSE;
1466 } 1474 }
1467 return target.closer(d1->getField(column), d2->getField(column)); 1475 return target.closer(d1->getField(column), d2->getField(column));
1468 } 1476 }
1469 return target.close(d1->getField(column)); 1477 return target.close(d1->getField(column));
1470} 1478}
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp
index 7c14eef..6380e1b 100644
--- a/noncore/apps/tableviewer/db/datacache.cpp
+++ b/noncore/apps/tableviewer/db/datacache.cpp
@@ -1,79 +1,87 @@
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 * This file is used to load the xml files that represent the database. 21 * This file is used to load the xml files that represent the database.
22 * The main requirment for said file is each data entry must contain a key, 22 * The main requirment for said file is each data entry must contain a key,
23 * otherwise any other data headings are allowed. 23 * otherwise any other data headings are allowed.
24 */ 24 */
25 25
26#include "datacache.h" 26#include "datacache.h"
27#include "xmlsource.h" 27#include "xmlsource.h"
28#include "csvsource.h" 28#include "csvsource.h"
29#include <stdlib.h> 29
30/* OPIE */
31#include <opie2/odebug.h>
32using namespace Opie::Core;
33
34/* QT */
30#include <qheader.h> 35#include <qheader.h>
31 36
37/* STD */
38#include <stdlib.h>
39
32#define INIT_TABLE_SIZE 128 40#define INIT_TABLE_SIZE 128
33 41
34/*! 42/*!
35 \class DBStore datastore.h 43 \class DBStore datastore.h
36 44
37 \brief The DBStore class is the class responsible for storing, sorting and 45 \brief The DBStore class is the class responsible for storing, sorting and
38 searching the data loaded by the application 46 searching the data loaded by the application
39 47
40*/ 48*/
41 49
42/*! 50/*!
43 Constructs a DBStore item 51 Constructs a DBStore item
44*/ 52*/
45DBStore::DBStore() 53DBStore::DBStore()
46{ 54{
47 name = ""; 55 name = "";
48 number_elems = 0; 56 number_elems = 0;
49 full = false; 57 full = false;
50 kRep = new KeyList(); 58 kRep = new KeyList();
51 master_table.resize(INIT_TABLE_SIZE); 59 master_table.resize(INIT_TABLE_SIZE);
52 table_size = INIT_TABLE_SIZE; 60 table_size = INIT_TABLE_SIZE;
53 61
54 current_elem = 0; 62 current_elem = 0;
55 archive = 0; 63 archive = 0;
56} 64}
57 65
58//TODO 66//TODO
59/*! 67/*!
60 Reinitializes the table to empty (include a resize of the master table, 68 Reinitializes the table to empty (include a resize of the master table,
61 which should free some memory) 69 which should free some memory)
62*/ 70*/
63void DBStore::freeTable() 71void DBStore::freeTable()
64{ 72{
65 name = ""; 73 name = "";
66 if(archive) { 74 if(archive) {
67 delete archive; 75 delete archive;
68 archive = 0; 76 archive = 0;
69 } 77 }
70 kRep->clear(); /* clear the current key list */ 78 kRep->clear(); /* clear the current key list */
71 79
72 number_elems = 0; 80 number_elems = 0;
73 table_size = INIT_TABLE_SIZE; 81 table_size = INIT_TABLE_SIZE;
74 master_table.resize(table_size); 82 master_table.resize(table_size);
75 full = false; 83 full = false;
76 current_elem = 0; 84 current_elem = 0;
77} 85}
78 86
79/*! 87/*!
@@ -105,97 +113,97 @@ bool DBStore::openSource(QIODevice *inDev, const QString &source) {
105 } else 113 } else
106 return false; 114 return false;
107 115
108 return (archive->openSource(inDev)); 116 return (archive->openSource(inDev));
109} 117}
110 118
111bool DBStore::saveSource(QIODevice *outDev, const QString &source) 119bool DBStore::saveSource(QIODevice *outDev, const QString &source)
112{ 120{
113 /* saving a new file */ 121 /* saving a new file */
114 if(!archive) { 122 if(!archive) {
115 if (source == "text/x-xml-tableviewer") { 123 if (source == "text/x-xml-tableviewer") {
116 archive = new DBXml(this); 124 archive = new DBXml(this);
117 } else if (source == "text/x-xml-tableviewer") { 125 } else if (source == "text/x-xml-tableviewer") {
118 archive = new DBCsv(this); 126 archive = new DBCsv(this);
119 } else 127 } else
120 return false; 128 return false;
121 } 129 }
122 130
123 /* changing file type */ 131 /* changing file type */
124 if(archive->type() != source) { 132 if(archive->type() != source) {
125 delete archive; 133 delete archive;
126 if (source == "text/x-xml-tableviewer") { 134 if (source == "text/x-xml-tableviewer") {
127 archive = new DBXml(this); 135 archive = new DBXml(this);
128 } else if (source == "text/x-xml-tableviewer") { 136 } else if (source == "text/x-xml-tableviewer") {
129 archive = new DBCsv(this); 137 archive = new DBCsv(this);
130 } else 138 } else
131 return false; 139 return false;
132 } 140 }
133 141
134 return (archive->saveSource(outDev)); 142 return (archive->saveSource(outDev));
135} 143}
136 144
137/*! 145/*!
138 This function is used to add new elements to the database. If the database 146 This function is used to add new elements to the database. If the database
139 has already reached the maximum allowable size this function does not alter 147 has already reached the maximum allowable size this function does not alter
140 the database. 148 the database.
141 149
142 \param delm An already allocated and initialized data element to be added 150 \param delm An already allocated and initialized data element to be added
143*/ 151*/
144void DBStore::addItem(DataElem *delem) 152void DBStore::addItem(DataElem *delem)
145{ 153{
146 addItemInternal(delem); 154 addItemInternal(delem);
147} 155}
148 156
149void DBStore::addItemInternal(DataElem *delem) 157void DBStore::addItemInternal(DataElem *delem)
150{ 158{
151 /* if already full, don't over fill, do a qWarning though */ 159 /* if already full, don't over fill, do a qWarning though */
152 if (full) { 160 if (full) {
153 qWarning("Attempted to add items to already full table"); 161 owarn << "Attempted to add items to already full table" << oendl;
154 return; 162 return;
155 } 163 }
156 164
157 master_table.insert(number_elems, delem); 165 master_table.insert(number_elems, delem);
158 166
159 current_elem = number_elems; 167 current_elem = number_elems;
160 number_elems++; 168 number_elems++;
161 169
162 if(number_elems >= table_size) { 170 if(number_elems >= table_size) {
163 /* filled current table, double if we can */ 171 /* filled current table, double if we can */
164 table_size = table_size << 1; 172 table_size = table_size << 1;
165 173
166 /* check that the new table size is still valid, i.e. that we didn't 174 /* check that the new table size is still valid, i.e. that we didn't
167 just shift the 1 bit of the end of the int. */ 175 just shift the 1 bit of the end of the int. */
168 if (!table_size) { 176 if (!table_size) {
169 full = true; 177 full = true;
170 /* no point in doing antying else. */ 178 /* no point in doing antying else. */
171 return; 179 return;
172 } 180 }
173 master_table.resize(table_size); 181 master_table.resize(table_size);
174 } 182 }
175} 183}
176 184
177void DBStore::removeItem(DataElem *r) 185void DBStore::removeItem(DataElem *r)
178{ 186{
179 int position = master_table.findRef(r); 187 int position = master_table.findRef(r);
180 if(position != -1) { 188 if(position != -1) {
181 /* there is at least one item, this is it */ 189 /* there is at least one item, this is it */
182 /* replace this with the last element, decrease the element count */ 190 /* replace this with the last element, decrease the element count */
183 master_table.insert(position, master_table.at(--number_elems)); 191 master_table.insert(position, master_table.at(--number_elems));
184 master_table.remove(number_elems); 192 master_table.remove(number_elems);
185 delete r; 193 delete r;
186 } 194 }
187} 195}
188 196
189/*! 197/*!
190 Sets the name of the database 198 Sets the name of the database
191 199
192 \param n A string representing the new name of the database. 200 \param n A string representing the new name of the database.
193*/ 201*/
194void DBStore::setName(const QString &n) 202void DBStore::setName(const QString &n)
195{ 203{
196 name = n; 204 name = n;
197} 205}
198 206
199/*! 207/*!
200 Gets the name of the database 208 Gets the name of the database
201 209
diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp
index 94fec36..4ca6aee 100644
--- a/noncore/apps/tableviewer/db/xmlsource.cpp
+++ b/noncore/apps/tableviewer/db/xmlsource.cpp
@@ -1,74 +1,80 @@
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 "xmlsource.h" 20#include "xmlsource.h"
21#include <qdict.h>
22#include <stdlib.h>
23#include <qtextstream.h>
24#include "../xmlencodeattr.h" 21#include "../xmlencodeattr.h"
25 22
23/* OPIE */
24#include <opie2/odebug.h>
25using namespace Opie::Core;
26 26
27/* QT */
28#include <qdict.h>
29#include <qtextstream.h>
30
31/* STD */
32#include <stdlib.h>
27 33
28DBXml::DBXml(DBStore *d) 34DBXml::DBXml(DBStore *d)
29{ 35{
30 dstore = d; 36 dstore = d;
31} 37}
32 38
33QString DBXml::type() 39QString DBXml::type()
34{ 40{
35 return "xml"; 41 return "xml";
36} 42}
37 43
38bool DBXml::openSource(QIODevice *inDev) 44bool DBXml::openSource(QIODevice *inDev)
39{ 45{
40 bool ok; 46 bool ok;
41 47
42 DBXmlHandler h(dstore); 48 DBXmlHandler h(dstore);
43 49
44 QTextStream tsIn(inDev); 50 QTextStream tsIn(inDev);
45 QXmlInputSource source(tsIn); 51 QXmlInputSource source(tsIn);
46 QXmlSimpleReader reader; 52 QXmlSimpleReader reader;
47 reader.setContentHandler(&h); 53 reader.setContentHandler(&h);
48 reader.setErrorHandler(&h); 54 reader.setErrorHandler(&h);
49 ok = reader.parse(source); 55 ok = reader.parse(source);
50 56
51 return ok; 57 return ok;
52} 58}
53 59
54bool DBXml::saveSource(QIODevice *outDev) 60bool DBXml::saveSource(QIODevice *outDev)
55{ 61{
56 int i; 62 int i;
57 DataElem *elem; 63 DataElem *elem;
58 KeyList *k; 64 KeyList *k;
59 65
60 QTextStream outstream(outDev); 66 QTextStream outstream(outDev);
61 67
62 outstream << "<database name=\"" << dstore->getName() << "\">" << endl; 68 outstream << "<database name=\"" << dstore->getName() << "\">" << endl;
63 outstream << "<header>" << endl; 69 outstream << "<header>" << endl;
64 70
65 k = dstore->getKeys(); 71 k = dstore->getKeys();
66 KeyListIterator it(*k); 72 KeyListIterator it(*k);
67 while(it.current()) { 73 while(it.current()) {
68 if (!it.current()->delFlag()) { 74 if (!it.current()->delFlag()) {
69 outstream << "<key name=\"KEYID" << it.currentKey() << "\" "; 75 outstream << "<key name=\"KEYID" << it.currentKey() << "\" ";
70 outstream << "type=\"" 76 outstream << "type=\""
71 << TVVariant::typeToName(it.current()->type()) 77 << TVVariant::typeToName(it.current()->type())
72 << "\">"; 78 << "\">";
73 outstream << encodeAttr(it.current()->name()) << "</key>" << endl; 79 outstream << encodeAttr(it.current()->name()) << "</key>" << endl;
74 } 80 }
@@ -95,203 +101,203 @@ bool DBXml::saveSource(QIODevice *outDev)
95 outstream << date.day() << "/" 101 outstream << date.day() << "/"
96 << date.month() << "/" 102 << date.month() << "/"
97 << date.year(); 103 << date.year();
98 } else { 104 } else {
99 outstream << encodeAttr(elem->toQString(i)); 105 outstream << encodeAttr(elem->toQString(i));
100 } 106 }
101 outstream << "</KEYID" << i << ">" << endl; 107 outstream << "</KEYID" << i << ">" << endl;
102 } 108 }
103 ++it; 109 ++it;
104 } 110 }
105 outstream << "</record>" << endl; 111 outstream << "</record>" << endl;
106 } while(dstore->next()); 112 } while(dstore->next());
107 113
108 outstream << "</database>" << endl; 114 outstream << "</database>" << endl;
109 return TRUE; 115 return TRUE;
110} 116}
111 117
112DBXml::~DBXml() {} 118DBXml::~DBXml() {}
113 119
114/*! 120/*!
115 \class DBXmlHandler 121 \class DBXmlHandler
116 \brief An Xml parser for flat tables. 122 \brief An Xml parser for flat tables.
117 123
118 An xml parser for parsing the files used by the table viewer application. 124 An xml parser for parsing the files used by the table viewer application.
119 125
120 The format of the xml files can be found at the front of the file 126 The format of the xml files can be found at the front of the file
121 dataparser.h 127 dataparser.h
122*/ 128*/
123 129
124/*! 130/*!
125 Constructs a new DBXmlHandler, and sets that the table should be 131 Constructs a new DBXmlHandler, and sets that the table should be
126 constructed in the DBStore pointed to by ds. 132 constructed in the DBStore pointed to by ds.
127*/ 133*/
128DBXmlHandler::DBXmlHandler(DBStore *ds) 134DBXmlHandler::DBXmlHandler(DBStore *ds)
129{ 135{
130 data_store = ds; 136 data_store = ds;
131 current_keyrep = 0; 137 current_keyrep = 0;
132} 138}
133 139
134/*! 140/*!
135 Destroys the DBXmlHandler 141 Destroys the DBXmlHandler
136*/ 142*/
137DBXmlHandler::~DBXmlHandler() 143DBXmlHandler::~DBXmlHandler()
138{ 144{
139} 145}
140 146
141QString DBXmlHandler::errorProtocol() 147QString DBXmlHandler::errorProtocol()
142{ 148{
143 qWarning("Error reading file"); 149 owarn << "Error reading file" << oendl;
144 return errorProt; 150 return errorProt;
145} 151}
146 152
147bool DBXmlHandler::startDocument() 153bool DBXmlHandler::startDocument()
148{ 154{
149 errorProt = ""; 155 errorProt = "";
150 state = StateInit; 156 state = StateInit;
151 return TRUE; 157 return TRUE;
152} 158}
153 159
154bool DBXmlHandler::startElement(const QString&, const QString&, 160bool DBXmlHandler::startElement(const QString&, const QString&,
155 const QString& qName, const QXmlAttributes& atts) 161 const QString& qName, const QXmlAttributes& atts)
156{ 162{
157 if (state == StateInit && qName == "database") { 163 if (state == StateInit && qName == "database") {
158 // First thing it expects is a <document name="..."> tag 164 // First thing it expects is a <document name="..."> tag
159 state = StateDocument; 165 state = StateDocument;
160 data_store->setName(atts.value("name")); 166 data_store->setName(atts.value("name"));
161 return TRUE; 167 return TRUE;
162 } 168 }
163 if (state == StateDocument && qName == "header") { 169 if (state == StateDocument && qName == "header") {
164 state = StateHeader; 170 state = StateHeader;
165 if (current_keyrep) delete current_keyrep; 171 if (current_keyrep) delete current_keyrep;
166 current_keyrep = new KeyList(); 172 current_keyrep = new KeyList();
167 return TRUE; 173 return TRUE;
168 } 174 }
169 if (state == StateHeader && qName == "key") { 175 if (state == StateHeader && qName == "key") {
170 /* Ok, adding a new key to our KeyList TODO */ 176 /* Ok, adding a new key to our KeyList TODO */
171 state = StateKey; 177 state = StateKey;
172 last_key_type = TVVariant::String; 178 last_key_type = TVVariant::String;
173 key = atts.value("name"); 179 key = atts.value("name");
174 if (key.isEmpty()) { 180 if (key.isEmpty()) {
175 qWarning("empty key name"); 181 owarn << "empty key name" << oendl;
176 return FALSE; 182 return FALSE;
177 } 183 }
178 if(!atts.value("type").isEmpty()) 184 if(!atts.value("type").isEmpty())
179 last_key_type = TVVariant::nameToType(atts.value("type")); 185 last_key_type = TVVariant::nameToType(atts.value("type"));
180 return TRUE; 186 return TRUE;
181 } 187 }
182 if (state == StateDocument && qName == "record") { 188 if (state == StateDocument && qName == "record") {
183 state = StateRecord; 189 state = StateRecord;
184 current_data = new DataElem(data_store); 190 current_data = new DataElem(data_store);
185 // Now expecting a <record> tag 191 // Now expecting a <record> tag
186 return TRUE; 192 return TRUE;
187 } 193 }
188 if (state == StateRecord) { 194 if (state == StateRecord) {
189 state = StateField; 195 state = StateField;
190 /* the qName is the name of a key */ 196 /* the qName is the name of a key */
191 if (!keyIndexList[qName]) { 197 if (!keyIndexList[qName]) {
192 /* invalid key, we failed */ 198 /* invalid key, we failed */
193 qWarning("Invalid key in record"); 199 owarn << "Invalid key in record" << oendl;
194 return FALSE; 200 return FALSE;
195 } 201 }
196 keyIndex = *keyIndexList[qName]; 202 keyIndex = *keyIndexList[qName];
197 return TRUE; 203 return TRUE;
198 } 204 }
199 qWarning("Unable to determine tag type"); 205 owarn << "Unable to determine tag type" << oendl;
200 return FALSE; 206 return FALSE;
201} 207}
202 208
203bool DBXmlHandler::endElement(const QString&, const QString&, 209bool DBXmlHandler::endElement(const QString&, const QString&,
204 const QString& qName) 210 const QString& qName)
205{ 211{
206 switch(state) { 212 switch(state) {
207 case StateField: 213 case StateField:
208 // TODO checks 'could' be done of the popped value 214 // TODO checks 'could' be done of the popped value
209 state = StateRecord; 215 state = StateRecord;
210 break; 216 break;
211 case StateKey: 217 case StateKey:
212 // TODO checks 'could' be done of the popped value 218 // TODO checks 'could' be done of the popped value
213 state = StateHeader; 219 state = StateHeader;
214 break; 220 break;
215 case StateHeader: 221 case StateHeader:
216 data_store->setKeys(current_keyrep); 222 data_store->setKeys(current_keyrep);
217 state = StateDocument; 223 state = StateDocument;
218 break; 224 break;
219 case StateRecord: 225 case StateRecord:
220 data_store->addItem(current_data); 226 data_store->addItem(current_data);
221 state = StateDocument; 227 state = StateDocument;
222 break; 228 break;
223 case StateDocument: 229 case StateDocument:
224 // we are done... 230 // we are done...
225 break; 231 break;
226 default: 232 default:
227 // should only get a 'endElement' from one of the above states. 233 // should only get a 'endElement' from one of the above states.
228 qWarning("Invalid end tag"); 234 owarn << "Invalid end tag" << oendl;
229 return FALSE; 235 return FALSE;
230 break; 236 break;
231 } 237 }
232 return TRUE; 238 return TRUE;
233} 239}
234 240
235bool DBXmlHandler::characters(const QString& ch) 241bool DBXmlHandler::characters(const QString& ch)
236{ 242{
237 // this is where the 'between tag' stuff happens. 243 // this is where the 'between tag' stuff happens.
238 // e.g. the stuff between tags. 244 // e.g. the stuff between tags.
239 QString ch_simplified = ch.simplifyWhiteSpace(); 245 QString ch_simplified = ch.simplifyWhiteSpace();
240 246
241 if (ch_simplified.isEmpty()) 247 if (ch_simplified.isEmpty())
242 return TRUE; 248 return TRUE;
243 249
244 if (state == StateKey) { 250 if (state == StateKey) {
245 int *tmp_val = new int; 251 int *tmp_val = new int;
246 /* We just grabbed the display name of a key */ 252 /* We just grabbed the display name of a key */
247 *tmp_val = current_keyrep->addKey(ch_simplified, last_key_type); 253 *tmp_val = current_keyrep->addKey(ch_simplified, last_key_type);
248 keyIndexList.insert(key, tmp_val); 254 keyIndexList.insert(key, tmp_val);
249 return TRUE; 255 return TRUE;
250 } 256 }
251 if (state == StateField) { 257 if (state == StateField) {
252 /* Ok, need to add data here */ 258 /* Ok, need to add data here */
253 current_data->setField(keyIndex, ch_simplified); 259 current_data->setField(keyIndex, ch_simplified);
254 return TRUE; 260 return TRUE;
255 } 261 }
256 262
257 qWarning("Junk characters found... ignored"); 263 owarn << "Junk characters found... ignored" << oendl;
258 return TRUE; 264 return TRUE;
259} 265}
260 266
261QString DBXmlHandler::errorString() 267QString DBXmlHandler::errorString()
262{ 268{
263 return "the document is not in the expected file format"; 269 return "the document is not in the expected file format";
264} 270}
265 271
266bool DBXmlHandler::warning(const QXmlParseException& exception) 272bool DBXmlHandler::warning(const QXmlParseException& exception)
267{ 273{
268 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" ) 274 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" )
269 .arg(exception.message()) 275 .arg(exception.message())
270 .arg(exception.lineNumber()) 276 .arg(exception.lineNumber())
271 .arg(exception.columnNumber()); 277 .arg(exception.columnNumber());
272 278
273 qWarning(errorProt); 279 owarn << errorProt << oendl;
274 return QXmlDefaultHandler::fatalError(exception); 280 return QXmlDefaultHandler::fatalError(exception);
275} 281}
276 282
277bool DBXmlHandler::error(const QXmlParseException& exception) 283bool DBXmlHandler::error(const QXmlParseException& exception)
278{ 284{
279 errorProt += QString("error parsing error: %1 in line %2, column %3\n" ) 285 errorProt += QString("error parsing error: %1 in line %2, column %3\n" )
280 .arg(exception.message()) 286 .arg(exception.message())
281 .arg(exception.lineNumber()) 287 .arg(exception.lineNumber())
282 .arg(exception.columnNumber()); 288 .arg(exception.columnNumber());
283 289
284 qWarning(errorProt); 290 owarn << errorProt << oendl;
285 return QXmlDefaultHandler::fatalError(exception); 291 return QXmlDefaultHandler::fatalError(exception);
286} 292}
287 293
288bool DBXmlHandler::fatalError(const QXmlParseException& exception) 294bool DBXmlHandler::fatalError(const QXmlParseException& exception)
289{ 295{
290 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" ) 296 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" )
291 .arg(exception.message()) 297 .arg(exception.message())
292 .arg(exception.lineNumber()) 298 .arg(exception.lineNumber())
293 .arg(exception.columnNumber()); 299 .arg(exception.columnNumber());
294 300
295 qWarning(errorProt); 301 owarn << errorProt << oendl;
296 return QXmlDefaultHandler::fatalError(exception); 302 return QXmlDefaultHandler::fatalError(exception);
297} 303}
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp
index 102b94c..9538cb3 100644
--- a/noncore/apps/tableviewer/tableviewer.cpp
+++ b/noncore/apps/tableviewer/tableviewer.cpp
@@ -1,89 +1,91 @@
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 */
22#include "tableviewer.h" 21#include "tableviewer.h"
23#include "ui/tvbrowseview.h" 22#include "ui/tvbrowseview.h"
24#include "ui/tvfilterview.h" 23#include "ui/tvfilterview.h"
25#include "ui/tvlistview.h" 24#include "ui/tvlistview.h"
26#include "ui/tveditview.h" 25#include "ui/tveditview.h"
27#include "ui/tvkeyedit.h" 26#include "ui/tvkeyedit.h"
28#include "db/datacache.h" 27#include "db/datacache.h"
29 28
30/* QPE includes */ 29/* OPIE */
30#include <opie2/odebug.h>
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qtoolbar.h> 33using namespace Opie::Core;
34 34
35/* QTE includes */ 35/* QT */
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qtoolbar.h>
37#include <qpopupmenu.h> 38#include <qpopupmenu.h>
38#include <qapplication.h> 39#include <qapplication.h>
39#include <qwidgetstack.h> 40#include <qwidgetstack.h>
40#include <qlayout.h> 41#include <qlayout.h>
41#include <qbuffer.h> 42#include <qbuffer.h>
43
42/*! 44/*!
43 \class TableViewerWindow 45 \class TableViewerWindow
44 \brief The main window widget of the application 46 \brief The main window widget of the application
45 47
46 This is the main widget of the table viewer application. 48 This is the main widget of the table viewer application.
47 It is the co-ordination point. 49 It is the co-ordination point.
48*/ 50*/
49 51
50/*! 52/*!
51 Constructs a new TableViewerWindow 53 Constructs a new TableViewerWindow
52*/ 54*/
53TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) 55TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f)
54 : QMainWindow(parent, name, f) 56 : QMainWindow(parent, name, f)
55{ 57{
56 setCaption(tr("Table Viewer")); 58 setCaption(tr("Table Viewer"));
57 59
58/* Build data */ 60/* Build data */
59 ds = new DBStore(); 61 ds = new DBStore();
60 doc.setType("text/x-xml-tableviewer"); 62 doc.setType("text/x-xml-tableviewer");
61 doc.setName("table"); 63 doc.setName("table");
62 64
63 dirty = FALSE; 65 dirty = FALSE;
64 ts.current_column = 0; 66 ts.current_column = 0;
65 ts.kRep = ds->getKeys(); 67 ts.kRep = ds->getKeys();
66 68
67/* build menus */ 69/* build menus */
68 menu = new QMenuBar(this, 0); 70 menu = new QMenuBar(this, 0);
69 71
70 QPopupMenu *file_menu = new QPopupMenu; 72 QPopupMenu *file_menu = new QPopupMenu;
71 file_menu->insertItem("New", this, SLOT(newDocument())); 73 file_menu->insertItem("New", this, SLOT(newDocument()));
72 74
73 file_menu->insertItem("Open", this, SLOT(selectDocument())); 75 file_menu->insertItem("Open", this, SLOT(selectDocument()));
74 file_menu->insertSeparator(); 76 file_menu->insertSeparator();
75 file_menu->insertItem("Properties"); 77 file_menu->insertItem("Properties");
76 78
77 /* later will want to set this up to clean up first via this, SLOT(quit) */ 79 /* later will want to set this up to clean up first via this, SLOT(quit) */
78 menu->insertItem("Document", file_menu); 80 menu->insertItem("Document", file_menu);
79 81
80 QPopupMenu *edit_menu = new QPopupMenu; 82 QPopupMenu *edit_menu = new QPopupMenu;
81 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); 83 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot()));
82 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); 84 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot()));
83 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); 85 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot()));
84 menu->insertItem("Edit", edit_menu); 86 menu->insertItem("Edit", edit_menu);
85 87
86 QPopupMenu *view_menu = new QPopupMenu; 88 QPopupMenu *view_menu = new QPopupMenu;
87 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); 89 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot()));
88 view_menu->insertItem("List View", this, SLOT(listViewSlot())); 90 view_menu->insertItem("List View", this, SLOT(listViewSlot()));
89 menu->insertItem("View", view_menu); 91 menu->insertItem("View", view_menu);
@@ -156,184 +158,184 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
156 fileSelector->reread(); 158 fileSelector->reread();
157 159
158 connect(browseView, SIGNAL(searchOnKey(int,TVVariant)), 160 connect(browseView, SIGNAL(searchOnKey(int,TVVariant)),
159 this, SLOT(searchOnKey(int,TVVariant))); 161 this, SLOT(searchOnKey(int,TVVariant)));
160 connect(browseView, SIGNAL(sortChanged(int)), 162 connect(browseView, SIGNAL(sortChanged(int)),
161 this, SLOT(setPrimaryKey(int))); 163 this, SLOT(setPrimaryKey(int)));
162 164
163 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); 165 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot()));
164 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), 166 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)),
165 this, SLOT(openDocument(const DocLnk&))); 167 this, SLOT(openDocument(const DocLnk&)));
166 168
167 main_layout->addWidget(menu); 169 main_layout->addWidget(menu);
168 main_layout->addWidget(cw); 170 main_layout->addWidget(cw);
169 171
170 setCentralWidget(cw); 172 setCentralWidget(cw);
171 173
172} 174}
173 175
174/*! 176/*!
175 Destroys the TableViewerWindow 177 Destroys the TableViewerWindow
176*/ 178*/
177TableViewerWindow::~TableViewerWindow() 179TableViewerWindow::~TableViewerWindow()
178{ 180{
179 if(dirty) 181 if(dirty)
180 saveDocument(); 182 saveDocument();
181} 183}
182 184
183/*! 185/*!
184 Opens a file dialog and loads the file specified by the dialog 186 Opens a file dialog and loads the file specified by the dialog
185*/ 187*/
186void TableViewerWindow::selectDocument() 188void TableViewerWindow::selectDocument()
187{ 189{
188 if(dirty) 190 if(dirty)
189 saveDocument(); 191 saveDocument();
190 current_view = FileState; 192 current_view = FileState;
191 cw->raiseWidget(current_view); 193 cw->raiseWidget(current_view);
192 fileSelector->reread(); 194 fileSelector->reread();
193} 195}
194 196
195void TableViewerWindow::saveDocument() 197void TableViewerWindow::saveDocument()
196{ 198{
197 if(!dirty) 199 if(!dirty)
198 return; 200 return;
199 201
200 FileManager fm; 202 FileManager fm;
201 QIODevice *dev = fm.saveFile(doc); 203 QIODevice *dev = fm.saveFile(doc);
202 204
203 if(!ds->saveSource(dev, doc.type())){ 205 if(!ds->saveSource(dev, doc.type())){
204 qWarning("Save unsuccessful"); 206 owarn << "Save unsuccessful" << oendl;
205 return; 207 return;
206 } 208 }
207 dev->close(); 209 dev->close();
208 dirty = FALSE; 210 dirty = FALSE;
209} 211}
210 212
211void TableViewerWindow::newDocument() 213void TableViewerWindow::newDocument()
212{ 214{
213 DocLnk nf; 215 DocLnk nf;
214 nf.setType("text/x-xml-tableviewer"); 216 nf.setType("text/x-xml-tableviewer");
215 nf.setName("table"); 217 nf.setName("table");
216 218
217 delete ds; 219 delete ds;
218 ds = new DBStore(); 220 ds = new DBStore();
219 221
220 ts.current_column = 0; 222 ts.current_column = 0;
221 ts.kRep = ds->getKeys(); 223 ts.kRep = ds->getKeys();
222 browseView->reset(); 224 browseView->reset();
223 listView->reset(); 225 listView->reset();
224 filterView->reset(); 226 filterView->reset();
225 227
226 doc = nf; 228 doc = nf;
227 dirty = FALSE; 229 dirty = FALSE;
228 230
229 current_view = BrowseState; 231 current_view = BrowseState;
230 cw->raiseWidget(current_view); 232 cw->raiseWidget(current_view);
231 233
232 /* now set up for editing the keys */ 234 /* now set up for editing the keys */
233 ts.kRep->addKey("key", TVVariant::String); 235 ts.kRep->addKey("key", TVVariant::String);
234 editKeysSlot(); 236 editKeysSlot();
235} 237}
236 238
237void TableViewerWindow::setDocument(const QString &f) 239void TableViewerWindow::setDocument(const QString &f)
238{ 240{
239 openDocument(DocLnk(f, TRUE)); 241 openDocument(DocLnk(f, TRUE));
240} 242}
241 243
242void TableViewerWindow::openDocument(const DocLnk &f) 244void TableViewerWindow::openDocument(const DocLnk &f)
243{ 245{
244 246
245 if (!f.isValid()) 247 if (!f.isValid())
246 return; 248 return;
247 249
248 FileManager fm; 250 FileManager fm;
249 QIODevice *dev = fm.openFile(f); 251 QIODevice *dev = fm.openFile(f);
250 doc = f; 252 doc = f;
251 253
252 if(ds->openSource(dev, doc.type())) { 254 if(ds->openSource(dev, doc.type())) {
253 DataElem *d; 255 DataElem *d;
254 256
255 browseView->reset(); 257 browseView->reset();
256 listView->reset(); 258 listView->reset();
257 filterView->reset(); 259 filterView->reset();
258 260
259 current_view = BrowseState; 261 current_view = BrowseState;
260 cw->raiseWidget(current_view); 262 cw->raiseWidget(current_view);
261 263
262 /* set up new table state and ensure sub widgets have a reference */ 264 /* set up new table state and ensure sub widgets have a reference */
263 ts.current_column = 0; 265 ts.current_column = 0;
264 ts.kRep = ds->getKeys(); 266 ts.kRep = ds->getKeys();
265 browseView->rebuildKeys(); 267 browseView->rebuildKeys();
266 listView->rebuildKeys(); 268 listView->rebuildKeys();
267 filterView->rebuildKeys(); 269 filterView->rebuildKeys();
268 270
269 ds->first(); 271 ds->first();
270 /* set up the list view */ 272 /* set up the list view */
271 listView->clearItems(); 273 listView->clearItems();
272 do { 274 do {
273 d = ds->getCurrentData(); 275 d = ds->getCurrentData();
274 if(d) 276 if(d)
275 listView->addItem(d); 277 listView->addItem(d);
276 } while(ds->next()); 278 } while(ds->next());
277 279
278 /* Set up browse view, Will be based of structure of listView */ 280 /* Set up browse view, Will be based of structure of listView */
279 listView->first(); 281 listView->first();
280 ts.current_elem = listView->getCurrentData(); 282 ts.current_elem = listView->getCurrentData();
281 browseView->rebuildData(); 283 browseView->rebuildData();
282 listView->rebuildData(); 284 listView->rebuildData();
283 285
284 QString scratch = "Table Viewer";/* later take from constant */ 286 QString scratch = "Table Viewer";/* later take from constant */
285 scratch += " - "; 287 scratch += " - ";
286 scratch += ds->getName(); 288 scratch += ds->getName();
287 setCaption(tr(scratch)); 289 setCaption(tr(scratch));
288 290
289 dirty = FALSE; 291 dirty = FALSE;
290 } else { 292 } else {
291 qWarning(tr("could not load Document")); 293 owarn << tr("could not load Document") << oendl;
292 } 294 }
293 dev->close(); 295 dev->close();
294} 296}
295 297
296/*! 298/*!
297 Moves to the first item of the current table 299 Moves to the first item of the current table
298*/ 300*/
299void TableViewerWindow::firstItem() 301void TableViewerWindow::firstItem()
300{ 302{
301 listView->first(); 303 listView->first();
302 ts.current_elem = listView->getCurrentData(); 304 ts.current_elem = listView->getCurrentData();
303 browseView->rebuildData(); 305 browseView->rebuildData();
304} 306}
305 307
306/*! 308/*!
307 Moves to the lat item of the current table 309 Moves to the lat item of the current table
308*/ 310*/
309void TableViewerWindow::lastItem() 311void TableViewerWindow::lastItem()
310{ 312{
311 listView->last(); 313 listView->last();
312 ts.current_elem = listView->getCurrentData(); 314 ts.current_elem = listView->getCurrentData();
313 browseView->rebuildData(); 315 browseView->rebuildData();
314} 316}
315 317
316/*! 318/*!
317 Moves to the next item of the current table 319 Moves to the next item of the current table
318*/ 320*/
319void TableViewerWindow::nextItem() 321void TableViewerWindow::nextItem()
320{ 322{
321 listView->next(); 323 listView->next();
322 ts.current_elem = listView->getCurrentData(); 324 ts.current_elem = listView->getCurrentData();
323 browseView->rebuildData(); 325 browseView->rebuildData();
324} 326}
325 327
326/*! 328/*!
327 Moves to the previous item of the current table 329 Moves to the previous item of the current table
328*/ 330*/
329void TableViewerWindow::previousItem() 331void TableViewerWindow::previousItem()
330{ 332{
331 listView->previous(); 333 listView->previous();
332 ts.current_elem = listView->getCurrentData(); 334 ts.current_elem = listView->getCurrentData();
333 browseView->rebuildData(); 335 browseView->rebuildData();
334} 336}
335 337
336/*! 338/*!
337 Raises the List View. This is a mode change for the application. 339 Raises the List View. This is a mode change for the application.
338*/ 340*/
339void TableViewerWindow::listViewSlot() 341void TableViewerWindow::listViewSlot()
diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro
index 1de23bb..564f50f 100644
--- a/noncore/apps/tableviewer/tableviewer.pro
+++ b/noncore/apps/tableviewer/tableviewer.pro
@@ -1,38 +1,38 @@
1 CONFIG = qt warn_on quick-app 1 CONFIG = qt warn_on quick-app
2 SUBDIRS = db ui 2 SUBDIRS = db ui
3 HEADERS = tableviewer.h \ 3 HEADERS = tableviewer.h \
4 xmlencodeattr.h \ 4 xmlencodeattr.h \
5 ui/commonwidgets.h \ 5 ui/commonwidgets.h \
6 ui/tvbrowseview.h \ 6 ui/tvbrowseview.h \
7 ui/tvlistview.h \ 7 ui/tvlistview.h \
8 ui/tvfilterview.h \ 8 ui/tvfilterview.h \
9 ui/tveditview.h \ 9 ui/tveditview.h \
10 ui/browsekeyentry.h \ 10 ui/browsekeyentry.h \
11 ui/filterkeyentry.h \ 11 ui/filterkeyentry.h \
12 ui/tvkeyedit.h \ 12 ui/tvkeyedit.h \
13 db/datacache.h \ 13 db/datacache.h \
14 db/common.h \ 14 db/common.h \
15 db/xmlsource.h \ 15 db/xmlsource.h \
16 db/csvsource.h 16 db/csvsource.h
17 SOURCES = main.cpp \ 17 SOURCES = main.cpp \
18 tableviewer.cpp \ 18 tableviewer.cpp \
19 xmlencodeattr.cpp \ 19 xmlencodeattr.cpp \
20 ui/commonwidgets.cpp \ 20 ui/commonwidgets.cpp \
21 ui/tvbrowseview.cpp \ 21 ui/tvbrowseview.cpp \
22 ui/tvfilterview.cpp \ 22 ui/tvfilterview.cpp \
23 ui/browsekeyentry.cpp \ 23 ui/browsekeyentry.cpp \
24 ui/filterkeyentry.cpp \ 24 ui/filterkeyentry.cpp \
25 ui/tvlistview.cpp \ 25 ui/tvlistview.cpp \
26 ui/tveditview.cpp \ 26 ui/tveditview.cpp \
27 ui/tvkeyedit.cpp \ 27 ui/tvkeyedit.cpp \
28 db/datacache.cpp \ 28 db/datacache.cpp \
29 db/xmlsource.cpp \ 29 db/xmlsource.cpp \
30 db/csvsource.cpp \ 30 db/csvsource.cpp \
31 db/common.cpp 31 db/common.cpp
32 INTERFACES= ui/tvkeyedit_gen.ui 32 INTERFACES= ui/tvkeyedit_gen.ui
33 TARGET = tableviewer 33 TARGET = tableviewer
34INCLUDEPATH += $(OPIEDIR)/include 34 INCLUDEPATH+= $(OPIEDIR)/include
35DEPENDPATH += $(OPIEDIR)/include 35 DEPENDPATH+= $(OPIEDIR)/include
36 LIBS += -lqpe -lopiecore2 36 LIBS += -lqpe -lopiecore2
37 37
38include ( $(OPIEDIR)/include.pro ) 38include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp
index b10ff1d..c3e6432 100644
--- a/noncore/apps/tableviewer/ui/tvlistview.cpp
+++ b/noncore/apps/tableviewer/ui/tvlistview.cpp
@@ -1,69 +1,76 @@
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#include "tvlistview.h" 21#include "tvlistview.h"
21#include "../db/common.h" 22#include "../db/common.h"
23
24/* OPIE */
25#include <opie2/odebug.h>
26using namespace Opie::Core;
27
28/* QT */
22#include <qtoolbutton.h> 29#include <qtoolbutton.h>
23#include <qlistview.h> 30#include <qlistview.h>
24#include <qlayout.h> 31#include <qlayout.h>
25 32
26void TVListViewPrivate::setColumnWidth(int column, int width) 33void TVListViewPrivate::setColumnWidth(int column, int width)
27{ 34{
28 if(width > 70) width = 70; 35 if(width > 70) width = 70;
29 QListView::setColumnWidth(column, width); 36 QListView::setColumnWidth(column, width);
30} 37}
31 38
32void TVListViewPrivate::setSorting(int column, bool increasing) 39void TVListViewPrivate::setSorting(int column, bool increasing)
33{ 40{
34 emit sortChanged(column); 41 emit sortChanged(column);
35 QListView::setSorting(column, increasing); 42 QListView::setSorting(column, increasing);
36} 43}
37 44
38TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name, 45TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name,
39 WFlags fl) : QListView(parent, name, fl) { 46 WFlags fl) : QListView(parent, name, fl) {
40 ; 47 ;
41} 48}
42 49
43class TVListViewItem : public QListViewItem 50class TVListViewItem : public QListViewItem
44{ 51{
45public: 52public:
46 53
47 TVListViewItem(QListView *parent, DataElem *d); 54 TVListViewItem(QListView *parent, DataElem *d);
48 ~TVListViewItem(); 55 ~TVListViewItem();
49 56
50 QString text(int i) const 57 QString text(int i) const
51 { 58 {
52 return data_reference->toQString(i); 59 return data_reference->toQString(i);
53 } 60 }
54 61
55 /* Do nothing... all data for this item should be generated */ 62 /* Do nothing... all data for this item should be generated */
56 void setText(int i, const QString &) 63 void setText(int i, const QString &)
57 { 64 {
58 ; 65 ;
59 } 66 }
60 QString key(int i, bool a) const 67 QString key(int i, bool a) const
61 { 68 {
62 return data_reference->toSortableQString(i); 69 return data_reference->toSortableQString(i);
63 } 70 }
64 71
65 void setDataElem(DataElem *d) 72 void setDataElem(DataElem *d)
66 { 73 {
67 data_reference = d; 74 data_reference = d;
68 } 75 }
69 76
@@ -118,97 +125,97 @@ TVListView::TVListView(TableState *t, QWidget* parent,
118TVListView::~TVListView() 125TVListView::~TVListView()
119{ 126{
120} 127}
121 128
122void TVListView::addItem(DataElem *d) 129void TVListView::addItem(DataElem *d)
123{ 130{
124 TVListViewItem *i = new TVListViewItem(listViewDisplay, d); 131 TVListViewItem *i = new TVListViewItem(listViewDisplay, d);
125 132
126 delete it; 133 delete it;
127 it = new QListViewItemIterator(i); 134 it = new QListViewItemIterator(i);
128} 135}
129 136
130/* remove current (it) item */ 137/* remove current (it) item */
131void TVListView::removeItem() 138void TVListView::removeItem()
132{ 139{
133 QListViewItemIterator other(*it); 140 QListViewItemIterator other(*it);
134 141
135 QListViewItemIterator tmp = *it; 142 QListViewItemIterator tmp = *it;
136 (*it)++; 143 (*it)++;
137 if (!it->current()) { 144 if (!it->current()) {
138 *it = tmp; 145 *it = tmp;
139 (*it)--; 146 (*it)--;
140 if (!it->current()) { 147 if (!it->current()) {
141 delete it; 148 delete it;
142 it = 0; 149 it = 0;
143 } 150 }
144 } 151 }
145 152
146 delete other.current(); 153 delete other.current();
147} 154}
148 155
149void TVListView::clearItems() 156void TVListView::clearItems()
150{ 157{
151 /* This is ok since the destructor for TVListItem does not know about 158 /* This is ok since the destructor for TVListItem does not know about
152 the data_reference pointer.. and hence will leave it alone */ 159 the data_reference pointer.. and hence will leave it alone */
153 listViewDisplay->clear(); 160 listViewDisplay->clear();
154 delete it; 161 delete it;
155 it = new QListViewItemIterator(listViewDisplay); 162 it = new QListViewItemIterator(listViewDisplay);
156} 163}
157 164
158void TVListView::first() 165void TVListView::first()
159{ 166{
160 delete it; 167 delete it;
161 it = new QListViewItemIterator(listViewDisplay); 168 it = new QListViewItemIterator(listViewDisplay);
162} 169}
163 170
164void TVListView::last() 171void TVListView::last()
165{ 172{
166 qWarning("TVListView::last not yet implemented"); 173 owarn << "TVListView::last not yet implemented" << oendl;
167} 174}
168 175
169void TVListView::next() 176void TVListView::next()
170{ 177{
171 QListViewItemIterator tmp = *it; 178 QListViewItemIterator tmp = *it;
172 (*it)++; 179 (*it)++;
173 if (!it->current()) { 180 if (!it->current()) {
174 *it = tmp; 181 *it = tmp;
175 } 182 }
176} 183}
177 184
178void TVListView::previous() 185void TVListView::previous()
179{ 186{
180 QListViewItemIterator tmp = *it; 187 QListViewItemIterator tmp = *it;
181 (*it)--; 188 (*it)--;
182 if (!it->current()) { 189 if (!it->current()) {
183 *it = tmp; 190 *it = tmp;
184 } 191 }
185} 192}
186 193
187DataElem *TVListView::getCurrentData() { 194DataElem *TVListView::getCurrentData() {
188 if (it->current()) { 195 if (it->current()) {
189 return ((TVListViewItem *)it->current())->getDataElem(); 196 return ((TVListViewItem *)it->current())->getDataElem();
190 } 197 }
191 return NULL; 198 return NULL;
192} 199}
193 200
194/*! Now to implement the closest match function */ 201/*! Now to implement the closest match function */
195void TVListView::findItem(int keyId, TVVariant value) 202void TVListView::findItem(int keyId, TVVariant value)
196{ 203{
197 QListViewItem *i; 204 QListViewItem *i;
198 TVListViewItem *best_so_far = NULL; 205 TVListViewItem *best_so_far = NULL;
199 /* start at the beginning... go through till find the closest elem */ 206 /* start at the beginning... go through till find the closest elem */
200 i = listViewDisplay->firstChild(); 207 i = listViewDisplay->firstChild();
201 while (i) { 208 while (i) {
202 /* search stuff */ 209 /* search stuff */
203 if(best_so_far) { 210 if(best_so_far) {
204 if (DataElem::closer( 211 if (DataElem::closer(
205 ((TVListViewItem *)i)->getDataElem(), 212 ((TVListViewItem *)i)->getDataElem(),
206 best_so_far->getDataElem(), value, keyId)) 213 best_so_far->getDataElem(), value, keyId))
207 best_so_far = (TVListViewItem *)i; 214 best_so_far = (TVListViewItem *)i;
208 } else { 215 } else {
209 if (DataElem::closer( 216 if (DataElem::closer(
210 ((TVListViewItem *)i)->getDataElem(), 217 ((TVListViewItem *)i)->getDataElem(),
211 NULL, value, keyId)) 218 NULL, value, keyId))
212 best_so_far = (TVListViewItem *)i; 219 best_so_far = (TVListViewItem *)i;
213 } 220 }
214 221
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro
index 11ee275..1552dff 100644
--- a/noncore/apps/tinykate/libkate/libkate.pro
+++ b/noncore/apps/tinykate/libkate/libkate.pro
@@ -1,90 +1,87 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG = qt warn_on 2CONFIG = qt warn_on
3HEADERS = microkde/kapplication.h \ 3HEADERS = microkde/kapplication.h \
4 kateconfig.h \ 4 kateconfig.h \
5 microkde/kdebug.h \ 5 microkde/kdebug.h \
6 microkde/kdialog.h \ 6 microkde/kdialog.h \
7 microkde/kdialogbase.h \ 7 microkde/kdialogbase.h \
8 microkde/kfiledialog.h \ 8 microkde/kfiledialog.h \
9 microkde/kglobal.h \ 9 microkde/kglobal.h \
10 microkde/kiconloader.h \ 10 microkde/kiconloader.h \
11 microkde/klineedit.h \ 11 microkde/klineedit.h \
12 microkde/klocale.h \ 12 microkde/klocale.h \
13 microkde/kmessagebox.h \ 13 microkde/kmessagebox.h \
14 microkde/kprinter.h \ 14 microkde/kprinter.h \
15 microkde/krestrictedline.h \ 15 microkde/krestrictedline.h \
16 microkde/kseparator.h \ 16 microkde/kseparator.h \
17 microkde/kstandarddirs.h \ 17 microkde/kstandarddirs.h \
18 microkde/ktempfile.h \ 18 microkde/ktempfile.h \
19 microkde/kunload.h \ 19 microkde/kunload.h \
20 microkde/kurlrequester.h \ 20 microkde/kurlrequester.h \
21 microkde/kfontdialog.h \ 21 microkde/kfontdialog.h \
22 microkde/krun.h \ 22 microkde/krun.h \
23 microkde/knumvalidator.h \ 23 microkde/knumvalidator.h \
24 microkde/kstaticdeleter.h \ 24 microkde/kstaticdeleter.h \
25 microkde/klistview.h \ 25 microkde/klistview.h \
26 microkde/kglobalsettings.h \ 26 microkde/kglobalsettings.h \
27 microkde/kcolorbtn.h \ 27 microkde/kcolorbtn.h \
28 \
29 \ 28 \
30 qt3back/qregexp3.h \ 29 qt3back/qregexp3.h \
31 microkde/ksharedptr.h \ 30 microkde/ksharedptr.h \
32 document/katebuffer.h document/katedialogs.h \ 31 document/katebuffer.h document/katedialogs.h \
33 document/katetextline.h \ 32 document/katetextline.h \
34 document/katecmd.h \ 33 document/katecmd.h \
35 document/katehighlight.h \ 34 document/katehighlight.h \
36 document/katecmds.h document/katedocument.h \ 35 document/katecmds.h document/katedocument.h \
37 document/katesyntaxdocument.h \ 36 document/katesyntaxdocument.h \
38 view/kateundohistory.h \ 37 view/kateundohistory.h \
39 view/kateview.h \ 38 view/kateview.h \
40 view/kateviewdialog.h \ 39 view/kateviewdialog.h \
41 interfaces/view.h \ 40 interfaces/view.h \
42 interfaces/document.h \ 41 interfaces/document.h \
43 ktexteditor/ktexteditor.h 42 ktexteditor/ktexteditor.h
44 43
45SOURCES = microkde/kapplication.cpp \ 44SOURCES = microkde/kapplication.cpp \
46 microkde/kdialogbase.cpp \ 45 microkde/kdialogbase.cpp \
47 kateconfig.cpp \ 46 kateconfig.cpp \
48 microkde/klocale.cpp \ 47 microkde/klocale.cpp \
49 microkde/kmessagebox.cpp \ 48 microkde/kmessagebox.cpp \
50 microkde/kprocess.cpp \ 49 microkde/kprocess.cpp \
51 microkde/kstandarddirs.cpp \ 50 microkde/kstandarddirs.cpp \
52 microkde/ktempfile.cpp \ 51 microkde/ktempfile.cpp \
53 microkde/kurlrequester.cpp \ 52 microkde/kurlrequester.cpp \
54 microkde/kfontdialog.cpp \ 53 microkde/kfontdialog.cpp \
55 microkde/krun.cpp \ 54 microkde/krun.cpp \
56 microkde/knumvalidator.cpp \ 55 microkde/knumvalidator.cpp \
57 microkde/kglobal.cpp \ 56 microkde/kglobal.cpp \
58 microkde/kglobalsettings.cpp \ 57 microkde/kglobalsettings.cpp \
59 microkde/kcolorbtn.cpp \ 58 microkde/kcolorbtn.cpp \
60 \ 59 \
61 \ 60 qt3back/qregexp3.cpp \
62 qt3back/qregexp3.cpp \ 61 ktexteditor/ktexteditor.cpp \
63 ktexteditor/ktexteditor.cpp \ 62 document/katebuffer.cpp document/katedialogs.cpp \
64 document/katebuffer.cpp document/katedialogs.cpp \ 63 document/katehighlight.cpp \
65 document/katehighlight.cpp \ 64 document/katecmd.cpp \
66 document/katecmd.cpp \ 65 document/katesyntaxdocument.cpp document/katecmds.cpp \
67 document/katesyntaxdocument.cpp document/katecmds.cpp \ 66 document/katedocument.cpp document/katetextline.cpp \
68 document/katedocument.cpp document/katetextline.cpp \ 67 view/kateundohistory.cpp \
69 view/kateundohistory.cpp \ 68 view/kateview.cpp \
70 view/kateview.cpp \ 69 view/kateviewdialog.cpp \
71 view/kateviewdialog.cpp \ 70 interfaces/interfaces.cpp
72 interfaces/interfaces.cpp 71INTERFACES =
73 72INCLUDEPATH += $(OPIEDIR)/include \
74INTERFACES =
75INCLUDEPATH += $(OPIEDIR)/include \
76 $(OPIEDIR)/noncore/apps/tinykate/libkate \ 73 $(OPIEDIR)/noncore/apps/tinykate/libkate \
77 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 74 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
78 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 75 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
79 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 76 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
80 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 77 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
81 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 78 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
82 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 79 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
83DEPENDPATH += $(OPIEDIR)/include 80DEPENDPATH += $(OPIEDIR)/include
84LIBS += -lqpe -lqtaux2 -lopiecore2 -lopieui2 81LIBS += -lqpe -lqtaux2 -lopiecore2 -lopieui2
85TARGET = tinykate 82TARGET = tinykate
86 83
87INCLUDEPATH += $(OPIEDIR)/include 84INCLUDEPATH += $(OPIEDIR)/include
88DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 85DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
89 86
90include ( $(OPIEDIR)/include.pro ) 87include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro
index 6f4baa8..d34e519 100644
--- a/noncore/apps/tinykate/tinykate.pro
+++ b/noncore/apps/tinykate/tinykate.pro
@@ -1,22 +1,20 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on quick-app 2CONFIG = qt warn_on quick-app
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = tinykate.h 4HEADERS = tinykate.h
5SOURCES = tinykate.cpp main.cpp 5SOURCES = tinykate.cpp main.cpp
6INTERFACES =
7INCLUDEPATH += $(OPIEDIR)/include \ 6INCLUDEPATH += $(OPIEDIR)/include \
8 $(OPIEDIR)/noncore/apps/tinykate/libkate \ 7 $(OPIEDIR)/noncore/apps/tinykate/libkate \
9 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 8 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
10 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 9 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
11 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 10 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
12 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 11 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
13 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 12 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
14 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 13 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
15 14DEPENDPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 15LIBS += -lqpe -ltinykate -lopiecore2 -lopieui2
17LIBS += -lqpe -ltinykate -lopiecore2 -lopieui2 16TARGET = kate
18TARGET = kate
19 17
20 18
21 19
22include ( $(OPIEDIR)/include.pro ) 20include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in
index 6e321f3..b6d3ffe 100644
--- a/noncore/apps/zsafe/config.in
+++ b/noncore/apps/zsafe/config.in
@@ -1,5 +1,5 @@
1config ZSAFE 1config ZSAFE
2 boolean "zsafe (Zaurus Password Manager)" 2 boolean "zsafe (Zaurus Password Manager)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
5 5
diff --git a/noncore/apps/zsafe/scqtfiledlg.cpp b/noncore/apps/zsafe/scqtfiledlg.cpp
index 52b8d0d..c67bbd5 100644
--- a/noncore/apps/zsafe/scqtfiledlg.cpp
+++ b/noncore/apps/zsafe/scqtfiledlg.cpp
@@ -1,58 +1,55 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'scqtfiledlg.ui'
3**
4** Created: Sun Jun 8 15:51:12 2003
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "scqtfiledlg.h" 1#include "scqtfiledlg.h"
10 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
11#include <qcombobox.h> 8#include <qcombobox.h>
12#include <qlineedit.h> 9#include <qlineedit.h>
13#include <qlistview.h> 10#include <qlistview.h>
14#include <qtoolbutton.h> 11#include <qtoolbutton.h>
15#include <qlayout.h> 12#include <qlayout.h>
16#include <qtooltip.h> 13#include <qtooltip.h>
17#include <qwhatsthis.h> 14#include <qwhatsthis.h>
18 15
19static const char* const image0_data[] = { 16static const char* const image0_data[] = {
20"24 16 3 1", 17"24 16 3 1",
21". c None", 18". c None",
22"# c #000040", 19"# c #000040",
23"a c #808080", 20"a c #808080",
24"........................", 21"........................",
25"........................", 22"........................",
26".................####...", 23".................####...",
27".................####...", 24".................####...",
28".......##........#aa#...", 25".......##........#aa#...",
29"......###........#aa#...", 26"......###........#aa#...",
30".....####........#aa#...", 27".....####........#aa#...",
31"....##############aa#...", 28"....##############aa#...",
32"...###aaaaaaaaaaaaaa#...", 29"...###aaaaaaaaaaaaaa#...",
33"..####aaaaaaaaaaaaaa#...", 30"..####aaaaaaaaaaaaaa#...",
34"...###aaaaaaaaaaaaaa#...", 31"...###aaaaaaaaaaaaaa#...",
35"....#################...", 32"....#################...",
36".....####...............", 33".....####...............",
37"......###...............", 34"......###...............",
38".......##...............", 35".......##...............",
39"........................"}; 36"........................"};
40 37
41static const char* const image1_data[] = { 38static const char* const image1_data[] = {
42"24 16 4 1", 39"24 16 4 1",
43". c None", 40". c None",
44"a c #008080", 41"a c #008080",
45"b c #808080", 42"b c #808080",
46"# c #ff0000", 43"# c #ff0000",
47"........................", 44"........................",
48"........................", 45"........................",
49"...####..........####...", 46"...####..........####...",
50"...#####........#####...", 47"...#####........#####...",
51"....######.....#####a...", 48"....######.....#####a...",
52".....######...#####ba...", 49".....######...#####ba...",
53".....aa###########bba...", 50".....aa###########bba...",
54"....aaaaa#######aabba...", 51"....aaaaa#######aabba...",
55"...aaabbb######bbbbba...", 52"...aaabbb######bbbbba...",
56"..aaaabb########bbbba...", 53"..aaaabb########bbbba...",
57"...aaa############bba...", 54"...aaa############bba...",
58"....a######aaa#####aa...", 55"....a######aaa#####aa...",
@@ -171,86 +168,86 @@ ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags
171 QWhatsThis::add( MkDirButton, tr( "OKButton" ) ); 168 QWhatsThis::add( MkDirButton, tr( "OKButton" ) );
172 Layout3_2->addWidget( MkDirButton ); 169 Layout3_2->addWidget( MkDirButton );
173 Layout4->addLayout( Layout3_2 ); 170 Layout4->addLayout( Layout3_2 );
174 171
175 DirComboBox = new QComboBox( FALSE, this, "DirComboBox" ); 172 DirComboBox = new QComboBox( FALSE, this, "DirComboBox" );
176 DirComboBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, DirComboBox->sizePolicy().hasHeightForWidth() ) ); 173 DirComboBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, DirComboBox->sizePolicy().hasHeightForWidth() ) );
177 DirComboBox->setEditable( TRUE ); 174 DirComboBox->setEditable( TRUE );
178 DirComboBox->setDuplicatesEnabled( FALSE ); 175 DirComboBox->setDuplicatesEnabled( FALSE );
179 QWhatsThis::add( DirComboBox, tr( "ComboBox Directory \n" 176 QWhatsThis::add( DirComboBox, tr( "ComboBox Directory \n"
180"edit or select the directories name" ) ); 177"edit or select the directories name" ) );
181 Layout4->addWidget( DirComboBox ); 178 Layout4->addWidget( DirComboBox );
182 Layout5->addLayout( Layout4 ); 179 Layout5->addLayout( Layout4 );
183 180
184 ListView = new QListView( this, "ListView" ); 181 ListView = new QListView( this, "ListView" );
185 ListView->addColumn( tr( "Name" ) ); 182 ListView->addColumn( tr( "Name" ) );
186 ListView->addColumn( tr( "size" ) ); 183 ListView->addColumn( tr( "size" ) );
187 ListView->addColumn( tr( "type" ) ); 184 ListView->addColumn( tr( "type" ) );
188 ListView->setRootIsDecorated( TRUE ); 185 ListView->setRootIsDecorated( TRUE );
189 QToolTip::add( ListView, tr( "directory listview" ) ); 186 QToolTip::add( ListView, tr( "directory listview" ) );
190 QWhatsThis::add( ListView, tr( "Directory ListView\n" 187 QWhatsThis::add( ListView, tr( "Directory ListView\n"
191"\n" 188"\n"
192"shows the list of dirs and files" ) ); 189"shows the list of dirs and files" ) );
193 Layout5->addWidget( ListView ); 190 Layout5->addWidget( ListView );
194 ScQtFileDlgLayout->addLayout( Layout5 ); 191 ScQtFileDlgLayout->addLayout( Layout5 );
195 192
196 // signals and slots connections 193 // signals and slots connections
197 connect( OkButton, SIGNAL( clicked() ), this, SLOT( slotOK() ) ); 194 connect( OkButton, SIGNAL( clicked() ), this, SLOT( slotOK() ) );
198 connect( DirComboBox, SIGNAL( activated(int) ), this, SLOT( slotDirComboBoxChanged(int) ) ); 195 connect( DirComboBox, SIGNAL( activated(int) ), this, SLOT( slotDirComboBoxChanged(int) ) );
199 connect( TypeComboBox, SIGNAL( activated(int) ), this, SLOT( slotTypeComboBoxChanged(int) ) ); 196 connect( TypeComboBox, SIGNAL( activated(int) ), this, SLOT( slotTypeComboBoxChanged(int) ) );
200 connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); 197 connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );
201 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) ); 198 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) );
202 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) ); 199 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) );
203 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotDoubleClicked(QListViewItem*) ) ); 200 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotDoubleClicked(QListViewItem*) ) );
204 connect( FNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileTextChanged(const QString&) ) ); 201 connect( FNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileTextChanged(const QString&) ) );
205 connect( FNameLineEdit, SIGNAL( returnPressed() ), this, SLOT( slotOK() ) ); 202 connect( FNameLineEdit, SIGNAL( returnPressed() ), this, SLOT( slotOK() ) );
206 connect( MkDirButton, SIGNAL( clicked() ), this, SLOT( slotMkDir() ) ); 203 connect( MkDirButton, SIGNAL( clicked() ), this, SLOT( slotMkDir() ) );
207} 204}
208 205
209/* 206/*
210 * Destroys the object and frees any allocated resources 207 * Destroys the object and frees any allocated resources
211 */ 208 */
212ScQtFileDlg::~ScQtFileDlg() 209ScQtFileDlg::~ScQtFileDlg()
213{ 210{
214 // no need to delete child widgets, Qt does it all for us 211 // no need to delete child widgets, Qt does it all for us
215} 212}
216 213
217void ScQtFileDlg::slotCancel() 214void ScQtFileDlg::slotCancel()
218{ 215{
219 qWarning( "ScQtFileDlg::slotCancel(): Not implemented yet!" ); 216 owarn << "ScQtFileDlg::slotCancel(): Not implemented yet!" << oendl;
220} 217}
221 218
222void ScQtFileDlg::slotDirComboBoxChanged( int ) 219void ScQtFileDlg::slotDirComboBoxChanged( int )
223{ 220{
224 qWarning( "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" ); 221 owarn << "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" << oendl;
225} 222}
226 223
227void ScQtFileDlg::slotDoubleClicked(QListViewItem *) 224void ScQtFileDlg::slotDoubleClicked(QListViewItem *)
228{ 225{
229 qWarning( "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" ); 226 owarn << "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" << oendl;
230} 227}
231 228
232void ScQtFileDlg::slotFileTextChanged( const QString & ) 229void ScQtFileDlg::slotFileTextChanged( const QString & )
233{ 230{
234 qWarning( "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" ); 231 owarn << "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" << oendl;
235} 232}
236 233
237void ScQtFileDlg::slotMkDir() 234void ScQtFileDlg::slotMkDir()
238{ 235{
239 qWarning( "ScQtFileDlg::slotMkDir(): Not implemented yet!" ); 236 owarn << "ScQtFileDlg::slotMkDir(): Not implemented yet!" << oendl;
240} 237}
241 238
242void ScQtFileDlg::slotOK() 239void ScQtFileDlg::slotOK()
243{ 240{
244 qWarning( "ScQtFileDlg::slotOK(): Not implemented yet!" ); 241 owarn << "ScQtFileDlg::slotOK(): Not implemented yet!" << oendl;
245} 242}
246 243
247void ScQtFileDlg::slotSelectionChanged(QListViewItem *) 244void ScQtFileDlg::slotSelectionChanged(QListViewItem *)
248{ 245{
249 qWarning( "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" ); 246 owarn << "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" << oendl;
250} 247}
251 248
252void ScQtFileDlg::slotTypeComboBoxChanged( int ) 249void ScQtFileDlg::slotTypeComboBoxChanged( int )
253{ 250{
254 qWarning( "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" ); 251 owarn << "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" << oendl;
255} 252}
256 253
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 3df55eb..bf8f7f4 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1,90 +1,89 @@
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#include <opie2/odebug.h>
33using namespace Opie::Core;
33using namespace Opie::Ui; 34using namespace Opie::Ui;
34#else 35#else
35#include "scqtfileedit.h" 36#include "scqtfileedit.h"
36#endif 37#endif
37#endif 38#endif
38 39
39#include <qclipboard.h> 40#include <qclipboard.h>
40 41
41#include <stdio.h>
42
43#include <sys/types.h> 42#include <sys/types.h>
44#include <sys/stat.h> 43#include <sys/stat.h>
45#include <fcntl.h> 44#include <fcntl.h>
46#include <stdlib.h> 45#include <stdlib.h>
47#ifndef WIN32 46#ifndef WIN32
48#include <unistd.h> 47#include <unistd.h>
49#endif 48#endif
50#include <string.h> 49#include <string.h>
51#include <errno.h> 50#include <errno.h>
52 51
53#include <qmenubar.h> 52#include <qmenubar.h>
54#include <qpopupmenu.h> 53#include <qpopupmenu.h>
55 54
56#ifdef DESKTOP 55#ifdef DESKTOP
57#include <qfiledialog.h> 56#include <qfiledialog.h>
58#ifndef WIN32 57#ifndef WIN32
59#include <qsettings.h> 58#include <qsettings.h>
60#else 59#else
61#include "qsettings.h" 60#include "qsettings.h"
62#endif 61#endif
63#include <qapplication.h> 62#include <qapplication.h>
64#else 63#else
65#include <qfile.h> 64#include <qfile.h>
66#include <qpe/fileselector.h> 65#include <qpe/fileselector.h>
67#include <qpe/global.h> 66#include <qpe/global.h>
68#include <qpe/qpeapplication.h> 67#include <qpe/qpeapplication.h>
69#include <qpe/resource.h> 68#include <qpe/resource.h>
70#include <qpe/config.h> 69#include <qpe/config.h>
71#endif 70#endif
72 71
73#include <qtimer.h> 72#include <qtimer.h>
74#include <qlayout.h> 73#include <qlayout.h>
75#include <qmessagebox.h> 74#include <qmessagebox.h>
76#include <qfile.h> 75#include <qfile.h>
77#include <qtextstream.h> 76#include <qtextstream.h>
78#include <qheader.h> 77#include <qheader.h>
79#include <qlistview.h> 78#include <qlistview.h>
80#include <qtoolbutton.h> 79#include <qtoolbutton.h>
81#include <qvariant.h> 80#include <qvariant.h>
82#include <qtooltip.h> 81#include <qtooltip.h>
83#include <qwhatsthis.h> 82#include <qwhatsthis.h>
84#include <qimage.h> 83#include <qimage.h>
85#include <qpixmap.h> 84#include <qpixmap.h>
86#include <qlineedit.h> 85#include <qlineedit.h>
87#include <qmultilineedit.h> 86#include <qmultilineedit.h>
88#include <qregexp.h> 87#include <qregexp.h>
89#include <qdir.h> 88#include <qdir.h>
90#include <qtextbrowser.h> 89#include <qtextbrowser.h>
@@ -2024,117 +2023,115 @@ bool ZSafe::openDocument(const char* _filename, const char* )
2024 switch( QMessageBox::warning( this, tr("ZSafe"), 2023 switch( QMessageBox::warning( this, tr("ZSafe"),
2025 tr("Empty document or\nwrong password.\nContinue?"), 2024 tr("Empty document or\nwrong password.\nContinue?"),
2026 tr("&No"), tr("&Yes."), 2025 tr("&No"), tr("&Yes."),
2027 0 2026 0
2028 ) ) { 2027 ) ) {
2029 case 0: // No 2028 case 0: // No
2030 retval = loadFinalize(); 2029 retval = loadFinalize();
2031 exitZs (1); 2030 exitZs (1);
2032 break; 2031 break;
2033 case 1: // Yes 2032 case 1: // Yes
2034 break; 2033 break;
2035 } 2034 }
2036 } 2035 }
2037 2036
2038 retval = loadFinalize(); 2037 retval = loadFinalize();
2039 2038
2040 return true; 2039 return true;
2041} 2040}
2042 2041
2043int ZSafe::loadInit(const char* _filename, const char *password) 2042int ZSafe::loadInit(const char* _filename, const char *password)
2044{ 2043{
2045 unsigned int j = 0; 2044 unsigned int j = 0;
2046 unsigned int keylength=0; 2045 unsigned int keylength=0;
2047 int count=0, count2=0, count3=0; 2046 int count=0, count2=0, count3=0;
2048 unsigned char charbuf[8]; 2047 unsigned char charbuf[8];
2049 unsigned short ciphertext[4]; 2048 unsigned short ciphertext[4];
2050 char key[128]; 2049 char key[128];
2051 Krc2* krc2 = new Krc2(); 2050 Krc2* krc2 = new Krc2();
2052 2051
2053 fd = fopen (_filename, "rb"); 2052 fd = fopen (_filename, "rb");
2054 2053
2055 QFileInfo f (_filename); 2054 QFileInfo f (_filename);
2056 load_buffer_length = f.size(); 2055 load_buffer_length = f.size();
2057 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; 2056 load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2;
2058 2057
2059 if (fd == NULL) 2058 if (fd == NULL)
2060 return PWERR_OPEN; 2059 return PWERR_OPEN;
2061 2060
2062 buffer = (char *)malloc(load_buffer_length); 2061 buffer = (char *)malloc(load_buffer_length);
2063 for (j = 0; password[j] != '\0'; j++) { 2062 for (j = 0; password[j] != '\0'; j++) {
2064 key[j] = password[j]; 2063 key[j] = password[j];
2065 } 2064 }
2066 keylength = j; 2065 keylength = j;
2067 krc2->rc2_expandkey (key, keylength, 128); 2066 krc2->rc2_expandkey (key, keylength, 128);
2068 2067
2069#ifndef WIN32 2068#ifndef WIN32
2070 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); 2069 size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
2071#else 2070#else
2072 printf ("LoadInit() read1");
2073 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); 2071 size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
2074#endif 2072#endif
2075 2073
2076 if (size < 8) 2074 if (size < 8)
2077 return PWERR_DATA; 2075 return PWERR_DATA;
2078 2076
2079 for (count = 0; count < 4; count++) { 2077 for (count = 0; count < 4; count++) {
2080 count2 = count << 1; 2078 count2 = count << 1;
2081 iv[count] = charbuf[count2] << 8; 2079 iv[count] = charbuf[count2] << 8;
2082 iv[count] += charbuf[count2 + 1]; 2080 iv[count] += charbuf[count2 + 1];
2083 } 2081 }
2084 2082
2085 size = 0; 2083 size = 0;
2086 bufferIndex = 0; 2084 bufferIndex = 0;
2087#ifndef WIN32 2085#ifndef WIN32
2088 while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { 2086 while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
2089 while (count < 8) { 2087 while (count < 8) {
2090 count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); 2088 count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8);
2091#else 2089#else
2092 printf ("LoadInit() read2");
2093 while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { 2090 while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) {
2094 while (count < 8) { 2091 while (count < 8) {
2095 count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); 2092 count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
2096#endif 2093#endif
2097 if (count2 == 0) { 2094 if (count2 == 0) {
2098 return PWERR_DATA; 2095 return PWERR_DATA;
2099 } 2096 }
2100 count += count2; 2097 count += count2;
2101 } /* while (count < 8) */ 2098 } /* while (count < 8) */
2102 2099
2103 size += 8; 2100 size += 8;
2104 for (count2 = 0; count2 < 8; count2 += 2) { 2101 for (count2 = 0; count2 < 8; count2 += 2) {
2105 count3 = count2 >> 1; 2102 count3 = count2 >> 1;
2106 ciphertext[count3] = charbuf[count2] << 8; 2103 ciphertext[count3] = charbuf[count2] << 8;
2107 ciphertext[count3] += charbuf[count2 + 1]; 2104 ciphertext[count3] += charbuf[count2 + 1];
2108 2105
2109 plaintext[count3] = ciphertext[count3] ^ iv[count3]; 2106 plaintext[count3] = ciphertext[count3] ^ iv[count3];
2110 iv[count3] = plaintext[count3]; 2107 iv[count3] = plaintext[count3];
2111 } /* for (count2) */ 2108 } /* for (count2) */
2112 2109
2113 krc2->rc2_decrypt (plaintext); 2110 krc2->rc2_decrypt (plaintext);
2114 memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); 2111 memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8);
2115 bufferIndex += 8; 2112 bufferIndex += 8;
2116 buffer[bufferIndex + 1] = '\0'; 2113 buffer[bufferIndex + 1] = '\0';
2117 } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ 2114 } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
2118 size -= buffer[size - 1]; 2115 size -= buffer[size - 1];
2119 lastcount = 0; 2116 lastcount = 0;
2120 2117
2121 /* This will point to the starting index */ 2118 /* This will point to the starting index */
2122 bufferIndex = 0; 2119 bufferIndex = 0;
2123 return PWERR_GOOD; 2120 return PWERR_GOOD;
2124} 2121}
2125 2122
2126int ZSafe::loadEntry(char *entry[FIELD_SIZE]) 2123int ZSafe::loadEntry(char *entry[FIELD_SIZE])
2127{ 2124{
2128 /* Strip off PKCS 5 padding 2125 /* Strip off PKCS 5 padding
2129 * Should check to make sure it's good here 2126 * Should check to make sure it's good here
2130 */ 2127 */
2131 int count, count1=0; 2128 int count, count1=0;
2132 2129
2133 for (count = lastcount; count < size; count++) { 2130 for (count = lastcount; count < size; count++) {
2134 if ((unsigned char) (buffer[count]) == 255) { 2131 if ((unsigned char) (buffer[count]) == 255) {
2135 if (buffer[bufferIndex] == '\0') { 2132 if (buffer[bufferIndex] == '\0') {
2136 bufferIndex++; 2133 bufferIndex++;
2137 } 2134 }
2138 entry[count1] = (char *) malloc (count - bufferIndex + 1); 2135 entry[count1] = (char *) malloc (count - bufferIndex + 1);
2139 memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); 2136 memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex);
2140 entry[count1][count - bufferIndex] = '\0'; 2137 entry[count1][count - bufferIndex] = '\0';
@@ -2214,150 +2211,150 @@ bool ZSafe::saveDocument(const char* _filename,
2214 tr("&Save"), 2211 tr("&Save"),
2215 tr("&Don't Save"), 2212 tr("&Don't Save"),
2216 0 // Enter == button 0 2213 0 // Enter == button 0
2217 ) ) 2214 ) )
2218 { // Escape == button 2 2215 { // Escape == button 2
2219 case 0: // Save clicked, Alt-S or Enter pressed. 2216 case 0: // Save clicked, Alt-S or Enter pressed.
2220 modified = false; 2217 modified = false;
2221 break; 2218 break;
2222 case 1: // Don't Save clicked or Alt-D pressed 2219 case 1: // Don't Save clicked or Alt-D pressed
2223 modified = false; 2220 modified = false;
2224 return true; 2221 return true;
2225 } 2222 }
2226 } 2223 }
2227 modified = false; 2224 modified = false;
2228 2225
2229 if (m_password.isEmpty()) 2226 if (m_password.isEmpty())
2230 return false; 2227 return false;
2231 2228
2232 int retval = saveInit(_filename, m_password); 2229 int retval = saveInit(_filename, m_password);
2233 // int retval = saveInit(_filename, "test"); 2230 // int retval = saveInit(_filename, "test");
2234 if (retval != PWERR_GOOD) { 2231 if (retval != PWERR_GOOD) {
2235 return false; 2232 return false;
2236 } 2233 }
2237 2234
2238 char* entry[FIELD_SIZE]; 2235 char* entry[FIELD_SIZE];
2239 2236
2240 // save the validation entry 2237 // save the validation entry
2241 { 2238 {
2242 int i=0; 2239 int i=0;
2243 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); 2240 entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
2244 strcpy(entry[i++], "ZSAFECATEGORY"); 2241 strcpy(entry[i++], "ZSAFECATEGORY");
2245 entry[i] = (char*)malloc(strlen("name")+1); 2242 entry[i] = (char*)malloc(strlen("name")+1);
2246 strcpy(entry[i++], "name"); 2243 strcpy(entry[i++], "name");
2247 entry[i] = (char*)malloc(strlen("username")+1); 2244 entry[i] = (char*)malloc(strlen("username")+1);
2248 strcpy(entry[i++], "username"); 2245 strcpy(entry[i++], "username");
2249 entry[i] = (char*)malloc(strlen("password")+1); 2246 entry[i] = (char*)malloc(strlen("password")+1);
2250 strcpy(entry[i++], "password"); 2247 strcpy(entry[i++], "password");
2251 entry[i] = (char*)malloc(strlen("comment")+1); 2248 entry[i] = (char*)malloc(strlen("comment")+1);
2252 strcpy(entry[i++], "comment"); 2249 strcpy(entry[i++], "comment");
2253 2250
2254 entry[i] = (char*)malloc(strlen("field5")+1); 2251 entry[i] = (char*)malloc(strlen("field5")+1);
2255 strcpy(entry[i++], "field5"); 2252 strcpy(entry[i++], "field5");
2256 entry[i] = (char*)malloc(strlen("field6")+1); 2253 entry[i] = (char*)malloc(strlen("field6")+1);
2257 strcpy(entry[i++], "field6"); 2254 strcpy(entry[i++], "field6");
2258 2255
2259 retval = saveEntry(entry); 2256 retval = saveEntry(entry);
2260 for (int z=0; z<i; z++) free(entry[z]); 2257 for (int z=0; z<i; z++) free(entry[z]);
2261 if (retval == PWERR_DATA) { 2258 if (retval == PWERR_DATA) {
2262 qWarning("1: Error writing file, contents not saved"); 2259 owarn << "1: Error writing file, contents not saved" << oendl;
2263 saveFinalize(); 2260 saveFinalize();
2264 return false; 2261 return false;
2265 } 2262 }
2266// #ifndef WIN32 2263// #ifndef WIN32
2267 conf->writeEntry(APP_KEY+"valzsafe", 1); 2264 conf->writeEntry(APP_KEY+"valzsafe", 1);
2268// #endif 2265// #endif
2269 saveConf(); 2266 saveConf();
2270 } 2267 }
2271 2268
2272 QListViewItem *i; 2269 QListViewItem *i;
2273 // step through all categories 2270 // step through all categories
2274 for (i = ListView->firstChild(); 2271 for (i = ListView->firstChild();
2275 i != NULL; 2272 i != NULL;
2276 i = i->nextSibling()) 2273 i = i->nextSibling())
2277 { 2274 {
2278 // step through all subitems 2275 // step through all subitems
2279 QListViewItem *si; 2276 QListViewItem *si;
2280 for (si = i->firstChild(); 2277 for (si = i->firstChild();
2281 si != NULL; 2278 si != NULL;
2282 si = si->nextSibling()) 2279 si = si->nextSibling())
2283 { 2280 {
2284 int j=0; 2281 int j=0;
2285 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); 2282 entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
2286 strcpy(entry[j++], i->text(0).utf8()); 2283 strcpy(entry[j++], i->text(0).utf8());
2287 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); 2284 entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
2288 strcpy(entry[j++], si->text(0).utf8()); 2285 strcpy(entry[j++], si->text(0).utf8());
2289 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); 2286 entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
2290 strcpy(entry[j++], si->text(1).utf8()); 2287 strcpy(entry[j++], si->text(1).utf8());
2291 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); 2288 entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
2292 strcpy(entry[j++], si->text(2).utf8()); 2289 strcpy(entry[j++], si->text(2).utf8());
2293 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); 2290 entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
2294 strcpy(entry[j++], si->text(3).utf8()); 2291 strcpy(entry[j++], si->text(3).utf8());
2295 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); 2292 entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
2296 strcpy(entry[j++], si->text(4).utf8()); 2293 strcpy(entry[j++], si->text(4).utf8());
2297 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); 2294 entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
2298 strcpy(entry[j++], si->text(5).utf8()); 2295 strcpy(entry[j++], si->text(5).utf8());
2299 2296
2300 retval = saveEntry(entry); 2297 retval = saveEntry(entry);
2301 for (int z=0; z<j; z++) 2298 for (int z=0; z<j; z++)
2302 { 2299 {
2303 free(entry[z]); 2300 free(entry[z]);
2304 } 2301 }
2305 if (retval == PWERR_DATA) { 2302 if (retval == PWERR_DATA) {
2306 qWarning("1: Error writing file, contents not saved"); 2303 owarn << "1: Error writing file, contents not saved" << oendl;
2307 saveFinalize(); 2304 saveFinalize();
2308 return false; 2305 return false;
2309 } 2306 }
2310 2307
2311 } 2308 }
2312 } 2309 }
2313 2310
2314 if (saveFinalize() == PWERR_DATA) { 2311 if (saveFinalize() == PWERR_DATA) {
2315 qWarning("2: Error writing file, contents not saved"); 2312 owarn << "2: Error writing file, contents not saved" << oendl;
2316 return false; 2313 return false;
2317 } else { 2314 } else {
2318#ifndef DESKTOP 2315#ifndef DESKTOP
2319 Global::statusMessage (tr("Password file saved.")); 2316 Global::statusMessage (tr("Password file saved."));
2320#endif 2317#endif
2321 modified = false; 2318 modified = false;
2322 return true; 2319 return true;
2323 } 2320 }
2324} 2321}
2325 2322
2326PasswordForm *newPwdDialog; 2323PasswordForm *newPwdDialog;
2327bool newPwdDialogResult = false; 2324bool newPwdDialogResult = false;
2328void ZSafe::setPasswordDialogDone() 2325void ZSafe::setPasswordDialogDone()
2329{ 2326{
2330 newPwdDialogResult = true; 2327 newPwdDialogResult = true;
2331 newPwdDialog->close(); 2328 newPwdDialog->close();
2332} 2329}
2333 2330
2334void ZSafe::getDocPassword(QString title) 2331void ZSafe::getDocPassword(QString title)
2335{ 2332{
2336qWarning ("getDocPassword"); 2333qWarning ("getDocPassword");
2337 // open the 'Password' dialog 2334 // open the 'Password' dialog
2338 PasswordForm *dialog = new PasswordForm(this, title, TRUE); 2335 PasswordForm *dialog = new PasswordForm(this, title, TRUE);
2339 newPwdDialog = dialog; 2336 newPwdDialog = dialog;
2340 newPwdDialogResult = false; 2337 newPwdDialogResult = false;
2341 2338
2342 connect( dialog->PasswordField, SIGNAL( returnPressed() ), 2339 connect( dialog->PasswordField, SIGNAL( returnPressed() ),
2343 this, SLOT( setPasswordDialogDone() ) ); 2340 this, SLOT( setPasswordDialogDone() ) );
2344 2341
2345 // CS: !!! 2342 // CS: !!!
2346 // int pos = filename.findRev ('/'); 2343 // int pos = filename.findRev ('/');
2347 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 2344 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
2348#ifdef WIN32 2345#ifdef WIN32
2349 dialog->setCaption("Qt " + ti); 2346 dialog->setCaption("Qt " + ti);
2350#else 2347#else
2351 dialog->setCaption(ti); 2348 dialog->setCaption(ti);
2352#endif 2349#endif
2353 // dialog->setCaption(title); 2350 // dialog->setCaption(title);
2354 2351
2355 dialog->PasswordField->setFocus(); 2352 dialog->PasswordField->setFocus();
2356 DialogCode result = (DialogCode) dialog->exec(); 2353 DialogCode result = (DialogCode) dialog->exec();
2357#ifdef DESKTOP 2354#ifdef DESKTOP
2358 result = Accepted; 2355 result = Accepted;
2359#endif 2356#endif
2360 2357
2361 QString password; 2358 QString password;
2362 if (result == Accepted || newPwdDialogResult) 2359 if (result == Accepted || newPwdDialogResult)
2363 { 2360 {
@@ -3145,97 +3142,97 @@ void ZSafe::editCategory()
3145 while ( (fi=it.current()) ) 3142 while ( (fi=it.current()) )
3146 { // for each file... 3143 { // for each file...
3147 QString fileName = fi->fileName(); 3144 QString fileName = fi->fileName();
3148 if(fileName.right(4) == ".png") 3145 if(fileName.right(4) == ".png")
3149 { 3146 {
3150 fileName = fileName.mid(0,fileName.length()-4); 3147 fileName = fileName.mid(0,fileName.length()-4);
3151 3148
3152 3149
3153 if(fileName+".png"==icon) 3150 if(fileName+".png"==icon)
3154 { 3151 {
3155 dialog->IconField->setCurrentItem(i+1); 3152 dialog->IconField->setCurrentItem(i+1);
3156 break; 3153 break;
3157 } 3154 }
3158 ++i; 3155 ++i;
3159 } 3156 }
3160 ++it; 3157 ++it;
3161 } 3158 }
3162 } 3159 }
3163 } 3160 }
3164 3161
3165 // dialog->show(); 3162 // dialog->show();
3166#ifndef DESKTOP 3163#ifndef DESKTOP
3167 // dialog->move (20, 100); 3164 // dialog->move (20, 100);
3168#endif 3165#endif
3169 DialogCode result = (DialogCode) dialog->exec(); 3166 DialogCode result = (DialogCode) dialog->exec();
3170#ifdef DESKTOP 3167#ifdef DESKTOP
3171 result = Accepted; 3168 result = Accepted;
3172#endif 3169#endif
3173 3170
3174 QString fullIconPath; 3171 QString fullIconPath;
3175 QPixmap *pix; 3172 QPixmap *pix;
3176 if (result == Accepted) 3173 if (result == Accepted)
3177 { 3174 {
3178 modified = true; 3175 modified = true;
3179 if (category != dialog->CategoryField->currentText()) 3176 if (category != dialog->CategoryField->currentText())
3180 { 3177 {
3181 categories.remove (category); 3178 categories.remove (category);
3182// #ifndef WIN32 3179// #ifndef WIN32
3183 conf->removeEntry(category); 3180 conf->removeEntry(category);
3184// #endif 3181// #endif
3185 saveConf(); 3182 saveConf();
3186 } 3183 }
3187 3184
3188 category = dialog->CategoryField->currentText(); 3185 category = dialog->CategoryField->currentText();
3189 icon = dialog->IconField->currentText()+".png"; 3186 icon = dialog->IconField->currentText()+".png";
3190 3187
3191 if (cat) 3188 if (cat)
3192 { 3189 {
3193 qWarning("Category found"); 3190 owarn << "Category found" << oendl;
3194 3191
3195 // if (!icon.isEmpty() && !icon.isNull()) 3192 // if (!icon.isEmpty() && !icon.isNull())
3196 if (icon != "predefined.png") 3193 if (icon != "predefined.png")
3197 { 3194 {
3198 // build the full path 3195 // build the full path
3199 fullIconPath = iconPath + icon; 3196 fullIconPath = iconPath + icon;
3200 pix = new QPixmap (fullIconPath); 3197 pix = new QPixmap (fullIconPath);
3201 if (pix) 3198 if (pix)
3202 { 3199 {
3203 // save the full pixmap name into the config file 3200 // save the full pixmap name into the config file
3204// #ifndef WIN32 3201// #ifndef WIN32
3205 conf->writeEntry(APP_KEY+category, icon); 3202 conf->writeEntry(APP_KEY+category, icon);
3206// #endif 3203// #endif
3207 saveConf(); 3204 saveConf();
3208 QImage img = pix->convertToImage(); 3205 QImage img = pix->convertToImage();
3209 pix->convertFromImage(img.smoothScale(14,14)); 3206 pix->convertFromImage(img.smoothScale(14,14));
3210 cat->setIconName (icon); 3207 cat->setIconName (icon);
3211 cat->setIcon (*pix); 3208 cat->setIcon (*pix);
3212 } 3209 }
3213 } 3210 }
3214 else 3211 else
3215 { 3212 {
3216// #ifndef WIN32 3213// #ifndef WIN32
3217 conf->removeEntry (category); 3214 conf->removeEntry (category);
3218// #endif 3215// #endif
3219 saveConf(); 3216 saveConf();
3220 cat->setIcon (*getPredefinedIcon(category)); 3217 cat->setIcon (*getPredefinedIcon(category));
3221 } 3218 }
3222 3219
3223 // change the category name of the selected category 3220 // change the category name of the selected category
3224 QListViewItem *catItem = cat->getListItem(); 3221 QListViewItem *catItem = cat->getListItem();
3225 if (catItem) 3222 if (catItem)
3226 { 3223 {
3227 qWarning (category); 3224 qWarning (category);
3228 catItem->setText( 0, tr( category ) ); 3225 catItem->setText( 0, tr( category ) );
3229 cat->setCategoryName (tr(category)); 3226 cat->setCategoryName (tr(category));
3230 3227
3231 cat->initListItem(); 3228 cat->initListItem();
3232 categories.insert (category, cat); 3229 categories.insert (category, cat);
3233 } 3230 }
3234 } 3231 }
3235 saveCategoryDialogFields(dialog); 3232 saveCategoryDialogFields(dialog);
3236 } 3233 }
3237 else 3234 else
3238 { 3235 {
3239 // delete dialog; 3236 // delete dialog;
3240 dialog->hide(); 3237 dialog->hide();
3241 return; 3238 return;
diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro
index 72c8fe9..3cae706 100644
--- a/noncore/apps/zsafe/zsafe.pro
+++ b/noncore/apps/zsafe/zsafe.pro
@@ -1,17 +1,17 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on 2CONFIG = qt warn_on
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \ 4HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \
5 scqtfiledlg.h 5 scqtfiledlg.h
6SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \ 6SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \
7 categorylist.cpp zlistview.cpp shadedlistitem.cpp\ 7 categorylist.cpp zlistview.cpp shadedlistitem.cpp\
8 scqtfileedit.cpp scqtfileedit.moc.cpp \ 8 scqtfileedit.cpp scqtfileedit.moc.cpp \
9 scqtfiledlg.cpp 9 scqtfiledlg.cpp
10INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui 10INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui
11INCLUDEPATH += $(OPIEDIR)/include 11INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 12DEPENDPATH += $(OPIEDIR)/include
13LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopiecore2 -lopieui2 13LIBS += -lqpe -lopiecore2 -lopieui2
14TARGET = zsafe 14TARGET = zsafe
15 15
16include ( $(OPIEDIR)/include.pro ) 16include ( $(OPIEDIR)/include.pro )
17 17