summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
authorllornkcor <llornkcor>2004-09-25 06:51:24 (UTC)
committer llornkcor <llornkcor>2004-09-25 06:51:24 (UTC)
commit3d4aef2df9828aedccf5d576ecbc8aad6621362e (patch) (unidiff)
tree435f8e3b658ef45d8e95d29a305d20c62e01c24e /noncore/apps/advancedfm/advancedfm.cpp
parent448e2835ff7b84162022b62f8570935739a167bb (diff)
downloadopie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.zip
opie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.tar.gz
opie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.tar.bz2
not hardcoded path
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp41
1 files changed, 7 insertions, 34 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index ec7a08a..f1be471 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,39 +1,42 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16
17#include <opie2/ostorageinfo.h>
18
16#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
17#include <qpe/config.h> 20#include <qpe/config.h>
18#include <qpe/mimetype.h> 21#include <qpe/mimetype.h>
19#include <qpe/applnk.h> 22#include <qpe/applnk.h>
20#include <qpe/resource.h> 23#include <qpe/resource.h>
21#include <qpe/menubutton.h> 24#include <qpe/menubutton.h>
22 25
23#include <qcombobox.h> 26#include <qcombobox.h>
24#include <qpopupmenu.h> 27#include <qpopupmenu.h>
25#include <qlistview.h> 28#include <qlistview.h>
26#include <qmessagebox.h> 29#include <qmessagebox.h>
27#include <qlineedit.h> 30#include <qlineedit.h>
28 31
29 32
30#include <sys/stat.h> 33#include <sys/stat.h>
31#include <time.h> 34#include <time.h>
32#include <dirent.h> 35#include <dirent.h>
33#include <fcntl.h> 36#include <fcntl.h>
34#include <sys/vfs.h> 37#include <sys/vfs.h>
35#include <mntent.h> 38#include <mntent.h>
36 39
37using namespace Opie::Ui; 40using namespace Opie::Ui;
38 41
39AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) 42AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
@@ -189,66 +192,51 @@ void AdvancedFm::populateView() {
189// odebug << mydirent->d_name << oendl; 192// odebug << mydirent->d_name << oendl;
190 fileL.sprintf("%s", mydirent->d_name); 193 fileL.sprintf("%s", mydirent->d_name);
191 devT = buf.st_dev; 194 devT = buf.st_dev;
192 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 195 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
193 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 196 fileDate.sprintf("%s", ctime( &buf.st_mtime));
194 if( fileL.find(".") == -1 ) { 197 if( fileL.find(".") == -1 ) {
195 item= new QListViewItem( thisView, fileL, fileS, fileDate); 198 item= new QListViewItem( thisView, fileL, fileS, fileDate);
196 pm = unknownXpm; 199 pm = unknownXpm;
197 item->setPixmap( 0,pm); 200 item->setPixmap( 0,pm);
198 } 201 }
199 } 202 }
200 203
201 closedir(dir); 204 closedir(dir);
202 } 205 }
203 206
204 thisView->setSorting( 3,FALSE); 207 thisView->setSorting( 3,FALSE);
205 fillCombo( (const QString &) path ); 208 fillCombo( (const QString &) path );
206} 209}
207 210
208void AdvancedFm::rePopulate() { 211void AdvancedFm::rePopulate() {
209 // qDebug("repopulate views"); 212 // qDebug("repopulate views");
210 populateView(); 213 populateView();
211 setOtherTabCurrent(); 214 setOtherTabCurrent();
212 populateView(); 215 populateView();
213
214// int tmpTab = whichTab;
215// // odebug << "" << tmpTab << "" << oendl;
216
217// for(int i =1; i < 3; i++) {
218// TabWidget->setCurrentWidget(i - 1);
219// populateView();
220// }
221// TabWidget->setCurrentWidget( tmpTab - 1);
222} 216}
223 217
224void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 218void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
225 // if ( TabWidget->currentWidget() == tab)
226 // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local");
227 // else
228 // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote");
229
230
231 if(selectedItem) { 219 if(selectedItem) {
232 QString strItem=selectedItem->text(0); 220 QString strItem=selectedItem->text(0);
233// owarn << strItem << oendl; 221// owarn << strItem << oendl;
234 QString strSize=selectedItem->text(1); 222 QString strSize=selectedItem->text(1);
235 strSize=strSize.stripWhiteSpace(); 223 strSize=strSize.stripWhiteSpace();
236 bool isDirectory = false; 224 bool isDirectory = false;
237 QString strItem2; 225 QString strItem2;
238 226
239 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink 227 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
240 strItem2 = dealWithSymName((const QString&)strItem); 228 strItem2 = dealWithSymName((const QString&)strItem);
241 if(QDir(strItem2).exists() ) 229 if(QDir(strItem2).exists() )
242 strItem = strItem2; 230 strItem = strItem2;
243 } 231 }
244 232
245 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 233 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
246 234
247 if(QDir(strItem).exists()) 235 if(QDir(strItem).exists())
248 isDirectory = true; 236 isDirectory = true;
249 } 237 }
250 238
251 if( isDirectory ) { 239 if( isDirectory ) {
252 CurrentDir()->cd( strItem, TRUE); 240 CurrentDir()->cd( strItem, TRUE);
253 populateView(); 241 populateView();
254 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 242 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
@@ -256,49 +244,48 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
256 chdir( strItem.latin1()); 244 chdir( strItem.latin1());
257 } 245 }
258} 246}
259 247
260void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { 248void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
261 Q_UNUSED(item); 249 Q_UNUSED(item);
262 switch (mouse) { 250 switch (mouse) {
263 case 1: 251 case 1:
264 { 252 {
265 if(renameBox != 0 ) { 253 if(renameBox != 0 ) {
266 cancelRename(); 254 cancelRename();
267 } 255 }
268 } 256 }
269 break; 257 break;
270// case 2: 258// case 2:
271// menuTimer.start( 50, TRUE ); 259// menuTimer.start( 50, TRUE );
272// break; 260// break;
273 }; 261 };
274} 262}
275 263
276 264
277void AdvancedFm::refreshCurrentTab() { 265void AdvancedFm::refreshCurrentTab() {
278 populateView(); 266 populateView();
279 // if ( TabWidget->currentWidget() == tab) { 267 // if ( TabWidget->currentWidget() == tab) {
280
281} 268}
282 269
283void AdvancedFm::switchToLocalTab() { 270void AdvancedFm::switchToLocalTab() {
284 TabWidget->setCurrentWidget(0); 271 TabWidget->setCurrentWidget(0);
285 // Local_View->setFocus(); 272 // Local_View->setFocus();
286 whichTab = 1; 273 whichTab = 1;
287} 274}
288 275
289void AdvancedFm::switchToRemoteTab() { 276void AdvancedFm::switchToRemoteTab() {
290 TabWidget->setCurrentWidget(1); 277 TabWidget->setCurrentWidget(1);
291 // Remote_View->setFocus(); 278 // Remote_View->setFocus();
292 whichTab = 2; 279 whichTab = 2;
293} 280}
294 281
295void AdvancedFm::currentPathComboChanged() { 282void AdvancedFm::currentPathComboChanged() {
296 QString pDir = currentPathCombo->lineEdit()->text(); 283 QString pDir = currentPathCombo->lineEdit()->text();
297 if(QDir(pDir).exists()) { 284 if(QDir(pDir).exists()) {
298 CurrentDir()->setPath(pDir ); 285 CurrentDir()->setPath(pDir );
299 populateView(); 286 populateView();
300 } else { 287 } else {
301 QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); 288 QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir));
302 } 289 }
303} 290}
304 291
@@ -331,56 +318,55 @@ QStringList AdvancedFm::getPath() {
331 if ( it.current()->isSelected() ) { 318 if ( it.current()->isSelected() ) {
332 strList << it.current()->text(0); 319 strList << it.current()->text(0);
333// odebug << it.current()->text(0) << oendl; 320// odebug << it.current()->text(0) << oendl;
334 } 321 }
335 } 322 }
336 return strList; 323 return strList;
337} 324}
338 325
339void AdvancedFm::changeTo(const QString dir) { 326void AdvancedFm::changeTo(const QString dir) {
340 chdir( dir.latin1()); 327 chdir( dir.latin1());
341 CurrentDir()->cd(dir, TRUE); 328 CurrentDir()->cd(dir, TRUE);
342 populateView(); 329 populateView();
343 update(); 330 update();
344} 331}
345 332
346void AdvancedFm::homeButtonPushed() { 333void AdvancedFm::homeButtonPushed() {
347 changeTo(QDir::homeDirPath()); 334 changeTo(QDir::homeDirPath());
348} 335}
349 336
350void AdvancedFm::docButtonPushed() { 337void AdvancedFm::docButtonPushed() {
351 changeTo(QPEApplication::documentDir()); 338 changeTo(QPEApplication::documentDir());
352} 339}
353 340
354void AdvancedFm::SDButtonPushed() { 341void AdvancedFm::SDButtonPushed() {
355 changeTo("/mnt/card");// this can change so fix 342 Opie::Core::OStorageInfo info;
343 changeTo(info.sdPath());
356} 344}
357 345
358void AdvancedFm::CFButtonPushed() { 346void AdvancedFm::CFButtonPushed() {
359 if(zaurusDevice) 347 Opie::Core::OStorageInfo info;
360 changeTo("/mnt/cf"); //zaurus 348 changeTo(info.cfPath());
361 else
362 changeTo("/mnt/hda"); //ipaq
363} 349}
364 350
365void AdvancedFm::QPEButtonPushed() { 351void AdvancedFm::QPEButtonPushed() {
366 changeTo(QPEApplication::qpeDir()); 352 changeTo(QPEApplication::qpeDir());
367} 353}
368 354
369void AdvancedFm::doAbout() { 355void AdvancedFm::doAbout() {
370 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>")); 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>"));
371} 357}
372 358
373void AdvancedFm::keyPressEvent( QKeyEvent *e) { 359void AdvancedFm::keyPressEvent( QKeyEvent *e) {
374 Q_UNUSED(e); 360 Q_UNUSED(e);
375} 361}
376 362
377void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { 363void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
378// if( CurrentView()->hasFocus() ) 364// if( CurrentView()->hasFocus() )
379// e->ignore(); 365// e->ignore();
380 if( currentPathCombo->lineEdit()->hasFocus()) { 366 if( currentPathCombo->lineEdit()->hasFocus()) {
381 // qDebug("shout!"); 367 // qDebug("shout!");
382 } 368 }
383 369
384 else if( e->key() == Key_Left ) 370 else if( e->key() == Key_Left )
385 upDir(); 371 upDir();
386 else if( e->key() == Key_Return || e->key() == Key_Enter) 372 else if( e->key() == Key_Return || e->key() == Key_Enter)
@@ -749,50 +735,37 @@ QListView * AdvancedFm::OtherView() {
749void AdvancedFm::setOtherTabCurrent() { 735void AdvancedFm::setOtherTabCurrent() {
750 // qDebug("setOtherTabCurrent() %d",whichTab); 736 // qDebug("setOtherTabCurrent() %d",whichTab);
751 if ( whichTab == 1) { 737 if ( whichTab == 1) {
752 TabWidget->setCurrentWidget(1); 738 TabWidget->setCurrentWidget(1);
753 } else { 739 } else {
754 TabWidget->setCurrentWidget(0); 740 TabWidget->setCurrentWidget(0);
755 } 741 }
756// OtherView()->setFocus(); 742// OtherView()->setFocus();
757 OtherView()->setSelected( CurrentView()->firstChild(), true); 743 OtherView()->setSelected( CurrentView()->firstChild(), true);
758} 744}
759 745
760void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 746void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
761// odebug << "qcop message "+msg << oendl; 747// odebug << "qcop message "+msg << oendl;
762 QDataStream stream ( data, IO_ReadOnly ); 748 QDataStream stream ( data, IO_ReadOnly );
763 if ( msg == "openDirectory(QString)" ) { 749 if ( msg == "openDirectory(QString)" ) {
764// odebug << "received" << oendl; 750// odebug << "received" << oendl;
765 QString file; 751 QString file;
766 stream >> file; 752 stream >> file;
767 changeTo( (const QString &) file); 753 changeTo( (const QString &) file);
768 } 754 }
769} 755}
770 756
771void AdvancedFm::setDocument(const QString &file) { 757void AdvancedFm::setDocument(const QString &file) {
772 changeTo( file); 758 changeTo( file);
773
774} 759}
775 760
776 761
777void AdvancedFm::findFile(const QString &fileName) {
778 QFileInfo fi(fileName);
779 QListView *thisView = CurrentView();
780 QListViewItemIterator it( thisView );
781 for ( ; it.current(); ++it ) {
782 if(it.current()->text(0) == fi.fileName()) {
783 it.current()->setSelected(true);
784 thisView->ensureItemVisible(it.current());
785 }
786 }
787}
788
789void AdvancedFm::slotSwitchMenu(int item) { 762void AdvancedFm::slotSwitchMenu(int item) {
790 Q_UNUSED(item); 763 Q_UNUSED(item);
791 // qDebug( "Switch %d",item); 764 // qDebug( "Switch %d",item);
792 // viewMenu->setItemChecked(item, true); 765 // viewMenu->setItemChecked(item, true);
793} 766}
794 767
795void AdvancedFm::navigateToSelected() { 768void AdvancedFm::navigateToSelected() {
796 if( !CurrentView()->currentItem()) return; 769 if( !CurrentView()->currentItem()) return;
797 doDirChange(); 770 doDirChange();
798} 771}