summaryrefslogtreecommitdiff
authordrw <drw>2004-02-23 18:27:31 (UTC)
committer drw <drw>2004-02-23 18:27:31 (UTC)
commitbce2a9995fa423f9fc796b46c548e47a45c9d247 (patch) (unidiff)
treed6af972e78fa2ca9721172a14ce2d83bae35c2bd
parent398c7d54acfc203ec90644d6c63e5b200391e906 (diff)
downloadopie-bce2a9995fa423f9fc796b46c548e47a45c9d247.zip
opie-bce2a9995fa423f9fc796b46c548e47a45c9d247.tar.gz
opie-bce2a9995fa423f9fc796b46c548e47a45c9d247.tar.bz2
AdvancedFM: libopie->libopie2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp206
-rw-r--r--noncore/apps/advancedfm/advancedfm.h12
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro10
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp10
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp161
-rw-r--r--noncore/apps/advancedfm/config.in2
-rw-r--r--noncore/apps/advancedfm/main.cpp8
-rw-r--r--noncore/apps/advancedfm/opie-advancedfm.control2
-rw-r--r--noncore/apps/advancedfm/output.cpp2
-rw-r--r--noncore/apps/advancedfm/output.h18
10 files changed, 209 insertions, 222 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 9c13e53..5148172 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,899 +1,893 @@
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
16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h>
18
19#include <opie/osplitter.h>
20
21#include <qpe/filemanager.h> 15#include <qpe/filemanager.h>
22#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
24#include <qpe/config.h> 18#include <qpe/config.h>
25#include <qpe/mimetype.h> 19#include <qpe/mimetype.h>
26#include <qpe/applnk.h> 20#include <qpe/applnk.h>
27#include <qpe/ir.h> 21#include <qpe/ir.h>
28#include <qpe/resource.h> 22#include <qpe/resource.h>
29#include <qpe/menubutton.h> 23#include <qpe/menubutton.h>
30 24
31#include <qdatetime.h> 25#include <qdatetime.h>
32#include <qfile.h> 26#include <qfile.h>
33#include <qcombobox.h> 27#include <qcombobox.h>
34#include <qpopupmenu.h> 28#include <qpopupmenu.h>
35#include <qlistview.h> 29#include <qlistview.h>
36#include <qlabel.h> 30#include <qlabel.h>
37#include <qwidget.h> 31#include <qwidget.h>
38#include <qlayout.h> 32#include <qlayout.h>
39#include <qimage.h> 33#include <qimage.h>
40#include <qmessagebox.h> 34#include <qmessagebox.h>
41#include <qlineedit.h> 35#include <qlineedit.h>
42 36
43#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
44 38
45#include <sys/stat.h> 39#include <sys/stat.h>
46#include <time.h> 40#include <time.h>
47#include <dirent.h> 41#include <dirent.h>
48#include <fcntl.h> 42#include <fcntl.h>
49#include <sys/vfs.h> 43#include <sys/vfs.h>
50#include <mntent.h> 44#include <mntent.h>
51 45
52#ifdef NOQUICKLAUNCH 46#ifdef NOQUICKLAUNCH
53AdvancedFm::AdvancedFm( ) 47AdvancedFm::AdvancedFm( )
54#else 48#else
55AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) 49AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
56#endif 50#endif
57 : QMainWindow( ) { 51 : QMainWindow( ) {
58 init(); 52 init();
59 renameBox = 0; 53 renameBox = 0;
60 54
61 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 55 unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
62 56
63 initConnections(); 57 initConnections();
64 whichTab=1; 58 whichTab=1;
65 rePopulate(); 59 rePopulate();
66 currentPathCombo->setFocus(); 60 currentPathCombo->setFocus();
67 channel = new QCopChannel( "QPE/Application/advancedfm", this ); 61 channel = new QCopChannel( "QPE/Application/advancedfm", this );
68 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 62 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
69 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); 63 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
70} 64}
71 65
72AdvancedFm::~AdvancedFm() { 66AdvancedFm::~AdvancedFm() {
73} 67}
74 68
75 69
76void AdvancedFm::cleanUp() { 70void AdvancedFm::cleanUp() {
77 QString sfile=QDir::homeDirPath(); 71 QString sfile=QDir::homeDirPath();
78 if(sfile.right(1) != "/") 72 if(sfile.right(1) != "/")
79 sfile+="/._temp"; 73 sfile+="/._temp";
80 else 74 else
81 sfile+="._temp"; 75 sfile+="._temp";
82 QFile file( sfile); 76 QFile file( sfile);
83 if(file.exists()) 77 if(file.exists())
84 file.remove(); 78 file.remove();
85} 79}
86 80
87void AdvancedFm::tabChanged(QWidget *) { 81void AdvancedFm::tabChanged(QWidget *) {
88// qWarning("tab changed"); 82// qWarning("tab changed");
89 QString path = CurrentDir()->canonicalPath(); 83 QString path = CurrentDir()->canonicalPath();
90 currentPathCombo->lineEdit()->setText( path ); 84 currentPathCombo->lineEdit()->setText( path );
91 85
92 if(whichTab == 1) { 86 if(whichTab == 1) {
93 viewMenu->setItemChecked(viewMenu->idAt(0), true); 87 viewMenu->setItemChecked(viewMenu->idAt(0), true);
94 viewMenu->setItemChecked(viewMenu->idAt(1), false); 88 viewMenu->setItemChecked(viewMenu->idAt(1), false);
95 } else { 89 } else {
96 viewMenu->setItemChecked(viewMenu->idAt(0), false); 90 viewMenu->setItemChecked(viewMenu->idAt(0), false);
97 viewMenu->setItemChecked(viewMenu->idAt(1), true); 91 viewMenu->setItemChecked(viewMenu->idAt(1), true);
98 } 92 }
99 93
100 QString fs= getFileSystemType( (const QString &) path); 94 QString fs= getFileSystemType( (const QString &) path);
101 95
102 setCaption(tr("AdvancedFm :: ")+fs+" :: " 96 setCaption(tr("AdvancedFm :: ")+fs+" :: "
103 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 97 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
104 chdir( path.latin1()); 98 chdir( path.latin1());
105} 99}
106 100
107 101
108void AdvancedFm::populateView() { 102void AdvancedFm::populateView() {
109 103
110// qWarning("PopulateView"); 104// qWarning("PopulateView");
111 QPixmap pm; 105 QPixmap pm;
112 QListView *thisView = CurrentView(); 106 QListView *thisView = CurrentView();
113 QDir *thisDir = CurrentDir(); 107 QDir *thisDir = CurrentDir();
114 QString path = thisDir->canonicalPath(); 108 QString path = thisDir->canonicalPath();
115 109
116//qWarning("path is "+path); 110//qWarning("path is "+path);
117 thisView->clear(); 111 thisView->clear();
118 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 112 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
119 thisDir->setMatchAllDirs(TRUE); 113 thisDir->setMatchAllDirs(TRUE);
120 thisDir->setNameFilter(filterStr); 114 thisDir->setNameFilter(filterStr);
121 QString fileL, fileS, fileDate; 115 QString fileL, fileS, fileDate;
122 QString fs= getFileSystemType((const QString &) path); 116 QString fs= getFileSystemType((const QString &) path);
123 setCaption(tr("AdvancedFm :: ")+fs+" :: " 117 setCaption(tr("AdvancedFm :: ")+fs+" :: "
124 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 118 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
125 bool isDir=FALSE; 119 bool isDir=FALSE;
126 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 120 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
127 QFileInfoListIterator it(*list); 121 QFileInfoListIterator it(*list);
128 QFileInfo *fi; 122 QFileInfo *fi;
129 while ( (fi=it.current()) ) { 123 while ( (fi=it.current()) ) {
130 if (fi->isSymLink() ) { 124 if (fi->isSymLink() ) {
131 QString symLink=fi->readLink(); 125 QString symLink=fi->readLink();
132 QFileInfo sym( symLink); 126 QFileInfo sym( symLink);
133 fileS.sprintf( "%10i", sym.size() ); 127 fileS.sprintf( "%10i", sym.size() );
134 fileL = fi->fileName() +" -> " + sym.filePath().data(); 128 fileL = fi->fileName() +" -> " + sym.filePath().data();
135 fileDate = sym.lastModified().toString(); 129 fileDate = sym.lastModified().toString();
136 } else { 130 } else {
137 fileS.sprintf( "%10i", fi->size() ); 131 fileS.sprintf( "%10i", fi->size() );
138 fileL = fi->fileName(); 132 fileL = fi->fileName();
139 fileDate= fi->lastModified().toString(); 133 fileDate= fi->lastModified().toString();
140 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 134 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
141// if(fileL == "..") 135// if(fileL == "..")
142 fileL += "/"; 136 fileL += "/";
143 isDir=TRUE; 137 isDir=TRUE;
144 } 138 }
145 } 139 }
146 QFileInfo fileInfo( path + "/" + fileL); 140 QFileInfo fileInfo( path + "/" + fileL);
147 141
148 if(fileL !="./" && fi->exists()) { 142 if(fileL !="./" && fi->exists()) {
149 item = new QListViewItem( thisView, fileL, fileS , fileDate); 143 item = new QListViewItem( thisView, fileL, fileS , fileDate);
150 144
151 if(isDir || fileL.find("/",0,TRUE) != -1) { 145 if(isDir || fileL.find("/",0,TRUE) != -1) {
152 146
153 if( !QDir( fi->filePath() ).isReadable()) //is directory 147 if( !QDir( fi->filePath() ).isReadable()) //is directory
154 pm = Resource::loadPixmap( "lockedfolder" ); 148 pm = Resource::loadPixmap( "lockedfolder" );
155 else 149 else
156 pm= Resource::loadPixmap( "folder" ); 150 pm= Resource::loadPixmap( "folder" );
157 } 151 }
158 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 152 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
159 pm = Resource::loadPixmap( "exec"); 153 pm = Resource::loadPixmap( "exec");
160 } 154 }
161 else if( (fileInfo.permission( QFileInfo::ExeUser) 155 else if( (fileInfo.permission( QFileInfo::ExeUser)
162 | fileInfo.permission( QFileInfo::ExeGroup) 156 | fileInfo.permission( QFileInfo::ExeGroup)
163 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 157 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
164 pm = Resource::loadPixmap( "exec"); 158 pm = Resource::loadPixmap( "exec");
165 } 159 }
166 else if( !fi->isReadable() ) { 160 else if( !fi->isReadable() ) {
167 pm = Resource::loadPixmap( "locked" ); 161 pm = Resource::loadPixmap( "locked" );
168 } 162 }
169 else { //everything else goes by mimetype 163 else { //everything else goes by mimetype
170 MimeType mt(fi->filePath()); 164 MimeType mt(fi->filePath());
171 pm=mt.pixmap(); //sets the correct pixmap for mimetype 165 pm=mt.pixmap(); //sets the correct pixmap for mimetype
172 if(pm.isNull()) { 166 if(pm.isNull()) {
173 pm = unknownXpm; 167 pm = unknownXpm;
174 } 168 }
175 } 169 }
176 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 170 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
177 // qDebug(" overlay link image"); 171 // qDebug(" overlay link image");
178 pm= Resource::loadPixmap( "advancedfm/symlink" ); 172 pm= Resource::loadPixmap( "advancedfm/symlink" );
179 // pm= Resource::loadPixmap( "folder" ); 173 // pm= Resource::loadPixmap( "folder" );
180// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 174// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
181// QPainter painter( &pm ); 175// QPainter painter( &pm );
182// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 176// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
183// pm.setMask( pm.createHeuristicMask( FALSE ) ); 177// pm.setMask( pm.createHeuristicMask( FALSE ) );
184 } 178 }
185 item->setPixmap( 0,pm); 179 item->setPixmap( 0,pm);
186 180
187 } 181 }
188 isDir=FALSE; 182 isDir=FALSE;
189 ++it; 183 ++it;
190 } 184 }
191 185
192 if( path.find("dev",0,TRUE) != -1) { 186 if( path.find("dev",0,TRUE) != -1) {
193 struct stat buf; 187 struct stat buf;
194 dev_t devT; 188 dev_t devT;
195 DIR *dir; 189 DIR *dir;
196 struct dirent *mydirent; 190 struct dirent *mydirent;
197 191
198 if((dir = opendir( path.latin1())) != NULL) 192 if((dir = opendir( path.latin1())) != NULL)
199 while ((mydirent = readdir(dir)) != NULL) { 193 while ((mydirent = readdir(dir)) != NULL) {
200 lstat( mydirent->d_name, &buf); 194 lstat( mydirent->d_name, &buf);
201// qDebug(mydirent->d_name); 195// qDebug(mydirent->d_name);
202 fileL.sprintf("%s", mydirent->d_name); 196 fileL.sprintf("%s", mydirent->d_name);
203 devT = buf.st_dev; 197 devT = buf.st_dev;
204 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
205 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 199 fileDate.sprintf("%s", ctime( &buf.st_mtime));
206 if( fileL.find(".") == -1 ) { 200 if( fileL.find(".") == -1 ) {
207 item= new QListViewItem( thisView, fileL, fileS, fileDate); 201 item= new QListViewItem( thisView, fileL, fileS, fileDate);
208 pm = unknownXpm; 202 pm = unknownXpm;
209 item->setPixmap( 0,pm); 203 item->setPixmap( 0,pm);
210 } 204 }
211 } 205 }
212 206
213 closedir(dir); 207 closedir(dir);
214 } 208 }
215 209
216 thisView->setSorting( 3,FALSE); 210 thisView->setSorting( 3,FALSE);
217 fillCombo( (const QString &) path ); 211 fillCombo( (const QString &) path );
218} 212}
219 213
220void AdvancedFm::rePopulate() { 214void AdvancedFm::rePopulate() {
221 populateView(); 215 populateView();
222 setOtherTabCurrent(); 216 setOtherTabCurrent();
223 populateView(); 217 populateView();
224 218
225// int tmpTab = whichTab; 219// int tmpTab = whichTab;
226// // qDebug("%d", tmpTab); 220// // qDebug("%d", tmpTab);
227 221
228// for(int i =1; i < 3; i++) { 222// for(int i =1; i < 3; i++) {
229// TabWidget->setCurrentWidget(i - 1); 223// TabWidget->setCurrentWidget(i - 1);
230// populateView(); 224// populateView();
231// } 225// }
232// TabWidget->setCurrentWidget( tmpTab - 1); 226// TabWidget->setCurrentWidget( tmpTab - 1);
233} 227}
234 228
235void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 229void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
236//qWarning("listclicked"); 230//qWarning("listclicked");
237 if(selectedItem) { 231 if(selectedItem) {
238 QString strItem=selectedItem->text(0); 232 QString strItem=selectedItem->text(0);
239// qWarning(strItem); 233// qWarning(strItem);
240 QString strSize=selectedItem->text(1); 234 QString strSize=selectedItem->text(1);
241 strSize=strSize.stripWhiteSpace(); 235 strSize=strSize.stripWhiteSpace();
242 bool isDirectory = false; 236 bool isDirectory = false;
243 QString strItem2; 237 QString strItem2;
244 238
245 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink 239 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
246 strItem2 = dealWithSymName((const QString&)strItem); 240 strItem2 = dealWithSymName((const QString&)strItem);
247 if(QDir(strItem2).exists() ) 241 if(QDir(strItem2).exists() )
248 strItem = strItem2; 242 strItem = strItem2;
249 } 243 }
250 244
251 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 245 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
252 246
253 if(QDir(strItem).exists()) 247 if(QDir(strItem).exists())
254 isDirectory = true; 248 isDirectory = true;
255 } 249 }
256 250
257 if( isDirectory ) { 251 if( isDirectory ) {
258 CurrentDir()->cd( strItem, TRUE); 252 CurrentDir()->cd( strItem, TRUE);
259 populateView(); 253 populateView();
260 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 254 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
261 } 255 }
262 chdir( strItem.latin1()); 256 chdir( strItem.latin1());
263 } 257 }
264} 258}
265 259
266void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { 260void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
267 dealWithSchmooSchmaa( item->listView()); 261 dealWithSchmooSchmaa( item->listView());
268 switch (mouse) { 262 switch (mouse) {
269 case 1: 263 case 1:
270 { 264 {
271 if(renameBox != 0 ) { 265 if(renameBox != 0 ) {
272 cancelRename(); 266 cancelRename();
273 } 267 }
274 } 268 }
275 break; 269 break;
276 case 2: 270 case 2:
277 menuTimer.start( 500, TRUE ); 271 menuTimer.start( 500, TRUE );
278 break; 272 break;
279 }; 273 };
280} 274}
281 275
282 276
283void AdvancedFm::switchToLocalTab() { 277void AdvancedFm::switchToLocalTab() {
284//qWarning("switch to local view"); 278//qWarning("switch to local view");
285 TabWidget->setCurrentWidget(0); 279 TabWidget->setCurrentWidget(0);
286 Local_View->setFocus(); 280 Local_View->setFocus();
287} 281}
288 282
289void AdvancedFm::switchToRemoteTab() { 283void AdvancedFm::switchToRemoteTab() {
290//qWarning("switch to local view"); 284//qWarning("switch to local view");
291 TabWidget->setCurrentWidget(1); 285 TabWidget->setCurrentWidget(1);
292 Remote_View->setFocus(); 286 Remote_View->setFocus();
293} 287}
294 288
295void AdvancedFm::readConfig() { 289void AdvancedFm::readConfig() {
296 Config cfg("AdvancedFm"); 290 Config cfg("AdvancedFm");
297} 291}
298 292
299void AdvancedFm::writeConfig() { 293void AdvancedFm::writeConfig() {
300 Config cfg("AdvancedFm"); 294 Config cfg("AdvancedFm");
301} 295}
302 296
303void AdvancedFm::currentPathComboChanged() { 297void AdvancedFm::currentPathComboChanged() {
304 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 298 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
305 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 299 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
306 populateView(); 300 populateView();
307 } else { 301 } else {
308 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 302 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
309 } 303 }
310} 304}
311 305
312void AdvancedFm::fillCombo(const QString &currentPath) { 306void AdvancedFm::fillCombo(const QString &currentPath) {
313 307
314 if ( whichTab == 1) { 308 if ( whichTab == 1) {
315 currentPathCombo->lineEdit()->setText( currentPath); 309 currentPathCombo->lineEdit()->setText( currentPath);
316 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 310 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
317 currentPathCombo->clear(); 311 currentPathCombo->clear();
318 localDirPathStringList.prepend( currentPath ); 312 localDirPathStringList.prepend( currentPath );
319 currentPathCombo->insertStringList( localDirPathStringList,-1); 313 currentPathCombo->insertStringList( localDirPathStringList,-1);
320 } 314 }
321 } else { 315 } else {
322 currentPathCombo->lineEdit()->setText( currentPath); 316 currentPathCombo->lineEdit()->setText( currentPath);
323 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 317 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
324 currentPathCombo->clear(); 318 currentPathCombo->clear();
325 remoteDirPathStringList.prepend( currentPath ); 319 remoteDirPathStringList.prepend( currentPath );
326 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 320 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
327 } 321 }
328 } 322 }
329} 323}
330 324
331void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 325void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
332 chdir( currentPath.latin1() ); 326 chdir( currentPath.latin1() );
333 CurrentDir()->cd( currentPath, TRUE); 327 CurrentDir()->cd( currentPath, TRUE);
334 populateView(); 328 populateView();
335 update(); 329 update();
336} 330}
337 331
338QStringList AdvancedFm::getPath() { 332QStringList AdvancedFm::getPath() {
339 QStringList strList; 333 QStringList strList;
340 QListView *thisView=CurrentView(); 334 QListView *thisView=CurrentView();
341 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 335 QList<QListViewItem> * getSelectedItems( QListView * thisView );
342 QListViewItemIterator it( thisView ); 336 QListViewItemIterator it( thisView );
343 for ( ; it.current(); ++it ) { 337 for ( ; it.current(); ++it ) {
344 if ( it.current()->isSelected() ) { 338 if ( it.current()->isSelected() ) {
345 strList << it.current()->text(0); 339 strList << it.current()->text(0);
346// qDebug(it.current()->text(0)); 340// qDebug(it.current()->text(0));
347 } 341 }
348 } 342 }
349 return strList; 343 return strList;
350} 344}
351 345
352void AdvancedFm::homeButtonPushed() { 346void AdvancedFm::homeButtonPushed() {
353 QString current = QDir::homeDirPath(); 347 QString current = QDir::homeDirPath();
354 chdir( current.latin1() ); 348 chdir( current.latin1() );
355 CurrentDir()->cd( current, TRUE); 349 CurrentDir()->cd( current, TRUE);
356 populateView(); 350 populateView();
357 update(); 351 update();
358} 352}
359 353
360void AdvancedFm::docButtonPushed() { 354void AdvancedFm::docButtonPushed() {
361 QString current = QPEApplication::documentDir(); 355 QString current = QPEApplication::documentDir();
362 chdir( current.latin1() ); 356 chdir( current.latin1() );
363 CurrentDir()->cd( current, TRUE); 357 CurrentDir()->cd( current, TRUE);
364 populateView(); 358 populateView();
365 update(); 359 update();
366} 360}
367 361
368void AdvancedFm::SDButtonPushed() { 362void AdvancedFm::SDButtonPushed() {
369 QString current = "/mnt/card";// this can change so fix 363 QString current = "/mnt/card";// this can change so fix
370 chdir( current.latin1() ); 364 chdir( current.latin1() );
371 CurrentDir()->cd( current, TRUE); 365 CurrentDir()->cd( current, TRUE);
372 populateView(); 366 populateView();
373 update(); 367 update();
374} 368}
375 369
376void AdvancedFm::CFButtonPushed() { 370void AdvancedFm::CFButtonPushed() {
377 QString current; 371 QString current;
378 if(zaurusDevice) 372 if(zaurusDevice)
379 current= "/mnt/cf"; //zaurus 373 current= "/mnt/cf"; //zaurus
380 else 374 else
381 current = "/mnt/hda"; //ipaq 375 current = "/mnt/hda"; //ipaq
382 chdir( current.latin1() ); 376 chdir( current.latin1() );
383 CurrentDir()->cd( current, TRUE); 377 CurrentDir()->cd( current, TRUE);
384 populateView(); 378 populateView();
385 update(); 379 update();
386} 380}
387 381
388 382
389void AdvancedFm::doAbout() { 383void AdvancedFm::doAbout() {
390 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 384 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
391 "is copyright 2002-2003 by\n" 385 "is copyright 2002-2003 by\n"
392 "L.J.Potter<llornkcor@handhelds.org>\n" 386 "L.J.Potter<llornkcor@handhelds.org>\n"
393 "and is licensed by the GPL")); 387 "and is licensed by the GPL"));
394} 388}
395 389
396void AdvancedFm::keyPressEvent( QKeyEvent *e) { 390void AdvancedFm::keyPressEvent( QKeyEvent *e) {
397// qWarning("key %d", e->key()); 391// qWarning("key %d", e->key());
398// if( CurrentView()->hasFocus() ) 392// if( CurrentView()->hasFocus() )
399 { 393 {
400 switch ( e->key() ) { 394 switch ( e->key() ) {
401 case Key_Left: 395 case Key_Left:
402 upDir(); 396 upDir();
403 break; 397 break;
404 case Key_Next: 398 case Key_Next:
405 break; 399 break;
406 case Key_Return: 400 case Key_Return:
407 case Key_Enter: 401 case Key_Enter:
408 navigateToSelected(); 402 navigateToSelected();
409 break; 403 break;
410 case Key_Tab: { 404 case Key_Tab: {
411 setOtherTabCurrent(); 405 setOtherTabCurrent();
412 } 406 }
413 break; 407 break;
414 case Key_Delete: 408 case Key_Delete:
415 del(); 409 del();
416 break; 410 break;
417 case Key_A: 411 case Key_A:
418 copyAs(); 412 copyAs();
419 break; 413 break;
420 case Key_C: 414 case Key_C:
421 copy(); 415 copy();
422 break; 416 break;
423 case Key_E: 417 case Key_E:
424 runThis(); 418 runThis();
425 break; 419 break;
426 case Key_G: 420 case Key_G:
427 { 421 {
428 currentPathCombo->lineEdit()->setFocus(); 422 currentPathCombo->lineEdit()->setFocus();
429 } 423 }
430 break; 424 break;
431 425
432 case Key_H: 426 case Key_H:
433 showHidden(); 427 showHidden();
434 break; 428 break;
435 case Key_I: 429 case Key_I:
436 fileStatus(); 430 fileStatus();
437 break; 431 break;
438 case Key_M: 432 case Key_M:
439 move(); 433 move();
440 break; 434 break;
441 case Key_N: 435 case Key_N:
442 mkDir(); 436 mkDir();
443 break; 437 break;
444 case Key_P: 438 case Key_P:
445 filePerms(); 439 filePerms();
446 break; 440 break;
447 case Key_R: 441 case Key_R:
448 rn(); 442 rn();
449 break; 443 break;
450 case Key_U: 444 case Key_U:
451 upDir(); 445 upDir();
452 break; 446 break;
453 case Key_1: 447 case Key_1:
454 switchToLocalTab(); 448 switchToLocalTab();
455 break; 449 break;
456 case Key_2: 450 case Key_2:
457 switchToRemoteTab(); 451 switchToRemoteTab();
458 break; 452 break;
459 case Key_3: 453 case Key_3:
460 CFButtonPushed(); 454 CFButtonPushed();
461 break; 455 break;
462 case Key_4: 456 case Key_4:
463 SDButtonPushed(); 457 SDButtonPushed();
464 break; 458 break;
465 case Key_5: 459 case Key_5:
466 homeButtonPushed(); 460 homeButtonPushed();
467 break; 461 break;
468 case Key_6: 462 case Key_6:
469 docButtonPushed(); 463 docButtonPushed();
470 break; 464 break;
471 case Key_7: 465 case Key_7:
472 break; 466 break;
473 case Key_8: 467 case Key_8:
474 break; 468 break;
475 case Key_9: 469 case Key_9:
476 break; 470 break;
477 case Key_0: 471 case Key_0:
478 break; 472 break;
479 }; 473 };
480 e->accept(); 474 e->accept();
481 } 475 }
482} 476}
483 477
484void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 478void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
485 if( CurrentView()->hasFocus() ) 479 if( CurrentView()->hasFocus() )
486 e->ignore(); 480 e->ignore();
487} 481}
488 482
489 483
490void AdvancedFm::QPEButtonPushed() { 484void AdvancedFm::QPEButtonPushed() {
491 QString current = QPEApplication::qpeDir(); 485 QString current = QPEApplication::qpeDir();
492 chdir( current.latin1() ); 486 chdir( current.latin1() );
493 CurrentDir()->cd( current, TRUE); 487 CurrentDir()->cd( current, TRUE);
494 populateView(); 488 populateView();
495 update(); 489 update();
496} 490}
497 491
498void AdvancedFm::parsetab(const QString &fileName) { 492void AdvancedFm::parsetab(const QString &fileName) {
499 493
500 fileSystemTypeList.clear(); 494 fileSystemTypeList.clear();
501 fsList.clear(); 495 fsList.clear();
502 struct mntent *me; 496 struct mntent *me;
503 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 497 FILE *mntfp = setmntent( fileName.latin1(), "r" );
504 if ( mntfp ) { 498 if ( mntfp ) {
505 while ( (me = getmntent( mntfp )) != 0 ) { 499 while ( (me = getmntent( mntfp )) != 0 ) {
506 QString deviceName = me->mnt_fsname; 500 QString deviceName = me->mnt_fsname;
507 QString filesystemType = me->mnt_type; 501 QString filesystemType = me->mnt_type;
508 QString mountDir = me->mnt_dir; 502 QString mountDir = me->mnt_dir;
509 if(deviceName != "none") { 503 if(deviceName != "none") {
510 if( fsList.contains(filesystemType) == 0 504 if( fsList.contains(filesystemType) == 0
511 & filesystemType.find("proc",0,TRUE) == -1 505 & filesystemType.find("proc",0,TRUE) == -1
512 & filesystemType.find("cramfs",0,TRUE) == -1 506 & filesystemType.find("cramfs",0,TRUE) == -1
513 & filesystemType.find("auto",0,TRUE) == -1) 507 & filesystemType.find("auto",0,TRUE) == -1)
514 fsList << filesystemType; 508 fsList << filesystemType;
515 fileSystemTypeList << mountDir+"::"+filesystemType; 509 fileSystemTypeList << mountDir+"::"+filesystemType;
516 } 510 }
517 } 511 }
518 } 512 }
519 endmntent( mntfp ); 513 endmntent( mntfp );
520} 514}
521 515
522QString AdvancedFm::getFileSystemType(const QString &currentText) { 516QString AdvancedFm::getFileSystemType(const QString &currentText) {
523 parsetab("/etc/mtab"); //why did TT forget filesystem type? 517 parsetab("/etc/mtab"); //why did TT forget filesystem type?
524 QString current = currentText;//.right( currentText.length()-1); 518 QString current = currentText;//.right( currentText.length()-1);
525 QString baseFs; 519 QString baseFs;
526 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 520 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
527 QString temp = (*it); 521 QString temp = (*it);
528 QString path = temp.left(temp.find("::",0,TRUE) ); 522 QString path = temp.left(temp.find("::",0,TRUE) );
529 path = path.right( path.length()-1); 523 path = path.right( path.length()-1);
530 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 524 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
531 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 525 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
532 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 526 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
533 } 527 }
534 } 528 }
535 return baseFs; 529 return baseFs;
536} 530}
537 531
538QString AdvancedFm::getDiskSpace( const QString &path) { 532QString AdvancedFm::getDiskSpace( const QString &path) {
539 struct statfs fss; 533 struct statfs fss;
540 if ( !statfs( path.latin1(), &fss ) ) { 534 if ( !statfs( path.latin1(), &fss ) ) {
541 int blkSize = fss.f_bsize; 535 int blkSize = fss.f_bsize;
542 // int totalBlks = fs.f_blocks; 536 // int totalBlks = fs.f_blocks;
543 int availBlks = fss.f_bavail; 537 int availBlks = fss.f_bavail;
544 538
545 long mult = blkSize / 1024; 539 long mult = blkSize / 1024;
546 long div = 1024 / blkSize; 540 long div = 1024 / blkSize;
547 if ( !mult ) mult = 1; 541 if ( !mult ) mult = 1;
548 if ( !div ) div = 1; 542 if ( !div ) div = 1;
549 543
550 return QString::number(availBlks * mult / div); 544 return QString::number(availBlks * mult / div);
551 } 545 }
552 return ""; 546 return "";
553} 547}
554 548
555 549
556void AdvancedFm::showFileMenu() { 550void AdvancedFm::showFileMenu() {
557 QString curApp; 551 QString curApp;
558 curApp = CurrentView()->currentItem()->text(0); 552 curApp = CurrentView()->currentItem()->text(0);
559 553
560 MimeType mt( curApp ); 554 MimeType mt( curApp );
561 const AppLnk* app = mt.application(); 555 const AppLnk* app = mt.application();
562 QFile fi(curApp); 556 QFile fi(curApp);
563 QPopupMenu *m = new QPopupMenu(0); 557 QPopupMenu *m = new QPopupMenu(0);
564 QPopupMenu *n = new QPopupMenu(0); 558 QPopupMenu *n = new QPopupMenu(0);
565 // QPopupMenu *o = new QPopupMenu(0); 559 // QPopupMenu *o = new QPopupMenu(0);
566 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 560 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
567 561
568 if ( QFileInfo(fi).isDir() ) { 562 if ( QFileInfo(fi).isDir() ) {
569 m->insertSeparator(); 563 m->insertSeparator();
570 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 564 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
571 } else { 565 } else {
572 566
573 if ( app ) 567 if ( app )
574 m->insertItem( app->pixmap(), tr( "Open in " 568 m->insertItem( app->pixmap(), tr( "Open in "
575 + app->name() ), this, SLOT( runThis() ) ); 569 + app->name() ), this, SLOT( runThis() ) );
576 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 570 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
577 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 571 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
578 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 572 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
579 } 573 }
580 574
581 m->insertItem(tr("Actions"),n); 575 m->insertItem(tr("Actions"),n);
582 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 576 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
583 577
584 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 578 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
585 579
586 n->insertSeparator(); 580 n->insertSeparator();
587 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 581 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
588 582
589 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 583 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
590 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 584 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
591 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 585 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
592 n->insertItem( tr( "Move" ), this, SLOT( move() )); 586 n->insertItem( tr( "Move" ), this, SLOT( move() ));
593 587
594 n->insertSeparator(); 588 n->insertSeparator();
595 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 589 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
596 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 590 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
597 591
598 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 592 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
599 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 593 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
600 594
601 m->insertSeparator(); 595 m->insertSeparator();
602 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 596 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
603 597
604#if defined(QT_QWS_OPIE) 598#if defined(QT_QWS_OPIE)
605 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 599 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
606#endif 600#endif
607 m->setCheckable(TRUE); 601 m->setCheckable(TRUE);
608 if (!b) 602 if (!b)
609 m->setItemChecked(m->idAt(0),TRUE); 603 m->setItemChecked(m->idAt(0),TRUE);
610 else 604 else
611 m->setItemChecked(m->idAt(0),FALSE); 605 m->setItemChecked(m->idAt(0),FALSE);
612 606
613 if(Ir::supported()) 607 if(Ir::supported())
614 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 608 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
615 m->setFocus(); 609 m->setFocus();
616 610
617 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 611 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
618 612
619 if(m) delete m; 613 if(m) delete m;
620} 614}
621 615
622 616
623void AdvancedFm::cancelMenuTimer() { 617void AdvancedFm::cancelMenuTimer() {
624 618
625 if( menuTimer.isActive() ) 619 if( menuTimer.isActive() )
626 menuTimer.stop(); 620 menuTimer.stop();
627} 621}
628 622
629QString AdvancedFm::checkDiskSpace(const QString &path) { 623QString AdvancedFm::checkDiskSpace(const QString &path) {
630 struct statfs fss; 624 struct statfs fss;
631 if ( !statfs( path.latin1(), &fss ) ) { 625 if ( !statfs( path.latin1(), &fss ) ) {
632 int blkSize = fss.f_bsize; 626 int blkSize = fss.f_bsize;
633// int totalBlks = fs.f_blocks; 627// int totalBlks = fs.f_blocks;
634 int availBlks = fss.f_bavail; 628 int availBlks = fss.f_bavail;
635 629
636 long mult = blkSize / 1024; 630 long mult = blkSize / 1024;
637 long div = 1024 / blkSize; 631 long div = 1024 / blkSize;
638 if ( !mult ) mult = 1; 632 if ( !mult ) mult = 1;
639 if ( !div ) div = 1; 633 if ( !div ) div = 1;
640 634
641 635
642 return QString::number(availBlks * mult / div); 636 return QString::number(availBlks * mult / div);
643 } 637 }
644 return ""; 638 return "";
645} 639}
646 640
647void AdvancedFm::addToDocs() { 641void AdvancedFm::addToDocs() {
648 QStringList strListPaths = getPath(); 642 QStringList strListPaths = getPath();
649 QDir *thisDir = CurrentDir(); 643 QDir *thisDir = CurrentDir();
650 644
651 if( strListPaths.count() > 0) { 645 if( strListPaths.count() > 0) {
652 QString curFile; 646 QString curFile;
653 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 647 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
654 curFile = thisDir->canonicalPath()+"/"+(*it); 648 curFile = thisDir->canonicalPath()+"/"+(*it);
655// qDebug(curFile); 649// qDebug(curFile);
656 QFileInfo fi(curFile); 650 QFileInfo fi(curFile);
657 DocLnk f; 651 DocLnk f;
658// curFile.replace(QRegExp("\\..*"),""); 652// curFile.replace(QRegExp("\\..*"),"");
659 f.setName(fi.baseName() ); 653 f.setName(fi.baseName() );
660 f.setFile( curFile); 654 f.setFile( curFile);
661 f.writeLink(); 655 f.writeLink();
662 } 656 }
663 } 657 }
664} 658}
665 659
666 660
667void AdvancedFm::customDirsToMenu() { 661void AdvancedFm::customDirsToMenu() {
668 662
669 Config cfg("AdvancedFm"); 663 Config cfg("AdvancedFm");
670 cfg.setGroup("Menu"); 664 cfg.setGroup("Menu");
671 665
672 QStringList list = cfg.readListEntry( "CustomDir", ','); 666 QStringList list = cfg.readListEntry( "CustomDir", ',');
673 menuButton->insertItems(list ); 667 menuButton->insertItems(list );
674 668
675// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 669// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
676// { 670// {
677// customDirMenu->insertItem(*it ); 671// customDirMenu->insertItem(*it );
678// } 672// }
679} 673}
680 674
681void AdvancedFm::dirMenuSelected(int item) { 675void AdvancedFm::dirMenuSelected(int item) {
682 switch(item) 676 switch(item)
683 { 677 {
684 678
685 case -21: 679 case -21:
686 case 0: 680 case 0:
687 addCustomDir(); 681 addCustomDir();
688 break; 682 break;
689 case -22: 683 case -22:
690 case 1: 684 case 1:
691 removeCustomDir(); 685 removeCustomDir();
692 break; 686 break;
693 default: 687 default:
694 { 688 {
695// gotoCustomDir( menuButton->text(item)); 689// gotoCustomDir( menuButton->text(item));
696// gotoCustomDir( customDirMenu->text(item)); 690// gotoCustomDir( customDirMenu->text(item));
697 } 691 }
698 break; 692 break;
699 693
700 }; 694 };
701} 695}
702 696
703void AdvancedFm::addCustomDir() { 697void AdvancedFm::addCustomDir() {
704 Config cfg("AdvancedFm"); 698 Config cfg("AdvancedFm");
705 cfg.setGroup("Menu"); 699 cfg.setGroup("Menu");
706 QString dir; 700 QString dir;
707 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 701 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
708 702
709 dir = CurrentDir()->canonicalPath(); 703 dir = CurrentDir()->canonicalPath();
710 704
711 bool addIt=true; 705 bool addIt=true;
712 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 706 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
713 if( dir == (*it)) { 707 if( dir == (*it)) {
714 addIt=false; 708 addIt=false;
715 } 709 }
716 } 710 }
717 if(addIt) { 711 if(addIt) {
718 menuButton->insertItem(dir); 712 menuButton->insertItem(dir);
719// customDirMenu->insertItem(dir); 713// customDirMenu->insertItem(dir);
720 list << dir; 714 list << dir;
721 } 715 }
722 716
723 cfg.writeEntry("CustomDir", list, ','); 717 cfg.writeEntry("CustomDir", list, ',');
724 cfg.write(); 718 cfg.write();
725} 719}
726 720
727void AdvancedFm::removeCustomDir() { 721void AdvancedFm::removeCustomDir() {
728// qDebug("remove custom dir"); 722// qDebug("remove custom dir");
729 Config cfg("AdvancedFm"); 723 Config cfg("AdvancedFm");
730 cfg.setGroup("Menu"); 724 cfg.setGroup("Menu");
731 QString dir; 725 QString dir;
732 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 726 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
733 QStringList list2; 727 QStringList list2;
734 dir = CurrentDir()->canonicalPath(); 728 dir = CurrentDir()->canonicalPath();
735 int ramble=2; 729 int ramble=2;
736// int ramble=-24; 730// int ramble=-24;
737//first remove list 731//first remove list
738 if(list.grep(dir,true).isEmpty()) { 732 if(list.grep(dir,true).isEmpty()) {
739 QMessageBox::message(tr( "AdvancedFm" ), 733 QMessageBox::message(tr( "AdvancedFm" ),
740 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 734 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
741 } else { 735 } else {
742 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 736 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
743 if((*it) != dir) { 737 if((*it) != dir) {
744//current item is not our current dir, so add it to temp list 738//current item is not our current dir, so add it to temp list
745 list2 <<(*it); 739 list2 <<(*it);
746 } else { 740 } else {
747// customDirMenu->removeItem( ramble); 741// customDirMenu->removeItem( ramble);
748 menuButton->remove( ramble); 742 menuButton->remove( ramble);
749 743
750 } 744 }
751 ramble++; 745 ramble++;
752// ramble--; 746// ramble--;
753 } 747 }
754 748
755 cfg.writeEntry("CustomDir", list2, ','); 749 cfg.writeEntry("CustomDir", list2, ',');
756 cfg.write(); 750 cfg.write();
757 } 751 }
758// customDirsToMenu(); 752// customDirsToMenu();
759 753
760} 754}
761 755
762void AdvancedFm::gotoCustomDir(const QString &dir) { 756void AdvancedFm::gotoCustomDir(const QString &dir) {
763// qDebug("gotoCustomDir(const QString &dir) " +dir ); 757// qDebug("gotoCustomDir(const QString &dir) " +dir );
764// QString curDir = dir; 758// QString curDir = dir;
765// QDir *thisDir = CurrentDir(); 759// QDir *thisDir = CurrentDir();
766// if( curDir.isEmpty()) { 760// if( curDir.isEmpty()) {
767// } 761// }
768 if( dir == s_addBookmark) { 762 if( dir == s_addBookmark) {
769 addCustomDir(); 763 addCustomDir();
770 } 764 }
771 if( dir == s_removeBookmark) { 765 if( dir == s_removeBookmark) {
772 removeCustomDir( ); 766 removeCustomDir( );
773 } else { 767 } else {
774 gotoDirectory( dir); 768 gotoDirectory( dir);
775// if(QDir( curDir).exists() ) 769// if(QDir( curDir).exists() )
776// { 770// {
777// thisDir->setPath( curDir ); 771// thisDir->setPath( curDir );
778// chdir( curDir.latin1() ); 772// chdir( curDir.latin1() );
779// thisDir->cd( curDir, TRUE); 773// thisDir->cd( curDir, TRUE);
780// populateView(); 774// populateView();
781// } 775// }
782 } 776 }
783} 777}
784 778
785QDir *AdvancedFm::CurrentDir() { 779QDir *AdvancedFm::CurrentDir() {
786 780
787 if ( whichTab == 1) { 781 if ( whichTab == 1) {
788 return &currentDir; 782 return &currentDir;
789 } else { 783 } else {
790 return &currentRemoteDir; 784 return &currentRemoteDir;
791 } 785 }
792} 786}
793 787
794QDir *AdvancedFm::OtherDir() { 788QDir *AdvancedFm::OtherDir() {
795 if ( whichTab == 1) { 789 if ( whichTab == 1) {
796 return &currentRemoteDir; 790 return &currentRemoteDir;
797 } else { 791 } else {
798 return &currentDir; 792 return &currentDir;
799 } 793 }
800} 794}
801 795
802QListView * AdvancedFm::CurrentView() { 796QListView * AdvancedFm::CurrentView() {
803 if ( whichTab == 1) { 797 if ( whichTab == 1) {
804// qWarning("CurrentView Tab 1"); 798// qWarning("CurrentView Tab 1");
805 return Local_View; 799 return Local_View;
806 } else { 800 } else {
807// qWarning("CurrentView Tab 2"); 801// qWarning("CurrentView Tab 2");
808 return Remote_View; 802 return Remote_View;
809 } 803 }
810} 804}
811 805
812QListView * AdvancedFm::OtherView() { 806QListView * AdvancedFm::OtherView() {
813 if ( whichTab == 1) 807 if ( whichTab == 1)
814 return Remote_View; 808 return Remote_View;
815 else 809 else
816 return Local_View; 810 return Local_View;
817} 811}
818 812
819void AdvancedFm::setOtherTabCurrent() { 813void AdvancedFm::setOtherTabCurrent() {
820// qWarning("setOtherTabCurrent() %d", whichTab); 814// qWarning("setOtherTabCurrent() %d", whichTab);
821 if ( whichTab == 1) { 815 if ( whichTab == 1) {
822 TabWidget->setCurrentWidget(1); 816 TabWidget->setCurrentWidget(1);
823 } else { 817 } else {
824 TabWidget->setCurrentWidget(0); 818 TabWidget->setCurrentWidget(0);
825 } 819 }
826 OtherView()->setFocus(); 820 OtherView()->setFocus();
827 OtherView()->setSelected( CurrentView()->firstChild(), true); 821 OtherView()->setSelected( CurrentView()->firstChild(), true);
828} 822}
829 823
830void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 824void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
831// qDebug("qcop message "+msg ); 825// qDebug("qcop message "+msg );
832 QDataStream stream ( data, IO_ReadOnly ); 826 QDataStream stream ( data, IO_ReadOnly );
833 if ( msg == "openDirectory(QString)" ) { 827 if ( msg == "openDirectory(QString)" ) {
834// qDebug("received"); 828// qDebug("received");
835 QString file; 829 QString file;
836 stream >> file; 830 stream >> file;
837 gotoDirectory( (const QString &) file); 831 gotoDirectory( (const QString &) file);
838 } 832 }
839} 833}
840 834
841void AdvancedFm::setDocument(const QString &file) { 835void AdvancedFm::setDocument(const QString &file) {
842 gotoDirectory( file); 836 gotoDirectory( file);
843 837
844} 838}
845 839
846void AdvancedFm::gotoDirectory(const QString &file) { 840void AdvancedFm::gotoDirectory(const QString &file) {
847// qWarning("goto dir "+file); 841// qWarning("goto dir "+file);
848 QString curDir = file; 842 QString curDir = file;
849 QDir *thisDir = CurrentDir(); 843 QDir *thisDir = CurrentDir();
850 if(QDir( curDir).exists() ) { 844 if(QDir( curDir).exists() ) {
851 thisDir->setPath( curDir ); 845 thisDir->setPath( curDir );
852 chdir( curDir.latin1() ); 846 chdir( curDir.latin1() );
853 thisDir->cd( curDir, TRUE); 847 thisDir->cd( curDir, TRUE);
854 populateView(); 848 populateView();
855 } 849 }
856 else if(QFileInfo(curDir).exists()) { 850 else if(QFileInfo(curDir).exists()) {
857 QFileInfo fileInfo(curDir); 851 QFileInfo fileInfo(curDir);
858 curDir=fileInfo.dirPath(); 852 curDir=fileInfo.dirPath();
859 if(QDir( curDir).exists() ) { 853 if(QDir( curDir).exists() ) {
860 thisDir->setPath( curDir ); 854 thisDir->setPath( curDir );
861 chdir( curDir.latin1() ); 855 chdir( curDir.latin1() );
862 thisDir->cd( curDir, TRUE); 856 thisDir->cd( curDir, TRUE);
863 populateView(); 857 populateView();
864 } 858 }
865 findFile(file); 859 findFile(file);
866 } 860 }
867 861
868} 862}
869 863
870void AdvancedFm::findFile(const QString &fileName) { 864void AdvancedFm::findFile(const QString &fileName) {
871 QFileInfo fi(fileName); 865 QFileInfo fi(fileName);
872 QListView *thisView = CurrentView(); 866 QListView *thisView = CurrentView();
873 QListViewItemIterator it( thisView ); 867 QListViewItemIterator it( thisView );
874 for ( ; it.current(); ++it ) { 868 for ( ; it.current(); ++it ) {
875 if(it.current()->text(0) == fi.fileName()) { 869 if(it.current()->text(0) == fi.fileName()) {
876 it.current()->setSelected(true); 870 it.current()->setSelected(true);
877 thisView->ensureItemVisible(it.current()); 871 thisView->ensureItemVisible(it.current());
878 } 872 }
879 } 873 }
880} 874}
881 875
882void AdvancedFm::slotSwitchMenu(int ) { 876void AdvancedFm::slotSwitchMenu(int ) {
883// qDebug("Switch %d", item); 877// qDebug("Switch %d", item);
884 // viewMenu->setItemChecked(item, true); 878 // viewMenu->setItemChecked(item, true);
885} 879}
886 880
887void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { 881void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
888 tabChanged( w); 882 tabChanged( w);
889 if( w == Local_View) { 883 if( w == Local_View) {
890 Remote_View->clearFocus(); 884 Remote_View->clearFocus();
891 } else { 885 } else {
892 Local_View->clearFocus(); 886 Local_View->clearFocus();
893 } 887 }
894} 888}
895 889
896void AdvancedFm::navigateToSelected() { 890void AdvancedFm::navigateToSelected() {
897 if( !CurrentView()->currentItem()) return; 891 if( !CurrentView()->currentItem()) return;
898 doDirChange(); 892 doDirChange();
899} 893}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index bfefa77..547fa7c 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -1,192 +1,192 @@
1/*************************************************************************** 1/***************************************************************************
2 advancedfm.h 2 advancedfm.h
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef ADVANCEDFM_H 12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H 13#define ADVANCEDFM_H
14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties 14#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
15#define QT_QWS_OPIE 15#define QT_QWS_OPIE
16 16
17//#include <opie/otabwidget.h> 17#include <opie2/oprocess.h>
18#include <opie/oprocess.h> 18#include <opie2/osplitter.h>
19 19
20#include <qpe/ir.h> 20#include <qpe/ir.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22 22
23#include <qvariant.h> 23#include <qvariant.h>
24#include <qdialog.h> 24#include <qdialog.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qpoint.h> 29#include <qpoint.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpixmap.h> 31#include <qpixmap.h>
32 32
33class OSplitter; 33using Opie::OSplitter;
34
34class QVBoxLayout; 35class QVBoxLayout;
35class QHBoxLayout; 36class QHBoxLayout;
36class QGridLayout; 37class QGridLayout;
37class QComboBox; 38class QComboBox;
38class QListView; 39class QListView;
39class QListviewItem; 40class QListviewItem;
40class QLabel; 41class QLabel;
41class QProgressBar; 42class QProgressBar;
42class QSpinBox; 43class QSpinBox;
43class QTabWidget;
44class QWidget; 44class QWidget;
45class QPopupMenu; 45class QPopupMenu;
46class QFile; 46class QFile;
47class QListViewItem; 47class QListViewItem;
48class QLineEdit; 48class QLineEdit;
49class MenuButton; 49class MenuButton;
50 50
51class QToolButton; 51class QToolButton;
52class Ir; 52class Ir;
53 53
54class AdvancedFm : public QMainWindow 54class AdvancedFm : public QMainWindow
55{ 55{
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 static QString appName() { return QString::fromLatin1("advancedfm"); } 58 static QString appName() { return QString::fromLatin1("advancedfm"); }
59#ifdef NOQUICKLAUNCH 59#ifdef NOQUICKLAUNCH
60 AdvancedFm(); 60 AdvancedFm();
61#else 61#else
62 AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0); 62 AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0);
63#endif 63#endif
64 ~AdvancedFm(); 64 ~AdvancedFm();
65protected slots: 65protected slots:
66 void slotSwitchMenu(int); 66 void slotSwitchMenu(int);
67 void selectAll(); 67 void selectAll();
68 void addToDocs(); 68 void addToDocs();
69 void doDirChange(); 69 void doDirChange();
70 void mkDir(); 70 void mkDir();
71 void del(); 71 void del();
72 void rn(); 72 void rn();
73 void populateView(); 73 void populateView();
74 void rePopulate(); 74 void rePopulate();
75 void showHidden(); 75 void showHidden();
76 void showMenuHidden(); 76 void showMenuHidden();
77 void writeConfig(); 77 void writeConfig();
78 void readConfig(); 78 void readConfig();
79 void ListClicked(QListViewItem *); 79 void ListClicked(QListViewItem *);
80 void ListPressed( int, QListViewItem *, const QPoint&, int); 80 void ListPressed( int, QListViewItem *, const QPoint&, int);
81 void makeDir(); 81 void makeDir();
82 void doDelete(); 82 void doDelete();
83 void tabChanged(QWidget*); 83 void tabChanged(QWidget*);
84 void cleanUp(); 84 void cleanUp();
85 void renameIt(); 85 void renameIt();
86 void runThis(); 86 void runThis();
87 void runText(); 87 void runText();
88 void filePerms(); 88 void filePerms();
89 void doProperties(); 89 void doProperties();
90 void runCommand(); 90 void runCommand();
91 void runCommandStd(); 91 void runCommandStd();
92 QStringList getPath(); 92 QStringList getPath();
93 void mkSym(); 93 void mkSym();
94 void switchToLocalTab(); 94 void switchToLocalTab();
95 void switchToRemoteTab(); 95 void switchToRemoteTab();
96 96
97protected: 97protected:
98 98
99 OSplitter *TabWidget; 99 OSplitter *TabWidget;
100 QCopChannel * channel; 100 QCopChannel * channel;
101 QPixmap unknownXpm; 101 QPixmap unknownXpm;
102 int whichTab; 102 int whichTab;
103// QTabWidget *TabWidget; 103// QTabWidget *TabWidget;
104 QWidget *tab, *tab_2, *tab_3; 104 QWidget *tab, *tab_2, *tab_3;
105 QListView *Local_View, *Remote_View; 105 QListView *Local_View, *Remote_View;
106 106
107 QLineEdit *currentPathEdit; 107 QLineEdit *currentPathEdit;
108 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; 108 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/;
109 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 109 QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
110// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; 110// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
111 QDir currentDir, currentRemoteDir; 111 QDir currentDir, currentRemoteDir;
112 QComboBox *currentPathCombo; 112 QComboBox *currentPathCombo;
113 QString filterStr, s_addBookmark, s_removeBookmark; 113 QString filterStr, s_addBookmark, s_removeBookmark;
114 QListViewItem * item; 114 QListViewItem * item;
115 bool b; 115 bool b;
116 QStringList fileSystemTypeList, fsList; 116 QStringList fileSystemTypeList, fsList;
117 int currentServerConfig; 117 int currentServerConfig;
118 bool zaurusDevice; 118 bool zaurusDevice;
119 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; 119 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
120 QStringList remoteDirPathStringList, localDirPathStringList; 120 QStringList remoteDirPathStringList, localDirPathStringList;
121 QLineEdit *renameBox; 121 QLineEdit *renameBox;
122 122
123 void init(); 123 void init();
124 void initConnections(); 124 void initConnections();
125 void keyReleaseEvent( QKeyEvent *); 125 void keyReleaseEvent( QKeyEvent *);
126 void keyPressEvent( QKeyEvent *); 126 void keyPressEvent( QKeyEvent *);
127 QString getFileSystemType(const QString &); 127 QString getFileSystemType(const QString &);
128 QString getDiskSpace(const QString &); 128 QString getDiskSpace(const QString &);
129 void parsetab(const QString &fileName); 129 void parsetab(const QString &fileName);
130 QString checkDiskSpace(const QString &); 130 QString checkDiskSpace(const QString &);
131 QString dealWithSymName(const QString &); 131 QString dealWithSymName(const QString &);
132 QDir *CurrentDir(); 132 QDir *CurrentDir();
133 QDir *OtherDir(); 133 QDir *OtherDir();
134 QListView *CurrentView(); 134 QListView *CurrentView();
135 QListView *OtherView(); 135 QListView *OtherView();
136 void setOtherTabCurrent(); 136 void setOtherTabCurrent();
137 void dealWithSchmooSchmaa(QWidget *); 137 void dealWithSchmooSchmaa(QWidget *);
138 138
139protected slots: 139protected slots:
140 void openSearch(); 140 void openSearch();
141 void dirMenuSelected(int); 141 void dirMenuSelected(int);
142 void showFileMenu(); 142 void showFileMenu();
143 void cancelMenuTimer(); 143 void cancelMenuTimer();
144 void homeButtonPushed(); 144 void homeButtonPushed();
145 void docButtonPushed(); 145 void docButtonPushed();
146 void SDButtonPushed(); 146 void SDButtonPushed();
147 void CFButtonPushed(); 147 void CFButtonPushed();
148 void QPEButtonPushed(); 148 void QPEButtonPushed();
149 void upDir(); 149 void upDir();
150 void currentPathComboChanged(); 150 void currentPathComboChanged();
151 void copy(); 151 void copy();
152 void copyAs(); 152 void copyAs();
153 void copySameDir(); 153 void copySameDir();
154 void currentPathComboActivated(const QString &); 154 void currentPathComboActivated(const QString &);
155 void fillCombo(const QString &); 155 void fillCombo(const QString &);
156 bool copyFile( const QString & , const QString & ); 156 bool copyFile( const QString & , const QString & );
157 void move(); 157 void move();
158 void fileStatus(); 158 void fileStatus();
159 void doAbout(); 159 void doAbout();
160 void doBeam(); 160 void doBeam();
161 void fileBeamFinished( Ir *); 161 void fileBeamFinished( Ir *);
162 bool copyDirectory( const QString & , const QString & ); 162 bool copyDirectory( const QString & , const QString & );
163// void navigateToSelected(); 163// void navigateToSelected();
164 bool moveDirectory( const QString & , const QString & ); 164 bool moveDirectory( const QString & , const QString & );
165// void slotSwitchtoLocal(int); 165// void slotSwitchtoLocal(int);
166 166
167private: 167private:
168 MenuButton *menuButton; 168 MenuButton *menuButton;
169 QString oldName; 169 QString oldName;
170 QTimer menuTimer; 170 QTimer menuTimer;
171 void startProcess(const QString &); 171 void startProcess(const QString &);
172 bool eventFilter( QObject * , QEvent * ); 172 bool eventFilter( QObject * , QEvent * );
173 void cancelRename(); 173 void cancelRename();
174 void doRename(QListView *); 174 void doRename(QListView *);
175 void okRename(); 175 void okRename();
176 void customDirsToMenu(); 176 void customDirsToMenu();
177 void addCustomDir(); 177 void addCustomDir();
178 void removeCustomDir(); 178 void removeCustomDir();
179 void gotoDirectory(const QString &); 179 void gotoDirectory(const QString &);
180 void navigateToSelected(); 180 void navigateToSelected();
181 void findFile(const QString &); 181 void findFile(const QString &);
182 182
183private slots: 183private slots:
184 void processEnded(OProcess *); 184 void processEnded(OProcess *);
185 void oprocessStderr(OProcess *, char *, int); 185 void oprocessStderr(OProcess *, char *, int);
186 void gotoCustomDir(const QString &); 186 void gotoCustomDir(const QString &);
187 void qcopReceive(const QCString&, const QByteArray&); 187 void qcopReceive(const QCString&, const QByteArray&);
188 void setDocument(const QString &); 188 void setDocument(const QString &);
189 189
190}; 190};
191 191
192#endif // ADVANCEDFM_H 192#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 70db018..ca9856b 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,35 +1,35 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release quick-app 2CONFIG += qt warn_on release quick-app
3# CONFIG += qt warn_on release 3# CONFIG += qt warn_on release
4HEADERS = advancedfm.h filePermissions.h output.h 4HEADERS = advancedfm.h filePermissions.h output.h
5SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp 5SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
6TARGET = advancedfm 6TARGET = advancedfm
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie 9LIBS += -lqpe -lopiecore2 -lopieui2
10 10
11TRANSLATIONS = ../../../i18n/de/advancedfm.ts \ 11TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
12 ../../../i18n/nl/advancedfm.ts \ 12 ../../../i18n/nl/advancedfm.ts \
13 ../../../i18n/da/advancedfm.ts \ 13 ../../../i18n/da/advancedfm.ts \
14 ../../../i18n/xx/advancedfm.ts \ 14 ../../../i18n/xx/advancedfm.ts \
15 ../../../i18n/en/advancedfm.ts \ 15 ../../../i18n/en/advancedfm.ts \
16 ../../../i18n/es/advancedfm.ts \ 16 ../../../i18n/es/advancedfm.ts \
17 ../../../i18n/fr/advancedfm.ts \ 17 ../../../i18n/fr/advancedfm.ts \
18 ../../../i18n/hu/advancedfm.ts \ 18 ../../../i18n/hu/advancedfm.ts \
19 ../../../i18n/ja/advancedfm.ts \ 19 ../../../i18n/ja/advancedfm.ts \
20 ../../../i18n/ko/advancedfm.ts \ 20 ../../../i18n/ko/advancedfm.ts \
21 ../../../i18n/no/advancedfm.ts \ 21 ../../../i18n/no/advancedfm.ts \
22 ../../../i18n/pl/advancedfm.ts \ 22 ../../../i18n/pl/advancedfm.ts \
23 ../../../i18n/pt/advancedfm.ts \ 23 ../../../i18n/pt/advancedfm.ts \
24 ../../../i18n/pt_BR/advancedfm.ts \ 24 ../../../i18n/pt_BR/advancedfm.ts \
25 ../../../i18n/sl/advancedfm.ts \ 25 ../../../i18n/sl/advancedfm.ts \
26 ../../../i18n/zh_CN/advancedfm.ts \ 26 ../../../i18n/zh_CN/advancedfm.ts \
27 ../../../i18n/zh_TW/advancedfm.ts 27 ../../../i18n/zh_TW/advancedfm.ts
28 28
29 29
30 !contains(CONFIG,quick-app) { 30!contains(CONFIG,quick-app) {
31 DESTDIR = $(OPIEDIR)/bin 31 DESTDIR = $(OPIEDIR)/bin
32 DEFINES += NOQUICKLAUNCH 32 DEFINES += NOQUICKLAUNCH
33} 33}
34 34
35include ( $(OPIEDIR)/include.pro ) 35include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index ddaa39a..763ae34 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -1,288 +1,286 @@
1/*************************************************************************** 1/***************************************************************************
2 advancedfmData.cpp 2 advancedfmData.cpp
3 ------------------- 3 -------------------
4** Created: Mon 09-23-2002 13:24:11 4** Created: Mon 09-23-2002 13:24:11
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13 13
14#include <opie/osplitter.h>
15#include <qpe/storage.h> 14#include <qpe/storage.h>
16
17#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
18#include <qpe/resource.h> 16#include <qpe/resource.h>
19#include <qpe/menubutton.h> 17#include <qpe/menubutton.h>
20 18
21#include <qlayout.h> 19#include <qlayout.h>
22#include <qhbox.h> 20#include <qhbox.h>
23#include <qmenubar.h> 21#include <qmenubar.h>
24#include <qcombobox.h> 22#include <qcombobox.h>
25#include <qtoolbutton.h> 23#include <qtoolbutton.h>
26#include <qlineedit.h> 24#include <qlineedit.h>
27#include <qlistview.h> 25#include <qlistview.h>
28 26
29#include <sys/utsname.h> 27#include <sys/utsname.h>
30 28
31 29
32void AdvancedFm::init() { 30void AdvancedFm::init() {
33#if defined(QT_QWS_OPIE) 31#if defined(QT_QWS_OPIE)
34 qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); 32 qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!");
35#endif 33#endif
36 setCaption( tr( "AdvancedFm" ) ); 34 setCaption( tr( "AdvancedFm" ) );
37 35
38 QVBoxLayout *layout = new QVBoxLayout( this ); 36 QVBoxLayout *layout = new QVBoxLayout( this );
39 layout->setSpacing( 2); 37 layout->setSpacing( 2);
40 layout->setMargin( 2); 38 layout->setMargin( 2);
41 39
42 QMenuBar *menuBar = new QMenuBar(this); 40 QMenuBar *menuBar = new QMenuBar(this);
43 fileMenu = new QPopupMenu( this ); 41 fileMenu = new QPopupMenu( this );
44 viewMenu = new QPopupMenu( this ); 42 viewMenu = new QPopupMenu( this );
45// customDirMenu = new QPopupMenu( this ); 43// customDirMenu = new QPopupMenu( this );
46 44
47 layout->addWidget( menuBar ); 45 layout->addWidget( menuBar );
48 46
49 menuBar->insertItem( tr( "File" ), fileMenu); 47 menuBar->insertItem( tr( "File" ), fileMenu);
50 menuBar->insertItem( tr( "View" ), viewMenu); 48 menuBar->insertItem( tr( "View" ), viewMenu);
51 49
52 cdUpButton = new QToolButton( 0,"cdUpButton"); 50 cdUpButton = new QToolButton( 0,"cdUpButton");
53 cdUpButton->setPixmap(Resource::loadPixmap("up")); 51 cdUpButton->setPixmap(Resource::loadPixmap("up"));
54 cdUpButton->setAutoRaise( true ); 52 cdUpButton->setAutoRaise( true );
55 menuBar->insertItem( cdUpButton ); 53 menuBar->insertItem( cdUpButton );
56 54
57 55
58 QHBox *lineBox = new QHBox( this ); 56 QHBox *lineBox = new QHBox( this );
59 57
60 qpeDirButton= new QToolButton( 0,"QPEButton"); 58 qpeDirButton= new QToolButton( 0,"QPEButton");
61 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); 59 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
62 qpeDirButton->setAutoRaise( true ); 60 qpeDirButton->setAutoRaise( true );
63 menuBar->insertItem( qpeDirButton ); 61 menuBar->insertItem( qpeDirButton );
64 62
65 cfButton = new QToolButton( 0, "CFButton"); 63 cfButton = new QToolButton( 0, "CFButton");
66 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); 64 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
67 cfButton->setAutoRaise( true ); 65 cfButton->setAutoRaise( true );
68 menuBar->insertItem( cfButton ); 66 menuBar->insertItem( cfButton );
69 67
70 sdButton = new QToolButton( 0, "SDButton"); 68 sdButton = new QToolButton( 0, "SDButton");
71 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); 69 sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard"));
72 sdButton->setAutoRaise( true ); 70 sdButton->setAutoRaise( true );
73 menuBar->insertItem( sdButton ); 71 menuBar->insertItem( sdButton );
74 72
75 docButton = new QToolButton( 0,"docsButton"); 73 docButton = new QToolButton( 0,"docsButton");
76 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 74 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
77 docButton->setAutoRaise( true ); 75 docButton->setAutoRaise( true );
78 menuBar->insertItem( docButton ); 76 menuBar->insertItem( docButton );
79 77
80 homeButton = new QToolButton( 0, "homeButton"); 78 homeButton = new QToolButton( 0, "homeButton");
81 homeButton->setPixmap(Resource::loadPixmap("home")); 79 homeButton->setPixmap(Resource::loadPixmap("home"));
82 homeButton->setAutoRaise( true ); 80 homeButton->setAutoRaise( true );
83 menuBar->insertItem( homeButton ); 81 menuBar->insertItem( homeButton );
84 82
85 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); 83 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() ));
86 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 84 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
87 fileMenu->insertSeparator(); 85 fileMenu->insertSeparator();
88 fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); 86 fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() ));
89 fileMenu->insertSeparator(); 87 fileMenu->insertSeparator();
90 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); 88 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
91 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); 89 fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
92 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 90 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
93 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); 91 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
94 fileMenu->insertSeparator(); 92 fileMenu->insertSeparator();
95 fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 93 fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
96 fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); 94 fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() ));
97 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 95 fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
98 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); 96 fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
99 fileMenu->setCheckable(TRUE); 97 fileMenu->setCheckable(TRUE);
100 98
101 viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); 99 viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab()));
102 viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); 100 viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab()));
103// viewMenu->insertSeparator(); 101// viewMenu->insertSeparator();
104// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 102// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
105 viewMenu->setCheckable(true); 103 viewMenu->setCheckable(true);
106 viewMenu->setItemChecked( viewMenu->idAt(0), true); 104 viewMenu->setItemChecked( viewMenu->idAt(0), true);
107 viewMenu->setItemChecked( viewMenu->idAt(1), false); 105 viewMenu->setItemChecked( viewMenu->idAt(1), false);
108 106
109 s_addBookmark = tr("Bookmark Directory"); 107 s_addBookmark = tr("Bookmark Directory");
110 s_removeBookmark = tr("Remove Current Directory from Bookmarks"); 108 s_removeBookmark = tr("Remove Current Directory from Bookmarks");
111 109
112// menuButton->insertItem(""); 110// menuButton->insertItem("");
113 111
114// customDirMenu->insertItem(tr("Add This Directory")); 112// customDirMenu->insertItem(tr("Add This Directory"));
115// customDirMenu->insertItem(tr("Remove This Directory")); 113// customDirMenu->insertItem(tr("Remove This Directory"));
116// customDirMenu->insertSeparator(); 114// customDirMenu->insertSeparator();
117 115
118 menuButton = new MenuButton( lineBox ); 116 menuButton = new MenuButton( lineBox );
119 117
120 menuButton->setUseLabel(false); 118 menuButton->setUseLabel(false);
121 menuButton->setMaximumWidth( 20 ); 119 menuButton->setMaximumWidth( 20 );
122 menuButton->insertItem( s_addBookmark); 120 menuButton->insertItem( s_addBookmark);
123 menuButton->insertItem( s_removeBookmark); 121 menuButton->insertItem( s_removeBookmark);
124 menuButton->insertSeparator(); 122 menuButton->insertSeparator();
125 menuButton->setFocusPolicy(NoFocus); 123 menuButton->setFocusPolicy(NoFocus);
126 124
127 customDirsToMenu(); 125 customDirsToMenu();
128 126
129 currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); 127 currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" );
130 currentPathCombo->setEditable(TRUE); 128 currentPathCombo->setEditable(TRUE);
131 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 129 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
132 currentPathCombo->setFocusPolicy(NoFocus); 130 currentPathCombo->setFocusPolicy(NoFocus);
133 layout->addWidget( lineBox ); 131 layout->addWidget( lineBox );
134 132
135 133
136 TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); 134 TabWidget = new OSplitter( Horizontal, this, "TabWidget" );
137// TabWidget = new QTabWidget( this, "TabWidget" ); 135// TabWidget = new QTabWidget( this, "TabWidget" );
138 layout->addWidget( TabWidget, 4 ); 136 layout->addWidget( TabWidget, 4 );
139 137
140 tab = new QWidget( TabWidget, "tab" ); 138 tab = new QWidget( TabWidget, "tab" );
141 tabLayout = new QGridLayout( tab ); 139 tabLayout = new QGridLayout( tab );
142 tabLayout->setSpacing( 2); 140 tabLayout->setSpacing( 2);
143 tabLayout->setMargin( 2); 141 tabLayout->setMargin( 2);
144 142
145 Local_View = new QListView( tab, "Local_View" ); 143 Local_View = new QListView( tab, "Local_View" );
146 Local_View->addColumn( tr("File"),130); 144 Local_View->addColumn( tr("File"),130);
147 Local_View->addColumn( tr("Size"),-1); 145 Local_View->addColumn( tr("Size"),-1);
148 Local_View->setColumnAlignment(1,QListView::AlignRight); 146 Local_View->setColumnAlignment(1,QListView::AlignRight);
149 Local_View->addColumn( tr("Date"),-1); 147 Local_View->addColumn( tr("Date"),-1);
150 Local_View->setColumnAlignment(2,QListView::AlignRight); 148 Local_View->setColumnAlignment(2,QListView::AlignRight);
151 Local_View->setAllColumnsShowFocus(TRUE); 149 Local_View->setAllColumnsShowFocus(TRUE);
152 Local_View->setMultiSelection( TRUE ); 150 Local_View->setMultiSelection( TRUE );
153 Local_View->setSelectionMode(QListView::Extended); 151 Local_View->setSelectionMode(QListView::Extended);
154 Local_View->setFocusPolicy(StrongFocus); 152 Local_View->setFocusPolicy(StrongFocus);
155 Local_View->installEventFilter( this ); 153 Local_View->installEventFilter( this );
156 154
157 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 155 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
158 156
159 tabLayout->addWidget( Local_View, 0, 0 ); 157 tabLayout->addWidget( Local_View, 0, 0 );
160 158
161 TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); 159 TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1"));
162// TabWidget->insertTab( tab, tr("1")); 160// TabWidget->insertTab( tab, tr("1"));
163 161
164 tab_2 = new QWidget( TabWidget, "tab_2" ); 162 tab_2 = new QWidget( TabWidget, "tab_2" );
165 tabLayout_2 = new QGridLayout( tab_2 ); 163 tabLayout_2 = new QGridLayout( tab_2 );
166 tabLayout_2->setSpacing( 2); 164 tabLayout_2->setSpacing( 2);
167 tabLayout_2->setMargin( 2); 165 tabLayout_2->setMargin( 2);
168 166
169 Remote_View = new QListView( tab_2, "Remote_View" ); 167 Remote_View = new QListView( tab_2, "Remote_View" );
170 Remote_View->addColumn( tr("File"),130); 168 Remote_View->addColumn( tr("File"),130);
171 Remote_View->addColumn( tr("Size"),-1); 169 Remote_View->addColumn( tr("Size"),-1);
172 Remote_View->setColumnAlignment(1,QListView::AlignRight); 170 Remote_View->setColumnAlignment(1,QListView::AlignRight);
173 Remote_View->addColumn( tr("Date"),-1); 171 Remote_View->addColumn( tr("Date"),-1);
174 Remote_View->setColumnAlignment(2,QListView::AlignRight); 172 Remote_View->setColumnAlignment(2,QListView::AlignRight);
175 Remote_View->setAllColumnsShowFocus(TRUE); 173 Remote_View->setAllColumnsShowFocus(TRUE);
176 Remote_View->setMultiSelection( TRUE ); 174 Remote_View->setMultiSelection( TRUE );
177 Remote_View->setSelectionMode(QListView::Extended); 175 Remote_View->setSelectionMode(QListView::Extended);
178 Remote_View->setFocusPolicy(StrongFocus); 176 Remote_View->setFocusPolicy(StrongFocus);
179 Remote_View->installEventFilter( this ); 177 Remote_View->installEventFilter( this );
180 178
181 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 179 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
182 180
183 tabLayout_2->addWidget( Remote_View, 0, 0 ); 181 tabLayout_2->addWidget( Remote_View, 0, 0 );
184 182
185 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); 183 TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
186 TabWidget->setSizeChange( 370 ); 184 TabWidget->setSizeChange( 370 );
187// TabWidget->insertTab( tab_2, tr( "2")); 185// TabWidget->insertTab( tab_2, tr( "2"));
188 186
189 /* tab_3 = new QWidget( TabWidget, "tab_3" ); 187 /* tab_3 = new QWidget( TabWidget, "tab_3" );
190 tabLayout_3 = new QGridLayout( tab_3 ); 188 tabLayout_3 = new QGridLayout( tab_3 );
191 tabLayout_3->setSpacing( 2); 189 tabLayout_3->setSpacing( 2);
192 tabLayout_3->setMargin( 2); 190 tabLayout_3->setMargin( 2);
193 191
194 192
195 // OFileDialog fileDialog; 193 // OFileDialog fileDialog;
196 // fileDialog; 194 // fileDialog;
197 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy 195 // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
198 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); 196 // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
199 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); 197 // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
200 198
201 QListView *fileTree; 199 QListView *fileTree;
202 fileTree = new QListView( tab_3, "tree" ); 200 fileTree = new QListView( tab_3, "tree" );
203 201
204 202
205 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); 203 tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
206 204
207 TabWidget->insertTab( tab_3, tr( "Remote" ) ); 205 TabWidget->insertTab( tab_3, tr( "Remote" ) );
208 */ 206 */
209 207
210 /////////////// 208 ///////////////
211 209
212 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 210 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
213 zaurusDevice=TRUE; 211 zaurusDevice=TRUE;
214 else 212 else
215 zaurusDevice=FALSE; 213 zaurusDevice=FALSE;
216 214
217 215
218 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { 216 if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
219 qDebug("not have sd"); 217 qDebug("not have sd");
220 sdButton->hide(); 218 sdButton->hide();
221 } 219 }
222 if( !StorageInfo::hasCf() ) { 220 if( !StorageInfo::hasCf() ) {
223 qDebug("not have cf"); 221 qDebug("not have cf");
224 cfButton->hide(); 222 cfButton->hide();
225 } 223 }
226 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 224 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
227 currentDir.setPath( QDir::currentDirPath()); 225 currentDir.setPath( QDir::currentDirPath());
228 226
229 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 227 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
230 currentRemoteDir.setPath( QDir::currentDirPath()); 228 currentRemoteDir.setPath( QDir::currentDirPath());
231 229
232 // b = TRUE; 230 // b = TRUE;
233 231
234 filterStr="*"; 232 filterStr="*";
235 b=FALSE; 233 b=FALSE;
236 showMenuHidden(); 234 showMenuHidden();
237 TabWidget->setCurrentWidget(0); 235 TabWidget->setCurrentWidget(0);
238 236
239} 237}
240 238
241void AdvancedFm::initConnections() 239void AdvancedFm::initConnections()
242{ 240{
243 241
244 connect( qApp,SIGNAL( aboutToQuit()), 242 connect( qApp,SIGNAL( aboutToQuit()),
245 this, SLOT( cleanUp()) ); 243 this, SLOT( cleanUp()) );
246 connect( qpeDirButton ,SIGNAL(released()), 244 connect( qpeDirButton ,SIGNAL(released()),
247 this,SLOT( QPEButtonPushed()) ); 245 this,SLOT( QPEButtonPushed()) );
248 connect( cfButton ,SIGNAL(released()), 246 connect( cfButton ,SIGNAL(released()),
249 this,SLOT( CFButtonPushed()) ); 247 this,SLOT( CFButtonPushed()) );
250 connect( sdButton ,SIGNAL(released()), 248 connect( sdButton ,SIGNAL(released()),
251 this,SLOT( SDButtonPushed()) ); 249 this,SLOT( SDButtonPushed()) );
252 connect( cdUpButton ,SIGNAL(released()), 250 connect( cdUpButton ,SIGNAL(released()),
253 this,SLOT( upDir()) ); 251 this,SLOT( upDir()) );
254 connect( docButton,SIGNAL(released()), 252 connect( docButton,SIGNAL(released()),
255 this,SLOT( docButtonPushed()) ); 253 this,SLOT( docButtonPushed()) );
256 connect( homeButton,SIGNAL(released()), 254 connect( homeButton,SIGNAL(released()),
257 this,SLOT( homeButtonPushed()) ); 255 this,SLOT( homeButtonPushed()) );
258 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 256 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
259 this, SLOT( currentPathComboActivated( const QString & ) ) ); 257 this, SLOT( currentPathComboActivated( const QString & ) ) );
260 258
261 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 259 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
262 this,SLOT(currentPathComboChanged())); 260 this,SLOT(currentPathComboChanged()));
263 261
264 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 262 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
265 this,SLOT( ListClicked(QListViewItem *)) ); 263 this,SLOT( ListClicked(QListViewItem *)) );
266 264
267 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 265 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
268 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 266 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
269 267
270 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 268 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
271 269
272 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 270 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
273 this,SLOT( ListClicked(QListViewItem *)) ); 271 this,SLOT( ListClicked(QListViewItem *)) );
274 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 272 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
275 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 273 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
276 274
277 connect( TabWidget,SIGNAL(currentChanged(QWidget *)), 275 connect( TabWidget,SIGNAL(currentChanged(QWidget *)),
278 this,SLOT(tabChanged(QWidget*))); 276 this,SLOT(tabChanged(QWidget*)));
279 277
280 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); 278 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
281 279
282 connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); 280 connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&)));
283// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); 281// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int)));
284 connect( viewMenu, SIGNAL( activated(int )), this, SLOT(slotSwitchMenu(int ))); 282 connect( viewMenu, SIGNAL( activated(int )), this, SLOT(slotSwitchMenu(int )));
285// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); 283// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
286 284
287} 285}
288 286
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 78f9da2..18bbd43 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,850 +1,847 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13#include "output.h" 13#include "output.h"
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <opie/otabwidget.h>
17#include <opie/oprocess.h>
18
19#include <qpe/lnkproperties.h> 16#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 18#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
23#include <qpe/applnk.h> 20#include <qpe/applnk.h>
24#include <qpe/ir.h> 21#include <qpe/ir.h>
25 22
26#include <qmessagebox.h> 23#include <qmessagebox.h>
27#include <qmultilineedit.h> 24#include <qmultilineedit.h>
28 25
29#include <qstring.h> 26#include <qstring.h>
30 27
31#include <qlayout.h> 28#include <qlayout.h>
32#include <qpixmap.h> 29#include <qpixmap.h>
33#include <qcombobox.h> 30#include <qcombobox.h>
34#include <qpopupmenu.h> 31#include <qpopupmenu.h>
35#include <qtabwidget.h> 32#include <qtabwidget.h>
36#include <qtoolbutton.h> 33#include <qtoolbutton.h>
37#include <qlineedit.h> 34#include <qlineedit.h>
38#include <qlistview.h> 35#include <qlistview.h>
39 36
40#include <errno.h> 37#include <errno.h>
41#include <stdlib.h> 38#include <stdlib.h>
42#include <unistd.h> 39#include <unistd.h>
43#include <sys/stat.h> 40#include <sys/stat.h>
44#include <dirent.h> 41#include <dirent.h>
45#include <sys/sendfile.h> 42#include <sys/sendfile.h>
46#include <fcntl.h> 43#include <fcntl.h>
47 44
48 45
49void AdvancedFm::doDirChange() { 46void AdvancedFm::doDirChange() {
50 QString pathItem = CurrentView()->currentItem()->text(0); 47 QString pathItem = CurrentView()->currentItem()->text(0);
51 if( pathItem == "../") { 48 if( pathItem == "../") {
52 ListClicked( CurrentView()->currentItem()); 49 ListClicked( CurrentView()->currentItem());
53 } else { 50 } else {
54 if( pathItem.find(" -> ",0,TRUE) != -1) 51 if( pathItem.find(" -> ",0,TRUE) != -1)
55 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 52 pathItem = dealWithSymName((const QString&)pathItem)+"/";
56// qWarning(pathItem); 53// qWarning(pathItem);
57 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 54 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
58 } 55 }
59} 56}
60 57
61void AdvancedFm::showMenuHidden() { 58void AdvancedFm::showMenuHidden() {
62 if (b) { 59 if (b) {
63 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 60 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 61 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
65 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 62 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
66 } else { 63 } else {
67 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 64 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 65 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 66 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70 } 67 }
71 b = !b; 68 b = !b;
72 populateView(); 69 populateView();
73} 70}
74 71
75void AdvancedFm::showHidden() { 72void AdvancedFm::showHidden() {
76 if (b) { 73 if (b) {
77 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 74 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
78 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 75 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
79 } else { 76 } else {
80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 77 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
81 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 78 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
82 } 79 }
83 populateView(); 80 populateView();
84} 81}
85 82
86QString AdvancedFm::dealWithSymName(const QString &fileName) { 83QString AdvancedFm::dealWithSymName(const QString &fileName) {
87 QString strItem = fileName; 84 QString strItem = fileName;
88 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 85 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
89} 86}
90 87
91void AdvancedFm::runThis() { 88void AdvancedFm::runThis() {
92 if( !CurrentView()->currentItem()) return; 89 if( !CurrentView()->currentItem()) return;
93 QString fs; 90 QString fs;
94 QDir *thisDir = CurrentDir(); 91 QDir *thisDir = CurrentDir();
95 92
96 QString curFile = CurrentView()->currentItem()->text(0); 93 QString curFile = CurrentView()->currentItem()->text(0);
97 QString path = thisDir->canonicalPath(); 94 QString path = thisDir->canonicalPath();
98 95
99 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 96 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
100 97
101 curFile = dealWithSymName((const QString&)curFile); 98 curFile = dealWithSymName((const QString&)curFile);
102 99
103 if(curFile != "../") { 100 if(curFile != "../") {
104 101
105 fs = getFileSystemType((const QString &) path); 102 fs = getFileSystemType((const QString &) path);
106 QFileInfo fileInfo( path + "/" + curFile); 103 QFileInfo fileInfo( path + "/" + curFile);
107// qDebug( fileInfo.owner()); 104// qDebug( fileInfo.owner());
108 105
109 if( (fileInfo.permission( QFileInfo::ExeUser) 106 if( (fileInfo.permission( QFileInfo::ExeUser)
110 | fileInfo.permission( QFileInfo::ExeGroup) 107 | fileInfo.permission( QFileInfo::ExeGroup)
111 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 108 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
112 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 109 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
113 QCopEnvelope e("QPE/System", "execute(QString)" ); 110 QCopEnvelope e("QPE/System", "execute(QString)" );
114 e << curFile; 111 e << curFile;
115 } else { 112 } else {
116 curFile = path + "/" + curFile; 113 curFile = path + "/" + curFile;
117 DocLnk nf(curFile); 114 DocLnk nf(curFile);
118 QString execStr = nf.exec(); 115 QString execStr = nf.exec();
119// qDebug( execStr); 116// qDebug( execStr);
120 if( execStr.isEmpty() ) { 117 if( execStr.isEmpty() ) {
121 } else { 118 } else {
122 nf.execute(); 119 nf.execute();
123 } 120 }
124 } 121 }
125 } 122 }
126} 123}
127 124
128void AdvancedFm::runText() { 125void AdvancedFm::runText() {
129 if( !CurrentView()->currentItem()) return; 126 if( !CurrentView()->currentItem()) return;
130 QString curFile = CurrentView()->currentItem()->text(0); 127 QString curFile = CurrentView()->currentItem()->text(0);
131 if(curFile != "../") { 128 if(curFile != "../") {
132 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 129 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
133 curFile = dealWithSymName((const QString&)curFile); 130 curFile = dealWithSymName((const QString&)curFile);
134 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 131 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
135 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 132 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
136 e << curFile; 133 e << curFile;
137 } 134 }
138} 135}
139 136
140void AdvancedFm::makeDir() { 137void AdvancedFm::makeDir() {
141 InputDialog *fileDlg; 138 InputDialog *fileDlg;
142 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 139 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
143 fileDlg->exec(); 140 fileDlg->exec();
144 if( fileDlg->result() == 1 ) { 141 if( fileDlg->result() == 1 ) {
145 QDir *thisDir = CurrentDir(); 142 QDir *thisDir = CurrentDir();
146 QString filename = fileDlg->LineEdit1->text(); 143 QString filename = fileDlg->LineEdit1->text();
147 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 144 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
148 } 145 }
149 populateView(); 146 populateView();
150} 147}
151 148
152void AdvancedFm::doDelete() { 149void AdvancedFm::doDelete() {
153 QStringList curFileList = getPath(); 150 QStringList curFileList = getPath();
154 bool doMsg=true; 151 bool doMsg=true;
155 int count = curFileList.count(); 152 int count = curFileList.count();
156 if( count > 0) { 153 if( count > 0) {
157 if(count > 1 ) { 154 if(count > 1 ) {
158 QString msg; 155 QString msg;
159 msg=tr("Really delete\n%1 files?").arg(count); 156 msg=tr("Really delete\n%1 files?").arg(count);
160 switch ( QMessageBox::warning(this,tr("Delete"),msg 157 switch ( QMessageBox::warning(this,tr("Delete"),msg
161 ,tr("Yes"),tr("No"),0,0,1) ) 158 ,tr("Yes"),tr("No"),0,0,1) )
162 { 159 {
163 case 0: 160 case 0:
164 doMsg=false; 161 doMsg=false;
165 break; 162 break;
166 case 1: 163 case 1:
167 return; 164 return;
168 break; 165 break;
169 }; 166 };
170 } 167 }
171 168
172 QString myFile; 169 QString myFile;
173 170
174 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 171 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
175 myFile = (*it); 172 myFile = (*it);
176 if( myFile.find(" -> ",0,TRUE) != -1) 173 if( myFile.find(" -> ",0,TRUE) != -1)
177 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 174 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
178 175
179 QString f = CurrentDir()->canonicalPath(); 176 QString f = CurrentDir()->canonicalPath();
180 if(f.right(1).find("/",0,TRUE) == -1) 177 if(f.right(1).find("/",0,TRUE) == -1)
181 f += "/"; 178 f += "/";
182 f += myFile; 179 f += myFile;
183 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 180 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
184 //if file is a directory 181 //if file is a directory
185 182
186 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 183 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
187 tr("Really delete %1\nand all it's contents ?" ).arg( f ) , 184 tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
188 tr("Yes"), tr("No"), 0, 0, 1) ) { 185 tr("Yes"), tr("No"), 0, 0, 1) ) {
189 case 0: 186 case 0:
190 { 187 {
191 f=f.left(f.length()-1); 188 f=f.left(f.length()-1);
192 QString cmd="rm -rf "+f; 189 QString cmd="rm -rf "+f;
193 startProcess( (const QString)cmd.latin1() ); 190 startProcess( (const QString)cmd.latin1() );
194 populateView(); 191 populateView();
195 } 192 }
196 break; 193 break;
197 case 1: 194 case 1:
198 // exit 195 // exit
199 break; 196 break;
200 }; 197 };
201 198
202 } else { 199 } else {
203 if(doMsg) { 200 if(doMsg) {
204 switch ( QMessageBox::warning(this,tr("Delete"), 201 switch ( QMessageBox::warning(this,tr("Delete"),
205 tr("Really delete\n%1?").arg( myFile ), 202 tr("Really delete\n%1?").arg( myFile ),
206 tr("Yes"), tr("No"), 0, 0, 1) ) { 203 tr("Yes"), tr("No"), 0, 0, 1) ) {
207 case 1: 204 case 1:
208 return; 205 return;
209 break; 206 break;
210 }; 207 };
211 } 208 }
212 209
213 QString cmd="rm "+f; 210 QString cmd="rm "+f;
214 QFile file(f); 211 QFile file(f);
215 QFileInfo fi(myFile); 212 QFileInfo fi(myFile);
216 if( fi.fileName().find("../",0,TRUE)==-1) { 213 if( fi.fileName().find("../",0,TRUE)==-1) {
217// qDebug("remove link files "+myFile); 214// qDebug("remove link files "+myFile);
218 215
219// DocLnk lnk(f); 216// DocLnk lnk(f);
220 DocLnk *lnk; 217 DocLnk *lnk;
221 lnk = new DocLnk(f); 218 lnk = new DocLnk(f);
222// qDebug("Deleting doclnk " + lnk->linkFile()); 219// qDebug("Deleting doclnk " + lnk->linkFile());
223 if(lnk->isValid()) 220 if(lnk->isValid())
224 lnk->removeLinkFile(); 221 lnk->removeLinkFile();
225 // delete lnk; 222 // delete lnk;
226 file.remove(); 223 file.remove();
227 } 224 }
228 } 225 }
229 } 226 }
230 } 227 }
231 populateView(); 228 populateView();
232} 229}
233 230
234void AdvancedFm::filePerms() { 231void AdvancedFm::filePerms() {
235 QStringList curFileList = getPath(); 232 QStringList curFileList = getPath();
236 QString filePath; 233 QString filePath;
237 234
238 filePath = CurrentDir()->canonicalPath()+"/"; 235 filePath = CurrentDir()->canonicalPath()+"/";
239 236
240 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 237 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
241 filePermissions *filePerm; 238 filePermissions *filePerm;
242 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 239 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
243 QPEApplication::execDialog( filePerm ); 240 QPEApplication::execDialog( filePerm );
244 if( filePerm ) 241 if( filePerm )
245 delete filePerm; 242 delete filePerm;
246 } 243 }
247 populateView(); 244 populateView();
248} 245}
249 246
250void AdvancedFm::doProperties() { 247void AdvancedFm::doProperties() {
251#if defined(QT_QWS_OPIE) 248#if defined(QT_QWS_OPIE)
252 249
253 QStringList curFileList = getPath(); 250 QStringList curFileList = getPath();
254 251
255 QString filePath; 252 QString filePath;
256 filePath = CurrentDir()->canonicalPath()+"/"; 253 filePath = CurrentDir()->canonicalPath()+"/";
257 254
258// qDebug("%d",curFileList.count()); 255// qDebug("%d",curFileList.count());
259 256
260 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 257 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
261// qDebug((filePath+*it)); 258// qDebug((filePath+*it));
262 DocLnk lnk( (filePath+*it)); 259 DocLnk lnk( (filePath+*it));
263 LnkProperties prop( &lnk ); 260 LnkProperties prop( &lnk );
264 QPEApplication::execDialog( &prop ); 261 QPEApplication::execDialog( &prop );
265 } 262 }
266#endif 263#endif
267 264
268} 265}
269 266
270void AdvancedFm::upDir() { 267void AdvancedFm::upDir() {
271 QDir *thisDir = CurrentDir(); 268 QDir *thisDir = CurrentDir();
272 QString current = thisDir->canonicalPath(); 269 QString current = thisDir->canonicalPath();
273 QDir dir(current); 270 QDir dir(current);
274 dir.cdUp(); 271 dir.cdUp();
275 current = dir.canonicalPath(); 272 current = dir.canonicalPath();
276 chdir( current.latin1() ); 273 chdir( current.latin1() );
277 thisDir->cd( current, TRUE); 274 thisDir->cd( current, TRUE);
278 275
279 populateView(); 276 populateView();
280 update(); 277 update();
281} 278}
282 279
283void AdvancedFm::copy() { 280void AdvancedFm::copy() {
284 qApp->processEvents(); 281 qApp->processEvents();
285 QStringList curFileList = getPath(); 282 QStringList curFileList = getPath();
286 283
287 QDir *thisDir = CurrentDir(); 284 QDir *thisDir = CurrentDir();
288 QDir *thatDir = OtherDir(); 285 QDir *thatDir = OtherDir();
289 286
290 bool doMsg=true; 287 bool doMsg=true;
291 int count=curFileList.count(); 288 int count=curFileList.count();
292 if( count > 0) { 289 if( count > 0) {
293 if(count > 1 ){ 290 if(count > 1 ){
294 QString msg; 291 QString msg;
295 msg=tr("Really copy\n%1 files?").arg(count); 292 msg=tr("Really copy\n%1 files?").arg(count);
296 switch ( QMessageBox::warning(this,tr("Copy"),msg 293 switch ( QMessageBox::warning(this,tr("Copy"),msg
297 ,tr("Yes"),tr("No"),0,0,1) ) 294 ,tr("Yes"),tr("No"),0,0,1) )
298 { 295 {
299 case 0: 296 case 0:
300 doMsg=false; 297 doMsg=false;
301 break; 298 break;
302 case 1: 299 case 1:
303 return; 300 return;
304 break; 301 break;
305 }; 302 };
306 } 303 }
307 304
308 QString curFile, item, destFile; 305 QString curFile, item, destFile;
309 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 306 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
310 item=(*it); 307 item=(*it);
311 if(item.find("->",0,TRUE)) //symlink 308 if(item.find("->",0,TRUE)) //symlink
312 item = item.left(item.find("->",0,TRUE)); 309 item = item.left(item.find("->",0,TRUE));
313 310
314 curFile = thisDir->canonicalPath()+"/"+ item; 311 curFile = thisDir->canonicalPath()+"/"+ item;
315 destFile = thatDir->canonicalPath()+"/"+ item; 312 destFile = thatDir->canonicalPath()+"/"+ item;
316 313
317// qDebug("Destination file is "+destFile); 314// qDebug("Destination file is "+destFile);
318// qDebug("CurrentFile file is " + curFile); 315// qDebug("CurrentFile file is " + curFile);
319 316
320 QFile f(destFile); 317 QFile f(destFile);
321 if( f.exists()) { 318 if( f.exists()) {
322 if(doMsg) { 319 if(doMsg) {
323 switch ( QMessageBox::warning(this,tr("File Exists!"), 320 switch ( QMessageBox::warning(this,tr("File Exists!"),
324 tr("%1 exists. Ok to overwrite?").arg( item ), 321 tr("%1 exists. Ok to overwrite?").arg( item ),
325 tr("Yes"),tr("No"),0,0,1) ) { 322 tr("Yes"),tr("No"),0,0,1) ) {
326 case 1: 323 case 1:
327 return; 324 return;
328 break; 325 break;
329 }; 326 };
330 } 327 }
331 f.remove(); 328 f.remove();
332 } 329 }
333 330
334 if( !copyFile( curFile, destFile) ) { 331 if( !copyFile( curFile, destFile) ) {
335 QMessageBox::message("AdvancedFm", 332 QMessageBox::message("AdvancedFm",
336 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 333 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
337 return; 334 return;
338 } 335 }
339 } 336 }
340 setOtherTabCurrent(); 337 setOtherTabCurrent();
341 rePopulate(); 338 rePopulate();
342 } 339 }
343} 340}
344 341
345void AdvancedFm::copyAs() { 342void AdvancedFm::copyAs() {
346 qApp->processEvents(); 343 qApp->processEvents();
347 344
348 QStringList curFileList = getPath(); 345 QStringList curFileList = getPath();
349 QString curFile, item; 346 QString curFile, item;
350 InputDialog *fileDlg; 347 InputDialog *fileDlg;
351 348
352 QDir *thisDir = CurrentDir(); 349 QDir *thisDir = CurrentDir();
353 QDir *thatDir = OtherDir(); 350 QDir *thatDir = OtherDir();
354 351
355 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 352 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
356 QString destFile; 353 QString destFile;
357 item=(*it); 354 item=(*it);
358 curFile = thisDir->canonicalPath()+"/"+(*it); 355 curFile = thisDir->canonicalPath()+"/"+(*it);
359 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 356 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
360 357
361 fileDlg->setInputText((const QString &) destFile ); 358 fileDlg->setInputText((const QString &) destFile );
362 fileDlg->exec(); 359 fileDlg->exec();
363 360
364 if( fileDlg->result() == 1 ) { 361 if( fileDlg->result() == 1 ) {
365 QString filename = fileDlg->LineEdit1->text(); 362 QString filename = fileDlg->LineEdit1->text();
366 destFile = thatDir->canonicalPath()+"/"+filename; 363 destFile = thatDir->canonicalPath()+"/"+filename;
367 364
368 QFile f( destFile); 365 QFile f( destFile);
369 if( f.exists()) { 366 if( f.exists()) {
370 switch (QMessageBox::warning(this,tr("File Exists!"), 367 switch (QMessageBox::warning(this,tr("File Exists!"),
371 item+tr("\nexists. Ok to overwrite?"), 368 item+tr("\nexists. Ok to overwrite?"),
372 tr("Yes"),tr("No"),0,0,1) ) { 369 tr("Yes"),tr("No"),0,0,1) ) {
373 case 0: 370 case 0:
374 f.remove(); 371 f.remove();
375 break; 372 break;
376 case 1: 373 case 1:
377 return; 374 return;
378 break; 375 break;
379 }; 376 };
380 } 377 }
381 if( !copyFile( curFile, destFile) ) { 378 if( !copyFile( curFile, destFile) ) {
382 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 379 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
383 +curFile +tr("to\n")+destFile); 380 +curFile +tr("to\n")+destFile);
384 return; 381 return;
385 } 382 }
386 } 383 }
387 delete fileDlg; 384 delete fileDlg;
388 385
389 } 386 }
390 rePopulate(); 387 rePopulate();
391 setOtherTabCurrent(); 388 setOtherTabCurrent();
392} 389}
393 390
394void AdvancedFm::copySameDir() { 391void AdvancedFm::copySameDir() {
395 qApp->processEvents(); 392 qApp->processEvents();
396 QStringList curFileList = getPath(); 393 QStringList curFileList = getPath();
397 QString curFile, item, destFile; 394 QString curFile, item, destFile;
398 InputDialog *fileDlg; 395 InputDialog *fileDlg;
399 396
400 QDir *thisDir = CurrentDir(); 397 QDir *thisDir = CurrentDir();
401 398
402 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 399 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
403 item=(*it); 400 item=(*it);
404 curFile = thisDir->canonicalPath()+"/"+ item; 401 curFile = thisDir->canonicalPath()+"/"+ item;
405 402
406 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 403 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
407 fileDlg->setInputText((const QString &) destFile ); 404 fileDlg->setInputText((const QString &) destFile );
408 fileDlg->exec(); 405 fileDlg->exec();
409 406
410 if( fileDlg->result() == 1 ) { 407 if( fileDlg->result() == 1 ) {
411 408
412 QString filename = fileDlg->LineEdit1->text(); 409 QString filename = fileDlg->LineEdit1->text();
413 destFile = thisDir->canonicalPath()+"/"+filename; 410 destFile = thisDir->canonicalPath()+"/"+filename;
414 411
415 QFile f(destFile); 412 QFile f(destFile);
416 if( f.exists()) { 413 if( f.exists()) {
417 switch (QMessageBox::warning(this,tr("Delete"), 414 switch (QMessageBox::warning(this,tr("Delete"),
418 destFile+tr(" already exists.\nDo you really want to delete it?"), 415 destFile+tr(" already exists.\nDo you really want to delete it?"),
419 tr("Yes"),tr("No"),0,0,1) ) { 416 tr("Yes"),tr("No"),0,0,1) ) {
420 case 0: 417 case 0:
421 418
422 f.remove(); 419 f.remove();
423 break; 420 break;
424 case 1: 421 case 1:
425 return; 422 return;
426 break; 423 break;
427 }; 424 };
428 } 425 }
429 if(!copyFile( curFile,destFile) ) { 426 if(!copyFile( curFile,destFile) ) {
430 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 427 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
431 +curFile +tr("to\n")+destFile); 428 +curFile +tr("to\n")+destFile);
432 return; 429 return;
433 } 430 }
434 431
435// qDebug("copy "+curFile+" as "+destFile); 432// qDebug("copy "+curFile+" as "+destFile);
436 } 433 }
437 delete fileDlg; 434 delete fileDlg;
438 } 435 }
439 rePopulate(); 436 rePopulate();
440} 437}
441 438
442void AdvancedFm::move() { 439void AdvancedFm::move() {
443 qApp->processEvents(); 440 qApp->processEvents();
444 441
445 QStringList curFileList = getPath(); 442 QStringList curFileList = getPath();
446 if( curFileList.count() > 0) { 443 if( curFileList.count() > 0) {
447 QString curFile, destFile, item; 444 QString curFile, destFile, item;
448 445
449 QDir *thisDir = CurrentDir(); 446 QDir *thisDir = CurrentDir();
450 QDir *thatDir = OtherDir(); 447 QDir *thatDir = OtherDir();
451 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 448 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
452 item=(*it); 449 item=(*it);
453 QString destFile = thatDir->canonicalPath(); 450 QString destFile = thatDir->canonicalPath();
454 451
455 if(destFile.right(1).find("/",0,TRUE) == -1) 452 if(destFile.right(1).find("/",0,TRUE) == -1)
456 destFile+="/"; 453 destFile+="/";
457 destFile += item; 454 destFile += item;
458// qDebug("Destination file is "+destFile); 455// qDebug("Destination file is "+destFile);
459 456
460 curFile = thisDir->canonicalPath(); 457 curFile = thisDir->canonicalPath();
461 if(curFile.right(1).find("/",0,TRUE) == -1) 458 if(curFile.right(1).find("/",0,TRUE) == -1)
462 curFile +="/"; 459 curFile +="/";
463 curFile+= item; 460 curFile+= item;
464// qDebug("CurrentFile file is " + curFile); 461// qDebug("CurrentFile file is " + curFile);
465 462
466 if(QFileInfo(curFile).isDir()) { 463 if(QFileInfo(curFile).isDir()) {
467 moveDirectory( curFile, destFile ); 464 moveDirectory( curFile, destFile );
468 rePopulate(); 465 rePopulate();
469 return; 466 return;
470 } 467 }
471 468
472 QFile f( curFile); 469 QFile f( curFile);
473 if( f.exists()) { 470 if( f.exists()) {
474 if( !copyFile( curFile, destFile) ) { 471 if( !copyFile( curFile, destFile) ) {
475 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 472 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
476 return; 473 return;
477 } else 474 } else
478 QFile::remove(curFile); 475 QFile::remove(curFile);
479 } 476 }
480 } 477 }
481 478
482 } 479 }
483 rePopulate(); 480 rePopulate();
484 setOtherTabCurrent(); 481 setOtherTabCurrent();
485} 482}
486 483
487bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { 484bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
488 int err = 0; 485 int err = 0;
489 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; 486 if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
490 err = system((const char*)cmd); 487 err = system((const char*)cmd);
491 } else 488 } else
492 err = -1; 489 err = -1;
493 490
494 if(err!=0) { 491 if(err!=0) {
495 QMessageBox::message(tr("Note"),tr("Could not move\n") + src); 492 QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
496 return false; 493 return false;
497 } 494 }
498 return true; 495 return true;
499} 496}
500 497
501bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { 498bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
502 499
503 QStringcmd = "/bin/cp -fpR " + src + " " + dest; 500 QString cmd = "/bin/cp -fpR " + src + " " + dest;
504 qWarning(cmd); 501 qWarning(cmd);
505 interr = system( (const char *) cmd ); 502 int err = system( (const char *) cmd );
506 if ( err != 0 ) { 503 if ( err != 0 ) {
507 QMessageBox::message("AdvancedFm", 504 QMessageBox::message("AdvancedFm",
508 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); 505 tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
509 return false; 506 return false;
510 } 507 }
511 508
512 return true; 509 return true;
513} 510}
514 511
515 512
516bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 513bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
517 514
518 515
519 if(QFileInfo(src).isDir()) { 516 if(QFileInfo(src).isDir()) {
520 if( copyDirectory( src, dest )) { 517 if( copyDirectory( src, dest )) {
521 setOtherTabCurrent(); 518 setOtherTabCurrent();
522 populateView(); 519 populateView();
523 return true; 520 return true;
524 } 521 }
525 else 522 else
526 return false; 523 return false;
527 } 524 }
528 525
529 526
530 bool success = true; 527 bool success = true;
531 struct stat status; 528 struct stat status;
532 QFile srcFile(src); 529 QFile srcFile(src);
533 QFile destFile(dest); 530 QFile destFile(dest);
534 int err=0; 531 int err=0;
535 int read_fd=0; 532 int read_fd=0;
536 int write_fd=0; 533 int write_fd=0;
537 struct stat stat_buf; 534 struct stat stat_buf;
538 off_t offset = 0; 535 off_t offset = 0;
539 if(!srcFile.open( IO_ReadOnly|IO_Raw)) { 536 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
540// qWarning("open failed"); 537// qWarning("open failed");
541 return success = false; 538 return success = false;
542 } 539 }
543 read_fd = srcFile.handle(); 540 read_fd = srcFile.handle();
544 if(read_fd != -1) { 541 if(read_fd != -1) {
545 fstat (read_fd, &stat_buf); 542 fstat (read_fd, &stat_buf);
546 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 543 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
547// qWarning("destfile open failed"); 544// qWarning("destfile open failed");
548 return success = false; 545 return success = false;
549 } 546 }
550 write_fd = destFile.handle(); 547 write_fd = destFile.handle();
551 if(write_fd != -1) { 548 if(write_fd != -1) {
552 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 549 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
553 if( err == -1) { 550 if( err == -1) {
554 QString msg; 551 QString msg;
555 switch(err) { 552 switch(err) {
556 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 553 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
557 case EINVAL: msg = "Descriptor is not valid or locked. "; 554 case EINVAL: msg = "Descriptor is not valid or locked. ";
558 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 555 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
559 case EIO: msg = "Unspecified error while reading from in_fd."; 556 case EIO: msg = "Unspecified error while reading from in_fd.";
560 }; 557 };
561 success = false; 558 success = false;
562// qWarning(msg); 559// qWarning(msg);
563 } 560 }
564 } else { 561 } else {
565 success = false; 562 success = false;
566 } 563 }
567 } else { 564 } else {
568 success = false; 565 success = false;
569 } 566 }
570 srcFile.close(); 567 srcFile.close();
571 destFile.close(); 568 destFile.close();
572 // Set file permissions 569 // Set file permissions
573 if( stat( (const char *) src, &status ) == 0 ) { 570 if( stat( (const char *) src, &status ) == 0 ) {
574 chmod( (const char *) dest, status.st_mode ); 571 chmod( (const char *) dest, status.st_mode );
575 } 572 }
576 573
577 return success; 574 return success;
578} 575}
579 576
580void AdvancedFm::runCommand() { 577void AdvancedFm::runCommand() {
581 if( !CurrentView()->currentItem()) return; 578 if( !CurrentView()->currentItem()) return;
582 QDir *thisDir = CurrentDir(); 579 QDir *thisDir = CurrentDir();
583 580
584 QString curFile; 581 QString curFile;
585 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 582 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
586 583
587 InputDialog *fileDlg; 584 InputDialog *fileDlg;
588 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 585 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
589 fileDlg->setInputText(curFile); 586 fileDlg->setInputText(curFile);
590 fileDlg->exec(); 587 fileDlg->exec();
591 //QString command; 588 //QString command;
592 589
593 if( fileDlg->result() == 1 ) { 590 if( fileDlg->result() == 1 ) {
594// qDebug(fileDlg->LineEdit1->text()); 591// qDebug(fileDlg->LineEdit1->text());
595 QStringList command; 592 QStringList command;
596 593
597 command << "/bin/sh"; 594 command << "/bin/sh";
598 command << "-c"; 595 command << "-c";
599 command << fileDlg->LineEdit1->text(); 596 command << fileDlg->LineEdit1->text();
600 Output *outDlg; 597 Output *outDlg;
601 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 598 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
602 QPEApplication::execDialog( outDlg ); 599 QPEApplication::execDialog( outDlg );
603 qApp->processEvents(); 600 qApp->processEvents();
604 601
605 } 602 }
606} 603}
607 604
608void AdvancedFm::runCommandStd() { 605void AdvancedFm::runCommandStd() {
609 if( !CurrentView()->currentItem()) return; 606 if( !CurrentView()->currentItem()) return;
610 QString curFile; 607 QString curFile;
611 QDir *thisDir = CurrentDir(); 608 QDir *thisDir = CurrentDir();
612 QListView *thisView = CurrentView(); 609 QListView *thisView = CurrentView();
613 if( thisView->currentItem()) 610 if( thisView->currentItem())
614 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 611 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
615 612
616 InputDialog *fileDlg; 613 InputDialog *fileDlg;
617 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 614 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
618 fileDlg->setInputText(curFile); 615 fileDlg->setInputText(curFile);
619 fileDlg->exec(); 616 fileDlg->exec();
620 617
621 if( fileDlg->result() == 1 ) { 618 if( fileDlg->result() == 1 ) {
622 qApp->processEvents(); 619 qApp->processEvents();
623 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 620 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
624 } 621 }
625} 622}
626 623
627void AdvancedFm::fileStatus() { 624void AdvancedFm::fileStatus() {
628 if( !CurrentView()->currentItem()) return; 625 if( !CurrentView()->currentItem()) return;
629 QString curFile; 626 QString curFile;
630 curFile = CurrentView()->currentItem()->text(0); 627 curFile = CurrentView()->currentItem()->text(0);
631 628
632 QStringList command; 629 QStringList command;
633 command << "/bin/sh"; 630 command << "/bin/sh";
634 command << "-c"; 631 command << "-c";
635 command << "stat -l "+ curFile; 632 command << "stat -l "+ curFile;
636 633
637 Output *outDlg; 634 Output *outDlg;
638 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 635 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
639 QPEApplication::execDialog( outDlg ); 636 QPEApplication::execDialog( outDlg );
640 qApp->processEvents(); 637 qApp->processEvents();
641} 638}
642 639
643 640
644void AdvancedFm::mkDir() { 641void AdvancedFm::mkDir() {
645 makeDir(); 642 makeDir();
646} 643}
647 644
648void AdvancedFm::rn() { 645void AdvancedFm::rn() {
649 renameIt(); 646 renameIt();
650} 647}
651 648
652void AdvancedFm::del() { 649void AdvancedFm::del() {
653 doDelete(); 650 doDelete();
654} 651}
655 652
656void AdvancedFm::mkSym() { 653void AdvancedFm::mkSym() {
657 QString cmd; 654 QString cmd;
658 QStringList curFileList = getPath(); 655 QStringList curFileList = getPath();
659 if( curFileList.count() > 0) { 656 if( curFileList.count() > 0) {
660 QDir *thisDir = CurrentDir(); 657 QDir *thisDir = CurrentDir();
661 QDir * thatDir = OtherDir(); 658 QDir * thatDir = OtherDir();
662 659
663 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 660 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
664 661
665 QString destName = thatDir->canonicalPath()+"/"+(*it); 662 QString destName = thatDir->canonicalPath()+"/"+(*it);
666 if(destName.right(1) == "/") { 663 if(destName.right(1) == "/") {
667 destName = destName.left( destName.length() -1); 664 destName = destName.left( destName.length() -1);
668 } 665 }
669 666
670 QString curFile = thisDir->canonicalPath()+"/"+(*it); 667 QString curFile = thisDir->canonicalPath()+"/"+(*it);
671 668
672 if( curFile.right(1) == "/") { 669 if( curFile.right(1) == "/") {
673 curFile = curFile.left( curFile.length() -1); 670 curFile = curFile.left( curFile.length() -1);
674 } 671 }
675 672
676 cmd = "ln -s "+curFile+" "+destName; 673 cmd = "ln -s "+curFile+" "+destName;
677// qDebug(cmd); 674// qDebug(cmd);
678 startProcess( (const QString)cmd ); 675 startProcess( (const QString)cmd );
679 } 676 }
680 rePopulate(); 677 rePopulate();
681 setOtherTabCurrent(); 678 setOtherTabCurrent();
682 } 679 }
683} 680}
684 681
685void AdvancedFm::doBeam() { 682void AdvancedFm::doBeam() {
686 Ir ir; 683 Ir ir;
687 if(!ir.supported()) { 684 if(!ir.supported()) {
688 } else { 685 } else {
689 QStringList curFileList = getPath(); 686 QStringList curFileList = getPath();
690 if( curFileList.count() > 0) { 687 if( curFileList.count() > 0) {
691 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 688 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
692 QString curFile = (*it); 689 QString curFile = (*it);
693 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 690 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
694 if( curFilePath.right(1) == "/") { 691 if( curFilePath.right(1) == "/") {
695 curFilePath = curFilePath.left( curFilePath.length() -1); 692 curFilePath = curFilePath.left( curFilePath.length() -1);
696 } 693 }
697 Ir *file = new Ir(this, "IR"); 694 Ir *file = new Ir(this, "IR");
698 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 695 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
699 file->send( curFilePath, curFile ); 696 file->send( curFilePath, curFile );
700 } 697 }
701 } 698 }
702 } 699 }
703} 700}
704 701
705void AdvancedFm::fileBeamFinished( Ir *) { 702void AdvancedFm::fileBeamFinished( Ir *) {
706 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 703 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
707} 704}
708 705
709void AdvancedFm::selectAll() { 706void AdvancedFm::selectAll() {
710 QListView *thisView = CurrentView(); 707 QListView *thisView = CurrentView();
711 thisView->selectAll(true); 708 thisView->selectAll(true);
712 thisView->setSelected( thisView->firstChild(),false); 709 thisView->setSelected( thisView->firstChild(),false);
713} 710}
714 711
715void AdvancedFm::startProcess(const QString & cmd) { 712void AdvancedFm::startProcess(const QString & cmd) {
716 QStringList command; 713 QStringList command;
717 OProcess *process; 714 OProcess *process;
718 process = new OProcess(); 715 process = new OProcess();
719 connect(process, SIGNAL(processExited(OProcess *)), 716 connect(process, SIGNAL(processExited(OProcess *)),
720 this, SLOT( processEnded(OProcess *))); 717 this, SLOT( processEnded(OProcess *)));
721 718
722 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), 719 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
723 this, SLOT( oprocessStderr(OProcess *, char *, int))); 720 this, SLOT( oprocessStderr(OProcess *, char *, int)));
724 721
725 command << "/bin/sh"; 722 command << "/bin/sh";
726 command << "-c"; 723 command << "-c";
727 command << cmd.latin1(); 724 command << cmd.latin1();
728 *process << command; 725 *process << command;
729 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 726 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
730 qDebug("could not start process"); 727 qDebug("could not start process");
731} 728}
732 729
733void AdvancedFm::processEnded(OProcess *) { 730void AdvancedFm::processEnded(OProcess *) {
734 rePopulate(); 731 rePopulate();
735} 732}
736 733
737void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 734void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
738// qWarning("received stderrt %d bytes", buflen); 735// qWarning("received stderrt %d bytes", buflen);
739 736
740 QString lineStr = buffer; 737 QString lineStr = buffer;
741 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); 738 QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
742} 739}
743 740
744bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 741bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
745 if ( o->inherits( "QLineEdit" ) ) { 742 if ( o->inherits( "QLineEdit" ) ) {
746 if ( e->type() == QEvent::KeyPress ) { 743 if ( e->type() == QEvent::KeyPress ) {
747 QKeyEvent *ke = (QKeyEvent*)e; 744 QKeyEvent *ke = (QKeyEvent*)e;
748 if ( ke->key() == Key_Return || 745 if ( ke->key() == Key_Return ||
749 ke->key() == Key_Enter ) { 746 ke->key() == Key_Enter ) {
750 okRename(); 747 okRename();
751 return true; 748 return true;
752 } 749 }
753 else if ( ke->key() == Key_Escape ) { 750 else if ( ke->key() == Key_Escape ) {
754 cancelRename(); 751 cancelRename();
755 return true; 752 return true;
756 } 753 }
757 } 754 }
758 else if ( e->type() == QEvent::FocusOut ) { 755 else if ( e->type() == QEvent::FocusOut ) {
759 cancelRename(); 756 cancelRename();
760 return true; 757 return true;
761 } 758 }
762 } 759 }
763 if ( o->inherits( "QListView" ) ) { 760 if ( o->inherits( "QListView" ) ) {
764 if ( e->type() == QEvent::FocusIn ) { 761 if ( e->type() == QEvent::FocusIn ) {
765 if( o == Local_View) { //keep track of which view 762 if( o == Local_View) { //keep track of which view
766 whichTab=1; 763 whichTab=1;
767 } 764 }
768 else { 765 else {
769 whichTab=2; 766 whichTab=2;
770 } 767 }
771 } 768 }
772 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection 769 OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
773 } 770 }
774 771
775 return QWidget::eventFilter( o, e ); 772 return QWidget::eventFilter( o, e );
776} 773}
777 774
778 775
779void AdvancedFm::cancelRename() { 776void AdvancedFm::cancelRename() {
780// qDebug("cancel rename"); 777// qDebug("cancel rename");
781 QListView * view; 778 QListView * view;
782 view = CurrentView(); 779 view = CurrentView();
783 780
784 bool resetFocus = view->viewport()->focusProxy() == renameBox; 781 bool resetFocus = view->viewport()->focusProxy() == renameBox;
785 delete renameBox; 782 delete renameBox;
786 renameBox = 0; 783 renameBox = 0;
787 if ( resetFocus ) { 784 if ( resetFocus ) {
788 view->viewport()->setFocusProxy( view); 785 view->viewport()->setFocusProxy( view);
789 view->setFocus(); 786 view->setFocus();
790 } 787 }
791} 788}
792 789
793void AdvancedFm::doRename(QListView * view) { 790void AdvancedFm::doRename(QListView * view) {
794 if( !CurrentView()->currentItem()) return; 791 if( !CurrentView()->currentItem()) return;
795 792
796 QRect r = view->itemRect( view->currentItem( )); 793 QRect r = view->itemRect( view->currentItem( ));
797 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 794 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
798 r.setX( view->contentsX() ); 795 r.setX( view->contentsX() );
799 796
800 if ( r.width() > view->visibleWidth() ) 797 if ( r.width() > view->visibleWidth() )
801 r.setWidth( view->visibleWidth() ); 798 r.setWidth( view->visibleWidth() );
802 799
803 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 800 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
804 renameBox->setFrame(true); 801 renameBox->setFrame(true);
805 802
806 renameBox->setText( view->currentItem()->text(0) ); 803 renameBox->setText( view->currentItem()->text(0) );
807 804
808 renameBox->selectAll(); 805 renameBox->selectAll();
809 renameBox->installEventFilter( this ); 806 renameBox->installEventFilter( this );
810 807
811 view->addChild( renameBox, r.x(), r.y() ); 808 view->addChild( renameBox, r.x(), r.y() );
812 809
813 renameBox->resize( r.size() ); 810 renameBox->resize( r.size() );
814 811
815 view->viewport()->setFocusProxy( renameBox ); 812 view->viewport()->setFocusProxy( renameBox );
816 813
817 renameBox->setFocus(); 814 renameBox->setFocus();
818 renameBox->show(); 815 renameBox->show();
819} 816}
820 817
821 818
822void AdvancedFm::renameIt() { 819void AdvancedFm::renameIt() {
823 if( !CurrentView()->currentItem()) return; 820 if( !CurrentView()->currentItem()) return;
824 821
825 QListView *thisView = CurrentView(); 822 QListView *thisView = CurrentView();
826 oldName = thisView->currentItem()->text(0); 823 oldName = thisView->currentItem()->text(0);
827 doRename( thisView ); 824 doRename( thisView );
828} 825}
829 826
830void AdvancedFm::okRename() { 827void AdvancedFm::okRename() {
831 if( !CurrentView()->currentItem()) return; 828 if( !CurrentView()->currentItem()) return;
832 829
833 QString newName = renameBox->text(); 830 QString newName = renameBox->text();
834 cancelRename(); 831 cancelRename();
835 QListView * view = CurrentView(); 832 QListView * view = CurrentView();
836 QString path = CurrentDir()->canonicalPath() + "/"; 833 QString path = CurrentDir()->canonicalPath() + "/";
837 oldName = path + oldName; 834 oldName = path + oldName;
838 newName = path + newName; 835 newName = path + newName;
839 if( rename( oldName.latin1(), newName.latin1())== -1) 836 if( rename( oldName.latin1(), newName.latin1())== -1)
840 QMessageBox::message(tr("Note"),tr("Could not rename")); 837 QMessageBox::message(tr("Note"),tr("Could not rename"));
841 else 838 else
842 oldName = ""; 839 oldName = "";
843 view->takeItem( view->currentItem() ); 840 view->takeItem( view->currentItem() );
844 delete view->currentItem(); 841 delete view->currentItem();
845 rePopulate(); 842 rePopulate();
846} 843}
847 844
848void AdvancedFm::openSearch() { 845void AdvancedFm::openSearch() {
849 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 846 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
850} 847}
diff --git a/noncore/apps/advancedfm/config.in b/noncore/apps/advancedfm/config.in
index 72a1f1b..0ba1487 100644
--- a/noncore/apps/advancedfm/config.in
+++ b/noncore/apps/advancedfm/config.in
@@ -1,4 +1,4 @@
1 config ADVANCEDFM 1 config ADVANCEDFM
2 boolean "opie-advancedfm (advanced file manager)" 2 boolean "opie-advancedfm (advanced file manager)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp
index 51e38dc..3c1a164 100644
--- a/noncore/apps/advancedfm/main.cpp
+++ b/noncore/apps/advancedfm/main.cpp
@@ -1,33 +1,33 @@
1 1
2/*************************************************************************** 2/***************************************************************************
3 main.cpp - description 3 main.cpp - description
4 ------------------- 4 -------------------
5 begin : March 10, 2002 5 begin : March 10, 2002
6 copyright : (C) 2002 by llornkcor 6 copyright : (C) 2002 by llornkcor
7 email : ljp@llornkcor.com 7 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify * 8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by * 9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or * 10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. * 11 * (at your option) any later version. *
12 ***************************************************************************/ 12 ***************************************************************************/
13#include <qpe/qpeapplication.h>
14
15
16 13
17#include "advancedfm.h" 14#include "advancedfm.h"
18 15
19#ifdef NOQUICKLAUNCH 16#ifdef NOQUICKLAUNCH
17
18#include <qpe/qpeapplication.h>
19
20int main(int argc, char *argv[]) 20int main(int argc, char *argv[])
21{ 21{
22 QPEApplication a(argc, argv); 22 QPEApplication a(argc, argv);
23 23
24 AdvancedFm advencedFm; 24 AdvancedFm advencedFm;
25 a.showMainWidget( &advencedFm); 25 a.showMainWidget( &advencedFm);
26 return a.exec(); 26 return a.exec();
27} 27}
28#else 28#else
29#include <opie/oapplicationfactory.h> 29#include <opie2/oapplicationfactory.h>
30 30
31OPIE_EXPORT_APP( OApplicationFactory<AdvancedFm> ) 31OPIE_EXPORT_APP( OApplicationFactory<AdvancedFm> )
32 32
33#endif 33#endif
diff --git a/noncore/apps/advancedfm/opie-advancedfm.control b/noncore/apps/advancedfm/opie-advancedfm.control
index 5bab6ab..bb311c1 100644
--- a/noncore/apps/advancedfm/opie-advancedfm.control
+++ b/noncore/apps/advancedfm/opie-advancedfm.control
@@ -1,10 +1,10 @@
1Package: opie-advancedfm 1Package: opie-advancedfm
2Files: plugins/application/libadvancedfm.so* bin/advancedfm apps/Applications/advancedfm.desktop pics/advancedfm 2Files: plugins/application/libadvancedfm.so* bin/advancedfm apps/Applications/advancedfm.desktop pics/advancedfm
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: L.J. Potter <lpotter@trolltech.com> 5Maintainer: L.J. Potter <lpotter@trolltech.com>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal, libopiecore2, libopieui2
8Description: Advanced File Manager 8Description: Advanced File Manager
9 The advanced file manager for the Opie environment. 9 The advanced file manager for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 33abdfc..7dc2416 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,278 +1,276 @@
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>
9
10#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
11#include <qpe/applnk.h> 9#include <qpe/applnk.h>
12 10
13#include <qfile.h> 11#include <qfile.h>
14#include <qmultilineedit.h> 12#include <qmultilineedit.h>
15#include <qpushbutton.h> 13#include <qpushbutton.h>
16#include <qlayout.h> 14#include <qlayout.h>
17 15
18#include <errno.h> 16#include <errno.h>
19 17
20/* XPM */ 18/* XPM */
21static char * filesave_xpm[] = { 19static char * filesave_xpm[] = {
22"16 16 78 1", 20"16 16 78 1",
23" c None", 21" c None",
24". c #343434", 22". c #343434",
25"+ c #A0A0A0", 23"+ c #A0A0A0",
26"@ c #565656", 24"@ c #565656",
27"# c #9E9E9E", 25"# c #9E9E9E",
28"$ c #525252", 26"$ c #525252",
29"% c #929292", 27"% c #929292",
30"& c #676767", 28"& c #676767",
31"* c #848484", 29"* c #848484",
32"= c #666666", 30"= c #666666",
33"- c #D8D8D8", 31"- c #D8D8D8",
34"; c #FFFFFF", 32"; c #FFFFFF",
35"> c #DBDBDB", 33"> c #DBDBDB",
36", c #636363", 34", c #636363",
37"' c #989898", 35"' c #989898",
38") c #2D2D2D", 36") c #2D2D2D",
39"! c #909090", 37"! c #909090",
40"~ c #AEAEAE", 38"~ c #AEAEAE",
41"{ c #EAEAEA", 39"{ c #EAEAEA",
42"] c #575757", 40"] c #575757",
43"^ c #585858", 41"^ c #585858",
44"/ c #8A8A8A", 42"/ c #8A8A8A",
45"( c #828282", 43"( c #828282",
46"_ c #6F6F6F", 44"_ c #6F6F6F",
47": c #C9C9C9", 45": c #C9C9C9",
48"< c #050505", 46"< c #050505",
49"[ c #292929", 47"[ c #292929",
50"} c #777777", 48"} c #777777",
51"| c #616161", 49"| c #616161",
52"1 c #3A3A3A", 50"1 c #3A3A3A",
53"2 c #BEBEBE", 51"2 c #BEBEBE",
54"3 c #2C2C2C", 52"3 c #2C2C2C",
55"4 c #7C7C7C", 53"4 c #7C7C7C",
56"5 c #F6F6F6", 54"5 c #F6F6F6",
57"6 c #FCFCFC", 55"6 c #FCFCFC",
58"7 c #6B6B6B", 56"7 c #6B6B6B",
59"8 c #959595", 57"8 c #959595",
60"9 c #4F4F4F", 58"9 c #4F4F4F",
61"0 c #808080", 59"0 c #808080",
62"a c #767676", 60"a c #767676",
63"b c #818181", 61"b c #818181",
64"c c #B8B8B8", 62"c c #B8B8B8",
65"d c #FBFBFB", 63"d c #FBFBFB",
66"e c #F9F9F9", 64"e c #F9F9F9",
67"f c #CCCCCC", 65"f c #CCCCCC",
68"g c #030303", 66"g c #030303",
69"h c #737373", 67"h c #737373",
70"i c #7A7A7A", 68"i c #7A7A7A",
71"j c #7E7E7E", 69"j c #7E7E7E",
72"k c #6A6A6A", 70"k c #6A6A6A",
73"l c #FAFAFA", 71"l c #FAFAFA",
74"m c #505050", 72"m c #505050",
75"n c #9D9D9D", 73"n c #9D9D9D",
76"o c #333333", 74"o c #333333",
77"p c #7B7B7B", 75"p c #7B7B7B",
78"q c #787878", 76"q c #787878",
79"r c #696969", 77"r c #696969",
80"s c #494949", 78"s c #494949",
81"t c #555555", 79"t c #555555",
82"u c #949494", 80"u c #949494",
83"v c #E6E6E6", 81"v c #E6E6E6",
84"w c #424242", 82"w c #424242",
85"x c #515151", 83"x c #515151",
86"y c #535353", 84"y c #535353",
87"z c #3E3E3E", 85"z c #3E3E3E",
88"A c #D4D4D4", 86"A c #D4D4D4",
89"B c #0C0C0C", 87"B c #0C0C0C",
90"C c #353535", 88"C c #353535",
91"D c #474747", 89"D c #474747",
92"E c #ECECEC", 90"E c #ECECEC",
93"F c #919191", 91"F c #919191",
94"G c #7D7D7D", 92"G c #7D7D7D",
95"H c #000000", 93"H c #000000",
96"I c #404040", 94"I c #404040",
97"J c #858585", 95"J c #858585",
98"K c #323232", 96"K c #323232",
99"L c #D0D0D0", 97"L c #D0D0D0",
100"M c #1C1C1C", 98"M c #1C1C1C",
101" ...+ ", 99" ...+ ",
102" @#$%&..+ ", 100" @#$%&..+ ",
103" .*=-;;>,..+ ", 101" .*=-;;>,..+ ",
104" ')!~;;;;;;{]..", 102" ')!~;;;;;;{]..",
105" ^/(-;;;;;;;_:<", 103" ^/(-;;;;;;;_:<",
106" [}|;;;;;;;{12$", 104" [}|;;;;;;;{12$",
107" #34-55;;;;678$+", 105" #34-55;;;;678$+",
108" 90ab=c;dd;e1fg ", 106" 90ab=c;dd;e1fg ",
109" [ahij((kbl0mn$ ", 107" [ahij((kbl0mn$ ",
110" op^q^^7r&]s/$+ ", 108" op^q^^7r&]s/$+ ",
111"@btu;vbwxy]zAB ", 109"@btu;vbwxy]zAB ",
112"CzDEvEv;;DssF$ ", 110"CzDEvEv;;DssF$ ",
113"G.H{E{E{IxsJ$+ ", 111"G.H{E{E{IxsJ$+ ",
114" +...vEKxzLM ", 112" +...vEKxzLM ",
115" +...z]n$ ", 113" +...z]n$ ",
116" +... "}; 114" +... "};
117 115
118Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 116Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
119 : QDialog( parent, name, modal, fl ) 117 : QDialog( parent, name, modal, fl )
120{ 118{
121 QStringList cmmds; 119 QStringList cmmds;
122// cmmds=QStringList::split( " ", commands, false); 120// cmmds=QStringList::split( " ", commands, false);
123 cmmds=commands; 121 cmmds=commands;
124// qDebug("count %d", cmmds.count()); 122// qDebug("count %d", cmmds.count());
125 if ( !name ) 123 if ( !name )
126 setName( tr("Output")); 124 setName( tr("Output"));
127 resize( 196, 269 ); 125 resize( 196, 269 );
128 setCaption( name ); 126 setCaption( name );
129 127
130 OutputLayout = new QGridLayout( this ); 128 OutputLayout = new QGridLayout( this );
131 OutputLayout->setSpacing( 2); 129 OutputLayout->setSpacing( 2);
132 OutputLayout->setMargin( 2); 130 OutputLayout->setMargin( 2);
133 131
134 QPushButton *docButton; 132 QPushButton *docButton;
135 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 133 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
136 docButton->setFixedSize( QSize( 20, 20 ) ); 134 docButton->setFixedSize( QSize( 20, 20 ) );
137 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 135 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
138 // docButton->setFlat(TRUE); 136 // docButton->setFlat(TRUE);
139 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 137 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
140 138
141 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 139 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
142 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 140 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
143 141
144 proc = new OProcess(); 142 proc = new OProcess();
145 143
146 connect(proc, SIGNAL(processExited(OProcess *)), 144 connect(proc, SIGNAL(processExited(OProcess *)),
147 this, SLOT( processFinished())); 145 this, SLOT( processFinished()));
148 146
149 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 147 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
150 this, SLOT(commandStdout(OProcess *, char *, int))); 148 this, SLOT(commandStdout(OProcess *, char *, int)));
151 149
152 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 150 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
153 this, SLOT(commandStderr(OProcess *, char *, int))); 151 this, SLOT(commandStderr(OProcess *, char *, int)));
154 152
155// connect( , SIGNAL(received(const QByteArray &)), 153// connect( , SIGNAL(received(const QByteArray &)),
156// this, SLOT(commandStdin(const QByteArray &))); 154// this, SLOT(commandStdin(const QByteArray &)));
157 155
158// * proc << commands.latin1(); 156// * proc << commands.latin1();
159 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 157 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
160 qDebug( "%s", (*it).latin1() ); 158 qDebug( "%s", (*it).latin1() );
161 * proc << (*it).latin1(); 159 * proc << (*it).latin1();
162 } 160 }
163 161
164 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 162 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
165 163
166 OutputEdit->append(tr("Process could not start") ); 164 OutputEdit->append(tr("Process could not start") );
167 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 165 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
168 perror("Error: "); 166 perror("Error: ");
169 QString errorMsg=tr("Error\n")+(QString)strerror(errno); 167 QString errorMsg=tr("Error\n")+(QString)strerror(errno);
170 OutputEdit->append( errorMsg); 168 OutputEdit->append( errorMsg);
171 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 169 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
172 } 170 }
173} 171}
174 172
175Output::~Output() { 173Output::~Output() {
176} 174}
177 175
178void Output::saveOutput() { 176void Output::saveOutput() {
179 177
180 InputDialog *fileDlg; 178 InputDialog *fileDlg;
181 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 179 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
182 fileDlg->exec(); 180 fileDlg->exec();
183 if( fileDlg->result() == 1 ) { 181 if( fileDlg->result() == 1 ) {
184 QString filename = QPEApplication::documentDir(); 182 QString filename = QPEApplication::documentDir();
185 if(filename.right(1).find('/') == -1) 183 if(filename.right(1).find('/') == -1)
186 filename+="/"; 184 filename+="/";
187 QString name = fileDlg->LineEdit1->text(); 185 QString name = fileDlg->LineEdit1->text();
188 filename+="text/plain/"+name; 186 filename+="text/plain/"+name;
189 qDebug(filename); 187 qDebug(filename);
190 188
191 QFile f(filename); 189 QFile f(filename);
192 f.open( IO_WriteOnly); 190 f.open( IO_WriteOnly);
193 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 191 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
194 DocLnk lnk; 192 DocLnk lnk;
195 lnk.setName(name); //sets file name 193 lnk.setName(name); //sets file name
196 lnk.setFile(filename); //sets File property 194 lnk.setFile(filename); //sets File property
197 lnk.setType("text/plain"); 195 lnk.setType("text/plain");
198 if(!lnk.writeLink()) { 196 if(!lnk.writeLink()) {
199 qDebug("Writing doclink did not work"); 197 qDebug("Writing doclink did not work");
200 } 198 }
201 } else 199 } else
202 qWarning("Could not write file"); 200 qWarning("Could not write file");
203 f.close(); 201 f.close();
204 } 202 }
205} 203}
206 204
207void Output::commandStdout(OProcess*, char *buffer, int buflen) { 205void Output::commandStdout(OProcess*, char *buffer, int buflen) {
208 qWarning("received stdout %d bytes", buflen); 206 qWarning("received stdout %d bytes", buflen);
209 207
210// QByteArray data(buflen); 208// QByteArray data(buflen);
211// data.fill(*buffer, buflen); 209// data.fill(*buffer, buflen);
212// for (uint i = 0; i < data.count(); i++ ) { 210// for (uint i = 0; i < data.count(); i++ ) {
213// printf("%c", buffer[i] ); 211// printf("%c", buffer[i] );
214// } 212// }
215// printf("\n"); 213// printf("\n");
216 214
217 QString lineStr = buffer; 215 QString lineStr = buffer;
218 lineStr=lineStr.left(lineStr.length()-1); 216 lineStr=lineStr.left(lineStr.length()-1);
219 OutputEdit->append(lineStr); 217 OutputEdit->append(lineStr);
220 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 218 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
221} 219}
222 220
223 221
224void Output::commandStdin( const QByteArray &data) { 222void Output::commandStdin( const QByteArray &data) {
225 qWarning("received stdin %d bytes", data.size()); 223 qWarning("received stdin %d bytes", data.size());
226 // recieved data from the io layer goes to sz 224 // recieved data from the io layer goes to sz
227 proc->writeStdin(data.data(), data.size()); 225 proc->writeStdin(data.data(), data.size());
228} 226}
229 227
230void Output::commandStderr(OProcess*, char *buffer, int buflen) { 228void Output::commandStderr(OProcess*, char *buffer, int buflen) {
231 qWarning("received stderrt %d bytes", buflen); 229 qWarning("received stderrt %d bytes", buflen);
232 230
233 QString lineStr = buffer; 231 QString lineStr = buffer;
234// lineStr=lineStr.left(lineStr.length()-1); 232// lineStr=lineStr.left(lineStr.length()-1);
235 OutputEdit->append(lineStr); 233 OutputEdit->append(lineStr);
236 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 234 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
237} 235}
238 236
239void Output::processFinished() { 237void Output::processFinished() {
240 238
241 delete proc; 239 delete proc;
242 OutputEdit->append( tr("\nFinished\n") ); 240 OutputEdit->append( tr("\nFinished\n") );
243 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 241 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
244// close(); 242// close();
245// disconnect( layer(), SIGNAL(received(const QByteArray &)), 243// disconnect( layer(), SIGNAL(received(const QByteArray &)),
246// this, SLOT(commandStdin(const QByteArray &))); 244// this, SLOT(commandStdin(const QByteArray &)));
247} 245}
248 246
249//============================== 247//==============================
250 248
251InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 249InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
252 : QDialog( parent, name, modal, fl ) 250 : QDialog( parent, name, modal, fl )
253{ 251{
254 if ( !name ) 252 if ( !name )
255 setName( "InputDialog" ); 253 setName( "InputDialog" );
256 resize( 234, 50 ); 254 resize( 234, 50 );
257 setMaximumSize( QSize( 240, 50 ) ); 255 setMaximumSize( QSize( 240, 50 ) );
258 setCaption( tr(name ) ); 256 setCaption( tr(name ) );
259 257
260 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 258 LineEdit1 = new QLineEdit( this, "LineEdit1" );
261 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 259 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
262 LineEdit1->setFocus(); 260 LineEdit1->setFocus();
263 LineEdit1->setFocus(); 261 LineEdit1->setFocus();
264 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 262 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
265} 263}
266 264
267InputDialog::~InputDialog() { 265InputDialog::~InputDialog() {
268 inputText = LineEdit1->text(); 266 inputText = LineEdit1->text();
269} 267}
270 268
271void InputDialog::setInputText(const QString &string) { 269void InputDialog::setInputText(const QString &string) {
272 LineEdit1->setText( string); 270 LineEdit1->setText( string);
273} 271}
274 272
275void InputDialog::returned() { 273void InputDialog::returned() {
276 inputText = LineEdit1->text(); 274 inputText = LineEdit1->text();
277 this->accept(); 275 this->accept();
278} 276}
diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h
index 199a684..26c0fa0 100644
--- a/noncore/apps/advancedfm/output.h
+++ b/noncore/apps/advancedfm/output.h
@@ -1,65 +1,65 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file 'outputEdit.ui' 2** Form interface generated from reading ui file 'outputEdit.ui'
3** 3**
4** Created: Fri Apr 12 15:12:44 2002 4** Created: Fri Apr 12 15:12:44 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#ifndef OUTPUT_H 9#ifndef OUTPUT_H
10#define OUTPUT_H 10#define OUTPUT_H
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qdialog.h> 13#include <qdialog.h>
14#include <qcstring.h> 14#include <qcstring.h>
15#include <qstringlist.h> 15#include <qstringlist.h>
16#include <qlineedit.h> 16#include <qlineedit.h>
17#include <qwhatsthis.h> 17#include <qwhatsthis.h>
18 18
19#include <opie/oprocess.h> 19#include <opie2/oprocess.h>
20 20
21class QVBoxLayout; 21class QVBoxLayout;
22class QHBoxLayout; 22class QHBoxLayout;
23class QGridLayout; 23class QGridLayout;
24class QMultiLineEdit; 24class QMultiLineEdit;
25 25
26class Output : public QDialog 26class Output : public QDialog
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 31 Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
32 ~Output(); 32 ~Output();
33 33
34 QMultiLineEdit* OutputEdit; 34 QMultiLineEdit* OutputEdit;
35 35
36protected: 36protected:
37 QGridLayout* OutputLayout; 37 QGridLayout* OutputLayout;
38 OProcess *proc; 38 OProcess *proc;
39protected slots: 39protected slots:
40 void saveOutput(); 40 void saveOutput();
41 void commandStdout(OProcess*, char *, int); 41 void commandStdout(OProcess*, char *, int);
42 void commandStdin(const QByteArray &); 42 void commandStdin(const QByteArray &);
43 void commandStderr(OProcess*, char *, int); 43 void commandStderr(OProcess*, char *, int);
44 void processFinished(); 44 void processFinished();
45 private: 45 private:
46 QString cmmd; 46 QString cmmd;
47 47
48}; 48};
49 49
50class InputDialog : public QDialog 50class InputDialog : public QDialog
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 55 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
56 ~InputDialog(); 56 ~InputDialog();
57 QString inputText; 57 QString inputText;
58 QLineEdit* LineEdit1; 58 QLineEdit* LineEdit1;
59 void setInputText(const QString &); 59 void setInputText(const QString &);
60private slots: 60private slots:
61 void returned(); 61 void returned();
62 62
63}; 63};
64 64
65#endif // OUTPUT_H 65#endif // OUTPUT_H