summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-21 22:44:28 (UTC)
committer llornkcor <llornkcor>2003-02-21 22:44:28 (UTC)
commita7448ec87d97a0128618e83ad7526bd884ef8853 (patch) (unidiff)
tree0dda2db8da959c26d0ec089bec161ae28486d2cc
parentd48baa03492fd4785ca273defb4e21bf8c0d1c08 (diff)
downloadopie-a7448ec87d97a0128618e83ad7526bd884ef8853.zip
opie-a7448ec87d97a0128618e83ad7526bd884ef8853.tar.gz
opie-a7448ec87d97a0128618e83ad7526bd884ef8853.tar.bz2
fix rename cancel.. hehehe
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp34
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp26
2 files changed, 45 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index c653b90..9edf7c1 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,197 +1,199 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie/otabwidget.h> 15#include <opie/otabwidget.h>
16// #include <opie/ofileselector.h> 16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h> 17// #include <opie/ofiledialog.h>
18 18
19#include <qpe/filemanager.h> 19#include <qpe/filemanager.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/mimetype.h> 26#include <qpe/mimetype.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/ir.h> 28#include <qpe/ir.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30 30
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qlistview.h> 40#include <qlistview.h>
41#include <qmainwindow.h> 41#include <qmainwindow.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qprogressbar.h> 43#include <qprogressbar.h>
44#include <qspinbox.h> 44#include <qspinbox.h>
45#include <qwidget.h> 45#include <qwidget.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qimage.h> 47#include <qimage.h>
48#include <qpixmap.h> 48#include <qpixmap.h>
49#include <qmessagebox.h> 49#include <qmessagebox.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qregexp.h> 51#include <qregexp.h>
52 52
53#include <unistd.h> 53#include <unistd.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <dirent.h> 56#include <dirent.h>
57#include <stdio.h> 57#include <stdio.h>
58#include <time.h> 58#include <time.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#include <mntent.h> 60#include <mntent.h>
61#include <string.h> 61#include <string.h>
62#include <errno.h> 62#include <errno.h>
63#include <sys/vfs.h> 63#include <sys/vfs.h>
64#include <mntent.h> 64#include <mntent.h>
65#include <sys/utsname.h> 65#include <sys/utsname.h>
66 66
67AdvancedFm::AdvancedFm( ) 67AdvancedFm::AdvancedFm( )
68 : QMainWindow( ) { 68 : QMainWindow( ) {
69 init(); 69 init();
70 renameBox = 0;
71
70 initConnections(); 72 initConnections();
71 populateLocalView(); 73 populateLocalView();
72 populateRemoteView(); 74 populateRemoteView();
73 currentPathCombo->setFocus(); 75 currentPathCombo->setFocus();
74} 76}
75 77
76AdvancedFm::~AdvancedFm() { 78AdvancedFm::~AdvancedFm() {
77} 79}
78 80
79void AdvancedFm::cleanUp() { 81void AdvancedFm::cleanUp() {
80 QString sfile=QDir::homeDirPath(); 82 QString sfile=QDir::homeDirPath();
81 if(sfile.right(1) != "/") 83 if(sfile.right(1) != "/")
82 sfile+="/._temp"; 84 sfile+="/._temp";
83 else 85 else
84 sfile+="._temp"; 86 sfile+="._temp";
85 QFile file( sfile); 87 QFile file( sfile);
86 if(file.exists()) 88 if(file.exists())
87 file.remove(); 89 file.remove();
88} 90}
89 91
90void AdvancedFm::tabChanged(QWidget *w) { 92void AdvancedFm::tabChanged(QWidget *w) {
91 qDebug("tab changed %d",TabWidget->getCurrentTab()); 93 qDebug("tab changed %d",TabWidget->getCurrentTab());
92 94
93 if ( w == tab) { 95 if ( w == tab) {
94// if (TabWidget->getCurrentTab() == 0) { 96// if (TabWidget->getCurrentTab() == 0) {
95// if (TabWidget->currentPageIndex() == 0) { 97// if (TabWidget->currentPageIndex() == 0) {
96 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 98 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
97 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 99 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
98 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 100 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
99 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 101 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
100 setCaption("AdvancedFm :: "+fs+" :: " 102 setCaption("AdvancedFm :: "+fs+" :: "
101 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 103 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
102 104
103 } 105 }
104 if ( w == tab_2) { 106 if ( w == tab_2) {
105// if (TabWidget->getCurrentTab() == 1) { 107// if (TabWidget->getCurrentTab() == 1) {
106 108
107// if (TabWidget->currentPageIndex() == 1) { 109// if (TabWidget->currentPageIndex() == 1) {
108 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 110 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
109 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 111 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
110 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 112 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
111 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 113 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
112 setCaption("AdvancedFm :: "+fs+" :: " 114 setCaption("AdvancedFm :: "+fs+" :: "
113 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 115 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
114 } 116 }
115} 117}
116 118
117 119
118void AdvancedFm::populateLocalView() { 120void AdvancedFm::populateLocalView() {
119 QPixmap pm; 121 QPixmap pm;
120 Local_View->clear(); 122 Local_View->clear();
121 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 123 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
122 currentDir.setMatchAllDirs(TRUE); 124 currentDir.setMatchAllDirs(TRUE);
123 currentDir.setNameFilter(filterStr); 125 currentDir.setNameFilter(filterStr);
124 QString fileL, fileS, fileDate; 126 QString fileL, fileS, fileDate;
125 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 127 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
126 setCaption("AdvancedFm :: "+fs+" :: " 128 setCaption("AdvancedFm :: "+fs+" :: "
127 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 129 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
128 bool isDir=FALSE; 130 bool isDir=FALSE;
129 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 131 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
130 QFileInfoListIterator it(*list); 132 QFileInfoListIterator it(*list);
131 QFileInfo *fi; 133 QFileInfo *fi;
132 while ( (fi=it.current()) ) { 134 while ( (fi=it.current()) ) {
133 if (fi->isSymLink() ) { 135 if (fi->isSymLink() ) {
134 QString symLink=fi->readLink(); 136 QString symLink=fi->readLink();
135 QFileInfo sym( symLink); 137 QFileInfo sym( symLink);
136 fileS.sprintf( "%10i", sym.size() ); 138 fileS.sprintf( "%10i", sym.size() );
137 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 139 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
138 fileDate = sym.lastModified().toString(); 140 fileDate = sym.lastModified().toString();
139 } else { 141 } else {
140 fileS.sprintf( "%10i", fi->size() ); 142 fileS.sprintf( "%10i", fi->size() );
141 fileL.sprintf( "%s",fi->fileName().data() ); 143 fileL.sprintf( "%s",fi->fileName().data() );
142 fileDate= fi->lastModified().toString(); 144 fileDate= fi->lastModified().toString();
143 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 145 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
144 fileL+="/"; 146 fileL+="/";
145 isDir=TRUE; 147 isDir=TRUE;
146 } 148 }
147 } 149 }
148 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 150 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
149 if(fileL !="./" && fi->exists()) { 151 if(fileL !="./" && fi->exists()) {
150 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 152 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
151 153
152 if(isDir || fileL.find("/",0,TRUE) != -1) { 154 if(isDir || fileL.find("/",0,TRUE) != -1) {
153 155
154 if( !QDir( fi->filePath() ).isReadable()) //is directory 156 if( !QDir( fi->filePath() ).isReadable()) //is directory
155 pm = Resource::loadPixmap( "lockedfolder" ); 157 pm = Resource::loadPixmap( "lockedfolder" );
156 else 158 else
157 pm= Resource::loadPixmap( "folder" ); 159 pm= Resource::loadPixmap( "folder" );
158 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 160 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
159 pm = Resource::loadPixmap( "exec"); 161 pm = Resource::loadPixmap( "exec");
160 } else if( (fileInfo.permission( QFileInfo::ExeUser) 162 } else if( (fileInfo.permission( QFileInfo::ExeUser)
161 | fileInfo.permission( QFileInfo::ExeGroup) 163 | fileInfo.permission( QFileInfo::ExeGroup)
162 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 164 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
163 pm = Resource::loadPixmap( "exec"); 165 pm = Resource::loadPixmap( "exec");
164 } else if( !fi->isReadable() ) { 166 } else if( !fi->isReadable() ) {
165 pm = Resource::loadPixmap( "locked" ); 167 pm = Resource::loadPixmap( "locked" );
166 } else { //everything else goes by mimetype 168 } else { //everything else goes by mimetype
167 MimeType mt(fi->filePath()); 169 MimeType mt(fi->filePath());
168 pm=mt.pixmap(); //sets the correct pixmap for mimetype 170 pm=mt.pixmap(); //sets the correct pixmap for mimetype
169 if(pm.isNull()) 171 if(pm.isNull())
170 pm = Resource::loadPixmap( "UnknownDocument-14" ); 172 pm = Resource::loadPixmap( "UnknownDocument-14" );
171 } 173 }
172 item->setPixmap( 0,pm); 174 item->setPixmap( 0,pm);
173 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 175 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
174 // overlay link image 176 // overlay link image
175 pm= Resource::loadPixmap( "folder" ); 177 pm= Resource::loadPixmap( "folder" );
176 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 178 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
177 QPainter painter( &pm ); 179 QPainter painter( &pm );
178 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 180 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
179 pm.setMask( pm.createHeuristicMask( FALSE ) ); 181 pm.setMask( pm.createHeuristicMask( FALSE ) );
180 item->setPixmap( 0, pm); 182 item->setPixmap( 0, pm);
181 } 183 }
182 } 184 }
183 isDir=FALSE; 185 isDir=FALSE;
184 ++it; 186 ++it;
185 } 187 }
186 188
187 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 189 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
188 struct stat buf; 190 struct stat buf;
189 dev_t devT; 191 dev_t devT;
190 DIR *dir; 192 DIR *dir;
191 struct dirent *mydirent; 193 struct dirent *mydirent;
192 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 194 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
193 while ((mydirent = readdir(dir)) != NULL) { 195 while ((mydirent = readdir(dir)) != NULL) {
194 lstat( mydirent->d_name, &buf); 196 lstat( mydirent->d_name, &buf);
195 qDebug(mydirent->d_name); 197 qDebug(mydirent->d_name);
196 fileL.sprintf("%s", mydirent->d_name); 198 fileL.sprintf("%s", mydirent->d_name);
197 devT = buf.st_dev; 199 devT = buf.st_dev;
@@ -277,274 +279,289 @@ void AdvancedFm::populateRemoteView() {
277 QPainter painter( &pm ); 279 QPainter painter( &pm );
278 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 280 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
279 pm.setMask( pm.createHeuristicMask( FALSE ) ); 281 pm.setMask( pm.createHeuristicMask( FALSE ) );
280 } 282 }
281 item->setPixmap( 0, pm); 283 item->setPixmap( 0, pm);
282 } 284 }
283 isDir=FALSE; 285 isDir=FALSE;
284 ++it; 286 ++it;
285 } 287 }
286 288
287 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 289 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
288 struct stat buf; 290 struct stat buf;
289 DIR *dir; 291 DIR *dir;
290 struct dirent *mydirent; 292 struct dirent *mydirent;
291 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 293 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
292 while ((mydirent = readdir(dir)) != NULL) { 294 while ((mydirent = readdir(dir)) != NULL) {
293 lstat( mydirent->d_name, &buf); 295 lstat( mydirent->d_name, &buf);
294 qDebug(mydirent->d_name); 296 qDebug(mydirent->d_name);
295 fileL.sprintf("%s", mydirent->d_name); 297 fileL.sprintf("%s", mydirent->d_name);
296 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 298 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
297 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 299 fileDate.sprintf("%s", ctime( &buf.st_mtime));
298 if( fileL.find(".") == -1 ){ 300 if( fileL.find(".") == -1 ){
299 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 301 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
300 pm = Resource::loadPixmap( "UnknownDocument-14" ); 302 pm = Resource::loadPixmap( "UnknownDocument-14" );
301 item->setPixmap( 0,pm); 303 item->setPixmap( 0,pm);
302 } 304 }
303 } 305 }
304 306
305 closedir(dir); 307 closedir(dir);
306 } 308 }
307 309
308 Remote_View->setSorting( 3,FALSE); 310 Remote_View->setSorting( 3,FALSE);
309 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 311 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
310} 312}
311 313
312void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 314void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
313 if(selectedItem) { 315 if(selectedItem) {
314 QString strItem=selectedItem->text(0); 316 QString strItem=selectedItem->text(0);
315 QString strSize=selectedItem->text(1); 317 QString strSize=selectedItem->text(1);
316 strSize=strSize.stripWhiteSpace(); 318 strSize=strSize.stripWhiteSpace();
317 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 319 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
318 QString strItem2 = dealWithSymName((const QString&)strItem); 320 QString strItem2 = dealWithSymName((const QString&)strItem);
319// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 321// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
320 if(QDir(strItem2).exists() ) { 322 if(QDir(strItem2).exists() ) {
321 currentDir.cd(strItem2, TRUE); 323 currentDir.cd(strItem2, TRUE);
322 populateLocalView(); 324 populateLocalView();
323 325
324 } 326 }
325 } else { // not a symlink 327 } else { // not a symlink
326 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 328 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
327 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 329 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
328 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 330 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
329 currentDir.cd(strItem,FALSE); 331 currentDir.cd(strItem,FALSE);
330 populateLocalView(); 332 populateLocalView();
331 Local_View->ensureItemVisible(Local_View->firstChild()); 333 Local_View->ensureItemVisible(Local_View->firstChild());
332 334
333 } else { 335 } else {
334 currentDir.cdUp(); 336 currentDir.cdUp();
335 populateLocalView(); 337 populateLocalView();
336 Local_View->ensureItemVisible(Local_View->firstChild()); 338 Local_View->ensureItemVisible(Local_View->firstChild());
337 } 339 }
338 if(QDir(strItem).exists()){ 340 if(QDir(strItem).exists()){
339 currentDir.cd(strItem, TRUE); 341 currentDir.cd(strItem, TRUE);
340 Local_View->ensureItemVisible(Local_View->firstChild()); 342 Local_View->ensureItemVisible(Local_View->firstChild());
341 populateLocalView(); 343 populateLocalView();
342 } 344 }
343 } else { 345 } else {
344 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 346 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
345 if( QFile::exists(strItem ) ) { 347 if( QFile::exists(strItem ) ) {
346 // qDebug("clicked item "+strItem); 348 // qDebug("clicked item "+strItem);
347 // DocLnk doc( strItem, FALSE ); 349 // DocLnk doc( strItem, FALSE );
348 // doc.execute(); 350 // doc.execute();
349 // Local_View->clearSelection(); 351 // Local_View->clearSelection();
350 } 352 }
351 } //end not symlink 353 } //end not symlink
352 chdir(strItem.latin1()); 354 chdir(strItem.latin1());
353 } 355 }
354 356
355 } 357 }
356} 358}
357 359
358void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 360void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
359 361
360 if(selectedItem) { 362 if(selectedItem) {
361 QString strItem=selectedItem->text(0); 363 QString strItem=selectedItem->text(0);
362 QString strSize=selectedItem->text(1); 364 QString strSize=selectedItem->text(1);
363 strSize=strSize.stripWhiteSpace(); 365 strSize=strSize.stripWhiteSpace();
364 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 366 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
365 QString strItem2 = dealWithSymName((const QString&)strItem); 367 QString strItem2 = dealWithSymName((const QString&)strItem);
366// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 368// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
367 currentRemoteDir.cd(strItem2, TRUE); 369 currentRemoteDir.cd(strItem2, TRUE);
368 populateRemoteView(); 370 populateRemoteView();
369 } else { // not a symlink 371 } else { // not a symlink
370 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 372 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
371 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 373 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
372 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 374 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
373 currentRemoteDir.cd(strItem,FALSE); 375 currentRemoteDir.cd(strItem,FALSE);
374 populateRemoteView(); 376 populateRemoteView();
375 Remote_View->ensureItemVisible(Remote_View->firstChild()); 377 Remote_View->ensureItemVisible(Remote_View->firstChild());
376 } else { 378 } else {
377 currentRemoteDir.cdUp(); 379 currentRemoteDir.cdUp();
378 populateRemoteView(); 380 populateRemoteView();
379 Remote_View->ensureItemVisible(Remote_View->firstChild()); 381 Remote_View->ensureItemVisible(Remote_View->firstChild());
380 } 382 }
381 if(QDir(strItem).exists()){ 383 if(QDir(strItem).exists()){
382 currentRemoteDir.cd(strItem, TRUE); 384 currentRemoteDir.cd(strItem, TRUE);
383 populateRemoteView(); 385 populateRemoteView();
384 Remote_View->ensureItemVisible(Remote_View->firstChild()); 386 Remote_View->ensureItemVisible(Remote_View->firstChild());
385 } 387 }
386 } else { 388 } else {
387 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 389 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
388 if( QFile::exists(strItem ) ) { 390 if( QFile::exists(strItem ) ) {
389 // qDebug("clicked item "+strItem); 391 // qDebug("clicked item "+strItem);
390 // DocLnk doc( strItem, FALSE ); 392 // DocLnk doc( strItem, FALSE );
391 // doc.execute(); 393 // doc.execute();
392 // Remote_View->clearSelection(); 394 // Remote_View->clearSelection();
393 } 395 }
394 } //end not symlink 396 } //end not symlink
395 chdir(strItem.latin1()); 397 chdir(strItem.latin1());
396 } 398 }
397 } 399 }
398} 400}
399 401
400 402
401void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 403void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
402// qDebug("list pressed"); 404// qDebug("list pressed");
403 switch (mouse) { 405 switch (mouse) {
404 case 1: 406 case 1:
407 {
408 if(renameBox != 0 )
409 {
410 qDebug("cancel rename");
411 cancelRename();
412 }
413
414 }
405 break; 415 break;
406 case 2: 416 case 2:
407 menuTimer.start( 500, TRUE ); 417 menuTimer.start( 500, TRUE );
408 qDebug("Start menu timer\n"); 418 qDebug("Start menu timer\n");
409 break; 419 break;
410 }; 420 };
411} 421}
412 422
413void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 423void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
414 424
415 switch (mouse) { 425 switch (mouse) {
416 case 1: 426 case 1:
417 break; 427 {
418 case 2: 428 if(renameBox != 0 )
419 menuTimer.start( 500, TRUE ); 429 {
420 qDebug("Start menu timer"); 430 qDebug("cancel rename");
421 break; 431 cancelRename();
422 }; 432 }
433 }
434 break;
435 case 2:
436 menuTimer.start( 500, TRUE );
437 qDebug("Start menu timer");
438 break;
439 };
423} 440}
424 441
425 442
426void AdvancedFm::switchToLocalTab() { 443void AdvancedFm::switchToLocalTab() {
427 TabWidget->setCurrentTab(0); 444 TabWidget->setCurrentTab(0);
428 Local_View->setFocus(); 445 Local_View->setFocus();
429} 446}
430 447
431void AdvancedFm::switchToRemoteTab() { 448void AdvancedFm::switchToRemoteTab() {
432 TabWidget->setCurrentTab(1); 449 TabWidget->setCurrentTab(1);
433 Remote_View->setFocus(); 450 Remote_View->setFocus();
434} 451}
435 452
436void AdvancedFm::readConfig() { 453void AdvancedFm::readConfig() {
437 Config cfg("AdvancedFm"); 454 Config cfg("AdvancedFm");
438} 455}
439 456
440void AdvancedFm::writeConfig() { 457void AdvancedFm::writeConfig() {
441 Config cfg("AdvancedFm"); 458 Config cfg("AdvancedFm");
442} 459}
443 460
444void AdvancedFm::currentPathComboChanged() { 461void AdvancedFm::currentPathComboChanged() {
445 if (TabWidget->getCurrentTab() == 0) { 462 if (TabWidget->getCurrentTab() == 0) {
446// if (TabWidget->currentPageIndex() == 0) { 463// if (TabWidget->currentPageIndex() == 0) {
447 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 464 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
448 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 465 currentDir.setPath( currentPathCombo->lineEdit()->text() );
449 populateLocalView(); 466 populateLocalView();
450 } else { 467 } else {
451 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 468 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
452 } 469 }
453 } 470 }
454 if (TabWidget->getCurrentTab() == 0) { 471 if (TabWidget->getCurrentTab() == 0) {
455// if (TabWidget->currentPageIndex() == 0) { 472// if (TabWidget->currentPageIndex() == 0) {
456 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 473 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
457 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 474 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
458 populateRemoteView(); 475 populateRemoteView();
459 } else { 476 } else {
460 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 477 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
461 } 478 }
462 } 479 }
463} 480}
464 481
465void AdvancedFm::fillCombo(const QString &currentPath) { 482void AdvancedFm::fillCombo(const QString &currentPath) {
466 qDebug("%d",TabWidget->getCurrentTab()); 483 qDebug("%d",TabWidget->getCurrentTab());
467 if (TabWidget->getCurrentTab() == 0) { 484 if (TabWidget->getCurrentTab() == 0) {
468// if (TabWidget->currentPageIndex() == 0) { 485// if (TabWidget->currentPageIndex() == 0) {
469 currentPathCombo->lineEdit()->setText( currentPath); 486 currentPathCombo->lineEdit()->setText( currentPath);
470 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 487 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
471 currentPathCombo->clear(); 488 currentPathCombo->clear();
472 localDirPathStringList.prepend( currentPath ); 489 localDirPathStringList.prepend( currentPath );
473 currentPathCombo->insertStringList( localDirPathStringList,-1); 490 currentPathCombo->insertStringList( localDirPathStringList,-1);
474 } 491 }
475 } else { 492 } else {
476 currentPathCombo->lineEdit()->setText( currentPath); 493 currentPathCombo->lineEdit()->setText( currentPath);
477 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 494 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
478 currentPathCombo->clear(); 495 currentPathCombo->clear();
479 remoteDirPathStringList.prepend( currentPath ); 496 remoteDirPathStringList.prepend( currentPath );
480 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 497 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
481 } 498 }
482 } 499 }
483} 500}
484 501
485void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 502void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
486 if (TabWidget->getCurrentTab() == 0) { 503 if (TabWidget->getCurrentTab() == 0) {
487// if (TabWidget->currentPageIndex() == 0) { 504// if (TabWidget->currentPageIndex() == 0) {
488 chdir( currentPath.latin1() ); 505 chdir( currentPath.latin1() );
489 currentDir.cd( currentPath, TRUE); 506 currentDir.cd( currentPath, TRUE);
490 populateLocalView(); 507 populateLocalView();
491 update(); 508 update();
492 } else { 509 } else {
493 chdir( currentPath.latin1() ); 510 chdir( currentPath.latin1() );
494 currentRemoteDir.cd( currentPath, TRUE); 511 currentRemoteDir.cd( currentPath, TRUE);
495 populateRemoteView(); 512 populateRemoteView();
496 update(); 513 update();
497 } 514 }
498} 515}
499 516
500QStringList AdvancedFm::getPath() { 517QStringList AdvancedFm::getPath() {
501 QStringList strList; 518 QStringList strList;
502 if (TabWidget->getCurrentTab() == 0) { 519 if (TabWidget->getCurrentTab() == 0) {
503// if (TabWidget->currentPageIndex() == 0) { 520// if (TabWidget->currentPageIndex() == 0) {
504 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 521 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
505 QListViewItemIterator it( Local_View ); 522 QListViewItemIterator it( Local_View );
506 for ( ; it.current(); ++it ) { 523 for ( ; it.current(); ++it ) {
507 if ( it.current()->isSelected() ) { 524 if ( it.current()->isSelected() ) {
508 strList << it.current()->text(0); 525 strList << it.current()->text(0);
509 qDebug(it.current()->text(0)); 526 qDebug(it.current()->text(0));
510 } 527 }
511 } 528 }
512 return strList; 529 return strList;
513 } else { 530 } else {
514 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 531 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
515 QListViewItemIterator it( Remote_View ); 532 QListViewItemIterator it( Remote_View );
516 for ( ; it.current(); ++it ) { 533 for ( ; it.current(); ++it ) {
517 if ( it.current()->isSelected() ) { 534 if ( it.current()->isSelected() ) {
518 strList << it.current()->text(0); 535 strList << it.current()->text(0);
519 qDebug(it.current()->text(0)); 536 qDebug(it.current()->text(0));
520 } 537 }
521 } 538 }
522 return strList; 539 return strList;
523 } 540 }
524 return ""; 541 return "";
525} 542}
526 543
527void AdvancedFm::homeButtonPushed() { 544void AdvancedFm::homeButtonPushed() {
528 QString current = QDir::homeDirPath(); 545 QString current = QDir::homeDirPath();
529 chdir( current.latin1() ); 546 chdir( current.latin1() );
530 if (TabWidget->getCurrentTab() == 0) { 547 if (TabWidget->getCurrentTab() == 0) {
531// if (TabWidget->currentPageIndex() == 0) { 548// if (TabWidget->currentPageIndex() == 0) {
532 currentDir.cd( current, TRUE); 549 currentDir.cd( current, TRUE);
533 populateLocalView(); 550 populateLocalView();
534 } else { 551 } else {
535 currentRemoteDir.cd( current, TRUE); 552 currentRemoteDir.cd( current, TRUE);
536 populateRemoteView(); 553 populateRemoteView();
537 } 554 }
538 update(); 555 update();
539} 556}
540 557
541void AdvancedFm::docButtonPushed() { 558void AdvancedFm::docButtonPushed() {
542 QString current = QPEApplication::documentDir(); 559 QString current = QPEApplication::documentDir();
543 chdir( current.latin1() ); 560 chdir( current.latin1() );
544 561
545 if (TabWidget->getCurrentTab() == 0) { 562 if (TabWidget->getCurrentTab() == 0) {
546//if (TabWidget->currentPageIndex() == 0) { 563//if (TabWidget->currentPageIndex() == 0) {
547 currentDir.cd( current, TRUE); 564 currentDir.cd( current, TRUE);
548 populateLocalView(); 565 populateLocalView();
549 } else { 566 } else {
550 currentRemoteDir.cd( current, TRUE); 567 currentRemoteDir.cd( current, TRUE);
@@ -754,128 +771,129 @@ void AdvancedFm::showFileMenu() {
754 // QPopupMenu *o = new QPopupMenu(0); 771 // QPopupMenu *o = new QPopupMenu(0);
755 if (TabWidget->getCurrentTab() == 0) 772 if (TabWidget->getCurrentTab() == 0)
756 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 773 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
757 else 774 else
758 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); 775 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
759 776
760 if ( QFileInfo(fi).isDir() ) { 777 if ( QFileInfo(fi).isDir() ) {
761 m->insertSeparator(); 778 m->insertSeparator();
762 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 779 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
763 } else { 780 } else {
764 781
765 if ( app ) 782 if ( app )
766 m->insertItem( app->pixmap(), tr( "Open in " 783 m->insertItem( app->pixmap(), tr( "Open in "
767 + app->name() ), this, SLOT( runThis() ) ); 784 + app->name() ), this, SLOT( runThis() ) );
768 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 785 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
769 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 786 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
770 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 787 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
771 } 788 }
772 789
773 m->insertItem(tr("Actions"),n); 790 m->insertItem(tr("Actions"),n);
774 if(isLocalView) 791 if(isLocalView)
775 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 792 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
776 else 793 else
777 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 794 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
778 795
779 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 796 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
780 797
781 n->insertSeparator(); 798 n->insertSeparator();
782 799
783 800
784 if(isLocalView) 801 if(isLocalView)
785 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 802 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
786 else 803 else
787 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 804 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
788 805
789 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 806 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
790 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 807 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
791 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 808 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
792 n->insertItem( tr( "Move" ), this, SLOT( move() )); 809 n->insertItem( tr( "Move" ), this, SLOT( move() ));
793 810
794 n->insertSeparator(); 811 n->insertSeparator();
795 812
796 if(isLocalView) 813 if(isLocalView)
797 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 814 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
798 else 815 else
799 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 816 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
800 817
801 818
802 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 819 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
803 820
804 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 821 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
805 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 822 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
806 823
807 m->insertSeparator(); 824 m->insertSeparator();
808 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 825 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
809 826
810#if defined(QT_QWS_OPIE) 827#if defined(QT_QWS_OPIE)
811 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 828 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
812#endif 829#endif
813 m->setCheckable(TRUE); 830 m->setCheckable(TRUE);
814 if (!b) 831 if (!b)
815 m->setItemChecked(m->idAt(0),TRUE); 832 m->setItemChecked(m->idAt(0),TRUE);
816 else 833 else
817 m->setItemChecked(m->idAt(0),FALSE); 834 m->setItemChecked(m->idAt(0),FALSE);
818 835
819 if(Ir::supported()) 836 if(Ir::supported())
820 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 837 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
821 m->setFocus(); 838 m->setFocus();
822 m->exec( QPoint( 4,QCursor::pos().y()) ); 839 m->exec( QPoint( 4,QCursor::pos().y()) );
823 840
824 if(m) delete m; 841 if(m) delete m;
825} 842}
826 843
827 844
828void AdvancedFm::cancelMenuTimer() { 845void AdvancedFm::cancelMenuTimer() {
829 846
830// qDebug("selectionChanged: cancel menu timer"); 847// qDebug("selectionChanged: cancel menu timer");
831 if( menuTimer.isActive() ) 848 if( menuTimer.isActive() )
832 menuTimer.stop(); 849 menuTimer.stop();
833} 850}
834 851
835QString AdvancedFm::checkDiskSpace(const QString &path) { 852QString AdvancedFm::checkDiskSpace(const QString &path) {
836 struct statfs fss; 853 struct statfs fss;
837 if ( !statfs( path.latin1(), &fss ) ) { 854 if ( !statfs( path.latin1(), &fss ) ) {
838 int blkSize = fss.f_bsize; 855 int blkSize = fss.f_bsize;
839// int totalBlks = fs.f_blocks; 856// int totalBlks = fs.f_blocks;
840 int availBlks = fss.f_bavail; 857 int availBlks = fss.f_bavail;
841 858
842 long mult = blkSize / 1024; 859 long mult = blkSize / 1024;
843 long div = 1024 / blkSize; 860 long div = 1024 / blkSize;
844 if ( !mult ) mult = 1; 861 if ( !mult ) mult = 1;
845 if ( !div ) div = 1; 862 if ( !div ) div = 1;
846 863
847 864
848 return QString::number(availBlks * mult / div); 865 return QString::number(availBlks * mult / div);
849 } 866 }
850 return ""; 867 return "";
851} 868}
852 869
853void AdvancedFm::addToDocs() { 870void AdvancedFm::addToDocs() {
854 QStringList strListPaths = getPath(); 871 QStringList strListPaths = getPath();
855 if( strListPaths.count() > 0) { 872 if( strListPaths.count() > 0) {
856 QString curFile; 873 QString curFile;
857 if (TabWidget->getCurrentTab() == 0) { 874 if (TabWidget->getCurrentTab() == 0) {
858// if (TabWidget->currentPageIndex() == 0) { 875// if (TabWidget->currentPageIndex() == 0) {
859 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 876 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
860 curFile = currentDir.canonicalPath()+"/"+(*it); 877 curFile = currentDir.canonicalPath()+"/"+(*it);
861 qDebug(curFile); 878 qDebug(curFile);
862 DocLnk f; 879 DocLnk f;
863// curFile.replace(QRegExp("\\..*"),""); 880// curFile.replace(QRegExp("\\..*"),"");
864 f.setName((*it)); 881 f.setName((*it));
865 f.setFile( curFile); 882 f.setFile( curFile);
866 f.writeLink(); 883 f.writeLink();
867 } 884 }
868 } else { 885 } else {
869 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 886 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
870 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 887 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
871 qDebug(curFile); 888 qDebug(curFile);
872 889
873 DocLnk f; 890 DocLnk f;
874// curFile.replace(QRegExp("\\..*"),""); 891// curFile.replace(QRegExp("\\..*"),"");
875 f.setName((*it)); 892 f.setName((*it));
876 f.setFile( curFile); 893 f.setFile( curFile);
877 f.writeLink(); 894 f.writeLink();
878 } 895 }
879 } 896 }
880 } 897 }
881} 898}
899
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index f067013..2ddcabc 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -902,224 +902,236 @@ void AdvancedFm::del() {
902 if (TabWidget->getCurrentTab() == 0) 902 if (TabWidget->getCurrentTab() == 0)
903 localDelete(); 903 localDelete();
904 else 904 else
905 remoteDelete(); 905 remoteDelete();
906} 906}
907 907
908void AdvancedFm::mkSym() { 908void AdvancedFm::mkSym() {
909 QString cmd; 909 QString cmd;
910 QStringList curFileList = getPath(); 910 QStringList curFileList = getPath();
911 if( curFileList.count() > 0) { 911 if( curFileList.count() > 0) {
912 912
913 if (TabWidget->getCurrentTab() == 0) { 913 if (TabWidget->getCurrentTab() == 0) {
914 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 914 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
915 915
916 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 916 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
917 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 917 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
918 QString curFile = currentDir.canonicalPath()+"/"+(*it); 918 QString curFile = currentDir.canonicalPath()+"/"+(*it);
919 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 919 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
920 cmd = "ln -s "+curFile+" "+destName; 920 cmd = "ln -s "+curFile+" "+destName;
921 qDebug(cmd); 921 qDebug(cmd);
922 startProcess( (const QString)cmd ); 922 startProcess( (const QString)cmd );
923 } 923 }
924 populateRemoteView(); 924 populateRemoteView();
925 TabWidget->setCurrentTab(1); 925 TabWidget->setCurrentTab(1);
926 } else { 926 } else {
927 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 927 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
928 928
929 QString destName = currentDir.canonicalPath()+"/"+(*it); 929 QString destName = currentDir.canonicalPath()+"/"+(*it);
930 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 930 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
931 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 931 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
932 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 932 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
933 933
934 cmd = "ln -s "+curFile+" "+destName; 934 cmd = "ln -s "+curFile+" "+destName;
935 qDebug(cmd); 935 qDebug(cmd);
936 startProcess( (const QString)cmd ); 936 startProcess( (const QString)cmd );
937 } 937 }
938 populateLocalView(); 938 populateLocalView();
939 TabWidget->setCurrentTab(0); 939 TabWidget->setCurrentTab(0);
940 } 940 }
941 } 941 }
942} 942}
943 943
944void AdvancedFm::doBeam() { 944void AdvancedFm::doBeam() {
945 Ir ir; 945 Ir ir;
946 if(!ir.supported()){ 946 if(!ir.supported()){
947 } else { 947 } else {
948 948
949 QStringList curFileList = getPath(); 949 QStringList curFileList = getPath();
950 if( curFileList.count() > 0) { 950 if( curFileList.count() > 0) {
951 951
952 if (TabWidget->getCurrentTab() == 0) { 952 if (TabWidget->getCurrentTab() == 0) {
953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 953 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
954 954
955 QString curFile = currentDir.canonicalPath()+"/"+(*it); 955 QString curFile = currentDir.canonicalPath()+"/"+(*it);
956 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 956 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
957 Ir *file = new Ir(this, "IR"); 957 Ir *file = new Ir(this, "IR");
958 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 958 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
959 file->send( curFile, curFile ); 959 file->send( curFile, curFile );
960 } 960 }
961 961
962 } else { 962 } else {
963 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 963 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
964 964
965 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 965 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 966 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
967 Ir *file = new Ir(this, "IR"); 967 Ir *file = new Ir(this, "IR");
968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 968 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
969 file->send( curFile, curFile ); 969 file->send( curFile, curFile );
970 970
971 } 971 }
972 } 972 }
973 } 973 }
974 } 974 }
975 975
976} 976}
977 977
978void AdvancedFm::fileBeamFinished( Ir *) { 978void AdvancedFm::fileBeamFinished( Ir *) {
979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 979 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
980 980
981} 981}
982 982
983void AdvancedFm::selectAll() { 983void AdvancedFm::selectAll() {
984 if (TabWidget->getCurrentTab() == 0) { 984 if (TabWidget->getCurrentTab() == 0) {
985 Local_View->selectAll(true); 985 Local_View->selectAll(true);
986 Local_View->setSelected( Local_View->firstChild(),false); 986 Local_View->setSelected( Local_View->firstChild(),false);
987 } else { 987 } else {
988 Remote_View->selectAll(true); 988 Remote_View->selectAll(true);
989 Remote_View->setSelected( Remote_View->firstChild(),false); 989 Remote_View->setSelected( Remote_View->firstChild(),false);
990 } 990 }
991} 991}
992 992
993void AdvancedFm::startProcess(const QString & cmd) { 993void AdvancedFm::startProcess(const QString & cmd) {
994 QStringList command; 994 QStringList command;
995 OProcess *process; 995 OProcess *process;
996 process = new OProcess(); 996 process = new OProcess();
997 connect(process, SIGNAL(processExited(OProcess *)), 997 connect(process, SIGNAL(processExited(OProcess *)),
998 this, SLOT( processEnded())); 998 this, SLOT( processEnded()));
999 999
1000 command << "/bin/sh"; 1000 command << "/bin/sh";
1001 command << "-c"; 1001 command << "-c";
1002 command << cmd.latin1(); 1002 command << cmd.latin1();
1003 *process << command; 1003 *process << command;
1004 if(!process->start(OProcess::NotifyOnExit) ) 1004 if(!process->start(OProcess::NotifyOnExit) )
1005 qDebug("could not start process"); 1005 qDebug("could not start process");
1006} 1006}
1007 1007
1008void AdvancedFm::processEnded() { 1008void AdvancedFm::processEnded() {
1009 populateLocalView(); 1009 populateLocalView();
1010 populateRemoteView(); 1010 populateRemoteView();
1011} 1011}
1012 1012
1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 1013bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
1014 if ( o->inherits( "QLineEdit" ) ) { 1014 if ( o->inherits( "QLineEdit" ) ) {
1015 if ( e->type() == QEvent::KeyPress ) { 1015 if ( e->type() == QEvent::KeyPress ) {
1016 QKeyEvent *ke = (QKeyEvent*)e; 1016 QKeyEvent *ke = (QKeyEvent*)e;
1017 if ( ke->key() == Key_Return || 1017 if ( ke->key() == Key_Return ||
1018 ke->key() == Key_Enter ) { 1018 ke->key() == Key_Enter ) {
1019 okRename(); 1019 okRename();
1020 return true; 1020 return true;
1021 } else if ( ke->key() == Key_Escape ) { 1021 } else if ( ke->key() == Key_Escape ) {
1022 cancelRename(); 1022 cancelRename();
1023 return true; 1023 return true;
1024 } 1024 }
1025 } else if ( e->type() == QEvent::FocusOut ) { 1025 } else if ( e->type() == QEvent::FocusOut ) {
1026 cancelRename(); 1026 cancelRename();
1027 return true; 1027 return true;
1028 } 1028 }
1029 } 1029 }
1030 if ( o->inherits( "QListView" ) ) {
1031 if ( e->type() == QEvent::FocusOut ) {
1032 printf("focusIn\n");
1033
1034 }
1035 }
1036
1030 return QWidget::eventFilter( o, e ); 1037 return QWidget::eventFilter( o, e );
1031} 1038}
1032 1039
1033 1040
1034void AdvancedFm::cancelRename() { 1041void AdvancedFm::cancelRename()
1042{
1035 qDebug("cancel rename"); 1043 qDebug("cancel rename");
1036 QListView * view; 1044 QListView * view;
1037 if (TabWidget->getCurrentTab() == 0) { 1045 if (TabWidget->getCurrentTab() == 0)
1038 view = Local_View; 1046 {
1039 } 1047 view = Local_View;
1048 }
1040 else 1049 else
1041 { 1050 {
1042 view = Remote_View; 1051 view = Remote_View;
1043 } 1052 }
1044 1053
1045 bool resetFocus = view->viewport()->focusProxy() == renameBox; 1054 bool resetFocus = view->viewport()->focusProxy() == renameBox;
1046 delete renameBox; 1055 delete renameBox;
1047 renameBox = 0; 1056 renameBox = 0;
1048 if ( resetFocus ) { 1057 if ( resetFocus ) {
1049 view->viewport()->setFocusProxy( view); 1058 view->viewport()->setFocusProxy( view);
1050 view->setFocus(); 1059 view->setFocus();
1051 } 1060 }
1052} 1061}
1053 1062
1054void AdvancedFm::doRename(QListView * view) { 1063void AdvancedFm::doRename(QListView * view)
1064{
1055 1065
1056 QRect r = view->itemRect( view->currentItem( )); 1066 QRect r = view->itemRect( view->currentItem( ));
1057 r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); 1067 r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
1058 r.setX( view->contentsX() ); 1068 r.setX( view->contentsX() );
1059 if ( r.width() > view->visibleWidth() ) 1069 if ( r.width() > view->visibleWidth() )
1060 r.setWidth( view->visibleWidth() ); 1070 r.setWidth( view->visibleWidth() );
1061 1071
1062 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 1072 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
1063 renameBox->setFrame(true); 1073 renameBox->setFrame(true);
1064 1074
1065 renameBox->setText( view->currentItem()->text(0) ); 1075 renameBox->setText( view->currentItem()->text(0) );
1066 1076
1067 renameBox->selectAll(); 1077 renameBox->selectAll();
1068 renameBox->installEventFilter( this ); 1078 renameBox->installEventFilter( this );
1069 view->addChild( renameBox, r.x(), r.y() ); 1079 view->addChild( renameBox, r.x(), r.y() );
1070 renameBox->resize( r.size() ); 1080 renameBox->resize( r.size() );
1071 view->viewport()->setFocusProxy( renameBox ); 1081 view->viewport()->setFocusProxy( renameBox );
1072 renameBox->setFocus(); 1082 renameBox->setFocus();
1073 renameBox->show(); 1083 renameBox->show();
1074 1084
1075} 1085}
1076 1086
1077 1087
1078void AdvancedFm::localRename() { 1088void AdvancedFm::localRename()
1089{
1079 oldName = Local_View->currentItem()->text(0); 1090 oldName = Local_View->currentItem()->text(0);
1080 doRename(Local_View ); 1091 doRename(Local_View );
1081 populateLocalView(); 1092 populateLocalView();
1082} 1093}
1083 1094
1084void AdvancedFm::remoteRename() 1095void AdvancedFm::remoteRename()
1085{ 1096{
1086 oldName = Remote_View->currentItem()->text(0); 1097 oldName = Remote_View->currentItem()->text(0);
1087 doRename(Local_View ); 1098 doRename(Local_View );
1088 populateRemoteView(); 1099 populateRemoteView();
1089} 1100}
1090 1101
1091void AdvancedFm::okRename() { 1102void AdvancedFm::okRename()
1103{
1092 QString newName = renameBox->text(); 1104 QString newName = renameBox->text();
1093 cancelRename(); 1105 cancelRename();
1094 int tabs=0; 1106 int tabs=0;
1095 QListView * view; 1107 QListView * view;
1096 tabs = TabWidget->getCurrentTab(); 1108 tabs = TabWidget->getCurrentTab();
1097 if ( tabs == 0) 1109 if ( tabs == 0)
1098 { 1110 {
1099 view = Local_View; 1111 view = Local_View;
1100 QString path = currentDir.canonicalPath() + "/"; 1112 QString path = currentDir.canonicalPath() + "/";
1101 oldName = path + oldName; 1113 oldName = path + oldName;
1102 newName = path + newName; 1114 newName = path + newName;
1103 } 1115 }
1104 else 1116 else
1105 { 1117 {
1106 view = Remote_View; 1118 view = Remote_View;
1107 QString path = currentRemoteDir.canonicalPath() + "/"; 1119 QString path = currentRemoteDir.canonicalPath() + "/";
1108 oldName = path + oldName; 1120 oldName = path + oldName;
1109 newName = path + newName; 1121 newName = path + newName;
1110 } 1122 }
1111 1123
1112 if( view->currentItem() == NULL) 1124 if( view->currentItem() == NULL)
1113 return; 1125 return;
1114 if( rename(oldName.latin1(), newName.latin1())== -1) 1126 if( rename(oldName.latin1(), newName.latin1())== -1)
1115 QMessageBox::message(tr("Note"),tr("Could not rename")); 1127 QMessageBox::message(tr("Note"),tr("Could not rename"));
1116 else 1128 else
1117 oldName = ""; 1129 oldName = "";
1118 1130
1119 view->takeItem( view->currentItem() ); 1131 view->takeItem( view->currentItem() );
1120 delete view->currentItem(); 1132 delete view->currentItem();
1121 if ( tabs == 0) 1133 if ( tabs == 0)
1122 populateLocalView(); 1134 populateLocalView();
1123 else 1135 else
1124 populateRemoteView(); 1136 populateRemoteView();
1125} 1137}