-rw-r--r-- | noncore/apps/advancedfm/Makefile | 214 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 41 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 148 | ||||
-rw-r--r-- | noncore/apps/advancedfm/output.h | 2 |
5 files changed, 338 insertions, 68 deletions
diff --git a/noncore/apps/advancedfm/Makefile b/noncore/apps/advancedfm/Makefile index 4622c6e..8799b03 100644 --- a/noncore/apps/advancedfm/Makefile +++ b/noncore/apps/advancedfm/Makefile @@ -1,159 +1,277 @@ ############################################################################# -# Makefile for building $(OPIEDIR)/bin/advancedfm -# Generated by tmake at 18:31, 2002/04/15 -# Project: advancedfm -# Template: app +# Automatically generated from noncore/advancedfm/Makefile.in +# Build options from ############################################################################# -####### Compiler, tools and options +# Compiling +INTERFACE_DECL_PATH = . +SYSCONF_CXX = g++ +SYSCONF_CC = gcc +DASHCROSS = + +# Compiling with support libraries +SYSCONF_CXXFLAGS_X11 = +SYSCONF_CXXFLAGS_QT = -I$(QTDIR)/include +SYSCONF_CXXFLAGS_OPENGL = -I/usr/X11R6/include + +# Compiling YACC output +SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses + +# Linking with support libraries +SYSCONF_RPATH_X11 = +SYSCONF_RPATH_QT = -Wl,-rpath,$(QTDIR)/lib +SYSCONF_RPATH_OPENGL = -Wl,-rpath,/usr/X11R6/lib + +# Linking with support libraries +# X11 +SYSCONF_LFLAGS_X11 = +SYSCONF_LIBS_X11 = +# Qt, Qt+OpenGL +SYSCONF_LFLAGS_QT = -L$(QTDIR)/lib +SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) +SYSCONF_LIBS_QT_OPENGL = +# OpenGL +SYSCONF_LFLAGS_OPENGL = -L/usr/X11R6/lib +SYSCONF_LIBS_OPENGL = +# Yacc +SYSCONF_LIBS_YACC = + +# Linking applications +SYSCONF_LINK = gcc +SYSCONF_LFLAGS = +SYSCONF_LIBS = + +# Link flags for shared objects +SYSCONF_LFLAGS_SHOBJ = -shared + +# Flags for threading +SYSCONF_CFLAGS_THREAD = -D_REENTRANT +SYSCONF_CXXFLAGS_THREAD = -D_REENTRANT +SYSCONF_LFLAGS_THREAD = +SYSCONF_LIBS_THREAD = -lpthread + +# Meta-object compiler +SYSCONF_MOC = $(QTDIR)/bin/moc + +# UI compiler +SYSCONF_UIC = $(QTDIR)/bin/uic + +# Linking shared libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 +# - Place target in $(DESTDIR) - which has a trailing / +# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) +# +SYSCONF_LINK_SHLIB = gcc +SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) +SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ + $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ + $(OBJECTS) $(OBJMOC) $(LIBS) && \ + mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ + cd $(DESTDIR) && \ + rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) + +# Linking static libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).a +# - Place target in $(DESTDIR) - which has a trailing / +# +SYSCONF_AR = ar cqs +SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a +SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ + $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) +# Compiling application source +SYSCONF_CXXFLAGS = -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W +SYSCONF_CFLAGS = -pipe -O2 -Wall -W +# Default link type (static linking is still be used where required) +SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) +SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) +# Compiling library source +SYSCONF_CXXFLAGS_LIB = -fPIC +SYSCONF_CFLAGS_LIB = -fPIC +# Compiling shared-object source +SYSCONF_CXXFLAGS_SHOBJ = -fPIC +SYSCONF_CFLAGS_SHOBJ = -fPIC +# Linking Qt +SYSCONF_LIBS_QTLIB = $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) +# Linking Qt applications +SYSCONF_LIBS_QTAPP = +############################################################################# -CC = gcc -CXX = g++ -CFLAGS = -pipe -Wall -W -O2 -fno-default-inline -DNO_DEBUG -CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -INCPATH = -I$(OPIEDIR)/include -I$(QTDIR)/include -LINK = g++ -LFLAGS = -LIBS = $(SUBLIBS) -L$(QTDIR)/lib -lqpe -lqte -MOC = $(QTDIR)/bin/moc -UIC = $(QTDIR)/bin/uic +####### Compiler, tools and options -TAR = tar -cf -GZIP = gzip -9f +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(OPIEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = $(OPIEDIR)/bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = advancedfm +TARGET1 = lib$(TARGET).so.$(VER_MAJ) ####### Files HEADERS = advancedfm.h \ inputDialog.h \ filePermissions.h \ output.h SOURCES = advancedfm.cpp \ inputDialog.cpp \ filePermissions.cpp \ output.cpp \ main.cpp OBJECTS = advancedfm.o \ inputDialog.o \ filePermissions.o \ output.o \ main.o -INTERFACES = -UICDECLS = -UICIMPLS = +INTERFACES = +UICDECLS = +UICIMPLS = SRCMOC = moc_advancedfm.cpp \ moc_inputDialog.cpp \ moc_filePermissions.cpp \ moc_output.cpp OBJMOC = moc_advancedfm.o \ moc_inputDialog.o \ moc_filePermissions.o \ moc_output.o -DIST = -TARGET = $(OPIEDIR)/bin/advancedfm -INTERFACE_DECL_PATH = . + ####### Implicit rules .SUFFIXES: .cpp .cxx .cc .C .c .cpp.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< .cxx.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< .cc.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< .C.o: $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< .c.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< ####### Build rules -all: $(TARGET) +all: $(DESTDIR)$(TARGET) -$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) - $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) moc: $(SRCMOC) -tmake: Makefile - -Makefile: advancedfm.pro - tmake advancedfm.pro -o Makefile - -dist: - $(TAR) advancedfm.tar advancedfm.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST) - $(GZIP) advancedfm.tar +tmake: + tmake advancedfm.pro clean: - -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET) + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES=medium-config ####### Sub-libraries ###### Combined headers + ####### Compile advancedfm.o: advancedfm.cpp \ advancedfm.h \ inputDialog.h \ filePermissions.h \ output.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/lnkproperties.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/filemanager.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/qcopenvelope_qws.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/qpemenubar.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/qpetoolbar.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/qpeapplication.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/resource.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/config.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/mimetype.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/applnk.h + $(OPIEDIR)/include/qpe/lnkproperties.h \ + $(OPIEDIR)/include/qpe/filemanager.h \ + $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ + $(OPIEDIR)/include/qpe/qpemenubar.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + $(OPIEDIR)/include/qpe/qpeapplication.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/config.h \ + $(OPIEDIR)/include/qpe/mimetype.h \ + $(OPIEDIR)/include/qpe/applnk.h inputDialog.o: inputDialog.cpp \ inputDialog.h filePermissions.o: filePermissions.cpp \ filePermissions.h output.o: output.cpp \ output.h main.o: main.cpp \ - /usr/src/oldsrc/Opie/opie/include/qpe/qpeapplication.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/qcopenvelope_qws.h \ - /usr/src/oldsrc/Opie/opie/include/qpe/config.h \ + $(OPIEDIR)/include/qpe/qpeapplication.h \ + $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ + $(OPIEDIR)/include/qpe/config.h \ advancedfm.h moc_advancedfm.o: moc_advancedfm.cpp \ advancedfm.h moc_inputDialog.o: moc_inputDialog.cpp \ inputDialog.h moc_filePermissions.o: moc_filePermissions.cpp \ filePermissions.h moc_output.o: moc_output.cpp \ output.h moc_advancedfm.cpp: advancedfm.h $(MOC) advancedfm.h -o moc_advancedfm.cpp moc_inputDialog.cpp: inputDialog.h $(MOC) inputDialog.h -o moc_inputDialog.cpp moc_filePermissions.cpp: filePermissions.h $(MOC) filePermissions.h -o moc_filePermissions.cpp moc_output.cpp: output.h $(MOC) output.h -o moc_output.cpp + + +lupdate: + lupdate advancedfm.pro + +lrelease: + lrelease advancedfm.pro + diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index a4ec714..8a1eeec 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -84,137 +84,139 @@ AdvancedFm::AdvancedFm( ) menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); cfButton ->setFixedSize( QSize( 20, 20 ) ); connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); cfButton->setFlat(TRUE); layout->addMultiCellWidget( cfButton , 0, 0, 2, 2); sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); sdButton->setFixedSize( QSize( 20, 20 ) ); connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); sdButton->setFlat(TRUE); layout->addMultiCellWidget( sdButton , 0, 0, 3, 3); cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); cdUpButton ->setFlat(TRUE); layout->addMultiCellWidget( cdUpButton , 0, 0, 4, 4); docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); docButton->setFixedSize( QSize( 20, 20 ) ); connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); docButton->setFlat(TRUE); layout->addMultiCellWidget( docButton, 0, 0, 5, 5); homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); homeButton->setFixedSize( QSize( 20, 20 ) ); connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); homeButton->setFlat(TRUE); layout->addMultiCellWidget( homeButton, 0, 0, 6, 6); // fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); // fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); // fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); fileMenu->setCheckable(TRUE); viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); + viewMenu->insertSeparator(); + viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); viewMenu->setCheckable(TRUE); TabWidget = new QTabWidget( this, "TabWidget" ); layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); // Local_View->setResizePolicy( QListView::AutoOneFit ); Local_View->addColumn( tr("File"),140); - Local_View->addColumn( tr("Size"),-1); - Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); + Local_View->setColumnAlignment(1,QListView::AlignRight); + Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); // Local_View->setMultiSelection( TRUE ); // Local_View->setSelectionMode(QListView::Extended); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); TabWidget->insertTab( tab, tr("1")); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),140); - Remote_View->addColumn( tr("Size"),-1); - Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); + Remote_View->setColumnAlignment(1,QListView::AlignRight); + Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); // Remote_View->setMultiSelection( TRUE ); // Remote_View->setSelectionMode(QListView::Extended); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->insertTab( tab_2, tr( "2")); connect(TabWidget,SIGNAL(currentChanged(QWidget *)), this,SLOT(tabChanged(QWidget*))); // tab_3 = new QWidget( TabWidget, "tab_3" ); // tabLayout_3 = new QGridLayout( tab_3 ); // tabLayout_3->setSpacing( 2); // tabLayout_3->setMargin( 2); // OFileSelector *fileSelector; // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); // TabWidget->insertTab( tab_3, tr( "Files" ) ); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); currentDir.setPath( QDir::currentDirPath()); currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); currentRemoteDir.setPath( QDir::currentDirPath()); currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); currentPathCombo->setEditable(TRUE); layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); connect( currentPathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( currentPathComboActivated( const QString & ) ) ); connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), this,SLOT(currentPathComboChanged())); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); @@ -254,255 +256,255 @@ void AdvancedFm::tabChanged(QWidget *w) viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); } } void AdvancedFm::populateLocalView() { // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); // QListViewItemIterator it( Local_View ); // for ( ; it.current(); ++it ) { // if ( it.current()->isSelected() ) { // QString strItem = it.current()->text(0); // QString localFile = currentDir.canonicalPath()+"/"+strItem; // QFileInfo fi(localFile); // } // } QPixmap pm; Local_View->clear(); currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); currentDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; // qDebug(currentDir.canonicalPath()); bool isDir=FALSE; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ) { QString symLink=fi->readLink(); // qDebug("Symlink detected "+symLink); QFileInfo sym( symLink); fileS.sprintf( "%10li", sym.size() ); fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); fileDate = sym.lastModified().toString(); } else { fileS.sprintf( "%10li", fi->size() ); fileL.sprintf( "%s",fi->fileName().data() ); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; isDir=TRUE; // qDebug( fileL); } } if(fileL !="./" && fi->exists()) { - item= new QListViewItem( Local_View, fileL, fileS , fileDate); + item= new QListViewItem( Local_View, fileL , fileDate, fileS); if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); item->setPixmap( 0,pm ); } else { if( !fi->isReadable() ) pm = Resource::loadPixmap( "locked" ); else { MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } if( fileL.find("->",0,TRUE) != -1) { // overlay link image pm= Resource::loadPixmap( "folder" ); QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); QPainter painter( &pm ); painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { struct stat buf; struct stat st; dev_t devT; mode_t mode; DIR *dir; int fd = 0; struct dirent *mydirent; int i = 1; if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); qDebug(mydirent->d_name); // mode = buf.st_mode; fileL.sprintf("%s", mydirent->d_name); // fileS.sprintf("%d, %d", ); //this isn't correct devT = buf.st_dev; fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); // fileS.sprintf("%d,%d", devT, devT); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ){ - item= new QListViewItem( Local_View, fileL, fileS, fileDate); + item= new QListViewItem( Local_View, fileL, fileDate, fileS); pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } closedir(dir); } Local_View->setSorting( 3,FALSE); fillCombo( (const QString &) currentDir.canonicalPath()); } void AdvancedFm::populateRemoteView() { // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); // QListViewItemIterator it( Remote_View ); // for ( ; it.current(); ++it ) { // if ( it.current()->isSelected() ) { // QString strItem = it.current()->text(0); // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; // QFileInfo fi(localFile); // } // } QPixmap pm; Remote_View->clear(); currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentRemoteDir.setMatchAllDirs(TRUE); currentRemoteDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; bool isDir=FALSE; const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ){ QString symLink=fi->readLink(); // qDebug("Symlink detected "+symLink); QFileInfo sym( symLink); fileS.sprintf( "%10li", sym.size() ); fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); fileDate = sym.lastModified().toString(); } else { // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); fileS.sprintf( "%10li", fi->size() ); fileL.sprintf( "%s",fi->fileName().data() ); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; isDir=TRUE; // qDebug( fileL); } } if(fileL !="./" && fi->exists()) { - item= new QListViewItem( Remote_View,fileL,fileS , fileDate); + item= new QListViewItem( Remote_View, fileL, fileDate, fileS); QPixmap pm; if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); item->setPixmap( 0,pm ); } else { if( !fi->isReadable() ) pm = Resource::loadPixmap( "locked" ); else { MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } if( fileL.find("->",0,TRUE) != -1) { // overlay link image pm= Resource::loadPixmap( "folder" ); QPixmap lnk = Resource::loadPixmap( "symlink" ); QPainter painter( &pm ); painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { struct stat buf; struct stat st; mode_t mode; DIR *dir; int fd = 0; struct dirent *mydirent; int i = 1; if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); qDebug(mydirent->d_name); // mode = buf.st_mode; fileL.sprintf("%s", mydirent->d_name); // fileS.sprintf("%d, %d", ); //this isn't correct fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ){ - item= new QListViewItem( Remote_View, fileL, fileS, fileDate); + item= new QListViewItem( Remote_View, fileL, fileDate, fileS); pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } closedir(dir); } Remote_View->setSorting( 3,FALSE); fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); } void AdvancedFm::localListClicked(QListViewItem *selectedItem) { if(selectedItem) { QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink // is symlink QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); if(QDir(strItem2).exists() ) { currentDir.cd(strItem2, TRUE); populateLocalView(); } } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); currentDir.cd(strItem,FALSE); populateLocalView(); } else { currentDir.cdUp(); populateLocalView(); } if(QDir(strItem).exists()){ currentDir.cd(strItem, TRUE); populateLocalView(); } } else { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { // qDebug("upload "+strItem); } } //end not symlink chdir(strItem.latin1()); } } @@ -1052,212 +1054,217 @@ void AdvancedFm::copy() void AdvancedFm::copyAs() { QString curFile = getPath(); if (TabWidget->currentPageIndex() == 0) { QString destFile = Local_View->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentRemoteDir.canonicalPath()+"/"+destFile; QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } populateRemoteView(); TabWidget->setCurrentPage(1); } else { QString destFile = Remote_View->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentDir.canonicalPath()+"/"+destFile; QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } populateLocalView(); TabWidget->setCurrentPage(0); } } void AdvancedFm::move() { QString curFile = getPath(); // qDebug(curFile); QString destFile; if (TabWidget->currentPageIndex() == 0) { - QString destFile = currentRemoteDir.canonicalPath()+Local_View->currentItem()->text(0); -// qDebug(destFile); + QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); + qDebug("Destination file is "+destFile); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile( destFile, curFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); return; } QFile::remove(curFile); TabWidget->setCurrentPage(1); } else { - QString destFile = currentDir.canonicalPath()+destFile + Remote_View->currentItem()->text(0); -// qDebug(destFile); + QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); + qDebug("Destination file is "+destFile); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); return; } QFile::remove(curFile); TabWidget->setCurrentPage(0); } populateRemoteView(); populateLocalView(); } bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { char bf[ 50000 ]; int bytesRead; bool success = TRUE; struct stat status; QFile s( src ); QFile d( dest ); if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ success = FALSE; break; } } if( success && (bytesRead > 0) ){ d.writeBlock( bf, bytesRead ); } } else { success = FALSE; } // Set file permissions if( stat( (const char *) src, &status ) == 0 ){ chmod( (const char *) dest, status.st_mode ); } return success; } void AdvancedFm::runCommand() { QString curFile; if (TabWidget->currentPageIndex() == 0) { if( Local_View->currentItem()) curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); } else { if(Remote_View->currentItem()) curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); } InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); fileDlg->setInputText(curFile); fileDlg->exec(); QString command; if( fileDlg->result() == 1 ) { command = fileDlg->LineEdit1->text(); int err=0; Output *outDlg; outDlg = new Output(this, tr("Formatter Output"),FALSE); outDlg->showMaximized(); outDlg->show(); qApp->processEvents(); FILE *fp; char line[130]; sleep(1); // if(command.find("2>",0,TRUE) != -1) command +=" 2>&1"; fp = popen( (const char *) command, "r"); if ( !fp ) { qDebug("Could not execute '" + command + "'! err=%d", fp); QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); pclose(fp); return; } else { while ( fgets( line, sizeof line, fp)) { - outDlg->OutputEdit->append(line); + QString lineStr = line; + lineStr=lineStr.left(lineStr.length()-1); + outDlg->OutputEdit->append(lineStr); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); - } - } - } - } void AdvancedFm::runCommandStd() { QString curFile; if (TabWidget->currentPageIndex() == 0) { if( Local_View->currentItem()) curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); } else { if(Remote_View->currentItem()) curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); } InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); fileDlg->setInputText(curFile); fileDlg->exec(); QString command; if( fileDlg->result() == 1 ) { qApp->processEvents(); command = fileDlg->LineEdit1->text() + " &"; system(command.latin1()); } } void AdvancedFm::fileStatus() { QString curFile; if (TabWidget->currentPageIndex() == 0) { curFile = Local_View->currentItem()->text(0); } else { curFile = Remote_View->currentItem()->text(0); } QString command = " stat -l "+ curFile +" 2>&1"; int err=0; Output *outDlg; outDlg = new Output(this, tr("Formatter Output"),FALSE); outDlg->showMaximized(); outDlg->show(); qApp->processEvents(); FILE *fp; char line[130]; sleep(1); fp = popen( (const char *) command, "r"); if ( !fp ) { qDebug("Could not execute '" + command + "'! err=%d", fp); QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); pclose(fp); return; } else { while ( fgets( line, sizeof line, fp)) { outDlg->OutputEdit->append(line); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); } } } + +void AdvancedFm::doAbout() { + QMessageBox::message("AdvancedFm","Advanced FileManager\n" + "is copyright 2002 by\n" + "L.J.Potter<llornkcor@handhelds.org>\n" + "and is licensed by the GPL"); +} diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 2ca45b1..30ff28c 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -68,51 +68,52 @@ protected slots: void populateLocalView(); void populateRemoteView(); void showHidden(); void showRemoteHidden(); void writeConfig(); void readConfig(); void localListClicked(QListViewItem *); void remoteListClicked(QListViewItem *); void localListPressed( int, QListViewItem *, const QPoint&, int); void remoteListPressed( int, QListViewItem *, const QPoint&, int); void localMakDir(); void localDelete(); void remoteMakDir(); void remoteDelete(); /* bool remoteDirList(const QString &); */ /* bool remoteChDir(const QString &); */ void tabChanged(QWidget*); void cleanUp(); void remoteRename(); void localRename(); void runThis(); void runText(); void filePerms(); void doProperties(); void runCommand(); void runCommandStd(); QString getPath(); void switchToLocalTab(); void switchToRemoteTab(); protected: QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; QStringList remoteDirPathStringList, localDirPathStringList; protected slots: void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); void CFButtonPushed(); void upDir(); void currentPathComboChanged(); void copy(); void copyAs(); void currentPathComboActivated(const QString &); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); void move(); void fileStatus(); + void doAbout(); }; #endif // ADVANCEDFM_H diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 6970f58..82e78a7 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp @@ -1,38 +1,180 @@ /**************************************************************************** ** outputEdit.cpp ** ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> ****************************************************************************/ #include "output.h" +#include "inputDialog.h" +#include <qpe/filemanager.h> +#include <qpe/qpeapplication.h> +#include <qpe/applnk.h> + +#include <qfile.h> + +#include <qlineedit.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> -#include <qtooltip.h> -#include <qwhatsthis.h> + +/* XPM */ +static char * filesave_xpm[] = { +"16 16 78 1", +" c None", +". c #343434", +"+ c #A0A0A0", +"@ c #565656", +"# c #9E9E9E", +"$ c #525252", +"% c #929292", +"& c #676767", +"* c #848484", +"= c #666666", +"- c #D8D8D8", +"; c #FFFFFF", +"> c #DBDBDB", +", c #636363", +"' c #989898", +") c #2D2D2D", +"! c #909090", +"~ c #AEAEAE", +"{ c #EAEAEA", +"] c #575757", +"^ c #585858", +"/ c #8A8A8A", +"( c #828282", +"_ c #6F6F6F", +": c #C9C9C9", +"< c #050505", +"[ c #292929", +"} c #777777", +"| c #616161", +"1 c #3A3A3A", +"2 c #BEBEBE", +"3 c #2C2C2C", +"4 c #7C7C7C", +"5 c #F6F6F6", +"6 c #FCFCFC", +"7 c #6B6B6B", +"8 c #959595", +"9 c #4F4F4F", +"0 c #808080", +"a c #767676", +"b c #818181", +"c c #B8B8B8", +"d c #FBFBFB", +"e c #F9F9F9", +"f c #CCCCCC", +"g c #030303", +"h c #737373", +"i c #7A7A7A", +"j c #7E7E7E", +"k c #6A6A6A", +"l c #FAFAFA", +"m c #505050", +"n c #9D9D9D", +"o c #333333", +"p c #7B7B7B", +"q c #787878", +"r c #696969", +"s c #494949", +"t c #555555", +"u c #949494", +"v c #E6E6E6", +"w c #424242", +"x c #515151", +"y c #535353", +"z c #3E3E3E", +"A c #D4D4D4", +"B c #0C0C0C", +"C c #353535", +"D c #474747", +"E c #ECECEC", +"F c #919191", +"G c #7D7D7D", +"H c #000000", +"I c #404040", +"J c #858585", +"K c #323232", +"L c #D0D0D0", +"M c #1C1C1C", +" ...+ ", +" @#$%&..+ ", +" .*=-;;>,..+ ", +" ')!~;;;;;;{]..", +" ^/(-;;;;;;;_:<", +" [}|;;;;;;;{12$", +" #34-55;;;;678$+", +" 90ab=c;dd;e1fg ", +" [ahij((kbl0mn$ ", +" op^q^^7r&]s/$+ ", +"@btu;vbwxy]zAB ", +"CzDEvEv;;DssF$ ", +"G.H{E{E{IxsJ$+ ", +" +...vEKxzLM ", +" +...z]n$ ", +" +... "}; Output::Output( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "Output" ); resize( 196, 269 ); setCaption( name ); OutputLayout = new QGridLayout( this ); OutputLayout->setSpacing( 6 ); OutputLayout->setMargin( 11 ); + QPushButton *docButton; + docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); + docButton->setFixedSize( QSize( 20, 20 ) ); + connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); +// docButton->setFlat(TRUE); + OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); + + OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); + OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); + - OutputLayout->addWidget( OutputEdit, 0, 0 ); } /* * Destroys the object and frees any allocated resources */ Output::~Output() { // no need to delete child widgets, Qt does it all for us } +void Output::saveOutput() { + + InputDialog *fileDlg; + fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); + fileDlg->exec(); + if( fileDlg->result() == 1 ) { + QString filename = QPEApplication::documentDir(); + if(filename.right(1).find('/') == -1) + filename+="/"; + QString name = fileDlg->LineEdit1->text(); + filename+="text/plain/"+name; + qDebug(filename); + + QFile f(filename); + f.open( IO_WriteOnly); + if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { + DocLnk lnk; + lnk.setName(name); //sets file name + lnk.setFile(filename); //sets File property + lnk.setType("text/plain"); + if(!lnk.writeLink()) { + qDebug("Writing doclink did not work"); + } + } else + qWarning("Could not write file"); + f.close(); + + } +} diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h index 84adccd..c1e48da 100644 --- a/noncore/apps/advancedfm/output.h +++ b/noncore/apps/advancedfm/output.h @@ -1,33 +1,35 @@ /**************************************************************************** ** Form interface generated from reading ui file 'outputEdit.ui' ** ** Created: Fri Apr 12 15:12:44 2002 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef OUTPUT_H #define OUTPUT_H #include <qvariant.h> #include <qdialog.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QMultiLineEdit; class Output : public QDialog { Q_OBJECT public: Output( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~Output(); QMultiLineEdit* OutputEdit; protected: QGridLayout* OutputLayout; +protected slots: + void saveOutput(); }; #endif // OUTPUT_H |