-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index c9366e7..7eac5d2 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -260,272 +260,272 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
260 | currentDir.cd(strItem, TRUE); | 260 | currentDir.cd(strItem, TRUE); |
261 | populateList(); | 261 | populateList(); |
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 264 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
265 | if( QFile::exists(strItem ) ) { | 265 | if( QFile::exists(strItem ) ) { |
266 | //currentDir.canonicalPath() | 266 | //currentDir.canonicalPath() |
267 | qDebug("We found our files!!"+strItem); | 267 | qDebug("We found our files!!"+strItem); |
268 | OnOK(); | 268 | OnOK(); |
269 | } | 269 | } |
270 | } //end not symlink | 270 | } //end not symlink |
271 | chdir(strItem.latin1()); | 271 | chdir(strItem.latin1()); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | void fileBrowser::OnOK() | 275 | void fileBrowser::OnOK() |
276 | { | 276 | { |
277 | QListViewItemIterator it1( ListView); | 277 | QListViewItemIterator it1( ListView); |
278 | for ( ; it1.current(); ++it1 ) { | 278 | for ( ; it1.current(); ++it1 ) { |
279 | if ( it1.current()->isSelected() ) { | 279 | if ( it1.current()->isSelected() ) { |
280 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 280 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
281 | qDebug("selected filename is "+selectedFileName); | 281 | qDebug("selected filename is "+selectedFileName); |
282 | fileList.append( selectedFileName ); | 282 | fileList.append( selectedFileName ); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | accept(); | 285 | accept(); |
286 | } | 286 | } |
287 | 287 | ||
288 | void fileBrowser::homeButtonPushed() { | 288 | void fileBrowser::homeButtonPushed() { |
289 | QString current = QDir::homeDirPath(); | 289 | QString current = QDir::homeDirPath(); |
290 | chdir( current.latin1() ); | 290 | chdir( current.latin1() ); |
291 | currentDir.cd( current, TRUE); | 291 | currentDir.cd( current, TRUE); |
292 | populateList(); | 292 | populateList(); |
293 | update(); | 293 | update(); |
294 | } | 294 | } |
295 | 295 | ||
296 | void fileBrowser::docButtonPushed() { | 296 | void fileBrowser::docButtonPushed() { |
297 | QString current = QPEApplication::documentDir(); | 297 | QString current = QPEApplication::documentDir(); |
298 | chdir( current.latin1() ); | 298 | chdir( current.latin1() ); |
299 | currentDir.cd( current, TRUE); | 299 | currentDir.cd( current, TRUE); |
300 | populateList(); | 300 | populateList(); |
301 | update(); | 301 | update(); |
302 | 302 | ||
303 | } | 303 | } |
304 | 304 | ||
305 | void fileBrowser::selectionChanged( const QString &select ) | 305 | void fileBrowser::selectionChanged( const QString &select ) |
306 | { | 306 | { |
307 | if ( select == "Documents") { | 307 | if ( select == "Documents") { |
308 | FileStack->raiseWidget( fileSelector ); | 308 | FileStack->raiseWidget( fileSelector ); |
309 | dirPathCombo->hide(); | 309 | dirPathCombo->hide(); |
310 | cdUpButton->hide(); | 310 | cdUpButton->hide(); |
311 | docButton->hide(); | 311 | docButton->hide(); |
312 | homeButton->hide(); | 312 | homeButton->hide(); |
313 | } else { | 313 | } else { |
314 | if ( select == "All files" ) | 314 | if ( select == "All files" ) |
315 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 315 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
316 | else | 316 | else |
317 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 317 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
318 | 318 | ||
319 | populateList(); | 319 | populateList(); |
320 | update(); | 320 | update(); |
321 | dirPathCombo->show(); | 321 | dirPathCombo->show(); |
322 | cdUpButton->show(); | 322 | cdUpButton->show(); |
323 | docButton->show(); | 323 | docButton->show(); |
324 | homeButton->show(); | 324 | homeButton->show(); |
325 | FileStack->raiseWidget( ListView ); | 325 | FileStack->raiseWidget( ListView ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | void fileBrowser::docOpen( const DocLnk &doc ) | 329 | void fileBrowser::docOpen( const DocLnk &doc ) |
330 | { | 330 | { |
331 | fileList.append( doc.file().latin1() ); | 331 | fileList.append( doc.file().latin1() ); |
332 | accept(); | 332 | accept(); |
333 | } | 333 | } |
334 | 334 | ||
335 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 335 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
336 | { | 336 | { |
337 | switch (mouse) { | 337 | switch (mouse) { |
338 | case 1: | 338 | case 1: |
339 | break; | 339 | break; |
340 | case 2: | 340 | case 2: |
341 | showListMenu(item); | 341 | showListMenu(item); |
342 | break; | 342 | break; |
343 | }; | 343 | }; |
344 | } | 344 | } |
345 | 345 | ||
346 | void fileBrowser::showListMenu(QListViewItem *item) { | 346 | void fileBrowser::showListMenu(QListViewItem *item) { |
347 | 347 | ||
348 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 348 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
349 | if( item->text(0).find("/",0,TRUE)) | 349 | if( item->text(0).find("/",0,TRUE)) |
350 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 350 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
351 | else | 351 | else |
352 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 352 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
353 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); | 353 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); |
354 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 354 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
355 | m.insertSeparator(); | 355 | m.insertSeparator(); |
356 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 356 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
357 | m.exec( QCursor::pos() ); | 357 | m.exec( QCursor::pos() ); |
358 | 358 | ||
359 | } | 359 | } |
360 | 360 | ||
361 | void fileBrowser::doCd() { | 361 | void fileBrowser::doCd() { |
362 | listClicked( ListView->currentItem()); | 362 | listClicked( ListView->currentItem()); |
363 | } | 363 | } |
364 | 364 | ||
365 | void fileBrowser::makDir() { | 365 | void fileBrowser::makDir() { |
366 | InputDialog *fileDlg; | 366 | InputDialog *fileDlg; |
367 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 367 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
368 | fileDlg->exec(); | 368 | fileDlg->exec(); |
369 | if( fileDlg->result() == 1 ) { | 369 | if( fileDlg->result() == 1 ) { |
370 | QString filename = fileDlg->LineEdit1->text(); | 370 | QString filename = fileDlg->LineEdit1->text(); |
371 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 371 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
372 | } | 372 | } |
373 | populateList(); | 373 | populateList(); |
374 | } | 374 | } |
375 | 375 | ||
376 | void fileBrowser::localRename() { | 376 | void fileBrowser::localRename() { |
377 | QString curFile = ListView->currentItem()->text(0); | 377 | QString curFile = ListView->currentItem()->text(0); |
378 | InputDialog *fileDlg; | 378 | InputDialog *fileDlg; |
379 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 379 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
380 | fileDlg->inputText = curFile; | 380 | fileDlg->inputText = curFile; |
381 | fileDlg->exec(); | 381 | fileDlg->exec(); |
382 | if( fileDlg->result() == 1 ) { | 382 | if( fileDlg->result() == 1 ) { |
383 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 383 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
384 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 384 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
385 | if( rename(oldname.latin1(), newName.latin1())== -1) | 385 | if( rename(oldname.latin1(), newName.latin1())== -1) |
386 | QMessageBox::message("Note","Could not rename"); | 386 | QMessageBox::message("Note","Could not rename"); |
387 | } | 387 | } |
388 | populateList(); | 388 | populateList(); |
389 | } | 389 | } |
390 | 390 | ||
391 | void fileBrowser::localDelete() { | 391 | void fileBrowser::localDelete() { |
392 | QString f = ListView->currentItem()->text(0); | 392 | QString f = ListView->currentItem()->text(0); |
393 | if(QDir(f).exists() ) { | 393 | if(QDir(f).exists() ) { |
394 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 394 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
395 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 395 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
396 | case 0: { | 396 | case 0: { |
397 | f=currentDir.canonicalPath()+"/"+f; | 397 | f=currentDir.canonicalPath()+"/"+f; |
398 | QString cmd="rmdir "+f; | 398 | QString cmd="rmdir "+f; |
399 | system( cmd.latin1()); | 399 | system( cmd.latin1()); |
400 | populateList(); | 400 | populateList(); |
401 | } | 401 | } |
402 | break; | 402 | break; |
403 | case 1: | 403 | case 1: |
404 | // exit | 404 | // exit |
405 | break; | 405 | break; |
406 | }; | 406 | }; |
407 | 407 | ||
408 | } else { | 408 | } else { |
409 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 409 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
410 | +" ?","Yes","No",0,0,1) ) { | 410 | +" ?","Yes","No",0,0,1) ) { |
411 | case 0: { | 411 | case 0: { |
412 | f=currentDir.canonicalPath()+"/"+f; | 412 | f=currentDir.canonicalPath()+"/"+f; |
413 | QString cmd="rm "+f; | 413 | QString cmd="rm "+f; |
414 | system( cmd.latin1()); | 414 | system( cmd.latin1()); |
415 | populateList(); | 415 | populateList(); |
416 | } | 416 | } |
417 | break; | 417 | break; |
418 | case 1: | 418 | case 1: |
419 | // exit | 419 | // exit |
420 | break; | 420 | break; |
421 | }; | 421 | }; |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | void fileBrowser::updateMimeTypeMenu() { | 425 | void fileBrowser::updateMimeTypeMenu() { |
426 | 426 | ||
427 | disconnect( typemb, SIGNAL(selected(const QString&)), | 427 | disconnect( typemb, SIGNAL(selected(const QString&)), |
428 | this, SLOT(showType(const QString&)) ); | 428 | this, SLOT(showType(const QString&)) ); |
429 | 429 | ||
430 | QString prev; | 430 | QString prev; |
431 | 431 | ||
432 | // Type filter | 432 | // Type filter |
433 | QStringList types; | 433 | QStringList types; |
434 | types << tr("All"); | 434 | types << tr("All"); |
435 | types << "--"; | 435 | types << "--"; |
436 | types += getMimeTypes(); | 436 | types += getMimeTypes(); |
437 | prev = typemb->currentText(); | 437 | prev = typemb->currentText(); |
438 | typemb->clear(); | 438 | typemb->clear(); |
439 | typemb->insertItems(types); | 439 | typemb->insertItems(types); |
440 | // typemb->select(prev); | 440 | // typemb->select(prev); |
441 | 441 | ||
442 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | 442 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); |
443 | } | 443 | } |
444 | 444 | ||
445 | void fileBrowser::showType(const QString &t) { | 445 | void fileBrowser::showType(const QString &t) { |
446 | 446 | ||
447 | qDebug(t); | 447 | qDebug(t); |
448 | mimeType = t+"/*"; | 448 | mimeType = t+"/*"; |
449 | // if(fileSelector) { | 449 | // if(fileSelector) { |
450 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 450 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
451 | // delete fileSelector; | 451 | // delete fileSelector; |
452 | } | 452 | // } |
453 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 453 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
454 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 454 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
455 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 455 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
456 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 456 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
457 | fileSelector->reread(); | 457 | // fileSelector->reread(); |
458 | repaint(); | 458 | repaint(); |
459 | // if ( t == tr("All") ) { | 459 | // if ( t == tr("All") ) { |
460 | // icons->setTypeFilter("",TRUE); | 460 | // icons->setTypeFilter("",TRUE); |
461 | // } else { | 461 | // } else { |
462 | // icons->setTypeFilter(t+"/*",TRUE); | 462 | // icons->setTypeFilter(t+"/*",TRUE); |
463 | // } | 463 | // } |
464 | 464 | ||
465 | } | 465 | } |
466 | 466 | ||
467 | QStringList fileBrowser::getMimeTypes() { | 467 | QStringList fileBrowser::getMimeTypes() { |
468 | QStringList r; | 468 | QStringList r; |
469 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | 469 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); |
470 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | 470 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); |
471 | file.open( IO_WriteOnly|IO_Truncate);//) | 471 | file.open( IO_WriteOnly|IO_Truncate);//) |
472 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | 472 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { |
473 | AppLnk* l; | 473 | AppLnk* l; |
474 | l = it.current(); | 474 | l = it.current(); |
475 | QStringList maj = l->mimeTypes(); | 475 | QStringList maj = l->mimeTypes(); |
476 | QStringList::ConstIterator f; | 476 | QStringList::ConstIterator f; |
477 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 477 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
478 | QString temp = *f; | 478 | QString temp = *f; |
479 | int sl = temp.find('/'); | 479 | int sl = temp.find('/'); |
480 | if (sl >= 0) { | 480 | if (sl >= 0) { |
481 | QString k = temp.left(sl); | 481 | QString k = temp.left(sl); |
482 | if( r.grep(k,TRUE).isEmpty() ) { | 482 | if( r.grep(k,TRUE).isEmpty() ) { |
483 | r << k; | 483 | r << k; |
484 | k+="\n"; | 484 | k+="\n"; |
485 | file.writeBlock( k.latin1(), k.length()); | 485 | file.writeBlock( k.latin1(), k.length()); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | r.sort(); | 490 | r.sort(); |
491 | file.close(); | 491 | file.close(); |
492 | return r; | 492 | return r; |
493 | } | 493 | } |
494 | 494 | ||
495 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | 495 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { |
496 | // QDataStream stream( data, IO_ReadOnly ); | 496 | // QDataStream stream( data, IO_ReadOnly ); |
497 | // if (msg == "keyRegister(int key, QString channel, QString message)") | 497 | // if (msg == "keyRegister(int key, QString channel, QString message)") |
498 | // { | 498 | // { |
499 | // int k; | 499 | // int k; |
500 | // QString c, m; | 500 | // QString c, m; |
501 | // stream >> k; | 501 | // stream >> k; |
502 | // stream >> c; | 502 | // stream >> c; |
503 | // stream >> m; | 503 | // stream >> m; |
504 | } | 504 | } |
505 | 505 | ||
506 | void fileBrowser::dirPathComboActivated( const QString & current) { | 506 | void fileBrowser::dirPathComboActivated( const QString & current) { |
507 | chdir( current.latin1() ); | 507 | chdir( current.latin1() ); |
508 | currentDir.cd( current, TRUE); | 508 | currentDir.cd( current, TRUE); |
509 | populateList(); | 509 | populateList(); |
510 | update(); | 510 | update(); |
511 | } | 511 | } |
512 | 512 | ||
513 | void fileBrowser::dirPathEditPressed() { | 513 | void fileBrowser::dirPathEditPressed() { |
514 | QString current = dirPathCombo->lineEdit()->text(); | 514 | QString current = dirPathCombo->lineEdit()->text(); |
515 | chdir( current.latin1() ); | 515 | chdir( current.latin1() ); |
516 | currentDir.cd( current, TRUE); | 516 | currentDir.cd( current, TRUE); |
517 | populateList(); | 517 | populateList(); |
518 | update(); | 518 | update(); |
519 | } | 519 | } |
520 | 520 | ||
521 | void fileBrowser::fillCombo(const QString ¤tPath) { | 521 | void fileBrowser::fillCombo(const QString ¤tPath) { |
522 | 522 | ||
523 | dirPathCombo->lineEdit()->setText(currentPath); | 523 | dirPathCombo->lineEdit()->setText(currentPath); |
524 | 524 | ||
525 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 525 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
526 | dirPathCombo->clear(); | 526 | dirPathCombo->clear(); |
527 | dirPathStringList.prepend(currentPath ); | 527 | dirPathStringList.prepend(currentPath ); |
528 | dirPathCombo->insertStringList( dirPathStringList,-1); | 528 | dirPathCombo->insertStringList( dirPathStringList,-1); |
529 | } | 529 | } |
530 | 530 | ||
531 | } | 531 | } |