-rw-r--r-- | core/apps/textedit/textedit.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 21bf4b3..6f96574 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -317,772 +317,769 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
317 | searchBarAction->addTo( advancedMenu); | 317 | searchBarAction->addTo( advancedMenu); |
318 | 318 | ||
319 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 319 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
320 | QString::null, 0, this, 0 ); | 320 | QString::null, 0, this, 0 ); |
321 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 321 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
322 | this, SLOT( doTimer(bool) ) ); | 322 | this, SLOT( doTimer(bool) ) ); |
323 | nAutoSave->setToggleAction(true); | 323 | nAutoSave->setToggleAction(true); |
324 | nAutoSave->addTo( advancedMenu); | 324 | nAutoSave->addTo( advancedMenu); |
325 | 325 | ||
326 | 326 | ||
327 | //font->insertSeparator(); | 327 | //font->insertSeparator(); |
328 | 328 | ||
329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
330 | 330 | ||
331 | mb->insertItem( tr( "File" ), file ); | 331 | mb->insertItem( tr( "File" ), file ); |
332 | mb->insertItem( tr( "Edit" ), edit ); | 332 | mb->insertItem( tr( "Edit" ), edit ); |
333 | mb->insertItem( tr( "View" ), font ); | 333 | mb->insertItem( tr( "View" ), font ); |
334 | 334 | ||
335 | searchBar = new QPEToolBar(this); | 335 | searchBar = new QPEToolBar(this); |
336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
337 | 337 | ||
338 | searchBar->setHorizontalStretchable( true ); | 338 | searchBar->setHorizontalStretchable( true ); |
339 | 339 | ||
340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
341 | searchBar->setStretchableWidget( searchEdit ); | 341 | searchBar->setStretchableWidget( searchEdit ); |
342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
343 | this, SLOT( search() ) ); | 343 | this, SLOT( search() ) ); |
344 | 344 | ||
345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
346 | QString::null, 0, this, 0 ); | 346 | QString::null, 0, this, 0 ); |
347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
348 | a->addTo( searchBar ); | 348 | a->addTo( searchBar ); |
349 | a->addTo( edit ); | 349 | a->addTo( edit ); |
350 | 350 | ||
351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
352 | QString::null, 0, this, 0 ); | 352 | QString::null, 0, this, 0 ); |
353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
354 | a->addTo( searchBar ); | 354 | a->addTo( searchBar ); |
355 | 355 | ||
356 | edit->insertSeparator(); | 356 | edit->insertSeparator(); |
357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
358 | QString::null, 0, this, 0 ); | 358 | QString::null, 0, this, 0 ); |
359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
360 | a->addTo( edit ); | 360 | a->addTo( edit ); |
361 | 361 | ||
362 | searchBar->hide(); | 362 | searchBar->hide(); |
363 | 363 | ||
364 | editor = new QpeEditor( this ); | 364 | editor = new QpeEditor( this ); |
365 | setCentralWidget( editor ); | 365 | setCentralWidget( editor ); |
366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
367 | connect( editor, SIGNAL( textChanged() ), | 367 | connect( editor, SIGNAL( textChanged() ), |
368 | this, SLOT( editorChanged() ) ); | 368 | this, SLOT( editorChanged() ) ); |
369 | 369 | ||
370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
371 | 371 | ||
372 | Config cfg("TextEdit"); | 372 | Config cfg("TextEdit"); |
373 | cfg. setGroup ( "Font" ); | 373 | cfg. setGroup ( "Font" ); |
374 | 374 | ||
375 | QFont defaultFont = editor-> font ( ); | 375 | QFont defaultFont = editor-> font ( ); |
376 | 376 | ||
377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
381 | 381 | ||
382 | defaultFont = QFont ( family, size, weight, italic ); | 382 | defaultFont = QFont ( family, size, weight, italic ); |
383 | editor-> setFont ( defaultFont ); | 383 | editor-> setFont ( defaultFont ); |
384 | // updateCaption(); | 384 | // updateCaption(); |
385 | 385 | ||
386 | cfg.setGroup ( "View" ); | 386 | cfg.setGroup ( "View" ); |
387 | 387 | ||
388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
392 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 392 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
394 | 394 | ||
395 | if(useSearchBar) searchBarAction->setOn(true); | 395 | if(useSearchBar) searchBarAction->setOn(true); |
396 | if(promptExit) nAdvanced->setOn( true ); | 396 | if(promptExit) nAdvanced->setOn( true ); |
397 | if(openDesktop) desktopAction->setOn( true ); | 397 | if(openDesktop) desktopAction->setOn( true ); |
398 | if(filePerms) filePermAction->setOn( true ); | 398 | if(filePerms) filePermAction->setOn( true ); |
399 | if(startWithNew) nStart->setOn( true ); | 399 | if(startWithNew) nStart->setOn( true ); |
400 | if(featureAutoSave) nAutoSave->setOn(true); | 400 | if(featureAutoSave) nAutoSave->setOn(true); |
401 | 401 | ||
402 | // { | 402 | // { |
403 | // doTimer(true); | 403 | // doTimer(true); |
404 | // } | 404 | // } |
405 | 405 | ||
406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
407 | wa-> setOn ( wrap ); | 407 | wa-> setOn ( wrap ); |
408 | setWordWrap ( wrap ); | 408 | setWordWrap ( wrap ); |
409 | 409 | ||
410 | ///////////////// | 410 | ///////////////// |
411 | if( qApp->argc() > 1) { | 411 | if( qApp->argc() > 1) { |
412 | currentFileName=qApp->argv()[1]; | 412 | currentFileName=qApp->argv()[1]; |
413 | 413 | ||
414 | QFileInfo fi(currentFileName); | 414 | QFileInfo fi(currentFileName); |
415 | 415 | ||
416 | if(fi.baseName().left(1) == "") { | 416 | if(fi.baseName().left(1) == "") { |
417 | openDotFile(currentFileName); | 417 | openDotFile(currentFileName); |
418 | } else { | 418 | } else { |
419 | openFile(currentFileName); | 419 | openFile(currentFileName); |
420 | } | 420 | } |
421 | } else { | 421 | } else { |
422 | edited1=false; | 422 | edited1=false; |
423 | openDotFile(""); | 423 | openDotFile(""); |
424 | } | 424 | } |
425 | 425 | ||
426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
427 | } | 427 | } |
428 | 428 | ||
429 | TextEdit::~TextEdit() { | 429 | TextEdit::~TextEdit() { |
430 | qWarning("textedit d'tor"); | 430 | qWarning("textedit d'tor"); |
431 | delete editor; | 431 | delete editor; |
432 | } | 432 | } |
433 | 433 | ||
434 | void TextEdit::closeEvent(QCloseEvent *) { | 434 | void TextEdit::closeEvent(QCloseEvent *) { |
435 | if( edited1 && promptExit) | 435 | if( edited1 && promptExit) |
436 | { | 436 | { |
437 | switch( savePrompt() ) | 437 | switch( savePrompt() ) |
438 | { | 438 | { |
439 | case 1: | 439 | case 1: |
440 | { | 440 | { |
441 | saveAs(); | 441 | saveAs(); |
442 | qApp->quit(); | 442 | qApp->quit(); |
443 | } | 443 | } |
444 | break; | 444 | break; |
445 | 445 | ||
446 | case 2: | 446 | case 2: |
447 | { | 447 | { |
448 | qApp->quit(); | 448 | qApp->quit(); |
449 | } | 449 | } |
450 | break; | 450 | break; |
451 | 451 | ||
452 | case -1: | 452 | case -1: |
453 | break; | 453 | break; |
454 | }; | 454 | }; |
455 | } | 455 | } |
456 | else | 456 | else |
457 | qApp->quit(); | 457 | qApp->quit(); |
458 | 458 | ||
459 | } | 459 | } |
460 | 460 | ||
461 | void TextEdit::cleanUp() { | 461 | void TextEdit::cleanUp() { |
462 | 462 | ||
463 | Config cfg ( "TextEdit" ); | 463 | Config cfg ( "TextEdit" ); |
464 | cfg. setGroup ( "Font" ); | 464 | cfg. setGroup ( "Font" ); |
465 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
466 | cfg.writeEntry ( "Family", f. family ( )); | 466 | cfg.writeEntry ( "Family", f. family ( )); |
467 | cfg.writeEntry ( "Size", f. pointSize ( )); | 467 | cfg.writeEntry ( "Size", f. pointSize ( )); |
468 | cfg.writeEntry ( "Weight", f. weight ( )); | 468 | cfg.writeEntry ( "Weight", f. weight ( )); |
469 | cfg.writeEntry ( "Italic", f. italic ( )); | 469 | cfg.writeEntry ( "Italic", f. italic ( )); |
470 | 470 | ||
471 | cfg.setGroup ( "View" ); | 471 | cfg.setGroup ( "View" ); |
472 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 472 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
473 | cfg.writeEntry ( "FileView", viewSelection ); | 473 | cfg.writeEntry ( "FileView", viewSelection ); |
474 | 474 | ||
475 | cfg.writeEntry ( "PromptExit", promptExit ); | 475 | cfg.writeEntry ( "PromptExit", promptExit ); |
476 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 476 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
477 | cfg.writeEntry ( "FilePermissions", filePerms ); | 477 | cfg.writeEntry ( "FilePermissions", filePerms ); |
478 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 478 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
479 | cfg.writeEntry ( "startNew", startWithNew ); | 479 | cfg.writeEntry ( "startNew", startWithNew ); |
480 | 480 | ||
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void TextEdit::accept() { | 484 | void TextEdit::accept() { |
485 | if( edited1) | 485 | if( edited1) |
486 | saveAs(); | 486 | saveAs(); |
487 | qApp->quit(); | 487 | qApp->quit(); |
488 | } | 488 | } |
489 | 489 | ||
490 | void TextEdit::zoomIn() { | 490 | void TextEdit::zoomIn() { |
491 | setFontSize(editor->font().pointSize()+1,false); | 491 | setFontSize(editor->font().pointSize()+1,false); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::zoomOut() { | 494 | void TextEdit::zoomOut() { |
495 | setFontSize(editor->font().pointSize()-1,true); | 495 | setFontSize(editor->font().pointSize()-1,true); |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 499 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
500 | int s=10; | 500 | int s=10; |
501 | for (int i=0; i<nfontsizes; i++) { | 501 | for (int i=0; i<nfontsizes; i++) { |
502 | if ( fontsize[i] == sz ) { | 502 | if ( fontsize[i] == sz ) { |
503 | s = sz; | 503 | s = sz; |
504 | break; | 504 | break; |
505 | } else if ( round_down_not_up ) { | 505 | } else if ( round_down_not_up ) { |
506 | if ( fontsize[i] < sz ) | 506 | if ( fontsize[i] < sz ) |
507 | s = fontsize[i]; | 507 | s = fontsize[i]; |
508 | } else { | 508 | } else { |
509 | if ( fontsize[i] > sz ) { | 509 | if ( fontsize[i] > sz ) { |
510 | s = fontsize[i]; | 510 | s = fontsize[i]; |
511 | break; | 511 | break; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | QFont f = editor->font(); | 516 | QFont f = editor->font(); |
517 | f.setPointSize(s); | 517 | f.setPointSize(s); |
518 | editor->setFont(f); | 518 | editor->setFont(f); |
519 | 519 | ||
520 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 520 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
521 | zout->setEnabled(s != fontsize[0]); | 521 | zout->setEnabled(s != fontsize[0]); |
522 | } | 522 | } |
523 | 523 | ||
524 | void TextEdit::setBold(bool y) { | 524 | void TextEdit::setBold(bool y) { |
525 | QFont f = editor->font(); | 525 | QFont f = editor->font(); |
526 | f.setBold(y); | 526 | f.setBold(y); |
527 | editor->setFont(f); | 527 | editor->setFont(f); |
528 | } | 528 | } |
529 | 529 | ||
530 | void TextEdit::setItalic(bool y) { | 530 | void TextEdit::setItalic(bool y) { |
531 | QFont f = editor->font(); | 531 | QFont f = editor->font(); |
532 | f.setItalic(y); | 532 | f.setItalic(y); |
533 | editor->setFont(f); | 533 | editor->setFont(f); |
534 | } | 534 | } |
535 | 535 | ||
536 | void TextEdit::setWordWrap(bool y) { | 536 | void TextEdit::setWordWrap(bool y) { |
537 | bool state = editor->edited(); | 537 | bool state = editor->edited(); |
538 | QString captionStr = caption(); | 538 | QString captionStr = caption(); |
539 | bool b1 = edited1; | 539 | bool b1 = edited1; |
540 | bool b2 = edited; | 540 | bool b2 = edited; |
541 | 541 | ||
542 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 542 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
543 | editor->setEdited( state ); | 543 | editor->setEdited( state ); |
544 | edited1=b1; | 544 | edited1=b1; |
545 | edited=b2; | 545 | edited=b2; |
546 | setCaption(captionStr); | 546 | setCaption(captionStr); |
547 | } | 547 | } |
548 | 548 | ||
549 | void TextEdit::setSearchBar(bool b) { | 549 | void TextEdit::setSearchBar(bool b) { |
550 | useSearchBar=b; | 550 | useSearchBar=b; |
551 | Config cfg("TextEdit"); | 551 | Config cfg("TextEdit"); |
552 | cfg.setGroup("View"); | 552 | cfg.setGroup("View"); |
553 | cfg.writeEntry ( "SearchBar", b ); | 553 | cfg.writeEntry ( "SearchBar", b ); |
554 | searchBarAction->setOn(b); | 554 | searchBarAction->setOn(b); |
555 | if(b) | 555 | if(b) |
556 | searchBar->show(); | 556 | searchBar->show(); |
557 | else | 557 | else |
558 | searchBar->hide(); | 558 | searchBar->hide(); |
559 | editor->setFocus(); | 559 | editor->setFocus(); |
560 | } | 560 | } |
561 | 561 | ||
562 | void TextEdit::fileNew() { | 562 | void TextEdit::fileNew() { |
563 | // if( !bFromDocView ) { | 563 | // if( !bFromDocView ) { |
564 | // saveAs(); | 564 | // saveAs(); |
565 | // } | 565 | // } |
566 | newFile(DocLnk()); | 566 | newFile(DocLnk()); |
567 | } | 567 | } |
568 | 568 | ||
569 | void TextEdit::fileOpen() { | 569 | void TextEdit::fileOpen() { |
570 | Config cfg("TextEdit"); | 570 | Config cfg("TextEdit"); |
571 | cfg. setGroup ( "View" ); | 571 | cfg. setGroup ( "View" ); |
572 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); | 572 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); |
573 | QMap<QString, QStringList> map; | 573 | QMap<QString, QStringList> map; |
574 | map.insert(tr("All"), QStringList() ); | 574 | map.insert(tr("All"), QStringList() ); |
575 | QStringList text; | 575 | QStringList text; |
576 | text << "text/*"; | 576 | text << "text/*"; |
577 | map.insert(tr("Text"), text ); | 577 | map.insert(tr("Text"), text ); |
578 | text << "*"; | 578 | text << "*"; |
579 | map.insert(tr("All"), text ); | 579 | map.insert(tr("All"), text ); |
580 | QString str = OFileDialog::getOpenFileName( 2, | 580 | QString str = OFileDialog::getOpenFileName( 2, |
581 | dir , | 581 | dir , |
582 | QString::null, map); | 582 | QString::null, map); |
583 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 583 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
584 | { | 584 | { |
585 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); | 585 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); |
586 | openFile( str ); | 586 | openFile( str ); |
587 | } | 587 | } |
588 | else | 588 | else |
589 | updateCaption(); | 589 | updateCaption(); |
590 | } | 590 | } |
591 | 591 | ||
592 | void TextEdit::doSearchBar() { | 592 | void TextEdit::doSearchBar() { |
593 | if(!useSearchBar) | 593 | if(!useSearchBar) |
594 | searchBar->hide(); | 594 | searchBar->hide(); |
595 | else | 595 | else |
596 | searchBar->show(); | 596 | searchBar->show(); |
597 | } | 597 | } |
598 | 598 | ||
599 | #if 0 | 599 | #if 0 |
600 | void TextEdit::slotFind() { | 600 | void TextEdit::slotFind() { |
601 | FindDialog frmFind( tr("Text Editor"), this ); | 601 | FindDialog frmFind( tr("Text Editor"), this ); |
602 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 602 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
603 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 603 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
604 | 604 | ||
605 | //case sensitive, backwards, [category] | 605 | //case sensitive, backwards, [category] |
606 | 606 | ||
607 | connect( editor, SIGNAL(notFound()), | 607 | connect( editor, SIGNAL(notFound()), |
608 | &frmFind, SLOT(slotNotFound()) ); | 608 | &frmFind, SLOT(slotNotFound()) ); |
609 | connect( editor, SIGNAL(searchWrapped()), | 609 | connect( editor, SIGNAL(searchWrapped()), |
610 | &frmFind, SLOT(slotWrapAround()) ); | 610 | &frmFind, SLOT(slotWrapAround()) ); |
611 | 611 | ||
612 | frmFind.exec(); | 612 | frmFind.exec(); |
613 | 613 | ||
614 | 614 | ||
615 | } | 615 | } |
616 | #endif | 616 | #endif |
617 | 617 | ||
618 | void TextEdit::fileRevert() { | 618 | void TextEdit::fileRevert() { |
619 | clear(); | 619 | clear(); |
620 | fileOpen(); | 620 | fileOpen(); |
621 | } | 621 | } |
622 | 622 | ||
623 | void TextEdit::editCut() { | 623 | void TextEdit::editCut() { |
624 | #ifndef QT_NO_CLIPBOARD | 624 | #ifndef QT_NO_CLIPBOARD |
625 | editor->cut(); | 625 | editor->cut(); |
626 | #endif | 626 | #endif |
627 | } | 627 | } |
628 | 628 | ||
629 | void TextEdit::editCopy() { | 629 | void TextEdit::editCopy() { |
630 | #ifndef QT_NO_CLIPBOARD | 630 | #ifndef QT_NO_CLIPBOARD |
631 | editor->copy(); | 631 | editor->copy(); |
632 | #endif | 632 | #endif |
633 | } | 633 | } |
634 | 634 | ||
635 | void TextEdit::editPaste() { | 635 | void TextEdit::editPaste() { |
636 | #ifndef QT_NO_CLIPBOARD | 636 | #ifndef QT_NO_CLIPBOARD |
637 | editor->paste(); | 637 | editor->paste(); |
638 | #endif | 638 | #endif |
639 | } | 639 | } |
640 | 640 | ||
641 | void TextEdit::editFind() { | 641 | void TextEdit::editFind() { |
642 | searchBar->show(); | 642 | searchBar->show(); |
643 | searchEdit->setFocus(); | 643 | searchEdit->setFocus(); |
644 | } | 644 | } |
645 | 645 | ||
646 | void TextEdit::findNext() { | 646 | void TextEdit::findNext() { |
647 | editor->find( searchEdit->text(), false, false ); | 647 | editor->find( searchEdit->text(), false, false ); |
648 | 648 | ||
649 | } | 649 | } |
650 | 650 | ||
651 | void TextEdit::findClose() { | 651 | void TextEdit::findClose() { |
652 | searchBar->hide(); | 652 | searchBar->hide(); |
653 | } | 653 | } |
654 | 654 | ||
655 | void TextEdit::search() { | 655 | void TextEdit::search() { |
656 | editor->find( searchEdit->text(), false, false ); | 656 | editor->find( searchEdit->text(), false, false ); |
657 | } | 657 | } |
658 | 658 | ||
659 | void TextEdit::newFile( const DocLnk &f ) { | 659 | void TextEdit::newFile( const DocLnk &f ) { |
660 | DocLnk nf = f; | 660 | DocLnk nf = f; |
661 | nf.setType("text/plain"); | 661 | nf.setType("text/plain"); |
662 | clear(); | 662 | clear(); |
663 | setWState (WState_Reserved1 ); | 663 | setWState (WState_Reserved1 ); |
664 | editor->setFocus(); | 664 | editor->setFocus(); |
665 | doc = new DocLnk(nf); | 665 | doc = new DocLnk(nf); |
666 | currentFileName = "Unnamed"; | 666 | currentFileName = "Unnamed"; |
667 | qDebug("newFile "+currentFileName); | 667 | qDebug("newFile "+currentFileName); |
668 | updateCaption( currentFileName); | 668 | updateCaption( currentFileName); |
669 | // editor->setEdited( false); | 669 | // editor->setEdited( false); |
670 | } | 670 | } |
671 | 671 | ||
672 | void TextEdit::openDotFile( const QString &f ) { | 672 | void TextEdit::openDotFile( const QString &f ) { |
673 | if(!currentFileName.isEmpty()) { | 673 | if(!currentFileName.isEmpty()) { |
674 | currentFileName=f; | 674 | currentFileName=f; |
675 | 675 | ||
676 | qDebug("openFile dotfile " + currentFileName); | 676 | qDebug("openFile dotfile " + currentFileName); |
677 | QString txt; | 677 | QString txt; |
678 | QFile file(f); | 678 | QFile file(f); |
679 | file.open(IO_ReadWrite); | 679 | file.open(IO_ReadWrite); |
680 | QTextStream t(&file); | 680 | QTextStream t(&file); |
681 | while ( !t.atEnd()) { | 681 | while ( !t.atEnd()) { |
682 | txt+=t.readLine()+"\n"; | 682 | txt+=t.readLine()+"\n"; |
683 | } | 683 | } |
684 | editor->setText(txt); | 684 | editor->setText(txt); |
685 | editor->setEdited( false); | 685 | editor->setEdited( false); |
686 | edited1=false; | 686 | edited1=false; |
687 | edited=false; | 687 | edited=false; |
688 | 688 | ||
689 | 689 | ||
690 | } | 690 | } |
691 | updateCaption( currentFileName); | 691 | updateCaption( currentFileName); |
692 | } | 692 | } |
693 | 693 | ||
694 | void TextEdit::openFile( const QString &f ) { | 694 | void TextEdit::openFile( const QString &f ) { |
695 | qDebug("filename is "+ f); | 695 | qDebug("filename is "+ f); |
696 | QString filer; | 696 | QString filer; |
697 | QFileInfo fi( f); | 697 | QFileInfo fi( f); |
698 | // bFromDocView = true; | 698 | // bFromDocView = true; |
699 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 699 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
700 | { | 700 | { |
701 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 701 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
702 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | ||
703 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | ||
704 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) | ||
705 | { | 702 | { |
706 | case 0: //desktop | 703 | case 0: //desktop |
707 | filer = f; | 704 | filer = f; |
708 | break; | 705 | break; |
709 | case 1: //linked | 706 | case 1: //linked |
710 | DocLnk sf(f); | 707 | DocLnk sf(f); |
711 | filer = sf.file(); | 708 | filer = sf.file(); |
712 | break; | 709 | break; |
713 | }; | 710 | }; |
714 | } | 711 | } |
715 | else if(fi.baseName().left(1) == "") | 712 | else if(fi.baseName().left(1) == "") |
716 | { | 713 | { |
717 | qDebug("opening dotfile"); | 714 | qDebug("opening dotfile"); |
718 | currentFileName=f; | 715 | currentFileName=f; |
719 | openDotFile(currentFileName); | 716 | openDotFile(currentFileName); |
720 | return; | 717 | return; |
721 | } | 718 | } |
722 | else | 719 | else |
723 | { | 720 | { |
724 | DocLnk sf(f); | 721 | DocLnk sf(f); |
725 | filer = sf.file(); | 722 | filer = sf.file(); |
726 | if(filer.right(1) == "/") | 723 | if(filer.right(1) == "/") |
727 | filer = f; | 724 | filer = f; |
728 | } | 725 | } |
729 | 726 | ||
730 | DocLnk nf; | 727 | DocLnk nf; |
731 | nf.setType("text/plain"); | 728 | nf.setType("text/plain"); |
732 | nf.setFile(filer); | 729 | nf.setFile(filer); |
733 | currentFileName=filer; | 730 | currentFileName=filer; |
734 | 731 | ||
735 | nf.setName(fi.baseName()); | 732 | nf.setName(fi.baseName()); |
736 | openFile(nf); | 733 | openFile(nf); |
737 | 734 | ||
738 | qDebug("openFile string "+currentFileName); | 735 | qDebug("openFile string "+currentFileName); |
739 | 736 | ||
740 | showEditTools(); | 737 | showEditTools(); |
741 | // Show filename in caption | 738 | // Show filename in caption |
742 | QString name = filer; | 739 | QString name = filer; |
743 | int sep = name.findRev( '/' ); | 740 | int sep = name.findRev( '/' ); |
744 | if ( sep > 0 ) | 741 | if ( sep > 0 ) |
745 | name = name.mid( sep+1 ); | 742 | name = name.mid( sep+1 ); |
746 | updateCaption( name ); | 743 | updateCaption( name ); |
747 | } | 744 | } |
748 | 745 | ||
749 | void TextEdit::openFile( const DocLnk &f ) { | 746 | void TextEdit::openFile( const DocLnk &f ) { |
750 | // clear(); | 747 | // clear(); |
751 | // bFromDocView = true; | 748 | // bFromDocView = true; |
752 | FileManager fm; | 749 | FileManager fm; |
753 | QString txt; | 750 | QString txt; |
754 | currentFileName=f.file(); | 751 | currentFileName=f.file(); |
755 | qDebug("openFile doclnk " + currentFileName); | 752 | qDebug("openFile doclnk " + currentFileName); |
756 | if ( !fm.loadFile( f, txt ) ) { | 753 | if ( !fm.loadFile( f, txt ) ) { |
757 | // ####### could be a new file | 754 | // ####### could be a new file |
758 | qDebug( "Cannot open file" ); | 755 | qDebug( "Cannot open file" ); |
759 | } | 756 | } |
760 | // fileNew(); | 757 | // fileNew(); |
761 | if ( doc ) | 758 | if ( doc ) |
762 | delete doc; | 759 | delete doc; |
763 | doc = new DocLnk(f); | 760 | doc = new DocLnk(f); |
764 | editor->setText(txt); | 761 | editor->setText(txt); |
765 | editor->setEdited( false); | 762 | editor->setEdited( false); |
766 | edited1=false; | 763 | edited1=false; |
767 | edited=false; | 764 | edited=false; |
768 | 765 | ||
769 | doc->setName(currentFileName); | 766 | doc->setName(currentFileName); |
770 | updateCaption(); | 767 | updateCaption(); |
771 | setTimer(); | 768 | setTimer(); |
772 | } | 769 | } |
773 | 770 | ||
774 | void TextEdit::showEditTools() { | 771 | void TextEdit::showEditTools() { |
775 | menu->show(); | 772 | menu->show(); |
776 | editBar->show(); | 773 | editBar->show(); |
777 | if(!useSearchBar) | 774 | if(!useSearchBar) |
778 | searchBar->hide(); | 775 | searchBar->hide(); |
779 | else | 776 | else |
780 | searchBar->show(); | 777 | searchBar->show(); |
781 | setWState (WState_Reserved1 ); | 778 | setWState (WState_Reserved1 ); |
782 | } | 779 | } |
783 | 780 | ||
784 | /*! | 781 | /*! |
785 | unprompted save */ | 782 | unprompted save */ |
786 | bool TextEdit::save() { | 783 | bool TextEdit::save() { |
787 | qDebug("saveAsFile " + currentFileName); | 784 | qDebug("saveAsFile " + currentFileName); |
788 | if(currentFileName.isEmpty()) { | 785 | if(currentFileName.isEmpty()) { |
789 | saveAs(); | 786 | saveAs(); |
790 | return false; | 787 | return false; |
791 | } | 788 | } |
792 | 789 | ||
793 | QString file = doc->file(); | 790 | QString file = doc->file(); |
794 | qDebug("saver file "+file); | 791 | qDebug("saver file "+file); |
795 | QString name= doc->name(); | 792 | QString name= doc->name(); |
796 | qDebug("File named "+name); | 793 | qDebug("File named "+name); |
797 | QString rt = editor->text(); | 794 | QString rt = editor->text(); |
798 | if( !rt.isEmpty() ) { | 795 | if( !rt.isEmpty() ) { |
799 | if(name.isEmpty()) { | 796 | if(name.isEmpty()) { |
800 | saveAs(); | 797 | saveAs(); |
801 | } else { | 798 | } else { |
802 | currentFileName= name ; | 799 | currentFileName= name ; |
803 | qDebug("saveFile "+currentFileName); | 800 | qDebug("saveFile "+currentFileName); |
804 | 801 | ||
805 | struct stat buf; | 802 | struct stat buf; |
806 | mode_t mode; | 803 | mode_t mode; |
807 | stat(file.latin1(), &buf); | 804 | stat(file.latin1(), &buf); |
808 | mode = buf.st_mode; | 805 | mode = buf.st_mode; |
809 | 806 | ||
810 | if(!fileIs) { | 807 | if(!fileIs) { |
811 | doc->setName( name); | 808 | doc->setName( name); |
812 | FileManager fm; | 809 | FileManager fm; |
813 | if ( !fm.saveFile( *doc, rt ) ) { | 810 | if ( !fm.saveFile( *doc, rt ) ) { |
814 | return false; | 811 | return false; |
815 | } | 812 | } |
816 | } else { | 813 | } else { |
817 | qDebug("regular save file"); | 814 | qDebug("regular save file"); |
818 | QFile f(file); | 815 | QFile f(file); |
819 | if( f.open(IO_WriteOnly)) { | 816 | if( f.open(IO_WriteOnly)) { |
820 | QCString crt = rt.utf8(); | 817 | QCString crt = rt.utf8(); |
821 | f.writeBlock(crt,crt.length()); | 818 | f.writeBlock(crt,crt.length()); |
822 | } else { | 819 | } else { |
823 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 820 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
824 | return false; | 821 | return false; |
825 | } | 822 | } |
826 | 823 | ||
827 | } | 824 | } |
828 | editor->setEdited( false); | 825 | editor->setEdited( false); |
829 | edited1=false; | 826 | edited1=false; |
830 | edited=false; | 827 | edited=false; |
831 | if(caption().left(1)=="*") | 828 | if(caption().left(1)=="*") |
832 | setCaption(caption().right(caption().length()-1)); | 829 | setCaption(caption().right(caption().length()-1)); |
833 | 830 | ||
834 | 831 | ||
835 | chmod( file.latin1(), mode); | 832 | chmod( file.latin1(), mode); |
836 | } | 833 | } |
837 | return true; | 834 | return true; |
838 | } | 835 | } |
839 | return false; | 836 | return false; |
840 | } | 837 | } |
841 | 838 | ||
842 | /*! | 839 | /*! |
843 | prompted save */ | 840 | prompted save */ |
844 | bool TextEdit::saveAs() { | 841 | bool TextEdit::saveAs() { |
845 | 842 | ||
846 | if(caption() == tr("Text Editor")) | 843 | if(caption() == tr("Text Editor")) |
847 | return false; | 844 | return false; |
848 | qDebug("saveAsFile " + currentFileName); | 845 | qDebug("saveAsFile " + currentFileName); |
849 | // case of nothing to save... | 846 | // case of nothing to save... |
850 | // if ( !doc && !currentFileName.isEmpty()) { | 847 | // if ( !doc && !currentFileName.isEmpty()) { |
851 | // //|| !bFromDocView) | 848 | // //|| !bFromDocView) |
852 | // qDebug("no doc"); | 849 | // qDebug("no doc"); |
853 | // return true; | 850 | // return true; |
854 | // } | 851 | // } |
855 | // if ( !editor->edited() ) { | 852 | // if ( !editor->edited() ) { |
856 | // delete doc; | 853 | // delete doc; |
857 | // doc = 0; | 854 | // doc = 0; |
858 | // return true; | 855 | // return true; |
859 | // } | 856 | // } |
860 | 857 | ||
861 | QString rt = editor->text(); | 858 | QString rt = editor->text(); |
862 | qDebug(currentFileName); | 859 | qDebug(currentFileName); |
863 | 860 | ||
864 | if( currentFileName.isEmpty() | 861 | if( currentFileName.isEmpty() |
865 | || currentFileName == tr("Unnamed") | 862 | || currentFileName == tr("Unnamed") |
866 | || currentFileName == tr("Text Editor")) { | 863 | || currentFileName == tr("Text Editor")) { |
867 | qDebug("do silly TT filename thing"); | 864 | qDebug("do silly TT filename thing"); |
868 | // if ( doc && doc->name().isEmpty() ) { | 865 | // if ( doc && doc->name().isEmpty() ) { |
869 | QString pt = rt.simplifyWhiteSpace(); | 866 | QString pt = rt.simplifyWhiteSpace(); |
870 | int i = pt.find( ' ' ); | 867 | int i = pt.find( ' ' ); |
871 | QString docname = pt; | 868 | QString docname = pt; |
872 | if ( i > 0 ) | 869 | if ( i > 0 ) |
873 | docname = pt.left( i ); | 870 | docname = pt.left( i ); |
874 | // remove "." at the beginning | 871 | // remove "." at the beginning |
875 | while( docname.startsWith( "." ) ) | 872 | while( docname.startsWith( "." ) ) |
876 | docname = docname.mid( 1 ); | 873 | docname = docname.mid( 1 ); |
877 | docname.replace( QRegExp("/"), "_" ); | 874 | docname.replace( QRegExp("/"), "_" ); |
878 | // cut the length. filenames longer than that | 875 | // cut the length. filenames longer than that |
879 | //don't make sense and something goes wrong when they get too long. | 876 | //don't make sense and something goes wrong when they get too long. |
880 | if ( docname.length() > 40 ) | 877 | if ( docname.length() > 40 ) |
881 | docname = docname.left(40); | 878 | docname = docname.left(40); |
882 | if ( docname.isEmpty() ) | 879 | if ( docname.isEmpty() ) |
883 | docname = tr("Unnamed"); | 880 | docname = tr("Unnamed"); |
884 | if(doc) doc->setName(docname); | 881 | if(doc) doc->setName(docname); |
885 | currentFileName=docname; | 882 | currentFileName=docname; |
886 | // } | 883 | // } |
887 | // else | 884 | // else |
888 | // qDebug("hmmmmmm"); | 885 | // qDebug("hmmmmmm"); |
889 | } | 886 | } |
890 | 887 | ||
891 | 888 | ||
892 | QMap<QString, QStringList> map; | 889 | QMap<QString, QStringList> map; |
893 | map.insert(tr("All"), QStringList() ); | 890 | map.insert(tr("All"), QStringList() ); |
894 | QStringList text; | 891 | QStringList text; |
895 | text << "text/*"; | 892 | text << "text/*"; |
896 | map.insert(tr("Text"), text ); | 893 | map.insert(tr("Text"), text ); |
897 | text << "*"; | 894 | text << "*"; |
898 | map.insert(tr("All"), text ); | 895 | map.insert(tr("All"), text ); |
899 | 896 | ||
900 | QFileInfo cuFi( currentFileName); | 897 | QFileInfo cuFi( currentFileName); |
901 | QString filee = cuFi.fileName(); | 898 | QString filee = cuFi.fileName(); |
902 | QString dire = cuFi.dirPath(); | 899 | QString dire = cuFi.dirPath(); |
903 | if(dire==".") | 900 | if(dire==".") |
904 | dire = QPEApplication::documentDir(); | 901 | dire = QPEApplication::documentDir(); |
905 | QString str; | 902 | QString str; |
906 | if( !featureAutoSave) | 903 | if( !featureAutoSave) |
907 | { | 904 | { |
908 | str = OFileDialog::getSaveFileName( 2, | 905 | str = OFileDialog::getSaveFileName( 2, |
909 | dire, | 906 | dire, |
910 | filee, map); | 907 | filee, map); |
911 | } | 908 | } |
912 | else | 909 | else |
913 | str=currentFileName; | 910 | str=currentFileName; |
914 | if(!str.isEmpty()) { | 911 | if(!str.isEmpty()) { |
915 | QString fileNm=str; | 912 | QString fileNm=str; |
916 | 913 | ||
917 | qDebug("saving filename "+fileNm); | 914 | qDebug("saving filename "+fileNm); |
918 | QFileInfo fi(fileNm); | 915 | QFileInfo fi(fileNm); |
919 | currentFileName=fi.fileName(); | 916 | currentFileName=fi.fileName(); |
920 | if(doc) | 917 | if(doc) |
921 | // QString file = doc->file(); | 918 | // QString file = doc->file(); |
922 | // doc->removeFiles(); | 919 | // doc->removeFiles(); |
923 | delete doc; | 920 | delete doc; |
924 | DocLnk nf; | 921 | DocLnk nf; |
925 | nf.setType("text/plain"); | 922 | nf.setType("text/plain"); |
926 | nf.setFile( fileNm); | 923 | nf.setFile( fileNm); |
927 | doc = new DocLnk(nf); | 924 | doc = new DocLnk(nf); |
928 | // editor->setText(rt); | 925 | // editor->setText(rt); |
929 | qDebug("Saving file as "+currentFileName); | 926 | qDebug("Saving file as "+currentFileName); |
930 | doc->setName( currentFileName); | 927 | doc->setName( currentFileName); |
931 | updateCaption( currentFileName); | 928 | updateCaption( currentFileName); |
932 | 929 | ||
933 | FileManager fm; | 930 | FileManager fm; |
934 | if ( !fm.saveFile( *doc, rt ) ) { | 931 | if ( !fm.saveFile( *doc, rt ) ) { |
935 | return false; | 932 | return false; |
936 | } | 933 | } |
937 | 934 | ||
938 | if( filePerms ) { | 935 | if( filePerms ) { |
939 | filePermissions *filePerm; | 936 | filePermissions *filePerm; |
940 | filePerm = new filePermissions(this, | 937 | filePerm = new filePermissions(this, |
941 | tr("Permissions"),true, | 938 | tr("Permissions"),true, |
942 | 0,(const QString &)fileNm); | 939 | 0,(const QString &)fileNm); |
943 | filePerm->showMaximized(); | 940 | filePerm->showMaximized(); |
944 | filePerm->exec(); | 941 | filePerm->exec(); |
945 | 942 | ||
946 | if( filePerm) | 943 | if( filePerm) |
947 | delete filePerm; | 944 | delete filePerm; |
948 | } | 945 | } |
949 | // } | 946 | // } |
950 | editor->setEdited( false); | 947 | editor->setEdited( false); |
951 | edited1 = false; | 948 | edited1 = false; |
952 | edited = false; | 949 | edited = false; |
953 | if(caption().left(1)=="*") | 950 | if(caption().left(1)=="*") |
954 | setCaption(caption().right(caption().length()-1)); | 951 | setCaption(caption().right(caption().length()-1)); |
955 | 952 | ||
956 | return true; | 953 | return true; |
957 | } | 954 | } |
958 | qDebug("returning false"); | 955 | qDebug("returning false"); |
959 | return false; | 956 | return false; |
960 | } //end saveAs | 957 | } //end saveAs |
961 | 958 | ||
962 | void TextEdit::clear() { | 959 | void TextEdit::clear() { |
963 | delete doc; | 960 | delete doc; |
964 | doc = 0; | 961 | doc = 0; |
965 | editor->clear(); | 962 | editor->clear(); |
966 | } | 963 | } |
967 | 964 | ||
968 | void TextEdit::updateCaption( const QString &name ) { | 965 | void TextEdit::updateCaption( const QString &name ) { |
969 | 966 | ||
970 | if ( name.isEmpty() ) | 967 | if ( name.isEmpty() ) |
971 | setCaption( tr("Text Editor") ); | 968 | setCaption( tr("Text Editor") ); |
972 | else { | 969 | else { |
973 | QString s = name; | 970 | QString s = name; |
974 | if ( s.isNull() ) | 971 | if ( s.isNull() ) |
975 | s = doc->name(); | 972 | s = doc->name(); |
976 | if ( s.isEmpty() ) { | 973 | if ( s.isEmpty() ) { |
977 | s = tr( "Unnamed" ); | 974 | s = tr( "Unnamed" ); |
978 | currentFileName=s; | 975 | currentFileName=s; |
979 | } | 976 | } |
980 | // if(s.left(1) == "/") | 977 | // if(s.left(1) == "/") |
981 | // s = s.right(s.length()-1); | 978 | // s = s.right(s.length()-1); |
982 | setCaption( s + " - " + tr("Text Editor") ); | 979 | setCaption( s + " - " + tr("Text Editor") ); |
983 | } | 980 | } |
984 | } | 981 | } |
985 | 982 | ||
986 | void TextEdit::setDocument(const QString& fileref) { | 983 | void TextEdit::setDocument(const QString& fileref) { |
987 | if(fileref != "Unnamed") { | 984 | if(fileref != "Unnamed") { |
988 | currentFileName=fileref; | 985 | currentFileName=fileref; |
989 | qDebug("setDocument"); | 986 | qDebug("setDocument"); |
990 | QFileInfo fi(currentFileName); | 987 | QFileInfo fi(currentFileName); |
991 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 988 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
992 | if( (fi.baseName().left(1)).isEmpty() ) { | 989 | if( (fi.baseName().left(1)).isEmpty() ) { |
993 | openDotFile(currentFileName); | 990 | openDotFile(currentFileName); |
994 | 991 | ||
995 | } else { | 992 | } else { |
996 | qDebug("setDoc open"); | 993 | qDebug("setDoc open"); |
997 | bFromDocView = true; | 994 | bFromDocView = true; |
998 | openFile(fileref); | 995 | openFile(fileref); |
999 | editor->setEdited(true); | 996 | editor->setEdited(true); |
1000 | edited1=false; | 997 | edited1=false; |
1001 | edited=true; | 998 | edited=true; |
1002 | // fromSetDocument=false; | 999 | // fromSetDocument=false; |
1003 | // doSearchBar(); | 1000 | // doSearchBar(); |
1004 | } | 1001 | } |
1005 | } | 1002 | } |
1006 | updateCaption( currentFileName); | 1003 | updateCaption( currentFileName); |
1007 | } | 1004 | } |
1008 | 1005 | ||
1009 | void TextEdit::changeFont() { | 1006 | void TextEdit::changeFont() { |
1010 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1007 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1011 | d-> setCaption ( tr( "Choose font" )); | 1008 | d-> setCaption ( tr( "Choose font" )); |
1012 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1009 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1013 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1010 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1014 | lay-> addWidget ( ofs ); | 1011 | lay-> addWidget ( ofs ); |
1015 | ofs-> setSelectedFont ( editor-> font ( )); | 1012 | ofs-> setSelectedFont ( editor-> font ( )); |
1016 | 1013 | ||
1017 | d-> showMaximized ( ); | 1014 | d-> showMaximized ( ); |
1018 | if ( d-> exec ( ) == QDialog::Accepted ) | 1015 | if ( d-> exec ( ) == QDialog::Accepted ) |
1019 | editor-> setFont ( ofs-> selectedFont ( )); | 1016 | editor-> setFont ( ofs-> selectedFont ( )); |
1020 | delete d; | 1017 | delete d; |
1021 | 1018 | ||
1022 | } | 1019 | } |
1023 | 1020 | ||
1024 | void TextEdit::editDelete() { | 1021 | void TextEdit::editDelete() { |
1025 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1022 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1026 | tr("Do you really want<BR>to <B>delete</B> " | 1023 | tr("Do you really want<BR>to <B>delete</B> " |
1027 | "the current file\nfrom the disk?<BR>This is " | 1024 | "the current file\nfrom the disk?<BR>This is " |
1028 | "<B>irreversable!!</B>"), | 1025 | "<B>irreversable!!</B>"), |
1029 | tr("Yes"),tr("No"),0,0,1) ) { | 1026 | tr("Yes"),tr("No"),0,0,1) ) { |
1030 | case 0: | 1027 | case 0: |
1031 | if(doc) { | 1028 | if(doc) { |
1032 | doc->removeFiles(); | 1029 | doc->removeFiles(); |
1033 | clear(); | 1030 | clear(); |
1034 | setCaption( tr("Text Editor") ); | 1031 | setCaption( tr("Text Editor") ); |
1035 | } | 1032 | } |
1036 | break; | 1033 | break; |
1037 | case 1: | 1034 | case 1: |
1038 | // exit | 1035 | // exit |
1039 | break; | 1036 | break; |
1040 | }; | 1037 | }; |
1041 | } | 1038 | } |
1042 | 1039 | ||
1043 | void TextEdit::changeStartConfig( bool b ) { | 1040 | void TextEdit::changeStartConfig( bool b ) { |
1044 | startWithNew=b; | 1041 | startWithNew=b; |
1045 | Config cfg("TextEdit"); | 1042 | Config cfg("TextEdit"); |
1046 | cfg.setGroup("View"); | 1043 | cfg.setGroup("View"); |
1047 | cfg.writeEntry("startNew",b); | 1044 | cfg.writeEntry("startNew",b); |
1048 | update(); | 1045 | update(); |
1049 | } | 1046 | } |
1050 | 1047 | ||
1051 | void TextEdit::editorChanged() { | 1048 | void TextEdit::editorChanged() { |
1052 | // qDebug("editor changed"); | 1049 | // qDebug("editor changed"); |
1053 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1050 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1054 | setCaption( "*"+caption()); | 1051 | setCaption( "*"+caption()); |
1055 | edited1=true; | 1052 | edited1=true; |
1056 | } | 1053 | } |
1057 | edited=true; | 1054 | edited=true; |
1058 | } | 1055 | } |
1059 | 1056 | ||
1060 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1057 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1061 | qDebug("QCop "+msg); | 1058 | qDebug("QCop "+msg); |
1062 | if ( msg == "setDocument(QString)" ) { | 1059 | if ( msg == "setDocument(QString)" ) { |
1063 | qDebug("bugger all"); | 1060 | qDebug("bugger all"); |
1064 | 1061 | ||
1065 | } | 1062 | } |
1066 | 1063 | ||
1067 | } | 1064 | } |
1068 | 1065 | ||
1069 | void TextEdit::doAbout() { | 1066 | void TextEdit::doAbout() { |
1070 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1067 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1071 | "2000 Trolltech AS, and<BR>" | 1068 | "2000 Trolltech AS, and<BR>" |
1072 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1069 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1073 | "and is licensed under the GPL")); | 1070 | "and is licensed under the GPL")); |
1074 | } | 1071 | } |
1075 | 1072 | ||
1076 | void TextEdit::doPrompt(bool b) { | 1073 | void TextEdit::doPrompt(bool b) { |
1077 | promptExit=b; | 1074 | promptExit=b; |
1078 | Config cfg("TextEdit"); | 1075 | Config cfg("TextEdit"); |
1079 | cfg.setGroup ( "View" ); | 1076 | cfg.setGroup ( "View" ); |
1080 | cfg.writeEntry ( "PromptExit", b); | 1077 | cfg.writeEntry ( "PromptExit", b); |
1081 | } | 1078 | } |
1082 | 1079 | ||
1083 | void TextEdit::doDesktop(bool b) { | 1080 | void TextEdit::doDesktop(bool b) { |
1084 | openDesktop=b; | 1081 | openDesktop=b; |
1085 | Config cfg("TextEdit"); | 1082 | Config cfg("TextEdit"); |
1086 | cfg.setGroup ( "View" ); | 1083 | cfg.setGroup ( "View" ); |
1087 | cfg.writeEntry ( "OpenDesktop", b); | 1084 | cfg.writeEntry ( "OpenDesktop", b); |
1088 | } | 1085 | } |