-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 18 |
2 files changed, 26 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index fc6c3bf..d56e746 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -161,386 +161,383 @@ void AdvancedFm::populateView() | |||
161 | isDir=TRUE; | 161 | isDir=TRUE; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | QFileInfo fileInfo( path + "/" + fileL); | 165 | QFileInfo fileInfo( path + "/" + fileL); |
166 | 166 | ||
167 | if(fileL !="./" && fi->exists()) | 167 | if(fileL !="./" && fi->exists()) |
168 | { | 168 | { |
169 | item= new QListViewItem( thisView, fileL, fileS , fileDate); | 169 | item= new QListViewItem( thisView, fileL, fileS , fileDate); |
170 | 170 | ||
171 | if(isDir || fileL.find("/",0,TRUE) != -1) | 171 | if(isDir || fileL.find("/",0,TRUE) != -1) |
172 | { | 172 | { |
173 | 173 | ||
174 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 174 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
175 | pm = Resource::loadPixmap( "lockedfolder" ); | 175 | pm = Resource::loadPixmap( "lockedfolder" ); |
176 | else | 176 | else |
177 | pm= Resource::loadPixmap( "folder" ); | 177 | pm= Resource::loadPixmap( "folder" ); |
178 | } | 178 | } |
179 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | 179 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) |
180 | { | 180 | { |
181 | pm = Resource::loadPixmap( "exec"); | 181 | pm = Resource::loadPixmap( "exec"); |
182 | } | 182 | } |
183 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 183 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
184 | | fileInfo.permission( QFileInfo::ExeGroup) | 184 | | fileInfo.permission( QFileInfo::ExeGroup) |
185 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | 185 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) |
186 | { | 186 | { |
187 | pm = Resource::loadPixmap( "exec"); | 187 | pm = Resource::loadPixmap( "exec"); |
188 | } | 188 | } |
189 | else if( !fi->isReadable() ) | 189 | else if( !fi->isReadable() ) |
190 | { | 190 | { |
191 | pm = Resource::loadPixmap( "locked" ); | 191 | pm = Resource::loadPixmap( "locked" ); |
192 | } | 192 | } |
193 | else { //everything else goes by mimetype | 193 | else { //everything else goes by mimetype |
194 | MimeType mt(fi->filePath()); | 194 | MimeType mt(fi->filePath()); |
195 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 195 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
196 | if(pm.isNull()) | 196 | if(pm.isNull()) |
197 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 197 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
198 | } | 198 | } |
199 | item->setPixmap( 0,pm); | 199 | item->setPixmap( 0,pm); |
200 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | 200 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) |
201 | { | 201 | { |
202 | // overlay link image | 202 | // overlay link image |
203 | pm= Resource::loadPixmap( "folder" ); | 203 | pm= Resource::loadPixmap( "folder" ); |
204 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 204 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
205 | QPainter painter( &pm ); | 205 | QPainter painter( &pm ); |
206 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 206 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
207 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 207 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
208 | item->setPixmap( 0, pm); | 208 | item->setPixmap( 0, pm); |
209 | } | 209 | } |
210 | } | 210 | } |
211 | isDir=FALSE; | 211 | isDir=FALSE; |
212 | ++it; | 212 | ++it; |
213 | } | 213 | } |
214 | 214 | ||
215 | if( path.find("dev",0,TRUE) != -1) | 215 | if( path.find("dev",0,TRUE) != -1) |
216 | { | 216 | { |
217 | struct stat buf; | 217 | struct stat buf; |
218 | dev_t devT; | 218 | dev_t devT; |
219 | DIR *dir; | 219 | DIR *dir; |
220 | struct dirent *mydirent; | 220 | struct dirent *mydirent; |
221 | 221 | ||
222 | if((dir = opendir( path.latin1())) != NULL) | 222 | if((dir = opendir( path.latin1())) != NULL) |
223 | while ((mydirent = readdir(dir)) != NULL) | 223 | while ((mydirent = readdir(dir)) != NULL) |
224 | { | 224 | { |
225 | lstat( mydirent->d_name, &buf); | 225 | lstat( mydirent->d_name, &buf); |
226 | // qDebug(mydirent->d_name); | 226 | // qDebug(mydirent->d_name); |
227 | fileL.sprintf("%s", mydirent->d_name); | 227 | fileL.sprintf("%s", mydirent->d_name); |
228 | devT = buf.st_dev; | 228 | devT = buf.st_dev; |
229 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 229 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
230 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 230 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
231 | if( fileL.find(".") == -1 ) | 231 | if( fileL.find(".") == -1 ) |
232 | { | 232 | { |
233 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 233 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
234 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 234 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
235 | item->setPixmap( 0,pm); | 235 | item->setPixmap( 0,pm); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | closedir(dir); | 239 | closedir(dir); |
240 | } | 240 | } |
241 | 241 | ||
242 | thisView->setSorting( 3,FALSE); | 242 | thisView->setSorting( 3,FALSE); |
243 | fillCombo( (const QString &) path ); | 243 | fillCombo( (const QString &) path ); |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 247 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) |
248 | { | 248 | { |
249 | if(selectedItem) | 249 | if(selectedItem) |
250 | { | 250 | { |
251 | QString strItem=selectedItem->text(0); | 251 | QString strItem=selectedItem->text(0); |
252 | QString strSize=selectedItem->text(1); | 252 | QString strSize=selectedItem->text(1); |
253 | strSize=strSize.stripWhiteSpace(); | 253 | strSize=strSize.stripWhiteSpace(); |
254 | bool isDirectory = false; | 254 | bool isDirectory = false; |
255 | QString strItem2; | 255 | QString strItem2; |
256 | 256 | ||
257 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 257 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink |
258 | { | 258 | { |
259 | strItem2 = dealWithSymName((const QString&)strItem); | 259 | strItem2 = dealWithSymName((const QString&)strItem); |
260 | if(QDir(strItem2).exists() ) | 260 | if(QDir(strItem2).exists() ) |
261 | strItem = strItem2; | 261 | strItem = strItem2; |
262 | } | 262 | } |
263 | 263 | ||
264 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 264 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) |
265 | { | 265 | { |
266 | 266 | ||
267 | if(QDir(strItem).exists()) | 267 | if(QDir(strItem).exists()) |
268 | isDirectory = true; | 268 | isDirectory = true; |
269 | } | 269 | } |
270 | 270 | ||
271 | if( isDirectory ) | 271 | if( isDirectory ) |
272 | { | 272 | { |
273 | CurrentDir()->cd( strItem, TRUE); | 273 | CurrentDir()->cd( strItem, TRUE); |
274 | populateView(); | 274 | populateView(); |
275 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 275 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
276 | } | 276 | } |
277 | chdir( strItem.latin1()); | 277 | chdir( strItem.latin1()); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 281 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
282 | switch (mouse) { | 282 | switch (mouse) { |
283 | case 1: | 283 | case 1: |
284 | { | 284 | { |
285 | if(renameBox != 0 ) | 285 | if(renameBox != 0 ) |
286 | { | 286 | { |
287 | cancelRename(); | 287 | cancelRename(); |
288 | } | 288 | } |
289 | |||
290 | } | 289 | } |
291 | break; | 290 | break; |
292 | case 2: | 291 | case 2: |
293 | menuTimer.start( 500, TRUE ); | 292 | menuTimer.start( 500, TRUE ); |
294 | break; | 293 | break; |
295 | }; | 294 | }; |
296 | } | 295 | } |
297 | 296 | ||
298 | void AdvancedFm::switchToLocalTab() | 297 | void AdvancedFm::switchToLocalTab() |
299 | { | 298 | { |
300 | TabWidget->setCurrentTab(0); | 299 | TabWidget->setCurrentTab(0); |
301 | Local_View->setFocus(); | 300 | Local_View->setFocus(); |
302 | } | 301 | } |
303 | 302 | ||
304 | void AdvancedFm::switchToRemoteTab() | 303 | void AdvancedFm::switchToRemoteTab() |
305 | { | 304 | { |
306 | TabWidget->setCurrentTab(1); | 305 | TabWidget->setCurrentTab(1); |
307 | Remote_View->setFocus(); | 306 | Remote_View->setFocus(); |
308 | } | 307 | } |
309 | 308 | ||
310 | void AdvancedFm::readConfig() | 309 | void AdvancedFm::readConfig() |
311 | { | 310 | { |
312 | Config cfg("AdvancedFm"); | 311 | Config cfg("AdvancedFm"); |
313 | } | 312 | } |
314 | 313 | ||
315 | void AdvancedFm::writeConfig() | 314 | void AdvancedFm::writeConfig() |
316 | { | 315 | { |
317 | Config cfg("AdvancedFm"); | 316 | Config cfg("AdvancedFm"); |
318 | } | 317 | } |
319 | 318 | ||
320 | void AdvancedFm::currentPathComboChanged() | 319 | void AdvancedFm::currentPathComboChanged() |
321 | { | 320 | { |
322 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) | 321 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) |
323 | { | 322 | { |
324 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 323 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
325 | populateView(); | 324 | populateView(); |
326 | } | 325 | } |
327 | else | 326 | else |
328 | { | 327 | { |
329 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 328 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
330 | } | 329 | } |
331 | } | 330 | } |
332 | 331 | ||
333 | void AdvancedFm::fillCombo(const QString ¤tPath) | 332 | void AdvancedFm::fillCombo(const QString ¤tPath) |
334 | { | 333 | { |
335 | // qDebug("%d",TabWidget->getCurrentTab()); | 334 | // qDebug("%d",TabWidget->getCurrentTab()); |
336 | if ( whichTab == 1) | 335 | if ( whichTab == 1) |
337 | { | 336 | { |
338 | currentPathCombo->lineEdit()->setText( currentPath); | 337 | currentPathCombo->lineEdit()->setText( currentPath); |
339 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 338 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
340 | { | 339 | { |
341 | currentPathCombo->clear(); | 340 | currentPathCombo->clear(); |
342 | localDirPathStringList.prepend( currentPath ); | 341 | localDirPathStringList.prepend( currentPath ); |
343 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 342 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
344 | } | 343 | } |
345 | } | 344 | } |
346 | else | 345 | else |
347 | { | 346 | { |
348 | currentPathCombo->lineEdit()->setText( currentPath); | 347 | currentPathCombo->lineEdit()->setText( currentPath); |
349 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 348 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) |
350 | { | 349 | { |
351 | currentPathCombo->clear(); | 350 | currentPathCombo->clear(); |
352 | remoteDirPathStringList.prepend( currentPath ); | 351 | remoteDirPathStringList.prepend( currentPath ); |
353 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 352 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
354 | } | 353 | } |
355 | } | 354 | } |
356 | } | 355 | } |
357 | 356 | ||
358 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) | 357 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) |
359 | { | 358 | { |
360 | chdir( currentPath.latin1() ); | 359 | chdir( currentPath.latin1() ); |
361 | CurrentDir()->cd( currentPath, TRUE); | 360 | CurrentDir()->cd( currentPath, TRUE); |
362 | populateView(); | 361 | populateView(); |
363 | update(); | 362 | update(); |
364 | } | 363 | } |
365 | 364 | ||
366 | QStringList AdvancedFm::getPath() | 365 | QStringList AdvancedFm::getPath() |
367 | { | 366 | { |
368 | QStringList strList; | 367 | QStringList strList; |
369 | QListView *thisView=CurrentView(); | 368 | QListView *thisView=CurrentView(); |
370 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 369 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
371 | QListViewItemIterator it( thisView ); | 370 | QListViewItemIterator it( thisView ); |
372 | for ( ; it.current(); ++it ) | 371 | for ( ; it.current(); ++it ) |
373 | { | 372 | { |
374 | if ( it.current()->isSelected() ) | 373 | if ( it.current()->isSelected() ) |
375 | { | 374 | { |
376 | strList << it.current()->text(0); | 375 | strList << it.current()->text(0); |
377 | // qDebug(it.current()->text(0)); | 376 | // qDebug(it.current()->text(0)); |
378 | } | 377 | } |
379 | } | 378 | } |
380 | return strList; | 379 | return strList; |
381 | } | 380 | } |
382 | 381 | ||
383 | void AdvancedFm::homeButtonPushed() | 382 | void AdvancedFm::homeButtonPushed() |
384 | { | 383 | { |
385 | QString current = QDir::homeDirPath(); | 384 | QString current = QDir::homeDirPath(); |
386 | chdir( current.latin1() ); | 385 | chdir( current.latin1() ); |
387 | CurrentDir()->cd( current, TRUE); | 386 | CurrentDir()->cd( current, TRUE); |
388 | populateView(); | 387 | populateView(); |
389 | update(); | 388 | update(); |
390 | } | 389 | } |
391 | 390 | ||
392 | void AdvancedFm::docButtonPushed() | 391 | void AdvancedFm::docButtonPushed() |
393 | { | 392 | { |
394 | QString current = QPEApplication::documentDir(); | 393 | QString current = QPEApplication::documentDir(); |
395 | chdir( current.latin1() ); | 394 | chdir( current.latin1() ); |
396 | 395 | CurrentDir()->cd( current, TRUE); | |
397 | CurrentDir()->cd( current, TRUE); | 396 | populateView(); |
398 | populateView(); | ||
399 | update(); | 397 | update(); |
400 | } | 398 | } |
401 | 399 | ||
402 | void AdvancedFm::SDButtonPushed() | 400 | void AdvancedFm::SDButtonPushed() |
403 | { | 401 | { |
404 | QString current = "/mnt/card";// this can change so fix | 402 | QString current = "/mnt/card";// this can change so fix |
405 | chdir( current.latin1() ); | 403 | chdir( current.latin1() ); |
406 | CurrentDir()->cd( current, TRUE); | 404 | CurrentDir()->cd( current, TRUE); |
407 | populateView(); | 405 | populateView(); |
408 | update(); | 406 | update(); |
409 | } | 407 | } |
410 | 408 | ||
411 | void AdvancedFm::CFButtonPushed() | 409 | void AdvancedFm::CFButtonPushed() |
412 | { | 410 | { |
413 | QString current; | 411 | QString current; |
414 | if(zaurusDevice) | 412 | if(zaurusDevice) |
415 | current= "/mnt/cf"; //zaurus | 413 | current= "/mnt/cf"; //zaurus |
416 | else | 414 | else |
417 | current = "/mnt/hda"; //ipaq | 415 | current = "/mnt/hda"; //ipaq |
418 | |||
419 | chdir( current.latin1() ); | 416 | chdir( current.latin1() ); |
420 | CurrentDir()->cd( current, TRUE); | 417 | CurrentDir()->cd( current, TRUE); |
421 | populateView(); | 418 | populateView(); |
422 | update(); | 419 | update(); |
423 | } | 420 | } |
424 | 421 | ||
425 | 422 | ||
426 | void AdvancedFm::doAbout() | 423 | void AdvancedFm::doAbout() |
427 | { | 424 | { |
428 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 425 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
429 | "is copyright 2002-2003 by\n" | 426 | "is copyright 2002-2003 by\n" |
430 | "L.J.Potter<llornkcor@handhelds.org>\n" | 427 | "L.J.Potter<llornkcor@handhelds.org>\n" |
431 | "and is licensed by the GPL")); | 428 | "and is licensed by the GPL")); |
432 | } | 429 | } |
433 | 430 | ||
434 | void AdvancedFm::keyPressEvent( QKeyEvent *e) | 431 | void AdvancedFm::keyPressEvent( QKeyEvent *e) |
435 | { | 432 | { |
436 | // e->accept(); | 433 | // e->accept(); |
437 | if( CurrentView()->hasFocus() ) | 434 | if( CurrentView()->hasFocus() ) |
438 | { | 435 | { |
439 | switch ( e->key() ) { | 436 | switch ( e->key() ) { |
440 | case Key_Delete: | 437 | case Key_Delete: |
441 | del(); | 438 | del(); |
442 | break; | 439 | break; |
443 | case Key_A: | 440 | case Key_A: |
444 | copyAs(); | 441 | copyAs(); |
445 | break; | 442 | break; |
446 | case Key_C: | 443 | case Key_C: |
447 | copy(); | 444 | copy(); |
448 | break; | 445 | break; |
449 | case Key_E: | 446 | case Key_E: |
450 | runThis(); | 447 | runThis(); |
451 | break; | 448 | break; |
452 | case Key_G: | 449 | case Key_G: |
453 | { | 450 | { |
454 | currentPathCombo->lineEdit()->setFocus(); | 451 | currentPathCombo->lineEdit()->setFocus(); |
455 | } | 452 | } |
456 | break; | 453 | break; |
457 | 454 | ||
458 | case Key_H: | 455 | case Key_H: |
459 | showHidden(); | 456 | showHidden(); |
460 | break; | 457 | break; |
461 | case Key_I: | 458 | case Key_I: |
462 | fileStatus(); | 459 | fileStatus(); |
463 | break; | 460 | break; |
464 | case Key_M: | 461 | case Key_M: |
465 | move(); | 462 | move(); |
466 | break; | 463 | break; |
467 | case Key_N: | 464 | case Key_N: |
468 | mkDir(); | 465 | mkDir(); |
469 | break; | 466 | break; |
470 | case Key_P: | 467 | case Key_P: |
471 | filePerms(); | 468 | filePerms(); |
472 | break; | 469 | break; |
473 | case Key_R: | 470 | case Key_R: |
474 | rn(); | 471 | rn(); |
475 | break; | 472 | break; |
476 | case Key_U: | 473 | case Key_U: |
477 | upDir(); | 474 | upDir(); |
478 | break; | 475 | break; |
479 | case Key_1: | 476 | case Key_1: |
480 | switchToLocalTab(); | 477 | switchToLocalTab(); |
481 | break; | 478 | break; |
482 | case Key_2: | 479 | case Key_2: |
483 | switchToRemoteTab(); | 480 | switchToRemoteTab(); |
484 | break; | 481 | break; |
485 | case Key_3: | 482 | case Key_3: |
486 | CFButtonPushed(); | 483 | CFButtonPushed(); |
487 | break; | 484 | break; |
488 | case Key_4: | 485 | case Key_4: |
489 | SDButtonPushed(); | 486 | SDButtonPushed(); |
490 | break; | 487 | break; |
491 | case Key_5: | 488 | case Key_5: |
492 | homeButtonPushed(); | 489 | homeButtonPushed(); |
493 | break; | 490 | break; |
494 | case Key_6: | 491 | case Key_6: |
495 | docButtonPushed(); | 492 | docButtonPushed(); |
496 | break; | 493 | break; |
497 | case Key_7: | 494 | case Key_7: |
498 | break; | 495 | break; |
499 | case Key_8: | 496 | case Key_8: |
500 | break; | 497 | break; |
501 | case Key_9: | 498 | case Key_9: |
502 | break; | 499 | break; |
503 | case Key_0: | 500 | case Key_0: |
504 | break; | 501 | break; |
505 | }; | 502 | }; |
506 | e->accept(); | 503 | e->accept(); |
507 | } | 504 | } |
508 | } | 505 | } |
509 | 506 | ||
510 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 507 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) |
511 | { | 508 | { |
512 | if( CurrentView()->hasFocus() ) | 509 | if( CurrentView()->hasFocus() ) |
513 | e->ignore(); | 510 | e->ignore(); |
514 | } | 511 | } |
515 | 512 | ||
516 | 513 | ||
517 | void AdvancedFm::QPEButtonPushed() | 514 | void AdvancedFm::QPEButtonPushed() |
518 | { | 515 | { |
519 | QString current = QPEApplication::qpeDir(); | 516 | QString current = QPEApplication::qpeDir(); |
520 | chdir( current.latin1() ); | 517 | chdir( current.latin1() ); |
521 | CurrentDir()->cd( current, TRUE); | 518 | CurrentDir()->cd( current, TRUE); |
522 | populateView(); | 519 | populateView(); |
523 | update(); | 520 | update(); |
524 | } | 521 | } |
525 | 522 | ||
526 | void AdvancedFm::parsetab(const QString &fileName) | 523 | void AdvancedFm::parsetab(const QString &fileName) |
527 | { | 524 | { |
528 | 525 | ||
529 | fileSystemTypeList.clear(); | 526 | fileSystemTypeList.clear(); |
530 | fsList.clear(); | 527 | fsList.clear(); |
531 | struct mntent *me; | 528 | struct mntent *me; |
532 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 529 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
533 | if ( mntfp ) | 530 | if ( mntfp ) |
534 | { | 531 | { |
535 | while ( (me = getmntent( mntfp )) != 0 ) | 532 | while ( (me = getmntent( mntfp )) != 0 ) |
536 | { | 533 | { |
537 | QString deviceName = me->mnt_fsname; | 534 | QString deviceName = me->mnt_fsname; |
538 | QString filesystemType = me->mnt_type; | 535 | QString filesystemType = me->mnt_type; |
539 | QString mountDir = me->mnt_dir; | 536 | QString mountDir = me->mnt_dir; |
540 | if(deviceName != "none") | 537 | if(deviceName != "none") |
541 | { | 538 | { |
542 | if( fsList.contains(filesystemType) == 0 | 539 | if( fsList.contains(filesystemType) == 0 |
543 | & filesystemType.find("proc",0,TRUE) == -1 | 540 | & filesystemType.find("proc",0,TRUE) == -1 |
544 | & filesystemType.find("cramfs",0,TRUE) == -1 | 541 | & filesystemType.find("cramfs",0,TRUE) == -1 |
545 | & filesystemType.find("auto",0,TRUE) == -1) | 542 | & filesystemType.find("auto",0,TRUE) == -1) |
546 | fsList << filesystemType; | 543 | fsList << filesystemType; |
@@ -662,229 +659,230 @@ void AdvancedFm::cancelMenuTimer() | |||
662 | // qDebug("selectionChanged: cancel menu timer"); | 659 | // qDebug("selectionChanged: cancel menu timer"); |
663 | if( menuTimer.isActive() ) | 660 | if( menuTimer.isActive() ) |
664 | menuTimer.stop(); | 661 | menuTimer.stop(); |
665 | } | 662 | } |
666 | 663 | ||
667 | QString AdvancedFm::checkDiskSpace(const QString &path) | 664 | QString AdvancedFm::checkDiskSpace(const QString &path) |
668 | { | 665 | { |
669 | struct statfs fss; | 666 | struct statfs fss; |
670 | if ( !statfs( path.latin1(), &fss ) ) | 667 | if ( !statfs( path.latin1(), &fss ) ) |
671 | { | 668 | { |
672 | int blkSize = fss.f_bsize; | 669 | int blkSize = fss.f_bsize; |
673 | // int totalBlks = fs.f_blocks; | 670 | // int totalBlks = fs.f_blocks; |
674 | int availBlks = fss.f_bavail; | 671 | int availBlks = fss.f_bavail; |
675 | 672 | ||
676 | long mult = blkSize / 1024; | 673 | long mult = blkSize / 1024; |
677 | long div = 1024 / blkSize; | 674 | long div = 1024 / blkSize; |
678 | if ( !mult ) mult = 1; | 675 | if ( !mult ) mult = 1; |
679 | if ( !div ) div = 1; | 676 | if ( !div ) div = 1; |
680 | 677 | ||
681 | 678 | ||
682 | return QString::number(availBlks * mult / div); | 679 | return QString::number(availBlks * mult / div); |
683 | } | 680 | } |
684 | return ""; | 681 | return ""; |
685 | } | 682 | } |
686 | 683 | ||
687 | void AdvancedFm::addToDocs() | 684 | void AdvancedFm::addToDocs() |
688 | { | 685 | { |
689 | QStringList strListPaths = getPath(); | 686 | QStringList strListPaths = getPath(); |
690 | QDir *thisDir = CurrentDir(); | 687 | QDir *thisDir = CurrentDir(); |
691 | 688 | ||
692 | if( strListPaths.count() > 0) | 689 | if( strListPaths.count() > 0) |
693 | { | 690 | { |
694 | QString curFile; | 691 | QString curFile; |
695 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 692 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) |
696 | { | 693 | { |
697 | curFile = thisDir->canonicalPath()+"/"+(*it); | 694 | curFile = thisDir->canonicalPath()+"/"+(*it); |
698 | // qDebug(curFile); | 695 | // qDebug(curFile); |
699 | DocLnk f; | 696 | DocLnk f; |
700 | // curFile.replace(QRegExp("\\..*"),""); | 697 | // curFile.replace(QRegExp("\\..*"),""); |
701 | f.setName((*it)); | 698 | f.setName((*it)); |
702 | f.setFile( curFile); | 699 | f.setFile( curFile); |
703 | f.writeLink(); | 700 | f.writeLink(); |
704 | } | 701 | } |
705 | } | 702 | } |
706 | } | 703 | } |
707 | 704 | ||
708 | 705 | ||
709 | void AdvancedFm::customDirsToMenu() | 706 | void AdvancedFm::customDirsToMenu() |
710 | { | 707 | { |
711 | 708 | ||
712 | Config cfg("AdvancedFm"); | 709 | Config cfg("AdvancedFm"); |
713 | cfg.setGroup("Menu"); | 710 | cfg.setGroup("Menu"); |
714 | 711 | ||
715 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 712 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
716 | menuButton->insertItems(list ); | 713 | menuButton->insertItems(list ); |
717 | 714 | ||
718 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 715 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
719 | // { | 716 | // { |
720 | // customDirMenu->insertItem(*it ); | 717 | // customDirMenu->insertItem(*it ); |
721 | // } | 718 | // } |
722 | } | 719 | } |
723 | 720 | ||
724 | void AdvancedFm::dirMenuSelected(int item) | 721 | void AdvancedFm::dirMenuSelected(int item) |
725 | { | 722 | { |
726 | qDebug("menu item %d", item); | 723 | qDebug("menu item %d", item); |
727 | switch(item) | 724 | switch(item) |
728 | { | 725 | { |
729 | 726 | ||
730 | case -21: | 727 | case -21: |
731 | case 0: | 728 | case 0: |
732 | addCustomDir(); | 729 | addCustomDir(); |
733 | break; | 730 | break; |
734 | case -22: | 731 | case -22: |
735 | case 1: | 732 | case 1: |
736 | removeCustomDir(); | 733 | removeCustomDir(); |
737 | break; | 734 | break; |
738 | default: | 735 | default: |
739 | { | 736 | { |
740 | // gotoCustomDir( menuButton->text(item)); | 737 | // gotoCustomDir( menuButton->text(item)); |
741 | // gotoCustomDir( customDirMenu->text(item)); | 738 | // gotoCustomDir( customDirMenu->text(item)); |
742 | } | 739 | } |
743 | break; | 740 | break; |
744 | 741 | ||
745 | }; | 742 | }; |
746 | } | 743 | } |
747 | 744 | ||
748 | void AdvancedFm::addCustomDir() | 745 | void AdvancedFm::addCustomDir() |
749 | { | 746 | { |
750 | Config cfg("AdvancedFm"); | 747 | Config cfg("AdvancedFm"); |
751 | cfg.setGroup("Menu"); | 748 | cfg.setGroup("Menu"); |
752 | QString dir; | 749 | QString dir; |
753 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 750 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
754 | 751 | ||
755 | dir = CurrentDir()->canonicalPath(); | 752 | dir = CurrentDir()->canonicalPath(); |
756 | 753 | ||
757 | bool addIt=true; | 754 | bool addIt=true; |
758 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 755 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
759 | { | 756 | { |
760 | if( dir == (*it)) | 757 | if( dir == (*it)) |
761 | { | 758 | { |
762 | addIt=false; | 759 | addIt=false; |
763 | } | 760 | } |
764 | } | 761 | } |
765 | if(addIt) | 762 | if(addIt) |
766 | { | 763 | { |
767 | menuButton->insertItem(dir); | 764 | menuButton->insertItem(dir); |
768 | // customDirMenu->insertItem(dir); | 765 | // customDirMenu->insertItem(dir); |
769 | list << dir; | 766 | list << dir; |
770 | } | 767 | } |
771 | 768 | ||
772 | cfg.writeEntry("CustomDir", list, ','); | 769 | cfg.writeEntry("CustomDir", list, ','); |
773 | cfg.write(); | 770 | cfg.write(); |
774 | } | 771 | } |
775 | 772 | ||
776 | void AdvancedFm::removeCustomDir() | 773 | void AdvancedFm::removeCustomDir() |
777 | { | 774 | { |
778 | // qDebug("remove custom dir"); | 775 | // qDebug("remove custom dir"); |
779 | Config cfg("AdvancedFm"); | 776 | Config cfg("AdvancedFm"); |
780 | cfg.setGroup("Menu"); | 777 | cfg.setGroup("Menu"); |
781 | QString dir; | 778 | QString dir; |
782 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 779 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
783 | QStringList list2; | 780 | QStringList list2; |
784 | dir = CurrentDir()->canonicalPath(); | 781 | dir = CurrentDir()->canonicalPath(); |
785 | int ramble=2; | 782 | int ramble=2; |
786 | // int ramble=-24; | 783 | // int ramble=-24; |
787 | //first remove list | 784 | //first remove list |
788 | if(list.grep(dir,true).isEmpty()) | 785 | if(list.grep(dir,true).isEmpty()) |
789 | { | 786 | { |
790 | QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | 787 | QMessageBox::message("AdvancedFm", |
788 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); | ||
791 | } | 789 | } |
792 | else | 790 | else |
793 | { | 791 | { |
794 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 792 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
795 | { | 793 | { |
796 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 794 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
797 | { | 795 | { |
798 | list2 <<(*it); | 796 | list2 <<(*it); |
799 | } | 797 | } |
800 | else | 798 | else |
801 | { | 799 | { |
802 | // customDirMenu->removeItem( ramble); | 800 | // customDirMenu->removeItem( ramble); |
803 | menuButton->remove( ramble); | 801 | menuButton->remove( ramble); |
804 | 802 | ||
805 | } | 803 | } |
806 | ramble++; | 804 | ramble++; |
807 | // ramble--; | 805 | // ramble--; |
808 | } | 806 | } |
809 | 807 | ||
810 | cfg.writeEntry("CustomDir", list2, ','); | 808 | cfg.writeEntry("CustomDir", list2, ','); |
811 | cfg.write(); | 809 | cfg.write(); |
812 | } | 810 | } |
813 | // customDirsToMenu(); | 811 | // customDirsToMenu(); |
814 | 812 | ||
815 | } | 813 | } |
816 | 814 | ||
817 | void AdvancedFm::gotoCustomDir(const QString &dir) | 815 | void AdvancedFm::gotoCustomDir(const QString &dir) |
818 | { | 816 | { |
819 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 817 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
820 | QString curDir = dir; | 818 | QString curDir = dir; |
821 | QDir *thisDir = CurrentDir(); | 819 | QDir *thisDir = CurrentDir(); |
822 | // if( curDir.isEmpty()) { | 820 | // if( curDir.isEmpty()) { |
823 | // } | 821 | // } |
824 | if( curDir == s_addBookmark) | 822 | if( curDir == s_addBookmark) |
825 | { | 823 | { |
826 | addCustomDir(); | 824 | addCustomDir(); |
827 | } | 825 | } |
828 | if( curDir == s_removeBookmark) | 826 | if( curDir == s_removeBookmark) |
829 | { | 827 | { |
830 | removeCustomDir( ); | 828 | removeCustomDir( ); |
831 | } | 829 | } |
832 | else | 830 | else |
833 | { | 831 | { |
834 | if(QDir( curDir).exists() ) | 832 | if(QDir( curDir).exists() ) |
835 | { | 833 | { |
836 | thisDir->setPath( curDir ); | 834 | thisDir->setPath( curDir ); |
837 | chdir( curDir.latin1() ); | 835 | chdir( curDir.latin1() ); |
838 | thisDir->cd( curDir, TRUE); | 836 | thisDir->cd( curDir, TRUE); |
839 | populateView(); | 837 | populateView(); |
840 | } | 838 | } |
841 | } | 839 | } |
842 | } | 840 | } |
843 | 841 | ||
844 | QDir *AdvancedFm::CurrentDir() | 842 | QDir *AdvancedFm::CurrentDir() |
845 | { | 843 | { |
846 | if ( whichTab == 1) | 844 | if ( whichTab == 1) |
847 | { | 845 | { |
848 | return ¤tDir; | 846 | return ¤tDir; |
849 | } | 847 | } |
850 | else | 848 | else |
851 | { | 849 | { |
852 | return ¤tRemoteDir; | 850 | return ¤tRemoteDir; |
853 | } | 851 | } |
854 | } | 852 | } |
855 | 853 | ||
856 | QDir *AdvancedFm::OtherDir() | 854 | QDir *AdvancedFm::OtherDir() |
857 | { | 855 | { |
858 | if ( whichTab == 1) | 856 | if ( whichTab == 1) |
859 | { | 857 | { |
860 | return ¤tRemoteDir; | 858 | return ¤tRemoteDir; |
861 | } | 859 | } |
862 | else | 860 | else |
863 | { | 861 | { |
864 | return ¤tDir; | 862 | return ¤tDir; |
865 | } | 863 | } |
866 | } | 864 | } |
867 | 865 | ||
868 | QListView * AdvancedFm::CurrentView() | 866 | QListView * AdvancedFm::CurrentView() |
869 | { | 867 | { |
870 | if ( whichTab == 1) | 868 | if ( whichTab == 1) |
871 | return Local_View; | 869 | return Local_View; |
872 | else | 870 | else |
873 | return Remote_View; | 871 | return Remote_View; |
874 | } | 872 | } |
875 | 873 | ||
876 | QListView * AdvancedFm::OtherView() | 874 | QListView * AdvancedFm::OtherView() |
877 | { | 875 | { |
878 | if ( whichTab == 1) | 876 | if ( whichTab == 1) |
879 | return Remote_View; | 877 | return Remote_View; |
880 | else | 878 | else |
881 | return Local_View; | 879 | return Local_View; |
882 | } | 880 | } |
883 | 881 | ||
884 | void AdvancedFm::setOtherTabCurrent() | 882 | void AdvancedFm::setOtherTabCurrent() |
885 | { | 883 | { |
886 | if ( whichTab == 1) | 884 | if ( whichTab == 1) |
887 | TabWidget->setCurrentTab(1); | 885 | TabWidget->setCurrentTab(1); |
888 | else | 886 | else |
889 | TabWidget->setCurrentTab(0); | 887 | TabWidget->setCurrentTab(0); |
890 | } | 888 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index c553017..062a013 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,216 +1,218 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
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 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
27 | 27 | ||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() |
50 | { | 50 | { |
51 | ListClicked( CurrentView()->currentItem()); | 51 | ListClicked( CurrentView()->currentItem()); |
52 | } | 52 | } |
53 | 53 | ||
54 | void AdvancedFm::showMenuHidden() | 54 | void AdvancedFm::showMenuHidden() |
55 | { | 55 | { |
56 | if (b) | 56 | if (b) |
57 | { | 57 | { |
58 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 61 | // b=FALSE; |
62 | 62 | ||
63 | } | 63 | } |
64 | else | 64 | else |
65 | { | 65 | { |
66 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | 69 | // b=TRUE; |
70 | } | 70 | } |
71 | populateView(); | 71 | populateView(); |
72 | // populateRemoteView(); | 72 | // populateRemoteView(); |
73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
74 | if(b) b = false; else b = true; | 74 | if(b) b = false; else b = true; |
75 | } | 75 | } |
76 | 76 | ||
77 | void AdvancedFm::showHidden() | 77 | void AdvancedFm::showHidden() |
78 | { | 78 | { |
79 | if (b) | 79 | if (b) |
80 | { | 80 | { |
81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
83 | // b=FALSE; | 84 | // b=FALSE; |
84 | 85 | ||
85 | } | 86 | } |
86 | else | 87 | else |
87 | { | 88 | { |
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | s OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
90 | // b=TRUE; | 92 | // b=TRUE; |
91 | } | 93 | } |
92 | populateView(); | 94 | populateView(); |
93 | } | 95 | } |
94 | 96 | ||
95 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 97 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
96 | { | 98 | { |
97 | QString strItem = fileName; | 99 | QString strItem = fileName; |
98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | } | 101 | } |
100 | 102 | ||
101 | void AdvancedFm::runThis() | 103 | void AdvancedFm::runThis() |
102 | { | 104 | { |
103 | QString fs; | 105 | QString fs; |
104 | QDir *thisDir = CurrentDir(); | 106 | QDir *thisDir = CurrentDir(); |
105 | 107 | ||
106 | QString curFile = CurrentView()->currentItem()->text(0); | 108 | QString curFile = CurrentView()->currentItem()->text(0); |
107 | QString path = thisDir->canonicalPath(); | 109 | QString path = thisDir->canonicalPath(); |
108 | 110 | ||
109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
110 | 112 | ||
111 | curFile = dealWithSymName((const QString&)curFile); | 113 | curFile = dealWithSymName((const QString&)curFile); |
112 | 114 | ||
113 | if(curFile != "../") | 115 | if(curFile != "../") |
114 | { | 116 | { |
115 | 117 | ||
116 | fs = getFileSystemType((const QString &) path); | 118 | fs = getFileSystemType((const QString &) path); |
117 | QFileInfo fileInfo( path + "/" + curFile); | 119 | QFileInfo fileInfo( path + "/" + curFile); |
118 | qDebug( fileInfo.owner()); | 120 | qDebug( fileInfo.owner()); |
119 | 121 | ||
120 | if( (fileInfo.permission( QFileInfo::ExeUser) | 122 | if( (fileInfo.permission( QFileInfo::ExeUser) |
121 | | fileInfo.permission( QFileInfo::ExeGroup) | 123 | | fileInfo.permission( QFileInfo::ExeGroup) |
122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
124 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 126 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
125 | e << curFile; | 127 | e << curFile; |
126 | } | 128 | } |
127 | else | 129 | else |
128 | { | 130 | { |
129 | curFile = path + "/" + curFile; | 131 | curFile = path + "/" + curFile; |
130 | DocLnk nf(curFile); | 132 | DocLnk nf(curFile); |
131 | QString execStr = nf.exec(); | 133 | QString execStr = nf.exec(); |
132 | qDebug( execStr); | 134 | qDebug( execStr); |
133 | if( execStr.isEmpty() ) | 135 | if( execStr.isEmpty() ) |
134 | { | 136 | { |
135 | } | 137 | } |
136 | else | 138 | else |
137 | { | 139 | { |
138 | nf.execute(); | 140 | nf.execute(); |
139 | } | 141 | } |
140 | } | 142 | } |
141 | } | 143 | } |
142 | } | 144 | } |
143 | 145 | ||
144 | void AdvancedFm::runText() | 146 | void AdvancedFm::runText() |
145 | { | 147 | { |
146 | QString curFile = CurrentView()->currentItem()->text(0); | 148 | QString curFile = CurrentView()->currentItem()->text(0); |
147 | if(curFile != "../") | 149 | if(curFile != "../") |
148 | { | 150 | { |
149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
150 | curFile = dealWithSymName((const QString&)curFile); | 152 | curFile = dealWithSymName((const QString&)curFile); |
151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
153 | e << curFile; | 155 | e << curFile; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | void AdvancedFm::makeDir() | 159 | void AdvancedFm::makeDir() |
158 | { | 160 | { |
159 | InputDialog *fileDlg; | 161 | InputDialog *fileDlg; |
160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
161 | fileDlg->exec(); | 163 | fileDlg->exec(); |
162 | if( fileDlg->result() == 1 ) | 164 | if( fileDlg->result() == 1 ) |
163 | { | 165 | { |
164 | QDir *thisDir = CurrentDir(); | 166 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | 167 | QString filename = fileDlg->LineEdit1->text(); |
166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
167 | } | 169 | } |
168 | populateView(); | 170 | populateView(); |
169 | } | 171 | } |
170 | 172 | ||
171 | void AdvancedFm::doDelete() | 173 | void AdvancedFm::doDelete() |
172 | { | 174 | { |
173 | 175 | ||
174 | QStringList curFileList = getPath(); | 176 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 177 | bool doMsg=true; |
176 | int count = curFileList.count(); | 178 | int count = curFileList.count(); |
177 | if( count > 0) | 179 | if( count > 0) |
178 | { | 180 | { |
179 | if(count > 1 ) | 181 | if(count > 1 ) |
180 | { | 182 | { |
181 | QString msg; | 183 | QString msg; |
182 | msg=tr("Really delete\n%1 files?").arg(count); | 184 | msg=tr("Really delete\n%1 files?").arg(count); |
183 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 185 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
184 | ,tr("Yes"),tr("No"),0,0,1) ) | 186 | ,tr("Yes"),tr("No"),0,0,1) ) |
185 | { | 187 | { |
186 | case 0: | 188 | case 0: |
187 | doMsg=false; | 189 | doMsg=false; |
188 | break; | 190 | break; |
189 | case 1: | 191 | case 1: |
190 | return; | 192 | return; |
191 | break; | 193 | break; |
192 | }; | 194 | }; |
193 | } | 195 | } |
194 | 196 | ||
195 | QString myFile; | 197 | QString myFile; |
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 198 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
197 | { | 199 | { |
198 | myFile = (*it); | 200 | myFile = (*it); |
199 | if( myFile.find(" -> ",0,TRUE) != -1) | 201 | if( myFile.find(" -> ",0,TRUE) != -1) |
200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 202 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
201 | 203 | ||
202 | QString f = CurrentDir()->canonicalPath(); | 204 | QString f = CurrentDir()->canonicalPath(); |
203 | if(f.right(1).find("/",0,TRUE) == -1) | 205 | if(f.right(1).find("/",0,TRUE) == -1) |
204 | f += "/"; | 206 | f += "/"; |
205 | f += myFile; | 207 | f += myFile; |
206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 208 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
207 | { | 209 | { |
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 210 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
209 | "\nand all it's contents ?" | 211 | "\nand all it's contents ?" |
210 | ,tr("Yes"),tr("No"),0,0,1) ) | 212 | ,tr("Yes"),tr("No"),0,0,1) ) |
211 | { | 213 | { |
212 | case 0: | 214 | case 0: |
213 | { | 215 | { |
214 | f=f.left(f.length()-1); | 216 | f=f.left(f.length()-1); |
215 | QString cmd="rm -rf "+f; | 217 | QString cmd="rm -rf "+f; |
216 | startProcess( (const QString)cmd.latin1() ); | 218 | startProcess( (const QString)cmd.latin1() ); |