Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index f1be471..0dc822d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -22,125 +22,123 @@ | |||
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/menubutton.h> | 24 | #include <qpe/menubutton.h> |
25 | 25 | ||
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | 31 | ||
32 | 32 | ||
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | #include <time.h> | 34 | #include <time.h> |
35 | #include <dirent.h> | 35 | #include <dirent.h> |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> |
37 | #include <sys/vfs.h> | 37 | #include <sys/vfs.h> |
38 | #include <mntent.h> | 38 | #include <mntent.h> |
39 | 39 | ||
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | 41 | ||
42 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | 42 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) |
43 | : QMainWindow( ) { | 43 | : QMainWindow( ) { |
44 | init(); | 44 | init(); |
45 | renameBox = 0; | 45 | renameBox = 0; |
46 | 46 | whichTab = 1; | |
47 | unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); | 47 | unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); |
48 | 48 | ||
49 | initConnections(); | 49 | initConnections(); |
50 | rePopulate(); | 50 | rePopulate(); |
51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
52 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); | 52 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); |
53 | switchToLocalTab(); | 53 | switchToLocalTab(); |
54 | } | 54 | } |
55 | 55 | ||
56 | AdvancedFm::~AdvancedFm() { | 56 | AdvancedFm::~AdvancedFm() { |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | void AdvancedFm::cleanUp() { | 60 | void AdvancedFm::cleanUp() { |
61 | QString sfile=QDir::homeDirPath(); | 61 | QString sfile=QDir::homeDirPath(); |
62 | if(sfile.right(1) != "/") | 62 | if(sfile.right(1) != "/") |
63 | sfile+="/._temp"; | 63 | sfile+="/._temp"; |
64 | else | 64 | else |
65 | sfile+="._temp"; | 65 | sfile+="._temp"; |
66 | QFile file( sfile); | 66 | QFile file( sfile); |
67 | if(file.exists()) | 67 | if(file.exists()) |
68 | file.remove(); | 68 | file.remove(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void AdvancedFm::tabChanged(QWidget *wd) { | 71 | void AdvancedFm::tabChanged(QWidget *wd) { |
72 | // qDebug("tabChanged"); | 72 | // qDebug("tabChanged"); |
73 | if(wd == tab) { | 73 | if(wd == tab) { |
74 | whichTab = 1; | 74 | whichTab = 1; |
75 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); | 75 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); |
76 | } | 76 | } |
77 | else if(wd == tab_2) { | 77 | else if(wd == tab_2) { |
78 | whichTab = 2; | 78 | whichTab = 2; |
79 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 79 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
80 | } | 80 | } |
81 | qApp->processEvents(); | 81 | qApp->processEvents(); |
82 | QString path = CurrentDir()->canonicalPath(); | 82 | QString path = CurrentDir()->canonicalPath(); |
83 | // qDebug(path); | 83 | // qDebug(path); |
84 | if ( TabWidget->currentWidget() == tab) { | 84 | if ( TabWidget->currentWidget() == tab) { |
85 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 85 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
86 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 86 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
87 | } else { | 87 | } else { |
88 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 88 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
89 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 89 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
90 | } | 90 | } |
91 | 91 | ||
92 | QString fs= getFileSystemType( (const QString &) path); | ||
93 | |||
94 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | ||
95 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | ||
96 | chdir( path.latin1()); | 92 | chdir( path.latin1()); |
97 | currentPathCombo->lineEdit()->setText(path); | 93 | currentPathCombo->lineEdit()->setText(path); |
98 | } | 94 | } |
99 | 95 | ||
100 | 96 | ||
101 | void AdvancedFm::populateView() { | 97 | void AdvancedFm::populateView() { |
102 | 98 | ||
103 | QPixmap pm; | 99 | QPixmap pm; |
104 | QListView *thisView = CurrentView(); | 100 | QListView *thisView = CurrentView(); |
105 | QDir *thisDir = CurrentDir(); | 101 | QDir *thisDir = CurrentDir(); |
106 | QString path = thisDir->canonicalPath(); | 102 | QString path = thisDir->canonicalPath(); |
107 | 103 | ||
108 | thisView->clear(); | 104 | thisView->clear(); |
109 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 105 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
110 | thisDir->setMatchAllDirs(TRUE); | 106 | thisDir->setMatchAllDirs(TRUE); |
111 | thisDir->setNameFilter(filterStr); | 107 | thisDir->setNameFilter(filterStr); |
112 | QString fileL, fileS, fileDate; | 108 | QString fileL, fileS, fileDate; |
113 | QString fs= getFileSystemType((const QString &) path); | 109 | |
110 | QString fs = getFileSystemType((const QString &) path); | ||
114 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 111 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
115 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 112 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
116 | bool isDir=FALSE; | 113 | bool isDir = FALSE; |
114 | |||
117 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 115 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
118 | QFileInfoListIterator it(*list); | 116 | QFileInfoListIterator it(*list); |
119 | QFileInfo *fi; | 117 | QFileInfo *fi; |
120 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
121 | if (fi->isSymLink() ) { | 119 | if (fi->isSymLink() ) { |
122 | QString symLink=fi->readLink(); | 120 | QString symLink = fi->readLink(); |
123 | QFileInfo sym( symLink); | 121 | QFileInfo sym( symLink); |
124 | fileS.sprintf( "%10i", sym.size() ); | 122 | fileS.sprintf( "%10i", sym.size() ); |
125 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 123 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
126 | fileDate = sym.lastModified().toString(); | 124 | fileDate = sym.lastModified().toString(); |
127 | } else { | 125 | } else { |
128 | fileS.sprintf( "%10i", fi->size() ); | 126 | fileS.sprintf( "%10i", fi->size() ); |
129 | fileL = fi->fileName(); | 127 | fileL = fi->fileName(); |
130 | fileDate= fi->lastModified().toString(); | 128 | fileDate= fi->lastModified().toString(); |
131 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 129 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
132 | // if(fileL == "..") | 130 | // if(fileL == "..") |
133 | fileL += "/"; | 131 | fileL += "/"; |
134 | isDir=TRUE; | 132 | isDir=TRUE; |
135 | } | 133 | } |
136 | } | 134 | } |
137 | QFileInfo fileInfo( path + "/" + fileL); | 135 | QFileInfo fileInfo( path + "/" + fileL); |
138 | 136 | ||
139 | if(fileL !="./" && fi->exists()) { | 137 | if(fileL !="./" && fi->exists()) { |
140 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 138 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
141 | 139 | ||
142 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 140 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
143 | 141 | ||
144 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 142 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
145 | pm = Resource::loadPixmap( "lockedfolder" ); | 143 | pm = Resource::loadPixmap( "lockedfolder" ); |
146 | else | 144 | else |
@@ -302,71 +300,71 @@ void AdvancedFm::fillCombo(const QString ¤tPath) { | |||
302 | } else { | 300 | } else { |
303 | currentPathCombo->lineEdit()->setText( currentPath); | 301 | currentPathCombo->lineEdit()->setText( currentPath); |
304 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 302 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
305 | currentPathCombo->clear(); | 303 | currentPathCombo->clear(); |
306 | remoteDirPathStringList.prepend( currentPath ); | 304 | remoteDirPathStringList.prepend( currentPath ); |
307 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 305 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
308 | } | 306 | } |
309 | } | 307 | } |
310 | } | 308 | } |
311 | 309 | ||
312 | QStringList AdvancedFm::getPath() { | 310 | QStringList AdvancedFm::getPath() { |
313 | QStringList strList; | 311 | QStringList strList; |
314 | QListView *thisView=CurrentView(); | 312 | QListView *thisView=CurrentView(); |
315 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 313 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
316 | QListViewItemIterator it( thisView ); | 314 | QListViewItemIterator it( thisView ); |
317 | for ( ; it.current(); ++it ) { | 315 | for ( ; it.current(); ++it ) { |
318 | if ( it.current()->isSelected() ) { | 316 | if ( it.current()->isSelected() ) { |
319 | strList << it.current()->text(0); | 317 | strList << it.current()->text(0); |
320 | // odebug << it.current()->text(0) << oendl; | 318 | // odebug << it.current()->text(0) << oendl; |
321 | } | 319 | } |
322 | } | 320 | } |
323 | return strList; | 321 | return strList; |
324 | } | 322 | } |
325 | 323 | ||
326 | void AdvancedFm::changeTo(const QString dir) { | 324 | void AdvancedFm::changeTo(const QString &dir) { |
327 | chdir( dir.latin1()); | 325 | chdir( dir.latin1()); |
328 | CurrentDir()->cd(dir, TRUE); | 326 | CurrentDir()->cd(dir, TRUE); |
329 | populateView(); | 327 | populateView(); |
330 | update(); | 328 | update(); |
331 | } | 329 | } |
332 | 330 | ||
333 | void AdvancedFm::homeButtonPushed() { | 331 | void AdvancedFm::homeButtonPushed() { |
334 | changeTo(QDir::homeDirPath()); | 332 | changeTo(QDir::homeDirPath()); |
335 | } | 333 | } |
336 | 334 | ||
337 | void AdvancedFm::docButtonPushed() { | 335 | void AdvancedFm::docButtonPushed() { |
338 | changeTo(QPEApplication::documentDir()); | 336 | changeTo(QPEApplication::documentDir()); |
339 | } | 337 | } |
340 | 338 | ||
341 | void AdvancedFm::SDButtonPushed() { | 339 | void AdvancedFm::SDButtonPushed() { |
342 | Opie::Core::OStorageInfo info; | 340 | Opie::Core::OStorageInfo info; |
343 | changeTo(info.sdPath()); | 341 | changeTo(info.sdPath()); |
344 | } | 342 | } |
345 | 343 | ||
346 | void AdvancedFm::CFButtonPushed() { | 344 | void AdvancedFm::CFButtonPushed() { |
347 | Opie::Core::OStorageInfo info; | 345 | Opie::Core::OStorageInfo info; |
348 | changeTo(info.cfPath()); | 346 | changeTo(info.cfPath()); |
349 | } | 347 | } |
350 | 348 | ||
351 | void AdvancedFm::QPEButtonPushed() { | 349 | void AdvancedFm::QPEButtonPushed() { |
352 | changeTo(QPEApplication::qpeDir()); | 350 | changeTo(QPEApplication::qpeDir()); |
353 | } | 351 | } |
354 | 352 | ||
355 | void AdvancedFm::doAbout() { | 353 | void AdvancedFm::doAbout() { |
356 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 354 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
357 | } | 355 | } |
358 | 356 | ||
359 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 357 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
360 | Q_UNUSED(e); | 358 | Q_UNUSED(e); |
361 | } | 359 | } |
362 | 360 | ||
363 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 361 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
364 | // if( CurrentView()->hasFocus() ) | 362 | // if( CurrentView()->hasFocus() ) |
365 | // e->ignore(); | 363 | // e->ignore(); |
366 | if( currentPathCombo->lineEdit()->hasFocus()) { | 364 | if( currentPathCombo->lineEdit()->hasFocus()) { |
367 | // qDebug("shout!"); | 365 | // qDebug("shout!"); |
368 | } | 366 | } |
369 | 367 | ||
370 | else if( e->key() == Key_Left ) | 368 | else if( e->key() == Key_Left ) |
371 | upDir(); | 369 | upDir(); |
372 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 370 | else if( e->key() == Key_Return || e->key() == Key_Enter) |