summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp680
-rw-r--r--noncore/apps/advancedfm/advancedfm.h30
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp33
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp858
4 files changed, 629 insertions, 972 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index d8bdff7..74654fc 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -82,7 +82,9 @@ AdvancedFm::AdvancedFm( )
82AdvancedFm::~AdvancedFm() { 82AdvancedFm::~AdvancedFm() {
83} 83}
84 84
85void AdvancedFm::cleanUp() { 85
86void AdvancedFm::cleanUp()
87{
86 QString sfile=QDir::homeDirPath(); 88 QString sfile=QDir::homeDirPath();
87 if(sfile.right(1) != "/") 89 if(sfile.right(1) != "/")
88 sfile+="/._temp"; 90 sfile+="/._temp";
@@ -93,35 +95,31 @@ void AdvancedFm::cleanUp() {
93 file.remove(); 95 file.remove();
94} 96}
95 97
96void AdvancedFm::tabChanged(QWidget *w) { 98void AdvancedFm::tabChanged(QWidget *w)
97// qDebug("tab changed %d",TabWidget->getCurrentTab()); 99{
100 if( w == tab)
101 whichTab = 1;
102 else
103 whichTab = 2;
104
105 //qDebug("tab changed %d", whichTab );
106
107 QString path = CurrentDir()->canonicalPath();
108 currentPathCombo->lineEdit()->setText( path );
98 109
99 if ( w == tab) {
100// if (TabWidget->getCurrentTab() == 0) {
101// if (TabWidget->currentPageIndex() == 0) {
102 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
103 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
104 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
105 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
106 setCaption("AdvancedFm :: "+fs+" :: "
107 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
108 112
109 } 113 QString fs= getFileSystemType( (const QString &) path);
110 if ( w == tab_2) {
111// if (TabWidget->getCurrentTab() == 1) {
112 114
113// if (TabWidget->currentPageIndex() == 1) {
114 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
115 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
116 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
117 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
118 setCaption("AdvancedFm :: "+fs+" :: " 115 setCaption("AdvancedFm :: "+fs+" :: "
119 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 116 +checkDiskSpace( (const QString &) path )+ " kB free" );
120 } 117 chdir( path.latin1());
121} 118}
122 119
123 120
124void AdvancedFm::populateLocalView() { 121void AdvancedFm::populateLocalView()
122{
125 QPixmap pm; 123 QPixmap pm;
126 Local_View->clear(); 124 Local_View->clear();
127 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 125 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -135,48 +133,63 @@ void AdvancedFm::populateLocalView() {
135 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 133 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
136 QFileInfoListIterator it(*list); 134 QFileInfoListIterator it(*list);
137 QFileInfo *fi; 135 QFileInfo *fi;
138 while ( (fi=it.current()) ) { 136 while ( (fi=it.current()) )
139 if (fi->isSymLink() ) { 137 {
138 if (fi->isSymLink() )
139 {
140 QString symLink=fi->readLink(); 140 QString symLink=fi->readLink();
141 QFileInfo sym( symLink); 141 QFileInfo sym( symLink);
142 fileS.sprintf( "%10i", sym.size() ); 142 fileS.sprintf( "%10i", sym.size() );
143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
144 fileDate = sym.lastModified().toString(); 144 fileDate = sym.lastModified().toString();
145 } else { 145 }
146 else
147 {
146 fileS.sprintf( "%10i", fi->size() ); 148 fileS.sprintf( "%10i", fi->size() );
147 fileL.sprintf( "%s",fi->fileName().data() ); 149 fileL.sprintf( "%s",fi->fileName().data() );
148 fileDate= fi->lastModified().toString(); 150 fileDate= fi->lastModified().toString();
149 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 151 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() )
152 {
150 fileL+="/"; 153 fileL+="/";
151 isDir=TRUE; 154 isDir=TRUE;
152 } 155 }
153 } 156 }
154 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 157 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
155 if(fileL !="./" && fi->exists()) { 158 if(fileL !="./" && fi->exists())
159 {
156 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 160 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
157 161
158 if(isDir || fileL.find("/",0,TRUE) != -1) { 162 if(isDir || fileL.find("/",0,TRUE) != -1)
163 {
159 164
160 if( !QDir( fi->filePath() ).isReadable()) //is directory 165 if( !QDir( fi->filePath() ).isReadable()) //is directory
161 pm = Resource::loadPixmap( "lockedfolder" ); 166 pm = Resource::loadPixmap( "lockedfolder" );
162 else 167 else
163 pm= Resource::loadPixmap( "folder" ); 168 pm= Resource::loadPixmap( "folder" );
164 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 169 }
170 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
171 {
165 pm = Resource::loadPixmap( "exec"); 172 pm = Resource::loadPixmap( "exec");
166 } else if( (fileInfo.permission( QFileInfo::ExeUser) 173 }
174 else if( (fileInfo.permission( QFileInfo::ExeUser)
167 | fileInfo.permission( QFileInfo::ExeGroup) 175 | fileInfo.permission( QFileInfo::ExeGroup)
168 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 176 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
177 {
169 pm = Resource::loadPixmap( "exec"); 178 pm = Resource::loadPixmap( "exec");
170 } else if( !fi->isReadable() ) { 179 }
180 else if( !fi->isReadable() )
181 {
171 pm = Resource::loadPixmap( "locked" ); 182 pm = Resource::loadPixmap( "locked" );
172 } else { //everything else goes by mimetype 183 }
184 else { //everything else goes by mimetype
173 MimeType mt(fi->filePath()); 185 MimeType mt(fi->filePath());
174 pm=mt.pixmap(); //sets the correct pixmap for mimetype 186 pm=mt.pixmap(); //sets the correct pixmap for mimetype
175 if(pm.isNull()) 187 if(pm.isNull())
176 pm = Resource::loadPixmap( "UnknownDocument-14" ); 188 pm = Resource::loadPixmap( "UnknownDocument-14" );
177 } 189 }
178 item->setPixmap( 0,pm); 190 item->setPixmap( 0,pm);
179 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 191 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
192 {
180 // overlay link image 193 // overlay link image
181 pm= Resource::loadPixmap( "folder" ); 194 pm= Resource::loadPixmap( "folder" );
182 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 195 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -190,20 +203,24 @@ void AdvancedFm::populateLocalView() {
190 ++it; 203 ++it;
191 } 204 }
192 205
193 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 206 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1)
207 {
194 struct stat buf; 208 struct stat buf;
195 dev_t devT; 209 dev_t devT;
196 DIR *dir; 210 DIR *dir;
197 struct dirent *mydirent; 211 struct dirent *mydirent;
212
198 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 213 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
199 while ((mydirent = readdir(dir)) != NULL) { 214 while ((mydirent = readdir(dir)) != NULL)
215 {
200 lstat( mydirent->d_name, &buf); 216 lstat( mydirent->d_name, &buf);
201// qDebug(mydirent->d_name); 217// qDebug(mydirent->d_name);
202 fileL.sprintf("%s", mydirent->d_name); 218 fileL.sprintf("%s", mydirent->d_name);
203 devT = buf.st_dev; 219 devT = buf.st_dev;
204 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 220 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
205 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 221 fileDate.sprintf("%s", ctime( &buf.st_mtime));
206 if( fileL.find(".") == -1 ){ 222 if( fileL.find(".") == -1 )
223 {
207 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 224 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
208 pm = Resource::loadPixmap( "UnknownDocument-14" ); 225 pm = Resource::loadPixmap( "UnknownDocument-14" );
209 item->setPixmap( 0,pm); 226 item->setPixmap( 0,pm);
@@ -218,7 +235,8 @@ void AdvancedFm::populateLocalView() {
218} 235}
219 236
220 237
221void AdvancedFm::populateRemoteView() { 238void AdvancedFm::populateRemoteView()
239{
222 QPixmap pm; 240 QPixmap pm;
223 Remote_View->clear(); 241 Remote_View->clear();
224 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 242 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -233,50 +251,68 @@ void AdvancedFm::populateRemoteView() {
233 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 251 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
234 QFileInfoListIterator it(*list); 252 QFileInfoListIterator it(*list);
235 QFileInfo *fi; 253 QFileInfo *fi;
236 while ( (fi=it.current()) ) { 254 while ( (fi=it.current()) )
237 if (fi->isSymLink() ){ 255 {
256 if (fi->isSymLink() )
257 {
238 QString symLink=fi->readLink(); 258 QString symLink=fi->readLink();
239 // qDebug("Symlink detected "+symLink); 259 // qDebug("Symlink detected "+symLink);
240 QFileInfo sym( symLink); 260 QFileInfo sym( symLink);
241 fileS.sprintf( "%10i", sym.size() ); 261 fileS.sprintf( "%10i", sym.size() );
242 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 262 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
243 fileDate = sym.lastModified().toString(); 263 fileDate = sym.lastModified().toString();
244 } else { 264 }
265 else
266 {
245 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 267 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
246 fileS.sprintf( "%10i", fi->size() ); 268 fileS.sprintf( "%10i", fi->size() );
247 fileL.sprintf( "%s",fi->fileName().data() ); 269 fileL.sprintf( "%s",fi->fileName().data() );
248 fileDate= fi->lastModified().toString(); 270 fileDate= fi->lastModified().toString();
249 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 271
272 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() )
273 {
250 fileL+="/"; 274 fileL+="/";
251 isDir=TRUE; 275 isDir=TRUE;
252 // qDebug( fileL); 276 // qDebug( fileL);
253 } 277 }
254 } 278 }
279
255 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 280 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
256 if(fileL !="./" && fi->exists()) { 281 if(fileL !="./" && fi->exists())
282 {
257 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 283 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
258 QPixmap pm; 284 QPixmap pm;
259 285
260 if(isDir || fileL.find("/",0,TRUE) != -1) { 286 if(isDir || fileL.find("/",0,TRUE) != -1)
287 {
261 if( !QDir( fi->filePath() ).isReadable()) 288 if( !QDir( fi->filePath() ).isReadable())
262 pm = Resource::loadPixmap( "lockedfolder" ); 289 pm = Resource::loadPixmap( "lockedfolder" );
263 else 290 else
264 pm= Resource::loadPixmap( "folder" ); 291 pm= Resource::loadPixmap( "folder" );
265 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 292 }
293 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
294 {
266 pm = Resource::loadPixmap( "exec"); 295 pm = Resource::loadPixmap( "exec");
267 } else if( (fileInfo.permission( QFileInfo::ExeUser) 296 }
297 else if( (fileInfo.permission( QFileInfo::ExeUser)
268 | fileInfo.permission( QFileInfo::ExeGroup) 298 | fileInfo.permission( QFileInfo::ExeGroup)
269 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 299 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
300 {
270 pm = Resource::loadPixmap( "exec"); 301 pm = Resource::loadPixmap( "exec");
271 } else if( !fi->isReadable() ) { 302 }
303 else if( !fi->isReadable() )
304 {
272 pm = Resource::loadPixmap( "locked" ); 305 pm = Resource::loadPixmap( "locked" );
273 } else { 306 }
307 else
308 {
274 MimeType mt(fi->filePath()); 309 MimeType mt(fi->filePath());
275 pm=mt.pixmap(); //sets the correct pixmap for mimetype 310 pm=mt.pixmap(); //sets the correct pixmap for mimetype
276 if(pm.isNull()) 311 if(pm.isNull())
277 pm = Resource::loadPixmap( "UnknownDocument-14" ); 312 pm = Resource::loadPixmap( "UnknownDocument-14" );
278 } 313 }
279 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 314 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
315 {
280 // overlay link image 316 // overlay link image
281 pm= Resource::loadPixmap( "folder" ); 317 pm= Resource::loadPixmap( "folder" );
282 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 318 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -290,18 +326,23 @@ void AdvancedFm::populateRemoteView() {
290 ++it; 326 ++it;
291 } 327 }
292 328
293 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 329 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1)
330 {
294 struct stat buf; 331 struct stat buf;
295 DIR *dir; 332 DIR *dir;
296 struct dirent *mydirent; 333 struct dirent *mydirent;
297 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 334 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
298 while ((mydirent = readdir(dir)) != NULL) { 335
336 while ((mydirent = readdir(dir)) != NULL)
337 {
299 lstat( mydirent->d_name, &buf); 338 lstat( mydirent->d_name, &buf);
300// qDebug(mydirent->d_name); 339// qDebug(mydirent->d_name);
301 fileL.sprintf("%s", mydirent->d_name); 340 fileL.sprintf("%s", mydirent->d_name);
302 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 341 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
303 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 342 fileDate.sprintf("%s", ctime( &buf.st_mtime));
304 if( fileL.find(".") == -1 ){ 343
344 if( fileL.find(".") == -1 )
345 {
305 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 346 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
306 pm = Resource::loadPixmap( "UnknownDocument-14" ); 347 pm = Resource::loadPixmap( "UnknownDocument-14" );
307 item->setPixmap( 0,pm); 348 item->setPixmap( 0,pm);
@@ -315,103 +356,46 @@ void AdvancedFm::populateRemoteView() {
315 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 356 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
316} 357}
317 358
318void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 359void AdvancedFm::ListClicked(QListViewItem *selectedItem)
319 if(selectedItem) { 360{
361 if(selectedItem)
362 {
320 QString strItem=selectedItem->text(0); 363 QString strItem=selectedItem->text(0);
321 QString strSize=selectedItem->text(1); 364 QString strSize=selectedItem->text(1);
322 strSize=strSize.stripWhiteSpace(); 365 strSize=strSize.stripWhiteSpace();
323 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 366 bool isDirectory = false;
324 QString strItem2 = dealWithSymName((const QString&)strItem); 367 QString strItem2;
325// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
326 if(QDir(strItem2).exists() ) {
327 currentDir.cd(strItem2, TRUE);
328 populateLocalView();
329 368
369 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
370 {
371 strItem2 = dealWithSymName((const QString&)strItem);
372 if(QDir(strItem2).exists() )
373 strItem = strItem2;
330 } 374 }
331 } else { // not a symlink
332 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
333 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
334 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
335 currentDir.cd(strItem,FALSE);
336 populateLocalView();
337 Local_View->ensureItemVisible(Local_View->firstChild());
338 375
339 } else { 376 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
340 currentDir.cdUp(); 377 {
341 populateLocalView();
342 Local_View->ensureItemVisible(Local_View->firstChild());
343 }
344 if(QDir(strItem).exists()){
345 currentDir.cd(strItem, TRUE);
346 Local_View->ensureItemVisible(Local_View->firstChild());
347 populateLocalView();
348 }
349 } else {
350 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
351 if( QFile::exists(strItem ) ) {
352 // qDebug("clicked item "+strItem);
353 // DocLnk doc( strItem, FALSE );
354 // doc.execute();
355 // Local_View->clearSelection();
356 }
357 } //end not symlink
358 chdir(strItem.latin1());
359 }
360 378
379 if(QDir(strItem).exists())
380 isDirectory = true;
361 } 381 }
362}
363
364void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
365 382
366 if(selectedItem) { 383 if( isDirectory )
367 QString strItem=selectedItem->text(0); 384 {
368 QString strSize=selectedItem->text(1); 385 CurrentDir()->cd( strItem, TRUE);
369 strSize=strSize.stripWhiteSpace(); 386 PopulateView();
370 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 387 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
371 QString strItem2 = dealWithSymName((const QString&)strItem);
372// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
373 currentRemoteDir.cd(strItem2, TRUE);
374 populateRemoteView();
375 } else { // not a symlink
376 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
377 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
378 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
379 currentRemoteDir.cd(strItem,FALSE);
380 populateRemoteView();
381 Remote_View->ensureItemVisible(Remote_View->firstChild());
382 } else {
383 currentRemoteDir.cdUp();
384 populateRemoteView();
385 Remote_View->ensureItemVisible(Remote_View->firstChild());
386 }
387 if(QDir(strItem).exists()){
388 currentRemoteDir.cd(strItem, TRUE);
389 populateRemoteView();
390 Remote_View->ensureItemVisible(Remote_View->firstChild());
391 }
392 } else {
393 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
394 if( QFile::exists(strItem ) ) {
395 // qDebug("clicked item "+strItem);
396 // DocLnk doc( strItem, FALSE );
397 // doc.execute();
398 // Remote_View->clearSelection();
399 } 388 }
400 } //end not symlink
401 chdir(strItem.latin1()); 389 chdir(strItem.latin1());
402 } 390 }
403 } 391 }
404}
405
406 392
407void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 393void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
408// qDebug("list pressed");
409 switch (mouse) { 394 switch (mouse) {
410 case 1: 395 case 1:
411 { 396 {
412 if(renameBox != 0 ) 397 if(renameBox != 0 )
413 { 398 {
414// qDebug("cancel rename");
415 cancelRename(); 399 cancelRename();
416 } 400 }
417 401
@@ -419,83 +403,63 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i
419 break; 403 break;
420 case 2: 404 case 2:
421 menuTimer.start( 500, TRUE ); 405 menuTimer.start( 500, TRUE );
422// qDebug("Start menu timer\n");
423 break; 406 break;
424 }; 407 };
425} 408}
426 409
427void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 410void AdvancedFm::switchToLocalTab()
428
429 switch (mouse) {
430 case 1:
431 {
432 if(renameBox != 0 )
433 { 411 {
434// qDebug("cancel rename");
435 cancelRename();
436 }
437 }
438 break;
439 case 2:
440 menuTimer.start( 500, TRUE );
441// qDebug("Start menu timer");
442 break;
443 };
444}
445
446
447void AdvancedFm::switchToLocalTab() {
448 TabWidget->setCurrentTab(0); 412 TabWidget->setCurrentTab(0);
449 Local_View->setFocus(); 413 Local_View->setFocus();
450} 414}
451 415
452void AdvancedFm::switchToRemoteTab() { 416void AdvancedFm::switchToRemoteTab()
417{
453 TabWidget->setCurrentTab(1); 418 TabWidget->setCurrentTab(1);
454 Remote_View->setFocus(); 419 Remote_View->setFocus();
455} 420}
456 421
457void AdvancedFm::readConfig() { 422void AdvancedFm::readConfig()
423{
458 Config cfg("AdvancedFm"); 424 Config cfg("AdvancedFm");
459} 425}
460 426
461void AdvancedFm::writeConfig() { 427void AdvancedFm::writeConfig()
428{
462 Config cfg("AdvancedFm"); 429 Config cfg("AdvancedFm");
463} 430}
464 431
465void AdvancedFm::currentPathComboChanged() { 432void AdvancedFm::currentPathComboChanged()
466 if (TabWidget->getCurrentTab() == 0) { 433{
467// if (TabWidget->currentPageIndex() == 0) { 434 if(QDir( currentPathCombo->lineEdit()->text()).exists())
468 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 435 {
469 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 436 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
470 populateLocalView(); 437 PopulateView();
471 } else {
472 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
473 }
474 } 438 }
475 if (TabWidget->getCurrentTab() == 0) { 439 else
476// if (TabWidget->currentPageIndex() == 0) { 440 {
477 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
478 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
479 populateRemoteView();
480 } else {
481 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 441 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
482 } 442 }
483 } 443 }
484}
485 444
486void AdvancedFm::fillCombo(const QString &currentPath) { 445void AdvancedFm::fillCombo(const QString &currentPath)
446{
487// qDebug("%d",TabWidget->getCurrentTab()); 447// qDebug("%d",TabWidget->getCurrentTab());
488 if (TabWidget->getCurrentTab() == 0) { 448 if ( whichTab == 1)
489// if (TabWidget->currentPageIndex() == 0) { 449 {
490 currentPathCombo->lineEdit()->setText( currentPath); 450 currentPathCombo->lineEdit()->setText( currentPath);
491 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 451 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
452 {
492 currentPathCombo->clear(); 453 currentPathCombo->clear();
493 localDirPathStringList.prepend( currentPath ); 454 localDirPathStringList.prepend( currentPath );
494 currentPathCombo->insertStringList( localDirPathStringList,-1); 455 currentPathCombo->insertStringList( localDirPathStringList,-1);
495 } 456 }
496 } else { 457 }
458 else
459 {
497 currentPathCombo->lineEdit()->setText( currentPath); 460 currentPathCombo->lineEdit()->setText( currentPath);
498 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 461 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
462 {
499 currentPathCombo->clear(); 463 currentPathCombo->clear();
500 remoteDirPathStringList.prepend( currentPath ); 464 remoteDirPathStringList.prepend( currentPath );
501 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 465 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
@@ -503,93 +467,61 @@ void AdvancedFm::fillCombo(const QString &currentPath) {
503 } 467 }
504} 468}
505 469
506void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 470void AdvancedFm::currentPathComboActivated(const QString & currentPath)
507 if (TabWidget->getCurrentTab() == 0) { 471{
508// if (TabWidget->currentPageIndex() == 0) {
509 chdir( currentPath.latin1() );
510 currentDir.cd( currentPath, TRUE);
511 populateLocalView();
512 update();
513 } else {
514 chdir( currentPath.latin1() ); 472 chdir( currentPath.latin1() );
515 currentRemoteDir.cd( currentPath, TRUE); 473 CurrentDir()->cd( currentPath, TRUE);
516 populateRemoteView(); 474 PopulateView();
517 update(); 475 update();
518 } 476 }
519}
520 477
521QStringList AdvancedFm::getPath() { 478QStringList AdvancedFm::getPath()
479{
522 QStringList strList; 480 QStringList strList;
523 if (TabWidget->getCurrentTab() == 0) { 481 QListView *thisView=CurrentView();
524// if (TabWidget->currentPageIndex() == 0) { 482 QList<QListViewItem> * getSelectedItems( QListView * thisView );
525 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 483 QListViewItemIterator it( thisView );
526 QListViewItemIterator it( Local_View ); 484 for ( ; it.current(); ++it )
527 for ( ; it.current(); ++it ) { 485 {
528 if ( it.current()->isSelected() ) { 486 if ( it.current()->isSelected() )
529 strList << it.current()->text(0); 487 {
530// qDebug(it.current()->text(0));
531 }
532 }
533 return strList;
534 } else {
535 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
536 QListViewItemIterator it( Remote_View );
537 for ( ; it.current(); ++it ) {
538 if ( it.current()->isSelected() ) {
539 strList << it.current()->text(0); 488 strList << it.current()->text(0);
540// qDebug(it.current()->text(0)); 489// qDebug(it.current()->text(0));
541 } 490 }
542 } 491 }
543 return strList; 492 return strList;
544 } 493 }
545 return "";
546}
547 494
548void AdvancedFm::homeButtonPushed() { 495void AdvancedFm::homeButtonPushed()
496{
549 QString current = QDir::homeDirPath(); 497 QString current = QDir::homeDirPath();
550 chdir( current.latin1() ); 498 chdir( current.latin1() );
551 if (TabWidget->getCurrentTab() == 0) { 499 CurrentDir()->cd( current, TRUE);
552// if (TabWidget->currentPageIndex() == 0) { 500 PopulateView();
553 currentDir.cd( current, TRUE);
554 populateLocalView();
555 } else {
556 currentRemoteDir.cd( current, TRUE);
557 populateRemoteView();
558 }
559 update(); 501 update();
560} 502}
561 503
562void AdvancedFm::docButtonPushed() { 504void AdvancedFm::docButtonPushed()
505{
563 QString current = QPEApplication::documentDir(); 506 QString current = QPEApplication::documentDir();
564 chdir( current.latin1() ); 507 chdir( current.latin1() );
565 508
566 if (TabWidget->getCurrentTab() == 0) { 509 CurrentDir()->cd( current, TRUE);
567//if (TabWidget->currentPageIndex() == 0) { 510 PopulateView();
568 currentDir.cd( current, TRUE);
569 populateLocalView();
570 } else {
571 currentRemoteDir.cd( current, TRUE);
572 populateRemoteView();
573 }
574 update(); 511 update();
575} 512}
576 513
577void AdvancedFm::SDButtonPushed() { 514void AdvancedFm::SDButtonPushed()
515{
578 QString current = "/mnt/card";// this can change so fix 516 QString current = "/mnt/card";// this can change so fix
579 chdir( current.latin1() ); 517 chdir( current.latin1() );
580 if (TabWidget->getCurrentTab() == 0) { 518 CurrentDir()->cd( current, TRUE);
581// if (TabWidget->currentPageIndex() == 0) { 519 PopulateView();
582 currentDir.cd( current, TRUE);
583 populateLocalView();
584 } else {
585 currentRemoteDir.cd( current, TRUE);
586 populateRemoteView();
587 }
588 update(); 520 update();
589
590} 521}
591 522
592void AdvancedFm::CFButtonPushed() { 523void AdvancedFm::CFButtonPushed()
524{
593 QString current; 525 QString current;
594 if(zaurusDevice) 526 if(zaurusDevice)
595 current= "/mnt/cf"; //zaurus 527 current= "/mnt/cf"; //zaurus
@@ -597,61 +529,64 @@ void AdvancedFm::CFButtonPushed() {
597 current = "/mnt/hda"; //ipaq 529 current = "/mnt/hda"; //ipaq
598 530
599 chdir( current.latin1() ); 531 chdir( current.latin1() );
600 if (TabWidget->getCurrentTab() == 0) { 532 CurrentDir()->cd( current, TRUE);
601// if (TabWidget->currentPageIndex() == 0) { 533 PopulateView();
602 currentDir.cd( current, TRUE);
603 populateLocalView();
604 } else {
605 currentRemoteDir.cd( current, TRUE);
606 populateRemoteView();
607 }
608 update(); 534 update();
609} 535}
610 536
611 537
612 538void AdvancedFm::doAbout()
613void AdvancedFm::doAbout() { 539{
614 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 540 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
615 "is copyright 2002 by\n" 541 "is copyright 2002-2003 by\n"
616 "L.J.Potter<llornkcor@handhelds.org>\n" 542 "L.J.Potter<llornkcor@handhelds.org>\n"
617 "and is licensed by the GPL")); 543 "and is licensed by the GPL"));
618} 544}
619 545
620void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 546void AdvancedFm::keyPressEvent( QKeyEvent *e)
621 if( TabWidget->hasFocus()) 547{
548// e->accept();
549 if( CurrentView()->hasFocus() )
550 {
622 switch ( e->key() ) { 551 switch ( e->key() ) {
623 case Key_Delete: 552 case Key_Delete:
624 del(); 553 del();
625 break; 554 break;
626 case Key_H: 555 case Key_A:
627 showHidden(); 556 copyAs();
628 break;
629 case Key_E:
630 runThis();
631 break; 557 break;
632 case Key_C: 558 case Key_C:
633 copy(); 559 copy();
634 break; 560 break;
635 case Key_A: 561 case Key_E:
636 copyAs(); 562 runThis();
637 break; 563 break;
638 case Key_M: 564 case Key_G:
639 move(); 565 {
566 currentPathCombo->lineEdit()->setFocus();
567 }
640 break; 568 break;
641 case Key_R: 569
642 rn(); 570 case Key_H:
571 showHidden();
643 break; 572 break;
644 case Key_I: 573 case Key_I:
645 fileStatus(); 574 fileStatus();
646 break; 575 break;
647 case Key_U: 576 case Key_M:
648 upDir(); 577 move();
578 break;
579 case Key_N:
580 mkDir();
649 break; 581 break;
650 case Key_P: 582 case Key_P:
651 filePerms(); 583 filePerms();
652 break; 584 break;
653 case Key_N: 585 case Key_R:
654 mkDir(); 586 rn();
587 break;
588 case Key_U:
589 upDir();
655 break; 590 break;
656 case Key_1: 591 case Key_1:
657 switchToLocalTab(); 592 switchToLocalTab();
@@ -679,36 +614,43 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
679 break; 614 break;
680 case Key_0: 615 case Key_0:
681 break; 616 break;
617 };
618 e->accept();
682 } 619 }
683} 620}
684 621
622void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
623{
624 if( CurrentView()->hasFocus() )
625 e->ignore();
626}
627
685 628
686void AdvancedFm::QPEButtonPushed() { 629void AdvancedFm::QPEButtonPushed()
630{
687 QString current = QPEApplication::qpeDir(); 631 QString current = QPEApplication::qpeDir();
688 chdir( current.latin1() ); 632 chdir( current.latin1() );
689 if (TabWidget->getCurrentTab() == 0) { 633 CurrentDir()->cd( current, TRUE);
690// if (TabWidget->currentPageIndex() == 0) { 634 PopulateView();
691 currentDir.cd( current, TRUE);
692 populateLocalView();
693 } else {
694 currentRemoteDir.cd( current, TRUE);
695 populateRemoteView();
696 }
697 update(); 635 update();
698} 636}
699 637
700void AdvancedFm::parsetab(const QString &fileName) { 638void AdvancedFm::parsetab(const QString &fileName)
639{
701 640
702 fileSystemTypeList.clear(); 641 fileSystemTypeList.clear();
703 fsList.clear(); 642 fsList.clear();
704 struct mntent *me; 643 struct mntent *me;
705 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 644 FILE *mntfp = setmntent( fileName.latin1(), "r" );
706 if ( mntfp ) { 645 if ( mntfp )
707 while ( (me = getmntent( mntfp )) != 0 ) { 646 {
647 while ( (me = getmntent( mntfp )) != 0 )
648 {
708 QString deviceName = me->mnt_fsname; 649 QString deviceName = me->mnt_fsname;
709 QString filesystemType = me->mnt_type; 650 QString filesystemType = me->mnt_type;
710 QString mountDir = me->mnt_dir; 651 QString mountDir = me->mnt_dir;
711 if(deviceName != "none") { 652 if(deviceName != "none")
653 {
712 if( fsList.contains(filesystemType) == 0 654 if( fsList.contains(filesystemType) == 0
713 & filesystemType.find("proc",0,TRUE) == -1 655 & filesystemType.find("proc",0,TRUE) == -1
714 & filesystemType.find("cramfs",0,TRUE) == -1 656 & filesystemType.find("cramfs",0,TRUE) == -1
@@ -721,7 +663,8 @@ void AdvancedFm::parsetab(const QString &fileName) {
721 endmntent( mntfp ); 663 endmntent( mntfp );
722} 664}
723 665
724QString AdvancedFm::getFileSystemType(const QString &currentText) { 666QString AdvancedFm::getFileSystemType(const QString &currentText)
667{
725 parsetab("/etc/mtab"); //why did TT forget filesystem type? 668 parsetab("/etc/mtab"); //why did TT forget filesystem type?
726 QString current = currentText;//.right( currentText.length()-1); 669 QString current = currentText;//.right( currentText.length()-1);
727 QString baseFs; 670 QString baseFs;
@@ -737,7 +680,8 @@ QString AdvancedFm::getFileSystemType(const QString &currentText) {
737 return baseFs; 680 return baseFs;
738} 681}
739 682
740QString AdvancedFm::getDiskSpace( const QString &path) { 683QString AdvancedFm::getDiskSpace( const QString &path)
684{
741 struct statfs fss; 685 struct statfs fss;
742 if ( !statfs( path.latin1(), &fss ) ) { 686 if ( !statfs( path.latin1(), &fss ) ) {
743 int blkSize = fss.f_bsize; 687 int blkSize = fss.f_bsize;
@@ -755,17 +699,10 @@ QString AdvancedFm::getDiskSpace( const QString &path) {
755} 699}
756 700
757 701
758void AdvancedFm::showFileMenu() { 702void AdvancedFm::showFileMenu()
759 703{
760 QString curApp; 704 QString curApp;
761 bool isLocalView = false; 705 curApp = CurrentView()->currentItem()->text(0);
762 if (TabWidget->getCurrentTab() == 0) {
763// if (TabWidget->currentPageIndex() == 0) {
764 isLocalView = TRUE;
765 curApp = Local_View->currentItem()->text(0);
766 } else {
767 curApp = Remote_View->currentItem()->text(0);
768 }
769 706
770 MimeType mt( curApp ); 707 MimeType mt( curApp );
771 const AppLnk* app = mt.application(); 708 const AppLnk* app = mt.application();
@@ -773,15 +710,15 @@ void AdvancedFm::showFileMenu() {
773 QPopupMenu *m = new QPopupMenu(0); 710 QPopupMenu *m = new QPopupMenu(0);
774 QPopupMenu *n = new QPopupMenu(0); 711 QPopupMenu *n = new QPopupMenu(0);
775 // QPopupMenu *o = new QPopupMenu(0); 712 // QPopupMenu *o = new QPopupMenu(0);
776 if (TabWidget->getCurrentTab() == 0)
777 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 713 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
778 else
779 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
780 714
781 if ( QFileInfo(fi).isDir() ) { 715 if ( QFileInfo(fi).isDir() )
716 {
782 m->insertSeparator(); 717 m->insertSeparator();
783 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 718 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
784 } else { 719 }
720 else
721 {
785 722
786 if ( app ) 723 if ( app )
787 m->insertItem( app->pixmap(), tr( "Open in " 724 m->insertItem( app->pixmap(), tr( "Open in "
@@ -792,20 +729,12 @@ void AdvancedFm::showFileMenu() {
792 } 729 }
793 730
794 m->insertItem(tr("Actions"),n); 731 m->insertItem(tr("Actions"),n);
795 if(isLocalView) 732 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
796 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
797 else
798 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
799 733
800 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 734 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
801 735
802 n->insertSeparator(); 736 n->insertSeparator();
803 737 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
804
805 if(isLocalView)
806 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
807 else
808 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
809 738
810 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 739 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
811 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 740 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
@@ -813,13 +742,7 @@ void AdvancedFm::showFileMenu() {
813 n->insertItem( tr( "Move" ), this, SLOT( move() )); 742 n->insertItem( tr( "Move" ), this, SLOT( move() ));
814 743
815 n->insertSeparator(); 744 n->insertSeparator();
816 745 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
817 if(isLocalView)
818 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
819 else
820 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
821
822
823 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 746 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
824 747
825 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 748 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
@@ -846,16 +769,18 @@ void AdvancedFm::showFileMenu() {
846} 769}
847 770
848 771
849void AdvancedFm::cancelMenuTimer() { 772void AdvancedFm::cancelMenuTimer()
850 773{
851// qDebug("selectionChanged: cancel menu timer"); 774// qDebug("selectionChanged: cancel menu timer");
852 if( menuTimer.isActive() ) 775 if( menuTimer.isActive() )
853 menuTimer.stop(); 776 menuTimer.stop();
854} 777}
855 778
856QString AdvancedFm::checkDiskSpace(const QString &path) { 779QString AdvancedFm::checkDiskSpace(const QString &path)
780{
857 struct statfs fss; 781 struct statfs fss;
858 if ( !statfs( path.latin1(), &fss ) ) { 782 if ( !statfs( path.latin1(), &fss ) )
783 {
859 int blkSize = fss.f_bsize; 784 int blkSize = fss.f_bsize;
860// int totalBlks = fs.f_blocks; 785// int totalBlks = fs.f_blocks;
861 int availBlks = fss.f_bavail; 786 int availBlks = fss.f_bavail;
@@ -871,26 +796,18 @@ QString AdvancedFm::checkDiskSpace(const QString &path) {
871 return ""; 796 return "";
872} 797}
873 798
874void AdvancedFm::addToDocs() { 799void AdvancedFm::addToDocs()
800{
875 QStringList strListPaths = getPath(); 801 QStringList strListPaths = getPath();
876 if( strListPaths.count() > 0) { 802 QDir *thisDir = CurrentDir();
803
804 if( strListPaths.count() > 0)
805 {
877 QString curFile; 806 QString curFile;
878 if (TabWidget->getCurrentTab() == 0) { 807 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
879// if (TabWidget->currentPageIndex() == 0) { 808 {
880 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 809 curFile = thisDir->canonicalPath()+"/"+(*it);
881 curFile = currentDir.canonicalPath()+"/"+(*it);
882// qDebug(curFile);
883 DocLnk f;
884// curFile.replace(QRegExp("\\..*"),"");
885 f.setName((*it));
886 f.setFile( curFile);
887 f.writeLink();
888 }
889 } else {
890 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
891 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
892// qDebug(curFile); 810// qDebug(curFile);
893
894 DocLnk f; 811 DocLnk f;
895// curFile.replace(QRegExp("\\..*"),""); 812// curFile.replace(QRegExp("\\..*"),"");
896 f.setName((*it)); 813 f.setName((*it));
@@ -899,7 +816,6 @@ void AdvancedFm::addToDocs() {
899 } 816 }
900 } 817 }
901 } 818 }
902}
903 819
904 820
905void AdvancedFm::customDirsToMenu() 821void AdvancedFm::customDirsToMenu()
@@ -948,14 +864,7 @@ void AdvancedFm::addCustomDir()
948 QString dir; 864 QString dir;
949 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 865 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
950 866
951 if (TabWidget->getCurrentTab() == 0) 867 dir = CurrentDir()->canonicalPath();
952 {
953 dir = currentDir.canonicalPath();
954 }
955 else
956 {
957 dir = currentRemoteDir.canonicalPath();
958 }
959 868
960 bool addIt=true; 869 bool addIt=true;
961 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 870 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
@@ -984,15 +893,7 @@ void AdvancedFm::removeCustomDir()
984 QString dir; 893 QString dir;
985 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 894 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
986 QStringList list2; 895 QStringList list2;
987 896 dir = CurrentDir()->canonicalPath();
988 if (TabWidget->getCurrentTab() == 0)
989 {
990 dir = currentDir.canonicalPath();
991 }
992 else
993 {
994 dir = currentRemoteDir.canonicalPath();
995 }
996 int ramble=2; 897 int ramble=2;
997// int ramble=-24; 898// int ramble=-24;
998//first remove list 899//first remove list
@@ -1029,6 +930,7 @@ void AdvancedFm::gotoCustomDir(const QString &dir)
1029{ 930{
1030// qDebug("gotoCustomDir(const QString &dir) " +dir ); 931// qDebug("gotoCustomDir(const QString &dir) " +dir );
1031 QString curDir = dir; 932 QString curDir = dir;
933 QDir *thisDir = CurrentDir();
1032// if( curDir.isEmpty()) { 934// if( curDir.isEmpty()) {
1033// } 935// }
1034 if( curDir == s_addBookmark) 936 if( curDir == s_addBookmark)
@@ -1043,42 +945,58 @@ void AdvancedFm::gotoCustomDir(const QString &dir)
1043 { 945 {
1044 if(QDir( curDir).exists() ) 946 if(QDir( curDir).exists() )
1045 { 947 {
1046 if (TabWidget->getCurrentTab() == 0) 948 thisDir->setPath( curDir );
1047 {
1048 currentDir.setPath( curDir );
1049 chdir( curDir.latin1() ); 949 chdir( curDir.latin1() );
1050 currentDir.cd( curDir, TRUE); 950 thisDir->cd( curDir, TRUE);
1051 populateLocalView(); 951 PopulateView();
952 }
953 }
954}
955
956QDir *AdvancedFm::CurrentDir()
957{
958 if ( whichTab == 1)
959 {
960 return &currentDir;
1052 } 961 }
1053 else 962 else
1054 { 963 {
1055 currentRemoteDir.setPath( curDir ); 964 return &currentRemoteDir;
1056 chdir( curDir.latin1() );
1057 currentRemoteDir.cd( curDir, TRUE);
1058 populateRemoteView();
1059 } 965 }
1060 } 966 }
967
968QDir *AdvancedFm::OtherDir()
969{
970 if ( whichTab == 1)
971 {
972 return &currentRemoteDir;
1061 } 973 }
1062// menuButton 974 else
1063// qDebug("gotoCustomDir(const QString &dir) " +dir ); 975 {
1064// QString curDir = dir; 976 return &currentDir;
1065// if(QDir( curDir).exists() ) 977 }
1066// { 978}
1067// if (TabWidget->getCurrentTab() == 0) 979
1068// { 980void AdvancedFm::PopulateView()
1069// currentDir.setPath( curDir ); 981{
1070// chdir( curDir.latin1() ); 982 if ( whichTab == 1)
1071// currentDir.cd( curDir, TRUE); 983 populateLocalView();
1072// populateLocalView(); 984 else
1073// } 985 populateRemoteView();
1074// else 986}
1075// { 987
1076// currentRemoteDir.setPath( curDir ); 988QListView * AdvancedFm::CurrentView()
1077// chdir( curDir.latin1() ); 989{
1078// currentRemoteDir.cd( curDir, TRUE); 990 if ( whichTab == 1)
1079// populateRemoteView(); 991 return Local_View;
1080// } 992 else
1081// } 993 return Remote_View;
1082// menuButton->setLabel(" "); 994}
1083// menuButton 995
996QListView * AdvancedFm::OtherView()
997{
998 if ( whichTab == 1)
999 return Remote_View;
1000 else
1001 return Local_View;
1084} 1002}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 7478dcb..8eec6ba 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -59,9 +59,7 @@ public:
59protected slots: 59protected slots:
60 void selectAll(); 60 void selectAll();
61 void addToDocs(); 61 void addToDocs();
62 void doLocalCd(); 62 void doDirChange();
63 void doRemoteCd();
64// void copy();
65 void mkDir(); 63 void mkDir();
66 void del(); 64 void del();
67 void rn(); 65 void rn();
@@ -69,23 +67,16 @@ protected slots:
69 void populateRemoteView(); 67 void populateRemoteView();
70 void showHidden(); 68 void showHidden();
71 void showMenuHidden(); 69 void showMenuHidden();
72 void showRemoteHidden(); 70// void showRemoteHidden();
73 void writeConfig(); 71 void writeConfig();
74 void readConfig(); 72 void readConfig();
75 void localListClicked(QListViewItem *); 73 void ListClicked(QListViewItem *);
76 void remoteListClicked(QListViewItem *); 74 void ListPressed( int, QListViewItem *, const QPoint&, int);
77 void localListPressed( int, QListViewItem *, const QPoint&, int); 75 void makeDir();
78 void remoteListPressed( int, QListViewItem *, const QPoint&, int); 76 void doDelete();
79 void localMakDir();
80 void localDelete();
81 void remoteMakDir();
82 void remoteDelete();
83/* bool remoteDirList(const QString &); */
84/* bool remoteChDir(const QString &); */
85 void tabChanged(QWidget*); 77 void tabChanged(QWidget*);
86 void cleanUp(); 78 void cleanUp();
87 void remoteRename(); 79 void renameIt();
88 void localRename();
89 void runThis(); 80 void runThis();
90 void runText(); 81 void runText();
91 void filePerms(); 82 void filePerms();
@@ -100,6 +91,7 @@ protected slots:
100protected: 91protected:
101 92
102 OTabWidget *TabWidget; 93 OTabWidget *TabWidget;
94 int whichTab;
103// QTabWidget *TabWidget; 95// QTabWidget *TabWidget;
104 QWidget *tab, *tab_2, *tab_3; 96 QWidget *tab, *tab_2, *tab_3;
105 QListView *Local_View, *Remote_View; 97 QListView *Local_View, *Remote_View;
@@ -123,11 +115,17 @@ protected:
123 void init(); 115 void init();
124 void initConnections(); 116 void initConnections();
125 void keyReleaseEvent( QKeyEvent *); 117 void keyReleaseEvent( QKeyEvent *);
118 void keyPressEvent( QKeyEvent *);
126 QString getFileSystemType(const QString &); 119 QString getFileSystemType(const QString &);
127 QString getDiskSpace(const QString &); 120 QString getDiskSpace(const QString &);
128 void parsetab(const QString &fileName); 121 void parsetab(const QString &fileName);
129 QString checkDiskSpace(const QString &); 122 QString checkDiskSpace(const QString &);
130 QString dealWithSymName(const QString &); 123 QString dealWithSymName(const QString &);
124 QDir *CurrentDir();
125 QDir *OtherDir();
126 QListView *CurrentView();
127 QListView *OtherView();
128 void PopulateView();
131 129
132protected slots: 130protected slots:
133 void dirMenuSelected(int); 131 void dirMenuSelected(int);
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index bb80dc6..90425dc 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -230,14 +230,23 @@ void AdvancedFm::init() {
230 230
231} 231}
232 232
233void AdvancedFm::initConnections() { 233void AdvancedFm::initConnections()
234 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 234{
235 connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); 235
236 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); 236 connect( qApp,SIGNAL( aboutToQuit()),
237 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); 237 this, SLOT( cleanUp()) );
238 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 238 connect( qpeDirButton ,SIGNAL(released()),
239 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 239 this,SLOT( QPEButtonPushed()) );
240 connect( homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 240 connect( cfButton ,SIGNAL(released()),
241 this,SLOT( CFButtonPushed()) );
242 connect( sdButton ,SIGNAL(released()),
243 this,SLOT( SDButtonPushed()) );
244 connect( cdUpButton ,SIGNAL(released()),
245 this,SLOT( upDir()) );
246 connect( docButton,SIGNAL(released()),
247 this,SLOT( docButtonPushed()) );
248 connect( homeButton,SIGNAL(released()),
249 this,SLOT( homeButtonPushed()) );
241 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 250 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
242 this, SLOT( currentPathComboActivated( const QString & ) ) ); 251 this, SLOT( currentPathComboActivated( const QString & ) ) );
243 252
@@ -245,16 +254,16 @@ void AdvancedFm::initConnections() {
245 this,SLOT(currentPathComboChanged())); 254 this,SLOT(currentPathComboChanged()));
246 255
247 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 256 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
248 this,SLOT( localListClicked(QListViewItem *)) ); 257 this,SLOT( ListClicked(QListViewItem *)) );
249 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 258 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
250 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); 259 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
251 260
252 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); 261 connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
253 262
254 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 263 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
255 this,SLOT( remoteListClicked(QListViewItem *)) ); 264 this,SLOT( ListClicked(QListViewItem *)) );
256 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 265 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
257 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 266 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
258 267
259 connect( TabWidget,SIGNAL(currentChanged(QWidget *)), 268 connect( TabWidget,SIGNAL(currentChanged(QWidget *)),
260 this,SLOT(tabChanged(QWidget*))); 269 this,SLOT(tabChanged(QWidget*)));
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index e7c0b6a..13dad33 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -46,22 +46,23 @@
46#include <dirent.h> 46#include <dirent.h>
47 47
48 48
49void AdvancedFm::doLocalCd() { 49void AdvancedFm::doDirChange()
50 localListClicked( Local_View->currentItem()); 50{
51} 51 ListClicked( CurrentView()->currentItem());
52
53void AdvancedFm::doRemoteCd() {
54 localListClicked( Remote_View->currentItem());
55} 52}
56 53
57void AdvancedFm::showMenuHidden() { 54void AdvancedFm::showMenuHidden()
58 if (b) { 55{
56 if (b)
57 {
59 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 58 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
62// b=FALSE; 61// b=FALSE;
63 62
64 } else { 63 }
64 else
65 {
65 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 66 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
66 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
@@ -69,158 +70,119 @@ void AdvancedFm::showMenuHidden() {
69 } 70 }
70 populateLocalView(); 71 populateLocalView();
71 populateRemoteView(); 72 populateRemoteView();
72// if(TabWidget->getCurrentTab() == 0)
73// showHidden();
74// else
75// showRemoteHidden();
76// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 73// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
77 if(b) b = false; else b = true; 74 if(b) b = false; else b = true;
78} 75}
79 76
80void AdvancedFm::showHidden() { 77void AdvancedFm::showHidden()
81 if (b) { 78{
82 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 79 if (b)
80 {
81 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
84// b=FALSE; 83// b=FALSE;
85 84
86 } else {
87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
88// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
89// b=TRUE;
90 }
91 populateLocalView();
92} 85}
93 86 else
94void AdvancedFm::showRemoteHidden() { 87 {
95 if (b) { 88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
96 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 89// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
97// b=TRUE; 90// b=TRUE;
98
99 } else {
100 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
101// b=FALSE;
102 } 91 }
103 populateRemoteView(); 92 PopulateView();
104} 93}
105 94
106QString AdvancedFm::dealWithSymName(const QString &fileName) { 95QString AdvancedFm::dealWithSymName(const QString &fileName)
96{
107 QString strItem = fileName; 97 QString strItem = fileName;
108 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 98 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
109} 99}
110 100
111void AdvancedFm::runThis() { 101void AdvancedFm::runThis()
102{
112 QString fs; 103 QString fs;
113 if (TabWidget->getCurrentTab() == 0) { 104 QDir *thisDir = CurrentDir();
114 QString curFile = Local_View->currentItem()->text(0); 105
106 QString curFile = CurrentView()->currentItem()->text(0);
107 QString path = thisDir->canonicalPath();
108
115 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 109 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
110
116 curFile = dealWithSymName((const QString&)curFile); 111 curFile = dealWithSymName((const QString&)curFile);
117 112
118 if(curFile != "../") { 113 if(curFile != "../")
114 {
119 115
120 fs = getFileSystemType((const QString &) currentDir.canonicalPath()); 116 fs = getFileSystemType((const QString &) path);
121 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 117 QFileInfo fileInfo( path + "/" + curFile);
122 qDebug( fileInfo.owner()); 118 qDebug( fileInfo.owner());
123 if( (fileInfo.permission( QFileInfo::ExeUser)
124 | fileInfo.permission( QFileInfo::ExeGroup)
125 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
126 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
127 QCopEnvelope e("QPE/System", "execute(QString)" );
128 e << curFile;
129 } else {
130 curFile = currentDir.canonicalPath()+"/"+curFile;
131 DocLnk nf(curFile);
132 QString execStr = nf.exec();
133 qDebug( execStr);
134 if( execStr.isEmpty() ) {
135 } else {
136 nf.execute();
137 }
138 }
139 }
140 } else {
141 QString curFile = Remote_View->currentItem()->text(0);
142 if(curFile != "../") {
143 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
144 curFile = dealWithSymName((const QString&)curFile);
145 119
146 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
147 qDebug("Filesystemtype is "+fs);
148 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
149 if( (fileInfo.permission( QFileInfo::ExeUser) 120 if( (fileInfo.permission( QFileInfo::ExeUser)
150 | fileInfo.permission( QFileInfo::ExeGroup) 121 | fileInfo.permission( QFileInfo::ExeGroup)
151 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 122 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
152 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 123 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
153 QCopEnvelope e("QPE/System", "execute(QString)" ); 124 QCopEnvelope e("QPE/System", "execute(QString)" );
154 e << curFile; 125 e << curFile;
155 } else { 126 }
156 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 127 else
128 {
129 curFile = path + "/" + curFile;
157 DocLnk nf(curFile); 130 DocLnk nf(curFile);
158 QString execStr = nf.exec(); 131 QString execStr = nf.exec();
159 qDebug(execStr); 132 qDebug(execStr);
160 if( execStr.isEmpty() ) { 133 if( execStr.isEmpty() )
161 } else { 134 {
162 nf.execute();
163 } 135 }
136 else
137 {
138 nf.execute();
164 } 139 }
165 } 140 }
166 } 141 }
167} 142}
168 143
169void AdvancedFm::runText() { 144void AdvancedFm::runText()
170 if (TabWidget->getCurrentTab() == 0) { 145{
171 QString curFile = Local_View->currentItem()->text(0); 146 QString curFile = CurrentView()->currentItem()->text(0);
172 if(curFile != "../") { 147 if(curFile != "../")
173 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 148 {
174 curFile = dealWithSymName((const QString&)curFile);
175 curFile = currentDir.canonicalPath()+"/"+curFile;
176 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
177 e << curFile;
178 }
179 } else {
180 QString curFile = Remote_View->currentItem()->text(0);
181 if(curFile != "../") {
182 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
183 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 149 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
184 curFile = dealWithSymName((const QString&)curFile); 150 curFile = dealWithSymName((const QString&)curFile);
185 DocLnk nf(curFile); 151 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
186 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 152 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
187 e << curFile; 153 e << curFile;
188 } 154 }
189 } 155 }
190}
191 156
192void AdvancedFm::localMakDir() { 157void AdvancedFm::makeDir()
158{
193 InputDialog *fileDlg; 159 InputDialog *fileDlg;
194 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 160 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
195 fileDlg->exec(); 161 fileDlg->exec();
196 if( fileDlg->result() == 1 ) { 162 if( fileDlg->result() == 1 )
163 {
164 QDir *thisDir = CurrentDir();
197 QString filename = fileDlg->LineEdit1->text(); 165 QString filename = fileDlg->LineEdit1->text();
198 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 166 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
199 } 167 }
200 populateLocalView(); 168 PopulateView();
201} 169}
202 170
203void AdvancedFm::remoteMakDir() { 171void AdvancedFm::doDelete()
204 InputDialog *fileDlg; 172{
205 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
206 fileDlg->exec();
207 if( fileDlg->result() == 1 ) {
208 QString filename = fileDlg->LineEdit1->text();
209 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
210 }
211 populateRemoteView();
212}
213 173
214void AdvancedFm::localDelete() {
215 QStringList curFileList = getPath(); 174 QStringList curFileList = getPath();
216 bool doMsg=true; 175 bool doMsg=true;
217 int count=curFileList.count(); 176 int count=curFileList.count();
218 if( count > 0) { 177 if( count > 0)
219 if(count > 1 ){ 178 {
179 if(count > 1 )
180 {
220 QString msg; 181 QString msg;
221 msg=tr("Really delete\n%1 files?").arg(count); 182 msg=tr("Really delete\n%1 files?").arg(count);
222 switch ( QMessageBox::warning(this,tr("Delete"),msg 183 switch ( QMessageBox::warning(this,tr("Delete"),msg
223 ,tr("Yes"),tr("No"),0,0,1) ) { 184 ,tr("Yes"),tr("No"),0,0,1) )
185 {
224 case 0: 186 case 0:
225 doMsg=false; 187 doMsg=false;
226 break; 188 break;
@@ -231,88 +193,28 @@ void AdvancedFm::localDelete() {
231 } 193 }
232 194
233 QString myFile; 195 QString myFile;
234 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 196 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
197 {
235 myFile = (*it); 198 myFile = (*it);
236 if( myFile.find(" -> ",0,TRUE) != -1) 199 if( myFile.find(" -> ",0,TRUE) != -1)
237 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 200 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
238 201
239 QString f = currentDir.canonicalPath(); 202 QString f = CurrentDir()->canonicalPath();
240 if(f.right(1).find("/",0,TRUE) == -1) 203 if(f.right(1).find("/",0,TRUE) == -1)
241 f+="/"; 204 f+="/";
242 f+=myFile; 205 f+=myFile;
243 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 206 if(QDir(f).exists() && !QFileInfo(f).isSymLink() )
207 {
244 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ 208 switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+
245 "\nand all it's contents ?" 209 "\nand all it's contents ?"
246 ,tr("Yes"),tr("No"),0,0,1) ) { 210 ,tr("Yes"),tr("No"),0,0,1) )
247 case 0: { 211 {
248 f=f.left(f.length()-1);
249 QString cmd="rm -rf "+f;
250 startProcess( (const QString)cmd.latin1() );
251 populateLocalView();
252 }
253 break;
254 case 1:
255 // exit
256 break;
257 };
258
259 } else {
260 if(doMsg) {
261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
262 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
263 case 1:
264 return;
265 break;
266 };
267 }
268 QString cmd="rm "+f;
269 QFile file(f);
270 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
271 file.remove();
272 }
273 }
274 }
275 populateLocalView();
276}
277
278void AdvancedFm::remoteDelete() {
279 QStringList curFileList = getPath();
280 bool doMsg=true;
281 int count=curFileList.count();
282 if( count > 0) {
283 if(count > 1 ){
284 QString msg;
285 msg=tr("Really delete\n%1 files?").arg(count);
286 switch ( QMessageBox::warning(this,tr("Delete"),msg
287 ,tr("Yes"),tr("No"),0,0,1) ) {
288 case 0: 212 case 0:
289 doMsg=false; 213 {
290 break;
291 case 1:
292 return;
293 break;
294 };
295 }
296
297 QString myFile;
298
299 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
300 myFile = (*it);
301 if(myFile.find(" -> ",0,TRUE) != -1)
302 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
303 QString f = currentRemoteDir.canonicalPath();
304 if(f.right(1).find("/",0,TRUE) == -1)
305 f+="/";
306 f+=myFile;
307 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
308 switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+
309 "\nand all it's contents ?",
310 tr("Yes"),tr("No"),0,0,1) ) {
311 case 0: {
312 f=f.left(f.length()-1); 214 f=f.left(f.length()-1);
313 QString cmd="rm -rf "+f; 215 QString cmd="rm -rf "+f;
314 startProcess( (const QString)cmd ); 216 startProcess( (const QString)cmd.latin1() );
315 populateRemoteView(); 217 PopulateView();
316 } 218 }
317 break; 219 break;
318 case 1: 220 case 1:
@@ -336,22 +238,18 @@ void AdvancedFm::remoteDelete() {
336 } 238 }
337 } 239 }
338 } 240 }
339 populateRemoteView(); 241 PopulateView();
340} 242}
341 243
342 244void AdvancedFm::filePerms()
343void AdvancedFm::filePerms() { 245{
344
345 QStringList curFileList = getPath(); 246 QStringList curFileList = getPath();
346 QString filePath; 247 QString filePath;
347 248
348 if (TabWidget->getCurrentTab() == 0) { 249 filePath = CurrentDir()->canonicalPath()+"/";
349 filePath = currentDir.canonicalPath()+"/";
350 } else {
351 filePath= currentRemoteDir.canonicalPath()+"/";
352 }
353 250
354 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 251 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
252 {
355 filePermissions *filePerm; 253 filePermissions *filePerm;
356 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 254 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
357 filePerm->showMaximized(); 255 filePerm->showMaximized();
@@ -359,27 +257,22 @@ void AdvancedFm::filePerms() {
359 if( filePerm) 257 if( filePerm)
360 delete filePerm; 258 delete filePerm;
361 } 259 }
362 if (TabWidget->getCurrentTab() == 0) { 260 PopulateView();
363 populateLocalView();
364 } else {
365 populateRemoteView();
366 }
367} 261}
368 262
369void AdvancedFm::doProperties() { 263void AdvancedFm::doProperties()
264{
370#if defined(QT_QWS_OPIE) 265#if defined(QT_QWS_OPIE)
371 266
372 QStringList curFileList = getPath(); 267 QStringList curFileList = getPath();
373 268
374 QString filePath; 269 QString filePath;
375 if (TabWidget->getCurrentTab() == 0) { 270 filePath = CurrentDir()->canonicalPath()+"/";
376 filePath = currentDir.canonicalPath()+"/"; 271
377 } else {
378 filePath= currentRemoteDir.canonicalPath()+"/";
379 }
380 qDebug("%d",curFileList.count()); 272 qDebug("%d",curFileList.count());
381 273
382 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 274 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
275 {
383 qDebug((filePath+*it)); 276 qDebug((filePath+*it));
384 DocLnk lnk( (filePath+*it)); 277 DocLnk lnk( (filePath+*it));
385 LnkProperties prop( &lnk ); 278 LnkProperties prop( &lnk );
@@ -390,31 +283,28 @@ void AdvancedFm::doProperties() {
390 283
391} 284}
392 285
393void AdvancedFm::upDir() { 286void AdvancedFm::upDir()
394 if (TabWidget->getCurrentTab() == 0) { 287{
395 QString current = currentDir.canonicalPath(); 288 QDir *thisDir = CurrentDir();
396 QDir dir(current); 289 QString current = thisDir->canonicalPath();
397 dir.cdUp();
398 current = dir.canonicalPath();
399 chdir( current.latin1() );
400 currentDir.cd( current, TRUE);
401 populateLocalView();
402 update();
403 } else {
404 QString current = currentRemoteDir.canonicalPath();
405 QDir dir(current); 290 QDir dir(current);
406 dir.cdUp(); 291 dir.cdUp();
407 current = dir.canonicalPath(); 292 current = dir.canonicalPath();
408 chdir( current.latin1() ); 293 chdir( current.latin1() );
409 currentRemoteDir.cd( current, TRUE); 294 thisDir->cd( current, TRUE);
410 populateRemoteView(); 295
296 PopulateView();
411 update(); 297 update();
412 } 298 }
413}
414 299
415void AdvancedFm::copy() { 300void AdvancedFm::copy()
301{
416 qApp->processEvents(); 302 qApp->processEvents();
417 QStringList curFileList = getPath(); 303 QStringList curFileList = getPath();
304
305 QDir *thisDir = CurrentDir();
306 QDir *thatDir = OtherDir();
307
418 bool doMsg=true; 308 bool doMsg=true;
419 int count=curFileList.count(); 309 int count=curFileList.count();
420 if( count > 0) { 310 if( count > 0) {
@@ -422,7 +312,8 @@ void AdvancedFm::copy() {
422 QString msg; 312 QString msg;
423 msg=tr("Really copy\n%1 files?").arg(count); 313 msg=tr("Really copy\n%1 files?").arg(count);
424 switch ( QMessageBox::warning(this,tr("Delete"),msg 314 switch ( QMessageBox::warning(this,tr("Delete"),msg
425 ,tr("Yes"),tr("No"),0,0,1) ) { 315 ,tr("Yes"),tr("No"),0,0,1) )
316 {
426 case 0: 317 case 0:
427 doMsg=false; 318 doMsg=false;
428 break; 319 break;
@@ -433,140 +324,81 @@ void AdvancedFm::copy() {
433 } 324 }
434 325
435 QString curFile, item, destFile; 326 QString curFile, item, destFile;
436 if (TabWidget->getCurrentTab() == 0) { 327 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
437 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 328 {
438 item=(*it); 329 item=(*it);
439 if(item.find("->",0,TRUE)) //symlink 330 if(item.find("->",0,TRUE)) //symlink
440 item = item.left(item.find("->",0,TRUE)); 331 item = item.left(item.find("->",0,TRUE));
441 332
442 destFile = currentRemoteDir.canonicalPath()+"/"+ item; 333 curFile = thisDir->canonicalPath()+"/"+ item;
443 qDebug("Destination file is "+destFile); 334 destFile = thatDir->canonicalPath()+"/"+ item;
444
445 curFile = currentDir.canonicalPath()+"/"+ item;
446 qDebug("CurrentFile file is " + curFile);
447 335
448 QFile f(destFile);
449 if( f.exists()) {
450 if(doMsg) {
451 switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) {
452 case 1:
453 return;
454 break;
455 };
456 }
457 f.remove();
458 }
459 if(!copyFile( curFile, destFile) ) {
460 QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
461 return;
462 }
463 }
464 populateRemoteView();
465 TabWidget->setCurrentTab(1);
466
467 } else {
468 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
469 item= (*it);
470 if(item.find("->",0,TRUE)) //symlink
471 item = item.left(item.find("->",0,TRUE));
472
473 destFile = currentDir.canonicalPath()+"/"+ item;
474 qDebug("Destination file is "+destFile); 336 qDebug("Destination file is "+destFile);
475
476 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
477 qDebug("CurrentFile file is " + curFile); 337 qDebug("CurrentFile file is " + curFile);
478 338
479 QFile f(destFile); 339 QFile f(destFile);
480 if( f.exists()) { 340 if( f.exists())
341 {
342 if(doMsg)
343 {
481 switch ( QMessageBox::warning(this,tr("File Exists!"), 344 switch ( QMessageBox::warning(this,tr("File Exists!"),
482 item+tr("\nexists. Ok to overwrite?"), 345 tr("%1 exists. Ok to overwrite?").arg( item ),
483 tr("Yes"),tr("No"),0,0,1) ) { 346 tr("Yes"),tr("No"),0,0,1) )
347 {
484 case 1: 348 case 1:
485 return; 349 return;
486 break; 350 break;
487 }; 351 };
352 }
488 f.remove(); 353 f.remove();
489 } 354 }
490 if(!copyFile( curFile, destFile) ) {
491 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
492 +curFile +tr("to\n")+destFile);
493 return;
494 355
356 if( !copyFile( curFile, destFile) )
357 {
358 QMessageBox::message("AdvancedFm",
359 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
360 return;
495 } 361 }
496 } 362 }
497 populateLocalView();
498 TabWidget->setCurrentTab(0);
499 }
500 363
364 PopulateView();
365 // TabWidget->setCurrentTab(1);
501 } 366 }
502} 367}
503 368
504void AdvancedFm::copyAs() { 369void AdvancedFm::copyAs()
370{
505 qApp->processEvents(); 371 qApp->processEvents();
506 372
507 QStringList curFileList = getPath(); 373 QStringList curFileList = getPath();
508 QString curFile, item; 374 QString curFile, item;
509 InputDialog *fileDlg; 375 InputDialog *fileDlg;
510 if (TabWidget->getCurrentTab() == 0) {
511 qDebug("tab 1");
512 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
513 QString destFile;
514 item=(*it);
515 curFile = currentDir.canonicalPath()+"/"+(*it);
516 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
517 376
518 fileDlg->setInputText((const QString &) destFile ); 377 QDir *thisDir = CurrentDir();
519 fileDlg->exec(); 378 QDir *thatDir = OtherDir();
520
521 if( fileDlg->result() == 1 ) {
522 QString filename = fileDlg->LineEdit1->text();
523 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
524
525 QFile f(destFile);
526 if( f.exists()) {
527 switch (QMessageBox::warning(this,tr("File Exists!"),
528 item+tr("\nexists. Ok to overwrite?"),
529 tr("Yes"),tr("No"),0,0,1) ) {
530 case 0:
531 f.remove();
532 break;
533 case 1:
534 return;
535 break;
536 };
537 }
538 if(!copyFile( curFile,destFile) ) {
539 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
540 +curFile +tr("to\n")+destFile);
541 return;
542 }
543 }
544 delete fileDlg;
545
546 }
547 populateRemoteView();
548 TabWidget->setCurrentTab(1);
549
550 } else {
551 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
552 379
380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
381 {
382 QString destFile;
553 item=(*it); 383 item=(*it);
554 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 384 curFile = thisDir->canonicalPath()+"/"+(*it);
555 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 385 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
556 386
557 QString destFile;
558 fileDlg->setInputText((const QString &) destFile); 387 fileDlg->setInputText((const QString &) destFile);
559 fileDlg->exec(); 388 fileDlg->exec();
560 389
561 if( fileDlg->result() == 1 ) { 390 if( fileDlg->result() == 1 )
391 {
562 QString filename = fileDlg->LineEdit1->text(); 392 QString filename = fileDlg->LineEdit1->text();
563 destFile = currentDir.canonicalPath()+"/"+filename; 393 destFile = thatDir->canonicalPath()+"/"+filename;
564 394
565 QFile f( destFile); 395 QFile f( destFile);
566 if( f.exists()) { 396 if( f.exists())
397 {
567 switch ( QMessageBox::warning(this,tr("File Exists!"), 398 switch ( QMessageBox::warning(this,tr("File Exists!"),
568 item+tr("\nexists. Ok to overwrite?"), 399 item+tr("\nexists. Ok to overwrite?"),
569 tr("Yes"),tr("No"),0,0,1) ) { 400 tr("Yes"),tr("No"),0,0,1) )
401 {
570 case 0: 402 case 0:
571 f.remove(); 403 f.remove();
572 break; 404 break;
@@ -575,44 +407,46 @@ void AdvancedFm::copyAs() {
575 break; 407 break;
576 }; 408 };
577 } 409 }
578 if(!copyFile( curFile,destFile) ) { 410 if( !copyFile( curFile, destFile) )
411 {
579 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 412 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
580 +curFile +tr("to\n")+destFile); 413 +curFile +tr("to\n")+destFile);
581 return; 414 return;
582 } 415 }
583
584 } 416 }
585 delete fileDlg; 417 delete fileDlg;
586 418
587 } 419 }
588 populateLocalView(); 420 PopulateView();
589 TabWidget->setCurrentTab(0);
590 }
591} 421}
592 422
593void AdvancedFm::copySameDir() { 423void AdvancedFm::copySameDir()
424{
594 qApp->processEvents(); 425 qApp->processEvents();
595 QStringList curFileList = getPath(); 426 QStringList curFileList = getPath();
596 QString curFile, item, destFile; 427 QString curFile, item, destFile;
597 InputDialog *fileDlg; 428 InputDialog *fileDlg;
598 429
599 if (TabWidget->getCurrentTab() == 0) { 430 QDir *thisDir = CurrentDir();
600 431
601 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 432 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
433 {
602 item=(*it); 434 item=(*it);
603 curFile = currentDir.canonicalPath()+"/"+ item; 435 curFile = thisDir->canonicalPath()+"/"+ item;
604 436
605 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 437 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
606 fileDlg->setInputText((const QString &) destFile ); 438 fileDlg->setInputText((const QString &) destFile );
607 fileDlg->exec(); 439 fileDlg->exec();
608 440
609 if( fileDlg->result() == 1 ) { 441 if( fileDlg->result() == 1 )
442 {
610 443
611 QString filename = fileDlg->LineEdit1->text(); 444 QString filename = fileDlg->LineEdit1->text();
612 destFile = currentDir.canonicalPath()+"/"+filename; 445 destFile = thisDir->canonicalPath()+"/"+filename;
613 446
614 QFile f(destFile); 447 QFile f(destFile);
615 if( f.exists()) { 448 if( f.exists())
449 {
616 switch (QMessageBox::warning(this,tr("Delete"), 450 switch (QMessageBox::warning(this,tr("Delete"),
617 destFile+tr(" already exists.\nDo you really want to delete it?"), 451 destFile+tr(" already exists.\nDo you really want to delete it?"),
618 tr("Yes"),tr("No"),0,0,1) ) { 452 tr("Yes"),tr("No"),0,0,1) ) {
@@ -625,7 +459,8 @@ void AdvancedFm::copySameDir() {
625 break; 459 break;
626 }; 460 };
627 } 461 }
628 if(!copyFile( curFile,destFile) ) { 462 if(!copyFile( curFile,destFile) )
463 {
629 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 464 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
630 +curFile +tr("to\n")+destFile); 465 +curFile +tr("to\n")+destFile);
631 return; 466 return;
@@ -635,76 +470,40 @@ void AdvancedFm::copySameDir() {
635 } 470 }
636 delete fileDlg; 471 delete fileDlg;
637 } 472 }
638 populateLocalView(); 473 PopulateView();
639
640 } else {
641 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
642 item=(*it);
643 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
644
645 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
646 fileDlg->setInputText((const QString &) destFile);
647 fileDlg->exec();
648 if( fileDlg->result() == 1 ) {
649 QString filename = fileDlg->LineEdit1->text();
650
651 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
652
653 QFile f(destFile);
654 if( f.exists()) {
655 switch ( QMessageBox::warning(this,tr("Delete"),
656 destFile+tr(" already exists.\nDo you really want to delete it?"),
657 tr("Yes"),tr("No"),0,0,1) ) {
658 case 0:
659 f.remove();
660 break;
661 case 1:
662 return;
663 break;
664 };
665 }
666 if(!copyFile( curFile,destFile) ) {
667 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
668 +curFile +tr("to\n")+destFile);
669 return;
670 }
671 qDebug("copy "+curFile+" as "+destFile);
672 }
673 delete fileDlg;
674 }
675 populateRemoteView();
676 }
677} 474}
678 475
679void AdvancedFm::move() { 476void AdvancedFm::move()
477{
680 qApp->processEvents(); 478 qApp->processEvents();
681 479
682 QStringList curFileList = getPath(); 480 QStringList curFileList = getPath();
683 if( curFileList.count() > 0) { 481 if( curFileList.count() > 0)
482 {
684 QString curFile, destFile, item; 483 QString curFile, destFile, item;
685 484
686 if (TabWidget->getCurrentTab() == 0) { 485 QDir *thisDir = CurrentDir();
687 486 QDir *thatDir = OtherDir();
688 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 487 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
488 {
689 item=(*it); 489 item=(*it);
690 QString destFile = currentRemoteDir.canonicalPath(); 490 QString destFile = thatDir->canonicalPath();
691 491
692 if(destFile.right(1).find("/",0,TRUE) == -1) 492 if(destFile.right(1).find("/",0,TRUE) == -1)
693 destFile+="/"; 493 destFile+="/";
694 destFile += item; 494 destFile += item;
695 curFile = currentDir.canonicalPath();
696
697 qDebug("Destination file is "+destFile); 495 qDebug("Destination file is "+destFile);
698 496
497 curFile = thisDir->canonicalPath();
699 if(curFile.right(1).find("/",0,TRUE) == -1) 498 if(curFile.right(1).find("/",0,TRUE) == -1)
700 curFile +="/"; 499 curFile +="/";
701
702 curFile+= item; 500 curFile+= item;
703 qDebug("CurrentFile file is " + curFile); 501 qDebug("CurrentFile file is " + curFile);
704 502
705 QFile f( curFile); 503 QFile f( curFile);
706 if( f.exists()) { 504 if( f.exists()) {
707 if(!copyFile( curFile,destFile) ) { 505 if( !copyFile( curFile, destFile) )
506 {
708 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 507 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
709 return; 508 return;
710 } else 509 } else
@@ -712,45 +511,13 @@ void AdvancedFm::move() {
712 } 511 }
713 } 512 }
714 513
715 TabWidget->setCurrentTab(1);
716
717 } else { //view 2
718
719 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
720 item = (*it);
721 QString destFile = currentDir.canonicalPath();
722
723 if(destFile.right(1).find("/",0,TRUE) == -1)
724 destFile+="/";
725
726 destFile += item;
727
728 qDebug("Destination file is "+destFile);
729
730 curFile = currentRemoteDir.canonicalPath();
731
732 if(curFile.right(1).find("/",0,TRUE) == -1)
733 curFile +="/";
734 curFile+= item;
735 qDebug("CurrentFile file is " + curFile);
736
737 QFile f( curFile);
738 if( f.exists()) {
739 if(!copyFile( curFile, destFile) ) {
740 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
741 return;
742 } else
743 QFile::remove( curFile);
744 }
745 TabWidget->setCurrentTab(0);
746 }
747 } 514 }
748 populateRemoteView(); 515 populateRemoteView();
749 populateLocalView(); 516 populateLocalView();
750 } 517 }
751}
752 518
753bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 519bool AdvancedFm::copyFile( const QString & src, const QString & dest )
520{
754 char bf[ 50000 ]; 521 char bf[ 50000 ];
755 int bytesRead; 522 int bytesRead;
756 bool success = TRUE; 523 bool success = TRUE;
@@ -759,37 +526,40 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
759 QFile s( src ); 526 QFile s( src );
760 QFile d( dest ); 527 QFile d( dest );
761 528
762 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 529 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
763 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 530 {
531 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
532 {
764 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 533 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
765 success = FALSE; 534 success = FALSE;
766 break; 535 break;
767 } 536 }
768 } 537 }
769 if( success && (bytesRead > 0) ){ 538 if( success && (bytesRead > 0) )
539 {
770 d.writeBlock( bf, bytesRead ); 540 d.writeBlock( bf, bytesRead );
771 } 541 }
772 } else { 542 }
543 else
544 {
773 success = FALSE; 545 success = FALSE;
774 } 546 }
775 547
776 // Set file permissions 548 // Set file permissions
777 if( stat( (const char *) src, &status ) == 0 ){ 549 if( stat( (const char *) src, &status ) == 0 )
550 {
778 chmod( (const char *) dest, status.st_mode ); 551 chmod( (const char *) dest, status.st_mode );
779 } 552 }
780 553
781 return success; 554 return success;
782} 555}
783 556
784void AdvancedFm::runCommand() { 557void AdvancedFm::runCommand()
558{
559 QDir *thisDir = CurrentDir();
560
785 QString curFile; 561 QString curFile;
786 if (TabWidget->getCurrentTab() == 0) { 562 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
787 if( Local_View->currentItem())
788 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
789 } else {
790 if(Remote_View->currentItem())
791 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
792 }
793 563
794 InputDialog *fileDlg; 564 InputDialog *fileDlg;
795 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 565 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
@@ -797,7 +567,8 @@ void AdvancedFm::runCommand() {
797 fileDlg->exec(); 567 fileDlg->exec();
798 //QString command; 568 //QString command;
799 569
800 if( fileDlg->result() == 1 ) { 570 if( fileDlg->result() == 1 )
571 {
801 qDebug(fileDlg->LineEdit1->text()); 572 qDebug(fileDlg->LineEdit1->text());
802 QStringList command; 573 QStringList command;
803 574
@@ -813,35 +584,30 @@ void AdvancedFm::runCommand() {
813 } 584 }
814} 585}
815 586
816void AdvancedFm::runCommandStd() { 587void AdvancedFm::runCommandStd()
588{
817 QString curFile; 589 QString curFile;
818 if (TabWidget->getCurrentTab() == 0) { 590 QDir *thisDir = CurrentDir();
819 if( Local_View->currentItem()) 591 QListView *thisView = CurrentView();
820 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 592 if( thisView->currentItem())
821 } else { 593 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
822 if(Remote_View->currentItem())
823 curFile = currentRemoteDir.canonicalPath() +"/"
824 + Remote_View->currentItem()->text(0);
825 }
826 594
827 InputDialog *fileDlg; 595 InputDialog *fileDlg;
828 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 596 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
829 fileDlg->setInputText(curFile); 597 fileDlg->setInputText(curFile);
830 fileDlg->exec(); 598 fileDlg->exec();
831 599
832 if( fileDlg->result() == 1 ) { 600 if( fileDlg->result() == 1 )
601 {
833 qApp->processEvents(); 602 qApp->processEvents();
834 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 603 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
835 } 604 }
836} 605}
837 606
838void AdvancedFm::fileStatus() { 607void AdvancedFm::fileStatus()
608{
839 QString curFile; 609 QString curFile;
840 if (TabWidget->getCurrentTab() == 0) { 610 curFile = CurrentView()->currentItem()->text(0);
841 curFile = Local_View->currentItem()->text(0);
842 } else {
843 curFile = Remote_View->currentItem()->text(0);
844 }
845 611
846 QStringList command; 612 QStringList command;
847 command << "/bin/sh"; 613 command << "/bin/sh";
@@ -853,83 +619,67 @@ void AdvancedFm::fileStatus() {
853 outDlg->showMaximized(); 619 outDlg->showMaximized();
854 outDlg->exec(); 620 outDlg->exec();
855 qApp->processEvents(); 621 qApp->processEvents();
856
857
858// Output *outDlg;
859// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
860// outDlg->showMaximized();
861// outDlg->show();
862// qApp->processEvents();
863
864// FILE *fp;
865// char line[130];
866// sleep(1);
867// fp = popen( (const char *) command, "r");
868// if ( !fp ) {
869// qDebug("Could not execute '" + command + "'! err=%d", fp);
870// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
871// pclose(fp);
872// return;
873// } else {
874// while ( fgets( line, sizeof line, fp)) {
875// outDlg->OutputEdit->append(line);
876// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
877
878// }
879
880// }
881// pclose(fp);
882} 622}
883 623
884 624
885void AdvancedFm::mkDir() { 625void AdvancedFm::mkDir()
886 if (TabWidget->getCurrentTab() == 0) 626{
887 localMakDir(); 627 makeDir();
888 else
889 remoteMakDir();
890
891} 628}
892 629
893void AdvancedFm::rn() { 630void AdvancedFm::rn()
894 if (TabWidget->getCurrentTab() == 0) 631{
895 localRename(); 632 renameIt();
896 else
897 remoteRename();
898
899} 633}
900 634
901void AdvancedFm::del() { 635void AdvancedFm::del()
902 if (TabWidget->getCurrentTab() == 0) 636{
903 localDelete(); 637 doDelete();
904 else
905 remoteDelete();
906} 638}
907 639
908void AdvancedFm::mkSym() { 640void AdvancedFm::mkSym()
641{
909 QString cmd; 642 QString cmd;
910 QStringList curFileList = getPath(); 643 QStringList curFileList = getPath();
911 if( curFileList.count() > 0) { 644 if( curFileList.count() > 0)
912 645 {
913 if (TabWidget->getCurrentTab() == 0) { 646 if ( whichTab == 1)
914 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 647 {
648 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
649 {
915 650
916 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 651 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
917 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 652 if(destName.right(1) == "/")
653 {
654 destName = destName.left( destName.length() -1);
655 }
918 QString curFile = currentDir.canonicalPath()+"/"+(*it); 656 QString curFile = currentDir.canonicalPath()+"/"+(*it);
919 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 657 if( curFile.right(1) == "/")
658 {
659 curFile = curFile.left( curFile.length() -1);
660 }
920 cmd = "ln -s "+curFile+" "+destName; 661 cmd = "ln -s "+curFile+" "+destName;
921 qDebug(cmd); 662 qDebug(cmd);
922 startProcess( (const QString)cmd ); 663 startProcess( (const QString)cmd );
923 } 664 }
924 populateRemoteView(); 665 populateRemoteView();
925 TabWidget->setCurrentTab(1); 666 TabWidget->setCurrentTab(1);
926 } else { 667 }
927 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 668 else
669 {
670 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
671 {
928 672
929 QString destName = currentDir.canonicalPath()+"/"+(*it); 673 QString destName = currentDir.canonicalPath()+"/"+(*it);
930 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 674 if(destName.right(1) == "/")
675 {
676 destName = destName.left( destName.length() -1);
677 }
931 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 678 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
932 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 679 if( curFile.right(1) == "/")
680 {
681 curFile = curFile.left( curFile.length() -1);
682 }
933 683
934 cmd = "ln -s "+curFile+" "+destName; 684 cmd = "ln -s "+curFile+" "+destName;
935 qDebug(cmd); 685 qDebug(cmd);
@@ -941,56 +691,54 @@ void AdvancedFm::mkSym() {
941 } 691 }
942} 692}
943 693
944void AdvancedFm::doBeam() { 694void AdvancedFm::doBeam()
695{
945 Ir ir; 696 Ir ir;
946 if(!ir.supported()){ 697 if(!ir.supported())
947 } else { 698 {
699 }
700 else
701 {
948 702
949 QStringList curFileList = getPath(); 703 QStringList curFileList = getPath();
950 if( curFileList.count() > 0) { 704 if( curFileList.count() > 0)
951 705 {
952 if (TabWidget->getCurrentTab() == 0) { 706 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 707 {
954 708
955 QString curFile = currentDir.canonicalPath()+"/"+(*it); 709 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it);
956 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 710 if( curFile.right(1) == "/")
957 Ir *file = new Ir(this, "IR"); 711 {
958 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 712 curFile = curFile.left( curFile.length() -1);
959 file->send( curFile, curFile );
960 } 713 }
961
962 } else {
963 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
964
965 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
967 Ir *file = new Ir(this, "IR"); 714 Ir *file = new Ir(this, "IR");
968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 715 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
969 file->send( curFile, curFile ); 716 file->send( curFile, curFile );
970
971 }
972 } 717 }
973 } 718 }
974 } 719 }
975 720
976} 721}
977 722
978void AdvancedFm::fileBeamFinished( Ir *) { 723void AdvancedFm::fileBeamFinished( Ir *)
724{
979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 725 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
980
981} 726}
982 727
983void AdvancedFm::selectAll() { 728void AdvancedFm::selectAll()
984 if (TabWidget->getCurrentTab() == 0) { 729{
985 Local_View->selectAll(true); 730// if (TabWidget->getCurrentTab() == 0) {
986 Local_View->setSelected( Local_View->firstChild(),false); 731 QListView *thisView = CurrentView();
987 } else { 732 thisView->selectAll(true);
988 Remote_View->selectAll(true); 733 thisView->setSelected( thisView->firstChild(),false);
989 Remote_View->setSelected( Remote_View->firstChild(),false); 734// } else {
990 } 735// Remote_View->selectAll(true);
736// Remote_View->setSelected( Remote_View->firstChild(),false);
737// }
991} 738}
992 739
993void AdvancedFm::startProcess(const QString & cmd) { 740void AdvancedFm::startProcess(const QString & cmd)
741{
994 QStringList command; 742 QStringList command;
995 OProcess *process; 743 OProcess *process;
996 process = new OProcess(); 744 process = new OProcess();
@@ -1005,30 +753,41 @@ void AdvancedFm::startProcess(const QString & cmd) {
1005 qDebug("could not start process"); 753 qDebug("could not start process");
1006} 754}
1007 755
1008void AdvancedFm::processEnded() { 756void AdvancedFm::processEnded()
757{
1009 populateLocalView(); 758 populateLocalView();
1010 populateRemoteView(); 759 populateRemoteView();
1011} 760}
1012 761
1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 762bool AdvancedFm::eventFilter( QObject * o, QEvent * e )
1014 if ( o->inherits( "QLineEdit" ) ) { 763{
1015 if ( e->type() == QEvent::KeyPress ) { 764 if ( o->inherits( "QLineEdit" ) )
765 {
766 if ( e->type() == QEvent::KeyPress )
767 {
1016 QKeyEvent *ke = (QKeyEvent*)e; 768 QKeyEvent *ke = (QKeyEvent*)e;
1017 if ( ke->key() == Key_Return || 769 if ( ke->key() == Key_Return ||
1018 ke->key() == Key_Enter ) { 770 ke->key() == Key_Enter )
771 {
1019 okRename(); 772 okRename();
1020 return true; 773 return true;
1021 } else if ( ke->key() == Key_Escape ) { 774 }
775 else if ( ke->key() == Key_Escape )
776 {
1022 cancelRename(); 777 cancelRename();
1023 return true; 778 return true;
1024 } 779 }
1025 } else if ( e->type() == QEvent::FocusOut ) { 780 }
781 else if ( e->type() == QEvent::FocusOut )
782 {
1026 cancelRename(); 783 cancelRename();
1027 return true; 784 return true;
1028 } 785 }
1029 } 786 }
1030 if ( o->inherits( "QListView" ) ) { 787 if ( o->inherits( "QListView" ) )
1031 if ( e->type() == QEvent::FocusOut ) { 788 {
789 if ( e->type() == QEvent::FocusOut )
790 {
1032 printf("focusIn\n"); 791 printf("focusIn\n");
1033 792
1034 } 793 }
@@ -1042,19 +801,13 @@ void AdvancedFm::cancelRename()
1042{ 801{
1043 qDebug("cancel rename"); 802 qDebug("cancel rename");
1044 QListView * view; 803 QListView * view;
1045 if (TabWidget->getCurrentTab() == 0) 804 view = CurrentView();
1046 {
1047 view = Local_View;
1048 }
1049 else
1050 {
1051 view = Remote_View;
1052 }
1053 805
1054 bool resetFocus = view->viewport()->focusProxy() == renameBox; 806 bool resetFocus = view->viewport()->focusProxy() == renameBox;
1055 delete renameBox; 807 delete renameBox;
1056 renameBox = 0; 808 renameBox = 0;
1057 if ( resetFocus ) { 809 if ( resetFocus )
810 {
1058 view->viewport()->setFocusProxy( view); 811 view->viewport()->setFocusProxy( view);
1059 view->setFocus(); 812 view->setFocus();
1060 } 813 }
@@ -1085,41 +838,23 @@ void AdvancedFm::doRename(QListView * view)
1085} 838}
1086 839
1087 840
1088void AdvancedFm::localRename() 841void AdvancedFm::renameIt()
1089{
1090 oldName = Local_View->currentItem()->text(0);
1091 doRename(Local_View );
1092 populateLocalView();
1093}
1094
1095void AdvancedFm::remoteRename()
1096{ 842{
1097 oldName = Remote_View->currentItem()->text(0); 843 QListView *thisView = CurrentView();
1098 doRename(Remote_View ); 844 oldName = thisView->currentItem()->text(0);
1099 populateRemoteView(); 845 doRename( thisView );
846 PopulateView();
1100} 847}
1101 848
1102void AdvancedFm::okRename() 849void AdvancedFm::okRename()
1103{ 850{
1104 QString newName = renameBox->text(); 851 QString newName = renameBox->text();
1105 cancelRename(); 852 cancelRename();
1106 int tabs=0; 853 //int tabs=0;
1107 QListView * view; 854 QListView * view = CurrentView();
1108 tabs = TabWidget->getCurrentTab(); 855 QString path = CurrentDir()->canonicalPath() + "/";
1109 if ( tabs == 0)
1110 {
1111 view = Local_View;
1112 QString path = currentDir.canonicalPath() + "/";
1113 oldName = path + oldName;
1114 newName = path + newName;
1115 }
1116 else
1117 {
1118 view = Remote_View;
1119 QString path = currentRemoteDir.canonicalPath() + "/";
1120 oldName = path + oldName; 856 oldName = path + oldName;
1121 newName = path + newName; 857 newName = path + newName;
1122 }
1123 858
1124 if( view->currentItem() == NULL) 859 if( view->currentItem() == NULL)
1125 return; 860 return;
@@ -1130,8 +865,5 @@ void AdvancedFm::okRename()
1130 865
1131 view->takeItem( view->currentItem() ); 866 view->takeItem( view->currentItem() );
1132 delete view->currentItem(); 867 delete view->currentItem();
1133 if ( tabs == 0) 868 PopulateView();
1134 populateLocalView();
1135 else
1136 populateRemoteView();
1137} 869}