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