Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 206 |
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 | |||
@@ -11,14 +11,8 @@ | |||
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> |
@@ -107,115 +101,115 @@ void AdvancedFm::tabChanged(QWidget *) { | |||
107 | 101 | ||
108 | void AdvancedFm::populateView() { | 102 | void 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 | ||
220 | void AdvancedFm::rePopulate() { | 214 | void AdvancedFm::rePopulate() { |
221 | populateView(); | 215 | populateView(); |
@@ -782,9 +776,9 @@ void AdvancedFm::gotoCustomDir(const QString &dir) { | |||
782 | } | 776 | } |
783 | } | 777 | } |
784 | 778 | ||
785 | QDir *AdvancedFm::CurrentDir() { | 779 | QDir *AdvancedFm::CurrentDir() { |
786 | 780 | ||
787 | if ( whichTab == 1) { | 781 | if ( whichTab == 1) { |
788 | return ¤tDir; | 782 | return ¤tDir; |
789 | } else { | 783 | } else { |
790 | return ¤tRemoteDir; | 784 | return ¤tRemoteDir; |
@@ -823,9 +817,9 @@ void AdvancedFm::setOtherTabCurrent() { | |||
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 | ||
830 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 824 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
831 | // qDebug("qcop message "+msg ); | 825 | // qDebug("qcop message "+msg ); |
@@ -863,9 +857,9 @@ void AdvancedFm::gotoDirectory(const QString &file) { | |||
863 | populateView(); | 857 | populateView(); |
864 | } | 858 | } |
865 | findFile(file); | 859 | findFile(file); |
866 | } | 860 | } |
867 | 861 | ||
868 | } | 862 | } |
869 | 863 | ||
870 | void AdvancedFm::findFile(const QString &fileName) { | 864 | void AdvancedFm::findFile(const QString &fileName) { |
871 | QFileInfo fi(fileName); | 865 | QFileInfo fi(fileName); |