author | zecke <zecke> | 2002-09-29 16:57:33 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-29 16:57:33 (UTC) |
commit | 0d4b54af104dadbff57804e5e6f8ac309aa36fc4 (patch) (unidiff) | |
tree | c157fa2a49c3b545d4e7c4a2fbdaabe043dde20a | |
parent | 33ebc68a530393697724428f0e0db3a4807f3a9e (diff) | |
download | opie-0d4b54af104dadbff57804e5e6f8ac309aa36fc4.zip opie-0d4b54af104dadbff57804e5e6f8ac309aa36fc4.tar.gz opie-0d4b54af104dadbff57804e5e6f8ac309aa36fc4.tar.bz2 |
Hide the TypeCombo/CategorySelect we provide our own stuff
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index c52aa62..458d432 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -247,776 +247,778 @@ void OFileSelector::setSelector(int mode ) | |||
247 | case Extended: | 247 | case Extended: |
248 | text = tr("Files"); | 248 | text = tr("Files"); |
249 | break; | 249 | break; |
250 | case ExtendedAll: | 250 | case ExtendedAll: |
251 | text = tr("All Files"); | 251 | text = tr("All Files"); |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | slotViewCheck( text ); | 254 | slotViewCheck( text ); |
255 | } | 255 | } |
256 | 256 | ||
257 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) | 257 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) |
258 | { | 258 | { |
259 | /* m_custom = popup; | 259 | /* m_custom = popup; |
260 | m_showPopup = true; | 260 | m_showPopup = true; |
261 | */ | 261 | */ |
262 | } | 262 | } |
263 | 263 | ||
264 | //void OFileSelector::updateL | 264 | //void OFileSelector::updateL |
265 | 265 | ||
266 | QString OFileSelector::selectedName() const | 266 | QString OFileSelector::selectedName() const |
267 | { | 267 | { |
268 | QString name; | 268 | QString name; |
269 | if( m_selector == Normal ){ | 269 | if( m_selector == Normal ){ |
270 | DocLnk lnk = m_select->selectedDocument(); | 270 | DocLnk lnk = m_select->selectedDocument(); |
271 | name = lnk.file(); | 271 | name = lnk.file(); |
272 | }else { | 272 | }else { |
273 | if ( m_shLne ) { | 273 | if ( m_shLne ) { |
274 | name = m_currentDir + "/" +m_edit->text(); | 274 | name = m_currentDir + "/" +m_edit->text(); |
275 | }else{ | 275 | }else{ |
276 | name = m_currentDir + "/" + currentView()->selectedName(); | 276 | name = m_currentDir + "/" + currentView()->selectedName(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | return name; | 279 | return name; |
280 | } | 280 | } |
281 | QStringList OFileSelector::selectedNames()const | 281 | QStringList OFileSelector::selectedNames()const |
282 | { | 282 | { |
283 | QStringList list; | 283 | QStringList list; |
284 | if( m_selector == Normal ){ | 284 | if( m_selector == Normal ){ |
285 | list << selectedName(); | 285 | list << selectedName(); |
286 | }else { | 286 | }else { |
287 | list << selectedName(); // FIXME implement multiple Selections | 287 | list << selectedName(); // FIXME implement multiple Selections |
288 | } | 288 | } |
289 | return list; | 289 | return list; |
290 | } | 290 | } |
291 | /** If mode is set to the Dir selection this will return the selected path. | 291 | /** If mode is set to the Dir selection this will return the selected path. |
292 | * | 292 | * |
293 | * | 293 | * |
294 | */ | 294 | */ |
295 | QString OFileSelector::selectedPath()const | 295 | QString OFileSelector::selectedPath()const |
296 | { | 296 | { |
297 | QString path; | 297 | QString path; |
298 | if( m_selector == Normal ){ | 298 | if( m_selector == Normal ){ |
299 | path = QPEApplication::documentDir(); | 299 | path = QPEApplication::documentDir(); |
300 | } /*else if( m_selector == Extended || m_selector == ExtendedAll ){ | 300 | } /*else if( m_selector == Extended || m_selector == ExtendedAll ){ |
301 | ; | 301 | ; |
302 | }*/ | 302 | }*/ |
303 | return path; | 303 | return path; |
304 | } | 304 | } |
305 | QStringList OFileSelector::selectedPaths() const | 305 | QStringList OFileSelector::selectedPaths() const |
306 | { | 306 | { |
307 | QStringList list; | 307 | QStringList list; |
308 | list << selectedPath(); | 308 | list << selectedPath(); |
309 | return list; | 309 | return list; |
310 | } | 310 | } |
311 | QString OFileSelector::directory()const | 311 | QString OFileSelector::directory()const |
312 | { | 312 | { |
313 | if( m_selector == Normal ) | 313 | if( m_selector == Normal ) |
314 | return QPEApplication::documentDir(); | 314 | return QPEApplication::documentDir(); |
315 | 315 | ||
316 | return QDir(m_currentDir).absPath(); | 316 | return QDir(m_currentDir).absPath(); |
317 | } | 317 | } |
318 | 318 | ||
319 | int OFileSelector::fileCount() | 319 | int OFileSelector::fileCount() |
320 | { | 320 | { |
321 | int count; | 321 | int count; |
322 | switch( m_selector ){ | 322 | switch( m_selector ){ |
323 | case Normal: | 323 | case Normal: |
324 | count = m_select->fileCount(); | 324 | count = m_select->fileCount(); |
325 | break; | 325 | break; |
326 | case Extended: | 326 | case Extended: |
327 | case ExtendedAll: | 327 | case ExtendedAll: |
328 | default: | 328 | default: |
329 | count = currentView()->fileCount(); | 329 | count = currentView()->fileCount(); |
330 | break; | 330 | break; |
331 | } | 331 | } |
332 | return count; | 332 | return count; |
333 | } | 333 | } |
334 | DocLnk OFileSelector::selectedDocument() const | 334 | DocLnk OFileSelector::selectedDocument() const |
335 | { | 335 | { |
336 | DocLnk lnk; | 336 | DocLnk lnk; |
337 | switch( m_selector ){ | 337 | switch( m_selector ){ |
338 | case Normal:{ | 338 | case Normal:{ |
339 | lnk = m_select->selectedDocument(); | 339 | lnk = m_select->selectedDocument(); |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | case Extended: | 342 | case Extended: |
343 | case ExtendedAll: | 343 | case ExtendedAll: |
344 | default: | 344 | default: |
345 | lnk = DocLnk( selectedName() ); | 345 | lnk = DocLnk( selectedName() ); |
346 | break; | 346 | break; |
347 | } | 347 | } |
348 | return lnk; | 348 | return lnk; |
349 | } | 349 | } |
350 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 350 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
351 | { | 351 | { |
352 | QValueList<DocLnk> docs; | 352 | QValueList<DocLnk> docs; |
353 | docs.append( selectedDocument() ); | 353 | docs.append( selectedDocument() ); |
354 | return docs; | 354 | return docs; |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | // slots internal | 358 | // slots internal |
359 | 359 | ||
360 | void OFileSelector::slotOk() | 360 | void OFileSelector::slotOk() |
361 | { | 361 | { |
362 | emit ok(); | 362 | emit ok(); |
363 | } | 363 | } |
364 | void OFileSelector::slotCancel() | 364 | void OFileSelector::slotCancel() |
365 | { | 365 | { |
366 | emit cancel(); | 366 | emit cancel(); |
367 | } | 367 | } |
368 | /* switch the views */ | 368 | /* switch the views */ |
369 | void OFileSelector::slotViewCheck(const QString &sel) | 369 | void OFileSelector::slotViewCheck(const QString &sel) |
370 | { | 370 | { |
371 | if( sel == tr("Documents" ) ){ | 371 | if( sel == tr("Documents" ) ){ |
372 | initializeOldSelector(); | 372 | initializeOldSelector(); |
373 | m_selector = Normal; | 373 | m_selector = Normal; |
374 | 374 | ||
375 | }else if( sel == tr("Files") ){ | 375 | }else if( sel == tr("Files") ){ |
376 | m_selector = Extended; | 376 | m_selector = Extended; |
377 | 377 | ||
378 | // FIXME call the factory | 378 | // FIXME call the factory |
379 | //reparse(); | 379 | //reparse(); |
380 | }else if( sel == tr("All Files") ){ | 380 | }else if( sel == tr("All Files") ){ |
381 | m_selector = ExtendedAll; | 381 | m_selector = ExtendedAll; |
382 | /* see above | 382 | /* see above |
383 | reparse(); */ | 383 | reparse(); */ |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | QString OFileSelector::currentMimeType() const{ | 387 | QString OFileSelector::currentMimeType() const{ |
388 | QString mime; | 388 | QString mime; |
389 | QString currentText; | 389 | QString currentText; |
390 | if (m_shChooser && m_mimeCheck ) | 390 | if (m_shChooser && m_mimeCheck ) |
391 | currentText = m_mimeCheck->currentText(); | 391 | currentText = m_mimeCheck->currentText(); |
392 | 392 | ||
393 | qWarning("CurrentText" + currentText ); | 393 | qWarning("CurrentText" + currentText ); |
394 | if (tr("All") == currentText ) return QString::null; | 394 | if (tr("All") == currentText ) return QString::null; |
395 | else if (currentText.isEmpty() ) { | 395 | else if (currentText.isEmpty() ) { |
396 | ; | 396 | ; |
397 | }else { | 397 | }else { |
398 | QMap<QString, QStringList>::ConstIterator it; | 398 | QMap<QString, QStringList>::ConstIterator it; |
399 | it = m_mimetypes.find( currentText ); | 399 | it = m_mimetypes.find( currentText ); |
400 | if ( it != m_mimetypes.end() ) { | 400 | if ( it != m_mimetypes.end() ) { |
401 | mime = it.data().join(";"); | 401 | mime = it.data().join(";"); |
402 | }else{ | 402 | }else{ |
403 | mime = currentText; | 403 | mime = currentText; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | return mime; | 406 | return mime; |
407 | } | 407 | } |
408 | void OFileSelector::slotMimeCheck(const QString &mime) | 408 | void OFileSelector::slotMimeCheck(const QString &mime) |
409 | { | 409 | { |
410 | if( m_selector == Normal ){ | 410 | if( m_selector == Normal ){ |
411 | initializeOldSelector(); | 411 | initializeOldSelector(); |
412 | 412 | ||
413 | updateMimes(); | 413 | updateMimes(); |
414 | updateMimeCheck(); | 414 | updateMimeCheck(); |
415 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 415 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
416 | }else{ // others | 416 | }else{ // others |
417 | qWarning("Mime %s", mime.latin1() ); | 417 | qWarning("Mime %s", mime.latin1() ); |
418 | if(m_shChooser ){ | 418 | if(m_shChooser ){ |
419 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 419 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
420 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 420 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
421 | } | 421 | } |
422 | reparse(); | 422 | reparse(); |
423 | } | 423 | } |
424 | 424 | ||
425 | } | 425 | } |
426 | /* | 426 | /* |
427 | * Ok if a non dir gets inserted into this combobox | 427 | * Ok if a non dir gets inserted into this combobox |
428 | * we need to change it | 428 | * we need to change it |
429 | * QFileInfo and dirPath will give us the right Dir | 429 | * QFileInfo and dirPath will give us the right Dir |
430 | */ | 430 | */ |
431 | void OFileSelector::slotLocationActivated(const QString &file) | 431 | void OFileSelector::slotLocationActivated(const QString &file) |
432 | { | 432 | { |
433 | qWarning("slotLocationActivated"); | 433 | qWarning("slotLocationActivated"); |
434 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 434 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
435 | QFileInfo info( name ); | 435 | QFileInfo info( name ); |
436 | if ( info.isFile() ) | 436 | if ( info.isFile() ) |
437 | cd(info.dirPath( TRUE ) ); //absolute | 437 | cd(info.dirPath( TRUE ) ); //absolute |
438 | else | 438 | else |
439 | cd(name ); | 439 | cd(name ); |
440 | reparse(); | 440 | reparse(); |
441 | } | 441 | } |
442 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 442 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
443 | { | 443 | { |
444 | QStringList pathList; | 444 | QStringList pathList; |
445 | bool underDog = FALSE; | 445 | bool underDog = FALSE; |
446 | for(int i=0;i<count;i++) { | 446 | for(int i=0;i<count;i++) { |
447 | pathList << m_location->text(i); | 447 | pathList << m_location->text(i); |
448 | if( m_location->text(i) == currentPath) | 448 | if( m_location->text(i) == currentPath) |
449 | underDog = TRUE; | 449 | underDog = TRUE; |
450 | } | 450 | } |
451 | if( !underDog) { | 451 | if( !underDog) { |
452 | m_location->clear(); | 452 | m_location->clear(); |
453 | if( currentPath.left(2)=="//") | 453 | if( currentPath.left(2)=="//") |
454 | pathList.append( currentPath.right(currentPath.length()-1) ); | 454 | pathList.append( currentPath.right(currentPath.length()-1) ); |
455 | else | 455 | else |
456 | pathList.append( currentPath ); | 456 | pathList.append( currentPath ); |
457 | m_location->insertStringList( pathList,-1); | 457 | m_location->insertStringList( pathList,-1); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | /* | 460 | /* |
461 | * Do not crash anymore | 461 | * Do not crash anymore |
462 | * don't try to change dir to a file | 462 | * don't try to change dir to a file |
463 | */ | 463 | */ |
464 | void OFileSelector::locationComboChanged() | 464 | void OFileSelector::locationComboChanged() |
465 | { | 465 | { |
466 | QFileInfo info( m_location->lineEdit()->text() ); | 466 | QFileInfo info( m_location->lineEdit()->text() ); |
467 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 467 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
468 | if (info.isFile() ) | 468 | if (info.isFile() ) |
469 | cd(info.dirPath(TRUE) ); //absolute path | 469 | cd(info.dirPath(TRUE) ); //absolute path |
470 | else | 470 | else |
471 | cd( m_location->lineEdit()->text() ); | 471 | cd( m_location->lineEdit()->text() ); |
472 | 472 | ||
473 | reparse(); | 473 | reparse(); |
474 | } | 474 | } |
475 | void OFileSelector::init() | 475 | void OFileSelector::init() |
476 | { | 476 | { |
477 | m_lay = new QVBoxLayout( this ); | 477 | m_lay = new QVBoxLayout( this ); |
478 | m_lay->setSpacing(0 ); | 478 | m_lay->setSpacing(0 ); |
479 | 479 | ||
480 | /* take care of the main view... */ | 480 | /* take care of the main view... */ |
481 | initToolbar(); | 481 | initToolbar(); |
482 | 482 | ||
483 | /* initialize the file lister */ | 483 | /* initialize the file lister */ |
484 | initLister(); | 484 | initLister(); |
485 | if( m_selector == Normal ){ | 485 | if( m_selector == Normal ){ |
486 | QString mime; | 486 | QString mime; |
487 | if (!m_autoMime) { | 487 | if (!m_autoMime) { |
488 | if (!m_mimetypes.isEmpty() ) { | 488 | if (!m_mimetypes.isEmpty() ) { |
489 | QMap<QString, QStringList>::Iterator it; | 489 | QMap<QString, QStringList>::Iterator it; |
490 | it = m_mimetypes.begin(); // cause we're in the init | 490 | it = m_mimetypes.begin(); // cause we're in the init |
491 | mime = it.data().join(";"); | 491 | mime = it.data().join(";"); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | initializeOldSelector(); | 494 | initializeOldSelector(); |
495 | }else{ | 495 | }else{ |
496 | initializeView(); | 496 | initializeView(); |
497 | } | 497 | } |
498 | 498 | ||
499 | if( m_shLne ) // the LineEdit with the current FileName | 499 | if( m_shLne ) // the LineEdit with the current FileName |
500 | initializeName(); | 500 | initializeName(); |
501 | 501 | ||
502 | if( m_shPerm ) // the Permission QCheckBox | 502 | if( m_shPerm ) // the Permission QCheckBox |
503 | initializePerm(); | 503 | initializePerm(); |
504 | 504 | ||
505 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 505 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
506 | initializeChooser(); | 506 | initializeChooser(); |
507 | 507 | ||
508 | if( m_shYesNo ) // the Yes No button row | 508 | if( m_shYesNo ) // the Yes No button row |
509 | initializeYes( ); | 509 | initializeYes( ); |
510 | 510 | ||
511 | if (m_selector != Normal ) | 511 | if (m_selector != Normal ) |
512 | reparse(); | 512 | reparse(); |
513 | } | 513 | } |
514 | void OFileSelector::updateMimes() | 514 | void OFileSelector::updateMimes() |
515 | { | 515 | { |
516 | if( m_autoMime ){ | 516 | if( m_autoMime ){ |
517 | m_mimetypes.clear(); | 517 | m_mimetypes.clear(); |
518 | m_mimetypes.insert( tr("All"), QString::null ); | 518 | m_mimetypes.insert( tr("All"), QString::null ); |
519 | if( m_selector == Normal ){ | 519 | if( m_selector == Normal ){ |
520 | DocLnkSet set; | 520 | DocLnkSet set; |
521 | Global::findDocuments(&set, QString::null ); | 521 | Global::findDocuments(&set, QString::null ); |
522 | QListIterator<DocLnk> dit( set.children() ); | 522 | QListIterator<DocLnk> dit( set.children() ); |
523 | for( ; dit.current(); ++dit ){ | 523 | for( ; dit.current(); ++dit ){ |
524 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 524 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
525 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 525 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
526 | } | 526 | } |
527 | }// else done in reparse | 527 | }// else done in reparse |
528 | } | 528 | } |
529 | } | 529 | } |
530 | void OFileSelector::initVars() | 530 | void OFileSelector::initVars() |
531 | { | 531 | { |
532 | if( m_mimetypes.isEmpty() ) | 532 | if( m_mimetypes.isEmpty() ) |
533 | m_autoMime = true; | 533 | m_autoMime = true; |
534 | else | 534 | else |
535 | m_autoMime = false; | 535 | m_autoMime = false; |
536 | 536 | ||
537 | m_shClose = false; | 537 | m_shClose = false; |
538 | m_shNew = false; | 538 | m_shNew = false; |
539 | m_shTool = true; | 539 | m_shTool = true; |
540 | m_shPerm = false; | 540 | m_shPerm = false; |
541 | m_shLne = true; | 541 | m_shLne = true; |
542 | m_shChooser = true; | 542 | m_shChooser = true; |
543 | m_shYesNo = true; | 543 | m_shYesNo = true; |
544 | m_case = false; | 544 | m_case = false; |
545 | m_dir = true; | 545 | m_dir = true; |
546 | m_files = true; | 546 | m_files = true; |
547 | m_showPopup = false; | 547 | m_showPopup = false; |
548 | m_mainView = 0l; | 548 | m_mainView = 0l; |
549 | m_fileView = 0l; | 549 | m_fileView = 0l; |
550 | m_lister = 0l; | 550 | m_lister = 0l; |
551 | 551 | ||
552 | if(m_pixmaps == 0 ) // init the pixmaps | 552 | if(m_pixmaps == 0 ) // init the pixmaps |
553 | initPics(); | 553 | initPics(); |
554 | 554 | ||
555 | // pointers | 555 | // pointers |
556 | m_location = 0; | 556 | m_location = 0; |
557 | m_mimeCheck = 0; | 557 | m_mimeCheck = 0; |
558 | m_viewCheck = 0; | 558 | m_viewCheck = 0; |
559 | m_homeButton = 0; | 559 | m_homeButton = 0; |
560 | m_docButton = 0; | 560 | m_docButton = 0; |
561 | m_hideButton = 0; | 561 | m_hideButton = 0; |
562 | m_ok = 0; | 562 | m_ok = 0; |
563 | m_cancel = 0; | 563 | m_cancel = 0; |
564 | m_reread = 0; | 564 | m_reread = 0; |
565 | m_up = 0; | 565 | m_up = 0; |
566 | m_View = 0; | 566 | m_View = 0; |
567 | m_checkPerm = 0; | 567 | m_checkPerm = 0; |
568 | m_pseudo = 0; | 568 | m_pseudo = 0; |
569 | m_pseudoLayout = 0; | 569 | m_pseudoLayout = 0; |
570 | m_select = 0; | 570 | m_select = 0; |
571 | m_lay = 0; | 571 | m_lay = 0; |
572 | m_Oselector = 0; | 572 | m_Oselector = 0; |
573 | m_boxToolbar = 0; | 573 | m_boxToolbar = 0; |
574 | m_boxOk = 0; | 574 | m_boxOk = 0; |
575 | m_boxName = 0; | 575 | m_boxName = 0; |
576 | m_boxView = 0; | 576 | m_boxView = 0; |
577 | m_edit = 0; | 577 | m_edit = 0; |
578 | m_fnLabel = 0; | 578 | m_fnLabel = 0; |
579 | m_new = 0; | 579 | m_new = 0; |
580 | m_close = 0; | 580 | m_close = 0; |
581 | } | 581 | } |
582 | void OFileSelector::initializeName() | 582 | void OFileSelector::initializeName() |
583 | { | 583 | { |
584 | /** Name Layout Line | 584 | /** Name Layout Line |
585 | * This is the Layout line arranged in | 585 | * This is the Layout line arranged in |
586 | * horizontal way each components | 586 | * horizontal way each components |
587 | * are next to each other | 587 | * are next to each other |
588 | * but we will only do this if | 588 | * but we will only do this if |
589 | * we didn't initialize a while ago. | 589 | * we didn't initialize a while ago. |
590 | */ | 590 | */ |
591 | if( m_boxName == 0 ){ | 591 | if( m_boxName == 0 ){ |
592 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 592 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
593 | m_fnLabel = new QLabel( m_boxName ); | 593 | m_fnLabel = new QLabel( m_boxName ); |
594 | m_fnLabel->setText( tr("Name:") ); | 594 | m_fnLabel->setText( tr("Name:") ); |
595 | m_edit = new QLineEdit( m_boxName ); | 595 | m_edit = new QLineEdit( m_boxName ); |
596 | m_edit->setText( m_name ); | 596 | m_edit->setText( m_name ); |
597 | //m_boxName->addWidget( m_fnLabel ); | 597 | //m_boxName->addWidget( m_fnLabel ); |
598 | m_boxName->setMargin( 5 ); | 598 | m_boxName->setMargin( 5 ); |
599 | m_boxName->setSpacing( 8 ); | 599 | m_boxName->setSpacing( 8 ); |
600 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 600 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
601 | 601 | ||
602 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 602 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
603 | }// else we already initialized | 603 | }// else we already initialized |
604 | // maybe show the components? | 604 | // maybe show the components? |
605 | // | 605 | // |
606 | } | 606 | } |
607 | void OFileSelector::initializeYes() | 607 | void OFileSelector::initializeYes() |
608 | { | 608 | { |
609 | /** The Save Cancel bar | 609 | /** The Save Cancel bar |
610 | * | 610 | * |
611 | */ | 611 | */ |
612 | if( m_boxOk == 0 ){ | 612 | if( m_boxOk == 0 ){ |
613 | m_boxOk = new QHBox( this ); | 613 | m_boxOk = new QHBox( this ); |
614 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 614 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
615 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 615 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
616 | 616 | ||
617 | //m_boxOk->addWidget( m_ok ); | 617 | //m_boxOk->addWidget( m_ok ); |
618 | //m_boxOk->addWidget( m_cancel ); | 618 | //m_boxOk->addWidget( m_cancel ); |
619 | m_boxOk->setMargin( 5 ); | 619 | m_boxOk->setMargin( 5 ); |
620 | m_boxOk->setSpacing( 10 ); | 620 | m_boxOk->setSpacing( 10 ); |
621 | m_lay->addWidget( m_boxOk, 0 ); | 621 | m_lay->addWidget( m_boxOk, 0 ); |
622 | 622 | ||
623 | connect( m_ok, SIGNAL( clicked() ), | 623 | connect( m_ok, SIGNAL( clicked() ), |
624 | this, SLOT(slotOk() ) ); | 624 | this, SLOT(slotOk() ) ); |
625 | connect( m_cancel, SIGNAL( clicked() ), | 625 | connect( m_cancel, SIGNAL( clicked() ), |
626 | this, SLOT( slotCancel() ) ); | 626 | this, SLOT( slotCancel() ) ); |
627 | } | 627 | } |
628 | } | 628 | } |
629 | /* | 629 | /* |
630 | * OK m_mimeCheck is a QComboBox we now want to fill | 630 | * OK m_mimeCheck is a QComboBox we now want to fill |
631 | * out that combobox | 631 | * out that combobox |
632 | * if automime we need to update the mimetypes | 632 | * if automime we need to update the mimetypes |
633 | */ | 633 | */ |
634 | void OFileSelector::updateMimeCheck() { | 634 | void OFileSelector::updateMimeCheck() { |
635 | m_mimeCheck->clear(); | 635 | m_mimeCheck->clear(); |
636 | if (m_autoMime ) { | 636 | if (m_autoMime ) { |
637 | //m_mimeCheck->insertItem( tr("All") ); | 637 | //m_mimeCheck->insertItem( tr("All") ); |
638 | updateMimes(); | 638 | updateMimes(); |
639 | } | 639 | } |
640 | 640 | ||
641 | QMap<QString, QStringList>::Iterator it; | 641 | QMap<QString, QStringList>::Iterator it; |
642 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 642 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
643 | m_mimeCheck->insertItem( it.key() ); | 643 | m_mimeCheck->insertItem( it.key() ); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | void OFileSelector::initializeChooser() | 647 | void OFileSelector::initializeChooser() |
648 | { | 648 | { |
649 | if( m_boxView == 0 ){ | 649 | if( m_boxView == 0 ){ |
650 | m_boxView = new QHBox( this ); | 650 | m_boxView = new QHBox( this ); |
651 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 651 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
652 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 652 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
653 | m_boxView->setSpacing( 8 ); | 653 | m_boxView->setSpacing( 8 ); |
654 | m_lay->addWidget(m_boxView, 0 ); | 654 | m_lay->addWidget(m_boxView, 0 ); |
655 | 655 | ||
656 | m_viewCheck->insertItem( tr("Documents") ); | 656 | m_viewCheck->insertItem( tr("Documents") ); |
657 | m_viewCheck->insertItem( tr("Files") ); | 657 | m_viewCheck->insertItem( tr("Files") ); |
658 | m_viewCheck->insertItem( tr("All Files") ); | 658 | m_viewCheck->insertItem( tr("All Files") ); |
659 | /* update to custom views */ | 659 | /* update to custom views */ |
660 | 660 | ||
661 | updateMimeCheck(); | 661 | updateMimeCheck(); |
662 | 662 | ||
663 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 663 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
664 | this, SLOT( slotViewCheck(const QString & ) ) ); | 664 | this, SLOT( slotViewCheck(const QString & ) ) ); |
665 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 665 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
666 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 666 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
667 | } | 667 | } |
668 | } | 668 | } |
669 | /* generate the buttons for the toolbar */ | 669 | /* generate the buttons for the toolbar */ |
670 | void OFileSelector::initToolbar() { | 670 | void OFileSelector::initToolbar() { |
671 | m_mainView = new OFileSelectorMain( this ); | 671 | m_mainView = new OFileSelectorMain( this ); |
672 | 672 | ||
673 | /* now generate the tool bar */ | 673 | /* now generate the tool bar */ |
674 | qWarning( "toolbar" ); | 674 | qWarning( "toolbar" ); |
675 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); | 675 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); |
676 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 676 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
677 | 677 | ||
678 | m_boxToolbar = new QHBox( m_pseudo ); | 678 | m_boxToolbar = new QHBox( m_pseudo ); |
679 | m_boxToolbar->setSpacing( 0 ); | 679 | m_boxToolbar->setSpacing( 0 ); |
680 | 680 | ||
681 | // tool bar members now | 681 | // tool bar members now |
682 | m_location = new QComboBox( m_boxToolbar ); | 682 | m_location = new QComboBox( m_boxToolbar ); |
683 | m_location->setEditable( TRUE ); | 683 | m_location->setEditable( TRUE ); |
684 | m_location->setDuplicatesEnabled( FALSE ); | 684 | m_location->setDuplicatesEnabled( FALSE ); |
685 | connect( m_location, SIGNAL(activated(const QString& ) ), | 685 | connect( m_location, SIGNAL(activated(const QString& ) ), |
686 | this, SLOT(slotLocationActivated(const QString& )) ); | 686 | this, SLOT(slotLocationActivated(const QString& )) ); |
687 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , | 687 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , |
688 | this, SLOT(locationComboChanged() ) ); | 688 | this, SLOT(locationComboChanged() ) ); |
689 | 689 | ||
690 | // UP Button | 690 | // UP Button |
691 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, | 691 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, |
692 | m_boxToolbar, "cdUpButton" ); | 692 | m_boxToolbar, "cdUpButton" ); |
693 | m_up->setFixedSize( QSize(20, 20 ) ); | 693 | m_up->setFixedSize( QSize(20, 20 ) ); |
694 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); | 694 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); |
695 | m_up->setFlat( TRUE ); | 695 | m_up->setFlat( TRUE ); |
696 | 696 | ||
697 | // Home Button | 697 | // Home Button |
698 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), | 698 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), |
699 | QString::null, m_boxToolbar ); | 699 | QString::null, m_boxToolbar ); |
700 | m_homeButton->setFixedSize( QSize(20, 20 ) ); | 700 | m_homeButton->setFixedSize( QSize(20, 20 ) ); |
701 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); | 701 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); |
702 | m_homeButton->setFlat( TRUE ); | 702 | m_homeButton->setFlat( TRUE ); |
703 | 703 | ||
704 | // Documents Button | 704 | // Documents Button |
705 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), | 705 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), |
706 | QString::null, m_boxToolbar, | 706 | QString::null, m_boxToolbar, |
707 | "docsButton" ); | 707 | "docsButton" ); |
708 | m_docButton->setFixedSize( QSize(20, 20 ) ); | 708 | m_docButton->setFixedSize( QSize(20, 20 ) ); |
709 | m_docButton->setFlat( true ); | 709 | m_docButton->setFlat( true ); |
710 | connect( m_docButton, SIGNAL(clicked() ), | 710 | connect( m_docButton, SIGNAL(clicked() ), |
711 | this, SLOT(slotDoc() ) ); | 711 | this, SLOT(slotDoc() ) ); |
712 | 712 | ||
713 | // close button | 713 | // close button |
714 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 714 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
715 | m_boxToolbar ); | 715 | m_boxToolbar ); |
716 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 716 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
717 | m_close->setFixedSize( 20, 20 ); | 717 | m_close->setFixedSize( 20, 20 ); |
718 | 718 | ||
719 | m_boxToolbar->setFixedHeight( 20 ); | 719 | m_boxToolbar->setFixedHeight( 20 ); |
720 | m_pseudoLayout->addWidget(m_boxToolbar ); | 720 | m_pseudoLayout->addWidget(m_boxToolbar ); |
721 | 721 | ||
722 | /* init the locations */ | 722 | /* init the locations */ |
723 | initLocations(); | 723 | initLocations(); |
724 | 724 | ||
725 | if( !m_shTool ){ | 725 | if( !m_shTool ){ |
726 | m_location->hide( ); | 726 | m_location->hide( ); |
727 | m_up->hide( ); | 727 | m_up->hide( ); |
728 | m_homeButton->hide( ); | 728 | m_homeButton->hide( ); |
729 | m_docButton->hide( ); | 729 | m_docButton->hide( ); |
730 | } | 730 | } |
731 | if(!m_shClose ) | 731 | if(!m_shClose ) |
732 | m_close->hide(); | 732 | m_close->hide(); |
733 | 733 | ||
734 | m_mainView->setToolbar( m_pseudo ); | 734 | m_mainView->setToolbar( m_pseudo ); |
735 | m_lay->addWidget( m_mainView, 100 ); | 735 | m_lay->addWidget( m_mainView, 100 ); |
736 | } | 736 | } |
737 | /* initialize the OLocalLister */ | 737 | /* initialize the OLocalLister */ |
738 | void OFileSelector::initLister() { | 738 | void OFileSelector::initLister() { |
739 | m_lister = new OLocalLister(this); | 739 | m_lister = new OLocalLister(this); |
740 | } | 740 | } |
741 | /* put default locations into the bar */ | 741 | /* put default locations into the bar */ |
742 | void OFileSelector::initLocations () { | 742 | void OFileSelector::initLocations () { |
743 | 743 | ||
744 | // let;s fill the Location ComboBox | 744 | // let;s fill the Location ComboBox |
745 | StorageInfo storage; | 745 | StorageInfo storage; |
746 | const QList<FileSystem> &fs = storage.fileSystems(); | 746 | const QList<FileSystem> &fs = storage.fileSystems(); |
747 | QListIterator<FileSystem> it ( fs ); | 747 | QListIterator<FileSystem> it ( fs ); |
748 | for( ; it.current(); ++it ){ | 748 | for( ; it.current(); ++it ){ |
749 | const QString disk = (*it)->name(); | 749 | const QString disk = (*it)->name(); |
750 | const QString path = (*it)->path(); | 750 | const QString path = (*it)->path(); |
751 | m_location->insertItem(path+ "<-"+disk ); | 751 | m_location->insertItem(path+ "<-"+disk ); |
752 | } | 752 | } |
753 | int count = m_location->count(); | 753 | int count = m_location->count(); |
754 | m_location->insertItem( m_currentDir ); | 754 | m_location->insertItem( m_currentDir ); |
755 | m_location->setCurrentItem( count ); | 755 | m_location->setCurrentItem( count ); |
756 | 756 | ||
757 | } | 757 | } |
758 | void OFileSelector::initializePerm() | 758 | void OFileSelector::initializePerm() |
759 | { | 759 | { |
760 | if( m_checkPerm == 0 ){ | 760 | if( m_checkPerm == 0 ){ |
761 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 761 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
762 | m_checkPerm->setChecked( false ); | 762 | m_checkPerm->setChecked( false ); |
763 | m_lay->addWidget( m_checkPerm ); | 763 | m_lay->addWidget( m_checkPerm ); |
764 | } | 764 | } |
765 | } | 765 | } |
766 | void OFileSelector::initPics() | 766 | void OFileSelector::initPics() |
767 | { | 767 | { |
768 | m_pixmaps = new QMap<QString,QPixmap>; | 768 | m_pixmaps = new QMap<QString,QPixmap>; |
769 | QPixmap pm = Resource::loadPixmap( "folder" ); | 769 | QPixmap pm = Resource::loadPixmap( "folder" ); |
770 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 770 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
771 | 771 | ||
772 | QPainter painter( &pm ); | 772 | QPainter painter( &pm ); |
773 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 773 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
774 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 774 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
775 | m_pixmaps->insert("dirsymlink", pm ); | 775 | m_pixmaps->insert("dirsymlink", pm ); |
776 | 776 | ||
777 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 777 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
778 | QPainter pen(&pm2 ); | 778 | QPainter pen(&pm2 ); |
779 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 779 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
780 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 780 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
781 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 781 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
782 | } | 782 | } |
783 | // if a mime complies with the m_mimeCheck->currentItem | 783 | // if a mime complies with the m_mimeCheck->currentItem |
784 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 784 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
785 | { | 785 | { |
786 | if( mime == "All" ) | 786 | if( mime == "All" ) |
787 | return true; | 787 | return true; |
788 | MimeType type( path ); | 788 | MimeType type( path ); |
789 | if( type.id() == mime ) | 789 | if( type.id() == mime ) |
790 | return true; | 790 | return true; |
791 | return false; | 791 | return false; |
792 | } | 792 | } |
793 | /* check if the mimetype in mime | 793 | /* check if the mimetype in mime |
794 | * complies with the one which is current | 794 | * complies with the one which is current |
795 | */ | 795 | */ |
796 | /* | 796 | /* |
797 | * We've the mimetype of the file | 797 | * We've the mimetype of the file |
798 | * We need to get the stringlist of the current mimetype | 798 | * We need to get the stringlist of the current mimetype |
799 | * | 799 | * |
800 | * mime = image/jpeg | 800 | * mime = image/jpeg |
801 | * QStringList = 'image/*' | 801 | * QStringList = 'image/*' |
802 | * or QStringList = image/jpeg;image/png;application/x-ogg | 802 | * or QStringList = image/jpeg;image/png;application/x-ogg |
803 | * or QStringList = application/x-ogg;image/*; | 803 | * or QStringList = application/x-ogg;image/*; |
804 | * with all these mime filters it should get acceptes | 804 | * with all these mime filters it should get acceptes |
805 | * to do so we need to look if mime is contained inside | 805 | * to do so we need to look if mime is contained inside |
806 | * the stringlist | 806 | * the stringlist |
807 | * if it's contained return true | 807 | * if it's contained return true |
808 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 808 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
809 | * is contained in the mimefilter and then we will | 809 | * is contained in the mimefilter and then we will |
810 | * look if both are equal until the '/' | 810 | * look if both are equal until the '/' |
811 | */ | 811 | */ |
812 | bool OFileSelector::compliesMime( const QString& mime ) { | 812 | bool OFileSelector::compliesMime( const QString& mime ) { |
813 | qWarning("mimetype is %s", mime.latin1() ); | 813 | qWarning("mimetype is %s", mime.latin1() ); |
814 | QString currentText; | 814 | QString currentText; |
815 | if (m_shChooser ) | 815 | if (m_shChooser ) |
816 | currentText = m_mimeCheck->currentText(); | 816 | currentText = m_mimeCheck->currentText(); |
817 | 817 | ||
818 | qWarning("current text is %s", currentText.latin1() ); | 818 | qWarning("current text is %s", currentText.latin1() ); |
819 | QMap<QString, QStringList>::Iterator it; | 819 | QMap<QString, QStringList>::Iterator it; |
820 | QStringList list; | 820 | QStringList list; |
821 | if ( currentText == tr("All") ) return true; | 821 | if ( currentText == tr("All") ) return true; |
822 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | 822 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { |
823 | it = m_mimetypes.begin(); | 823 | it = m_mimetypes.begin(); |
824 | list = it.data(); | 824 | list = it.data(); |
825 | }else if ( currentText.isEmpty() ) return true; | 825 | }else if ( currentText.isEmpty() ) return true; |
826 | else{ | 826 | else{ |
827 | it = m_mimetypes.find(currentText ); | 827 | it = m_mimetypes.find(currentText ); |
828 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 828 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
829 | else qWarning("found"), list = it.data(); | 829 | else qWarning("found"), list = it.data(); |
830 | } | 830 | } |
831 | 831 | ||
832 | 832 | ||
833 | if ( list.contains(mime) ) return true; | 833 | if ( list.contains(mime) ) return true; |
834 | qWarning("list doesn't contain it "); | 834 | qWarning("list doesn't contain it "); |
835 | QStringList::Iterator it2; | 835 | QStringList::Iterator it2; |
836 | int pos; | 836 | int pos; |
837 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | 837 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { |
838 | pos = (*it2).findRev("/*"); | 838 | pos = (*it2).findRev("/*"); |
839 | if ( pos >= 0 ) { | 839 | if ( pos >= 0 ) { |
840 | if ( mime.contains( (*it2).left(pos) ) ) return true; | 840 | if ( mime.contains( (*it2).left(pos) ) ) return true; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | return false; | 843 | return false; |
844 | } | 844 | } |
845 | void OFileSelector::slotFileSelected( const QString &string ) | 845 | void OFileSelector::slotFileSelected( const QString &string ) |
846 | { | 846 | { |
847 | if( m_shLne ) | 847 | if( m_shLne ) |
848 | m_edit->setText( string ); | 848 | m_edit->setText( string ); |
849 | emit fileSelected( string ); | 849 | emit fileSelected( string ); |
850 | } | 850 | } |
851 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 851 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
852 | { | 852 | { |
853 | slotFileSelected( lnk.name() ); | 853 | slotFileSelected( lnk.name() ); |
854 | // emit fileSelected( lnk ); | 854 | // emit fileSelected( lnk ); |
855 | } | 855 | } |
856 | 856 | ||
857 | 857 | ||
858 | void OFileSelector::slotDelete() | 858 | void OFileSelector::slotDelete() |
859 | { | 859 | { |
860 | /* | 860 | /* |
861 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 861 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
862 | QStringList list = QStringList::split("->", sel->text(1) ); | 862 | QStringList list = QStringList::split("->", sel->text(1) ); |
863 | if( sel->isDir() ){ | 863 | if( sel->isDir() ){ |
864 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 864 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
865 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 865 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
866 | tr("Yes"),tr("No"),0,1,1) ) { | 866 | tr("Yes"),tr("No"),0,1,1) ) { |
867 | case 0: | 867 | case 0: |
868 | ::system(str.utf8().data() ); | 868 | ::system(str.utf8().data() ); |
869 | break; | 869 | break; |
870 | } | 870 | } |
871 | } else { | 871 | } else { |
872 | QFile::remove( list[0] ); | 872 | QFile::remove( list[0] ); |
873 | } | 873 | } |
874 | m_View->takeItem( sel ); | 874 | m_View->takeItem( sel ); |
875 | delete sel; | 875 | delete sel; |
876 | */ | 876 | */ |
877 | } | 877 | } |
878 | void OFileSelector::cdUP() | 878 | void OFileSelector::cdUP() |
879 | { | 879 | { |
880 | QDir dir( m_currentDir ); | 880 | QDir dir( m_currentDir ); |
881 | dir.cdUp(); | 881 | dir.cdUp(); |
882 | if(dir.exists() ){ | 882 | if(dir.exists() ){ |
883 | m_currentDir = dir.absPath(); | 883 | m_currentDir = dir.absPath(); |
884 | reparse(); | 884 | reparse(); |
885 | int count = m_location->count(); | 885 | int count = m_location->count(); |
886 | slotInsertLocationPath( m_currentDir, count); | 886 | slotInsertLocationPath( m_currentDir, count); |
887 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 887 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
888 | //this wont work in all instances | 888 | //this wont work in all instances |
889 | // FIXME | 889 | // FIXME |
890 | } | 890 | } |
891 | } | 891 | } |
892 | void OFileSelector::slotHome() | 892 | void OFileSelector::slotHome() |
893 | { | 893 | { |
894 | cd(QDir::homeDirPath() ); | 894 | cd(QDir::homeDirPath() ); |
895 | } | 895 | } |
896 | void OFileSelector::slotDoc() | 896 | void OFileSelector::slotDoc() |
897 | { | 897 | { |
898 | cd(QPEApplication::documentDir() ); | 898 | cd(QPEApplication::documentDir() ); |
899 | } | 899 | } |
900 | void OFileSelector::slotNavigate( ) | 900 | void OFileSelector::slotNavigate( ) |
901 | { | 901 | { |
902 | 902 | ||
903 | } | 903 | } |
904 | // fill the View with life | 904 | // fill the View with life |
905 | void OFileSelector::reparse() | 905 | void OFileSelector::reparse() |
906 | { | 906 | { |
907 | if( m_selector == Normal ) | 907 | if( m_selector == Normal ) |
908 | return; | 908 | return; |
909 | 909 | ||
910 | currentView()->clear(); | 910 | currentView()->clear(); |
911 | 911 | ||
912 | if( m_shChooser) | 912 | if( m_shChooser) |
913 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 913 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
914 | 914 | ||
915 | QString currentMimeType; | 915 | QString currentMimeType; |
916 | 916 | ||
917 | // let's update the mimetype | 917 | // let's update the mimetype |
918 | if( m_autoMime ){ | 918 | if( m_autoMime ){ |
919 | m_mimetypes.clear(); | 919 | m_mimetypes.clear(); |
920 | // ok we can change mimetype so we need to be able to give a selection | 920 | // ok we can change mimetype so we need to be able to give a selection |
921 | if( m_shChooser ) { | 921 | if( m_shChooser ) { |
922 | currentMimeType = m_mimeCheck->currentText(); | 922 | currentMimeType = m_mimeCheck->currentText(); |
923 | m_mimeCheck->clear(); | 923 | m_mimeCheck->clear(); |
924 | 924 | ||
925 | // let's find possible mimetypes | 925 | // let's find possible mimetypes |
926 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); | 926 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); |
927 | 927 | ||
928 | // add them to the chooser | 928 | // add them to the chooser |
929 | updateMimeCheck(); | 929 | updateMimeCheck(); |
930 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 930 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
931 | currentMimeType = m_mimeCheck->currentText(); | 931 | currentMimeType = m_mimeCheck->currentText(); |
932 | } | 932 | } |
933 | }else { // no autoMime | 933 | }else { // no autoMime |
934 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 934 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
935 | 935 | ||
936 | if( m_shChooser ) | 936 | if( m_shChooser ) |
937 | currentMimeType = m_mimeCheck->currentText(); | 937 | currentMimeType = m_mimeCheck->currentText(); |
938 | 938 | ||
939 | } | 939 | } |
940 | // now we got our mimetypes we can add the files | 940 | // now we got our mimetypes we can add the files |
941 | 941 | ||
942 | currentLister()->reparse( m_currentDir ); | 942 | currentLister()->reparse( m_currentDir ); |
943 | /* we're done with adding let's sort */ | 943 | /* we're done with adding let's sort */ |
944 | currentView()->sort(); | 944 | currentView()->sort(); |
945 | 945 | ||
946 | 946 | ||
947 | if( m_shTool ){ | 947 | if( m_shTool ){ |
948 | m_location->insertItem( m_currentDir ); | 948 | m_location->insertItem( m_currentDir ); |
949 | 949 | ||
950 | } | 950 | } |
951 | // reenable painting and updates | 951 | // reenable painting and updates |
952 | } | 952 | } |
953 | 953 | ||
954 | 954 | ||
955 | OFileView* OFileSelector::currentView() { | 955 | OFileView* OFileSelector::currentView() { |
956 | return m_fileView; | 956 | return m_fileView; |
957 | } | 957 | } |
958 | OFileView* OFileSelector::currentView() const{ | 958 | OFileView* OFileSelector::currentView() const{ |
959 | return m_fileView; | 959 | return m_fileView; |
960 | } | 960 | } |
961 | int OFileSelector::filter() { | 961 | int OFileSelector::filter() { |
962 | int filter; | 962 | int filter; |
963 | if ( m_selector == ExtendedAll ) | 963 | if ( m_selector == ExtendedAll ) |
964 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 964 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
965 | else | 965 | else |
966 | filter = QDir::Files | QDir::Dirs | QDir::All ; | 966 | filter = QDir::Files | QDir::Dirs | QDir::All ; |
967 | 967 | ||
968 | return filter; | 968 | return filter; |
969 | } | 969 | } |
970 | int OFileSelector::sorting() { | 970 | int OFileSelector::sorting() { |
971 | int sort; | 971 | int sort; |
972 | 972 | ||
973 | if (m_case ) | 973 | if (m_case ) |
974 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 974 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
975 | else | 975 | else |
976 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 976 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
977 | 977 | ||
978 | return sort; | 978 | return sort; |
979 | } | 979 | } |
980 | void OFileSelector::internFileSelected( const QString& s) { | 980 | void OFileSelector::internFileSelected( const QString& s) { |
981 | emit fileSelected( s ); | 981 | emit fileSelected( s ); |
982 | } | 982 | } |
983 | void OFileSelector::internFileSelected( const DocLnk& d ) { | 983 | void OFileSelector::internFileSelected( const DocLnk& d ) { |
984 | emit fileSelected( d ); | 984 | emit fileSelected( d ); |
985 | } | 985 | } |
986 | void OFileSelector::internContextMenu() { | 986 | void OFileSelector::internContextMenu() { |
987 | emit contextMenu(); | 987 | emit contextMenu(); |
988 | } | 988 | } |
989 | void OFileSelector::internChangedDir( const QString& s) { | 989 | void OFileSelector::internChangedDir( const QString& s) { |
990 | emit dirSelected( s ); | 990 | emit dirSelected( s ); |
991 | cd(s ); | 991 | cd(s ); |
992 | } | 992 | } |
993 | void OFileSelector::internChangedDir( const QDir& s) { | 993 | void OFileSelector::internChangedDir( const QDir& s) { |
994 | emit dirSelected( s ); | 994 | emit dirSelected( s ); |
995 | } | 995 | } |
996 | QPixmap OFileSelector::pixmap( const QString& s ) { | 996 | QPixmap OFileSelector::pixmap( const QString& s ) { |
997 | 997 | ||
998 | return (*m_pixmaps)[s]; | 998 | return (*m_pixmaps)[s]; |
999 | } | 999 | } |
1000 | OLister* OFileSelector::currentLister()const { | 1000 | OLister* OFileSelector::currentLister()const { |
1001 | return m_lister; | 1001 | return m_lister; |
1002 | } | 1002 | } |
1003 | void OFileSelector::initializeOldSelector() { | 1003 | void OFileSelector::initializeOldSelector() { |
1004 | qWarning("initializeOldSelector"); | 1004 | qWarning("initializeOldSelector"); |
1005 | 1005 | ||
1006 | delete m_select; | 1006 | delete m_select; |
1007 | 1007 | ||
1008 | // we need to initialize but keep the selected mimetype | 1008 | // we need to initialize but keep the selected mimetype |
1009 | /* we default not to show close and new buttons */ | 1009 | /* we default not to show close and new buttons */ |
1010 | QString mime = currentMimeType(); | 1010 | QString mime = currentMimeType(); |
1011 | qWarning("MimeType " + mime ); | 1011 | qWarning("MimeType " + mime ); |
1012 | m_select = new FileSelector( mime , | 1012 | m_select = new FileSelector( mime , |
1013 | m_mainView, "fileselector", | 1013 | m_mainView, "fileselector", |
1014 | FALSE, FALSE); | 1014 | FALSE, FALSE); |
1015 | m_select->setCategorySelectVisible( FALSE ); | ||
1016 | m_select->setTypeComboVisible( FALSE ); | ||
1015 | 1017 | ||
1016 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 1018 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
1017 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 1019 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
1018 | connect(m_select, SIGNAL(closeMe() ), | 1020 | connect(m_select, SIGNAL(closeMe() ), |
1019 | this, SIGNAL(closeMe() ) ); | 1021 | this, SIGNAL(closeMe() ) ); |
1020 | //connect to close me and other signals as well | 1022 | //connect to close me and other signals as well |
1021 | m_mainView->setWidget( m_select ); | 1023 | m_mainView->setWidget( m_select ); |
1022 | } | 1024 | } |