summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp200
1 files changed, 44 insertions, 156 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 74654fc..fc6c3bf 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -53,358 +53,246 @@
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qlineedit.h> 54#include <qlineedit.h>
55#include <qregexp.h> 55#include <qregexp.h>
56 56
57#include <unistd.h> 57#include <unistd.h>
58#include <stdlib.h> 58#include <stdlib.h>
59#include <sys/stat.h> 59#include <sys/stat.h>
60#include <dirent.h> 60#include <dirent.h>
61#include <stdio.h> 61#include <stdio.h>
62#include <time.h> 62#include <time.h>
63#include <fcntl.h> 63#include <fcntl.h>
64#include <mntent.h> 64#include <mntent.h>
65#include <string.h> 65#include <string.h>
66#include <errno.h> 66#include <errno.h>
67#include <sys/vfs.h> 67#include <sys/vfs.h>
68#include <mntent.h> 68#include <mntent.h>
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 TabWidget->setCurrentTab(1);
78 populateRemoteView(); 78 populateView();
79 TabWidget->setCurrentTab(0);
80 populateView();
79 currentPathCombo->setFocus(); 81 currentPathCombo->setFocus();
80} 82}
81 83
82AdvancedFm::~AdvancedFm() { 84AdvancedFm::~AdvancedFm() {
83} 85}
84 86
85 87
86void AdvancedFm::cleanUp() 88void AdvancedFm::cleanUp()
87{ 89{
88 QString sfile=QDir::homeDirPath(); 90 QString sfile=QDir::homeDirPath();
89 if(sfile.right(1) != "/") 91 if(sfile.right(1) != "/")
90 sfile+="/._temp"; 92 sfile+="/._temp";
91 else 93 else
92 sfile+="._temp"; 94 sfile+="._temp";
93 QFile file( sfile); 95 QFile file( sfile);
94 if(file.exists()) 96 if(file.exists())
95 file.remove(); 97 file.remove();
96} 98}
97 99
98void AdvancedFm::tabChanged(QWidget *w) 100void AdvancedFm::tabChanged(QWidget *w)
99{ 101{
100 if( w == tab) 102 if( w == tab)
101 whichTab = 1; 103 whichTab = 1;
102 else 104 else
103 whichTab = 2; 105 whichTab = 2;
104 106
105 //qDebug("tab changed %d", whichTab ); 107 //qDebug("tab changed %d", whichTab );
106 108
107 QString path = CurrentDir()->canonicalPath(); 109 QString path = CurrentDir()->canonicalPath();
108 currentPathCombo->lineEdit()->setText( path ); 110 currentPathCombo->lineEdit()->setText( path );
109 111
110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 112 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 113 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
112 114
113 QString fs= getFileSystemType( (const QString &) path); 115 QString fs= getFileSystemType( (const QString &) path);
114 116
115 setCaption("AdvancedFm :: "+fs+" :: " 117 setCaption("AdvancedFm :: "+fs+" :: "
116 +checkDiskSpace( (const QString &) path )+ " kB free" ); 118 +checkDiskSpace( (const QString &) path )+ " kB free" );
117 chdir( path.latin1()); 119 chdir( path.latin1());
120 //2populateView();
118} 121}
119 122
120 123
121void AdvancedFm::populateLocalView() 124void AdvancedFm::populateView()
122{ 125{
123 QPixmap pm; 126 QPixmap pm;
124 Local_View->clear(); 127 QListView *thisView = CurrentView();
125 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 128 QDir *thisDir = CurrentDir();
126 currentDir.setMatchAllDirs(TRUE); 129 QString path = thisDir->canonicalPath();
127 currentDir.setNameFilter(filterStr); 130
131 thisView->clear();
132 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
133 thisDir->setMatchAllDirs(TRUE);
134 thisDir->setNameFilter(filterStr);
128 QString fileL, fileS, fileDate; 135 QString fileL, fileS, fileDate;
129 QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); 136 QString fs= getFileSystemType((const QString &) path);
130 setCaption("AdvancedFm :: "+fs+" :: " 137 setCaption("AdvancedFm :: "+fs+" :: "
131 +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); 138 +checkDiskSpace((const QString &) path)+" kB free" );
132 bool isDir=FALSE; 139 bool isDir=FALSE;
133 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 140 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
134 QFileInfoListIterator it(*list); 141 QFileInfoListIterator it(*list);
135 QFileInfo *fi; 142 QFileInfo *fi;
136 while ( (fi=it.current()) ) 143 while ( (fi=it.current()) )
137 { 144 {
138 if (fi->isSymLink() ) 145 if (fi->isSymLink() )
139 { 146 {
140 QString symLink=fi->readLink(); 147 QString symLink=fi->readLink();
141 QFileInfo sym( symLink); 148 QFileInfo sym( symLink);
142 fileS.sprintf( "%10i", sym.size() ); 149 fileS.sprintf( "%10i", sym.size() );
143 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 150 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
144 fileDate = sym.lastModified().toString(); 151 fileDate = sym.lastModified().toString();
145 } 152 }
146 else 153 else
147 { 154 {
148 fileS.sprintf( "%10i", fi->size() ); 155 fileS.sprintf( "%10i", fi->size() );
149 fileL.sprintf( "%s",fi->fileName().data() ); 156 fileL.sprintf( "%s",fi->fileName().data() );
150 fileDate= fi->lastModified().toString(); 157 fileDate= fi->lastModified().toString();
151 if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) 158 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() )
152 { 159 {
153 fileL+="/"; 160 fileL+="/";
154 isDir=TRUE; 161 isDir=TRUE;
155 } 162 }
156 } 163 }
157 QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); 164
165 QFileInfo fileInfo( path + "/" + fileL);
166
158 if(fileL !="./" && fi->exists()) 167 if(fileL !="./" && fi->exists())
159 { 168 {
160 item= new QListViewItem( Local_View, fileL, fileS , fileDate); 169 item= new QListViewItem( thisView, fileL, fileS , fileDate);
161 170
162 if(isDir || fileL.find("/",0,TRUE) != -1) 171 if(isDir || fileL.find("/",0,TRUE) != -1)
163 { 172 {
164 173
165 if( !QDir( fi->filePath() ).isReadable()) //is directory 174 if( !QDir( fi->filePath() ).isReadable()) //is directory
166 pm = Resource::loadPixmap( "lockedfolder" ); 175 pm = Resource::loadPixmap( "lockedfolder" );
167 else 176 else
168 pm= Resource::loadPixmap( "folder" ); 177 pm= Resource::loadPixmap( "folder" );
169 } 178 }
170 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) 179 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
171 { 180 {
172 pm = Resource::loadPixmap( "exec"); 181 pm = Resource::loadPixmap( "exec");
173 } 182 }
174 else if( (fileInfo.permission( QFileInfo::ExeUser) 183 else if( (fileInfo.permission( QFileInfo::ExeUser)
175 | fileInfo.permission( QFileInfo::ExeGroup) 184 | fileInfo.permission( QFileInfo::ExeGroup)
176 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) 185 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
177 { 186 {
178 pm = Resource::loadPixmap( "exec"); 187 pm = Resource::loadPixmap( "exec");
179 } 188 }
180 else if( !fi->isReadable() ) 189 else if( !fi->isReadable() )
181 { 190 {
182 pm = Resource::loadPixmap( "locked" ); 191 pm = Resource::loadPixmap( "locked" );
183 } 192 }
184 else { //everything else goes by mimetype 193 else { //everything else goes by mimetype
185 MimeType mt(fi->filePath()); 194 MimeType mt(fi->filePath());
186 pm=mt.pixmap(); //sets the correct pixmap for mimetype 195 pm=mt.pixmap(); //sets the correct pixmap for mimetype
187 if(pm.isNull()) 196 if(pm.isNull())
188 pm = Resource::loadPixmap( "UnknownDocument-14" ); 197 pm = Resource::loadPixmap( "UnknownDocument-14" );
189 } 198 }
190 item->setPixmap( 0,pm); 199 item->setPixmap( 0,pm);
191 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) 200 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
192 { 201 {
193 // overlay link image 202 // overlay link image
194 pm= Resource::loadPixmap( "folder" ); 203 pm= Resource::loadPixmap( "folder" );
195 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 204 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
196 QPainter painter( &pm ); 205 QPainter painter( &pm );
197 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 206 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
198 pm.setMask( pm.createHeuristicMask( FALSE ) ); 207 pm.setMask( pm.createHeuristicMask( FALSE ) );
199 item->setPixmap( 0, pm); 208 item->setPixmap( 0, pm);
200 } 209 }
201 } 210 }
202 isDir=FALSE; 211 isDir=FALSE;
203 ++it; 212 ++it;
204 } 213 }
205 214
206 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) 215 if( path.find("dev",0,TRUE) != -1)
207 { 216 {
208 struct stat buf; 217 struct stat buf;
209 dev_t devT; 218 dev_t devT;
210 DIR *dir; 219 DIR *dir;
211 struct dirent *mydirent; 220 struct dirent *mydirent;
212 221
213 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) 222 if((dir = opendir( path.latin1())) != NULL)
214 while ((mydirent = readdir(dir)) != NULL) 223 while ((mydirent = readdir(dir)) != NULL)
215 { 224 {
216 lstat( mydirent->d_name, &buf); 225 lstat( mydirent->d_name, &buf);
217// qDebug(mydirent->d_name); 226// qDebug(mydirent->d_name);
218 fileL.sprintf("%s", mydirent->d_name); 227 fileL.sprintf("%s", mydirent->d_name);
219 devT = buf.st_dev; 228 devT = buf.st_dev;
220 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 229 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
221 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 230 fileDate.sprintf("%s", ctime( &buf.st_mtime));
222 if( fileL.find(".") == -1 ) 231 if( fileL.find(".") == -1 )
223 { 232 {
224 item= new QListViewItem( Local_View, fileL, fileS, fileDate); 233 item= new QListViewItem( thisView, fileL, fileS, fileDate);
225 pm = Resource::loadPixmap( "UnknownDocument-14" ); 234 pm = Resource::loadPixmap( "UnknownDocument-14" );
226 item->setPixmap( 0,pm); 235 item->setPixmap( 0,pm);
227 } 236 }
228 } 237 }
229 238
230 closedir(dir); 239 closedir(dir);
231 } 240 }
232 241
233 Local_View->setSorting( 3,FALSE); 242 thisView->setSorting( 3,FALSE);
234 fillCombo( (const QString &) currentDir.canonicalPath()); 243 fillCombo( (const QString &) path );
235} 244}
236 245
237 246
238void AdvancedFm::populateRemoteView()
239{
240 QPixmap pm;
241 Remote_View->clear();
242 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
243 currentRemoteDir.setMatchAllDirs(TRUE);
244 currentRemoteDir.setNameFilter(filterStr);
245 QString fileL, fileS, fileDate;
246
247 QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
248 setCaption("AdvancedFm :: "+fs+" :: "
249 +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" );
250 bool isDir=FALSE;
251 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
252 QFileInfoListIterator it(*list);
253 QFileInfo *fi;
254 while ( (fi=it.current()) )
255 {
256 if (fi->isSymLink() )
257 {
258 QString symLink=fi->readLink();
259 // qDebug("Symlink detected "+symLink);
260 QFileInfo sym( symLink);
261 fileS.sprintf( "%10i", sym.size() );
262 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
263 fileDate = sym.lastModified().toString();
264 }
265 else
266 {
267 // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
268 fileS.sprintf( "%10i", fi->size() );
269 fileL.sprintf( "%s",fi->fileName().data() );
270 fileDate= fi->lastModified().toString();
271
272 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() )
273 {
274 fileL+="/";
275 isDir=TRUE;
276 // qDebug( fileL);
277 }
278 }
279
280 QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL);
281 if(fileL !="./" && fi->exists())
282 {
283 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
284 QPixmap pm;
285
286 if(isDir || fileL.find("/",0,TRUE) != -1)
287 {
288 if( !QDir( fi->filePath() ).isReadable())
289 pm = Resource::loadPixmap( "lockedfolder" );
290 else
291 pm= Resource::loadPixmap( "folder" );
292 }
293 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
294 {
295 pm = Resource::loadPixmap( "exec");
296 }
297 else if( (fileInfo.permission( QFileInfo::ExeUser)
298 | fileInfo.permission( QFileInfo::ExeGroup)
299 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
300 {
301 pm = Resource::loadPixmap( "exec");
302 }
303 else if( !fi->isReadable() )
304 {
305 pm = Resource::loadPixmap( "locked" );
306 }
307 else
308 {
309 MimeType mt(fi->filePath());
310 pm=mt.pixmap(); //sets the correct pixmap for mimetype
311 if(pm.isNull())
312 pm = Resource::loadPixmap( "UnknownDocument-14" );
313 }
314 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
315 {
316 // overlay link image
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);
339// qDebug(mydirent->d_name);
340 fileL.sprintf("%s", mydirent->d_name);
341 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
342 fileDate.sprintf("%s", ctime( &buf.st_mtime));
343
344 if( fileL.find(".") == -1 )
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 }
354
355 Remote_View->setSorting( 3,FALSE);
356 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
357}
358
359void AdvancedFm::ListClicked(QListViewItem *selectedItem) 247void AdvancedFm::ListClicked(QListViewItem *selectedItem)
360{ 248{
361 if(selectedItem) 249 if(selectedItem)
362 { 250 {
363 QString strItem=selectedItem->text(0); 251 QString strItem=selectedItem->text(0);
364 QString strSize=selectedItem->text(1); 252 QString strSize=selectedItem->text(1);
365 strSize=strSize.stripWhiteSpace(); 253 strSize=strSize.stripWhiteSpace();
366 bool isDirectory = false; 254 bool isDirectory = false;
367 QString strItem2; 255 QString strItem2;
368 256
369 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink 257 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
370 { 258 {
371 strItem2 = dealWithSymName((const QString&)strItem); 259 strItem2 = dealWithSymName((const QString&)strItem);
372 if(QDir(strItem2).exists() ) 260 if(QDir(strItem2).exists() )
373 strItem = strItem2; 261 strItem = strItem2;
374 } 262 }
375 263
376 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) 264 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
377 { 265 {
378 266
379 if(QDir(strItem).exists()) 267 if(QDir(strItem).exists())
380 isDirectory = true; 268 isDirectory = true;
381 } 269 }
382 270
383 if( isDirectory ) 271 if( isDirectory )
384 { 272 {
385 CurrentDir()->cd( strItem, TRUE); 273 CurrentDir()->cd( strItem, TRUE);
386 PopulateView(); 274 populateView();
387 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 275 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
388 } 276 }
389 chdir( strItem.latin1()); 277 chdir( strItem.latin1());
390 } 278 }
391} 279}
392 280
393void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 281void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
394 switch (mouse) { 282 switch (mouse) {
395 case 1: 283 case 1:
396 { 284 {
397 if(renameBox != 0 ) 285 if(renameBox != 0 )
398 { 286 {
399 cancelRename(); 287 cancelRename();
400 } 288 }
401 289
402 } 290 }
403 break; 291 break;
404 case 2: 292 case 2:
405 menuTimer.start( 500, TRUE ); 293 menuTimer.start( 500, TRUE );
406 break; 294 break;
407 }; 295 };
408} 296}
409 297
410void AdvancedFm::switchToLocalTab() 298void AdvancedFm::switchToLocalTab()
@@ -413,145 +301,145 @@ void AdvancedFm::switchToLocalTab()
413 Local_View->setFocus(); 301 Local_View->setFocus();
414} 302}
415 303
416void AdvancedFm::switchToRemoteTab() 304void AdvancedFm::switchToRemoteTab()
417{ 305{
418 TabWidget->setCurrentTab(1); 306 TabWidget->setCurrentTab(1);
419 Remote_View->setFocus(); 307 Remote_View->setFocus();
420} 308}
421 309
422void AdvancedFm::readConfig() 310void AdvancedFm::readConfig()
423{ 311{
424 Config cfg("AdvancedFm"); 312 Config cfg("AdvancedFm");
425} 313}
426 314
427void AdvancedFm::writeConfig() 315void AdvancedFm::writeConfig()
428{ 316{
429 Config cfg("AdvancedFm"); 317 Config cfg("AdvancedFm");
430} 318}
431 319
432void AdvancedFm::currentPathComboChanged() 320void AdvancedFm::currentPathComboChanged()
433{ 321{
434 if(QDir( currentPathCombo->lineEdit()->text()).exists()) 322 if(QDir( currentPathCombo->lineEdit()->text()).exists())
435 { 323 {
436 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 324 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
437 PopulateView(); 325 populateView();
438 } 326 }
439 else 327 else
440 { 328 {
441 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 329 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
442 } 330 }
443} 331}
444 332
445void AdvancedFm::fillCombo(const QString &currentPath) 333void AdvancedFm::fillCombo(const QString &currentPath)
446{ 334{
447// qDebug("%d",TabWidget->getCurrentTab()); 335// qDebug("%d",TabWidget->getCurrentTab());
448 if ( whichTab == 1) 336 if ( whichTab == 1)
449 { 337 {
450 currentPathCombo->lineEdit()->setText( currentPath); 338 currentPathCombo->lineEdit()->setText( currentPath);
451 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 339 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
452 { 340 {
453 currentPathCombo->clear(); 341 currentPathCombo->clear();
454 localDirPathStringList.prepend( currentPath ); 342 localDirPathStringList.prepend( currentPath );
455 currentPathCombo->insertStringList( localDirPathStringList,-1); 343 currentPathCombo->insertStringList( localDirPathStringList,-1);
456 } 344 }
457 } 345 }
458 else 346 else
459 { 347 {
460 currentPathCombo->lineEdit()->setText( currentPath); 348 currentPathCombo->lineEdit()->setText( currentPath);
461 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 349 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
462 { 350 {
463 currentPathCombo->clear(); 351 currentPathCombo->clear();
464 remoteDirPathStringList.prepend( currentPath ); 352 remoteDirPathStringList.prepend( currentPath );
465 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 353 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
466 } 354 }
467 } 355 }
468} 356}
469 357
470void AdvancedFm::currentPathComboActivated(const QString & currentPath) 358void AdvancedFm::currentPathComboActivated(const QString & currentPath)
471{ 359{
472 chdir( currentPath.latin1() ); 360 chdir( currentPath.latin1() );
473 CurrentDir()->cd( currentPath, TRUE); 361 CurrentDir()->cd( currentPath, TRUE);
474 PopulateView(); 362 populateView();
475 update(); 363 update();
476} 364}
477 365
478QStringList AdvancedFm::getPath() 366QStringList AdvancedFm::getPath()
479{ 367{
480 QStringList strList; 368 QStringList strList;
481 QListView *thisView=CurrentView(); 369 QListView *thisView=CurrentView();
482 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 370 QList<QListViewItem> * getSelectedItems( QListView * thisView );
483 QListViewItemIterator it( thisView ); 371 QListViewItemIterator it( thisView );
484 for ( ; it.current(); ++it ) 372 for ( ; it.current(); ++it )
485 { 373 {
486 if ( it.current()->isSelected() ) 374 if ( it.current()->isSelected() )
487 { 375 {
488 strList << it.current()->text(0); 376 strList << it.current()->text(0);
489// qDebug(it.current()->text(0)); 377// qDebug(it.current()->text(0));
490 } 378 }
491 } 379 }
492 return strList; 380 return strList;
493} 381}
494 382
495void AdvancedFm::homeButtonPushed() 383void AdvancedFm::homeButtonPushed()
496{ 384{
497 QString current = QDir::homeDirPath(); 385 QString current = QDir::homeDirPath();
498 chdir( current.latin1() ); 386 chdir( current.latin1() );
499 CurrentDir()->cd( current, TRUE); 387 CurrentDir()->cd( current, TRUE);
500 PopulateView(); 388 populateView();
501 update(); 389 update();
502} 390}
503 391
504void AdvancedFm::docButtonPushed() 392void AdvancedFm::docButtonPushed()
505{ 393{
506 QString current = QPEApplication::documentDir(); 394 QString current = QPEApplication::documentDir();
507 chdir( current.latin1() ); 395 chdir( current.latin1() );
508 396
509 CurrentDir()->cd( current, TRUE); 397 CurrentDir()->cd( current, TRUE);
510 PopulateView(); 398 populateView();
511 update(); 399 update();
512} 400}
513 401
514void AdvancedFm::SDButtonPushed() 402void AdvancedFm::SDButtonPushed()
515{ 403{
516 QString current = "/mnt/card";// this can change so fix 404 QString current = "/mnt/card";// this can change so fix
517 chdir( current.latin1() ); 405 chdir( current.latin1() );
518 CurrentDir()->cd( current, TRUE); 406 CurrentDir()->cd( current, TRUE);
519 PopulateView(); 407 populateView();
520 update(); 408 update();
521} 409}
522 410
523void AdvancedFm::CFButtonPushed() 411void AdvancedFm::CFButtonPushed()
524{ 412{
525 QString current; 413 QString current;
526 if(zaurusDevice) 414 if(zaurusDevice)
527 current= "/mnt/cf"; //zaurus 415 current= "/mnt/cf"; //zaurus
528 else 416 else
529 current = "/mnt/hda"; //ipaq 417 current = "/mnt/hda"; //ipaq
530 418
531 chdir( current.latin1() ); 419 chdir( current.latin1() );
532 CurrentDir()->cd( current, TRUE); 420 CurrentDir()->cd( current, TRUE);
533 PopulateView(); 421 populateView();
534 update(); 422 update();
535} 423}
536 424
537 425
538void AdvancedFm::doAbout() 426void AdvancedFm::doAbout()
539{ 427{
540 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 428 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
541 "is copyright 2002-2003 by\n" 429 "is copyright 2002-2003 by\n"
542 "L.J.Potter<llornkcor@handhelds.org>\n" 430 "L.J.Potter<llornkcor@handhelds.org>\n"
543 "and is licensed by the GPL")); 431 "and is licensed by the GPL"));
544} 432}
545 433
546void AdvancedFm::keyPressEvent( QKeyEvent *e) 434void AdvancedFm::keyPressEvent( QKeyEvent *e)
547{ 435{
548// e->accept(); 436// e->accept();
549 if( CurrentView()->hasFocus() ) 437 if( CurrentView()->hasFocus() )
550 { 438 {
551 switch ( e->key() ) { 439 switch ( e->key() ) {
552 case Key_Delete: 440 case Key_Delete:
553 del(); 441 del();
554 break; 442 break;
555 case Key_A: 443 case Key_A:
556 copyAs(); 444 copyAs();
557 break; 445 break;
@@ -610,49 +498,49 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e)
610 break; 498 break;
611 case Key_8: 499 case Key_8:
612 break; 500 break;
613 case Key_9: 501 case Key_9:
614 break; 502 break;
615 case Key_0: 503 case Key_0:
616 break; 504 break;
617 }; 505 };
618 e->accept(); 506 e->accept();
619 } 507 }
620} 508}
621 509
622void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 510void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
623{ 511{
624 if( CurrentView()->hasFocus() ) 512 if( CurrentView()->hasFocus() )
625 e->ignore(); 513 e->ignore();
626} 514}
627 515
628 516
629void AdvancedFm::QPEButtonPushed() 517void AdvancedFm::QPEButtonPushed()
630{ 518{
631 QString current = QPEApplication::qpeDir(); 519 QString current = QPEApplication::qpeDir();
632 chdir( current.latin1() ); 520 chdir( current.latin1() );
633 CurrentDir()->cd( current, TRUE); 521 CurrentDir()->cd( current, TRUE);
634 PopulateView(); 522 populateView();
635 update(); 523 update();
636} 524}
637 525
638void AdvancedFm::parsetab(const QString &fileName) 526void AdvancedFm::parsetab(const QString &fileName)
639{ 527{
640 528
641 fileSystemTypeList.clear(); 529 fileSystemTypeList.clear();
642 fsList.clear(); 530 fsList.clear();
643 struct mntent *me; 531 struct mntent *me;
644 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 532 FILE *mntfp = setmntent( fileName.latin1(), "r" );
645 if ( mntfp ) 533 if ( mntfp )
646 { 534 {
647 while ( (me = getmntent( mntfp )) != 0 ) 535 while ( (me = getmntent( mntfp )) != 0 )
648 { 536 {
649 QString deviceName = me->mnt_fsname; 537 QString deviceName = me->mnt_fsname;
650 QString filesystemType = me->mnt_type; 538 QString filesystemType = me->mnt_type;
651 QString mountDir = me->mnt_dir; 539 QString mountDir = me->mnt_dir;
652 if(deviceName != "none") 540 if(deviceName != "none")
653 { 541 {
654 if( fsList.contains(filesystemType) == 0 542 if( fsList.contains(filesystemType) == 0
655 & filesystemType.find("proc",0,TRUE) == -1 543 & filesystemType.find("proc",0,TRUE) == -1
656 & filesystemType.find("cramfs",0,TRUE) == -1 544 & filesystemType.find("cramfs",0,TRUE) == -1
657 & filesystemType.find("auto",0,TRUE) == -1) 545 & filesystemType.find("auto",0,TRUE) == -1)
658 fsList << filesystemType; 546 fsList << filesystemType;
@@ -927,76 +815,76 @@ void AdvancedFm::removeCustomDir()
927} 815}
928 816
929void AdvancedFm::gotoCustomDir(const QString &dir) 817void AdvancedFm::gotoCustomDir(const QString &dir)
930{ 818{
931// qDebug("gotoCustomDir(const QString &dir) " +dir ); 819// qDebug("gotoCustomDir(const QString &dir) " +dir );
932 QString curDir = dir; 820 QString curDir = dir;
933 QDir *thisDir = CurrentDir(); 821 QDir *thisDir = CurrentDir();
934// if( curDir.isEmpty()) { 822// if( curDir.isEmpty()) {
935// } 823// }
936 if( curDir == s_addBookmark) 824 if( curDir == s_addBookmark)
937 { 825 {
938 addCustomDir(); 826 addCustomDir();
939 } 827 }
940 if( curDir == s_removeBookmark) 828 if( curDir == s_removeBookmark)
941 { 829 {
942 removeCustomDir( ); 830 removeCustomDir( );
943 } 831 }
944 else 832 else
945 { 833 {
946 if(QDir( curDir).exists() ) 834 if(QDir( curDir).exists() )
947 { 835 {
948 thisDir->setPath( curDir ); 836 thisDir->setPath( curDir );
949 chdir( curDir.latin1() ); 837 chdir( curDir.latin1() );
950 thisDir->cd( curDir, TRUE); 838 thisDir->cd( curDir, TRUE);
951 PopulateView(); 839 populateView();
952 } 840 }
953 } 841 }
954} 842}
955 843
956QDir *AdvancedFm::CurrentDir() 844QDir *AdvancedFm::CurrentDir()
957{ 845{
958 if ( whichTab == 1) 846 if ( whichTab == 1)
959 { 847 {
960 return &currentDir; 848 return &currentDir;
961 } 849 }
962 else 850 else
963 { 851 {
964 return &currentRemoteDir; 852 return &currentRemoteDir;
965 } 853 }
966} 854}
967 855
968QDir *AdvancedFm::OtherDir() 856QDir *AdvancedFm::OtherDir()
969{ 857{
970 if ( whichTab == 1) 858 if ( whichTab == 1)
971 { 859 {
972 return &currentRemoteDir; 860 return &currentRemoteDir;
973 } 861 }
974 else 862 else
975 { 863 {
976 return &currentDir; 864 return &currentDir;
977 } 865 }
978} 866}
979 867
980void AdvancedFm::PopulateView()
981{
982 if ( whichTab == 1)
983 populateLocalView();
984 else
985 populateRemoteView();
986}
987
988QListView * AdvancedFm::CurrentView() 868QListView * AdvancedFm::CurrentView()
989{ 869{
990 if ( whichTab == 1) 870 if ( whichTab == 1)
991 return Local_View; 871 return Local_View;
992 else 872 else
993 return Remote_View; 873 return Remote_View;
994} 874}
995 875
996QListView * AdvancedFm::OtherView() 876QListView * AdvancedFm::OtherView()
997{ 877{
998 if ( whichTab == 1) 878 if ( whichTab == 1)
999 return Remote_View; 879 return Remote_View;
1000 else 880 else
1001 return Local_View; 881 return Local_View;
1002} 882}
883
884void AdvancedFm::setOtherTabCurrent()
885{
886 if ( whichTab == 1)
887 TabWidget->setCurrentTab(1);
888 else
889 TabWidget->setCurrentTab(0);
890}