Diffstat (limited to 'noncore/apps/opie-write/qtextedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qtextedit.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-write/qtextedit.cpp b/noncore/apps/opie-write/qtextedit.cpp index 27dd515..73b7b7b 100644 --- a/noncore/apps/opie-write/qtextedit.cpp +++ b/noncore/apps/opie-write/qtextedit.cpp | |||
@@ -584,194 +584,194 @@ static bool block_set_alignment = FALSE; | |||
584 | 584 | ||
585 | The new alignment is \a a. | 585 | The new alignment is \a a. |
586 | 586 | ||
587 | \sa setAlignment() | 587 | \sa setAlignment() |
588 | */ | 588 | */ |
589 | 589 | ||
590 | /*! \fn void QTextEdit::cursorPositionChanged( QTextCursor *c ) | 590 | /*! \fn void QTextEdit::cursorPositionChanged( QTextCursor *c ) |
591 | 591 | ||
592 | This signal is emitted if the position of the cursor changed. \a c | 592 | This signal is emitted if the position of the cursor changed. \a c |
593 | points to the text cursor object. | 593 | points to the text cursor object. |
594 | 594 | ||
595 | \sa setCursorPosition() | 595 | \sa setCursorPosition() |
596 | */ | 596 | */ |
597 | 597 | ||
598 | /*! \overload void QTextEdit::cursorPositionChanged( int para, int pos ) | 598 | /*! \overload void QTextEdit::cursorPositionChanged( int para, int pos ) |
599 | 599 | ||
600 | This signal is emitted if the position of the cursor changed. \a | 600 | This signal is emitted if the position of the cursor changed. \a |
601 | para contains the paragraph index and \a pos contains the character | 601 | para contains the paragraph index and \a pos contains the character |
602 | position within the paragraph. | 602 | position within the paragraph. |
603 | 603 | ||
604 | \sa setCursorPosition() | 604 | \sa setCursorPosition() |
605 | */ | 605 | */ |
606 | 606 | ||
607 | /*! \fn void QTextEdit::returnPressed() | 607 | /*! \fn void QTextEdit::returnPressed() |
608 | 608 | ||
609 | This signal is emitted if the user pressed the Return or the Enter key. | 609 | This signal is emitted if the user pressed the Return or the Enter key. |
610 | */ | 610 | */ |
611 | 611 | ||
612 | /*! | 612 | /*! |
613 | \fn QTextCursor *QTextEdit::textCursor() const | 613 | \fn QTextCursor *QTextEdit::textCursor() const |
614 | 614 | ||
615 | Returns the text edit's text cursor. | 615 | Returns the text edit's text cursor. |
616 | 616 | ||
617 | \warning QTextCursor is not in the public API, but in special | 617 | \warning QTextCursor is not in the public API, but in special |
618 | circumstances you might wish to use it. | 618 | circumstances you might wish to use it. |
619 | */ | 619 | */ |
620 | 620 | ||
621 | /*! Constructs an empty QTextEdit with parent \a parent and name \a | 621 | /*! Constructs an empty QTextEdit with parent \a parent and name \a |
622 | name. | 622 | name. |
623 | */ | 623 | */ |
624 | 624 | ||
625 | QTextEdit::QTextEdit( QWidget *parent, const char *name ) | 625 | QTextEdit::QTextEdit( QWidget *parent, const char *name ) |
626 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), | 626 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), |
627 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) | 627 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) |
628 | { | 628 | { |
629 | init(); | 629 | init(); |
630 | } | 630 | } |
631 | 631 | ||
632 | /*! | 632 | /*! |
633 | Constructs a QTextEdit with parent \a parent and name \a name. The | 633 | Constructs a QTextEdit with parent \a parent and name \a name. The |
634 | text edit will display the text \a text using context \a context. | 634 | text edit will display the text \a text using context \a context. |
635 | 635 | ||
636 | The \a context is a path which the text edit's QMimeSourceFactory | 636 | The \a context is a path which the text edit's QMimeSourceFactory |
637 | uses to resolve the locations of files and images. It is passed to | 637 | uses to resolve the locations of files and images. It is passed to |
638 | the mimeSourceFactory() when quering data. | 638 | the mimeSourceFactory() when quering data. |
639 | 639 | ||
640 | For example if the text contains an image tag, | 640 | For example if the text contains an image tag, |
641 | \c{<img src="image.png">}, and the context is "path/to/look/in", the | 641 | \c{<img src="image.png">}, and the context is "path/to/look/in", the |
642 | QMimeSourceFactory will try to load the image from | 642 | QMimeSourceFactory will try to load the image from |
643 | "path/to/look/in/image.png". If the tag was | 643 | "path/to/look/in/image.png". If the tag was |
644 | \c{<img src="/image.png">}, the context will not be used (because | 644 | \c{<img src="/image.png">}, the context will not be used (because |
645 | QMimeSourceFactory recognizes that we have used an absolute path) | 645 | QMimeSourceFactory recognizes that we have used an absolute path) |
646 | and will try to load "/image.png". The context is applied in exactly | 646 | and will try to load "/image.png". The context is applied in exactly |
647 | the same way to \e hrefs, for example, | 647 | the same way to \e hrefs, for example, |
648 | \c{<a href="target.html">Target</a>}, would resolve to | 648 | \c{<a href="target.html">Target</a>}, would resolve to |
649 | "path/to/look/in/target.html". | 649 | "path/to/look/in/target.html". |
650 | 650 | ||
651 | */ | 651 | */ |
652 | 652 | ||
653 | QTextEdit::QTextEdit( const QString& text, const QString& context, | 653 | QTextEdit::QTextEdit( const QString& text, const QString& context, |
654 | QWidget *parent, const char *name) | 654 | QWidget *parent, const char *name) |
655 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), | 655 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), |
656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) | 656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) |
657 | { | 657 | { |
658 | init(); | 658 | init(); |
659 | setText( text, context ); | 659 | setText( text, context ); |
660 | } | 660 | } |
661 | 661 | ||
662 | /*! \reimp */ | 662 | /*! \reimp */ |
663 | 663 | ||
664 | QTextEdit::~QTextEdit() | 664 | QTextEdit::~QTextEdit() |
665 | { | 665 | { |
666 | delete undoRedoInfo.d; | 666 | delete undoRedoInfo.d; |
667 | undoRedoInfo.d = 0; | 667 | undoRedoInfo.d = 0; |
668 | delete cursor; | 668 | delete cursor; |
669 | delete doc; | 669 | delete doc; |
670 | delete d; | 670 | delete d; |
671 | } | 671 | } |
672 | 672 | ||
673 | void QTextEdit::init() | 673 | void QTextEdit::init() |
674 | { | 674 | { |
675 | setFrameStyle( Sunken ); | 675 | setFrameStyle( Sunken ); |
676 | undoEnabled = TRUE; | 676 | undoEnabled = TRUE; |
677 | readonly = TRUE; | 677 | readonly = TRUE; |
678 | setReadOnly( FALSE ); | 678 | setReadOnly( FALSE ); |
679 | d = new QTextEditPrivate; | 679 | d = new QTextEditPrivate; |
680 | connect( doc, SIGNAL( minimumWidthChanged( int ) ), | 680 | connect( doc, SIGNAL( minimumWidthChanged(int) ), |
681 | this, SLOT( documentWidthChanged( int ) ) ); | 681 | this, SLOT( documentWidthChanged(int) ) ); |
682 | 682 | ||
683 | mousePressed = FALSE; | 683 | mousePressed = FALSE; |
684 | inDoubleClick = FALSE; | 684 | inDoubleClick = FALSE; |
685 | modified = FALSE; | 685 | modified = FALSE; |
686 | onLink = QString::null; | 686 | onLink = QString::null; |
687 | overWrite = FALSE; | 687 | overWrite = FALSE; |
688 | wrapMode = WidgetWidth; | 688 | wrapMode = WidgetWidth; |
689 | wrapWidth = -1; | 689 | wrapWidth = -1; |
690 | wPolicy = AtWhiteSpace; | 690 | wPolicy = AtWhiteSpace; |
691 | inDnD = FALSE; | 691 | inDnD = FALSE; |
692 | 692 | ||
693 | doc->setFormatter( new QTextFormatterBreakWords ); | 693 | doc->setFormatter( new QTextFormatterBreakWords ); |
694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); | 694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); |
695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); | 695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); |
696 | currentFormat = doc->formatCollection()->defaultFormat(); | 696 | currentFormat = doc->formatCollection()->defaultFormat(); |
697 | currentAlignment = Qt3::AlignAuto; | 697 | currentAlignment = Qt3::AlignAuto; |
698 | 698 | ||
699 | viewport()->setBackgroundMode( PaletteBase ); | 699 | viewport()->setBackgroundMode( PaletteBase ); |
700 | viewport()->setAcceptDrops( TRUE ); | 700 | viewport()->setAcceptDrops( TRUE ); |
701 | resizeContents( 0, doc->lastParagraph() ? | 701 | resizeContents( 0, doc->lastParagraph() ? |
702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); | 702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); |
703 | 703 | ||
704 | setKeyCompression( TRUE ); | 704 | setKeyCompression( TRUE ); |
705 | viewport()->setMouseTracking( TRUE ); | 705 | viewport()->setMouseTracking( TRUE ); |
706 | #ifndef QT_NO_CURSOR | 706 | #ifndef QT_NO_CURSOR |
707 | viewport()->setCursor( isReadOnly() ? arrowCursor : ibeamCursor ); | 707 | viewport()->setCursor( isReadOnly() ? arrowCursor : ibeamCursor ); |
708 | #endif | 708 | #endif |
709 | cursor = new QTextCursor( doc ); | 709 | cursor = new QTextCursor( doc ); |
710 | 710 | ||
711 | formatTimer = new QTimer( this ); | 711 | formatTimer = new QTimer( this ); |
712 | connect( formatTimer, SIGNAL( timeout() ), | 712 | connect( formatTimer, SIGNAL( timeout() ), |
713 | this, SLOT( formatMore() ) ); | 713 | this, SLOT( formatMore() ) ); |
714 | lastFormatted = doc->firstParagraph(); | 714 | lastFormatted = doc->firstParagraph(); |
715 | 715 | ||
716 | scrollTimer = new QTimer( this ); | 716 | scrollTimer = new QTimer( this ); |
717 | connect( scrollTimer, SIGNAL( timeout() ), | 717 | connect( scrollTimer, SIGNAL( timeout() ), |
718 | this, SLOT( autoScrollTimerDone() ) ); | 718 | this, SLOT( autoScrollTimerDone() ) ); |
719 | 719 | ||
720 | interval = 0; | 720 | interval = 0; |
721 | changeIntervalTimer = new QTimer( this ); | 721 | changeIntervalTimer = new QTimer( this ); |
722 | connect( changeIntervalTimer, SIGNAL( timeout() ), | 722 | connect( changeIntervalTimer, SIGNAL( timeout() ), |
723 | this, SLOT( doChangeInterval() ) ); | 723 | this, SLOT( doChangeInterval() ) ); |
724 | 724 | ||
725 | cursorVisible = TRUE; | 725 | cursorVisible = TRUE; |
726 | blinkTimer = new QTimer( this ); | 726 | blinkTimer = new QTimer( this ); |
727 | connect( blinkTimer, SIGNAL( timeout() ), | 727 | connect( blinkTimer, SIGNAL( timeout() ), |
728 | this, SLOT( blinkCursor() ) ); | 728 | this, SLOT( blinkCursor() ) ); |
729 | 729 | ||
730 | #ifndef QT_NO_DRAGANDDROP | 730 | #ifndef QT_NO_DRAGANDDROP |
731 | dragStartTimer = new QTimer( this ); | 731 | dragStartTimer = new QTimer( this ); |
732 | connect( dragStartTimer, SIGNAL( timeout() ), | 732 | connect( dragStartTimer, SIGNAL( timeout() ), |
733 | this, SLOT( startDrag() ) ); | 733 | this, SLOT( startDrag() ) ); |
734 | #endif | 734 | #endif |
735 | 735 | ||
736 | 736 | ||
737 | formatMore(); | 737 | formatMore(); |
738 | 738 | ||
739 | blinkCursorVisible = FALSE; | 739 | blinkCursorVisible = FALSE; |
740 | 740 | ||
741 | viewport()->setFocusProxy( this ); | 741 | viewport()->setFocusProxy( this ); |
742 | viewport()->setFocusPolicy( WheelFocus ); | 742 | viewport()->setFocusPolicy( WheelFocus ); |
743 | viewport()->installEventFilter( this ); | 743 | viewport()->installEventFilter( this ); |
744 | installEventFilter( this ); | 744 | installEventFilter( this ); |
745 | } | 745 | } |
746 | 746 | ||
747 | void QTextEdit::paintDocument( bool drawAll, QPainter *p, int cx, int cy, int cw, int ch ) | 747 | void QTextEdit::paintDocument( bool drawAll, QPainter *p, int cx, int cy, int cw, int ch ) |
748 | { | 748 | { |
749 | bool drawCur = hasFocus() || viewport()->hasFocus(); | 749 | bool drawCur = hasFocus() || viewport()->hasFocus(); |
750 | if ( hasSelectedText() || isReadOnly() || !cursorVisible ) | 750 | if ( hasSelectedText() || isReadOnly() || !cursorVisible ) |
751 | drawCur = FALSE; | 751 | drawCur = FALSE; |
752 | QColorGroup g = colorGroup(); | 752 | QColorGroup g = colorGroup(); |
753 | if ( doc->paper() ) | 753 | if ( doc->paper() ) |
754 | g.setBrush( QColorGroup::Base, *doc->paper() ); | 754 | g.setBrush( QColorGroup::Base, *doc->paper() ); |
755 | 755 | ||
756 | if ( contentsY() < doc->y() ) { | 756 | if ( contentsY() < doc->y() ) { |
757 | p->fillRect( contentsX(), contentsY(), visibleWidth(), doc->y(), | 757 | p->fillRect( contentsX(), contentsY(), visibleWidth(), doc->y(), |
758 | g.brush( QColorGroup::Base ) ); | 758 | g.brush( QColorGroup::Base ) ); |
759 | } | 759 | } |
760 | if ( drawAll && doc->width() - contentsX() < cx + cw ) { | 760 | if ( drawAll && doc->width() - contentsX() < cx + cw ) { |
761 | p->fillRect( doc->width() - contentsX(), cy, cx + cw - doc->width() + contentsX(), ch, | 761 | p->fillRect( doc->width() - contentsX(), cy, cx + cw - doc->width() + contentsX(), ch, |
762 | g.brush( QColorGroup::Base ) ); | 762 | g.brush( QColorGroup::Base ) ); |
763 | } | 763 | } |
764 | 764 | ||
765 | p->setBrushOrigin( -contentsX(), -contentsY() ); | 765 | p->setBrushOrigin( -contentsX(), -contentsY() ); |
766 | 766 | ||
767 | lastFormatted = doc->draw( p, cx, cy, cw, ch, g, !drawAll, drawCur, cursor ); | 767 | lastFormatted = doc->draw( p, cx, cy, cw, ch, g, !drawAll, drawCur, cursor ); |
768 | 768 | ||
769 | if ( lastFormatted == doc->lastParagraph() ) | 769 | if ( lastFormatted == doc->lastParagraph() ) |
770 | resizeContents( contentsWidth(), doc->height() ); | 770 | resizeContents( contentsWidth(), doc->height() ); |
771 | 771 | ||
772 | if ( contentsHeight() < visibleHeight() && ( !doc->lastParagraph() || doc->lastParagraph()->isValid() ) && drawAll ) | 772 | if ( contentsHeight() < visibleHeight() && ( !doc->lastParagraph() || doc->lastParagraph()->isValid() ) && drawAll ) |
773 | p->fillRect( 0, contentsHeight(), visibleWidth(), | 773 | p->fillRect( 0, contentsHeight(), visibleWidth(), |
774 | visibleHeight() - contentsHeight(), g.brush( QColorGroup::Base ) ); | 774 | visibleHeight() - contentsHeight(), g.brush( QColorGroup::Base ) ); |
775 | } | 775 | } |
776 | 776 | ||
777 | /*! \reimp */ | 777 | /*! \reimp */ |