summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp38
-rw-r--r--noncore/apps/advancedfm/output.cpp2
2 files changed, 23 insertions, 17 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 23244a2..92804b2 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,875 +1,879 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie/otabwidget.h> 15#include <opie/otabwidget.h>
16// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
18 18
19#include <qpe/filemanager.h> 19#include <qpe/filemanager.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/mimetype.h> 26#include <qpe/mimetype.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/ir.h> 28#include <qpe/ir.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30 30
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qlistview.h> 40#include <qlistview.h>
41#include <qmainwindow.h> 41#include <qmainwindow.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qprogressbar.h> 43#include <qprogressbar.h>
44#include <qspinbox.h> 44#include <qspinbox.h>
45#include <qwidget.h> 45#include <qwidget.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qimage.h> 47#include <qimage.h>
48#include <qpixmap.h> 48#include <qpixmap.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qregexp.h> 51#include <qregexp.h>
52 52
53#include <unistd.h> 53#include <unistd.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <dirent.h> 56#include <dirent.h>
57#include <stdio.h> 57#include <stdio.h>
58#include <time.h> 58#include <time.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#include <mntent.h> 60#include <mntent.h>
61#include <string.h> 61#include <string.h>
62#include <errno.h> 62#include <errno.h>
63#include <sys/vfs.h> 63#include <sys/vfs.h>
64#include <mntent.h> 64#include <mntent.h>
65#include <sys/utsname.h> 65#include <sys/utsname.h>
66 66
67AdvancedFm::AdvancedFm( ) 67AdvancedFm::AdvancedFm( )
68 : QMainWindow( ) { 68 : QMainWindow( ) {
69 init(); 69 init();
70 initConnections(); 70 initConnections();
71 populateLocalView(); 71 populateLocalView();
72 populateRemoteView(); 72 populateRemoteView();
73 currentPathCombo->setFocus(); 73 currentPathCombo->setFocus();
74} 74}
75 75
76AdvancedFm::~AdvancedFm() { 76AdvancedFm::~AdvancedFm() {
77} 77}
78 78
79void AdvancedFm::cleanUp() { 79void AdvancedFm::cleanUp() {
80 QString sfile=QDir::homeDirPath(); 80 QString sfile=QDir::homeDirPath();
81 if(sfile.right(1) != "/") 81 if(sfile.right(1) != "/")
82 sfile+="/._temp"; 82 sfile+="/._temp";
83 else 83 else
84 sfile+="._temp"; 84 sfile+="._temp";
85 QFile file( sfile); 85 QFile file( sfile);
86 if(file.exists()) 86 if(file.exists())
87 file.remove(); 87 file.remove();
88} 88}
89 89
90void AdvancedFm::tabChanged(QWidget *) { 90void AdvancedFm::tabChanged(QWidget *w) {
91 if (TabWidget->getCurrentTab() == 0) { 91 qDebug("tab changed %d",TabWidget->getCurrentTab());
92
93 if ( w == tab) {
94// if (TabWidget->getCurrentTab() == 0) {
92// if (TabWidget->currentPageIndex() == 0) { 95// if (TabWidget->currentPageIndex() == 0) {
93 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 96 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
94 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 97 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
95 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 98 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
96 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 99 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
97 setCaption("AdvancedFm :: "+fs+" :: " 100 setCaption("AdvancedFm :: "+fs+" :: "
98 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 101 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
99 102
100 } 103 }
101 if (TabWidget->getCurrentTab() == 1) { 104 if ( w == tab_2) {
105// if (TabWidget->getCurrentTab() == 1) {
102 106
103// if (TabWidget->currentPageIndex() == 1) { 107// if (TabWidget->currentPageIndex() == 1) {
104 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
105 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
106 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
107 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
108 setCaption("AdvancedFm :: "+fs+" :: " 112 setCaption("AdvancedFm :: "+fs+" :: "
109 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 113 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
110 } 114 }
111} 115}
112 116
113 117
114void AdvancedFm::populateLocalView() { 118void AdvancedFm::populateLocalView() {
115 QPixmap pm; 119 QPixmap pm;
116 Local_View->clear(); 120 Local_View->clear();
117 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 121 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
118 currentDir.setMatchAllDirs(TRUE); 122 currentDir.setMatchAllDirs(TRUE);
119 currentDir.setNameFilter(filterStr); 123 currentDir.setNameFilter(filterStr);
120 QString fileL, fileS, fileDate; 124 QString fileL, fileS, fileDate;
121 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 125 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
122 setCaption("AdvancedFm :: "+fs+" :: " 126 setCaption("AdvancedFm :: "+fs+" :: "
123 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 127 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
124 bool isDir=FALSE; 128 bool isDir=FALSE;
125 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 129 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
126 QFileInfoListIterator it(*list); 130 QFileInfoListIterator it(*list);
127 QFileInfo *fi; 131 QFileInfo *fi;
128 while ( (fi=it.current()) ) { 132 while ( (fi=it.current()) ) {
129 if (fi->isSymLink() ) { 133 if (fi->isSymLink() ) {
130 QString symLink=fi->readLink(); 134 QString symLink=fi->readLink();
131 QFileInfo sym( symLink); 135 QFileInfo sym( symLink);
132 fileS.sprintf( "%10i", sym.size() ); 136 fileS.sprintf( "%10i", sym.size() );
133 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 137 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
134 fileDate = sym.lastModified().toString(); 138 fileDate = sym.lastModified().toString();
135 } else { 139 } else {
136 fileS.sprintf( "%10i", fi->size() ); 140 fileS.sprintf( "%10i", fi->size() );
137 fileL.sprintf( "%s",fi->fileName().data() ); 141 fileL.sprintf( "%s",fi->fileName().data() );
138 fileDate= fi->lastModified().toString(); 142 fileDate= fi->lastModified().toString();
139 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 143 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
140 fileL+="/"; 144 fileL+="/";
141 isDir=TRUE; 145 isDir=TRUE;
142 } 146 }
143 } 147 }
144 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 148 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
145 if(fileL !="./" && fi->exists()) { 149 if(fileL !="./" && fi->exists()) {
146 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 150 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
147 151
148 if(isDir || fileL.find("/",0,TRUE) != -1) { 152 if(isDir || fileL.find("/",0,TRUE) != -1) {
149 153
150 if( !QDir( fi->filePath() ).isReadable()) //is directory 154 if( !QDir( fi->filePath() ).isReadable()) //is directory
151 pm = Resource::loadPixmap( "lockedfolder" ); 155 pm = Resource::loadPixmap( "lockedfolder" );
152 else 156 else
153 pm= Resource::loadPixmap( "folder" ); 157 pm= Resource::loadPixmap( "folder" );
154 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 158 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
155 pm = Resource::loadPixmap( "exec"); 159 pm = Resource::loadPixmap( "exec");
156 } else if( (fileInfo.permission( QFileInfo::ExeUser) 160 } else if( (fileInfo.permission( QFileInfo::ExeUser)
157 | fileInfo.permission( QFileInfo::ExeGroup) 161 | fileInfo.permission( QFileInfo::ExeGroup)
158 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 162 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
159 pm = Resource::loadPixmap( "exec"); 163 pm = Resource::loadPixmap( "exec");
160 } else if( !fi->isReadable() ) { 164 } else if( !fi->isReadable() ) {
161 pm = Resource::loadPixmap( "locked" ); 165 pm = Resource::loadPixmap( "locked" );
162 } else { //everything else goes by mimetype 166 } else { //everything else goes by mimetype
163 MimeType mt(fi->filePath()); 167 MimeType mt(fi->filePath());
164 pm=mt.pixmap(); //sets the correct pixmap for mimetype 168 pm=mt.pixmap(); //sets the correct pixmap for mimetype
165 if(pm.isNull()) 169 if(pm.isNull())
166 pm = Resource::loadPixmap( "UnknownDocument-14" ); 170 pm = Resource::loadPixmap( "UnknownDocument-14" );
167 } 171 }
168 item->setPixmap( 0,pm); 172 item->setPixmap( 0,pm);
169 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 173 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
170 // overlay link image 174 // overlay link image
171 pm= Resource::loadPixmap( "folder" ); 175 pm= Resource::loadPixmap( "folder" );
172 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 176 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
173 QPainter painter( &pm ); 177 QPainter painter( &pm );
174 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 178 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
175 pm.setMask( pm.createHeuristicMask( FALSE ) ); 179 pm.setMask( pm.createHeuristicMask( FALSE ) );
176 item->setPixmap( 0, pm); 180 item->setPixmap( 0, pm);
177 } 181 }
178 } 182 }
179 isDir=FALSE; 183 isDir=FALSE;
180 ++it; 184 ++it;
181 } 185 }
182 186
183 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 187 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
184 struct stat buf; 188 struct stat buf;
185 dev_t devT; 189 dev_t devT;
186 DIR *dir; 190 DIR *dir;
187 struct dirent *mydirent; 191 struct dirent *mydirent;
188 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 192 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
189 while ((mydirent = readdir(dir)) != NULL) { 193 while ((mydirent = readdir(dir)) != NULL) {
190 lstat( mydirent->d_name, &buf); 194 lstat( mydirent->d_name, &buf);
191 qDebug(mydirent->d_name); 195 qDebug(mydirent->d_name);
192 fileL.sprintf("%s", mydirent->d_name); 196 fileL.sprintf("%s", mydirent->d_name);
193 devT = buf.st_dev; 197 devT = buf.st_dev;
194 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
195 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 199 fileDate.sprintf("%s", ctime( &buf.st_mtime));
196 if( fileL.find(".") == -1 ){ 200 if( fileL.find(".") == -1 ){
197 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 201 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
198 pm = Resource::loadPixmap( "UnknownDocument-14" ); 202 pm = Resource::loadPixmap( "UnknownDocument-14" );
199 item->setPixmap( 0,pm); 203 item->setPixmap( 0,pm);
200 } 204 }
201 } 205 }
202 206
203 closedir(dir); 207 closedir(dir);
204 } 208 }
205 209
206 Local_View->setSorting( 3,FALSE); 210 Local_View->setSorting( 3,FALSE);
207 fillCombo( (const QString &) currentDir.canonicalPath()); 211 fillCombo( (const QString &) currentDir.canonicalPath());
208} 212}
209 213
210 214
211void AdvancedFm::populateRemoteView() { 215void AdvancedFm::populateRemoteView() {
212 QPixmap pm; 216 QPixmap pm;
213 Remote_View->clear(); 217 Remote_View->clear();
214 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 218 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
215 currentRemoteDir.setMatchAllDirs(TRUE); 219 currentRemoteDir.setMatchAllDirs(TRUE);
216 currentRemoteDir.setNameFilter(filterStr); 220 currentRemoteDir.setNameFilter(filterStr);
217 QString fileL, fileS, fileDate; 221 QString fileL, fileS, fileDate;
218 222
219 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 223 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
220 setCaption("AdvancedFm :: "+fs+" :: " 224 setCaption("AdvancedFm :: "+fs+" :: "
221 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 225 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
222 bool isDir=FALSE; 226 bool isDir=FALSE;
223 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 227 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
224 QFileInfoListIterator it(*list); 228 QFileInfoListIterator it(*list);
225 QFileInfo *fi; 229 QFileInfo *fi;
226 while ( (fi=it.current()) ) { 230 while ( (fi=it.current()) ) {
227 if (fi->isSymLink() ){ 231 if (fi->isSymLink() ){
228 QString symLink=fi->readLink(); 232 QString symLink=fi->readLink();
229 // qDebug("Symlink detected "+symLink); 233 // qDebug("Symlink detected "+symLink);
230 QFileInfo sym( symLink); 234 QFileInfo sym( symLink);
231 fileS.sprintf( "%10i", sym.size() ); 235 fileS.sprintf( "%10i", sym.size() );
232 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 236 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
233 fileDate = sym.lastModified().toString(); 237 fileDate = sym.lastModified().toString();
234 } else { 238 } else {
235 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 239 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
236 fileS.sprintf( "%10i", fi->size() ); 240 fileS.sprintf( "%10i", fi->size() );
237 fileL.sprintf( "%s",fi->fileName().data() ); 241 fileL.sprintf( "%s",fi->fileName().data() );
238 fileDate= fi->lastModified().toString(); 242 fileDate= fi->lastModified().toString();
239 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 243 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
240 fileL+="/"; 244 fileL+="/";
241 isDir=TRUE; 245 isDir=TRUE;
242 // qDebug( fileL); 246 // qDebug( fileL);
243 } 247 }
244 } 248 }
245 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 249 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
246 if(fileL !="./" && fi->exists()) { 250 if(fileL !="./" && fi->exists()) {
247 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 251 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
248 QPixmap pm; 252 QPixmap pm;
249 253
250 if(isDir || fileL.find("/",0,TRUE) != -1) { 254 if(isDir || fileL.find("/",0,TRUE) != -1) {
251 if( !QDir( fi->filePath() ).isReadable()) 255 if( !QDir( fi->filePath() ).isReadable())
252 pm = Resource::loadPixmap( "lockedfolder" ); 256 pm = Resource::loadPixmap( "lockedfolder" );
253 else 257 else
254 pm= Resource::loadPixmap( "folder" ); 258 pm= Resource::loadPixmap( "folder" );
255 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 259 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
256 pm = Resource::loadPixmap( "exec"); 260 pm = Resource::loadPixmap( "exec");
257 } else if( (fileInfo.permission( QFileInfo::ExeUser) 261 } else if( (fileInfo.permission( QFileInfo::ExeUser)
258 | fileInfo.permission( QFileInfo::ExeGroup) 262 | fileInfo.permission( QFileInfo::ExeGroup)
259 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 263 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
260 pm = Resource::loadPixmap( "exec"); 264 pm = Resource::loadPixmap( "exec");
261 } else if( !fi->isReadable() ) { 265 } else if( !fi->isReadable() ) {
262 pm = Resource::loadPixmap( "locked" ); 266 pm = Resource::loadPixmap( "locked" );
263 } else { 267 } else {
264 MimeType mt(fi->filePath()); 268 MimeType mt(fi->filePath());
265 pm=mt.pixmap(); //sets the correct pixmap for mimetype 269 pm=mt.pixmap(); //sets the correct pixmap for mimetype
266 if(pm.isNull()) 270 if(pm.isNull())
267 pm = Resource::loadPixmap( "UnknownDocument-14" ); 271 pm = Resource::loadPixmap( "UnknownDocument-14" );
268 } 272 }
269 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 273 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
270 // overlay link image 274 // overlay link image
271 pm= Resource::loadPixmap( "folder" ); 275 pm= Resource::loadPixmap( "folder" );
272 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 276 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
273 QPainter painter( &pm ); 277 QPainter painter( &pm );
274 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 278 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
275 pm.setMask( pm.createHeuristicMask( FALSE ) ); 279 pm.setMask( pm.createHeuristicMask( FALSE ) );
276 } 280 }
277 item->setPixmap( 0, pm); 281 item->setPixmap( 0, pm);
278 } 282 }
279 isDir=FALSE; 283 isDir=FALSE;
280 ++it; 284 ++it;
281 } 285 }
282 286
283 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 287 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
284 struct stat buf; 288 struct stat buf;
285 DIR *dir; 289 DIR *dir;
286 struct dirent *mydirent; 290 struct dirent *mydirent;
287 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 291 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
288 while ((mydirent = readdir(dir)) != NULL) { 292 while ((mydirent = readdir(dir)) != NULL) {
289 lstat( mydirent->d_name, &buf); 293 lstat( mydirent->d_name, &buf);
290 qDebug(mydirent->d_name); 294 qDebug(mydirent->d_name);
291 fileL.sprintf("%s", mydirent->d_name); 295 fileL.sprintf("%s", mydirent->d_name);
292 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 296 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
293 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 297 fileDate.sprintf("%s", ctime( &buf.st_mtime));
294 if( fileL.find(".") == -1 ){ 298 if( fileL.find(".") == -1 ){
295 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 299 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
296 pm = Resource::loadPixmap( "UnknownDocument-14" ); 300 pm = Resource::loadPixmap( "UnknownDocument-14" );
297 item->setPixmap( 0,pm); 301 item->setPixmap( 0,pm);
298 } 302 }
299 } 303 }
300 304
301 closedir(dir); 305 closedir(dir);
302 } 306 }
303 307
304 Remote_View->setSorting( 3,FALSE); 308 Remote_View->setSorting( 3,FALSE);
305 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 309 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
306} 310}
307 311
308void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 312void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
309 if(selectedItem) { 313 if(selectedItem) {
310 QString strItem=selectedItem->text(0); 314 QString strItem=selectedItem->text(0);
311 QString strSize=selectedItem->text(1); 315 QString strSize=selectedItem->text(1);
312 strSize=strSize.stripWhiteSpace(); 316 strSize=strSize.stripWhiteSpace();
313 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 317 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
314 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 318 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
315 if(QDir(strItem2).exists() ) { 319 if(QDir(strItem2).exists() ) {
316 currentDir.cd(strItem2, TRUE); 320 currentDir.cd(strItem2, TRUE);
317 populateLocalView(); 321 populateLocalView();
318 322
319 } 323 }
320 } else { // not a symlink 324 } else { // not a symlink
321 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 325 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
322 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 326 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
323 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 327 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
324 currentDir.cd(strItem,FALSE); 328 currentDir.cd(strItem,FALSE);
325 populateLocalView(); 329 populateLocalView();
326 Local_View->ensureItemVisible(Local_View->firstChild()); 330 Local_View->ensureItemVisible(Local_View->firstChild());
327 331
328 } else { 332 } else {
329 currentDir.cdUp(); 333 currentDir.cdUp();
330 populateLocalView(); 334 populateLocalView();
331 Local_View->ensureItemVisible(Local_View->firstChild()); 335 Local_View->ensureItemVisible(Local_View->firstChild());
332 } 336 }
333 if(QDir(strItem).exists()){ 337 if(QDir(strItem).exists()){
334 currentDir.cd(strItem, TRUE); 338 currentDir.cd(strItem, TRUE);
335 Local_View->ensureItemVisible(Local_View->firstChild()); 339 Local_View->ensureItemVisible(Local_View->firstChild());
336 populateLocalView(); 340 populateLocalView();
337 } 341 }
338 } else { 342 } else {
339 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 343 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
340 if( QFile::exists(strItem ) ) { 344 if( QFile::exists(strItem ) ) {
341 // qDebug("clicked item "+strItem); 345 // qDebug("clicked item "+strItem);
342 // DocLnk doc( strItem, FALSE ); 346 // DocLnk doc( strItem, FALSE );
343 // doc.execute(); 347 // doc.execute();
344 // Local_View->clearSelection(); 348 // Local_View->clearSelection();
345 } 349 }
346 } //end not symlink 350 } //end not symlink
347 chdir(strItem.latin1()); 351 chdir(strItem.latin1());
348 } 352 }
349 353
350 } 354 }
351} 355}
352 356
353void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 357void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
354 358
355 if(selectedItem) { 359 if(selectedItem) {
356 QString strItem=selectedItem->text(0); 360 QString strItem=selectedItem->text(0);
357 QString strSize=selectedItem->text(1); 361 QString strSize=selectedItem->text(1);
358 strSize=strSize.stripWhiteSpace(); 362 strSize=strSize.stripWhiteSpace();
359 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 363 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
360 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 364 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
361 currentRemoteDir.cd(strItem2, TRUE); 365 currentRemoteDir.cd(strItem2, TRUE);
362 populateRemoteView(); 366 populateRemoteView();
363 } else { // not a symlink 367 } else { // not a symlink
364 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 368 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
365 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 369 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
366 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 370 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
367 currentRemoteDir.cd(strItem,FALSE); 371 currentRemoteDir.cd(strItem,FALSE);
368 populateRemoteView(); 372 populateRemoteView();
369 Remote_View->ensureItemVisible(Remote_View->firstChild()); 373 Remote_View->ensureItemVisible(Remote_View->firstChild());
370 } else { 374 } else {
371 currentRemoteDir.cdUp(); 375 currentRemoteDir.cdUp();
372 populateRemoteView(); 376 populateRemoteView();
373 Remote_View->ensureItemVisible(Remote_View->firstChild()); 377 Remote_View->ensureItemVisible(Remote_View->firstChild());
374 } 378 }
375 if(QDir(strItem).exists()){ 379 if(QDir(strItem).exists()){
376 currentRemoteDir.cd(strItem, TRUE); 380 currentRemoteDir.cd(strItem, TRUE);
377 populateRemoteView(); 381 populateRemoteView();
378 Remote_View->ensureItemVisible(Remote_View->firstChild()); 382 Remote_View->ensureItemVisible(Remote_View->firstChild());
379 } 383 }
380 } else { 384 } else {
381 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 385 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
382 if( QFile::exists(strItem ) ) { 386 if( QFile::exists(strItem ) ) {
383 // qDebug("clicked item "+strItem); 387 // qDebug("clicked item "+strItem);
384 // DocLnk doc( strItem, FALSE ); 388 // DocLnk doc( strItem, FALSE );
385 // doc.execute(); 389 // doc.execute();
386 // Remote_View->clearSelection(); 390 // Remote_View->clearSelection();
387 } 391 }
388 } //end not symlink 392 } //end not symlink
389 chdir(strItem.latin1()); 393 chdir(strItem.latin1());
390 } 394 }
391 } 395 }
392} 396}
393 397
394 398
395void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 399void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
396// qDebug("list pressed"); 400// qDebug("list pressed");
397 switch (mouse) { 401 switch (mouse) {
398 case 1: 402 case 1:
399 break; 403 break;
400 case 2: 404 case 2:
401 menuTimer.start( 500, TRUE ); 405 menuTimer.start( 500, TRUE );
402 qDebug("Start menu timer\n"); 406 qDebug("Start menu timer\n");
403 break; 407 break;
404 }; 408 };
405} 409}
406 410
407void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 411void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
408 412
409 switch (mouse) { 413 switch (mouse) {
410 case 1: 414 case 1:
411 break; 415 break;
412 case 2: 416 case 2:
413 menuTimer.start( 500, TRUE ); 417 menuTimer.start( 500, TRUE );
414 qDebug("Start menu timer"); 418 qDebug("Start menu timer");
415 break; 419 break;
416 }; 420 };
417} 421}
418 422
419 423
420void AdvancedFm::switchToLocalTab() { 424void AdvancedFm::switchToLocalTab() {
421 TabWidget->setCurrentTab(0); 425 TabWidget->setCurrentTab(0);
422 Local_View->setFocus(); 426 Local_View->setFocus();
423} 427}
424 428
425void AdvancedFm::switchToRemoteTab() { 429void AdvancedFm::switchToRemoteTab() {
426 TabWidget->setCurrentTab(1); 430 TabWidget->setCurrentTab(1);
427 Remote_View->setFocus(); 431 Remote_View->setFocus();
428} 432}
429 433
430void AdvancedFm::readConfig() { 434void AdvancedFm::readConfig() {
431 Config cfg("AdvancedFm"); 435 Config cfg("AdvancedFm");
432} 436}
433 437
434void AdvancedFm::writeConfig() { 438void AdvancedFm::writeConfig() {
435 Config cfg("AdvancedFm"); 439 Config cfg("AdvancedFm");
436} 440}
437 441
438void AdvancedFm::currentPathComboChanged() { 442void AdvancedFm::currentPathComboChanged() {
439 if (TabWidget->getCurrentTab() == 0) { 443 if (TabWidget->getCurrentTab() == 0) {
440// if (TabWidget->currentPageIndex() == 0) { 444// if (TabWidget->currentPageIndex() == 0) {
441 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 445 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
442 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 446 currentDir.setPath( currentPathCombo->lineEdit()->text() );
443 populateLocalView(); 447 populateLocalView();
444 } else { 448 } else {
445 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 449 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
446 } 450 }
447 } 451 }
448 if (TabWidget->getCurrentTab() == 0) { 452 if (TabWidget->getCurrentTab() == 0) {
449// if (TabWidget->currentPageIndex() == 0) { 453// if (TabWidget->currentPageIndex() == 0) {
450 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 454 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
451 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 455 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
452 populateRemoteView(); 456 populateRemoteView();
453 } else { 457 } else {
454 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 458 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
455 } 459 }
456 } 460 }
457} 461}
458 462
459void AdvancedFm::fillCombo(const QString &currentPath) { 463void AdvancedFm::fillCombo(const QString &currentPath) {
460 464
461 if (TabWidget->getCurrentTab() == 0) { 465 if (TabWidget->getCurrentTab() == 0) {
462// if (TabWidget->currentPageIndex() == 0) { 466// if (TabWidget->currentPageIndex() == 0) {
463 currentPathCombo->lineEdit()->setText( currentPath); 467 currentPathCombo->lineEdit()->setText( currentPath);
464 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 468 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
465 currentPathCombo->clear(); 469 currentPathCombo->clear();
466 localDirPathStringList.prepend( currentPath ); 470 localDirPathStringList.prepend( currentPath );
467 currentPathCombo->insertStringList( localDirPathStringList,-1); 471 currentPathCombo->insertStringList( localDirPathStringList,-1);
468 } 472 }
469 } else { 473 } else {
470 currentPathCombo->lineEdit()->setText( currentPath); 474 currentPathCombo->lineEdit()->setText( currentPath);
471 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 475 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
472 currentPathCombo->clear(); 476 currentPathCombo->clear();
473 remoteDirPathStringList.prepend( currentPath ); 477 remoteDirPathStringList.prepend( currentPath );
474 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 478 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
475 } 479 }
476 } 480 }
477} 481}
478 482
479void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 483void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
480 if (TabWidget->getCurrentTab() == 0) { 484 if (TabWidget->getCurrentTab() == 0) {
481// if (TabWidget->currentPageIndex() == 0) { 485// if (TabWidget->currentPageIndex() == 0) {
482 chdir( currentPath.latin1() ); 486 chdir( currentPath.latin1() );
483 currentDir.cd( currentPath, TRUE); 487 currentDir.cd( currentPath, TRUE);
484 populateLocalView(); 488 populateLocalView();
485 update(); 489 update();
486 } else { 490 } else {
487 chdir( currentPath.latin1() ); 491 chdir( currentPath.latin1() );
488 currentRemoteDir.cd( currentPath, TRUE); 492 currentRemoteDir.cd( currentPath, TRUE);
489 populateRemoteView(); 493 populateRemoteView();
490 update(); 494 update();
491 } 495 }
492} 496}
493 497
494QStringList AdvancedFm::getPath() { 498QStringList AdvancedFm::getPath() {
495 QStringList strList; 499 QStringList strList;
496 if (TabWidget->getCurrentTab() == 0) { 500 if (TabWidget->getCurrentTab() == 0) {
497// if (TabWidget->currentPageIndex() == 0) { 501// if (TabWidget->currentPageIndex() == 0) {
498 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 502 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
499 QListViewItemIterator it( Local_View ); 503 QListViewItemIterator it( Local_View );
500 for ( ; it.current(); ++it ) { 504 for ( ; it.current(); ++it ) {
501 if ( it.current()->isSelected() ) { 505 if ( it.current()->isSelected() ) {
502 strList << it.current()->text(0); 506 strList << it.current()->text(0);
503 qDebug(it.current()->text(0)); 507 qDebug(it.current()->text(0));
504 } 508 }
505 } 509 }
506 return strList; 510 return strList;
507 } else { 511 } else {
508 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 512 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
509 QListViewItemIterator it( Remote_View ); 513 QListViewItemIterator it( Remote_View );
510 for ( ; it.current(); ++it ) { 514 for ( ; it.current(); ++it ) {
511 if ( it.current()->isSelected() ) { 515 if ( it.current()->isSelected() ) {
512 strList << it.current()->text(0); 516 strList << it.current()->text(0);
513 qDebug(it.current()->text(0)); 517 qDebug(it.current()->text(0));
514 } 518 }
515 } 519 }
516 return strList; 520 return strList;
517 } 521 }
518 return ""; 522 return "";
519} 523}
520 524
521void AdvancedFm::homeButtonPushed() { 525void AdvancedFm::homeButtonPushed() {
522 QString current = QDir::homeDirPath(); 526 QString current = QDir::homeDirPath();
523 chdir( current.latin1() ); 527 chdir( current.latin1() );
524 if (TabWidget->getCurrentTab() == 0) { 528 if (TabWidget->getCurrentTab() == 0) {
525// if (TabWidget->currentPageIndex() == 0) { 529// if (TabWidget->currentPageIndex() == 0) {
526 currentDir.cd( current, TRUE); 530 currentDir.cd( current, TRUE);
527 populateLocalView(); 531 populateLocalView();
528 } else { 532 } else {
529 currentRemoteDir.cd( current, TRUE); 533 currentRemoteDir.cd( current, TRUE);
530 populateRemoteView(); 534 populateRemoteView();
531 } 535 }
532 update(); 536 update();
533} 537}
534 538
535void AdvancedFm::docButtonPushed() { 539void AdvancedFm::docButtonPushed() {
536 QString current = QPEApplication::documentDir(); 540 QString current = QPEApplication::documentDir();
537 chdir( current.latin1() ); 541 chdir( current.latin1() );
538 542
539 if (TabWidget->getCurrentTab() == 0) { 543 if (TabWidget->getCurrentTab() == 0) {
540//if (TabWidget->currentPageIndex() == 0) { 544//if (TabWidget->currentPageIndex() == 0) {
541 currentDir.cd( current, TRUE); 545 currentDir.cd( current, TRUE);
542 populateLocalView(); 546 populateLocalView();
543 } else { 547 } else {
544 currentRemoteDir.cd( current, TRUE); 548 currentRemoteDir.cd( current, TRUE);
545 populateRemoteView(); 549 populateRemoteView();
546 } 550 }
547 update(); 551 update();
548} 552}
549 553
550void AdvancedFm::SDButtonPushed() { 554void AdvancedFm::SDButtonPushed() {
551 QString current = "/mnt/card";// this can change so fix 555 QString current = "/mnt/card";// this can change so fix
552 chdir( current.latin1() ); 556 chdir( current.latin1() );
553 if (TabWidget->getCurrentTab() == 0) { 557 if (TabWidget->getCurrentTab() == 0) {
554// if (TabWidget->currentPageIndex() == 0) { 558// if (TabWidget->currentPageIndex() == 0) {
555 currentDir.cd( current, TRUE); 559 currentDir.cd( current, TRUE);
556 populateLocalView(); 560 populateLocalView();
557 } else { 561 } else {
558 currentRemoteDir.cd( current, TRUE); 562 currentRemoteDir.cd( current, TRUE);
559 populateRemoteView(); 563 populateRemoteView();
560 } 564 }
561 update(); 565 update();
562 566
563} 567}
564 568
565void AdvancedFm::CFButtonPushed() { 569void AdvancedFm::CFButtonPushed() {
566 QString current; 570 QString current;
567 if(zaurusDevice) 571 if(zaurusDevice)
568 current= "/mnt/cf"; //zaurus 572 current= "/mnt/cf"; //zaurus
569 else 573 else
570 current = "/mnt/hda"; //ipaq 574 current = "/mnt/hda"; //ipaq
571 575
572 chdir( current.latin1() ); 576 chdir( current.latin1() );
573 if (TabWidget->getCurrentTab() == 0) { 577 if (TabWidget->getCurrentTab() == 0) {
574// if (TabWidget->currentPageIndex() == 0) { 578// if (TabWidget->currentPageIndex() == 0) {
575 currentDir.cd( current, TRUE); 579 currentDir.cd( current, TRUE);
576 populateLocalView(); 580 populateLocalView();
577 } else { 581 } else {
578 currentRemoteDir.cd( current, TRUE); 582 currentRemoteDir.cd( current, TRUE);
579 populateRemoteView(); 583 populateRemoteView();
580 } 584 }
581 update(); 585 update();
582} 586}
583 587
584 588
585 589
586void AdvancedFm::doAbout() { 590void AdvancedFm::doAbout() {
587 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 591 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
588 "is copyright 2002 by\n" 592 "is copyright 2002 by\n"
589 "L.J.Potter<llornkcor@handhelds.org>\n" 593 "L.J.Potter<llornkcor@handhelds.org>\n"
590 "and is licensed by the GPL")); 594 "and is licensed by the GPL"));
591} 595}
592 596
593void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 597void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
594 if( TabWidget->hasFocus()) 598 if( TabWidget->hasFocus())
595 switch ( e->key() ) { 599 switch ( e->key() ) {
596 case Key_Delete: 600 case Key_Delete:
597 del(); 601 del();
598 break; 602 break;
599 case Key_H: 603 case Key_H:
600 showHidden(); 604 showHidden();
601 break; 605 break;
602 case Key_E: 606 case Key_E:
603 runThis(); 607 runThis();
604 break; 608 break;
605 case Key_C: 609 case Key_C:
606 copy(); 610 copy();
607 break; 611 break;
608 case Key_A: 612 case Key_A:
609 copyAs(); 613 copyAs();
610 break; 614 break;
611 case Key_M: 615 case Key_M:
612 move(); 616 move();
613 break; 617 break;
614 case Key_R: 618 case Key_R:
615 rn(); 619 rn();
616 break; 620 break;
617 case Key_I: 621 case Key_I:
618 fileStatus(); 622 fileStatus();
619 break; 623 break;
620 case Key_U: 624 case Key_U:
621 upDir(); 625 upDir();
622 break; 626 break;
623 case Key_P: 627 case Key_P:
624 filePerms(); 628 filePerms();
625 break; 629 break;
626 case Key_N: 630 case Key_N:
627 mkDir(); 631 mkDir();
628 break; 632 break;
629 case Key_1: 633 case Key_1:
630 switchToLocalTab(); 634 switchToLocalTab();
631 break; 635 break;
632 case Key_2: 636 case Key_2:
633 switchToRemoteTab(); 637 switchToRemoteTab();
634 break; 638 break;
635 case Key_3: 639 case Key_3:
636 CFButtonPushed(); 640 CFButtonPushed();
637 break; 641 break;
638 case Key_4: 642 case Key_4:
639 SDButtonPushed(); 643 SDButtonPushed();
640 break; 644 break;
641 case Key_5: 645 case Key_5:
642 homeButtonPushed(); 646 homeButtonPushed();
643 break; 647 break;
644 case Key_6: 648 case Key_6:
645 docButtonPushed(); 649 docButtonPushed();
646 break; 650 break;
647 case Key_7: 651 case Key_7:
648 break; 652 break;
649 case Key_8: 653 case Key_8:
650 break; 654 break;
651 case Key_9: 655 case Key_9:
652 break; 656 break;
653 case Key_0: 657 case Key_0:
654 break; 658 break;
655 } 659 }
656} 660}
657 661
658 662
659void AdvancedFm::QPEButtonPushed() { 663void AdvancedFm::QPEButtonPushed() {
660 QString current = QPEApplication::qpeDir(); 664 QString current = QPEApplication::qpeDir();
661 chdir( current.latin1() ); 665 chdir( current.latin1() );
662 if (TabWidget->getCurrentTab() == 0) { 666 if (TabWidget->getCurrentTab() == 0) {
663// if (TabWidget->currentPageIndex() == 0) { 667// if (TabWidget->currentPageIndex() == 0) {
664 currentDir.cd( current, TRUE); 668 currentDir.cd( current, TRUE);
665 populateLocalView(); 669 populateLocalView();
666 } else { 670 } else {
667 currentRemoteDir.cd( current, TRUE); 671 currentRemoteDir.cd( current, TRUE);
668 populateRemoteView(); 672 populateRemoteView();
669 } 673 }
670 update(); 674 update();
671} 675}
672 676
673void AdvancedFm::parsetab(const QString &fileName) { 677void AdvancedFm::parsetab(const QString &fileName) {
674 678
675 fileSystemTypeList.clear(); 679 fileSystemTypeList.clear();
676 fsList.clear(); 680 fsList.clear();
677 struct mntent *me; 681 struct mntent *me;
678 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 682 FILE *mntfp = setmntent( fileName.latin1(), "r" );
679 if ( mntfp ) { 683 if ( mntfp ) {
680 while ( (me = getmntent( mntfp )) != 0 ) { 684 while ( (me = getmntent( mntfp )) != 0 ) {
681 QString deviceName = me->mnt_fsname; 685 QString deviceName = me->mnt_fsname;
682 QString filesystemType = me->mnt_type; 686 QString filesystemType = me->mnt_type;
683 QString mountDir = me->mnt_dir; 687 QString mountDir = me->mnt_dir;
684 if(deviceName != "none") { 688 if(deviceName != "none") {
685 if( fsList.contains(filesystemType) == 0 689 if( fsList.contains(filesystemType) == 0
686 & filesystemType.find("proc",0,TRUE) == -1 690 & filesystemType.find("proc",0,TRUE) == -1
687 & filesystemType.find("cramfs",0,TRUE) == -1 691 & filesystemType.find("cramfs",0,TRUE) == -1
688 & filesystemType.find("auto",0,TRUE) == -1) 692 & filesystemType.find("auto",0,TRUE) == -1)
689 fsList << filesystemType; 693 fsList << filesystemType;
690 fileSystemTypeList << mountDir+"::"+filesystemType; 694 fileSystemTypeList << mountDir+"::"+filesystemType;
691 } 695 }
692 } 696 }
693 } 697 }
694 endmntent( mntfp ); 698 endmntent( mntfp );
695} 699}
696 700
697QString AdvancedFm::getFileSystemType(const QString &currentText) { 701QString AdvancedFm::getFileSystemType(const QString &currentText) {
698 parsetab("/etc/mtab"); //why did TT forget filesystem type? 702 parsetab("/etc/mtab"); //why did TT forget filesystem type?
699 QString current = currentText;//.right( currentText.length()-1); 703 QString current = currentText;//.right( currentText.length()-1);
700 QString baseFs; 704 QString baseFs;
701 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 705 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
702 QString temp = (*it); 706 QString temp = (*it);
703 QString path = temp.left(temp.find("::",0,TRUE) ); 707 QString path = temp.left(temp.find("::",0,TRUE) );
704 path = path.right( path.length()-1); 708 path = path.right( path.length()-1);
705 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 709 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
706 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 710 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
707 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 711 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
708 } 712 }
709 } 713 }
710 return baseFs; 714 return baseFs;
711} 715}
712 716
713QString AdvancedFm::getDiskSpace( const QString &path) { 717QString AdvancedFm::getDiskSpace( const QString &path) {
714 struct statfs fss; 718 struct statfs fss;
715 if ( !statfs( path.latin1(), &fss ) ) { 719 if ( !statfs( path.latin1(), &fss ) ) {
716 int blkSize = fss.f_bsize; 720 int blkSize = fss.f_bsize;
717 // int totalBlks = fs.f_blocks; 721 // int totalBlks = fs.f_blocks;
718 int availBlks = fss.f_bavail; 722 int availBlks = fss.f_bavail;
719 723
720 long mult = blkSize / 1024; 724 long mult = blkSize / 1024;
721 long div = 1024 / blkSize; 725 long div = 1024 / blkSize;
722 if ( !mult ) mult = 1; 726 if ( !mult ) mult = 1;
723 if ( !div ) div = 1; 727 if ( !div ) div = 1;
724 728
725 return QString::number(availBlks * mult / div); 729 return QString::number(availBlks * mult / div);
726 } 730 }
727 return ""; 731 return "";
728} 732}
729 733
730 734
731void AdvancedFm::showFileMenu() { 735void AdvancedFm::showFileMenu() {
732 736
733 QString curApp; 737 QString curApp;
734 bool isLocalView = false; 738 bool isLocalView = false;
735 if (TabWidget->getCurrentTab() == 0) { 739 if (TabWidget->getCurrentTab() == 0) {
736// if (TabWidget->currentPageIndex() == 0) { 740// if (TabWidget->currentPageIndex() == 0) {
737 isLocalView = TRUE; 741 isLocalView = TRUE;
738 curApp = Local_View->currentItem()->text(0); 742 curApp = Local_View->currentItem()->text(0);
739 } else { 743 } else {
740 curApp = Remote_View->currentItem()->text(0); 744 curApp = Remote_View->currentItem()->text(0);
741 } 745 }
742 746
743 MimeType mt( curApp ); 747 MimeType mt( curApp );
744 const AppLnk* app = mt.application(); 748 const AppLnk* app = mt.application();
745 QFile fi(curApp); 749 QFile fi(curApp);
746 QPopupMenu *m = new QPopupMenu(0); 750 QPopupMenu *m = new QPopupMenu(0);
747 QPopupMenu *n = new QPopupMenu(0); 751 QPopupMenu *n = new QPopupMenu(0);
748 // QPopupMenu *o = new QPopupMenu(0); 752 // QPopupMenu *o = new QPopupMenu(0);
749 if (TabWidget->getCurrentTab() == 0) 753 if (TabWidget->getCurrentTab() == 0)
750 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 754 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
751 else 755 else
752 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 756 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
753 757
754 if ( QFileInfo(fi).isDir() ) { 758 if ( QFileInfo(fi).isDir() ) {
755 m->insertSeparator(); 759 m->insertSeparator();
756 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 760 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
757 } else { 761 } else {
758 762
759 if ( app ) 763 if ( app )
760 m->insertItem( app->pixmap(), tr( "Open in " 764 m->insertItem( app->pixmap(), tr( "Open in "
761 + app->name() ), this, SLOT( runThis() ) ); 765 + app->name() ), this, SLOT( runThis() ) );
762 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 766 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
763 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 767 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
764 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 768 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
765 } 769 }
766 770
767 m->insertItem(tr("Actions"),n); 771 m->insertItem(tr("Actions"),n);
768 if(isLocalView) 772 if(isLocalView)
769 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 773 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
770 else 774 else
771 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 775 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
772 776
773 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 777 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
774 778
775 n->insertSeparator(); 779 n->insertSeparator();
776 780
777 781
778 if(isLocalView) 782 if(isLocalView)
779 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 783 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
780 else 784 else
781 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 785 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
782 786
783 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 787 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
784 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 788 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
785 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 789 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
786 n->insertItem( tr( "Move" ), this, SLOT( move() )); 790 n->insertItem( tr( "Move" ), this, SLOT( move() ));
787 791
788 n->insertSeparator(); 792 n->insertSeparator();
789 793
790 if(isLocalView) 794 if(isLocalView)
791 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 795 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
792 else 796 else
793 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 797 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
794 798
795 799
796 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 800 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
797 801
798 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 802 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
799 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 803 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
800 804
801 m->insertSeparator(); 805 m->insertSeparator();
802 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 806 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
803 807
804#if defined(QT_QWS_OPIE) 808#if defined(QT_QWS_OPIE)
805 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 809 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
806#endif 810#endif
807 m->setCheckable(TRUE); 811 m->setCheckable(TRUE);
808 if (!b) 812 if (!b)
809 m->setItemChecked(m->idAt(0),TRUE); 813 m->setItemChecked(m->idAt(0),TRUE);
810 else 814 else
811 m->setItemChecked(m->idAt(0),FALSE); 815 m->setItemChecked(m->idAt(0),FALSE);
812 816
813 if(Ir::supported()) 817 if(Ir::supported())
814 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 818 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
815 m->setFocus(); 819 m->setFocus();
816 m->exec( QPoint( 4,QCursor::pos().y()) ); 820 m->exec( QPoint( 4,QCursor::pos().y()) );
817 821
818 if(m) delete m; 822 if(m) delete m;
819} 823}
820 824
821 825
822void AdvancedFm::cancelMenuTimer() { 826void AdvancedFm::cancelMenuTimer() {
823 827
824// qDebug("selectionChanged: cancel menu timer"); 828// qDebug("selectionChanged: cancel menu timer");
825 if( menuTimer.isActive() ) 829 if( menuTimer.isActive() )
826 menuTimer.stop(); 830 menuTimer.stop();
827} 831}
828 832
829QString AdvancedFm::checkDiskSpace(const QString &path) { 833QString AdvancedFm::checkDiskSpace(const QString &path) {
830 struct statfs fss; 834 struct statfs fss;
831 if ( !statfs( path.latin1(), &fss ) ) { 835 if ( !statfs( path.latin1(), &fss ) ) {
832 int blkSize = fss.f_bsize; 836 int blkSize = fss.f_bsize;
833// int totalBlks = fs.f_blocks; 837// int totalBlks = fs.f_blocks;
834 int availBlks = fss.f_bavail; 838 int availBlks = fss.f_bavail;
835 839
836 long mult = blkSize / 1024; 840 long mult = blkSize / 1024;
837 long div = 1024 / blkSize; 841 long div = 1024 / blkSize;
838 if ( !mult ) mult = 1; 842 if ( !mult ) mult = 1;
839 if ( !div ) div = 1; 843 if ( !div ) div = 1;
840 844
841 845
842 return QString::number(availBlks * mult / div); 846 return QString::number(availBlks * mult / div);
843 } 847 }
844 return ""; 848 return "";
845} 849}
846 850
847void AdvancedFm::addToDocs() { 851void AdvancedFm::addToDocs() {
848 QStringList strListPaths = getPath(); 852 QStringList strListPaths = getPath();
849 if( strListPaths.count() > 0) { 853 if( strListPaths.count() > 0) {
850 QString curFile; 854 QString curFile;
851 if (TabWidget->getCurrentTab() == 0) { 855 if (TabWidget->getCurrentTab() == 0) {
852// if (TabWidget->currentPageIndex() == 0) { 856// if (TabWidget->currentPageIndex() == 0) {
853 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 857 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
854 curFile = currentDir.canonicalPath()+"/"+(*it); 858 curFile = currentDir.canonicalPath()+"/"+(*it);
855 qDebug(curFile); 859 qDebug(curFile);
856 DocLnk f; 860 DocLnk f;
857// curFile.replace(QRegExp("\\..*"),""); 861// curFile.replace(QRegExp("\\..*"),"");
858 f.setName((*it)); 862 f.setName((*it));
859 f.setFile( curFile); 863 f.setFile( curFile);
860 f.writeLink(); 864 f.writeLink();
861 } 865 }
862 } else { 866 } else {
863 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 867 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
864 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 868 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
865 qDebug(curFile); 869 qDebug(curFile);
866 870
867 DocLnk f; 871 DocLnk f;
868// curFile.replace(QRegExp("\\..*"),""); 872// curFile.replace(QRegExp("\\..*"),"");
869 f.setName((*it)); 873 f.setName((*it));
870 f.setFile( curFile); 874 f.setFile( curFile);
871 f.writeLink(); 875 f.writeLink();
872 } 876 }
873 } 877 }
874 } 878 }
875} 879}
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 946d038..a60cea6 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,282 +1,284 @@
1/**************************************************************************** 1/****************************************************************************
2** outputEdit.cpp 2** outputEdit.cpp
3** 3**
4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> 4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#include "output.h" 6#include "output.h"
7 7
8#include <opie/oprocess.h> 8#include <opie/oprocess.h>
9 9
10#include <qpe/filemanager.h> 10#include <qpe/filemanager.h>
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/applnk.h> 12#include <qpe/applnk.h>
13 13
14#include <qmessagebox.h> 14#include <qmessagebox.h>
15#include <qstringlist.h> 15#include <qstringlist.h>
16#include <qfile.h> 16#include <qfile.h>
17#include <qcstring.h> 17#include <qcstring.h>
18#include <qlineedit.h> 18#include <qlineedit.h>
19#include <qmultilineedit.h> 19#include <qmultilineedit.h>
20#include <qpushbutton.h> 20#include <qpushbutton.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qvariant.h> 22#include <qvariant.h>
23 23
24#include <errno.h> 24#include <errno.h>
25 25
26/* XPM */ 26/* XPM */
27static char * filesave_xpm[] = { 27static char * filesave_xpm[] = {
28"16 16 78 1", 28"16 16 78 1",
29" c None", 29" c None",
30". c #343434", 30". c #343434",
31"+ c #A0A0A0", 31"+ c #A0A0A0",
32"@ c #565656", 32"@ c #565656",
33"# c #9E9E9E", 33"# c #9E9E9E",
34"$ c #525252", 34"$ c #525252",
35"% c #929292", 35"% c #929292",
36"& c #676767", 36"& c #676767",
37"* c #848484", 37"* c #848484",
38"= c #666666", 38"= c #666666",
39"- c #D8D8D8", 39"- c #D8D8D8",
40"; c #FFFFFF", 40"; c #FFFFFF",
41"> c #DBDBDB", 41"> c #DBDBDB",
42", c #636363", 42", c #636363",
43"' c #989898", 43"' c #989898",
44") c #2D2D2D", 44") c #2D2D2D",
45"! c #909090", 45"! c #909090",
46"~ c #AEAEAE", 46"~ c #AEAEAE",
47"{ c #EAEAEA", 47"{ c #EAEAEA",
48"] c #575757", 48"] c #575757",
49"^ c #585858", 49"^ c #585858",
50"/ c #8A8A8A", 50"/ c #8A8A8A",
51"( c #828282", 51"( c #828282",
52"_ c #6F6F6F", 52"_ c #6F6F6F",
53": c #C9C9C9", 53": c #C9C9C9",
54"< c #050505", 54"< c #050505",
55"[ c #292929", 55"[ c #292929",
56"} c #777777", 56"} c #777777",
57"| c #616161", 57"| c #616161",
58"1 c #3A3A3A", 58"1 c #3A3A3A",
59"2 c #BEBEBE", 59"2 c #BEBEBE",
60"3 c #2C2C2C", 60"3 c #2C2C2C",
61"4 c #7C7C7C", 61"4 c #7C7C7C",
62"5 c #F6F6F6", 62"5 c #F6F6F6",
63"6 c #FCFCFC", 63"6 c #FCFCFC",
64"7 c #6B6B6B", 64"7 c #6B6B6B",
65"8 c #959595", 65"8 c #959595",
66"9 c #4F4F4F", 66"9 c #4F4F4F",
67"0 c #808080", 67"0 c #808080",
68"a c #767676", 68"a c #767676",
69"b c #818181", 69"b c #818181",
70"c c #B8B8B8", 70"c c #B8B8B8",
71"d c #FBFBFB", 71"d c #FBFBFB",
72"e c #F9F9F9", 72"e c #F9F9F9",
73"f c #CCCCCC", 73"f c #CCCCCC",
74"g c #030303", 74"g c #030303",
75"h c #737373", 75"h c #737373",
76"i c #7A7A7A", 76"i c #7A7A7A",
77"j c #7E7E7E", 77"j c #7E7E7E",
78"k c #6A6A6A", 78"k c #6A6A6A",
79"l c #FAFAFA", 79"l c #FAFAFA",
80"m c #505050", 80"m c #505050",
81"n c #9D9D9D", 81"n c #9D9D9D",
82"o c #333333", 82"o c #333333",
83"p c #7B7B7B", 83"p c #7B7B7B",
84"q c #787878", 84"q c #787878",
85"r c #696969", 85"r c #696969",
86"s c #494949", 86"s c #494949",
87"t c #555555", 87"t c #555555",
88"u c #949494", 88"u c #949494",
89"v c #E6E6E6", 89"v c #E6E6E6",
90"w c #424242", 90"w c #424242",
91"x c #515151", 91"x c #515151",
92"y c #535353", 92"y c #535353",
93"z c #3E3E3E", 93"z c #3E3E3E",
94"A c #D4D4D4", 94"A c #D4D4D4",
95"B c #0C0C0C", 95"B c #0C0C0C",
96"C c #353535", 96"C c #353535",
97"D c #474747", 97"D c #474747",
98"E c #ECECEC", 98"E c #ECECEC",
99"F c #919191", 99"F c #919191",
100"G c #7D7D7D", 100"G c #7D7D7D",
101"H c #000000", 101"H c #000000",
102"I c #404040", 102"I c #404040",
103"J c #858585", 103"J c #858585",
104"K c #323232", 104"K c #323232",
105"L c #D0D0D0", 105"L c #D0D0D0",
106"M c #1C1C1C", 106"M c #1C1C1C",
107" ...+ ", 107" ...+ ",
108" @#$%&..+ ", 108" @#$%&..+ ",
109" .*=-;;>,..+ ", 109" .*=-;;>,..+ ",
110" ')!~;;;;;;{]..", 110" ')!~;;;;;;{]..",
111" ^/(-;;;;;;;_:<", 111" ^/(-;;;;;;;_:<",
112" [}|;;;;;;;{12$", 112" [}|;;;;;;;{12$",
113" #34-55;;;;678$+", 113" #34-55;;;;678$+",
114" 90ab=c;dd;e1fg ", 114" 90ab=c;dd;e1fg ",
115" [ahij((kbl0mn$ ", 115" [ahij((kbl0mn$ ",
116" op^q^^7r&]s/$+ ", 116" op^q^^7r&]s/$+ ",
117"@btu;vbwxy]zAB ", 117"@btu;vbwxy]zAB ",
118"CzDEvEv;;DssF$ ", 118"CzDEvEv;;DssF$ ",
119"G.H{E{E{IxsJ$+ ", 119"G.H{E{E{IxsJ$+ ",
120" +...vEKxzLM ", 120" +...vEKxzLM ",
121" +...z]n$ ", 121" +...z]n$ ",
122" +... "}; 122" +... "};
123 123
124Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 124Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
125 : QDialog( parent, name, modal, fl ) 125 : QDialog( parent, name, modal, fl )
126{ 126{
127 QStringList cmmds; 127 QStringList cmmds;
128// cmmds=QStringList::split( " ", commands, false); 128// cmmds=QStringList::split( " ", commands, false);
129 cmmds=commands; 129 cmmds=commands;
130// qDebug("count %d", cmmds.count()); 130// qDebug("count %d", cmmds.count());
131 if ( !name ) 131 if ( !name )
132 setName( tr("Output")); 132 setName( tr("Output"));
133 resize( 196, 269 ); 133 resize( 196, 269 );
134 setCaption( name ); 134 setCaption( name );
135 135
136 OutputLayout = new QGridLayout( this ); 136 OutputLayout = new QGridLayout( this );
137 OutputLayout->setSpacing( 2); 137 OutputLayout->setSpacing( 2);
138 OutputLayout->setMargin( 2); 138 OutputLayout->setMargin( 2);
139 139
140 QPushButton *docButton; 140 QPushButton *docButton;
141 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 141 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
142 docButton->setFixedSize( QSize( 20, 20 ) ); 142 docButton->setFixedSize( QSize( 20, 20 ) );
143 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 143 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
144 // docButton->setFlat(TRUE); 144 // docButton->setFlat(TRUE);
145 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 145 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
146 146
147 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 147 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
148 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 148 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
149 149
150 proc = new OProcess(); 150 proc = new OProcess();
151 151
152 connect(proc, SIGNAL(processExited(OProcess *)), 152 connect(proc, SIGNAL(processExited(OProcess *)),
153 this, SLOT( processFinished())); 153 this, SLOT( processFinished()));
154 154
155 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 155 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
156 this, SLOT(commandStdout(OProcess *, char *, int))); 156 this, SLOT(commandStdout(OProcess *, char *, int)));
157 157
158 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 158 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
159 this, SLOT(commandStderr(OProcess *, char *, int))); 159 this, SLOT(commandStderr(OProcess *, char *, int)));
160 160
161// connect( , SIGNAL(received(const QByteArray &)), 161// connect( , SIGNAL(received(const QByteArray &)),
162// this, SLOT(commandStdin(const QByteArray &))); 162// this, SLOT(commandStdin(const QByteArray &)));
163 163
164// * proc << commands.latin1(); 164// * proc << commands.latin1();
165 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 165 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
166 qDebug( "%s", (*it).latin1() ); 166 qDebug( "%s", (*it).latin1() );
167 * proc << (*it).latin1(); 167 * proc << (*it).latin1();
168 } 168 }
169 169
170 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 170 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
171 171
172 OutputEdit->append("Process could not start"); 172 OutputEdit->append("Process could not start");
173 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 173 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
174 perror("Error: "); 174 perror("Error: ");
175 QString errorMsg="Error\n"+(QString)strerror(errno); 175 QString errorMsg="Error\n"+(QString)strerror(errno);
176 OutputEdit->append( errorMsg); 176 OutputEdit->append( errorMsg);
177 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 177 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
178 } 178 }
179} 179}
180 180
181Output::~Output() { 181Output::~Output() {
182} 182}
183 183
184void Output::saveOutput() { 184void Output::saveOutput() {
185 185
186 InputDialog *fileDlg; 186 InputDialog *fileDlg;
187 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 187 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
188 fileDlg->exec(); 188 fileDlg->exec();
189 if( fileDlg->result() == 1 ) { 189 if( fileDlg->result() == 1 ) {
190 QString filename = QPEApplication::documentDir(); 190 QString filename = QPEApplication::documentDir();
191 if(filename.right(1).find('/') == -1) 191 if(filename.right(1).find('/') == -1)
192 filename+="/"; 192 filename+="/";
193 QString name = fileDlg->LineEdit1->text(); 193 QString name = fileDlg->LineEdit1->text();
194 filename+="text/plain/"+name; 194 filename+="text/plain/"+name;
195 qDebug(filename); 195 qDebug(filename);
196 196
197 QFile f(filename); 197 QFile f(filename);
198 f.open( IO_WriteOnly); 198 f.open( IO_WriteOnly);
199 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 199 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
200 DocLnk lnk; 200 DocLnk lnk;
201 lnk.setName(name); //sets file name 201 lnk.setName(name); //sets file name
202 lnk.setFile(filename); //sets File property 202 lnk.setFile(filename); //sets File property
203 lnk.setType("text/plain"); 203 lnk.setType("text/plain");
204 if(!lnk.writeLink()) { 204 if(!lnk.writeLink()) {
205 qDebug("Writing doclink did not work"); 205 qDebug("Writing doclink did not work");
206 } 206 }
207 } else 207 } else
208 qWarning("Could not write file"); 208 qWarning("Could not write file");
209 f.close(); 209 f.close();
210 } 210 }
211} 211}
212 212
213void Output::commandStdout(OProcess*, char *buffer, int buflen) { 213void Output::commandStdout(OProcess*, char *buffer, int buflen) {
214 qWarning("received stdout %d bytes", buflen); 214 qWarning("received stdout %d bytes", buflen);
215 215
216// QByteArray data(buflen); 216// QByteArray data(buflen);
217// data.fill(*buffer, buflen); 217// data.fill(*buffer, buflen);
218// for (uint i = 0; i < data.count(); i++ ) { 218// for (uint i = 0; i < data.count(); i++ ) {
219// printf("%c", buffer[i] ); 219// printf("%c", buffer[i] );
220// } 220// }
221// printf("\n"); 221// printf("\n");
222 222
223 QString lineStr = buffer; 223 QString lineStr = buffer;
224 lineStr=lineStr.left(lineStr.length()-1); 224 lineStr=lineStr.left(lineStr.length()-1);
225 OutputEdit->append(lineStr); 225 OutputEdit->append(lineStr);
226 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 226 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
227} 227}
228 228
229 229
230void Output::commandStdin( const QByteArray &data) { 230void Output::commandStdin( const QByteArray &data) {
231 qWarning("received stdin %d bytes", data.size()); 231 qWarning("received stdin %d bytes", data.size());
232 // recieved data from the io layer goes to sz 232 // recieved data from the io layer goes to sz
233 proc->writeStdin(data.data(), data.size()); 233 proc->writeStdin(data.data(), data.size());
234} 234}
235 235
236void Output::commandStderr(OProcess*, char *buffer, int buflen) { 236void Output::commandStderr(OProcess*, char *buffer, int buflen) {
237 qWarning("received stderrt %d bytes", buflen); 237 qWarning("received stderrt %d bytes", buflen);
238 238
239 QString lineStr = buffer; 239 QString lineStr = buffer;
240// lineStr=lineStr.left(lineStr.length()-1); 240// lineStr=lineStr.left(lineStr.length()-1);
241 OutputEdit->append(lineStr); 241 OutputEdit->append(lineStr);
242 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 242 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
243} 243}
244 244
245void Output::processFinished() { 245void Output::processFinished() {
246 246
247 delete proc; 247 delete proc;
248 OutputEdit->append( "\nFinished\n"); 248 OutputEdit->append( "\nFinished\n");
249 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 249 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
250// close(); 250// close();
251// disconnect( layer(), SIGNAL(received(const QByteArray &)), 251// disconnect( layer(), SIGNAL(received(const QByteArray &)),
252// this, SLOT(commandStdin(const QByteArray &))); 252// this, SLOT(commandStdin(const QByteArray &)));
253} 253}
254 254
255//============================== 255//==============================
256 256
257InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 257InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
258 : QDialog( parent, name, modal, fl ) 258 : QDialog( parent, name, modal, fl )
259{ 259{
260 if ( !name ) 260 if ( !name )
261 setName( "InputDialog" ); 261 setName( "InputDialog" );
262 resize( 234, 50 ); 262 resize( 234, 50 );
263 setMaximumSize( QSize( 240, 50 ) ); 263 setMaximumSize( QSize( 240, 50 ) );
264 setCaption( tr(name ) ); 264 setCaption( tr(name ) );
265 265
266 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 266 LineEdit1 = new QLineEdit( this, "LineEdit1" );
267 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 267 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
268 LineEdit1->setFocus();
269 LineEdit1->setFocus();
268 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 270 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
269} 271}
270 272
271InputDialog::~InputDialog() { 273InputDialog::~InputDialog() {
272 inputText = LineEdit1->text(); 274 inputText = LineEdit1->text();
273} 275}
274 276
275void InputDialog::setInputText(const QString &string) { 277void InputDialog::setInputText(const QString &string) {
276 LineEdit1->setText( string); 278 LineEdit1->setText( string);
277} 279}
278 280
279void InputDialog::returned() { 281void InputDialog::returned() {
280 inputText = LineEdit1->text(); 282 inputText = LineEdit1->text();
281 this->accept(); 283 this->accept();
282} 284}