diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-22 00:30:31 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-22 00:30:31 +0000 |
commit | 69cac65817d949cda2672ec4f0aa73d5e66a0ba1 (patch) | |
tree | 073fde0496ea90eb5bf5cffe66a8da43a9f55fbc /ksirc/kstextview.cpp | |
parent | 3467e6464beac3a162839bf7078e22e3a74d73e7 (diff) | |
download | tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.tar.gz tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.zip |
TQt4 port kdenetwork
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1237912 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksirc/kstextview.cpp')
-rw-r--r-- | ksirc/kstextview.cpp | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/ksirc/kstextview.cpp b/ksirc/kstextview.cpp index 2589e59a..8b2e5e45 100644 --- a/ksirc/kstextview.cpp +++ b/ksirc/kstextview.cpp @@ -57,12 +57,12 @@ TQPixmap ksTextViewLoadPixmap( const TQString &icon ) qAddPostRoutine( cleanupKSTextViewPixmapDict ); } - TQPixmap *pix = ksTextViewPixmapDict->find( icon ); + TQPixmap *pix = ksTextViewPixmapDict->tqfind( icon ); if ( !pix ) { TQImage img; - const TQMimeSource *src = kapp->mimeSourceFactory()->data( icon, TQString::null ); + const TQMimeSource *src = kapp->mimeSourceFactory()->data( icon, TQString() ); if ( !src || !TQImageDrag::decode( src, img ) || img.isNull() ) return TQPixmap(); @@ -245,7 +245,7 @@ Item *TextChunk::breakLine( int width ) return 0; } -Item::LayoutResetStatus TextChunk::resetLayout() +Item::LayoutResettqStatus TextChunk::resetLayout() { if ( m_originalTextLength == 0 ) @@ -376,12 +376,12 @@ Item *TextChunk::hardBreak( const StringPtr &rightHandSide ) selStart->offset -= m_text.len; selEnd->offset -= m_text.len; selStart->item = selEnd->item = chunk; - chunk->setSelectionStatus( m_selection ); + chunk->setSelectiontqStatus( m_selection ); m_selection = NoSelection; } else if ( selEnd->offset >= m_text.len ) { selEnd->offset -= m_text.len; selEnd->item = chunk; - chunk->setSelectionStatus( SelectionEnd ); + chunk->setSelectiontqStatus( SelectionEnd ); m_selection = SelectionStart; } } @@ -389,7 +389,7 @@ Item *TextChunk::hardBreak( const StringPtr &rightHandSide ) if ( selection && selection->offset >= m_text.len ) { selection->offset -= m_text.len; selection->item = chunk; - chunk->setSelectionStatus( m_selection ); + chunk->setSelectiontqStatus( m_selection ); m_selection = NoSelection; } @@ -433,7 +433,7 @@ int TextChunk::paintSelection( TQPainter &p, int x, const StringPtr &text ) const int width = m_metrics.width( str ); - const TQColorGroup &cg = m_parag->textView()->colorGroup(); + const TQColorGroup &cg = m_parag->textView()->tqcolorGroup(); if (m_props.bgSelColor.isValid()) p.fillRect( x, 0, width, height(), m_props.bgSelColor ); @@ -475,18 +475,18 @@ void TextChunk::mergeSelection( TextChunk *child, SelectionPoint *selection ) selection->offset += child->m_text.ptr - m_text.ptr; if(selection->offset > m_originalTextLength){ - kdDebug(5008) << "Child: " << child->m_text.toQString() << " Parent: " << m_text.toQString() << endl; + kdDebug(5008) << "Child: " << child->m_text.toTQString() << " Parent: " << m_text.toTQString() << endl; kdDebug(5008) << "Length all wrong!" << endl; //assert(0); } selection->item = this; - if ( ( m_selection == SelectionStart && child->selectionStatus() == SelectionEnd ) || - ( m_selection == SelectionEnd && child->selectionStatus() == SelectionStart ) ) + if ( ( m_selection == SelectionStart && child->selectiontqStatus() == SelectionEnd ) || + ( m_selection == SelectionEnd && child->selectiontqStatus() == SelectionStart ) ) m_selection = SelectionBoth; else - m_selection = child->selectionStatus(); + m_selection = child->selectiontqStatus(); } ImageItem::ImageItem( TextParag *parag, const TQPixmap &pixmap ) @@ -512,7 +512,7 @@ void ImageItem::paint( TQPainter &painter ) if (m_props.bgSelColor.isValid()) painter.fillRect( 0, 0, width(), h, m_props.bgSelColor ); else { - const TQColorGroup &cg = m_parag->textView()->colorGroup(); + const TQColorGroup &cg = m_parag->textView()->tqcolorGroup(); painter.fillRect( 0, 0, width(), h, cg.highlight() ); } } @@ -520,7 +520,7 @@ void ImageItem::paint( TQPainter &painter ) painter.drawPixmap( 0, y, m_pixmap ); } -Item::LayoutResetStatus ImageItem::resetLayout() +Item::LayoutResettqStatus ImageItem::resetLayout() { // nothin' to do return KeepItem; @@ -586,22 +586,22 @@ TQString Tokenizer::convertToRichText( const PString &ptext ) { TQString entity = KGlobal::charsets()->toEntity( ch ); indexAdjustment = entity.length() - 1; - result.replace( i, 1, entity ); + result.tqreplace( i, 1, entity ); } */ if ( ch == '<' ) { - result.replace( i, 1, "<" ); + result.tqreplace( i, 1, "<" ); indexAdjustment = 3; } else if ( ch == '>' ) { - result.replace( i, 1, ">" ); + result.tqreplace( i, 1, ">" ); indexAdjustment = 3; } else if ( ch == '&' ) { - result.replace( i, 1, "&" ); + result.tqreplace( i, 1, "&" ); indexAdjustment = 4; } @@ -645,7 +645,7 @@ bool Tokenizer::parseNextToken( Token &tok ) return false; tok.id = Token::Text; - tok.value = StringPtr( m_text.unicode() + idx, + tok.value = StringPtr( m_text.tqunicode() + idx, m_text.length() - idx ); tok.attributes.clear(); return true; @@ -658,7 +658,7 @@ bool Tokenizer::parseNextToken( Token &tok ) { tok.id = Token::Text; tok.attributes.clear(); - tok.value = StringPtr( m_text.unicode(), + tok.value = StringPtr( m_text.tqunicode(), (*m_lastTag).index ); m_textBeforeFirstTagProcessed = true; @@ -676,7 +676,7 @@ bool Tokenizer::parseNextToken( Token &tok ) if ( lastType == TagIndex::Open && type == TagIndex::Close ) { - const TQChar *tagStart = m_text.unicode() + lastIndex + 1; + const TQChar *tagStart = m_text.tqunicode() + lastIndex + 1; uint tagLen = ( index - 1 ) - ( lastIndex + 1 ) + 1; // </bleh> ? if ( *tagStart == '/' ) @@ -699,7 +699,7 @@ bool Tokenizer::parseNextToken( Token &tok ) { tok.id = Token::Text; tok.attributes.clear(); - tok.value = StringPtr( m_text.unicode() + lastIndex + 1, + tok.value = StringPtr( m_text.tqunicode() + lastIndex + 1, ( index - 1 ) - lastIndex ); m_lastTag = it; @@ -715,7 +715,7 @@ bool Tokenizer::parseNextToken( Token &tok ) Tokenizer::TagIndexList Tokenizer::scanTagIndices( const TQString &text ) { - const TQChar *start = text.unicode(); + const TQChar *start = text.tqunicode(); const TQChar *p = start; const TQChar *endP = p + text.length(); bool quoted = false; @@ -754,7 +754,7 @@ Tokenizer::TagIndexList Tokenizer::scanTagIndices( const TQString &text ) void Tokenizer::resolveEntities( TQString &text, TagIndexList &tags ) { - const TQChar *p = text.unicode(); + const TQChar *p = text.tqunicode(); const TQChar *endP = p + text.length(); uint i = 0; bool scanForSemicolon = false; @@ -793,13 +793,13 @@ void Tokenizer::resolveEntities( TQString &text, TagIndexList &tags ) if ( entityValue.isNull() ) continue; - const uint ampersandPos = ampersand - text.unicode(); + const uint ampersandPos = ampersand - text.tqunicode(); text[ ampersandPos ] = entityValue; text.remove( ampersandPos + 1, entityLength + 1 ); i = ampersandPos; - p = text.unicode() + i; - endP = text.unicode() + text.length(); + p = text.tqunicode() + i; + endP = text.tqunicode() + text.length(); ampersand = 0; uint adjustment = entityLength + 1; @@ -921,11 +921,11 @@ void Tokenizer::parseTag( const StringPtr &text, } /* - kdDebug(5008) << "tagName: " << tag.toQString() << endl; + kdDebug(5008) << "tagName: " << tag.toTQString() << endl; AttributeMap::ConstIterator it = attributes.begin(); for (; it != attributes.end(); ++it ) - kdDebug(5008) << "attribute: " << it.key().toQString() << - " -> " << it.data().toQString() << endl; + kdDebug(5008) << "attribute: " << it.key().toTQString() << + " -> " << it.data().toTQString() << endl; */ } @@ -1052,11 +1052,11 @@ TQString TextLine::updateSelection( const SelectionPoint &start, const Selection // fixes a crash where because of an empty list i becomes null if ( m_items.isEmpty() ) - return TQString::null; + return TQString(); if ( start.line == this ) { - const int idx = m_items.findRef( start.item ); + const int idx = m_items.tqfindRef( start.item ); assert( idx != -1 ); } else @@ -1070,7 +1070,7 @@ TQString TextLine::updateSelection( const SelectionPoint &start, const Selection { const int oldCurrent = m_items.at(); - const int idx = m_items.findRef( end.item ); + const int idx = m_items.tqfindRef( end.item ); assert( idx != -1 ); lastItem = m_items.next(); @@ -1081,7 +1081,7 @@ TQString TextLine::updateSelection( const SelectionPoint &start, const Selection { if ( i == start.item ) { - i->setSelectionStatus( Item::SelectionStart ); + i->setSelectiontqStatus( Item::SelectionStart ); StringPtr txt = i->text(); if ( !txt.isNull() ) @@ -1090,7 +1090,7 @@ TQString TextLine::updateSelection( const SelectionPoint &start, const Selection } else if ( i == end.item ) { - i->setSelectionStatus( Item::SelectionEnd ); + i->setSelectiontqStatus( Item::SelectionEnd ); StringPtr txt = i->text(); if ( !txt.isNull() ) @@ -1098,9 +1098,9 @@ TQString TextLine::updateSelection( const SelectionPoint &start, const Selection } else { - i->setSelectionStatus( Item::InSelection ); + i->setSelectiontqStatus( Item::InSelection ); - selectedText += i->text().toQString(); + selectedText += i->text().toTQString(); } } @@ -1111,15 +1111,15 @@ void TextLine::clearSelection() { Item *i = m_items.first(); for (; i; i = m_items.next() ) - i->setSelectionStatus( Item::NoSelection ); + i->setSelectiontqStatus( Item::NoSelection ); } -void TextLine::appendItem( Item *i, int layoutUpdatePolicy ) +void TextLine::appendItem( Item *i, int tqlayoutUpdatePolicy ) { m_items.append( i ); i->setLine(this); - if ( layoutUpdatePolicy == UpdateMaxHeight ) + if ( tqlayoutUpdatePolicy == UpdateMaxHeight ) m_maxHeight = kMax( m_maxHeight, i->height() ); } @@ -1198,7 +1198,7 @@ TQString TextLine::plainText() const TQString res; TQPtrListIterator<Item> it( m_items ); for (; it.current(); ++it ) - res += it.current()->text().toQString(); + res += it.current()->text().toTQString(); return res; } @@ -1225,7 +1225,7 @@ TextParag::~TextParag() { } -void TextParag::layout( int width ) +void TextParag::tqlayout( int width ) { TQPtrList<Item> items; @@ -1381,11 +1381,11 @@ TQString TextParag::updateSelection( const SelectionPoint &start, const Selectio // sanity check // (don't put it lower because it changes the current list item) if ( end.parag == this ) - assert( m_lines.findRef( end.line ) != -1 ); + assert( m_lines.tqfindRef( end.line ) != -1 ); if ( start.parag == this ) { - int idx = m_lines.findRef( start.line ); + int idx = m_lines.tqfindRef( start.line ); assert( idx != -1 ); } else @@ -1471,7 +1471,7 @@ void TextParag::setRichText( const TQString &richText ) Tag tag = tagStack.pop(); if( !( tok.value == tag.name ) ) { - kdDebug(5008) << "ASSERT failed! tok.value=" << tok.value.toQString() << " tag.name=" << tag.name.toQString() << endl; + kdDebug(5008) << "ASSERT failed! tok.value=" << tok.value.toTQString() << " tag.name=" << tag.name.toTQString() << endl; kdDebug(5008) << "while parsing " << richText << endl; } @@ -1613,12 +1613,12 @@ void ContentsPaintAlgorithm::paint() } } -TextView::TextView( TQWidget *parent, const char *name ) - : TQScrollView( parent, name, WRepaintNoErase ), +TextView::TextView( TQWidget *tqparent, const char *name ) + : TQScrollView( tqparent, name, WRepaintNoErase ), m_paintBuffer( PaintBufferExtend, PaintBufferExtend ), m_selectionEndBeforeStart( false ), m_mousePressed( false ), m_mmbPressed( false ), - m_linkColor( Qt::blue ), m_height(-1), m_inScroll(false), + m_linkColor( TQt::blue ), m_height(-1), m_inScroll(false), m_lastScroll(0) { m_parags.setAutoDelete( true ); @@ -1658,7 +1658,7 @@ void TextView::viewportResizeEvent( TQResizeEvent *ev ) TQScrollView::viewportResizeEvent(ev); if ( ev->size().width() != ev->oldSize().width() ) - layout(); + tqlayout(); int newdiff = ev->size().height() - ev->oldSize().height(); setContentsPos( 0, contentsY()-newdiff ); @@ -1720,7 +1720,7 @@ void TextView::clear() stopAutoScroll(); clearSelection(); m_parags.clear(); - layout(); + tqlayout(); viewport()->erase(); } @@ -1728,7 +1728,7 @@ TextParagIterator TextView::appendParag( const TQString &richText ) { TextParag *parag = new TextParag( this, richText ); m_parags.append( parag ); - layout( false ); + tqlayout( false ); scrollToBottom(); TQPtrListIterator<TextParag> it( m_parags ); it.toLast(); @@ -1742,7 +1742,7 @@ bool TextView::removeParag( const TextParagIterator ¶g ) return false; TextParag *paragPtr = parag.m_paragIt.current(); - const int idx = m_parags.findRef( paragPtr ); + const int idx = m_parags.tqfindRef( paragPtr ); if ( idx == -1 ) return false; @@ -1758,7 +1758,7 @@ bool TextView::removeParag( const TextParagIterator ¶g ) if(m_selectionEnd.item != 0) m_selectionEnd.pos.ry() -= height; - //layout( false ); + //tqlayout( false ); contentsChange(-height, true); @@ -1768,14 +1768,14 @@ bool TextView::removeParag( const TextParagIterator ¶g ) return true; } -void TextView::clearSelection( bool repaint ) +void TextView::clearSelection( bool tqrepaint ) { m_selectionStart = SelectionPoint(); m_selectionEnd = SelectionPoint(); m_selectionEndBeforeStart = false; - m_selectedText = TQString::null; + m_selectedText = TQString(); clearSelectionInternal(); - if ( repaint ) + if ( tqrepaint ) updateContents(); } @@ -1787,7 +1787,7 @@ TextParagIterator TextView::firstParag() const TQString TextView::plainText() const { if ( m_parags.isEmpty() ) - return TQString::null; + return TQString(); TQString result; TQPtrListIterator<TextParag> paragIt( m_parags ); @@ -1814,7 +1814,7 @@ void TextView::setLinkColor( const TQColor &linkColor ) void TextView::copy() { - TQApplication::clipboard()->setText( m_selectedText ); + TQApplication::tqclipboard()->setText( m_selectedText ); } void TextView::clearSelectionInternal() @@ -1827,27 +1827,27 @@ void TextView::clearSelectionInternal() void TextView::contentsMousePressEvent( TQMouseEvent *ev ) { - if ( ev->button() & RightButton ) { + if ( ev->button() & Qt::RightButton ) { emitLinkClickedForMouseEvent( ev ); return; } - if ( !( ev->button() & LeftButton ) && !(ev->button() & MidButton ) ) + if ( !( ev->button() & Qt::LeftButton ) && !(ev->button() & Qt::MidButton ) ) return; clearSelection( true ); SelectionPoint p; Item *itemUnderMouse = itemAt( ev->pos(), &p, Item::SelectFuzzy ); - if ( p.item && ( ev->button() & LeftButton ) ) { + if ( p.item && ( ev->button() & Qt::LeftButton ) ) { m_selectionMaybeStart = p; - p.item->setSelectionStatus( Item::NoSelection ); + p.item->setSelectiontqStatus( Item::NoSelection ); } if ( TextChunk *text = dynamic_cast<TextChunk *>( itemUnderMouse ) ) { StringPtr href = text->props().attributes[ "href" ]; if ( !href.isNull() ) { m_dragStartPos = ev->pos(); - m_dragURL = href.toQString(); - if ( ev->button() & LeftButton ) + m_dragURL = href.toTQString(); + if ( ev->button() & Qt::LeftButton ) m_mousePressed = true; else m_mmbPressed = true; @@ -1857,7 +1857,7 @@ void TextView::contentsMousePressEvent( TQMouseEvent *ev ) void TextView::contentsMouseMoveEvent( TQMouseEvent *ev ) { - if ( m_mousePressed && ev->state() == NoButton ) + if ( m_mousePressed && ev->state() == Qt::NoButton ) { m_mousePressed = false; m_mmbPressed = false; @@ -1871,7 +1871,7 @@ void TextView::contentsMouseMoveEvent( TQMouseEvent *ev ) startDrag(); - m_dragURL = TQString::null; + m_dragURL = TQString(); return; } @@ -1881,8 +1881,8 @@ void TextView::contentsMouseMoveEvent( TQMouseEvent *ev ) if ( !i && !p.item ) return; - if ( (ev->state() & LeftButton && m_selectionStart.item && p.item) || - (ev->state() & LeftButton && m_selectionMaybeStart.item && p.item)) + if ( (ev->state() & Qt::LeftButton && m_selectionStart.item && p.item) || + (ev->state() & Qt::LeftButton && m_selectionMaybeStart.item && p.item)) { if(m_selectionMaybeStart.item != 0){ @@ -1904,10 +1904,10 @@ void TextView::contentsMouseMoveEvent( TQMouseEvent *ev ) if ( start.item == end.item ) { if ( start.offset > end.offset ) - qSwap( start.offset, end.offset ); + tqSwap( start.offset, end.offset ); } else - qSwap( start, end ); + tqSwap( start, end ); } m_selectedText = updateSelection( start, end ); @@ -1948,12 +1948,12 @@ void TextView::contentsMouseReleaseEvent( TQMouseEvent *ev ) m_mousePressed = false; m_mmbPressed = false; m_dragStartPos = TQPoint(); - m_dragURL = TQString::null; + m_dragURL = TQString(); m_selectionMaybeStart = SelectionPoint(); if ( (ev->button() & Qt::LeftButton) && !m_selectedText.isEmpty() ) - TQApplication::clipboard()->setText( m_selectedText, QClipboard::Selection ); + TQApplication::tqclipboard()->setText( m_selectedText, TQClipboard::Selection ); if ( clicked ) { emitLinkClickedForMouseEvent( ev ); @@ -1962,7 +1962,7 @@ void TextView::contentsMouseReleaseEvent( TQMouseEvent *ev ) if (ev->button() & Qt::MidButton) { - emit pasteReq( KApplication::clipboard()->text( QClipboard::Selection ) ); + emit pasteReq( KApplication::tqclipboard()->text( TQClipboard::Selection ) ); return; } } @@ -1973,7 +1973,7 @@ void TextView::fontChange( const TQFont & ) for (; it.current(); ++it ) it.current()->fontChange( font() ); - layout( true ); + tqlayout( true ); } void TextView::startDrag() @@ -2057,7 +2057,7 @@ void TextView::selectionOffsets( int &startOffset, int &endOffset ) } if ( m_selectionStart.item == m_selectionEnd.item && startOffset > endOffset ) - qSwap( startOffset, endOffset ); + tqSwap( startOffset, endOffset ); } void TextView::updateSelectionOrder() @@ -2103,11 +2103,11 @@ TQString TextView::updateSelection( const SelectionPoint &start, const Selection { if ( start.pos.x() == end.pos.x() ) { - i->setSelectionStatus( Item::NoSelection ); - return TQString::null; + i->setSelectiontqStatus( Item::NoSelection ); + return TQString(); } - i->setSelectionStatus( Item::SelectionBoth ); + i->setSelectiontqStatus( Item::SelectionBoth ); // ### ugly const TextChunk *t = dynamic_cast<TextChunk *>( i ); @@ -2119,7 +2119,7 @@ TQString TextView::updateSelection( const SelectionPoint &start, const Selection } else { - i->setSelectionStatus( Item::SelectionBoth ); + i->setSelectiontqStatus( Item::SelectionBoth ); // ### ugly TextChunk *t = dynamic_cast<TextChunk *>( i ); @@ -2138,8 +2138,8 @@ TQString TextView::updateSelection( const SelectionPoint &start, const Selection } else { - assert( m_parags.findRef( end.parag ) != -1 ); - const int idx = m_parags.findRef( start.parag ); + assert( m_parags.tqfindRef( end.parag ) != -1 ); + const int idx = m_parags.tqfindRef( start.parag ); assert( idx != -1 ); TextParag *p = m_parags.current(); @@ -2156,7 +2156,7 @@ TQString TextView::updateSelection( const SelectionPoint &start, const Selection return selectedText; } -void TextView::layout( bool force ) +void TextView::tqlayout( bool force ) { int height = 0; int contentsWidth = visibleWidth(); @@ -2166,7 +2166,7 @@ void TextView::layout( bool force ) for (; it.current(); ++it ) { if ( !it.current()->isLayouted() || force ) - it.current()->layout( width ); + it.current()->tqlayout( width ); height += it.current()->height(); contentsWidth = kMax( contentsWidth, it.current()->minWidth() ); @@ -2182,7 +2182,7 @@ void TextView::layout( bool force ) void TextView::contentsChange(int heightChange, bool force) { if(m_height == -1){ - layout(force); + tqlayout(force); } else { m_height += heightChange; @@ -2235,7 +2235,7 @@ Item *TextView::itemAt( const TQPoint &pos, SelectionPoint *selectionInfo, TQString TextParagIterator::richText() const { if ( atEnd() ) - return TQString::null; + return TQString(); return Tokenizer::convertToRichText( m_paragIt.current()->processedRichText() ); } @@ -2248,7 +2248,7 @@ void TextParagIterator::setRichText( const TQString &richText ) m_paragIt.current()->setRichText( richText ); TextView *textView = m_paragIt.current()->textView(); - textView->layout( false ); + textView->tqlayout( false ); if ( textView->isUpdatesEnabled() ) textView->updateContents(); @@ -2257,7 +2257,7 @@ void TextParagIterator::setRichText( const TQString &richText ) TQString TextParagIterator::plainText() const { if ( atEnd() ) - return TQString::null; + return TQString(); return m_paragIt.current()->plainText(); } |