summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp680
1 files changed, 299 insertions, 381 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index d8bdff7..74654fc 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -82,7 +82,9 @@ AdvancedFm::AdvancedFm( )
82AdvancedFm::~AdvancedFm() { 82AdvancedFm::~AdvancedFm() {
83} 83}
84 84
85void AdvancedFm::cleanUp() { 85
86void AdvancedFm::cleanUp()
87{
86 QString sfile=QDir::homeDirPath(); 88 QString sfile=QDir::homeDirPath();
87 if(sfile.right(1) != "/") 89 if(sfile.right(1) != "/")
88 sfile+="/._temp"; 90 sfile+="/._temp";
@@ -93,35 +95,31 @@ void AdvancedFm::cleanUp() {
93 file.remove(); 95 file.remove();
94} 96}
95 97
96void AdvancedFm::tabChanged(QWidget *w) { 98void AdvancedFm::tabChanged(QWidget *w)
97// qDebug("tab changed %d",TabWidget->getCurrentTab()); 99{
100 if( w == tab)
101 whichTab = 1;
102 else
103 whichTab = 2;
104
105 //qDebug("tab changed %d", whichTab );
106
107 QString path = CurrentDir()->canonicalPath();
108 currentPathCombo->lineEdit()->setText( path );
98 109
99 if ( w == tab) {
100// if (TabWidget->getCurrentTab() == 0) {
101// if (TabWidget->currentPageIndex() == 0) {
102 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
103 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
104 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
105 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath());
106 setCaption("AdvancedFm :: "+fs+" :: "
107 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" );
108 112
109 } 113 QString fs= getFileSystemType( (const QString &) path);
110 if ( w == tab_2) {
111// if (TabWidget->getCurrentTab() == 1) {
112 114
113// if (TabWidget->currentPageIndex() == 1) {
114 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
115 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
116 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
117 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
118 setCaption("AdvancedFm :: "+fs+" :: " 115 setCaption("AdvancedFm :: "+fs+" :: "
119 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); 116 +checkDiskSpace( (const QString &) path )+ " kB free" );
120 } 117 chdir( path.latin1());
121} 118}
122 119
123 120
124void AdvancedFm::populateLocalView() { 121void AdvancedFm::populateLocalView()
122{
125 QPixmap pm; 123 QPixmap pm;
126 Local_View->clear(); 124 Local_View->clear();
127 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 125 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -135,48 +133,63 @@ void AdvancedFm::populateLocalView() {
135 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 133 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
136 QFileInfoListIterator it(*list); 134 QFileInfoListIterator it(*list);
137 QFileInfo *fi; 135 QFileInfo *fi;
138 while ( (fi=it.current()) ) { 136 while ( (fi=it.current()) )
139 if (fi->isSymLink() ) { 137 {
138 if (fi->isSymLink() )
139 {
140 QString symLink=fi->readLink(); 140 QString symLink=fi->readLink();
141 QFileInfo sym( symLink); 141 QFileInfo sym( symLink);
142 fileS.sprintf( "%10i", sym.size() ); 142 fileS.sprintf( "%10i", sym.size() );
143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
144 fileDate = sym.lastModified().toString(); 144 fileDate = sym.lastModified().toString();
145 } else { 145 }
146 else
147 {
146 fileS.sprintf( "%10i", fi->size() ); 148 fileS.sprintf( "%10i", fi->size() );
147 fileL.sprintf( "%s",fi->fileName().data() ); 149 fileL.sprintf( "%s",fi->fileName().data() );
148 fileDate= fi->lastModified().toString(); 150 fileDate= fi->lastModified().toString();
149 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { 151 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() )
152 {
150 fileL+="/"; 153 fileL+="/";
151 isDir=TRUE; 154 isDir=TRUE;
152 } 155 }
153 } 156 }
154 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 157 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL);
155 if(fileL !="./" && fi->exists()) { 158 if(fileL !="./" && fi->exists())
159 {
156 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 160 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
157 161
158 if(isDir || fileL.find("/",0,TRUE) != -1) { 162 if(isDir || fileL.find("/",0,TRUE) != -1)
163 {
159 164
160 if( !QDir( fi->filePath() ).isReadable()) //is directory 165 if( !QDir( fi->filePath() ).isReadable()) //is directory
161 pm = Resource::loadPixmap( "lockedfolder" ); 166 pm = Resource::loadPixmap( "lockedfolder" );
162 else 167 else
163 pm= Resource::loadPixmap( "folder" ); 168 pm= Resource::loadPixmap( "folder" );
164 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 169 }
170 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
171 {
165 pm = Resource::loadPixmap( "exec"); 172 pm = Resource::loadPixmap( "exec");
166 } else if( (fileInfo.permission( QFileInfo::ExeUser) 173 }
174 else if( (fileInfo.permission( QFileInfo::ExeUser)
167 | fileInfo.permission( QFileInfo::ExeGroup) 175 | fileInfo.permission( QFileInfo::ExeGroup)
168 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 176 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
177 {
169 pm = Resource::loadPixmap( "exec"); 178 pm = Resource::loadPixmap( "exec");
170 } else if( !fi->isReadable() ) { 179 }
180 else if( !fi->isReadable() )
181 {
171 pm = Resource::loadPixmap( "locked" ); 182 pm = Resource::loadPixmap( "locked" );
172 } else { //everything else goes by mimetype 183 }
184 else { //everything else goes by mimetype
173 MimeType mt(fi->filePath()); 185 MimeType mt(fi->filePath());
174 pm=mt.pixmap(); //sets the correct pixmap for mimetype 186 pm=mt.pixmap(); //sets the correct pixmap for mimetype
175 if(pm.isNull()) 187 if(pm.isNull())
176 pm = Resource::loadPixmap( "UnknownDocument-14" ); 188 pm = Resource::loadPixmap( "UnknownDocument-14" );
177 } 189 }
178 item->setPixmap( 0,pm); 190 item->setPixmap( 0,pm);
179 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 191 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
192 {
180 // overlay link image 193 // overlay link image
181 pm= Resource::loadPixmap( "folder" ); 194 pm= Resource::loadPixmap( "folder" );
182 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 195 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -190,20 +203,24 @@ void AdvancedFm::populateLocalView() {
190 ++it; 203 ++it;
191 } 204 }
192 205
193 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { 206 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1)
207 {
194 struct stat buf; 208 struct stat buf;
195 dev_t devT; 209 dev_t devT;
196 DIR *dir; 210 DIR *dir;
197 struct dirent *mydirent; 211 struct dirent *mydirent;
212
198 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 213 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
199 while ((mydirent = readdir(dir)) != NULL) { 214 while ((mydirent = readdir(dir)) != NULL)
215 {
200 lstat( mydirent->d_name, &buf); 216 lstat( mydirent->d_name, &buf);
201// qDebug(mydirent->d_name); 217// qDebug(mydirent->d_name);
202 fileL.sprintf("%s", mydirent->d_name); 218 fileL.sprintf("%s", mydirent->d_name);
203 devT = buf.st_dev; 219 devT = buf.st_dev;
204 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 220 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
205 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 221 fileDate.sprintf("%s", ctime( &buf.st_mtime));
206 if( fileL.find(".") == -1 ){ 222 if( fileL.find(".") == -1 )
223 {
207 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 224 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
208 pm = Resource::loadPixmap( "UnknownDocument-14" ); 225 pm = Resource::loadPixmap( "UnknownDocument-14" );
209 item->setPixmap( 0,pm); 226 item->setPixmap( 0,pm);
@@ -218,7 +235,8 @@ void AdvancedFm::populateLocalView() {
218} 235}
219 236
220 237
221void AdvancedFm::populateRemoteView() { 238void AdvancedFm::populateRemoteView()
239{
222 QPixmap pm; 240 QPixmap pm;
223 Remote_View->clear(); 241 Remote_View->clear();
224 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 242 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -233,50 +251,68 @@ void AdvancedFm::populateRemoteView() {
233 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 251 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
234 QFileInfoListIterator it(*list); 252 QFileInfoListIterator it(*list);
235 QFileInfo *fi; 253 QFileInfo *fi;
236 while ( (fi=it.current()) ) { 254 while ( (fi=it.current()) )
237 if (fi->isSymLink() ){ 255 {
256 if (fi->isSymLink() )
257 {
238 QString symLink=fi->readLink(); 258 QString symLink=fi->readLink();
239 // qDebug("Symlink detected "+symLink); 259 // qDebug("Symlink detected "+symLink);
240 QFileInfo sym( symLink); 260 QFileInfo sym( symLink);
241 fileS.sprintf( "%10i", sym.size() ); 261 fileS.sprintf( "%10i", sym.size() );
242 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 262 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
243 fileDate = sym.lastModified().toString(); 263 fileDate = sym.lastModified().toString();
244 } else { 264 }
265 else
266 {
245 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 267 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
246 fileS.sprintf( "%10i", fi->size() ); 268 fileS.sprintf( "%10i", fi->size() );
247 fileL.sprintf( "%s",fi->fileName().data() ); 269 fileL.sprintf( "%s",fi->fileName().data() );
248 fileDate= fi->lastModified().toString(); 270 fileDate= fi->lastModified().toString();
249 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { 271
272 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() )
273 {
250 fileL+="/"; 274 fileL+="/";
251 isDir=TRUE; 275 isDir=TRUE;
252 // qDebug( fileL); 276 // qDebug( fileL);
253 } 277 }
254 } 278 }
279
255 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); 280 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
256 if(fileL !="./" && fi->exists()) { 281 if(fileL !="./" && fi->exists())
282 {
257 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 283 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
258 QPixmap pm; 284 QPixmap pm;
259 285
260 if(isDir || fileL.find("/",0,TRUE) != -1) { 286 if(isDir || fileL.find("/",0,TRUE) != -1)
287 {
261 if( !QDir( fi->filePath() ).isReadable()) 288 if( !QDir( fi->filePath() ).isReadable())
262 pm = Resource::loadPixmap( "lockedfolder" ); 289 pm = Resource::loadPixmap( "lockedfolder" );
263 else 290 else
264 pm= Resource::loadPixmap( "folder" ); 291 pm= Resource::loadPixmap( "folder" );
265 } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 292 }
293 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
294 {
266 pm = Resource::loadPixmap( "exec"); 295 pm = Resource::loadPixmap( "exec");
267 } else if( (fileInfo.permission( QFileInfo::ExeUser) 296 }
297 else if( (fileInfo.permission( QFileInfo::ExeUser)
268 | fileInfo.permission( QFileInfo::ExeGroup) 298 | fileInfo.permission( QFileInfo::ExeGroup)
269 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 299 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
300 {
270 pm = Resource::loadPixmap( "exec"); 301 pm = Resource::loadPixmap( "exec");
271 } else if( !fi->isReadable() ) { 302 }
303 else if( !fi->isReadable() )
304 {
272 pm = Resource::loadPixmap( "locked" ); 305 pm = Resource::loadPixmap( "locked" );
273 } else { 306 }
307 else
308 {
274 MimeType mt(fi->filePath()); 309 MimeType mt(fi->filePath());
275 pm=mt.pixmap(); //sets the correct pixmap for mimetype 310 pm=mt.pixmap(); //sets the correct pixmap for mimetype
276 if(pm.isNull()) 311 if(pm.isNull())
277 pm = Resource::loadPixmap( "UnknownDocument-14" ); 312 pm = Resource::loadPixmap( "UnknownDocument-14" );
278 } 313 }
279 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { 314 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
315 {
280 // overlay link image 316 // overlay link image
281 pm= Resource::loadPixmap( "folder" ); 317 pm= Resource::loadPixmap( "folder" );
282 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 318 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -290,18 +326,23 @@ void AdvancedFm::populateRemoteView() {
290 ++it; 326 ++it;
291 } 327 }
292 328
293 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { 329 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1)
330 {
294 struct stat buf; 331 struct stat buf;
295 DIR *dir; 332 DIR *dir;
296 struct dirent *mydirent; 333 struct dirent *mydirent;
297 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) 334 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
298 while ((mydirent = readdir(dir)) != NULL) { 335
336 while ((mydirent = readdir(dir)) != NULL)
337 {
299 lstat( mydirent->d_name, &buf); 338 lstat( mydirent->d_name, &buf);
300// qDebug(mydirent->d_name); 339// qDebug(mydirent->d_name);
301 fileL.sprintf("%s", mydirent->d_name); 340 fileL.sprintf("%s", mydirent->d_name);
302 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); 341 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
303 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 342 fileDate.sprintf("%s", ctime( &buf.st_mtime));
304 if( fileL.find(".") == -1 ){ 343
344 if( fileL.find(".") == -1 )
345 {
305 item= new QListViewItem( Remote_View, fileL, fileS, fileDate); 346 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
306 pm = Resource::loadPixmap( "UnknownDocument-14" ); 347 pm = Resource::loadPixmap( "UnknownDocument-14" );
307 item->setPixmap( 0,pm); 348 item->setPixmap( 0,pm);
@@ -315,103 +356,46 @@ void AdvancedFm::populateRemoteView() {
315 fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); 356 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
316} 357}
317 358
318void AdvancedFm::localListClicked(QListViewItem *selectedItem) { 359void AdvancedFm::ListClicked(QListViewItem *selectedItem)
319 if(selectedItem) { 360{
361 if(selectedItem)
362 {
320 QString strItem=selectedItem->text(0); 363 QString strItem=selectedItem->text(0);
321 QString strSize=selectedItem->text(1); 364 QString strSize=selectedItem->text(1);
322 strSize=strSize.stripWhiteSpace(); 365 strSize=strSize.stripWhiteSpace();
323 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 366 bool isDirectory = false;
324 QString strItem2 = dealWithSymName((const QString&)strItem); 367 QString strItem2;
325// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
326 if(QDir(strItem2).exists() ) {
327 currentDir.cd(strItem2, TRUE);
328 populateLocalView();
329 368
369 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
370 {
371 strItem2 = dealWithSymName((const QString&)strItem);
372 if(QDir(strItem2).exists() )
373 strItem = strItem2;
330 } 374 }
331 } else { // not a symlink
332 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
333 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
334 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
335 currentDir.cd(strItem,FALSE);
336 populateLocalView();
337 Local_View->ensureItemVisible(Local_View->firstChild());
338 375
339 } else { 376 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
340 currentDir.cdUp(); 377 {
341 populateLocalView();
342 Local_View->ensureItemVisible(Local_View->firstChild());
343 }
344 if(QDir(strItem).exists()){
345 currentDir.cd(strItem, TRUE);
346 Local_View->ensureItemVisible(Local_View->firstChild());
347 populateLocalView();
348 }
349 } else {
350 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
351 if( QFile::exists(strItem ) ) {
352 // qDebug("clicked item "+strItem);
353 // DocLnk doc( strItem, FALSE );
354 // doc.execute();
355 // Local_View->clearSelection();
356 }
357 } //end not symlink
358 chdir(strItem.latin1());
359 }
360 378
379 if(QDir(strItem).exists())
380 isDirectory = true;
361 } 381 }
362}
363
364void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) {
365 382
366 if(selectedItem) { 383 if( isDirectory )
367 QString strItem=selectedItem->text(0); 384 {
368 QString strSize=selectedItem->text(1); 385 CurrentDir()->cd( strItem, TRUE);
369 strSize=strSize.stripWhiteSpace(); 386 PopulateView();
370 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 387 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
371 QString strItem2 = dealWithSymName((const QString&)strItem);
372// QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
373 currentRemoteDir.cd(strItem2, TRUE);
374 populateRemoteView();
375 } else { // not a symlink
376 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
377 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
378 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
379 currentRemoteDir.cd(strItem,FALSE);
380 populateRemoteView();
381 Remote_View->ensureItemVisible(Remote_View->firstChild());
382 } else {
383 currentRemoteDir.cdUp();
384 populateRemoteView();
385 Remote_View->ensureItemVisible(Remote_View->firstChild());
386 }
387 if(QDir(strItem).exists()){
388 currentRemoteDir.cd(strItem, TRUE);
389 populateRemoteView();
390 Remote_View->ensureItemVisible(Remote_View->firstChild());
391 }
392 } else {
393 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
394 if( QFile::exists(strItem ) ) {
395 // qDebug("clicked item "+strItem);
396 // DocLnk doc( strItem, FALSE );
397 // doc.execute();
398 // Remote_View->clearSelection();
399 } 388 }
400 } //end not symlink
401 chdir(strItem.latin1()); 389 chdir(strItem.latin1());
402 } 390 }
403 } 391 }
404}
405
406 392
407void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 393void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
408// qDebug("list pressed");
409 switch (mouse) { 394 switch (mouse) {
410 case 1: 395 case 1:
411 { 396 {
412 if(renameBox != 0 ) 397 if(renameBox != 0 )
413 { 398 {
414// qDebug("cancel rename");
415 cancelRename(); 399 cancelRename();
416 } 400 }
417 401
@@ -419,83 +403,63 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i
419 break; 403 break;
420 case 2: 404 case 2:
421 menuTimer.start( 500, TRUE ); 405 menuTimer.start( 500, TRUE );
422// qDebug("Start menu timer\n");
423 break; 406 break;
424 }; 407 };
425} 408}
426 409
427void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { 410void AdvancedFm::switchToLocalTab()
428
429 switch (mouse) {
430 case 1:
431 {
432 if(renameBox != 0 )
433 { 411 {
434// qDebug("cancel rename");
435 cancelRename();
436 }
437 }
438 break;
439 case 2:
440 menuTimer.start( 500, TRUE );
441// qDebug("Start menu timer");
442 break;
443 };
444}
445
446
447void AdvancedFm::switchToLocalTab() {
448 TabWidget->setCurrentTab(0); 412 TabWidget->setCurrentTab(0);
449 Local_View->setFocus(); 413 Local_View->setFocus();
450} 414}
451 415
452void AdvancedFm::switchToRemoteTab() { 416void AdvancedFm::switchToRemoteTab()
417{
453 TabWidget->setCurrentTab(1); 418 TabWidget->setCurrentTab(1);
454 Remote_View->setFocus(); 419 Remote_View->setFocus();
455} 420}
456 421
457void AdvancedFm::readConfig() { 422void AdvancedFm::readConfig()
423{
458 Config cfg("AdvancedFm"); 424 Config cfg("AdvancedFm");
459} 425}
460 426
461void AdvancedFm::writeConfig() { 427void AdvancedFm::writeConfig()
428{
462 Config cfg("AdvancedFm"); 429 Config cfg("AdvancedFm");
463} 430}
464 431
465void AdvancedFm::currentPathComboChanged() { 432void AdvancedFm::currentPathComboChanged()
466 if (TabWidget->getCurrentTab() == 0) { 433{
467// if (TabWidget->currentPageIndex() == 0) { 434 if(QDir( currentPathCombo->lineEdit()->text()).exists())
468 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 435 {
469 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 436 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
470 populateLocalView(); 437 PopulateView();
471 } else {
472 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
473 }
474 } 438 }
475 if (TabWidget->getCurrentTab() == 0) { 439 else
476// if (TabWidget->currentPageIndex() == 0) { 440 {
477 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
478 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
479 populateRemoteView();
480 } else {
481 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 441 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
482 } 442 }
483 } 443 }
484}
485 444
486void AdvancedFm::fillCombo(const QString &currentPath) { 445void AdvancedFm::fillCombo(const QString &currentPath)
446{
487// qDebug("%d",TabWidget->getCurrentTab()); 447// qDebug("%d",TabWidget->getCurrentTab());
488 if (TabWidget->getCurrentTab() == 0) { 448 if ( whichTab == 1)
489// if (TabWidget->currentPageIndex() == 0) { 449 {
490 currentPathCombo->lineEdit()->setText( currentPath); 450 currentPathCombo->lineEdit()->setText( currentPath);
491 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 451 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
452 {
492 currentPathCombo->clear(); 453 currentPathCombo->clear();
493 localDirPathStringList.prepend( currentPath ); 454 localDirPathStringList.prepend( currentPath );
494 currentPathCombo->insertStringList( localDirPathStringList,-1); 455 currentPathCombo->insertStringList( localDirPathStringList,-1);
495 } 456 }
496 } else { 457 }
458 else
459 {
497 currentPathCombo->lineEdit()->setText( currentPath); 460 currentPathCombo->lineEdit()->setText( currentPath);
498 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { 461 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
462 {
499 currentPathCombo->clear(); 463 currentPathCombo->clear();
500 remoteDirPathStringList.prepend( currentPath ); 464 remoteDirPathStringList.prepend( currentPath );
501 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 465 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
@@ -503,93 +467,61 @@ void AdvancedFm::fillCombo(const QString &currentPath) {
503 } 467 }
504} 468}
505 469
506void AdvancedFm::currentPathComboActivated(const QString & currentPath) { 470void AdvancedFm::currentPathComboActivated(const QString & currentPath)
507 if (TabWidget->getCurrentTab() == 0) { 471{
508// if (TabWidget->currentPageIndex() == 0) {
509 chdir( currentPath.latin1() );
510 currentDir.cd( currentPath, TRUE);
511 populateLocalView();
512 update();
513 } else {
514 chdir( currentPath.latin1() ); 472 chdir( currentPath.latin1() );
515 currentRemoteDir.cd( currentPath, TRUE); 473 CurrentDir()->cd( currentPath, TRUE);
516 populateRemoteView(); 474 PopulateView();
517 update(); 475 update();
518 } 476 }
519}
520 477
521QStringList AdvancedFm::getPath() { 478QStringList AdvancedFm::getPath()
479{
522 QStringList strList; 480 QStringList strList;
523 if (TabWidget->getCurrentTab() == 0) { 481 QListView *thisView=CurrentView();
524// if (TabWidget->currentPageIndex() == 0) { 482 QList<QListViewItem> * getSelectedItems( QListView * thisView );
525 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 483 QListViewItemIterator it( thisView );
526 QListViewItemIterator it( Local_View ); 484 for ( ; it.current(); ++it )
527 for ( ; it.current(); ++it ) { 485 {
528 if ( it.current()->isSelected() ) { 486 if ( it.current()->isSelected() )
529 strList << it.current()->text(0); 487 {
530// qDebug(it.current()->text(0));
531 }
532 }
533 return strList;
534 } else {
535 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
536 QListViewItemIterator it( Remote_View );
537 for ( ; it.current(); ++it ) {
538 if ( it.current()->isSelected() ) {
539 strList << it.current()->text(0); 488 strList << it.current()->text(0);
540// qDebug(it.current()->text(0)); 489// qDebug(it.current()->text(0));
541 } 490 }
542 } 491 }
543 return strList; 492 return strList;
544 } 493 }
545 return "";
546}
547 494
548void AdvancedFm::homeButtonPushed() { 495void AdvancedFm::homeButtonPushed()
496{
549 QString current = QDir::homeDirPath(); 497 QString current = QDir::homeDirPath();
550 chdir( current.latin1() ); 498 chdir( current.latin1() );
551 if (TabWidget->getCurrentTab() == 0) { 499 CurrentDir()->cd( current, TRUE);
552// if (TabWidget->currentPageIndex() == 0) { 500 PopulateView();
553 currentDir.cd( current, TRUE);
554 populateLocalView();
555 } else {
556 currentRemoteDir.cd( current, TRUE);
557 populateRemoteView();
558 }
559 update(); 501 update();
560} 502}
561 503
562void AdvancedFm::docButtonPushed() { 504void AdvancedFm::docButtonPushed()
505{
563 QString current = QPEApplication::documentDir(); 506 QString current = QPEApplication::documentDir();
564 chdir( current.latin1() ); 507 chdir( current.latin1() );
565 508
566 if (TabWidget->getCurrentTab() == 0) { 509 CurrentDir()->cd( current, TRUE);
567//if (TabWidget->currentPageIndex() == 0) { 510 PopulateView();
568 currentDir.cd( current, TRUE);
569 populateLocalView();
570 } else {
571 currentRemoteDir.cd( current, TRUE);
572 populateRemoteView();
573 }
574 update(); 511 update();
575} 512}
576 513
577void AdvancedFm::SDButtonPushed() { 514void AdvancedFm::SDButtonPushed()
515{
578 QString current = "/mnt/card";// this can change so fix 516 QString current = "/mnt/card";// this can change so fix
579 chdir( current.latin1() ); 517 chdir( current.latin1() );
580 if (TabWidget->getCurrentTab() == 0) { 518 CurrentDir()->cd( current, TRUE);
581// if (TabWidget->currentPageIndex() == 0) { 519 PopulateView();
582 currentDir.cd( current, TRUE);
583 populateLocalView();
584 } else {
585 currentRemoteDir.cd( current, TRUE);
586 populateRemoteView();
587 }
588 update(); 520 update();
589
590} 521}
591 522
592void AdvancedFm::CFButtonPushed() { 523void AdvancedFm::CFButtonPushed()
524{
593 QString current; 525 QString current;
594 if(zaurusDevice) 526 if(zaurusDevice)
595 current= "/mnt/cf"; //zaurus 527 current= "/mnt/cf"; //zaurus
@@ -597,61 +529,64 @@ void AdvancedFm::CFButtonPushed() {
597 current = "/mnt/hda"; //ipaq 529 current = "/mnt/hda"; //ipaq
598 530
599 chdir( current.latin1() ); 531 chdir( current.latin1() );
600 if (TabWidget->getCurrentTab() == 0) { 532 CurrentDir()->cd( current, TRUE);
601// if (TabWidget->currentPageIndex() == 0) { 533 PopulateView();
602 currentDir.cd( current, TRUE);
603 populateLocalView();
604 } else {
605 currentRemoteDir.cd( current, TRUE);
606 populateRemoteView();
607 }
608 update(); 534 update();
609} 535}
610 536
611 537
612 538void AdvancedFm::doAbout()
613void AdvancedFm::doAbout() { 539{
614 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 540 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
615 "is copyright 2002 by\n" 541 "is copyright 2002-2003 by\n"
616 "L.J.Potter<llornkcor@handhelds.org>\n" 542 "L.J.Potter<llornkcor@handhelds.org>\n"
617 "and is licensed by the GPL")); 543 "and is licensed by the GPL"));
618} 544}
619 545
620void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 546void AdvancedFm::keyPressEvent( QKeyEvent *e)
621 if( TabWidget->hasFocus()) 547{
548// e->accept();
549 if( CurrentView()->hasFocus() )
550 {
622 switch ( e->key() ) { 551 switch ( e->key() ) {
623 case Key_Delete: 552 case Key_Delete:
624 del(); 553 del();
625 break; 554 break;
626 case Key_H: 555 case Key_A:
627 showHidden(); 556 copyAs();
628 break;
629 case Key_E:
630 runThis();
631 break; 557 break;
632 case Key_C: 558 case Key_C:
633 copy(); 559 copy();
634 break; 560 break;
635 case Key_A: 561 case Key_E:
636 copyAs(); 562 runThis();
637 break; 563 break;
638 case Key_M: 564 case Key_G:
639 move(); 565 {
566 currentPathCombo->lineEdit()->setFocus();
567 }
640 break; 568 break;
641 case Key_R: 569
642 rn(); 570 case Key_H:
571 showHidden();
643 break; 572 break;
644 case Key_I: 573 case Key_I:
645 fileStatus(); 574 fileStatus();
646 break; 575 break;
647 case Key_U: 576 case Key_M:
648 upDir(); 577 move();
578 break;
579 case Key_N:
580 mkDir();
649 break; 581 break;
650 case Key_P: 582 case Key_P:
651 filePerms(); 583 filePerms();
652 break; 584 break;
653 case Key_N: 585 case Key_R:
654 mkDir(); 586 rn();
587 break;
588 case Key_U:
589 upDir();
655 break; 590 break;
656 case Key_1: 591 case Key_1:
657 switchToLocalTab(); 592 switchToLocalTab();
@@ -679,36 +614,43 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
679 break; 614 break;
680 case Key_0: 615 case Key_0:
681 break; 616 break;
617 };
618 e->accept();
682 } 619 }
683} 620}
684 621
622void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
623{
624 if( CurrentView()->hasFocus() )
625 e->ignore();
626}
627
685 628
686void AdvancedFm::QPEButtonPushed() { 629void AdvancedFm::QPEButtonPushed()
630{
687 QString current = QPEApplication::qpeDir(); 631 QString current = QPEApplication::qpeDir();
688 chdir( current.latin1() ); 632 chdir( current.latin1() );
689 if (TabWidget->getCurrentTab() == 0) { 633 CurrentDir()->cd( current, TRUE);
690// if (TabWidget->currentPageIndex() == 0) { 634 PopulateView();
691 currentDir.cd( current, TRUE);
692 populateLocalView();
693 } else {
694 currentRemoteDir.cd( current, TRUE);
695 populateRemoteView();
696 }
697 update(); 635 update();
698} 636}
699 637
700void AdvancedFm::parsetab(const QString &fileName) { 638void AdvancedFm::parsetab(const QString &fileName)
639{
701 640
702 fileSystemTypeList.clear(); 641 fileSystemTypeList.clear();
703 fsList.clear(); 642 fsList.clear();
704 struct mntent *me; 643 struct mntent *me;
705 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 644 FILE *mntfp = setmntent( fileName.latin1(), "r" );
706 if ( mntfp ) { 645 if ( mntfp )
707 while ( (me = getmntent( mntfp )) != 0 ) { 646 {
647 while ( (me = getmntent( mntfp )) != 0 )
648 {
708 QString deviceName = me->mnt_fsname; 649 QString deviceName = me->mnt_fsname;
709 QString filesystemType = me->mnt_type; 650 QString filesystemType = me->mnt_type;
710 QString mountDir = me->mnt_dir; 651 QString mountDir = me->mnt_dir;
711 if(deviceName != "none") { 652 if(deviceName != "none")
653 {
712 if( fsList.contains(filesystemType) == 0 654 if( fsList.contains(filesystemType) == 0
713 & filesystemType.find("proc",0,TRUE) == -1 655 & filesystemType.find("proc",0,TRUE) == -1
714 & filesystemType.find("cramfs",0,TRUE) == -1 656 & filesystemType.find("cramfs",0,TRUE) == -1
@@ -721,7 +663,8 @@ void AdvancedFm::parsetab(const QString &fileName) {
721 endmntent( mntfp ); 663 endmntent( mntfp );
722} 664}
723 665
724QString AdvancedFm::getFileSystemType(const QString &currentText) { 666QString AdvancedFm::getFileSystemType(const QString &currentText)
667{
725 parsetab("/etc/mtab"); //why did TT forget filesystem type? 668 parsetab("/etc/mtab"); //why did TT forget filesystem type?
726 QString current = currentText;//.right( currentText.length()-1); 669 QString current = currentText;//.right( currentText.length()-1);
727 QString baseFs; 670 QString baseFs;
@@ -737,7 +680,8 @@ QString AdvancedFm::getFileSystemType(const QString &currentText) {
737 return baseFs; 680 return baseFs;
738} 681}
739 682
740QString AdvancedFm::getDiskSpace( const QString &path) { 683QString AdvancedFm::getDiskSpace( const QString &path)
684{
741 struct statfs fss; 685 struct statfs fss;
742 if ( !statfs( path.latin1(), &fss ) ) { 686 if ( !statfs( path.latin1(), &fss ) ) {
743 int blkSize = fss.f_bsize; 687 int blkSize = fss.f_bsize;
@@ -755,17 +699,10 @@ QString AdvancedFm::getDiskSpace( const QString &path) {
755} 699}
756 700
757 701
758void AdvancedFm::showFileMenu() { 702void AdvancedFm::showFileMenu()
759 703{
760 QString curApp; 704 QString curApp;
761 bool isLocalView = false; 705 curApp = CurrentView()->currentItem()->text(0);
762 if (TabWidget->getCurrentTab() == 0) {
763// if (TabWidget->currentPageIndex() == 0) {
764 isLocalView = TRUE;
765 curApp = Local_View->currentItem()->text(0);
766 } else {
767 curApp = Remote_View->currentItem()->text(0);
768 }
769 706
770 MimeType mt( curApp ); 707 MimeType mt( curApp );
771 const AppLnk* app = mt.application(); 708 const AppLnk* app = mt.application();
@@ -773,15 +710,15 @@ void AdvancedFm::showFileMenu() {
773 QPopupMenu *m = new QPopupMenu(0); 710 QPopupMenu *m = new QPopupMenu(0);
774 QPopupMenu *n = new QPopupMenu(0); 711 QPopupMenu *n = new QPopupMenu(0);
775 // QPopupMenu *o = new QPopupMenu(0); 712 // QPopupMenu *o = new QPopupMenu(0);
776 if (TabWidget->getCurrentTab() == 0)
777 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 713 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
778 else
779 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
780 714
781 if ( QFileInfo(fi).isDir() ) { 715 if ( QFileInfo(fi).isDir() )
716 {
782 m->insertSeparator(); 717 m->insertSeparator();
783 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 718 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
784 } else { 719 }
720 else
721 {
785 722
786 if ( app ) 723 if ( app )
787 m->insertItem( app->pixmap(), tr( "Open in " 724 m->insertItem( app->pixmap(), tr( "Open in "
@@ -792,20 +729,12 @@ void AdvancedFm::showFileMenu() {
792 } 729 }
793 730
794 m->insertItem(tr("Actions"),n); 731 m->insertItem(tr("Actions"),n);
795 if(isLocalView) 732 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
796 n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
797 else
798 n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
799 733
800 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 734 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
801 735
802 n->insertSeparator(); 736 n->insertSeparator();
803 737 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
804
805 if(isLocalView)
806 n->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
807 else
808 n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
809 738
810 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 739 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
811 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 740 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
@@ -813,13 +742,7 @@ void AdvancedFm::showFileMenu() {
813 n->insertItem( tr( "Move" ), this, SLOT( move() )); 742 n->insertItem( tr( "Move" ), this, SLOT( move() ));
814 743
815 n->insertSeparator(); 744 n->insertSeparator();
816 745 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
817 if(isLocalView)
818 n->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
819 else
820 n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
821
822
823 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 746 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
824 747
825 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 748 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
@@ -846,16 +769,18 @@ void AdvancedFm::showFileMenu() {
846} 769}
847 770
848 771
849void AdvancedFm::cancelMenuTimer() { 772void AdvancedFm::cancelMenuTimer()
850 773{
851// qDebug("selectionChanged: cancel menu timer"); 774// qDebug("selectionChanged: cancel menu timer");
852 if( menuTimer.isActive() ) 775 if( menuTimer.isActive() )
853 menuTimer.stop(); 776 menuTimer.stop();
854} 777}
855 778
856QString AdvancedFm::checkDiskSpace(const QString &path) { 779QString AdvancedFm::checkDiskSpace(const QString &path)
780{
857 struct statfs fss; 781 struct statfs fss;
858 if ( !statfs( path.latin1(), &fss ) ) { 782 if ( !statfs( path.latin1(), &fss ) )
783 {
859 int blkSize = fss.f_bsize; 784 int blkSize = fss.f_bsize;
860// int totalBlks = fs.f_blocks; 785// int totalBlks = fs.f_blocks;
861 int availBlks = fss.f_bavail; 786 int availBlks = fss.f_bavail;
@@ -871,26 +796,18 @@ QString AdvancedFm::checkDiskSpace(const QString &path) {
871 return ""; 796 return "";
872} 797}
873 798
874void AdvancedFm::addToDocs() { 799void AdvancedFm::addToDocs()
800{
875 QStringList strListPaths = getPath(); 801 QStringList strListPaths = getPath();
876 if( strListPaths.count() > 0) { 802 QDir *thisDir = CurrentDir();
803
804 if( strListPaths.count() > 0)
805 {
877 QString curFile; 806 QString curFile;
878 if (TabWidget->getCurrentTab() == 0) { 807 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
879// if (TabWidget->currentPageIndex() == 0) { 808 {
880 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { 809 curFile = thisDir->canonicalPath()+"/"+(*it);
881 curFile = currentDir.canonicalPath()+"/"+(*it);
882// qDebug(curFile);
883 DocLnk f;
884// curFile.replace(QRegExp("\\..*"),"");
885 f.setName((*it));
886 f.setFile( curFile);
887 f.writeLink();
888 }
889 } else {
890 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
891 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
892// qDebug(curFile); 810// qDebug(curFile);
893
894 DocLnk f; 811 DocLnk f;
895// curFile.replace(QRegExp("\\..*"),""); 812// curFile.replace(QRegExp("\\..*"),"");
896 f.setName((*it)); 813 f.setName((*it));
@@ -899,7 +816,6 @@ void AdvancedFm::addToDocs() {
899 } 816 }
900 } 817 }
901 } 818 }
902}
903 819
904 820
905void AdvancedFm::customDirsToMenu() 821void AdvancedFm::customDirsToMenu()
@@ -948,14 +864,7 @@ void AdvancedFm::addCustomDir()
948 QString dir; 864 QString dir;
949 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 865 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
950 866
951 if (TabWidget->getCurrentTab() == 0) 867 dir = CurrentDir()->canonicalPath();
952 {
953 dir = currentDir.canonicalPath();
954 }
955 else
956 {
957 dir = currentRemoteDir.canonicalPath();
958 }
959 868
960 bool addIt=true; 869 bool addIt=true;
961 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 870 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
@@ -984,15 +893,7 @@ void AdvancedFm::removeCustomDir()
984 QString dir; 893 QString dir;
985 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 894 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
986 QStringList list2; 895 QStringList list2;
987 896 dir = CurrentDir()->canonicalPath();
988 if (TabWidget->getCurrentTab() == 0)
989 {
990 dir = currentDir.canonicalPath();
991 }
992 else
993 {
994 dir = currentRemoteDir.canonicalPath();
995 }
996 int ramble=2; 897 int ramble=2;
997// int ramble=-24; 898// int ramble=-24;
998//first remove list 899//first remove list
@@ -1029,6 +930,7 @@ void AdvancedFm::gotoCustomDir(const QString &dir)
1029{ 930{
1030// qDebug("gotoCustomDir(const QString &dir) " +dir ); 931// qDebug("gotoCustomDir(const QString &dir) " +dir );
1031 QString curDir = dir; 932 QString curDir = dir;
933 QDir *thisDir = CurrentDir();
1032// if( curDir.isEmpty()) { 934// if( curDir.isEmpty()) {
1033// } 935// }
1034 if( curDir == s_addBookmark) 936 if( curDir == s_addBookmark)
@@ -1043,42 +945,58 @@ void AdvancedFm::gotoCustomDir(const QString &dir)
1043 { 945 {
1044 if(QDir( curDir).exists() ) 946 if(QDir( curDir).exists() )
1045 { 947 {
1046 if (TabWidget->getCurrentTab() == 0) 948 thisDir->setPath( curDir );
1047 {
1048 currentDir.setPath( curDir );
1049 chdir( curDir.latin1() ); 949 chdir( curDir.latin1() );
1050 currentDir.cd( curDir, TRUE); 950 thisDir->cd( curDir, TRUE);
1051 populateLocalView(); 951 PopulateView();
952 }
953 }
954}
955
956QDir *AdvancedFm::CurrentDir()
957{
958 if ( whichTab == 1)
959 {
960 return &currentDir;
1052 } 961 }
1053 else 962 else
1054 { 963 {
1055 currentRemoteDir.setPath( curDir ); 964 return &currentRemoteDir;
1056 chdir( curDir.latin1() );
1057 currentRemoteDir.cd( curDir, TRUE);
1058 populateRemoteView();
1059 } 965 }
1060 } 966 }
967
968QDir *AdvancedFm::OtherDir()
969{
970 if ( whichTab == 1)
971 {
972 return &currentRemoteDir;
1061 } 973 }
1062// menuButton 974 else
1063// qDebug("gotoCustomDir(const QString &dir) " +dir ); 975 {
1064// QString curDir = dir; 976 return &currentDir;
1065// if(QDir( curDir).exists() ) 977 }
1066// { 978}
1067// if (TabWidget->getCurrentTab() == 0) 979
1068// { 980void AdvancedFm::PopulateView()
1069// currentDir.setPath( curDir ); 981{
1070// chdir( curDir.latin1() ); 982 if ( whichTab == 1)
1071// currentDir.cd( curDir, TRUE); 983 populateLocalView();
1072// populateLocalView(); 984 else
1073// } 985 populateRemoteView();
1074// else 986}
1075// { 987
1076// currentRemoteDir.setPath( curDir ); 988QListView * AdvancedFm::CurrentView()
1077// chdir( curDir.latin1() ); 989{
1078// currentRemoteDir.cd( curDir, TRUE); 990 if ( whichTab == 1)
1079// populateRemoteView(); 991 return Local_View;
1080// } 992 else
1081// } 993 return Remote_View;
1082// menuButton->setLabel(" "); 994}
1083// menuButton 995
996QListView * AdvancedFm::OtherView()
997{
998 if ( whichTab == 1)
999 return Remote_View;
1000 else
1001 return Local_View;
1084} 1002}