author | llornkcor <llornkcor> | 2003-11-07 12:37:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-11-07 12:37:57 (UTC) |
commit | fa1e47631442d509e9c1603684bdc9e9590cf866 (patch) (unidiff) | |
tree | 5411adf72ccde8c46b13b0487a2602609b081d9e /noncore/apps/advancedfm/advancedfm.cpp | |
parent | 82fdb639058354177d27b432f97e8750ac846ee6 (diff) | |
download | opie-fa1e47631442d509e9c1603684bdc9e9590cf866.zip opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.gz opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.bz2 |
from 1.0, needs fix
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 201 |
1 files changed, 102 insertions, 99 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 2fc4b49..ecf471d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -102,112 +102,115 @@ void AdvancedFm::tabChanged(QWidget *) { | |||
102 | 102 | ||
103 | 103 | ||
104 | void AdvancedFm::populateView() { | 104 | void AdvancedFm::populateView() { |
105 | QPixmap pm; | ||
106 | QListView *thisView = CurrentView(); | ||
107 | QDir *thisDir = CurrentDir(); | ||
108 | QString path = thisDir->canonicalPath(); | ||
109 | // qWarning("path is "+path); | ||
110 | thisView->clear(); | ||
111 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | ||
112 | thisDir->setMatchAllDirs(TRUE); | ||
113 | thisDir->setNameFilter(filterStr); | ||
114 | QString fileL, fileS, fileDate; | ||
115 | QString fs= getFileSystemType((const QString &) path); | ||
116 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | ||
117 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | ||
118 | bool isDir=FALSE; | ||
119 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | ||
120 | QFileInfoListIterator it(*list); | ||
121 | QFileInfo *fi; | ||
122 | while ( (fi=it.current()) ) { | ||
123 | if (fi->isSymLink() ) { | ||
124 | QString symLink=fi->readLink(); | ||
125 | QFileInfo sym( symLink); | ||
126 | fileS.sprintf( "%10i", sym.size() ); | ||
127 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | ||
128 | fileDate = sym.lastModified().toString(); | ||
129 | } else { | ||
130 | fileS.sprintf( "%10i", fi->size() ); | ||
131 | fileL = fi->fileName(); | ||
132 | fileDate= fi->lastModified().toString(); | ||
133 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | ||
134 | // if(fileL == "..") | ||
135 | fileL += "/"; | ||
136 | isDir=TRUE; | ||
137 | } | ||
138 | } | ||
139 | QFileInfo fileInfo( path + "/" + fileL); | ||
140 | 105 | ||
141 | if(fileL !="./" && fi->exists()) { | 106 | qWarning("PopulateView"); |
142 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 107 | QPixmap pm; |
143 | 108 | QListView *thisView = CurrentView(); | |
144 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 109 | QDir *thisDir = CurrentDir(); |
145 | 110 | QString path = thisDir->canonicalPath(); | |
146 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 111 | |
147 | pm = Resource::loadPixmap( "lockedfolder" ); | 112 | qWarning("path is "+path); |
148 | else | 113 | thisView->clear(); |
149 | pm= Resource::loadPixmap( "folder" ); | 114 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
150 | } | 115 | thisDir->setMatchAllDirs(TRUE); |
151 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 116 | thisDir->setNameFilter(filterStr); |
152 | pm = Resource::loadPixmap( "exec"); | 117 | QString fileL, fileS, fileDate; |
153 | } | 118 | QString fs= getFileSystemType((const QString &) path); |
154 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 119 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
155 | | fileInfo.permission( QFileInfo::ExeGroup) | 120 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
156 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 121 | bool isDir=FALSE; |
157 | pm = Resource::loadPixmap( "exec"); | 122 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
158 | } | 123 | QFileInfoListIterator it(*list); |
159 | else if( !fi->isReadable() ) { | 124 | QFileInfo *fi; |
160 | pm = Resource::loadPixmap( "locked" ); | 125 | while ( (fi=it.current()) ) { |
161 | } | 126 | if (fi->isSymLink() ) { |
162 | else { //everything else goes by mimetype | 127 | QString symLink=fi->readLink(); |
163 | MimeType mt(fi->filePath()); | 128 | QFileInfo sym( symLink); |
164 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 129 | fileS.sprintf( "%10i", sym.size() ); |
165 | if(pm.isNull()) { | 130 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
166 | pm = unknownXpm; | 131 | fileDate = sym.lastModified().toString(); |
167 | } | 132 | } else { |
168 | } | 133 | fileS.sprintf( "%10i", fi->size() ); |
169 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 134 | fileL = fi->fileName(); |
170 | // qDebug(" overlay link image"); | 135 | fileDate= fi->lastModified().toString(); |
171 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 136 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
172 | // pm= Resource::loadPixmap( "folder" ); | 137 | // if(fileL == "..") |
138 | fileL += "/"; | ||
139 | isDir=TRUE; | ||
140 | } | ||
141 | } | ||
142 | QFileInfo fileInfo( path + "/" + fileL); | ||
143 | |||
144 | if(fileL !="./" && fi->exists()) { | ||
145 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | ||
146 | |||
147 | if(isDir || fileL.find("/",0,TRUE) != -1) { | ||
148 | |||
149 | if( !QDir( fi->filePath() ).isReadable()) //is directory | ||
150 | pm = Resource::loadPixmap( "lockedfolder" ); | ||
151 | else | ||
152 | pm= Resource::loadPixmap( "folder" ); | ||
153 | } | ||
154 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
155 | pm = Resource::loadPixmap( "exec"); | ||
156 | } | ||
157 | else if( (fileInfo.permission( QFileInfo::ExeUser) | ||
158 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
159 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | ||
160 | pm = Resource::loadPixmap( "exec"); | ||
161 | } | ||
162 | else if( !fi->isReadable() ) { | ||
163 | pm = Resource::loadPixmap( "locked" ); | ||
164 | } | ||
165 | else { //everything else goes by mimetype | ||
166 | MimeType mt(fi->filePath()); | ||
167 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | ||
168 | if(pm.isNull()) { | ||
169 | pm = unknownXpm; | ||
170 | } | ||
171 | } | ||
172 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | ||
173 | // qDebug(" overlay link image"); | ||
174 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | ||
175 | // pm= Resource::loadPixmap( "folder" ); | ||
173 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 176 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
174 | // QPainter painter( &pm ); | 177 | // QPainter painter( &pm ); |
175 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 178 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
176 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 179 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
177 | } | 180 | } |
178 | item->setPixmap( 0,pm); | 181 | item->setPixmap( 0,pm); |
179 | 182 | ||
180 | } | 183 | } |
181 | isDir=FALSE; | 184 | isDir=FALSE; |
182 | ++it; | 185 | ++it; |
183 | } | 186 | } |
184 | 187 | ||
185 | if( path.find("dev",0,TRUE) != -1) { | 188 | if( path.find("dev",0,TRUE) != -1) { |
186 | struct stat buf; | 189 | struct stat buf; |
187 | dev_t devT; | 190 | dev_t devT; |
188 | DIR *dir; | 191 | DIR *dir; |
189 | struct dirent *mydirent; | 192 | struct dirent *mydirent; |
190 | 193 | ||
191 | if((dir = opendir( path.latin1())) != NULL) | 194 | if((dir = opendir( path.latin1())) != NULL) |
192 | while ((mydirent = readdir(dir)) != NULL) { | 195 | while ((mydirent = readdir(dir)) != NULL) { |
193 | lstat( mydirent->d_name, &buf); | 196 | lstat( mydirent->d_name, &buf); |
194 | // qDebug(mydirent->d_name); | 197 | // qDebug(mydirent->d_name); |
195 | fileL.sprintf("%s", mydirent->d_name); | 198 | fileL.sprintf("%s", mydirent->d_name); |
196 | devT = buf.st_dev; | 199 | devT = buf.st_dev; |
197 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 200 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
198 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 201 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
199 | if( fileL.find(".") == -1 ) { | 202 | if( fileL.find(".") == -1 ) { |
200 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 203 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
201 | pm = unknownXpm; | 204 | pm = unknownXpm; |
202 | item->setPixmap( 0,pm); | 205 | item->setPixmap( 0,pm); |
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
206 | closedir(dir); | 209 | closedir(dir); |
207 | } | 210 | } |
208 | 211 | ||
209 | thisView->setSorting( 3,FALSE); | 212 | thisView->setSorting( 3,FALSE); |
210 | fillCombo( (const QString &) path ); | 213 | fillCombo( (const QString &) path ); |
211 | } | 214 | } |
212 | 215 | ||
213 | void AdvancedFm::rePopulate() { | 216 | void AdvancedFm::rePopulate() { |
@@ -809,7 +812,7 @@ QListView * AdvancedFm::OtherView() { | |||
809 | } | 812 | } |
810 | 813 | ||
811 | void AdvancedFm::setOtherTabCurrent() { | 814 | void AdvancedFm::setOtherTabCurrent() { |
812 | // qWarning("setOtherTabCurrent()"); | 815 | qWarning("setOtherTabCurrent() %d", whichTab); |
813 | if ( whichTab == 1) { | 816 | if ( whichTab == 1) { |
814 | TabWidget->setCurrentWidget(1); | 817 | TabWidget->setCurrentWidget(1); |
815 | } else { | 818 | } else { |