summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp9
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp18
2 files changed, 12 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index b6e7a30..f23fd86 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,860 +1,855 @@
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/ofileselector.h> 15// #include <opie/ofileselector.h>
16// #include <opie/ofiledialog.h> 16// #include <opie/ofiledialog.h>
17 17
18#include <qpe/filemanager.h> 18#include <qpe/filemanager.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20#include <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/mimetype.h> 25#include <qpe/mimetype.h>
26#include <qpe/applnk.h> 26#include <qpe/applnk.h>
27#include <qpe/ir.h> 27#include <qpe/ir.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qstring.h> 36#include <qstring.h>
37#include <qcombobox.h> 37#include <qcombobox.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qlistview.h> 39#include <qlistview.h>
40#include <qmainwindow.h> 40#include <qmainwindow.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <qwidget.h> 44#include <qwidget.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qimage.h> 46#include <qimage.h>
47#include <qpixmap.h> 47#include <qpixmap.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qlineedit.h> 49#include <qlineedit.h>
50#include <qregexp.h> 50#include <qregexp.h>
51 51
52#include <unistd.h> 52#include <unistd.h>
53#include <stdlib.h> 53#include <stdlib.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <dirent.h> 55#include <dirent.h>
56#include <stdio.h> 56#include <stdio.h>
57#include <time.h> 57#include <time.h>
58#include <fcntl.h> 58#include <fcntl.h>
59#include <mntent.h> 59#include <mntent.h>
60#include <string.h> 60#include <string.h>
61#include <errno.h> 61#include <errno.h>
62#include <sys/vfs.h> 62#include <sys/vfs.h>
63#include <mntent.h> 63#include <mntent.h>
64#include <sys/utsname.h> 64#include <sys/utsname.h>
65 65
66AdvancedFm::AdvancedFm( ) 66AdvancedFm::AdvancedFm( )
67 : QMainWindow( ) { 67 : QMainWindow( ) {
68 init(); 68 init();
69 initConnections(); 69 initConnections();
70 populateLocalView(); 70 populateLocalView();
71 populateRemoteView(); 71 populateRemoteView();
72 currentPathCombo->setFocus(); 72 currentPathCombo->setFocus();
73} 73}
74 74
75AdvancedFm::~AdvancedFm() { 75AdvancedFm::~AdvancedFm() {
76} 76}
77 77
78void AdvancedFm::cleanUp() { 78void AdvancedFm::cleanUp() {
79 QString sfile=QDir::homeDirPath(); 79 QString sfile=QDir::homeDirPath();
80 if(sfile.right(1) != "/") 80 if(sfile.right(1) != "/")
81 sfile+="/._temp"; 81 sfile+="/._temp";
82 else 82 else
83 sfile+="._temp"; 83 sfile+="._temp";
84 QFile file( sfile); 84 QFile file( sfile);
85 if(file.exists()) 85 if(file.exists())
86 file.remove(); 86 file.remove();
87} 87}
88 88
89void AdvancedFm::tabChanged(QWidget *) { 89void AdvancedFm::tabChanged(QWidget *) {
90 if (TabWidget->currentPageIndex() == 0) { 90 if (TabWidget->currentPageIndex() == 0) {
91 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 91 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
92 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 92 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
93 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 93 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
94 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 94 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
95 setCaption("AdvancedFm :: "+fs+" :: " 95 setCaption("AdvancedFm :: "+fs+" :: "
96 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 96 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
97 97
98 } 98 }
99 if (TabWidget->currentPageIndex() == 1) { 99 if (TabWidget->currentPageIndex() == 1) {
100 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); 100 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
101 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); 101 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
102 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); 102 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
103 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 103 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
104 setCaption("AdvancedFm :: "+fs+" :: " 104 setCaption("AdvancedFm :: "+fs+" :: "
105 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 105 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
106 } 106 }
107} 107}
108 108
109 109
110void AdvancedFm::populateLocalView() { 110void AdvancedFm::populateLocalView() {
111 QPixmap pm; 111 QPixmap pm;
112 Local_View->clear(); 112 Local_View->clear();
113 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 113 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
114 currentDir.setMatchAllDirs(TRUE); 114 currentDir.setMatchAllDirs(TRUE);
115 currentDir.setNameFilter(filterStr); 115 currentDir.setNameFilter(filterStr);
116 QString fileL, fileS, fileDate; 116 QString fileL, fileS, fileDate;
117 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 117 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
118 setCaption("AdvancedFm :: "+fs+" :: " 118 setCaption("AdvancedFm :: "+fs+" :: "
119 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 119 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
120 bool isDir=FALSE; 120 bool isDir=FALSE;
121 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 121 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
122 QFileInfoListIterator it(*list); 122 QFileInfoListIterator it(*list);
123 QFileInfo *fi; 123 QFileInfo *fi;
124 while ( (fi=it.current()) ) { 124 while ( (fi=it.current()) ) {
125 if (fi->isSymLink() ) { 125 if (fi->isSymLink() ) {
126 QString symLink=fi->readLink(); 126 QString symLink=fi->readLink();
127 QFileInfo sym( symLink); 127 QFileInfo sym( symLink);
128 fileS.sprintf( "%10i", sym.size() ); 128 fileS.sprintf( "%10i", sym.size() );
129 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 129 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
130 fileDate = sym.lastModified().toString(); 130 fileDate = sym.lastModified().toString();
131 } else { 131 } else {
132 fileS.sprintf( "%10i", fi->size() ); 132 fileS.sprintf( "%10i", fi->size() );
133 fileL.sprintf( "%s",fi->fileName().data() ); 133 fileL.sprintf( "%s",fi->fileName().data() );
134 fileDate= fi->lastModified().toString(); 134 fileDate= fi->lastModified().toString();
135 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 135 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) {
136 fileL+="/"; 136 fileL+="/";
137 isDir=TRUE; 137 isDir=TRUE;
138 } 138 }
139 } 139 }
140 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 140 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
141 if(fileL !="./" && fi->exists()) { 141 if(fileL !="./" && fi->exists()) {
142 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 142 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
143 143
144 if(isDir || fileL.find("/",0,TRUE) != -1) { 144 if(isDir || fileL.find("/",0,TRUE) != -1) {
145 145
146 if( !QDir( fi->filePath() ).isReadable()) //is directory 146 if( !QDir( fi->filePath() ).isReadable()) //is directory
147 pm = Resource::loadPixmap( "lockedfolder" ); 147 pm = Resource::loadPixmap( "lockedfolder" );
148 else 148 else
149 pm= Resource::loadPixmap( "folder" ); 149 pm= Resource::loadPixmap( "folder" );
150 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 150 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
151 pm = Resource::loadPixmap( "exec"); 151 pm = Resource::loadPixmap( "exec");
152 } else if( (fileInfo.permission( QFileInfo::ExeUser) 152 } else if( (fileInfo.permission( QFileInfo::ExeUser)
153 | fileInfo.permission( QFileInfo::ExeGroup) 153 | fileInfo.permission( QFileInfo::ExeGroup)
154 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 154 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
155 pm = Resource::loadPixmap( "exec"); 155 pm = Resource::loadPixmap( "exec");
156 } else if( !fi->isReadable() ) { 156 } else if( !fi->isReadable() ) {
157 pm = Resource::loadPixmap( "locked" ); 157 pm = Resource::loadPixmap( "locked" );
158 } else { //everything else goes by mimetype 158 } else { //everything else goes by mimetype
159 MimeType mt(fi->filePath()); 159 MimeType mt(fi->filePath());
160 pm=mt.pixmap(); //sets the correct pixmap for mimetype 160 pm=mt.pixmap(); //sets the correct pixmap for mimetype
161 if(pm.isNull()) 161 if(pm.isNull())
162 pm = Resource::loadPixmap( "UnknownDocument-14" ); 162 pm = Resource::loadPixmap( "UnknownDocument-14" );
163 } 163 }
164 item->setPixmap( 0,pm); 164 item->setPixmap( 0,pm);
165 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 165 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
166 // overlay link image 166 // overlay link image
167 pm= Resource::loadPixmap( "folder" ); 167 pm= Resource::loadPixmap( "folder" );
168 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 168 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
169 QPainter painter( &pm ); 169 QPainter painter( &pm );
170 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 170 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
171 pm.setMask( pm.createHeuristicMask( FALSE ) ); 171 pm.setMask( pm.createHeuristicMask( FALSE ) );
172 item->setPixmap( 0, pm); 172 item->setPixmap( 0, pm);
173 } 173 }
174 } 174 }
175 isDir=FALSE; 175 isDir=FALSE;
176 ++it; 176 ++it;
177 } 177 }
178 178
179 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 179 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
180 struct stat buf; 180 struct stat buf;
181 dev_t devT; 181 dev_t devT;
182 DIR *dir; 182 DIR *dir;
183 struct dirent *mydirent; 183 struct dirent *mydirent;
184 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 184 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
185 while ((mydirent = readdir(dir)) != NULL) { 185 while ((mydirent = readdir(dir)) != NULL) {
186 lstat( mydirent->d_name, &buf); 186 lstat( mydirent->d_name, &buf);
187 qDebug(mydirent->d_name); 187 qDebug(mydirent->d_name);
188 fileL.sprintf("%s", mydirent->d_name); 188 fileL.sprintf("%s", mydirent->d_name);
189 devT = buf.st_dev; 189 devT = buf.st_dev;
190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 190 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
191 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 191 fileDate.sprintf("%s", ctime( &buf.st_mtime));
192 if( fileL.find(".") == -1 ){ 192 if( fileL.find(".") == -1 ){
193 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 193 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
194 pm = Resource::loadPixmap( "UnknownDocument-14" ); 194 pm = Resource::loadPixmap( "UnknownDocument-14" );
195 item->setPixmap( 0,pm); 195 item->setPixmap( 0,pm);
196 } 196 }
197 } 197 }
198 198
199 closedir(dir); 199 closedir(dir);
200 } 200 }
201 201
202 Local_View->setSorting( 3,FALSE); 202 Local_View->setSorting( 3,FALSE);
203 fillCombo( (const QString &) currentDir.canonicalPath()); 203 fillCombo( (const QString &) currentDir.canonicalPath());
204} 204}
205 205
206 206
207void AdvancedFm::populateRemoteView() { 207void AdvancedFm::populateRemoteView() {
208 QPixmap pm; 208 QPixmap pm;
209 Remote_View->clear(); 209 Remote_View->clear();
210 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 210 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
211 currentRemoteDir.setMatchAllDirs(TRUE); 211 currentRemoteDir.setMatchAllDirs(TRUE);
212 currentRemoteDir.setNameFilter(filterStr); 212 currentRemoteDir.setNameFilter(filterStr);
213 QString fileL, fileS, fileDate; 213 QString fileL, fileS, fileDate;
214 214
215 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 215 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
216 setCaption("AdvancedFm :: "+fs+" :: " 216 setCaption("AdvancedFm :: "+fs+" :: "
217 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 217 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
218 bool isDir=FALSE; 218 bool isDir=FALSE;
219 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 219 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
220 QFileInfoListIterator it(*list); 220 QFileInfoListIterator it(*list);
221 QFileInfo *fi; 221 QFileInfo *fi;
222 while ( (fi=it.current()) ) { 222 while ( (fi=it.current()) ) {
223 if (fi->isSymLink() ){ 223 if (fi->isSymLink() ){
224 QString symLink=fi->readLink(); 224 QString symLink=fi->readLink();
225 // qDebug("Symlink detected "+symLink); 225 // qDebug("Symlink detected "+symLink);
226 QFileInfo sym( symLink); 226 QFileInfo sym( symLink);
227 fileS.sprintf( "%10i", sym.size() ); 227 fileS.sprintf( "%10i", sym.size() );
228 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 228 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
229 fileDate = sym.lastModified().toString(); 229 fileDate = sym.lastModified().toString();
230 } else { 230 } else {
231 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 231 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
232 fileS.sprintf( "%10i", fi->size() ); 232 fileS.sprintf( "%10i", fi->size() );
233 fileL.sprintf( "%s",fi->fileName().data() ); 233 fileL.sprintf( "%s",fi->fileName().data() );
234 fileDate= fi->lastModified().toString(); 234 fileDate= fi->lastModified().toString();
235 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 235 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
236 fileL+="/"; 236 fileL+="/";
237 isDir=TRUE; 237 isDir=TRUE;
238 // qDebug( fileL); 238 // qDebug( fileL);
239 } 239 }
240 } 240 }
241 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 241 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
242 if(fileL !="./" && fi->exists()) { 242 if(fileL !="./" && fi->exists()) {
243 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 243 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
244 QPixmap pm; 244 QPixmap pm;
245 245
246 if(isDir || fileL.find("/",0,TRUE) != -1) { 246 if(isDir || fileL.find("/",0,TRUE) != -1) {
247 if( !QDir( fi->filePath() ).isReadable()) 247 if( !QDir( fi->filePath() ).isReadable())
248 pm = Resource::loadPixmap( "lockedfolder" ); 248 pm = Resource::loadPixmap( "lockedfolder" );
249 else 249 else
250 pm= Resource::loadPixmap( "folder" ); 250 pm= Resource::loadPixmap( "folder" );
251 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 251 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
252 pm = Resource::loadPixmap( "exec"); 252 pm = Resource::loadPixmap( "exec");
253 } else if( (fileInfo.permission( QFileInfo::ExeUser) 253 } else if( (fileInfo.permission( QFileInfo::ExeUser)
254 | fileInfo.permission( QFileInfo::ExeGroup) 254 | fileInfo.permission( QFileInfo::ExeGroup)
255 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 255 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
256 pm = Resource::loadPixmap( "exec"); 256 pm = Resource::loadPixmap( "exec");
257 } else if( !fi->isReadable() ) { 257 } else if( !fi->isReadable() ) {
258 pm = Resource::loadPixmap( "locked" ); 258 pm = Resource::loadPixmap( "locked" );
259 } else { 259 } else {
260 MimeType mt(fi->filePath()); 260 MimeType mt(fi->filePath());
261 pm=mt.pixmap(); //sets the correct pixmap for mimetype 261 pm=mt.pixmap(); //sets the correct pixmap for mimetype
262 if(pm.isNull()) 262 if(pm.isNull())
263 pm = Resource::loadPixmap( "UnknownDocument-14" ); 263 pm = Resource::loadPixmap( "UnknownDocument-14" );
264 } 264 }
265 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 265 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) {
266 // overlay link image 266 // overlay link image
267 pm= Resource::loadPixmap( "folder" ); 267 pm= Resource::loadPixmap( "folder" );
268 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 268 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
269 QPainter painter( &pm ); 269 QPainter painter( &pm );
270 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 270 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
271 pm.setMask( pm.createHeuristicMask( FALSE ) ); 271 pm.setMask( pm.createHeuristicMask( FALSE ) );
272 } 272 }
273 item->setPixmap( 0, pm); 273 item->setPixmap( 0, pm);
274 } 274 }
275 isDir=FALSE; 275 isDir=FALSE;
276 ++it; 276 ++it;
277 } 277 }
278 278
279 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 279 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
280 struct stat buf; 280 struct stat buf;
281 DIR *dir; 281 DIR *dir;
282 struct dirent *mydirent; 282 struct dirent *mydirent;
283 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 283 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
284 while ((mydirent = readdir(dir)) != NULL) { 284 while ((mydirent = readdir(dir)) != NULL) {
285 lstat( mydirent->d_name, &buf); 285 lstat( mydirent->d_name, &buf);
286 qDebug(mydirent->d_name); 286 qDebug(mydirent->d_name);
287 fileL.sprintf("%s", mydirent->d_name); 287 fileL.sprintf("%s", mydirent->d_name);
288 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 288 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
289 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 289 fileDate.sprintf("%s", ctime( &buf.st_mtime));
290 if( fileL.find(".") == -1 ){ 290 if( fileL.find(".") == -1 ){
291 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 291 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
292 pm = Resource::loadPixmap( "UnknownDocument-14" ); 292 pm = Resource::loadPixmap( "UnknownDocument-14" );
293 item->setPixmap( 0,pm); 293 item->setPixmap( 0,pm);
294 } 294 }
295 } 295 }
296 296
297 closedir(dir); 297 closedir(dir);
298 } 298 }
299 299
300 Remote_View->setSorting( 3,FALSE); 300 Remote_View->setSorting( 3,FALSE);
301 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 301 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
302} 302}
303 303
304void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 304void AdvancedFm::localListClicked(QListViewItem *selectedItem) {
305 if(selectedItem) { 305 if(selectedItem) {
306 QString strItem=selectedItem->text(0); 306 QString strItem=selectedItem->text(0);
307 QString strSize=selectedItem->text(1); 307 QString strSize=selectedItem->text(1);
308 strSize=strSize.stripWhiteSpace(); 308 strSize=strSize.stripWhiteSpace();
309 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 309 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
310 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 310 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
311 if(QDir(strItem2).exists() ) { 311 if(QDir(strItem2).exists() ) {
312 currentDir.cd(strItem2, TRUE); 312 currentDir.cd(strItem2, TRUE);
313 populateLocalView(); 313 populateLocalView();
314 314
315 } 315 }
316 } else { // not a symlink 316 } else { // not a symlink
317 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 317 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
318 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 318 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
319 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 319 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
320 currentDir.cd(strItem,FALSE); 320 currentDir.cd(strItem,FALSE);
321 populateLocalView(); 321 populateLocalView();
322 Local_View->ensureItemVisible(Local_View->firstChild()); 322 Local_View->ensureItemVisible(Local_View->firstChild());
323 323
324 } else { 324 } else {
325 currentDir.cdUp(); 325 currentDir.cdUp();
326 populateLocalView(); 326 populateLocalView();
327 Local_View->ensureItemVisible(Local_View->firstChild()); 327 Local_View->ensureItemVisible(Local_View->firstChild());
328 } 328 }
329 if(QDir(strItem).exists()){ 329 if(QDir(strItem).exists()){
330 currentDir.cd(strItem, TRUE); 330 currentDir.cd(strItem, TRUE);
331 Local_View->ensureItemVisible(Local_View->firstChild()); 331 Local_View->ensureItemVisible(Local_View->firstChild());
332 populateLocalView(); 332 populateLocalView();
333 } 333 }
334 } else { 334 } else {
335 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 335 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
336 if( QFile::exists(strItem ) ) { 336 if( QFile::exists(strItem ) ) {
337 // qDebug("clicked item "+strItem); 337 // qDebug("clicked item "+strItem);
338 // DocLnk doc( strItem, FALSE ); 338 // DocLnk doc( strItem, FALSE );
339 // doc.execute(); 339 // doc.execute();
340 // Local_View->clearSelection(); 340 // Local_View->clearSelection();
341 } 341 }
342 } //end not symlink 342 } //end not symlink
343 chdir(strItem.latin1()); 343 chdir(strItem.latin1());
344 } 344 }
345 345
346 } 346 }
347} 347}
348 348
349void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { 349void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
350 350
351 if(selectedItem) { 351 if(selectedItem) {
352 QString strItem=selectedItem->text(0); 352 QString strItem=selectedItem->text(0);
353 QString strSize=selectedItem->text(1); 353 QString strSize=selectedItem->text(1);
354 strSize=strSize.stripWhiteSpace(); 354 strSize=strSize.stripWhiteSpace();
355 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 355 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
356 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 356 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
357 currentRemoteDir.cd(strItem2, TRUE); 357 currentRemoteDir.cd(strItem2, TRUE);
358 populateRemoteView(); 358 populateRemoteView();
359 } else { // not a symlink 359 } else { // not a symlink
360 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 360 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
361 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { 361 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
362 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 362 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
363 currentRemoteDir.cd(strItem,FALSE); 363 currentRemoteDir.cd(strItem,FALSE);
364 populateRemoteView(); 364 populateRemoteView();
365 Remote_View->ensureItemVisible(Remote_View->firstChild()); 365 Remote_View->ensureItemVisible(Remote_View->firstChild());
366 } else { 366 } else {
367 currentRemoteDir.cdUp(); 367 currentRemoteDir.cdUp();
368 populateRemoteView(); 368 populateRemoteView();
369 Remote_View->ensureItemVisible(Remote_View->firstChild()); 369 Remote_View->ensureItemVisible(Remote_View->firstChild());
370 } 370 }
371 if(QDir(strItem).exists()){ 371 if(QDir(strItem).exists()){
372 currentRemoteDir.cd(strItem, TRUE); 372 currentRemoteDir.cd(strItem, TRUE);
373 populateRemoteView(); 373 populateRemoteView();
374 Remote_View->ensureItemVisible(Remote_View->firstChild()); 374 Remote_View->ensureItemVisible(Remote_View->firstChild());
375 } 375 }
376 } else { 376 } else {
377 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); 377 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
378 if( QFile::exists(strItem ) ) { 378 if( QFile::exists(strItem ) ) {
379 // qDebug("clicked item "+strItem); 379 // qDebug("clicked item "+strItem);
380 // DocLnk doc( strItem, FALSE ); 380 // DocLnk doc( strItem, FALSE );
381 // doc.execute(); 381 // doc.execute();
382 // Remote_View->clearSelection(); 382 // Remote_View->clearSelection();
383 } 383 }
384 } //end not symlink 384 } //end not symlink
385 chdir(strItem.latin1()); 385 chdir(strItem.latin1());
386 } 386 }
387 } 387 }
388} 388}
389 389
390 390
391void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 391void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
392// qDebug("list pressed"); 392// qDebug("list pressed");
393 switch (mouse) { 393 switch (mouse) {
394 case 1: 394 case 1:
395 break; 395 break;
396 case 2: 396 case 2:
397 menuTimer.start( 500, TRUE ); 397 menuTimer.start( 500, TRUE );
398 qDebug("Start menu timer\n"); 398 qDebug("Start menu timer\n");
399 break; 399 break;
400 }; 400 };
401} 401}
402 402
403void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 403void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) {
404 404
405 switch (mouse) { 405 switch (mouse) {
406 case 1: 406 case 1:
407 break; 407 break;
408 case 2: 408 case 2:
409 menuTimer.start( 500, TRUE ); 409 menuTimer.start( 500, TRUE );
410 qDebug("Start menu timer"); 410 qDebug("Start menu timer");
411 break; 411 break;
412 }; 412 };
413} 413}
414 414
415 415
416void AdvancedFm::switchToLocalTab() { 416void AdvancedFm::switchToLocalTab() {
417 TabWidget->setCurrentPage(0); 417 TabWidget->setCurrentPage(0);
418 Local_View->setFocus(); 418 Local_View->setFocus();
419} 419}
420 420
421void AdvancedFm::switchToRemoteTab() { 421void AdvancedFm::switchToRemoteTab() {
422 TabWidget->setCurrentPage(1); 422 TabWidget->setCurrentPage(1);
423 Remote_View->setFocus(); 423 Remote_View->setFocus();
424} 424}
425 425
426void AdvancedFm::readConfig() { 426void AdvancedFm::readConfig() {
427 Config cfg("AdvancedFm"); 427 Config cfg("AdvancedFm");
428} 428}
429 429
430void AdvancedFm::writeConfig() { 430void AdvancedFm::writeConfig() {
431 Config cfg("AdvancedFm"); 431 Config cfg("AdvancedFm");
432} 432}
433 433
434void AdvancedFm::currentPathComboChanged() { 434void AdvancedFm::currentPathComboChanged() {
435 if (TabWidget->currentPageIndex() == 0) { 435 if (TabWidget->currentPageIndex() == 0) {
436 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 436 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
437 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 437 currentDir.setPath( currentPathCombo->lineEdit()->text() );
438 populateLocalView(); 438 populateLocalView();
439 } else { 439 } else {
440 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 440 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
441 } 441 }
442 } 442 }
443 if (TabWidget->currentPageIndex() == 0) { 443 if (TabWidget->currentPageIndex() == 0) {
444 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 444 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
445 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); 445 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
446 populateRemoteView(); 446 populateRemoteView();
447 } else { 447 } else {
448 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 448 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
449 } 449 }
450 } 450 }
451} 451}
452 452
453void AdvancedFm::fillCombo(const QString &currentPath) { 453void AdvancedFm::fillCombo(const QString &currentPath) {
454 454
455 if (TabWidget->currentPageIndex() == 0) { 455 if (TabWidget->currentPageIndex() == 0) {
456 currentPathCombo->lineEdit()->setText( currentPath); 456 currentPathCombo->lineEdit()->setText( currentPath);
457 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 457 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
458 currentPathCombo->clear(); 458 currentPathCombo->clear();
459 localDirPathStringList.prepend( currentPath ); 459 localDirPathStringList.prepend( currentPath );
460 currentPathCombo->insertStringList( localDirPathStringList,-1); 460 currentPathCombo->insertStringList( localDirPathStringList,-1);
461 } 461 }
462 } else { 462 } else {
463 currentPathCombo->lineEdit()->setText( currentPath); 463 currentPathCombo->lineEdit()->setText( currentPath);
464 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 464 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
465 currentPathCombo->clear(); 465 currentPathCombo->clear();
466 remoteDirPathStringList.prepend( currentPath ); 466 remoteDirPathStringList.prepend( currentPath );
467 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 467 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
468 } 468 }
469 } 469 }
470} 470}
471 471
472void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 472void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
473 if (TabWidget->currentPageIndex() == 0) { 473 if (TabWidget->currentPageIndex() == 0) {
474 chdir( currentPath.latin1() ); 474 chdir( currentPath.latin1() );
475 currentDir.cd( currentPath, TRUE); 475 currentDir.cd( currentPath, TRUE);
476 populateLocalView(); 476 populateLocalView();
477 update(); 477 update();
478 } else { 478 } else {
479 chdir( currentPath.latin1() ); 479 chdir( currentPath.latin1() );
480 currentRemoteDir.cd( currentPath, TRUE); 480 currentRemoteDir.cd( currentPath, TRUE);
481 populateRemoteView(); 481 populateRemoteView();
482 update(); 482 update();
483 } 483 }
484} 484}
485 485
486QStringList AdvancedFm::getPath() { 486QStringList AdvancedFm::getPath() {
487 QStringList strList; 487 QStringList strList;
488 if (TabWidget->currentPageIndex() == 0) { 488 if (TabWidget->currentPageIndex() == 0) {
489 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 489 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
490 QListViewItemIterator it( Local_View ); 490 QListViewItemIterator it( Local_View );
491 for ( ; it.current(); ++it ) { 491 for ( ; it.current(); ++it ) {
492 if ( it.current()->isSelected() ) { 492 if ( it.current()->isSelected() ) {
493 strList << it.current()->text(0); 493 strList << it.current()->text(0);
494 qDebug(it.current()->text(0)); 494 qDebug(it.current()->text(0));
495 } 495 }
496 } 496 }
497 return strList; 497 return strList;
498 } else { 498 } else {
499 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 499 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
500 QListViewItemIterator it( Remote_View ); 500 QListViewItemIterator it( Remote_View );
501 for ( ; it.current(); ++it ) { 501 for ( ; it.current(); ++it ) {
502 if ( it.current()->isSelected() ) { 502 if ( it.current()->isSelected() ) {
503 strList << it.current()->text(0); 503 strList << it.current()->text(0);
504 qDebug(it.current()->text(0)); 504 qDebug(it.current()->text(0));
505 } 505 }
506 } 506 }
507 return strList; 507 return strList;
508 } 508 }
509 return ""; 509 return "";
510} 510}
511 511
512void AdvancedFm::homeButtonPushed() { 512void AdvancedFm::homeButtonPushed() {
513 QString current = QDir::homeDirPath(); 513 QString current = QDir::homeDirPath();
514 chdir( current.latin1() ); 514 chdir( current.latin1() );
515 if (TabWidget->currentPageIndex() == 0) { 515 if (TabWidget->currentPageIndex() == 0) {
516 currentDir.cd( current, TRUE); 516 currentDir.cd( current, TRUE);
517 populateLocalView(); 517 populateLocalView();
518 } else { 518 } else {
519 currentRemoteDir.cd( current, TRUE); 519 currentRemoteDir.cd( current, TRUE);
520 populateRemoteView(); 520 populateRemoteView();
521 } 521 }
522 update(); 522 update();
523} 523}
524 524
525void AdvancedFm::docButtonPushed() { 525void AdvancedFm::docButtonPushed() {
526 QString current = QPEApplication::documentDir(); 526 QString current = QPEApplication::documentDir();
527 chdir( current.latin1() ); 527 chdir( current.latin1() );
528 if (TabWidget->currentPageIndex() == 0) { 528 if (TabWidget->currentPageIndex() == 0) {
529 currentDir.cd( current, TRUE); 529 currentDir.cd( current, TRUE);
530 populateLocalView(); 530 populateLocalView();
531 } else { 531 } else {
532 currentRemoteDir.cd( current, TRUE); 532 currentRemoteDir.cd( current, TRUE);
533 populateRemoteView(); 533 populateRemoteView();
534 } 534 }
535 update(); 535 update();
536} 536}
537 537
538void AdvancedFm::SDButtonPushed() { 538void AdvancedFm::SDButtonPushed() {
539 QString current = "/mnt/card";// this can change so fix 539 QString current = "/mnt/card";// this can change so fix
540 chdir( current.latin1() ); 540 chdir( current.latin1() );
541 if (TabWidget->currentPageIndex() == 0) { 541 if (TabWidget->currentPageIndex() == 0) {
542 currentDir.cd( current, TRUE); 542 currentDir.cd( current, TRUE);
543 populateLocalView(); 543 populateLocalView();
544 } else { 544 } else {
545 currentRemoteDir.cd( current, TRUE); 545 currentRemoteDir.cd( current, TRUE);
546 populateRemoteView(); 546 populateRemoteView();
547 } 547 }
548 update(); 548 update();
549 549
550} 550}
551 551
552void AdvancedFm::CFButtonPushed() { 552void AdvancedFm::CFButtonPushed() {
553 QString current; 553 QString current;
554 if(zaurusDevice) 554 if(zaurusDevice)
555 current= "/mnt/cf"; //zaurus 555 current= "/mnt/cf"; //zaurus
556 else 556 else
557 current = "/mnt/hda"; //ipaq 557 current = "/mnt/hda"; //ipaq
558 558
559 chdir( current.latin1() ); 559 chdir( current.latin1() );
560 if (TabWidget->currentPageIndex() == 0) { 560 if (TabWidget->currentPageIndex() == 0) {
561 currentDir.cd( current, TRUE); 561 currentDir.cd( current, TRUE);
562 populateLocalView(); 562 populateLocalView();
563 } else { 563 } else {
564 currentRemoteDir.cd( current, TRUE); 564 currentRemoteDir.cd( current, TRUE);
565 populateRemoteView(); 565 populateRemoteView();
566 } 566 }
567 update(); 567 update();
568} 568}
569 569
570 570
571 571
572void AdvancedFm::doAbout() { 572void AdvancedFm::doAbout() {
573 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 573 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
574 "is copyright 2002 by\n" 574 "is copyright 2002 by\n"
575 "L.J.Potter<llornkcor@handhelds.org>\n" 575 "L.J.Potter<llornkcor@handhelds.org>\n"
576 "and is licensed by the GPL")); 576 "and is licensed by the GPL"));
577} 577}
578 578
579void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 579void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
580 if( TabWidget->hasFocus()) 580 if( TabWidget->hasFocus())
581 switch ( e->key() ) { 581 switch ( e->key() ) {
582 case Key_Delete: 582 case Key_Delete:
583 del(); 583 del();
584 break; 584 break;
585 case Key_H: 585 case Key_H:
586 showHidden(); 586 showHidden();
587 break; 587 break;
588 case Key_E: 588 case Key_E:
589 runThis(); 589 runThis();
590 break; 590 break;
591 case Key_C: 591 case Key_C:
592 copy(); 592 copy();
593 break; 593 break;
594 case Key_A: 594 case Key_A:
595 copyAs(); 595 copyAs();
596 break; 596 break;
597 case Key_M: 597 case Key_M:
598 move(); 598 move();
599 break; 599 break;
600 case Key_R: 600 case Key_R:
601 rn(); 601 rn();
602 break; 602 break;
603 case Key_I: 603 case Key_I:
604 fileStatus(); 604 fileStatus();
605 break; 605 break;
606 case Key_U: 606 case Key_U:
607 upDir(); 607 upDir();
608 break; 608 break;
609 case Key_P: 609 case Key_P:
610 filePerms(); 610 filePerms();
611 break; 611 break;
612 case Key_N: 612 case Key_N:
613 mkDir(); 613 mkDir();
614 break; 614 break;
615 case Key_1: 615 case Key_1:
616 switchToLocalTab(); 616 switchToLocalTab();
617 break; 617 break;
618 case Key_2: 618 case Key_2:
619 switchToRemoteTab(); 619 switchToRemoteTab();
620 break; 620 break;
621 case Key_3: 621 case Key_3:
622 CFButtonPushed(); 622 CFButtonPushed();
623 break; 623 break;
624 case Key_4: 624 case Key_4:
625 SDButtonPushed(); 625 SDButtonPushed();
626 break; 626 break;
627 case Key_5: 627 case Key_5:
628 homeButtonPushed(); 628 homeButtonPushed();
629 break; 629 break;
630 case Key_6: 630 case Key_6:
631 docButtonPushed(); 631 docButtonPushed();
632 break; 632 break;
633 case Key_7: 633 case Key_7:
634 break; 634 break;
635 case Key_8: 635 case Key_8:
636 break; 636 break;
637 case Key_9: 637 case Key_9:
638 break; 638 break;
639 case Key_0: 639 case Key_0:
640 break; 640 break;
641 } 641 }
642} 642}
643 643
644 644
645void AdvancedFm::QPEButtonPushed() { 645void AdvancedFm::QPEButtonPushed() {
646 QString current = QPEApplication::qpeDir(); 646 QString current = QPEApplication::qpeDir();
647 chdir( current.latin1() ); 647 chdir( current.latin1() );
648 if (TabWidget->currentPageIndex() == 0) { 648 if (TabWidget->currentPageIndex() == 0) {
649 currentDir.cd( current, TRUE); 649 currentDir.cd( current, TRUE);
650 populateLocalView(); 650 populateLocalView();
651 } else { 651 } else {
652 currentRemoteDir.cd( current, TRUE); 652 currentRemoteDir.cd( current, TRUE);
653 populateRemoteView(); 653 populateRemoteView();
654 } 654 }
655 update(); 655 update();
656} 656}
657 657
658void AdvancedFm::parsetab(const QString &fileName) { 658void AdvancedFm::parsetab(const QString &fileName) {
659 659
660 fileSystemTypeList.clear(); 660 fileSystemTypeList.clear();
661 fsList.clear(); 661 fsList.clear();
662 struct mntent *me; 662 struct mntent *me;
663 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 663 FILE *mntfp = setmntent( fileName.latin1(), "r" );
664 if ( mntfp ) { 664 if ( mntfp ) {
665 while ( (me = getmntent( mntfp )) != 0 ) { 665 while ( (me = getmntent( mntfp )) != 0 ) {
666 QString deviceName = me->mnt_fsname; 666 QString deviceName = me->mnt_fsname;
667 QString filesystemType = me->mnt_type; 667 QString filesystemType = me->mnt_type;
668 QString mountDir = me->mnt_dir; 668 QString mountDir = me->mnt_dir;
669 if(deviceName != "none") { 669 if(deviceName != "none") {
670 if( fsList.contains(filesystemType) == 0 670 if( fsList.contains(filesystemType) == 0
671 & filesystemType.find("proc",0,TRUE) == -1 671 & filesystemType.find("proc",0,TRUE) == -1
672 & filesystemType.find("cramfs",0,TRUE) == -1 672 & filesystemType.find("cramfs",0,TRUE) == -1
673 & filesystemType.find("auto",0,TRUE) == -1) 673 & filesystemType.find("auto",0,TRUE) == -1)
674 fsList << filesystemType; 674 fsList << filesystemType;
675 fileSystemTypeList << mountDir+"::"+filesystemType; 675 fileSystemTypeList << mountDir+"::"+filesystemType;
676 } 676 }
677 } 677 }
678 } 678 }
679 endmntent( mntfp ); 679 endmntent( mntfp );
680} 680}
681 681
682QString AdvancedFm::getFileSystemType(const QString &currentText) { 682QString AdvancedFm::getFileSystemType(const QString &currentText) {
683 parsetab("/etc/mtab"); //why did TT forget filesystem type? 683 parsetab("/etc/mtab"); //why did TT forget filesystem type?
684 QString current = currentText;//.right( currentText.length()-1); 684 QString current = currentText;//.right( currentText.length()-1);
685 QString baseFs; 685 QString baseFs;
686 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 686 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
687 QString temp = (*it); 687 QString temp = (*it);
688 QString path = temp.left(temp.find("::",0,TRUE) ); 688 QString path = temp.left(temp.find("::",0,TRUE) );
689 path = path.right( path.length()-1); 689 path = path.right( path.length()-1);
690 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 690 if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
691 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { 691 if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
692 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 692 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
693 } 693 }
694 } 694 }
695 return baseFs; 695 return baseFs;
696} 696}
697 697
698QString AdvancedFm::getDiskSpace( const QString &path) { 698QString AdvancedFm::getDiskSpace( const QString &path) {
699 struct statfs fss; 699 struct statfs fss;
700 if ( !statfs( path.latin1(), &fss ) ) { 700 if ( !statfs( path.latin1(), &fss ) ) {
701 int blkSize = fss.f_bsize; 701 int blkSize = fss.f_bsize;
702 // int totalBlks = fs.f_blocks; 702 // int totalBlks = fs.f_blocks;
703 int availBlks = fss.f_bavail; 703 int availBlks = fss.f_bavail;
704 704
705 long mult = blkSize / 1024; 705 long mult = blkSize / 1024;
706 long div = 1024 / blkSize; 706 long div = 1024 / blkSize;
707 if ( !mult ) mult = 1; 707 if ( !mult ) mult = 1;
708 if ( !div ) div = 1; 708 if ( !div ) div = 1;
709 709
710 return QString::number(availBlks * mult / div); 710 return QString::number(availBlks * mult / div);
711 } 711 }
712 return ""; 712 return "";
713} 713}
714 714
715 715
716void AdvancedFm::showFileMenu() { 716void AdvancedFm::showFileMenu() {
717 717
718 QString curApp; 718 QString curApp;
719 bool isLocalView = false; 719 bool isLocalView = false;
720 if (TabWidget->currentPageIndex() == 0) { 720 if (TabWidget->currentPageIndex() == 0) {
721 isLocalView = TRUE; 721 isLocalView = TRUE;
722 curApp = Local_View->currentItem()->text(0); 722 curApp = Local_View->currentItem()->text(0);
723 } else { 723 } else {
724 curApp = Remote_View->currentItem()->text(0); 724 curApp = Remote_View->currentItem()->text(0);
725 } 725 }
726 726
727 MimeType mt( curApp ); 727 MimeType mt( curApp );
728
729 const AppLnk* app = mt.application(); 728 const AppLnk* app = mt.application();
730
731 QFile fi(curApp); 729 QFile fi(curApp);
732
733 QPopupMenu *m = new QPopupMenu(0); 730 QPopupMenu *m = new QPopupMenu(0);
734 QPopupMenu *n = new QPopupMenu(0); 731 QPopupMenu *n = new QPopupMenu(0);
735 // QPopupMenu *o = new QPopupMenu(0); 732 // QPopupMenu *o = new QPopupMenu(0);
736 733 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() ));
737 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
738 734
739 if ( QFileInfo(fi).isDir() ) { 735 if ( QFileInfo(fi).isDir() ) {
740 m->insertSeparator(); 736 m->insertSeparator();
741 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 737 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
742 } else { 738 } else {
743 739
744 if ( app ) 740 if ( app )
745 m->insertItem( app->pixmap(), tr( "Open in " 741 m->insertItem( app->pixmap(), tr( "Open in "
746 + app->name() ), this, SLOT( runThis() ) ); 742 + app->name() ), this, SLOT( runThis() ) );
747 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 743 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
748 m->insertItem( /*Resource::loadPixmap( app->name()),*/ tr( "Execute" ), this, SLOT( runThis() ) ); 744 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
749
750 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 745 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
751 } 746 }
752 747
753 m->insertItem(tr("Actions"),n); 748 m->insertItem(tr("Actions"),n);
754 if(isLocalView) 749 if(isLocalView)
755 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 750 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
756 else 751 else
757 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 752 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
758 753
759 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 754 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
760 755
761 n->insertSeparator(); 756 n->insertSeparator();
762 757
763 758
764 if(isLocalView) 759 if(isLocalView)
765 n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 760 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
766 else 761 else
767 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 762 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
768 763
769 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 764 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
770 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 765 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
771 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 766 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
772 n->insertItem( tr( "Move" ), this, SLOT( move() )); 767 n->insertItem( tr( "Move" ), this, SLOT( move() ));
773 768
774 n->insertSeparator(); 769 n->insertSeparator();
775 770
776 if(isLocalView) 771 if(isLocalView)
777 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 772 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
778 else 773 else
779 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 774 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
780 775
781 776
782 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 777 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
783 778
784 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 779 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
785 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 780 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
786 781
787 m->insertSeparator(); 782 m->insertSeparator();
788 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 783 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
789 784
790#if defined(QT_QWS_OPIE) 785#if defined(QT_QWS_OPIE)
791 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 786 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
792#endif 787#endif
793 m->setCheckable(TRUE); 788 m->setCheckable(TRUE);
794 if (!b) 789 if (!b)
795 m->setItemChecked(m->idAt(0),TRUE); 790 m->setItemChecked(m->idAt(0),TRUE);
796 else 791 else
797 m->setItemChecked(m->idAt(0),FALSE); 792 m->setItemChecked(m->idAt(0),FALSE);
798 793
799 if(Ir::supported()) 794 if(Ir::supported())
800 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 795 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
801 m->setFocus(); 796 m->setFocus();
802 m->exec( QCursor::pos() ); 797 m->exec( QCursor::pos() );
803 sleep(1); 798 sleep(1);
804 if(m) delete m; 799 if(m) delete m;
805} 800}
806 801
807 802
808void AdvancedFm::cancelMenuTimer() { 803void AdvancedFm::cancelMenuTimer() {
809 804
810// qDebug("selectionChanged: cancel menu timer"); 805// qDebug("selectionChanged: cancel menu timer");
811 if( menuTimer.isActive() ) 806 if( menuTimer.isActive() )
812 menuTimer.stop(); 807 menuTimer.stop();
813} 808}
814 809
815QString AdvancedFm::checkDiskSpace(const QString &path) { 810QString AdvancedFm::checkDiskSpace(const QString &path) {
816 struct statfs fss; 811 struct statfs fss;
817 if ( !statfs( path.latin1(), &fss ) ) { 812 if ( !statfs( path.latin1(), &fss ) ) {
818 int blkSize = fss.f_bsize; 813 int blkSize = fss.f_bsize;
819// int totalBlks = fs.f_blocks; 814// int totalBlks = fs.f_blocks;
820 int availBlks = fss.f_bavail; 815 int availBlks = fss.f_bavail;
821 816
822 long mult = blkSize / 1024; 817 long mult = blkSize / 1024;
823 long div = 1024 / blkSize; 818 long div = 1024 / blkSize;
824 if ( !mult ) mult = 1; 819 if ( !mult ) mult = 1;
825 if ( !div ) div = 1; 820 if ( !div ) div = 1;
826 821
827 822
828 return QString::number(availBlks * mult / div); 823 return QString::number(availBlks * mult / div);
829 } 824 }
830 return ""; 825 return "";
831} 826}
832 827
833void AdvancedFm::addToDocs() { 828void AdvancedFm::addToDocs() {
834 QStringList strListPaths = getPath(); 829 QStringList strListPaths = getPath();
835 if( strListPaths.count() > 0) { 830 if( strListPaths.count() > 0) {
836 QString curFile; 831 QString curFile;
837 if (TabWidget->currentPageIndex() == 0) { 832 if (TabWidget->currentPageIndex() == 0) {
838 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 833 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
839 curFile = currentDir.canonicalPath()+"/"+(*it); 834 curFile = currentDir.canonicalPath()+"/"+(*it);
840 qDebug(curFile); 835 qDebug(curFile);
841 DocLnk f; 836 DocLnk f;
842// curFile.replace(QRegExp("\\..*"),""); 837// curFile.replace(QRegExp("\\..*"),"");
843 f.setName((*it)); 838 f.setName((*it));
844 f.setFile( curFile); 839 f.setFile( curFile);
845 f.writeLink(); 840 f.writeLink();
846 } 841 }
847 } else { 842 } else {
848 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 843 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
849 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 844 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
850 qDebug(curFile); 845 qDebug(curFile);
851 846
852 DocLnk f; 847 DocLnk f;
853// curFile.replace(QRegExp("\\..*"),""); 848// curFile.replace(QRegExp("\\..*"),"");
854 f.setName((*it)); 849 f.setName((*it));
855 f.setFile( curFile); 850 f.setFile( curFile);
856 f.writeLink(); 851 f.writeLink();
857 } 852 }
858 } 853 }
859 } 854 }
860} 855}
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 6d37904..5fa8d0c 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,946 +1,948 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13#include "inputDialog.h" 13#include "inputDialog.h"
14#include "output.h" 14#include "output.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17#include <qpe/lnkproperties.h> 17#include <qpe/lnkproperties.h>
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25 25
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qmultilineedit.h> 27#include <qmultilineedit.h>
28 28
29#include <qstring.h> 29#include <qstring.h>
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtabwidget.h> 35#include <qtabwidget.h>
36#include <qtoolbutton.h> 36#include <qtoolbutton.h>
37#include <qtabwidget.h> 37#include <qtabwidget.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qlistview.h> 39#include <qlistview.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <sys/stat.h> 43#include <sys/stat.h>
44#include <dirent.h> 44#include <dirent.h>
45 45
46 46
47void AdvancedFm::doLocalCd() { 47void AdvancedFm::doLocalCd() {
48 localListClicked( Local_View->currentItem()); 48 localListClicked( Local_View->currentItem());
49} 49}
50 50
51void AdvancedFm::doRemoteCd() { 51void AdvancedFm::doRemoteCd() {
52 localListClicked( Remote_View->currentItem()); 52 localListClicked( Remote_View->currentItem());
53} 53}
54 54
55void AdvancedFm::showMenuHidden() { 55void AdvancedFm::showMenuHidden() {
56 showHidden(); 56 if(TabWidget->currentPageIndex() == 0)
57 if(b) b= false; else b=true; 57 showHidden();
58 showRemoteHidden(); 58 else
59 showRemoteHidden();
60// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
61 if(b) b = false; else b = true;
59} 62}
60 63
61void AdvancedFm::showHidden() { 64void AdvancedFm::showHidden() {
62 if (b) { 65 if (b) {
63 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 66 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
64 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 67 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
65 b=FALSE; 68// b=FALSE;
66 69
67 } else { 70 } else {
68 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 71 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 72 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
70 b=TRUE; 73// b=TRUE;
71 } 74 }
72 populateLocalView(); 75 populateLocalView();
73
74} 76}
75 77
76void AdvancedFm::showRemoteHidden() { 78void AdvancedFm::showRemoteHidden() {
77 if (b) { 79 if (b) {
78 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 80 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
79 b=TRUE; 81// b=TRUE;
80 82
81 } else { 83 } else {
82 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 84 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
83 b=FALSE; 85// b=FALSE;
84 } 86 }
85 populateRemoteView(); 87 populateRemoteView();
86} 88}
87 89
88void AdvancedFm::runThis() { 90void AdvancedFm::runThis() {
89 QString fs; 91 QString fs;
90 if (TabWidget->currentPageIndex() == 0) { 92 if (TabWidget->currentPageIndex() == 0) {
91 QString curFile = Local_View->currentItem()->text(0); 93 QString curFile = Local_View->currentItem()->text(0);
92 if(curFile != "../") { 94 if(curFile != "../") {
93 95
94 fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 96 fs= getFileSystemType((const QString &) currentDir.canonicalPath());
95 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 97 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
96 qDebug( fileInfo.owner()); 98 qDebug( fileInfo.owner());
97 if( (fileInfo.permission( QFileInfo::ExeUser) 99 if( (fileInfo.permission( QFileInfo::ExeUser)
98 | fileInfo.permission( QFileInfo::ExeGroup) 100 | fileInfo.permission( QFileInfo::ExeGroup)
99 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 101 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
100 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 102 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
101 QCopEnvelope e("QPE/System", "execute(QString)" ); 103 QCopEnvelope e("QPE/System", "execute(QString)" );
102 e << curFile; 104 e << curFile;
103 } else { 105 } else {
104 curFile = currentDir.canonicalPath()+"/"+curFile; 106 curFile = currentDir.canonicalPath()+"/"+curFile;
105 DocLnk nf(curFile); 107 DocLnk nf(curFile);
106 QString execStr = nf.exec(); 108 QString execStr = nf.exec();
107 qDebug( execStr); 109 qDebug( execStr);
108 if( execStr.isEmpty() ) { 110 if( execStr.isEmpty() ) {
109 } else { 111 } else {
110 nf.execute(); 112 nf.execute();
111 } 113 }
112 } 114 }
113 } 115 }
114 } else { 116 } else {
115 QString curFile = Remote_View->currentItem()->text(0); 117 QString curFile = Remote_View->currentItem()->text(0);
116 if(curFile != "../") { 118 if(curFile != "../") {
117 119
118 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); 120 fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
119 qDebug("Filesystemtype is "+fs); 121 qDebug("Filesystemtype is "+fs);
120 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); 122 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
121 if( (fileInfo.permission( QFileInfo::ExeUser) 123 if( (fileInfo.permission( QFileInfo::ExeUser)
122 | fileInfo.permission( QFileInfo::ExeGroup) 124 | fileInfo.permission( QFileInfo::ExeGroup)
123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 125 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 126 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
125 QCopEnvelope e("QPE/System", "execute(QString)" ); 127 QCopEnvelope e("QPE/System", "execute(QString)" );
126 e << curFile; 128 e << curFile;
127 } else { 129 } else {
128 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 130 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
129 DocLnk nf(curFile); 131 DocLnk nf(curFile);
130 QString execStr = nf.exec(); 132 QString execStr = nf.exec();
131 qDebug(execStr); 133 qDebug(execStr);
132 if( execStr.isEmpty() ) { 134 if( execStr.isEmpty() ) {
133 } else { 135 } else {
134 nf.execute(); 136 nf.execute();
135 } 137 }
136 } 138 }
137 } 139 }
138 } 140 }
139} 141}
140 142
141void AdvancedFm::runText() { 143void AdvancedFm::runText() {
142 if (TabWidget->currentPageIndex() == 0) { 144 if (TabWidget->currentPageIndex() == 0) {
143 QString curFile = Local_View->currentItem()->text(0); 145 QString curFile = Local_View->currentItem()->text(0);
144 if(curFile != "../") { 146 if(curFile != "../") {
145 curFile = currentDir.canonicalPath()+"/"+curFile; 147 curFile = currentDir.canonicalPath()+"/"+curFile;
146 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 148 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
147 e << curFile; 149 e << curFile;
148 } 150 }
149 } else { 151 } else {
150 QString curFile = Remote_View->currentItem()->text(0); 152 QString curFile = Remote_View->currentItem()->text(0);
151 if(curFile != "../") { 153 if(curFile != "../") {
152 curFile = currentRemoteDir.canonicalPath()+"/"+curFile; 154 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
153 DocLnk nf(curFile); 155 DocLnk nf(curFile);
154 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 156 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
155 e << curFile; 157 e << curFile;
156 } 158 }
157 } 159 }
158} 160}
159 161
160void AdvancedFm::localMakDir() { 162void AdvancedFm::localMakDir() {
161 InputDialog *fileDlg; 163 InputDialog *fileDlg;
162 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 164 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
163 fileDlg->exec(); 165 fileDlg->exec();
164 if( fileDlg->result() == 1 ) { 166 if( fileDlg->result() == 1 ) {
165 QString filename = fileDlg->LineEdit1->text(); 167 QString filename = fileDlg->LineEdit1->text();
166 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 168 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
167 } 169 }
168 populateLocalView(); 170 populateLocalView();
169} 171}
170 172
171void AdvancedFm::remoteMakDir() { 173void AdvancedFm::remoteMakDir() {
172 InputDialog *fileDlg; 174 InputDialog *fileDlg;
173 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 175 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
174 fileDlg->exec(); 176 fileDlg->exec();
175 if( fileDlg->result() == 1 ) { 177 if( fileDlg->result() == 1 ) {
176 QString filename = fileDlg->LineEdit1->text(); 178 QString filename = fileDlg->LineEdit1->text();
177 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); 179 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
178 } 180 }
179 populateRemoteView(); 181 populateRemoteView();
180} 182}
181 183
182void AdvancedFm::localDelete() { 184void AdvancedFm::localDelete() {
183 QStringList curFileList = getPath(); 185 QStringList curFileList = getPath();
184 if(curFileList.count() > 0) { 186 if(curFileList.count() > 0) {
185 QString myFile; 187 QString myFile;
186 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 188 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
187 myFile = (*it); 189 myFile = (*it);
188 if( myFile.find(" -> ",0,TRUE) != -1) 190 if( myFile.find(" -> ",0,TRUE) != -1)
189 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 191 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
190 192
191 QString f = currentDir.canonicalPath(); 193 QString f = currentDir.canonicalPath();
192 if(f.right(1).find("/",0,TRUE) == -1) 194 if(f.right(1).find("/",0,TRUE) == -1)
193 f+="/"; 195 f+="/";
194 f+=myFile; 196 f+=myFile;
195 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 197 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
196 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 198 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
197 "\nand all it's contents ?" 199 "\nand all it's contents ?"
198 ,tr("Yes"),tr("No"),0,0,1) ) { 200 ,tr("Yes"),tr("No"),0,0,1) ) {
199 case 0: { 201 case 0: {
200 f=f.left(f.length()-1); 202 f=f.left(f.length()-1);
201 QString cmd="rm -rf "+f; 203 QString cmd="rm -rf "+f;
202 system( cmd.latin1()); 204 system( cmd.latin1());
203 populateLocalView(); 205 populateLocalView();
204 } 206 }
205 break; 207 break;
206 case 1: 208 case 1:
207 // exit 209 // exit
208 break; 210 break;
209 }; 211 };
210 212
211 } else { 213 } else {
212 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 214 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
213 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 215 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
214 case 0: { 216 case 0: {
215 QString cmd="rm "+f; 217 QString cmd="rm "+f;
216 QFile file(f); 218 QFile file(f);
217 file.remove(); 219 file.remove();
218 // system( cmd.latin1()); 220 // system( cmd.latin1());
219 populateLocalView(); 221 populateLocalView();
220 } 222 }
221 break; 223 break;
222 case 1: 224 case 1:
223 // exit 225 // exit
224 break; 226 break;
225 }; 227 };
226 } 228 }
227 } 229 }
228 } 230 }
229} 231}
230 232
231void AdvancedFm::remoteDelete() { 233void AdvancedFm::remoteDelete() {
232 QStringList curFileList = getPath(); 234 QStringList curFileList = getPath();
233 if( curFileList.count() > 0) { 235 if( curFileList.count() > 0) {
234 QString myFile; 236 QString myFile;
235 237
236 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 238 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
237 myFile = (*it); 239 myFile = (*it);
238 if(myFile.find(" -> ",0,TRUE) != -1) 240 if(myFile.find(" -> ",0,TRUE) != -1)
239 myFile = myFile.left(myFile.find(" -> ",0,TRUE)); 241 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
240 QString f = currentRemoteDir.canonicalPath(); 242 QString f = currentRemoteDir.canonicalPath();
241 if(f.right(1).find("/",0,TRUE) == -1) 243 if(f.right(1).find("/",0,TRUE) == -1)
242 f+="/"; 244 f+="/";
243 f+=myFile; 245 f+=myFile;
244 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 246 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
245 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 247 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
246 "\nand all it's contents ?", 248 "\nand all it's contents ?",
247 tr("Yes"),tr("No"),0,0,1) ) { 249 tr("Yes"),tr("No"),0,0,1) ) {
248 case 0: { 250 case 0: {
249 f=f.left(f.length()-1); 251 f=f.left(f.length()-1);
250 QString cmd="rm -rf "+f; 252 QString cmd="rm -rf "+f;
251 system( cmd.latin1()); 253 system( cmd.latin1());
252 populateRemoteView(); 254 populateRemoteView();
253 } 255 }
254 break; 256 break;
255 case 1: 257 case 1:
256 // exit 258 // exit
257 break; 259 break;
258 }; 260 };
259 261
260 } else { 262 } else {
261 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 263 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
262 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 264 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
263 case 0: { 265 case 0: {
264 QString cmd="rm "+f; 266 QString cmd="rm "+f;
265 QFile file(f); 267 QFile file(f);
266 file.remove(); 268 file.remove();
267 // system( cmd.latin1()); 269 // system( cmd.latin1());
268 populateRemoteView(); 270 populateRemoteView();
269 } 271 }
270 break; 272 break;
271 case 1: 273 case 1:
272 // exit 274 // exit
273 break; 275 break;
274 }; 276 };
275 } 277 }
276 } 278 }
277 } 279 }
278} 280}
279 281
280void AdvancedFm::localRename() { 282void AdvancedFm::localRename() {
281 QString curFile = Local_View->currentItem()->text(0); 283 QString curFile = Local_View->currentItem()->text(0);
282 qDebug("currentItem "+curFile); 284 qDebug("currentItem "+curFile);
283 if( curFile !="../") { 285 if( curFile !="../") {
284 InputDialog *fileDlg; 286 InputDialog *fileDlg;
285 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 287 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
286 fileDlg->setInputText((const QString &)curFile); 288 fileDlg->setInputText((const QString &)curFile);
287 fileDlg->exec(); 289 fileDlg->exec();
288 if( fileDlg->result() == 1 ) { 290 if( fileDlg->result() == 1 ) {
289 QString oldname = currentDir.canonicalPath() + "/" + curFile; 291 QString oldname = currentDir.canonicalPath() + "/" + curFile;
290 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 292 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
291//+".playlist"; 293//+".playlist";
292 if( rename(oldname.latin1(), newName.latin1())== -1) 294 if( rename(oldname.latin1(), newName.latin1())== -1)
293 QMessageBox::message(tr("Note"),tr("Could not rename")); 295 QMessageBox::message(tr("Note"),tr("Could not rename"));
294 } 296 }
295 populateLocalView(); 297 populateLocalView();
296 } 298 }
297} 299}
298 300
299void AdvancedFm::remoteRename() 301void AdvancedFm::remoteRename()
300{ 302{
301 QString curFile = Remote_View->currentItem()->text(0); 303 QString curFile = Remote_View->currentItem()->text(0);
302 if( curFile !="../") { 304 if( curFile !="../") {
303 InputDialog *fileDlg; 305 InputDialog *fileDlg;
304 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 306 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
305 fileDlg->setInputText((const QString &)curFile); 307 fileDlg->setInputText((const QString &)curFile);
306 fileDlg->exec(); 308 fileDlg->exec();
307 if( fileDlg->result() == 1 ) { 309 if( fileDlg->result() == 1 ) {
308 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; 310 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
309 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); 311 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
310//+".playlist"; 312//+".playlist";
311 if( rename(oldname.latin1(), newName.latin1())== -1) 313 if( rename(oldname.latin1(), newName.latin1())== -1)
312 QMessageBox::message(tr("Note"),tr("Could not rename")); 314 QMessageBox::message(tr("Note"),tr("Could not rename"));
313 } 315 }
314 populateRemoteView(); 316 populateRemoteView();
315 } 317 }
316} 318}
317 319
318 320
319void AdvancedFm::filePerms() { 321void AdvancedFm::filePerms() {
320 322
321 QStringList curFileList = getPath(); 323 QStringList curFileList = getPath();
322 QString filePath; 324 QString filePath;
323 325
324 if (TabWidget->currentPageIndex() == 0) { 326 if (TabWidget->currentPageIndex() == 0) {
325 filePath = currentDir.canonicalPath()+"/"; 327 filePath = currentDir.canonicalPath()+"/";
326 } else { 328 } else {
327 filePath= currentRemoteDir.canonicalPath()+"/"; 329 filePath= currentRemoteDir.canonicalPath()+"/";
328 } 330 }
329 331
330 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 332 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
331 filePermissions *filePerm; 333 filePermissions *filePerm;
332 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 334 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
333 filePerm->showMaximized(); 335 filePerm->showMaximized();
334 filePerm->exec(); 336 filePerm->exec();
335 if( filePerm) 337 if( filePerm)
336 delete filePerm; 338 delete filePerm;
337 } 339 }
338 if (TabWidget->currentPageIndex() == 0) { 340 if (TabWidget->currentPageIndex() == 0) {
339 populateLocalView(); 341 populateLocalView();
340 } else { 342 } else {
341 populateRemoteView(); 343 populateRemoteView();
342 } 344 }
343} 345}
344 346
345void AdvancedFm::doProperties() { 347void AdvancedFm::doProperties() {
346#if defined(QT_QWS_OPIE) 348#if defined(QT_QWS_OPIE)
347 349
348 QStringList curFileList = getPath(); 350 QStringList curFileList = getPath();
349 351
350 QString filePath; 352 QString filePath;
351 if (TabWidget->currentPageIndex() == 0) { 353 if (TabWidget->currentPageIndex() == 0) {
352 filePath = currentDir.canonicalPath()+"/"; 354 filePath = currentDir.canonicalPath()+"/";
353 } else { 355 } else {
354 filePath= currentRemoteDir.canonicalPath()+"/"; 356 filePath= currentRemoteDir.canonicalPath()+"/";
355 } 357 }
356 qDebug("%d",curFileList.count()); 358 qDebug("%d",curFileList.count());
357 359
358 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 360 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
359 qDebug((filePath+*it)); 361 qDebug((filePath+*it));
360 DocLnk lnk( (filePath+*it)); 362 DocLnk lnk( (filePath+*it));
361 LnkProperties prop( &lnk ); 363 LnkProperties prop( &lnk );
362 prop.showMaximized(); 364 prop.showMaximized();
363 prop.exec(); 365 prop.exec();
364 } 366 }
365#endif 367#endif
366 368
367} 369}
368 370
369void AdvancedFm::upDir() { 371void AdvancedFm::upDir() {
370 if (TabWidget->currentPageIndex() == 0) { 372 if (TabWidget->currentPageIndex() == 0) {
371 QString current = currentDir.canonicalPath(); 373 QString current = currentDir.canonicalPath();
372 QDir dir(current); 374 QDir dir(current);
373 dir.cdUp(); 375 dir.cdUp();
374 current = dir.canonicalPath(); 376 current = dir.canonicalPath();
375 chdir( current.latin1() ); 377 chdir( current.latin1() );
376 currentDir.cd( current, TRUE); 378 currentDir.cd( current, TRUE);
377 populateLocalView(); 379 populateLocalView();
378 update(); 380 update();
379 } else { 381 } else {
380 QString current = currentRemoteDir.canonicalPath(); 382 QString current = currentRemoteDir.canonicalPath();
381 QDir dir(current); 383 QDir dir(current);
382 dir.cdUp(); 384 dir.cdUp();
383 current = dir.canonicalPath(); 385 current = dir.canonicalPath();
384 chdir( current.latin1() ); 386 chdir( current.latin1() );
385 currentRemoteDir.cd( current, TRUE); 387 currentRemoteDir.cd( current, TRUE);
386 populateRemoteView(); 388 populateRemoteView();
387 update(); 389 update();
388 } 390 }
389} 391}
390 392
391void AdvancedFm::copy() { 393void AdvancedFm::copy() {
392 qApp->processEvents(); 394 qApp->processEvents();
393 QStringList curFileList = getPath(); 395 QStringList curFileList = getPath();
394 if( curFileList.count() > 0) { 396 if( curFileList.count() > 0) {
395 QString curFile, item, destFile; 397 QString curFile, item, destFile;
396 if (TabWidget->currentPageIndex() == 0) { 398 if (TabWidget->currentPageIndex() == 0) {
397 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 399 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
398 item=(*it); 400 item=(*it);
399 401
400 if(item.find("->",0,TRUE)) //symlink 402 if(item.find("->",0,TRUE)) //symlink
401 item = item.left(item.find("->",0,TRUE)); 403 item = item.left(item.find("->",0,TRUE));
402 404
403 destFile = currentRemoteDir.canonicalPath()+"/"+ item; 405 destFile = currentRemoteDir.canonicalPath()+"/"+ item;
404 qDebug("Destination file is "+destFile); 406 qDebug("Destination file is "+destFile);
405 407
406 curFile = currentDir.canonicalPath()+"/"+ item; 408 curFile = currentDir.canonicalPath()+"/"+ item;
407 qDebug("CurrentFile file is " + curFile); 409 qDebug("CurrentFile file is " + curFile);
408 410
409 QFile f(destFile); 411 QFile f(destFile);
410 if( f.exists()) { 412 if( f.exists()) {
411 switch ( QMessageBox::warning(this,tr("Delete"), 413 switch ( QMessageBox::warning(this,tr("Delete"),
412 destFile+tr(" already exists\nDo you really want to delete it?"), 414 destFile+tr(" already exists\nDo you really want to delete it?"),
413 tr("Yes"),tr("No"),0,0,1) ) { 415 tr("Yes"),tr("No"),0,0,1) ) {
414 case 0: 416 case 0:
415 f.remove(); 417 f.remove();
416 break; 418 break;
417 case 1: 419 case 1:
418 return; 420 return;
419 break; 421 break;
420 }; 422 };
421 } 423 }
422 if(!copyFile(destFile, curFile) ) { 424 if(!copyFile(destFile, curFile) ) {
423 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 425 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
424 return; 426 return;
425 } 427 }
426 } 428 }
427 populateRemoteView(); 429 populateRemoteView();
428 TabWidget->setCurrentPage(1); 430 TabWidget->setCurrentPage(1);
429 431
430 } else { 432 } else {
431 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 433 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
432 item= (*it); 434 item= (*it);
433 435
434 if(item.find("->",0,TRUE)) //symlink 436 if(item.find("->",0,TRUE)) //symlink
435 item = item.left(item.find("->",0,TRUE)); 437 item = item.left(item.find("->",0,TRUE));
436 438
437 destFile = currentDir.canonicalPath()+"/"+ item; 439 destFile = currentDir.canonicalPath()+"/"+ item;
438 qDebug("Destination file is "+destFile); 440 qDebug("Destination file is "+destFile);
439 441
440 curFile = currentRemoteDir.canonicalPath()+"/"+ item;; 442 curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
441 qDebug("CurrentFile file is " + curFile); 443 qDebug("CurrentFile file is " + curFile);
442 444
443 QFile f(destFile); 445 QFile f(destFile);
444 if( f.exists()) { 446 if( f.exists()) {
445 switch ( QMessageBox::warning(this,tr("Delete"), 447 switch ( QMessageBox::warning(this,tr("Delete"),
446 destFile+tr(" already exists\nDo you really want to delete it?"), 448 destFile+tr(" already exists\nDo you really want to delete it?"),
447 tr("Yes"),tr("No"),0,0,1) ) { 449 tr("Yes"),tr("No"),0,0,1) ) {
448 case 0: 450 case 0:
449 f.remove(); 451 f.remove();
450 break; 452 break;
451 case 1: 453 case 1:
452 return; 454 return;
453 break; 455 break;
454 }; 456 };
455 } 457 }
456 if(!copyFile(destFile, curFile) ) { 458 if(!copyFile(destFile, curFile) ) {
457 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 459 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
458 +curFile +tr("to\n")+destFile); 460 +curFile +tr("to\n")+destFile);
459 return; 461 return;
460 462
461 } 463 }
462 } 464 }
463 populateLocalView(); 465 populateLocalView();
464 TabWidget->setCurrentPage(0); 466 TabWidget->setCurrentPage(0);
465 } 467 }
466 468
467 } 469 }
468} 470}
469 471
470void AdvancedFm::copyAs() { 472void AdvancedFm::copyAs() {
471 qApp->processEvents(); 473 qApp->processEvents();
472 474
473 QStringList curFileList = getPath(); 475 QStringList curFileList = getPath();
474 QString curFile; 476 QString curFile;
475 InputDialog *fileDlg; 477 InputDialog *fileDlg;
476 if (TabWidget->currentPageIndex() == 0) { 478 if (TabWidget->currentPageIndex() == 0) {
477 qDebug("tab 1"); 479 qDebug("tab 1");
478 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 480 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
479 QString destFile; 481 QString destFile;
480 curFile = currentDir.canonicalPath()+"/"+(*it); 482 curFile = currentDir.canonicalPath()+"/"+(*it);
481 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 483 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
482 484
483 fileDlg->setInputText((const QString &) destFile ); 485 fileDlg->setInputText((const QString &) destFile );
484 fileDlg->exec(); 486 fileDlg->exec();
485 487
486 if( fileDlg->result() == 1 ) { 488 if( fileDlg->result() == 1 ) {
487 QString filename = fileDlg->LineEdit1->text(); 489 QString filename = fileDlg->LineEdit1->text();
488 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 490 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
489 491
490 QFile f(destFile); 492 QFile f(destFile);
491 if( f.exists()) { 493 if( f.exists()) {
492 switch (QMessageBox::warning(this,tr("Delete"), 494 switch (QMessageBox::warning(this,tr("Delete"),
493 destFile+tr(" already exists\nDo you really want to delete it?"), 495 destFile+tr(" already exists\nDo you really want to delete it?"),
494 tr("Yes"),tr("No"),0,0,1) ) { 496 tr("Yes"),tr("No"),0,0,1) ) {
495 case 0: 497 case 0:
496 f.remove(); 498 f.remove();
497 break; 499 break;
498 case 1: 500 case 1:
499 return; 501 return;
500 break; 502 break;
501 }; 503 };
502 } 504 }
503 if(!copyFile(destFile, curFile) ) { 505 if(!copyFile(destFile, curFile) ) {
504 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 506 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
505 +curFile +tr("to\n")+destFile); 507 +curFile +tr("to\n")+destFile);
506 return; 508 return;
507 } 509 }
508 } 510 }
509 delete fileDlg; 511 delete fileDlg;
510 512
511 } 513 }
512 populateRemoteView(); 514 populateRemoteView();
513 TabWidget->setCurrentPage(1); 515 TabWidget->setCurrentPage(1);
514 516
515 } else { 517 } else {
516 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 518 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
517 519
518 curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 520 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
519 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); 521 fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0);
520 522
521 QString destFile; 523 QString destFile;
522 fileDlg->setInputText((const QString &) destFile); 524 fileDlg->setInputText((const QString &) destFile);
523 fileDlg->exec(); 525 fileDlg->exec();
524 526
525 if( fileDlg->result() == 1 ) { 527 if( fileDlg->result() == 1 ) {
526 QString filename = fileDlg->LineEdit1->text(); 528 QString filename = fileDlg->LineEdit1->text();
527 destFile = currentDir.canonicalPath()+"/"+filename; 529 destFile = currentDir.canonicalPath()+"/"+filename;
528 530
529 QFile f( destFile); 531 QFile f( destFile);
530 if( f.exists()) { 532 if( f.exists()) {
531 switch ( QMessageBox::warning(this,tr("Delete"), 533 switch ( QMessageBox::warning(this,tr("Delete"),
532 destFile+tr(" already exists\nDo you really want to delete it?"), 534 destFile+tr(" already exists\nDo you really want to delete it?"),
533 tr("Yes"),tr("No"),0,0,1) ) { 535 tr("Yes"),tr("No"),0,0,1) ) {
534 case 0: 536 case 0:
535 f.remove(); 537 f.remove();
536 break; 538 break;
537 case 1: 539 case 1:
538 return; 540 return;
539 break; 541 break;
540 }; 542 };
541 } 543 }
542 if(!copyFile(destFile, curFile) ) { 544 if(!copyFile(destFile, curFile) ) {
543 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 545 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
544 +curFile +tr("to\n")+destFile); 546 +curFile +tr("to\n")+destFile);
545 return; 547 return;
546 } 548 }
547 549
548 } 550 }
549 delete fileDlg; 551 delete fileDlg;
550 552
551 } 553 }
552 populateLocalView(); 554 populateLocalView();
553 TabWidget->setCurrentPage(0); 555 TabWidget->setCurrentPage(0);
554 } 556 }
555} 557}
556 558
557void AdvancedFm::copySameDir() { 559void AdvancedFm::copySameDir() {
558 qApp->processEvents(); 560 qApp->processEvents();
559 QStringList curFileList = getPath(); 561 QStringList curFileList = getPath();
560 QString curFile, item, destFile; 562 QString curFile, item, destFile;
561 InputDialog *fileDlg; 563 InputDialog *fileDlg;
562 564
563 if (TabWidget->currentPageIndex() == 0) { 565 if (TabWidget->currentPageIndex() == 0) {
564 566
565 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 567 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
566 item=(*it); 568 item=(*it);
567 curFile = currentDir.canonicalPath()+"/"+ item; 569 curFile = currentDir.canonicalPath()+"/"+ item;
568 570
569 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 571 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
570 fileDlg->setInputText((const QString &) destFile ); 572 fileDlg->setInputText((const QString &) destFile );
571 fileDlg->exec(); 573 fileDlg->exec();
572 574
573 if( fileDlg->result() == 1 ) { 575 if( fileDlg->result() == 1 ) {
574 576
575 QString filename = fileDlg->LineEdit1->text(); 577 QString filename = fileDlg->LineEdit1->text();
576 destFile = currentDir.canonicalPath()+"/"+filename; 578 destFile = currentDir.canonicalPath()+"/"+filename;
577 579
578 QFile f(destFile); 580 QFile f(destFile);
579 if( f.exists()) { 581 if( f.exists()) {
580 switch (QMessageBox::warning(this,tr("Delete"), 582 switch (QMessageBox::warning(this,tr("Delete"),
581 destFile+tr(" already exists\nDo you really want to delete it?"), 583 destFile+tr(" already exists\nDo you really want to delete it?"),
582 tr("Yes"),tr("No"),0,0,1) ) { 584 tr("Yes"),tr("No"),0,0,1) ) {
583 case 0: 585 case 0:
584 586
585 f.remove(); 587 f.remove();
586 break; 588 break;
587 case 1: 589 case 1:
588 return; 590 return;
589 break; 591 break;
590 }; 592 };
591 } 593 }
592 if(!copyFile(destFile, curFile) ) { 594 if(!copyFile(destFile, curFile) ) {
593 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 595 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
594 +curFile +tr("to\n")+destFile); 596 +curFile +tr("to\n")+destFile);
595 return; 597 return;
596 } 598 }
597 599
598 qDebug("copy "+curFile+" as "+destFile); 600 qDebug("copy "+curFile+" as "+destFile);
599 } 601 }
600 delete fileDlg; 602 delete fileDlg;
601 } 603 }
602 populateLocalView(); 604 populateLocalView();
603 605
604 } else { 606 } else {
605 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 607 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
606 item=(*it); 608 item=(*it);
607 curFile = currentRemoteDir.canonicalPath()+"/"+ item; 609 curFile = currentRemoteDir.canonicalPath()+"/"+ item;
608 610
609 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 611 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
610 fileDlg->setInputText((const QString &) destFile); 612 fileDlg->setInputText((const QString &) destFile);
611 fileDlg->exec(); 613 fileDlg->exec();
612 if( fileDlg->result() == 1 ) { 614 if( fileDlg->result() == 1 ) {
613 QString filename = fileDlg->LineEdit1->text(); 615 QString filename = fileDlg->LineEdit1->text();
614 616
615 destFile = currentRemoteDir.canonicalPath()+"/"+filename; 617 destFile = currentRemoteDir.canonicalPath()+"/"+filename;
616 618
617 QFile f(destFile); 619 QFile f(destFile);
618 if( f.exists()) { 620 if( f.exists()) {
619 switch ( QMessageBox::warning(this,tr("Delete"), 621 switch ( QMessageBox::warning(this,tr("Delete"),
620 destFile+tr(" already exists\nDo you really want to delete it?"), 622 destFile+tr(" already exists\nDo you really want to delete it?"),
621 tr("Yes"),tr("No"),0,0,1) ) { 623 tr("Yes"),tr("No"),0,0,1) ) {
622 case 0: 624 case 0:
623 f.remove(); 625 f.remove();
624 break; 626 break;
625 case 1: 627 case 1:
626 return; 628 return;
627 break; 629 break;
628 }; 630 };
629 } 631 }
630 if(!copyFile(destFile, curFile) ) { 632 if(!copyFile(destFile, curFile) ) {
631 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 633 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
632 +curFile +tr("to\n")+destFile); 634 +curFile +tr("to\n")+destFile);
633 return; 635 return;
634 } 636 }
635 qDebug("copy "+curFile+" as "+destFile); 637 qDebug("copy "+curFile+" as "+destFile);
636 } 638 }
637 delete fileDlg; 639 delete fileDlg;
638 } 640 }
639 populateRemoteView(); 641 populateRemoteView();
640 } 642 }
641} 643}
642 644
643void AdvancedFm::move() { 645void AdvancedFm::move() {
644 qApp->processEvents(); 646 qApp->processEvents();
645 647
646 QStringList curFileList = getPath(); 648 QStringList curFileList = getPath();
647 if( curFileList.count() > 0) { 649 if( curFileList.count() > 0) {
648 QString curFile, destFile, item; 650 QString curFile, destFile, item;
649 651
650 if (TabWidget->currentPageIndex() == 0) { 652 if (TabWidget->currentPageIndex() == 0) {
651 653
652 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 654 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
653 item=(*it); 655 item=(*it);
654 QString destFile = currentRemoteDir.canonicalPath(); 656 QString destFile = currentRemoteDir.canonicalPath();
655 657
656 if(destFile.right(1).find("/",0,TRUE) == -1) 658 if(destFile.right(1).find("/",0,TRUE) == -1)
657 destFile+="/"; 659 destFile+="/";
658 destFile += item; 660 destFile += item;
659 curFile = currentDir.canonicalPath(); 661 curFile = currentDir.canonicalPath();
660 662
661 qDebug("Destination file is "+destFile); 663 qDebug("Destination file is "+destFile);
662 664
663 if(curFile.right(1).find("/",0,TRUE) == -1) 665 if(curFile.right(1).find("/",0,TRUE) == -1)
664 curFile +="/"; 666 curFile +="/";
665 667
666 curFile+= item; 668 curFile+= item;
667 qDebug("CurrentFile file is " + curFile); 669 qDebug("CurrentFile file is " + curFile);
668 670
669 QFile f( curFile); 671 QFile f( curFile);
670 if( f.exists()) { 672 if( f.exists()) {
671 if(!copyFile( destFile, curFile) ) { 673 if(!copyFile( destFile, curFile) ) {
672 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 674 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
673 return; 675 return;
674 } else 676 } else
675 QFile::remove(curFile); 677 QFile::remove(curFile);
676 } 678 }
677 } 679 }
678 680
679 TabWidget->setCurrentPage(1); 681 TabWidget->setCurrentPage(1);
680 682
681 } else { //view 2 683 } else { //view 2
682 684
683 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 685 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
684 item = (*it); 686 item = (*it);
685 QString destFile = currentDir.canonicalPath(); 687 QString destFile = currentDir.canonicalPath();
686 688
687 if(destFile.right(1).find("/",0,TRUE) == -1) 689 if(destFile.right(1).find("/",0,TRUE) == -1)
688 destFile+="/"; 690 destFile+="/";
689 691
690 destFile += item; 692 destFile += item;
691 693
692 qDebug("Destination file is "+destFile); 694 qDebug("Destination file is "+destFile);
693 695
694 curFile = currentRemoteDir.canonicalPath(); 696 curFile = currentRemoteDir.canonicalPath();
695 697
696 if(curFile.right(1).find("/",0,TRUE) == -1) 698 if(curFile.right(1).find("/",0,TRUE) == -1)
697 curFile +="/"; 699 curFile +="/";
698 curFile+= item; 700 curFile+= item;
699 qDebug("CurrentFile file is " + curFile); 701 qDebug("CurrentFile file is " + curFile);
700 702
701 QFile f( curFile); 703 QFile f( curFile);
702 if( f.exists()) { 704 if( f.exists()) {
703 if(!copyFile( destFile, curFile) ) { 705 if(!copyFile( destFile, curFile) ) {
704 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); 706 QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
705 return; 707 return;
706 } else 708 } else
707 QFile::remove( curFile); 709 QFile::remove( curFile);
708 } 710 }
709 TabWidget->setCurrentPage(0); 711 TabWidget->setCurrentPage(0);
710 } 712 }
711 } 713 }
712 populateRemoteView(); 714 populateRemoteView();
713 populateLocalView(); 715 populateLocalView();
714 } 716 }
715} 717}
716 718
717bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { 719bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
718 char bf[ 50000 ]; 720 char bf[ 50000 ];
719 int bytesRead; 721 int bytesRead;
720 bool success = TRUE; 722 bool success = TRUE;
721 struct stat status; 723 struct stat status;
722 724
723 QFile s( src ); 725 QFile s( src );
724 QFile d( dest ); 726 QFile d( dest );
725 727
726 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { 728 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
727 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { 729 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
728 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 730 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
729 success = FALSE; 731 success = FALSE;
730 break; 732 break;
731 } 733 }
732 } 734 }
733 if( success && (bytesRead > 0) ){ 735 if( success && (bytesRead > 0) ){
734 d.writeBlock( bf, bytesRead ); 736 d.writeBlock( bf, bytesRead );
735 } 737 }
736 } else { 738 } else {
737 success = FALSE; 739 success = FALSE;
738 } 740 }
739 741
740 // Set file permissions 742 // Set file permissions
741 if( stat( (const char *) src, &status ) == 0 ){ 743 if( stat( (const char *) src, &status ) == 0 ){
742 chmod( (const char *) dest, status.st_mode ); 744 chmod( (const char *) dest, status.st_mode );
743 } 745 }
744 746
745 return success; 747 return success;
746} 748}
747 749
748void AdvancedFm::runCommand() { 750void AdvancedFm::runCommand() {
749 QString curFile; 751 QString curFile;
750 if (TabWidget->currentPageIndex() == 0) { 752 if (TabWidget->currentPageIndex() == 0) {
751 if( Local_View->currentItem()) 753 if( Local_View->currentItem())
752 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 754 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
753 } else { 755 } else {
754 if(Remote_View->currentItem()) 756 if(Remote_View->currentItem())
755 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 757 curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
756 } 758 }
757 759
758 InputDialog *fileDlg; 760 InputDialog *fileDlg;
759 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 761 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
760 fileDlg->setInputText(curFile); 762 fileDlg->setInputText(curFile);
761 fileDlg->exec(); 763 fileDlg->exec();
762 QString command; 764 QString command;
763 if( fileDlg->result() == 1 ) { 765 if( fileDlg->result() == 1 ) {
764 command = fileDlg->LineEdit1->text(); 766 command = fileDlg->LineEdit1->text();
765 767
766 Output *outDlg; 768 Output *outDlg;
767 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 769 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
768 outDlg->showMaximized(); 770 outDlg->showMaximized();
769 outDlg->show(); 771 outDlg->show();
770 qApp->processEvents(); 772 qApp->processEvents();
771 FILE *fp; 773 FILE *fp;
772 char line[130]; 774 char line[130];
773 sleep(1); 775 sleep(1);
774 command +=" 2>&1"; 776 command +=" 2>&1";
775 fp = popen( (const char *) command, "r"); 777 fp = popen( (const char *) command, "r");
776 if ( !fp ) { 778 if ( !fp ) {
777 qDebug("Could not execute '" + command + "'! err=%d", fp); 779 qDebug("Could not execute '" + command + "'! err=%d", fp);
778 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 780 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
779 pclose(fp); 781 pclose(fp);
780 return; 782 return;
781 } else { 783 } else {
782 while ( fgets( line, sizeof line, fp)) { 784 while ( fgets( line, sizeof line, fp)) {
783 QString lineStr = line; 785 QString lineStr = line;
784 lineStr=lineStr.left(lineStr.length()-1); 786 lineStr=lineStr.left(lineStr.length()-1);
785 outDlg->OutputEdit->append(lineStr); 787 outDlg->OutputEdit->append(lineStr);
786 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 788 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
787 } 789 }
788 } 790 }
789 pclose(fp); 791 pclose(fp);
790 792
791 } 793 }
792} 794}
793 795
794void AdvancedFm::runCommandStd() { 796void AdvancedFm::runCommandStd() {
795 QString curFile; 797 QString curFile;
796 if (TabWidget->currentPageIndex() == 0) { 798 if (TabWidget->currentPageIndex() == 0) {
797 if( Local_View->currentItem()) 799 if( Local_View->currentItem())
798 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); 800 curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
799 } else { 801 } else {
800 if(Remote_View->currentItem()) 802 if(Remote_View->currentItem())
801 curFile = currentRemoteDir.canonicalPath() +"/" 803 curFile = currentRemoteDir.canonicalPath() +"/"
802 + Remote_View->currentItem()->text(0); 804 + Remote_View->currentItem()->text(0);
803 } 805 }
804 806
805 InputDialog *fileDlg; 807 InputDialog *fileDlg;
806 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 808 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
807 fileDlg->setInputText(curFile); 809 fileDlg->setInputText(curFile);
808 fileDlg->exec(); 810 fileDlg->exec();
809 QString command; 811 QString command;
810 if( fileDlg->result() == 1 ) { 812 if( fileDlg->result() == 1 ) {
811 qApp->processEvents(); 813 qApp->processEvents();
812 command = fileDlg->LineEdit1->text() + " &"; 814 command = fileDlg->LineEdit1->text() + " &";
813 system(command.latin1()); 815 system(command.latin1());
814 } 816 }
815} 817}
816 818
817void AdvancedFm::fileStatus() { 819void AdvancedFm::fileStatus() {
818 QString curFile; 820 QString curFile;
819 if (TabWidget->currentPageIndex() == 0) { 821 if (TabWidget->currentPageIndex() == 0) {
820 curFile = Local_View->currentItem()->text(0); 822 curFile = Local_View->currentItem()->text(0);
821 } else { 823 } else {
822 curFile = Remote_View->currentItem()->text(0); 824 curFile = Remote_View->currentItem()->text(0);
823 } 825 }
824 QString command = " stat -l "+ curFile +" 2>&1"; 826 QString command = " stat -l "+ curFile +" 2>&1";
825 Output *outDlg; 827 Output *outDlg;
826 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); 828 outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
827 outDlg->showMaximized(); 829 outDlg->showMaximized();
828 outDlg->show(); 830 outDlg->show();
829 qApp->processEvents(); 831 qApp->processEvents();
830 FILE *fp; 832 FILE *fp;
831 char line[130]; 833 char line[130];
832 sleep(1); 834 sleep(1);
833 fp = popen( (const char *) command, "r"); 835 fp = popen( (const char *) command, "r");
834 if ( !fp ) { 836 if ( !fp ) {
835 qDebug("Could not execute '" + command + "'! err=%d", fp); 837 qDebug("Could not execute '" + command + "'! err=%d", fp);
836 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); 838 QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
837 pclose(fp); 839 pclose(fp);
838 return; 840 return;
839 } else { 841 } else {
840 while ( fgets( line, sizeof line, fp)) { 842 while ( fgets( line, sizeof line, fp)) {
841 outDlg->OutputEdit->append(line); 843 outDlg->OutputEdit->append(line);
842 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 844 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
843 845
844 } 846 }
845 847
846 } 848 }
847 pclose(fp); 849 pclose(fp);
848} 850}
849 851
850void AdvancedFm::mkDir() { 852void AdvancedFm::mkDir() {
851 if (TabWidget->currentPageIndex() == 0) 853 if (TabWidget->currentPageIndex() == 0)
852 localMakDir(); 854 localMakDir();
853 else 855 else
854 remoteMakDir(); 856 remoteMakDir();
855 857
856} 858}
857 859
858void AdvancedFm::rn() { 860void AdvancedFm::rn() {
859 if (TabWidget->currentPageIndex() == 0) 861 if (TabWidget->currentPageIndex() == 0)
860 localRename(); 862 localRename();
861 else 863 else
862 remoteRename(); 864 remoteRename();
863 865
864} 866}
865 867
866void AdvancedFm::del() { 868void AdvancedFm::del() {
867 if (TabWidget->currentPageIndex() == 0) 869 if (TabWidget->currentPageIndex() == 0)
868 localDelete(); 870 localDelete();
869 else 871 else
870 remoteDelete(); 872 remoteDelete();
871} 873}
872 874
873void AdvancedFm::mkSym() { 875void AdvancedFm::mkSym() {
874 QString cmd; 876 QString cmd;
875 QStringList curFileList = getPath(); 877 QStringList curFileList = getPath();
876 if( curFileList.count() > 0) { 878 if( curFileList.count() > 0) {
877 879
878 if (TabWidget->currentPageIndex() == 0) { 880 if (TabWidget->currentPageIndex() == 0) {
879 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 881 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
880 882
881 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); 883 QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
882 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 884 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
883 QString curFile = currentDir.canonicalPath()+"/"+(*it); 885 QString curFile = currentDir.canonicalPath()+"/"+(*it);
884 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 886 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
885 cmd = "ln -s "+curFile+" "+destName; 887 cmd = "ln -s "+curFile+" "+destName;
886 qDebug(cmd); 888 qDebug(cmd);
887 system(cmd.latin1() ); 889 system(cmd.latin1() );
888 } 890 }
889 populateRemoteView(); 891 populateRemoteView();
890 TabWidget->setCurrentPage(1); 892 TabWidget->setCurrentPage(1);
891 } else { 893 } else {
892 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 894 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
893 895
894 QString destName = currentDir.canonicalPath()+"/"+(*it); 896 QString destName = currentDir.canonicalPath()+"/"+(*it);
895 if(destName.right(1) == "/") destName = destName.left( destName.length() -1); 897 if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
896 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 898 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
897 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 899 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
898 900
899 cmd = "ln -s "+curFile+" "+destName; 901 cmd = "ln -s "+curFile+" "+destName;
900 qDebug(cmd); 902 qDebug(cmd);
901 system(cmd.latin1() ); 903 system(cmd.latin1() );
902 } 904 }
903 populateLocalView(); 905 populateLocalView();
904 TabWidget->setCurrentPage(0); 906 TabWidget->setCurrentPage(0);
905 } 907 }
906 } 908 }
907} 909}
908 910
909void AdvancedFm::doBeam() { 911void AdvancedFm::doBeam() {
910 Ir ir; 912 Ir ir;
911 if(!ir.supported()){ 913 if(!ir.supported()){
912 } else { 914 } else {
913 915
914 QStringList curFileList = getPath(); 916 QStringList curFileList = getPath();
915 if( curFileList.count() > 0) { 917 if( curFileList.count() > 0) {
916 918
917 if (TabWidget->currentPageIndex() == 0) { 919 if (TabWidget->currentPageIndex() == 0) {
918 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 920 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
919 921
920 QString curFile = currentDir.canonicalPath()+"/"+(*it); 922 QString curFile = currentDir.canonicalPath()+"/"+(*it);
921 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 923 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
922 Ir *file = new Ir(this, "IR"); 924 Ir *file = new Ir(this, "IR");
923 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 925 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
924 file->send( curFile, curFile ); 926 file->send( curFile, curFile );
925 } 927 }
926 928
927 } else { 929 } else {
928 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 930 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
929 931
930 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); 932 QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
931 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); 933 if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
932 Ir *file = new Ir(this, "IR"); 934 Ir *file = new Ir(this, "IR");
933 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 935 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
934 file->send( curFile, curFile ); 936 file->send( curFile, curFile );
935 937
936 } 938 }
937 } 939 }
938 } 940 }
939 } 941 }
940 942
941} 943}
942 944
943void AdvancedFm::fileBeamFinished( Ir *) { 945void AdvancedFm::fileBeamFinished( Ir *) {
944 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 946 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
945 947
946} 948}