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.cpp206
1 files changed, 100 insertions, 106 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 9c13e53..5148172 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -3,30 +3,24 @@
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
16// #include <opie/ofileselector.h>
17// #include <opie/ofiledialog.h>
18
19#include <opie/osplitter.h>
20
21#include <qpe/filemanager.h> 15#include <qpe/filemanager.h>
22#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
24#include <qpe/config.h> 18#include <qpe/config.h>
25#include <qpe/mimetype.h> 19#include <qpe/mimetype.h>
26#include <qpe/applnk.h> 20#include <qpe/applnk.h>
27#include <qpe/ir.h> 21#include <qpe/ir.h>
28#include <qpe/resource.h> 22#include <qpe/resource.h>
29#include <qpe/menubutton.h> 23#include <qpe/menubutton.h>
30 24
31#include <qdatetime.h> 25#include <qdatetime.h>
32#include <qfile.h> 26#include <qfile.h>
@@ -99,131 +93,131 @@ void AdvancedFm::tabChanged(QWidget *) {
99 93
100 QString fs= getFileSystemType( (const QString &) path); 94 QString fs= getFileSystemType( (const QString &) path);
101 95
102 setCaption(tr("AdvancedFm :: ")+fs+" :: " 96 setCaption(tr("AdvancedFm :: ")+fs+" :: "
103 +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); 97 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
104 chdir( path.latin1()); 98 chdir( path.latin1());
105} 99}
106 100
107 101
108void AdvancedFm::populateView() { 102void AdvancedFm::populateView() {
109 103
110// qWarning("PopulateView"); 104// qWarning("PopulateView");
111 QPixmap pm; 105 QPixmap pm;
112 QListView *thisView = CurrentView(); 106 QListView *thisView = CurrentView();
113 QDir *thisDir = CurrentDir(); 107 QDir *thisDir = CurrentDir();
114 QString path = thisDir->canonicalPath(); 108 QString path = thisDir->canonicalPath();
115 109
116//qWarning("path is "+path); 110//qWarning("path is "+path);
117 thisView->clear(); 111 thisView->clear();
118 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 112 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
119 thisDir->setMatchAllDirs(TRUE); 113 thisDir->setMatchAllDirs(TRUE);
120 thisDir->setNameFilter(filterStr); 114 thisDir->setNameFilter(filterStr);
121 QString fileL, fileS, fileDate; 115 QString fileL, fileS, fileDate;
122 QString fs= getFileSystemType((const QString &) path); 116 QString fs= getFileSystemType((const QString &) path);
123 setCaption(tr("AdvancedFm :: ")+fs+" :: " 117 setCaption(tr("AdvancedFm :: ")+fs+" :: "
124 +checkDiskSpace((const QString &) path)+ tr(" kB free") ); 118 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
125 bool isDir=FALSE; 119 bool isDir=FALSE;
126 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 120 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
127 QFileInfoListIterator it(*list); 121 QFileInfoListIterator it(*list);
128 QFileInfo *fi; 122 QFileInfo *fi;
129 while ( (fi=it.current()) ) { 123 while ( (fi=it.current()) ) {
130 if (fi->isSymLink() ) { 124 if (fi->isSymLink() ) {
131 QString symLink=fi->readLink(); 125 QString symLink=fi->readLink();
132 QFileInfo sym( symLink); 126 QFileInfo sym( symLink);
133 fileS.sprintf( "%10i", sym.size() ); 127 fileS.sprintf( "%10i", sym.size() );
134 fileL = fi->fileName() +" -> " + sym.filePath().data(); 128 fileL = fi->fileName() +" -> " + sym.filePath().data();
135 fileDate = sym.lastModified().toString(); 129 fileDate = sym.lastModified().toString();
136 } else { 130 } else {
137 fileS.sprintf( "%10i", fi->size() ); 131 fileS.sprintf( "%10i", fi->size() );
138 fileL = fi->fileName(); 132 fileL = fi->fileName();
139 fileDate= fi->lastModified().toString(); 133 fileDate= fi->lastModified().toString();
140 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 134 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
141// if(fileL == "..") 135// if(fileL == "..")
142 fileL += "/"; 136 fileL += "/";
143 isDir=TRUE; 137 isDir=TRUE;
144 } 138 }
145 } 139 }
146 QFileInfo fileInfo( path + "/" + fileL); 140 QFileInfo fileInfo( path + "/" + fileL);
147 141
148 if(fileL !="./" && fi->exists()) { 142 if(fileL !="./" && fi->exists()) {
149 item = new QListViewItem( thisView, fileL, fileS , fileDate); 143 item = new QListViewItem( thisView, fileL, fileS , fileDate);
150 144
151 if(isDir || fileL.find("/",0,TRUE) != -1) { 145 if(isDir || fileL.find("/",0,TRUE) != -1) {
152 146
153 if( !QDir( fi->filePath() ).isReadable()) //is directory 147 if( !QDir( fi->filePath() ).isReadable()) //is directory
154 pm = Resource::loadPixmap( "lockedfolder" ); 148 pm = Resource::loadPixmap( "lockedfolder" );
155 else 149 else
156 pm= Resource::loadPixmap( "folder" ); 150 pm= Resource::loadPixmap( "folder" );
157 } 151 }
158 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 152 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
159 pm = Resource::loadPixmap( "exec"); 153 pm = Resource::loadPixmap( "exec");
160 } 154 }
161 else if( (fileInfo.permission( QFileInfo::ExeUser) 155 else if( (fileInfo.permission( QFileInfo::ExeUser)
162 | fileInfo.permission( QFileInfo::ExeGroup) 156 | fileInfo.permission( QFileInfo::ExeGroup)
163 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 157 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
164 pm = Resource::loadPixmap( "exec"); 158 pm = Resource::loadPixmap( "exec");
165 } 159 }
166 else if( !fi->isReadable() ) { 160 else if( !fi->isReadable() ) {
167 pm = Resource::loadPixmap( "locked" ); 161 pm = Resource::loadPixmap( "locked" );
168 } 162 }
169 else { //everything else goes by mimetype 163 else { //everything else goes by mimetype
170 MimeType mt(fi->filePath()); 164 MimeType mt(fi->filePath());
171 pm=mt.pixmap(); //sets the correct pixmap for mimetype 165 pm=mt.pixmap(); //sets the correct pixmap for mimetype
172 if(pm.isNull()) { 166 if(pm.isNull()) {
173 pm = unknownXpm; 167 pm = unknownXpm;
174 } 168 }
175 } 169 }
176 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 170 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
177 // qDebug(" overlay link image"); 171 // qDebug(" overlay link image");
178 pm= Resource::loadPixmap( "advancedfm/symlink" ); 172 pm= Resource::loadPixmap( "advancedfm/symlink" );
179 // pm= Resource::loadPixmap( "folder" ); 173 // pm= Resource::loadPixmap( "folder" );
180// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 174// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
181// QPainter painter( &pm ); 175// QPainter painter( &pm );
182// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 176// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
183// pm.setMask( pm.createHeuristicMask( FALSE ) ); 177// pm.setMask( pm.createHeuristicMask( FALSE ) );
184 } 178 }
185 item->setPixmap( 0,pm); 179 item->setPixmap( 0,pm);
186 180
187 } 181 }
188 isDir=FALSE; 182 isDir=FALSE;
189 ++it; 183 ++it;
190 } 184 }
191 185
192 if( path.find("dev",0,TRUE) != -1) { 186 if( path.find("dev",0,TRUE) != -1) {
193 struct stat buf; 187 struct stat buf;
194 dev_t devT; 188 dev_t devT;
195 DIR *dir; 189 DIR *dir;
196 struct dirent *mydirent; 190 struct dirent *mydirent;
197 191
198 if((dir = opendir( path.latin1())) != NULL) 192 if((dir = opendir( path.latin1())) != NULL)
199 while ((mydirent = readdir(dir)) != NULL) { 193 while ((mydirent = readdir(dir)) != NULL) {
200 lstat( mydirent->d_name, &buf); 194 lstat( mydirent->d_name, &buf);
201// qDebug(mydirent->d_name); 195// qDebug(mydirent->d_name);
202 fileL.sprintf("%s", mydirent->d_name); 196 fileL.sprintf("%s", mydirent->d_name);
203 devT = buf.st_dev; 197 devT = buf.st_dev;
204 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 198 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
205 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 199 fileDate.sprintf("%s", ctime( &buf.st_mtime));
206 if( fileL.find(".") == -1 ) { 200 if( fileL.find(".") == -1 ) {
207 item= new QListViewItem( thisView, fileL, fileS, fileDate); 201 item= new QListViewItem( thisView, fileL, fileS, fileDate);
208 pm = unknownXpm; 202 pm = unknownXpm;
209 item->setPixmap( 0,pm); 203 item->setPixmap( 0,pm);
210 } 204 }
211 } 205 }
212 206
213 closedir(dir); 207 closedir(dir);
214 } 208 }
215 209
216 thisView->setSorting( 3,FALSE); 210 thisView->setSorting( 3,FALSE);
217 fillCombo( (const QString &) path ); 211 fillCombo( (const QString &) path );
218} 212}
219 213
220void AdvancedFm::rePopulate() { 214void AdvancedFm::rePopulate() {
221 populateView(); 215 populateView();
222 setOtherTabCurrent(); 216 setOtherTabCurrent();
223 populateView(); 217 populateView();
224 218
225// int tmpTab = whichTab; 219// int tmpTab = whichTab;
226// // qDebug("%d", tmpTab); 220// // qDebug("%d", tmpTab);
227 221
228// for(int i =1; i < 3; i++) { 222// for(int i =1; i < 3; i++) {
229// TabWidget->setCurrentWidget(i - 1); 223// TabWidget->setCurrentWidget(i - 1);
@@ -774,25 +768,25 @@ void AdvancedFm::gotoCustomDir(const QString &dir) {
774 gotoDirectory( dir); 768 gotoDirectory( dir);
775// if(QDir( curDir).exists() ) 769// if(QDir( curDir).exists() )
776// { 770// {
777// thisDir->setPath( curDir ); 771// thisDir->setPath( curDir );
778// chdir( curDir.latin1() ); 772// chdir( curDir.latin1() );
779// thisDir->cd( curDir, TRUE); 773// thisDir->cd( curDir, TRUE);
780// populateView(); 774// populateView();
781// } 775// }
782 } 776 }
783} 777}
784 778
785QDir *AdvancedFm::CurrentDir() { 779QDir *AdvancedFm::CurrentDir() {
786 780
787 if ( whichTab == 1) { 781 if ( whichTab == 1) {
788 return &currentDir; 782 return &currentDir;
789 } else { 783 } else {
790 return &currentRemoteDir; 784 return &currentRemoteDir;
791 } 785 }
792} 786}
793 787
794QDir *AdvancedFm::OtherDir() { 788QDir *AdvancedFm::OtherDir() {
795 if ( whichTab == 1) { 789 if ( whichTab == 1) {
796 return &currentRemoteDir; 790 return &currentRemoteDir;
797 } else { 791 } else {
798 return &currentDir; 792 return &currentDir;
@@ -815,25 +809,25 @@ QListView * AdvancedFm::OtherView() {
815 else 809 else
816 return Local_View; 810 return Local_View;
817} 811}
818 812
819void AdvancedFm::setOtherTabCurrent() { 813void AdvancedFm::setOtherTabCurrent() {
820// qWarning("setOtherTabCurrent() %d", whichTab); 814// qWarning("setOtherTabCurrent() %d", whichTab);
821 if ( whichTab == 1) { 815 if ( whichTab == 1) {
822 TabWidget->setCurrentWidget(1); 816 TabWidget->setCurrentWidget(1);
823 } else { 817 } else {
824 TabWidget->setCurrentWidget(0); 818 TabWidget->setCurrentWidget(0);
825 } 819 }
826 OtherView()->setFocus(); 820 OtherView()->setFocus();
827 OtherView()->setSelected( CurrentView()->firstChild(), true); 821 OtherView()->setSelected( CurrentView()->firstChild(), true);
828} 822}
829 823
830void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 824void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
831// qDebug("qcop message "+msg ); 825// qDebug("qcop message "+msg );
832 QDataStream stream ( data, IO_ReadOnly ); 826 QDataStream stream ( data, IO_ReadOnly );
833 if ( msg == "openDirectory(QString)" ) { 827 if ( msg == "openDirectory(QString)" ) {
834// qDebug("received"); 828// qDebug("received");
835 QString file; 829 QString file;
836 stream >> file; 830 stream >> file;
837 gotoDirectory( (const QString &) file); 831 gotoDirectory( (const QString &) file);
838 } 832 }
839} 833}
@@ -855,25 +849,25 @@ void AdvancedFm::gotoDirectory(const QString &file) {
855 } 849 }
856 else if(QFileInfo(curDir).exists()) { 850 else if(QFileInfo(curDir).exists()) {
857 QFileInfo fileInfo(curDir); 851 QFileInfo fileInfo(curDir);
858 curDir=fileInfo.dirPath(); 852 curDir=fileInfo.dirPath();
859 if(QDir( curDir).exists() ) { 853 if(QDir( curDir).exists() ) {
860 thisDir->setPath( curDir ); 854 thisDir->setPath( curDir );
861 chdir( curDir.latin1() ); 855 chdir( curDir.latin1() );
862 thisDir->cd( curDir, TRUE); 856 thisDir->cd( curDir, TRUE);
863 populateView(); 857 populateView();
864 } 858 }
865 findFile(file); 859 findFile(file);
866 } 860 }
867 861
868} 862}
869 863
870void AdvancedFm::findFile(const QString &fileName) { 864void AdvancedFm::findFile(const QString &fileName) {
871 QFileInfo fi(fileName); 865 QFileInfo fi(fileName);
872 QListView *thisView = CurrentView(); 866 QListView *thisView = CurrentView();
873 QListViewItemIterator it( thisView ); 867 QListViewItemIterator it( thisView );
874 for ( ; it.current(); ++it ) { 868 for ( ; it.current(); ++it ) {
875 if(it.current()->text(0) == fi.fileName()) { 869 if(it.current()->text(0) == fi.fileName()) {
876 it.current()->setSelected(true); 870 it.current()->setSelected(true);
877 thisView->ensureItemVisible(it.current()); 871 thisView->ensureItemVisible(it.current());
878 } 872 }
879 } 873 }