author | llornkcor <llornkcor> | 2005-03-24 20:14:38 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-03-24 20:14:38 (UTC) |
commit | 1e6c3181dcc7ec4edbe99db0d886ce7a9c483056 (patch) (unidiff) | |
tree | 38e98006c0bb49bb6b1008dddb840e961bb2b775 | |
parent | 38ace7e9b3c9665336c0e6d2350895b147858f1f (diff) | |
download | opie-1e6c3181dcc7ec4edbe99db0d886ce7a9c483056.zip opie-1e6c3181dcc7ec4edbe99db0d886ce7a9c483056.tar.gz opie-1e6c3181dcc7ec4edbe99db0d886ce7a9c483056.tar.bz2 |
cd to sd or mmc
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index fd81313..979549d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -80,514 +80,519 @@ void AdvancedFm::tabChanged(QWidget *wd) { | |||
80 | whichTab = 2; | 80 | whichTab = 2; |
81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
84 | } | 84 | } |
85 | qApp->processEvents(); | 85 | qApp->processEvents(); |
86 | QString path = CurrentDir()->canonicalPath(); | 86 | QString path = CurrentDir()->canonicalPath(); |
87 | 87 | ||
88 | chdir( path.latin1()); | 88 | chdir( path.latin1()); |
89 | currentPathCombo->lineEdit()->setText(path); | 89 | currentPathCombo->lineEdit()->setText(path); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | void AdvancedFm::populateView() { | 93 | void AdvancedFm::populateView() { |
94 | 94 | ||
95 | QPixmap pm; | 95 | QPixmap pm; |
96 | QListView *thisView = CurrentView(); | 96 | QListView *thisView = CurrentView(); |
97 | QDir *thisDir = CurrentDir(); | 97 | QDir *thisDir = CurrentDir(); |
98 | QString path = thisDir->canonicalPath(); | 98 | QString path = thisDir->canonicalPath(); |
99 | 99 | ||
100 | thisView->clear(); | 100 | thisView->clear(); |
101 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 101 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
102 | thisDir->setMatchAllDirs(TRUE); | 102 | thisDir->setMatchAllDirs(TRUE); |
103 | thisDir->setNameFilter(filterStr); | 103 | thisDir->setNameFilter(filterStr); |
104 | QString fileL, fileS, fileDate; | 104 | QString fileL, fileS, fileDate; |
105 | 105 | ||
106 | QString fs = getFileSystemType((const QString &) path); | 106 | QString fs = getFileSystemType((const QString &) path); |
107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
109 | bool isDir = FALSE; | 109 | bool isDir = FALSE; |
110 | 110 | ||
111 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 111 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
112 | QFileInfoListIterator it(*list); | 112 | QFileInfoListIterator it(*list); |
113 | QFileInfo *fi; | 113 | QFileInfo *fi; |
114 | while ( (fi=it.current()) ) { | 114 | while ( (fi=it.current()) ) { |
115 | if (fi->isSymLink() ) { | 115 | if (fi->isSymLink() ) { |
116 | QString symLink = fi->readLink(); | 116 | QString symLink = fi->readLink(); |
117 | QFileInfo sym( symLink); | 117 | QFileInfo sym( symLink); |
118 | fileS.sprintf( "%10i", sym.size() ); | 118 | fileS.sprintf( "%10i", sym.size() ); |
119 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 119 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
120 | fileDate = sym.lastModified().toString(); | 120 | fileDate = sym.lastModified().toString(); |
121 | } else { | 121 | } else { |
122 | fileS.sprintf( "%10i", fi->size() ); | 122 | fileS.sprintf( "%10i", fi->size() ); |
123 | fileL = fi->fileName(); | 123 | fileL = fi->fileName(); |
124 | fileDate= fi->lastModified().toString(); | 124 | fileDate= fi->lastModified().toString(); |
125 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 125 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
126 | // if(fileL == "..") | 126 | // if(fileL == "..") |
127 | fileL += "/"; | 127 | fileL += "/"; |
128 | isDir=TRUE; | 128 | isDir=TRUE; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | QFileInfo fileInfo( path + "/" + fileL); | 131 | QFileInfo fileInfo( path + "/" + fileL); |
132 | 132 | ||
133 | if(fileL !="./" && fi->exists()) { | 133 | if(fileL !="./" && fi->exists()) { |
134 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 134 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
135 | 135 | ||
136 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 136 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
137 | 137 | ||
138 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 138 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
139 | pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 139 | pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
140 | else | 140 | else |
141 | pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 141 | pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
142 | } | 142 | } |
143 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 143 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
144 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 144 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
145 | } | 145 | } |
146 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 146 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
147 | | fileInfo.permission( QFileInfo::ExeGroup) | 147 | | fileInfo.permission( QFileInfo::ExeGroup) |
148 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 148 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
149 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 149 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
150 | } | 150 | } |
151 | else if( !fi->isReadable() ) { | 151 | else if( !fi->isReadable() ) { |
152 | pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 152 | pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
153 | } | 153 | } |
154 | else { //everything else goes by mimetype | 154 | else { //everything else goes by mimetype |
155 | MimeType mt(fi->filePath()); | 155 | MimeType mt(fi->filePath()); |
156 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 156 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
157 | if(pm.isNull()) { | 157 | if(pm.isNull()) { |
158 | pm = unknownXpm; | 158 | pm = unknownXpm; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 161 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
162 | // odebug << " overlay link image" << oendl; | 162 | // odebug << " overlay link image" << oendl; |
163 | pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 163 | pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
164 | // pm= Resource::loadPixmap( "folder" ); | 164 | // pm= Resource::loadPixmap( "folder" ); |
165 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 165 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
166 | // QPainter painter( &pm ); | 166 | // QPainter painter( &pm ); |
167 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 167 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
168 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 168 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
169 | } | 169 | } |
170 | item->setPixmap( 0, pm ); | 170 | item->setPixmap( 0, pm ); |
171 | 171 | ||
172 | } | 172 | } |
173 | isDir=FALSE; | 173 | isDir=FALSE; |
174 | ++it; | 174 | ++it; |
175 | } | 175 | } |
176 | 176 | ||
177 | if( path.find("dev",0,TRUE) != -1) { | 177 | if( path.find("dev",0,TRUE) != -1) { |
178 | struct stat buf; | 178 | struct stat buf; |
179 | dev_t devT; | 179 | dev_t devT; |
180 | DIR *dir; | 180 | DIR *dir; |
181 | struct dirent *mydirent; | 181 | struct dirent *mydirent; |
182 | 182 | ||
183 | if((dir = opendir( path.latin1())) != NULL) | 183 | if((dir = opendir( path.latin1())) != NULL) |
184 | while ((mydirent = readdir(dir)) != NULL) { | 184 | while ((mydirent = readdir(dir)) != NULL) { |
185 | lstat( mydirent->d_name, &buf); | 185 | lstat( mydirent->d_name, &buf); |
186 | // odebug << mydirent->d_name << oendl; | 186 | // odebug << mydirent->d_name << oendl; |
187 | fileL.sprintf("%s", mydirent->d_name); | 187 | fileL.sprintf("%s", mydirent->d_name); |
188 | devT = buf.st_dev; | 188 | devT = buf.st_dev; |
189 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 189 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
190 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 190 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
191 | if( fileL.find(".") == -1 ) { | 191 | if( fileL.find(".") == -1 ) { |
192 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 192 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
193 | pm = unknownXpm; | 193 | pm = unknownXpm; |
194 | item->setPixmap( 0,pm); | 194 | item->setPixmap( 0,pm); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | closedir(dir); | 198 | closedir(dir); |
199 | } | 199 | } |
200 | 200 | ||
201 | thisView->setSorting( 3,FALSE); | 201 | thisView->setSorting( 3,FALSE); |
202 | fillCombo( (const QString &) path ); | 202 | fillCombo( (const QString &) path ); |
203 | } | 203 | } |
204 | 204 | ||
205 | void AdvancedFm::rePopulate() { | 205 | void AdvancedFm::rePopulate() { |
206 | // qDebug("repopulate views"); | 206 | // qDebug("repopulate views"); |
207 | populateView(); | 207 | populateView(); |
208 | setOtherTabCurrent(); | 208 | setOtherTabCurrent(); |
209 | populateView(); | 209 | populateView(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 212 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
213 | if(selectedItem) { | 213 | if(selectedItem) { |
214 | QString strItem=selectedItem->text(0); | 214 | QString strItem=selectedItem->text(0); |
215 | // owarn << strItem << oendl; | 215 | // owarn << strItem << oendl; |
216 | QString strSize=selectedItem->text(1); | 216 | QString strSize=selectedItem->text(1); |
217 | strSize=strSize.stripWhiteSpace(); | 217 | strSize=strSize.stripWhiteSpace(); |
218 | bool isDirectory = false; | 218 | bool isDirectory = false; |
219 | QString strItem2; | 219 | QString strItem2; |
220 | 220 | ||
221 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 221 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
222 | strItem2 = dealWithSymName((const QString&)strItem); | 222 | strItem2 = dealWithSymName((const QString&)strItem); |
223 | if(QDir(strItem2).exists() ) | 223 | if(QDir(strItem2).exists() ) |
224 | strItem = strItem2; | 224 | strItem = strItem2; |
225 | } | 225 | } |
226 | 226 | ||
227 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 227 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
228 | 228 | ||
229 | if(QDir(strItem).exists()) | 229 | if(QDir(strItem).exists()) |
230 | isDirectory = true; | 230 | isDirectory = true; |
231 | } | 231 | } |
232 | 232 | ||
233 | if( isDirectory ) { | 233 | if( isDirectory ) { |
234 | CurrentDir()->cd( strItem, TRUE); | 234 | CurrentDir()->cd( strItem, TRUE); |
235 | populateView(); | 235 | populateView(); |
236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
237 | } | 237 | } |
238 | chdir( strItem.latin1()); | 238 | chdir( strItem.latin1()); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
243 | Q_UNUSED(item); | 243 | Q_UNUSED(item); |
244 | switch (mouse) { | 244 | switch (mouse) { |
245 | case 1: | 245 | case 1: |
246 | { | 246 | { |
247 | if(renameBox != 0 ) { | 247 | if(renameBox != 0 ) { |
248 | cancelRename(); | 248 | cancelRename(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | // case 2: | 252 | // case 2: |
253 | // menuTimer.start( 50, TRUE ); | 253 | // menuTimer.start( 50, TRUE ); |
254 | // break; | 254 | // break; |
255 | }; | 255 | }; |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AdvancedFm::refreshCurrentTab() { | 259 | void AdvancedFm::refreshCurrentTab() { |
260 | populateView(); | 260 | populateView(); |
261 | // if ( TabWidget->currentWidget() == tab) { | 261 | // if ( TabWidget->currentWidget() == tab) { |
262 | } | 262 | } |
263 | 263 | ||
264 | void AdvancedFm::switchToLocalTab() { | 264 | void AdvancedFm::switchToLocalTab() { |
265 | TabWidget->setCurrentWidget(tab); | 265 | TabWidget->setCurrentWidget(tab); |
266 | Local_View->setFocus(); | 266 | Local_View->setFocus(); |
267 | // whichTab = 1; | 267 | // whichTab = 1; |
268 | } | 268 | } |
269 | 269 | ||
270 | void AdvancedFm::switchToRemoteTab() { | 270 | void AdvancedFm::switchToRemoteTab() { |
271 | TabWidget->setCurrentWidget(tab_2); | 271 | TabWidget->setCurrentWidget(tab_2); |
272 | Remote_View->setFocus(); | 272 | Remote_View->setFocus(); |
273 | // whichTab = 2; | 273 | // whichTab = 2; |
274 | } | 274 | } |
275 | 275 | ||
276 | void AdvancedFm::currentPathComboChanged() { | 276 | void AdvancedFm::currentPathComboChanged() { |
277 | QString pDir = currentPathCombo->lineEdit()->text(); | 277 | QString pDir = currentPathCombo->lineEdit()->text(); |
278 | if(QDir(pDir).exists()) { | 278 | if(QDir(pDir).exists()) { |
279 | CurrentDir()->setPath(pDir ); | 279 | CurrentDir()->setPath(pDir ); |
280 | populateView(); | 280 | populateView(); |
281 | } else { | 281 | } else { |
282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); | 282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 286 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
287 | 287 | ||
288 | if ( TabWidget->currentWidget() == tab) { | 288 | if ( TabWidget->currentWidget() == tab) { |
289 | // if ( whichTab == 1) { | 289 | // if ( whichTab == 1) { |
290 | currentPathCombo->lineEdit()->setText( currentPath); | 290 | currentPathCombo->lineEdit()->setText( currentPath); |
291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
292 | currentPathCombo->clear(); | 292 | currentPathCombo->clear(); |
293 | localDirPathStringList.prepend( currentPath ); | 293 | localDirPathStringList.prepend( currentPath ); |
294 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 294 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
295 | } | 295 | } |
296 | } else { | 296 | } else { |
297 | currentPathCombo->lineEdit()->setText( currentPath); | 297 | currentPathCombo->lineEdit()->setText( currentPath); |
298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
299 | currentPathCombo->clear(); | 299 | currentPathCombo->clear(); |
300 | remoteDirPathStringList.prepend( currentPath ); | 300 | remoteDirPathStringList.prepend( currentPath ); |
301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QStringList AdvancedFm::getPath() { | 306 | QStringList AdvancedFm::getPath() { |
307 | QStringList strList; | 307 | QStringList strList; |
308 | QListView *thisView=CurrentView(); | 308 | QListView *thisView=CurrentView(); |
309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
310 | QListViewItemIterator it( thisView ); | 310 | QListViewItemIterator it( thisView ); |
311 | for ( ; it.current(); ++it ) { | 311 | for ( ; it.current(); ++it ) { |
312 | if ( it.current()->isSelected() ) { | 312 | if ( it.current()->isSelected() ) { |
313 | strList << it.current()->text(0); | 313 | strList << it.current()->text(0); |
314 | // odebug << it.current()->text(0) << oendl; | 314 | // odebug << it.current()->text(0) << oendl; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | return strList; | 317 | return strList; |
318 | } | 318 | } |
319 | 319 | ||
320 | void AdvancedFm::changeTo(const QString &dir) { | 320 | void AdvancedFm::changeTo(const QString &dir) { |
321 | chdir( dir.latin1()); | 321 | chdir( dir.latin1()); |
322 | CurrentDir()->cd(dir, TRUE); | 322 | CurrentDir()->cd(dir, TRUE); |
323 | populateView(); | 323 | populateView(); |
324 | update(); | 324 | update(); |
325 | } | 325 | } |
326 | 326 | ||
327 | void AdvancedFm::homeButtonPushed() { | 327 | void AdvancedFm::homeButtonPushed() { |
328 | changeTo(QDir::homeDirPath()); | 328 | changeTo(QDir::homeDirPath()); |
329 | } | 329 | } |
330 | 330 | ||
331 | void AdvancedFm::docButtonPushed() { | 331 | void AdvancedFm::docButtonPushed() { |
332 | changeTo(QPEApplication::documentDir()); | 332 | changeTo(QPEApplication::documentDir()); |
333 | } | 333 | } |
334 | 334 | ||
335 | void AdvancedFm::SDButtonPushed() { | 335 | void AdvancedFm::SDButtonPushed() { |
336 | Opie::Core::OStorageInfo info; | 336 | Opie::Core::OStorageInfo info; |
337 | changeTo(info.sdPath()); | 337 | if(StorageInfo::hasSd() ) { |
338 | changeTo(info.sdPath()); | ||
339 | } | ||
340 | else if(StorageInfo::hasMmc()) { | ||
341 | changeTo(info.mmcPath()); | ||
342 | } | ||
338 | } | 343 | } |
339 | 344 | ||
340 | void AdvancedFm::CFButtonPushed() { | 345 | void AdvancedFm::CFButtonPushed() { |
341 | Opie::Core::OStorageInfo info; | 346 | Opie::Core::OStorageInfo info; |
342 | changeTo(info.cfPath()); | 347 | changeTo(info.cfPath()); |
343 | } | 348 | } |
344 | 349 | ||
345 | void AdvancedFm::QPEButtonPushed() { | 350 | void AdvancedFm::QPEButtonPushed() { |
346 | changeTo(QPEApplication::qpeDir()); | 351 | changeTo(QPEApplication::qpeDir()); |
347 | } | 352 | } |
348 | 353 | ||
349 | void AdvancedFm::doAbout() { | 354 | void AdvancedFm::doAbout() { |
350 | 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>")); | 355 | 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>")); |
351 | } | 356 | } |
352 | 357 | ||
353 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 358 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
354 | Q_UNUSED(e); | 359 | Q_UNUSED(e); |
355 | } | 360 | } |
356 | 361 | ||
357 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 362 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
358 | // if( CurrentView()->hasFocus() ) | 363 | // if( CurrentView()->hasFocus() ) |
359 | // e->ignore(); | 364 | // e->ignore(); |
360 | 365 | ||
361 | if( currentPathCombo->lineEdit()->hasFocus()) { | 366 | if( currentPathCombo->lineEdit()->hasFocus()) { |
362 | // qDebug("shout!"); | 367 | // qDebug("shout!"); |
363 | } | 368 | } |
364 | 369 | ||
365 | else if( e->key() == Key_Left ) | 370 | else if( e->key() == Key_Left ) |
366 | upDir(); | 371 | upDir(); |
367 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 372 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
368 | navigateToSelected(); | 373 | navigateToSelected(); |
369 | else if( e->key() == Key_Tab) | 374 | else if( e->key() == Key_Tab) |
370 | setOtherTabCurrent(); | 375 | setOtherTabCurrent(); |
371 | else if( e->key() == Key_Delete ) | 376 | else if( e->key() == Key_Delete ) |
372 | del(); | 377 | del(); |
373 | else | 378 | else |
374 | e->accept(); | 379 | e->accept(); |
375 | 380 | ||
376 | } | 381 | } |
377 | 382 | ||
378 | 383 | ||
379 | void AdvancedFm::parsetab(const QString &fileName) { | 384 | void AdvancedFm::parsetab(const QString &fileName) { |
380 | 385 | ||
381 | fileSystemTypeList.clear(); | 386 | fileSystemTypeList.clear(); |
382 | fsList.clear(); | 387 | fsList.clear(); |
383 | struct mntent *me; | 388 | struct mntent *me; |
384 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 389 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
385 | if ( mntfp ) { | 390 | if ( mntfp ) { |
386 | while ( (me = getmntent( mntfp )) != 0 ) { | 391 | while ( (me = getmntent( mntfp )) != 0 ) { |
387 | QString deviceName = me->mnt_fsname; | 392 | QString deviceName = me->mnt_fsname; |
388 | QString filesystemType = me->mnt_type; | 393 | QString filesystemType = me->mnt_type; |
389 | QString mountDir = me->mnt_dir; | 394 | QString mountDir = me->mnt_dir; |
390 | if(deviceName != "none") { | 395 | if(deviceName != "none") { |
391 | if( fsList.contains(filesystemType) == 0 | 396 | if( fsList.contains(filesystemType) == 0 |
392 | & filesystemType.find("proc",0,TRUE) == -1 | 397 | & filesystemType.find("proc",0,TRUE) == -1 |
393 | & filesystemType.find("cramfs",0,TRUE) == -1 | 398 | & filesystemType.find("cramfs",0,TRUE) == -1 |
394 | & filesystemType.find("auto",0,TRUE) == -1) | 399 | & filesystemType.find("auto",0,TRUE) == -1) |
395 | fsList << filesystemType; | 400 | fsList << filesystemType; |
396 | fileSystemTypeList << mountDir+"::"+filesystemType; | 401 | fileSystemTypeList << mountDir+"::"+filesystemType; |
397 | } | 402 | } |
398 | } | 403 | } |
399 | } | 404 | } |
400 | endmntent( mntfp ); | 405 | endmntent( mntfp ); |
401 | } | 406 | } |
402 | 407 | ||
403 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 408 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
404 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 409 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
405 | QString current = currentText;//.right( currentText.length()-1); | 410 | QString current = currentText;//.right( currentText.length()-1); |
406 | QString baseFs; | 411 | QString baseFs; |
407 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 412 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
408 | QString temp = (*it); | 413 | QString temp = (*it); |
409 | QString path = temp.left(temp.find("::",0,TRUE) ); | 414 | QString path = temp.left(temp.find("::",0,TRUE) ); |
410 | path = path.right( path.length()-1); | 415 | path = path.right( path.length()-1); |
411 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 416 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
412 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 417 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
413 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 418 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
414 | } | 419 | } |
415 | } | 420 | } |
416 | return baseFs; | 421 | return baseFs; |
417 | } | 422 | } |
418 | 423 | ||
419 | QString AdvancedFm::getDiskSpace( const QString &path) { | 424 | QString AdvancedFm::getDiskSpace( const QString &path) { |
420 | struct statfs fss; | 425 | struct statfs fss; |
421 | if ( !statfs( path.latin1(), &fss ) ) { | 426 | if ( !statfs( path.latin1(), &fss ) ) { |
422 | int blkSize = fss.f_bsize; | 427 | int blkSize = fss.f_bsize; |
423 | // int totalBlks = fs.f_blocks; | 428 | // int totalBlks = fs.f_blocks; |
424 | int availBlks = fss.f_bavail; | 429 | int availBlks = fss.f_bavail; |
425 | 430 | ||
426 | long mult = blkSize / 1024; | 431 | long mult = blkSize / 1024; |
427 | long div = 1024 / blkSize; | 432 | long div = 1024 / blkSize; |
428 | if ( !mult ) mult = 1; | 433 | if ( !mult ) mult = 1; |
429 | if ( !div ) div = 1; | 434 | if ( !div ) div = 1; |
430 | 435 | ||
431 | return QString::number(availBlks * mult / div); | 436 | return QString::number(availBlks * mult / div); |
432 | } | 437 | } |
433 | return ""; | 438 | return ""; |
434 | } | 439 | } |
435 | 440 | ||
436 | 441 | ||
437 | void AdvancedFm::showFileMenu() { | 442 | void AdvancedFm::showFileMenu() { |
438 | QString curApp; | 443 | QString curApp; |
439 | curApp = CurrentView()->currentItem()->text(0); | 444 | curApp = CurrentView()->currentItem()->text(0); |
440 | 445 | ||
441 | MimeType mt(curApp); | 446 | MimeType mt(curApp); |
442 | const AppLnk* app = mt.application(); | 447 | const AppLnk* app = mt.application(); |
443 | QFile fi(curApp); | 448 | QFile fi(curApp); |
444 | QPopupMenu *m = new QPopupMenu(0); | 449 | QPopupMenu *m = new QPopupMenu(0); |
445 | QPopupMenu *n = new QPopupMenu(0); | 450 | QPopupMenu *n = new QPopupMenu(0); |
446 | // QPopupMenu *o = new QPopupMenu(0); | 451 | // QPopupMenu *o = new QPopupMenu(0); |
447 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 452 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
448 | 453 | ||
449 | if ( QFileInfo(fi).isDir()) { | 454 | if ( QFileInfo(fi).isDir()) { |
450 | m->insertSeparator(); | 455 | m->insertSeparator(); |
451 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 456 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
452 | } else { | 457 | } else { |
453 | 458 | ||
454 | if (app) | 459 | if (app) |
455 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 460 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
456 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 461 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
457 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 462 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
458 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 463 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); |
459 | } | 464 | } |
460 | 465 | ||
461 | m->insertItem(tr("Actions"),n); | 466 | m->insertItem(tr("Actions"),n); |
462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 467 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
463 | 468 | ||
464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 469 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
465 | 470 | ||
466 | n->insertSeparator(); | 471 | n->insertSeparator(); |
467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 472 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
468 | 473 | ||
469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 474 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 475 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 476 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 477 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
473 | 478 | ||
474 | n->insertSeparator(); | 479 | n->insertSeparator(); |
475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 480 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 481 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
477 | 482 | ||
478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 483 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 484 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
480 | 485 | ||
481 | m->insertSeparator(); | 486 | m->insertSeparator(); |
482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 487 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
483 | 488 | ||
484 | #if defined(QT_QWS_OPIE) | 489 | #if defined(QT_QWS_OPIE) |
485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 490 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
486 | #endif | 491 | #endif |
487 | m->setCheckable(TRUE); | 492 | m->setCheckable(TRUE); |
488 | if (!b) | 493 | if (!b) |
489 | m->setItemChecked(m->idAt(0),TRUE); | 494 | m->setItemChecked(m->idAt(0),TRUE); |
490 | else | 495 | else |
491 | m->setItemChecked(m->idAt(0),FALSE); | 496 | m->setItemChecked(m->idAt(0),FALSE); |
492 | 497 | ||
493 | if(Ir::supported()) | 498 | if(Ir::supported()) |
494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 499 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
495 | m->setFocus(); | 500 | m->setFocus(); |
496 | 501 | ||
497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 502 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
498 | 503 | ||
499 | if(m) delete m; | 504 | if(m) delete m; |
500 | } | 505 | } |
501 | 506 | ||
502 | 507 | ||
503 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 508 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
504 | struct statfs fss; | 509 | struct statfs fss; |
505 | if ( !statfs( path.latin1(), &fss ) ) { | 510 | if ( !statfs( path.latin1(), &fss ) ) { |
506 | int blkSize = fss.f_bsize; | 511 | int blkSize = fss.f_bsize; |
507 | // int totalBlks = fs.f_blocks; | 512 | // int totalBlks = fs.f_blocks; |
508 | int availBlks = fss.f_bavail; | 513 | int availBlks = fss.f_bavail; |
509 | 514 | ||
510 | long mult = blkSize / 1024; | 515 | long mult = blkSize / 1024; |
511 | long div = 1024 / blkSize; | 516 | long div = 1024 / blkSize; |
512 | if ( !mult ) mult = 1; | 517 | if ( !mult ) mult = 1; |
513 | if ( !div ) div = 1; | 518 | if ( !div ) div = 1; |
514 | 519 | ||
515 | 520 | ||
516 | return QString::number(availBlks * mult / div); | 521 | return QString::number(availBlks * mult / div); |
517 | } | 522 | } |
518 | return ""; | 523 | return ""; |
519 | } | 524 | } |
520 | 525 | ||
521 | void AdvancedFm::addToDocs() { | 526 | void AdvancedFm::addToDocs() { |
522 | QStringList strListPaths = getPath(); | 527 | QStringList strListPaths = getPath(); |
523 | QDir *thisDir = CurrentDir(); | 528 | QDir *thisDir = CurrentDir(); |
524 | 529 | ||
525 | if( strListPaths.count() > 0) { | 530 | if( strListPaths.count() > 0) { |
526 | QString curFile; | 531 | QString curFile; |
527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 532 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
528 | curFile = thisDir->canonicalPath()+"/"+(*it); | 533 | curFile = thisDir->canonicalPath()+"/"+(*it); |
529 | // odebug << curFile << oendl; | 534 | // odebug << curFile << oendl; |
530 | QFileInfo fi(curFile); | 535 | QFileInfo fi(curFile); |
531 | DocLnk f; | 536 | DocLnk f; |
532 | // curFile.replace(QRegExp("\\..*"),""); | 537 | // curFile.replace(QRegExp("\\..*"),""); |
533 | f.setName(fi.baseName() ); | 538 | f.setName(fi.baseName() ); |
534 | f.setFile( curFile); | 539 | f.setFile( curFile); |
535 | f.writeLink(); | 540 | f.writeLink(); |
536 | } | 541 | } |
537 | } | 542 | } |
538 | } | 543 | } |
539 | 544 | ||
540 | 545 | ||
541 | void AdvancedFm::customDirsToMenu() { | 546 | void AdvancedFm::customDirsToMenu() { |
542 | 547 | ||
543 | Config cfg("AdvancedFm"); | 548 | Config cfg("AdvancedFm"); |
544 | cfg.setGroup("Menu"); | 549 | cfg.setGroup("Menu"); |
545 | 550 | ||
546 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 551 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
547 | menuButton->insertItems(list ); | 552 | menuButton->insertItems(list ); |
548 | 553 | ||
549 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 554 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
550 | // { | 555 | // { |
551 | // customDirMenu->insertItem(*it ); | 556 | // customDirMenu->insertItem(*it ); |
552 | // } | 557 | // } |
553 | } | 558 | } |
554 | 559 | ||
555 | void AdvancedFm::dirMenuSelected(int item) { | 560 | void AdvancedFm::dirMenuSelected(int item) { |
556 | switch(item) | 561 | switch(item) |
557 | { | 562 | { |
558 | 563 | ||
559 | case -21: | 564 | case -21: |
560 | case 0: | 565 | case 0: |
561 | addCustomDir(); | 566 | addCustomDir(); |
562 | break; | 567 | break; |
563 | case -22: | 568 | case -22: |
564 | case 1: | 569 | case 1: |
565 | removeCustomDir(); | 570 | removeCustomDir(); |
566 | break; | 571 | break; |
567 | default: | 572 | default: |
568 | { | 573 | { |
569 | // gotoCustomDir( menuButton->text(item)); | 574 | // gotoCustomDir( menuButton->text(item)); |
570 | // gotoCustomDir( customDirMenu->text(item)); | 575 | // gotoCustomDir( customDirMenu->text(item)); |
571 | } | 576 | } |
572 | break; | 577 | break; |
573 | 578 | ||
574 | }; | 579 | }; |
575 | } | 580 | } |
576 | 581 | ||
577 | void AdvancedFm::addCustomDir() { | 582 | void AdvancedFm::addCustomDir() { |
578 | Config cfg("AdvancedFm"); | 583 | Config cfg("AdvancedFm"); |
579 | cfg.setGroup("Menu"); | 584 | cfg.setGroup("Menu"); |
580 | QString dir; | 585 | QString dir; |
581 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 586 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
582 | 587 | ||
583 | dir = CurrentDir()->canonicalPath(); | 588 | dir = CurrentDir()->canonicalPath(); |
584 | 589 | ||
585 | bool addIt=true; | 590 | bool addIt=true; |
586 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 591 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
587 | if( dir == (*it)) { | 592 | if( dir == (*it)) { |
588 | addIt=false; | 593 | addIt=false; |
589 | } | 594 | } |
590 | } | 595 | } |
591 | if(addIt) { | 596 | if(addIt) { |
592 | menuButton->insertItem(dir); | 597 | menuButton->insertItem(dir); |
593 | // customDirMenu->insertItem(dir); | 598 | // customDirMenu->insertItem(dir); |