diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /ksirc/kstextview.h | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksirc/kstextview.h')
-rw-r--r-- | ksirc/kstextview.h | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/ksirc/kstextview.h b/ksirc/kstextview.h index 27a63eb5..4f9d59f4 100644 --- a/ksirc/kstextview.h +++ b/ksirc/kstextview.h @@ -19,12 +19,12 @@ #ifndef __kstextview_h__ #define __kstextview_h__ -#include <qscrollview.h> -#include <qpen.h> -#include <qptrlist.h> -#include <qvaluelist.h> -#include <qmap.h> -#include <qpixmap.h> +#include <tqscrollview.h> +#include <tqpen.h> +#include <tqptrlist.h> +#include <tqvaluelist.h> +#include <tqmap.h> +#include <tqpixmap.h> class QTimer; class QDragObject; @@ -37,22 +37,22 @@ class TextView; struct StringPtr { StringPtr() : ptr( 0 ), len( 0 ) {} - StringPtr( const QChar *_ptr, uint _len ) + StringPtr( const TQChar *_ptr, uint _len ) : ptr( _ptr ), len( _len ) {} - explicit StringPtr( const QString &s ) // use with care! + explicit StringPtr( const TQString &s ) // use with care! : ptr( s.unicode() ), len( s.length() ) {} inline bool isNull() const { return ptr == 0; } // makes deep copy - inline QString toQString() const - { return ( ptr && len > 0 ) ? QString( ptr, len ) : QString::null; } + inline TQString toQString() const + { return ( ptr && len > 0 ) ? TQString( ptr, len ) : TQString::null; } - const QChar *ptr; + const TQChar *ptr; uint len; }; -#define CONSTSTRING( substr ) QConstString( substr.ptr, substr.len ).string() +#define CONSTSTRING( substr ) TQConstString( substr.ptr, substr.len ).string() inline bool operator<( const StringPtr &s1, const StringPtr &s2 ) { @@ -69,23 +69,23 @@ inline bool operator==( const StringPtr &s1, const char *s2 ) return CONSTSTRING( s1 ) == s2; } -class AttributeMap : public QMap<StringPtr, StringPtr> +class AttributeMap : public TQMap<StringPtr, StringPtr> { public: AttributeMap() {} - AttributeMap( const AttributeMap &rhs ) : QMap<StringPtr, StringPtr>( rhs ) {} + AttributeMap( const AttributeMap &rhs ) : TQMap<StringPtr, StringPtr>( rhs ) {} AttributeMap &operator=( const AttributeMap &rhs ) - { QMap<StringPtr, StringPtr>::operator=( rhs ); return *this; } + { TQMap<StringPtr, StringPtr>::operator=( rhs ); return *this; } // helper for 'const char *' key... ConstIterator findAttribute( const char *key ) const { - QString qkey( key ); + TQString qkey( key ); return find( StringPtr( qkey ) ); } Iterator findAttribute( const char *key ) { - QString qkey( key ); + TQString qkey( key ); return find( StringPtr( qkey ) ); } @@ -98,7 +98,7 @@ public: } StringPtr &operator[]( const StringPtr &key ) { - return QMap<StringPtr, StringPtr>::operator[]( key ); + return TQMap<StringPtr, StringPtr>::operator[]( key ); } }; @@ -115,21 +115,21 @@ struct Token struct ItemProperties { ItemProperties(); - ItemProperties( const QFont &defaultFont ); + ItemProperties( const TQFont &defaultFont ); ItemProperties( const ItemProperties &other, const Token &token, TextView *textView ); ItemProperties( const ItemProperties &rhs ); ItemProperties &operator=( const ItemProperties &rhs ); - void updateFont( const QFont &newFont ); + void updateFont( const TQFont &newFont ); // these three are inherited/merged - QFont font; - QColor color; - QColor selColor; - QColor bgColor; - QColor bgSelColor; + TQFont font; + TQColor color; + TQColor selColor; + TQColor bgColor; + TQColor bgSelColor; bool reversed; // ### todo: inherit these, too AttributeMap attributes; @@ -153,7 +153,7 @@ public: virtual const char *type() { return "Item"; } - virtual void paint( QPainter &painter ) = 0; + virtual void paint( TQPainter &painter ) = 0; int width() const; @@ -207,7 +207,7 @@ public: virtual const char *type() { return "TextChunk"; } - virtual void paint( QPainter &painter ); + virtual void paint( TQPainter &painter ); virtual Item *breakLine( int width ); @@ -226,26 +226,26 @@ private: StringPtr breakInTheMiddle( int width ); Item *hardBreak( const StringPtr &rightHandSide ); - void paintSelection( QPainter &p ); - int paintSelection( QPainter &p, int x, const StringPtr &text ); - int paintText( QPainter &p, int x, const StringPtr &text ); + void paintSelection( TQPainter &p ); + int paintSelection( TQPainter &p, int x, const StringPtr &text ); + int paintText( TQPainter &p, int x, const StringPtr &text ); void mergeSelection( TextChunk *child, SelectionPoint *selection ); StringPtr m_text; uint m_originalTextLength; - QFontMetrics m_metrics; + TQFontMetrics m_metrics; class TextChunk *m_parent; }; class ImageItem : public Item { public: - ImageItem( TextParag *parag, const QPixmap &pixmap ); + ImageItem( TextParag *parag, const TQPixmap &pixmap ); virtual const char *type() { return "Image"; } - virtual void paint( QPainter &painter ); + virtual void paint( TQPainter &painter ); virtual LayoutResetStatus resetLayout(); @@ -253,7 +253,7 @@ protected: virtual void calcExtends() const; private: - QPixmap m_pixmap; + TQPixmap m_pixmap; }; class Tokenizer @@ -268,20 +268,20 @@ public: uint index; int type; }; - typedef QValueList<TagIndex> TagIndexList; + typedef TQValueList<TagIndex> TagIndexList; // preprocessed string struct PString { - QString data; + TQString data; TagIndexList tags; }; Tokenizer( PString &text ); - static PString preprocess( const QString &richText ); + static PString preprocess( const TQString &richText ); - static QString convertToRichText( const PString &ptext ); + static TQString convertToRichText( const PString &ptext ); bool parseNextToken( Token &tok ); @@ -290,12 +290,12 @@ private: StringPtr &tag, AttributeMap &attributes ); - static TagIndexList scanTagIndices( const QString &text ); - static void resolveEntities( QString &text, TagIndexList &tags ); + static TagIndexList scanTagIndices( const TQString &text ); + static void resolveEntities( TQString &text, TagIndexList &tags ); enum TagParsingState { ScanForName, ScanForEqual, ScanForValue }; - QString &m_text; + TQString &m_text; TagIndexList m_tags; TagIndexList::ConstIterator m_lastTag; bool m_textBeforeFirstTagProcessed; @@ -315,11 +315,11 @@ public: TextLine(); // tranfers ownership of items! make sure that 'items' does not // have autodeletion enabled! - TextLine( const QPtrList<Item> &items ); + TextLine( const TQPtrList<Item> &items ); int maxHeight() const { return m_maxHeight; } - QString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); + TQString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); void clearSelection(); // transfers ownership @@ -327,21 +327,21 @@ public: bool isEmpty() const { return m_items.isEmpty(); } - Item *resetLayout( QPtrList<Item> &remainingItems); + Item *resetLayout( TQPtrList<Item> &remainingItems); - void paint( QPainter &p, int y ); + void paint( TQPainter &p, int y ); Item *itemAt( int px, SelectionPoint *selectionInfo, Item::SelectionAccuracy accuracy = Item::SelectExact ); - QPtrListIterator<Item> iterator() const { return QPtrListIterator<Item>( m_items ); } + TQPtrListIterator<Item> iterator() const { return TQPtrListIterator<Item>( m_items ); } - QString plainText() const; + TQString plainText() const; - void fontChange( const QFont &newFont ); + void fontChange( const TQFont &newFont ); private: - QPtrList<Item> m_items; + TQPtrList<Item> m_items; int m_maxHeight; }; @@ -350,13 +350,13 @@ class SelectionPoint; class TextParag { public: - TextParag( TextView *textView, const QString &richText ); + TextParag( TextView *textView, const TQString &richText ); ~TextParag(); void layout( int width ); - void paint( QPainter &p, int y, int maxY ); + void paint( TQPainter &p, int y, int maxY ); inline void setLayouted( bool l ) { m_layouted = l; } inline bool isLayouted() const { return m_layouted; } @@ -369,21 +369,21 @@ public: TextView *textView() const { return m_textView; } - QString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); + TQString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); void clearSelection(); - void setRichText( const QString &richText ); + void setRichText( const TQString &richText ); Tokenizer::PString processedRichText() const { return m_processedRichText; } - QString plainText() const; + TQString plainText() const; - void fontChange( const QFont &newFont ); + void fontChange( const TQFont &newFont ); private: Tokenizer::PString m_processedRichText; - QPtrList<TextLine> m_lines; + TQPtrList<TextLine> m_lines; bool m_layouted; int m_height; int m_minWidth; @@ -410,7 +410,7 @@ struct SelectionPoint TextLine *line; TextParag *parag; uint offset; - QPoint pos; + TQPoint pos; }; class TextParagIterator @@ -422,10 +422,10 @@ public: TextParagIterator &operator=( const TextParagIterator &rhs ) { m_paragIt = rhs.m_paragIt; return *this; } - QString richText() const; - void setRichText( const QString &richText ); + TQString richText() const; + void setRichText( const TQString &richText ); - QString plainText() const; + TQString plainText() const; bool atEnd() const { return m_paragIt.current() == 0; } @@ -435,31 +435,31 @@ public: TextParagIterator &operator--( int steps ) { m_paragIt -= steps; return *this; } protected: - TextParagIterator( const QPtrListIterator<TextParag> ¶gIt ) + TextParagIterator( const TQPtrListIterator<TextParag> ¶gIt ) : m_paragIt( paragIt ) {} private: - QPtrListIterator<TextParag> m_paragIt; + TQPtrListIterator<TextParag> m_paragIt; }; class ContentsPaintAlgorithm { public: - ContentsPaintAlgorithm( const QPtrListIterator<TextParag> ¶gIt, - QWidget *viewport, QPixmap &paintBuffer, - QPainter &painter, int clipX, int clipY, int clipHeight ); + ContentsPaintAlgorithm( const TQPtrListIterator<TextParag> ¶gIt, + TQWidget *viewport, TQPixmap &paintBuffer, + TQPainter &painter, int clipX, int clipY, int clipHeight ); void paint(); private: int goToFirstVisibleParagraph(); - int paint( QPainter &bufferedPainter, int currentY ); + int paint( TQPainter &bufferedPainter, int currentY ); int adjustYAndIterator( int startY, int currentY, int nextY ); - QPtrListIterator<TextParag> m_paragIt; - QWidget *m_viewport; - QPixmap &m_paintBuffer; - QPainter &m_painter; + TQPtrListIterator<TextParag> m_paragIt; + TQWidget *m_viewport; + TQPixmap &m_paintBuffer; + TQPainter &m_painter; int m_clipX, m_clipY, m_clipHeight; int m_overshoot; }; @@ -472,32 +472,32 @@ class TextView : public QScrollView friend class TextParag; friend class TextParagIterator; public: - TextView( QWidget *parent, const char *name = 0 ); + TextView( TQWidget *parent, const char *name = 0 ); virtual ~TextView(); virtual void clear(); - TextParagIterator appendParag( const QString &richText ); + TextParagIterator appendParag( const TQString &richText ); bool removeParag( const TextParagIterator ¶g ); void clearSelection( bool repaint = false ); // ### re-consider the repaint arg... - QString selectedText() const { return m_selectedText; } + TQString selectedText() const { return m_selectedText; } TextParagIterator firstParag() const; - QString plainText() const; + TQString plainText() const; - QColor linkColor() const; - void setLinkColor( const QColor &linkColor ); + TQColor linkColor() const; + void setLinkColor( const TQColor &linkColor ); void scrollToBottom( bool force = false ); signals: void selectionChanged(); - void pasteReq(const QString&); - void linkClicked( const QMouseEvent *ev, const QString &url ); + void pasteReq(const TQString&); + void linkClicked( const TQMouseEvent *ev, const TQString &url ); public slots: void copy(); @@ -506,22 +506,22 @@ protected slots: void scrolling(int value); protected: - virtual void viewportResizeEvent( QResizeEvent *ev ); - virtual void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); - virtual void contentsMousePressEvent( QMouseEvent *ev ); - virtual void contentsMouseMoveEvent( QMouseEvent *ev ); - virtual void contentsMouseReleaseEvent( QMouseEvent *ev ); - virtual void fontChange( const QFont & ); + virtual void viewportResizeEvent( TQResizeEvent *ev ); + virtual void drawContents( TQPainter *p, int cx, int cy, int cw, int ch ); + virtual void contentsMousePressEvent( TQMouseEvent *ev ); + virtual void contentsMouseMoveEvent( TQMouseEvent *ev ); + virtual void contentsMouseReleaseEvent( TQMouseEvent *ev ); + virtual void fontChange( const TQFont & ); virtual void startDrag(); - virtual QDragObject *dragObject( const QString &dragURL ); + virtual TQDragObject *dragObject( const TQString &dragURL ); private slots: void autoScroll(); private: - void emitLinkClickedForMouseEvent( QMouseEvent *ev ); + void emitLinkClickedForMouseEvent( TQMouseEvent *ev ); void startAutoScroll(); @@ -531,38 +531,38 @@ private: void updateSelectionOrder(); - QString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); + TQString updateSelection( const SelectionPoint &start, const SelectionPoint &end ); SelectionPoint *selectionStart(); SelectionPoint *selectionEnd(); void layout( bool force = true ); - Item *itemAt( const QPoint &pos, SelectionPoint *selectionInfo = 0, + Item *itemAt( const TQPoint &pos, SelectionPoint *selectionInfo = 0, Item::SelectionAccuracy accuracy = Item::SelectExact ); void clearSelectionInternal(); void contentsChange(int heightChange, bool force = false); - QPtrList<TextParag> m_parags; - QPixmap m_paintBuffer; + TQPtrList<TextParag> m_parags; + TQPixmap m_paintBuffer; SelectionPoint m_selectionMaybeStart; SelectionPoint m_selectionStart; SelectionPoint m_selectionEnd; bool m_selectionEndBeforeStart; - QTimer *m_autoScrollTimer; + TQTimer *m_autoScrollTimer; - QString m_selectedText; + TQString m_selectedText; - QPoint m_dragStartPos; - QString m_dragURL; + TQPoint m_dragStartPos; + TQString m_dragURL; bool m_mousePressed : 1; bool m_mmbPressed : 1; - QColor m_linkColor; - QColor m_selectionBackgroundColor; + TQColor m_linkColor; + TQColor m_selectionBackgroundColor; int m_height; bool m_inScroll; |