diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:52:55 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:52:55 +0000 |
commit | 5f5ee2367157176ed223b86343eb0a9e4022e020 (patch) | |
tree | 6a9c87f14ee38e90eff3c77c784f14e4f38fd5a1 /kregexpeditor/qtregexpconverter.cpp | |
parent | 4facf42feec57b22dcf46badc115ad6c5b5cc512 (diff) | |
download | tdeutils-5f5ee2367157176ed223b86343eb0a9e4022e020.tar.gz tdeutils-5f5ee2367157176ed223b86343eb0a9e4022e020.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1157653 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kregexpeditor/qtregexpconverter.cpp')
-rw-r--r-- | kregexpeditor/qtregexpconverter.cpp | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/kregexpeditor/qtregexpconverter.cpp b/kregexpeditor/qtregexpconverter.cpp index 198d7dd..6098097 100644 --- a/kregexpeditor/qtregexpconverter.cpp +++ b/kregexpeditor/qtregexpconverter.cpp @@ -29,7 +29,7 @@ #include "positionregexp.h" #include "repeatregexp.h" -extern RegExp* parseQtRegExp( QString str, bool *ok ); +extern RegExp* parseQtRegExp( TQString str, bool *ok ); extern RegExp* parseDataQtRegExp(); bool QtRegExpConverter::canParse() @@ -38,24 +38,24 @@ bool QtRegExpConverter::canParse() } -RegExp* QtRegExpConverter::parse( const QString& txt, bool* ok ) +RegExp* QtRegExpConverter::parse( const TQString& txt, bool* ok ) { return parseQtRegExp( txt, ok ); } -QString QtRegExpConverter::toString( AltnRegExp* regexp, bool markSelection ) +TQString QtRegExpConverter::toString( AltnRegExp* regexp, bool markSelection ) { - QString res; + TQString res; bool first = true; RegExpList list = regexp->children(); for ( RegExpListIt it(list); *it; ++it ) { if ( !first ) { - res += QString::fromLatin1( "|" ); + res += TQString::fromLatin1( "|" ); } first = false; if ( markSelection && !regexp->isSelected() && (*it)->isSelected() ) { - res += QString::fromLatin1("(") + toStr( *it, markSelection ) + QString::fromLatin1(")"); + res += TQString::fromLatin1("(") + toStr( *it, markSelection ) + TQString::fromLatin1(")"); } else { res += toStr( *it, markSelection ); @@ -64,53 +64,53 @@ QString QtRegExpConverter::toString( AltnRegExp* regexp, bool markSelection ) return res; } -QString QtRegExpConverter::toString( ConcRegExp* regexp, bool markSelection ) +TQString QtRegExpConverter::toString( ConcRegExp* regexp, bool markSelection ) { - QString res; + TQString res; bool childSelected = false; RegExpList list = regexp->children(); for ( RegExpListIt it(list); *it; ++it ) { - QString startPar = QString::fromLocal8Bit(""); - QString endPar = QString::fromLocal8Bit(""); + TQString startPar = TQString::fromLocal8Bit(""); + TQString endPar = TQString::fromLocal8Bit(""); if ( (*it)->precedence() < regexp->precedence() ) { if ( markSelection ) - startPar = QString::fromLocal8Bit("(?:"); + startPar = TQString::fromLocal8Bit("(?:"); else - startPar = QString::fromLatin1( "(" ); - endPar = QString::fromLatin1( ")" ); + startPar = TQString::fromLatin1( "(" ); + endPar = TQString::fromLatin1( ")" ); } // Note these two have different tests! They are activated in each their iteration of the loop. if ( markSelection && !childSelected && !regexp->isSelected() && (*it)->isSelected() ) { - res += QString::fromLatin1("("); + res += TQString::fromLatin1("("); childSelected = true; } if ( markSelection && childSelected && !regexp->isSelected() && !(*it)->isSelected() ) { - res += QString::fromLatin1(")"); + res += TQString::fromLatin1(")"); childSelected= false; } res += startPar + toStr( *it, markSelection ) + endPar; } if ( markSelection && childSelected && !regexp->isSelected() ) { - res += QString::fromLatin1(")"); + res += TQString::fromLatin1(")"); } return res; } -QString QtRegExpConverter::toString( LookAheadRegExp* regexp, bool markSelection ) +TQString QtRegExpConverter::toString( LookAheadRegExp* regexp, bool markSelection ) { if ( regexp->lookAheadType() == LookAheadRegExp::POSITIVE ) - return QString::fromLatin1( "(?=" ) + toStr( regexp->child(), markSelection ) + QString::fromLocal8Bit( ")" ); + return TQString::fromLatin1( "(?=" ) + toStr( regexp->child(), markSelection ) + TQString::fromLocal8Bit( ")" ); else - return QString::fromLatin1( "(?!" ) + toStr( regexp->child(), markSelection ) + QString::fromLocal8Bit( ")" ); + return TQString::fromLatin1( "(?!" ) + toStr( regexp->child(), markSelection ) + TQString::fromLocal8Bit( ")" ); } -QString QtRegExpConverter::toString( TextRangeRegExp* regexp, bool /*markSelection*/ ) +TQString QtRegExpConverter::toString( TextRangeRegExp* regexp, bool /*markSelection*/ ) { - QString txt; + TQString txt; bool foundCarrot = false; bool foundDash = false; @@ -118,15 +118,15 @@ QString QtRegExpConverter::toString( TextRangeRegExp* regexp, bool /*markSelecti // Now print the rest of the single characters, but keep "^" as the very // last element of the characters. - QStringList chars = regexp->chars(); + TQStringList chars = regexp->chars(); for (unsigned int i = 0; i< chars.count(); i++) { - if ( *chars.at(i) == QChar( ']' ) ) { + if ( *chars.at(i) == TQChar( ']' ) ) { foundParenthesis = true; } - else if ( *chars.at(i) == QChar( '-' ) ) { + else if ( *chars.at(i) == TQChar( '-' ) ) { foundDash = true; } - else if ( *chars.at(i) == QChar( '^' ) ) { + else if ( *chars.at(i) == TQChar( '^' ) ) { foundCarrot = true; } else { @@ -135,9 +135,9 @@ QString QtRegExpConverter::toString( TextRangeRegExp* regexp, bool /*markSelecti } // Now insert the ranges. - QPtrList<StringPair> ranges = regexp->range(); - for ( QPtrListIterator<StringPair> it(ranges); *it; ++it ) { - txt.append((*it)->first()+ QString::fromLatin1("-")+ (*it)->second()); + TQPtrList<StringPair> ranges = regexp->range(); + for ( TQPtrListIterator<StringPair> it(ranges); *it; ++it ) { + txt.append((*it)->first()+ TQString::fromLatin1("-")+ (*it)->second()); } // Ok, its time to build each part of the regexp, here comes the rule: @@ -147,145 +147,145 @@ QString QtRegExpConverter::toString( TextRangeRegExp* regexp, bool /*markSelecti // finally if '^' is one of the characters, then it must not be the first // one! - QString res = QString::fromLatin1("["); + TQString res = TQString::fromLatin1("["); if ( regexp->negate() ) - res.append(QString::fromLatin1("^")); + res.append(TQString::fromLatin1("^")); // a ']' must be the first character in teh range. if ( foundParenthesis ) { - res.append(QString::fromLatin1("]")); + res.append(TQString::fromLatin1("]")); } // a '-' must be the first character ( only coming after a ']') if ( foundDash ) { - res.append(QString::fromLatin1("-")); + res.append(TQString::fromLatin1("-")); } res += txt; // Insert \s,\S,\d,\D,\w, and \W if ( regexp->digit() ) - res += QString::fromLocal8Bit("\\d"); + res += TQString::fromLocal8Bit("\\d"); if ( regexp->nonDigit() ) - res += QString::fromLocal8Bit("\\D"); + res += TQString::fromLocal8Bit("\\D"); if ( regexp->space() ) - res += QString::fromLocal8Bit("\\s"); + res += TQString::fromLocal8Bit("\\s"); if ( regexp->nonSpace() ) - res += QString::fromLocal8Bit("\\S"); + res += TQString::fromLocal8Bit("\\S"); if ( regexp->wordChar() ) - res += QString::fromLocal8Bit("\\w"); + res += TQString::fromLocal8Bit("\\w"); if ( regexp->nonWordChar() ) - res += QString::fromLocal8Bit("\\W"); + res += TQString::fromLocal8Bit("\\W"); if ( foundCarrot ) { - res.append( QChar( '^' ) ); + res.append( TQChar( '^' ) ); } - res.append(QString::fromLatin1("]")); + res.append(TQString::fromLatin1("]")); return res; } -QString QtRegExpConverter::toString( CompoundRegExp* regexp, bool markSelection ) +TQString QtRegExpConverter::toString( CompoundRegExp* regexp, bool markSelection ) { if ( markSelection && !regexp->isSelected() && regexp->child()->isSelected() ) - return QString::fromLatin1( "(" ) + toStr( regexp->child(), markSelection ) + QString::fromLatin1( ")" ); + return TQString::fromLatin1( "(" ) + toStr( regexp->child(), markSelection ) + TQString::fromLatin1( ")" ); else return toStr( regexp->child(), markSelection ); } -QString QtRegExpConverter::toString( DotRegExp* /*regexp*/, bool /*markSelection*/ ) +TQString QtRegExpConverter::toString( DotRegExp* /*regexp*/, bool /*markSelection*/ ) { - return QString::fromLatin1( "." ); + return TQString::fromLatin1( "." ); } -QString QtRegExpConverter::toString( PositionRegExp* regexp, bool /*markSelection*/ ) +TQString QtRegExpConverter::toString( PositionRegExp* regexp, bool /*markSelection*/ ) { switch (regexp->position()) { case PositionRegExp::BEGLINE: - return QString::fromLatin1("^"); + return TQString::fromLatin1("^"); case PositionRegExp::ENDLINE: - return QString::fromLatin1("$"); + return TQString::fromLatin1("$"); case PositionRegExp::WORDBOUNDARY: - return QString::fromLatin1("\\b"); + return TQString::fromLatin1("\\b"); case PositionRegExp::NONWORDBOUNDARY: - return QString::fromLatin1("\\B"); + return TQString::fromLatin1("\\B"); } Q_ASSERT( false ); - return QString::fromLatin1(""); + return TQString::fromLatin1(""); } -QString QtRegExpConverter::toString( RepeatRegExp* regexp, bool markSelection ) +TQString QtRegExpConverter::toString( RepeatRegExp* regexp, bool markSelection ) { RegExp* child = regexp->child(); - QString cText = toStr( child, markSelection ); - QString startPar; - QString endPar; + TQString cText = toStr( child, markSelection ); + TQString startPar; + TQString endPar; if ( markSelection ) { if ( !regexp->isSelected() && child->isSelected()) { - startPar = QString::fromLatin1( "(" ); - endPar = QString::fromLatin1( ")" ); + startPar = TQString::fromLatin1( "(" ); + endPar = TQString::fromLatin1( ")" ); } else if ( child->precedence() < regexp->precedence() ) { - startPar = QString::fromLatin1( "(?:" ); - endPar = QString::fromLatin1( ")" ); + startPar = TQString::fromLatin1( "(?:" ); + endPar = TQString::fromLatin1( ")" ); } } else if ( child->precedence() < regexp->precedence() ) { - startPar = QString::fromLatin1( "(" ); - endPar = QString::fromLatin1( ")" ); + startPar = TQString::fromLatin1( "(" ); + endPar = TQString::fromLatin1( ")" ); } if ( regexp->min() == 0 && regexp->max() == -1) { - return startPar + cText +endPar + QString::fromLocal8Bit("*"); + return startPar + cText +endPar + TQString::fromLocal8Bit("*"); } else if ( regexp->min() == 0 && regexp->max() == 1 ) { - return startPar + cText + endPar + QString::fromLocal8Bit("?"); + return startPar + cText + endPar + TQString::fromLocal8Bit("?"); } else if ( regexp->min() == 1 && regexp->max() == -1 ) { - return startPar + cText + endPar + QString::fromLocal8Bit("+"); + return startPar + cText + endPar + TQString::fromLocal8Bit("+"); } else if ( regexp->max() == -1 ) { - return startPar + cText + endPar + QString::fromLocal8Bit("{") + - QString::number( regexp->min() ) + QString::fromLocal8Bit(",") + - QString::fromLocal8Bit("}"); + return startPar + cText + endPar + TQString::fromLocal8Bit("{") + + TQString::number( regexp->min() ) + TQString::fromLocal8Bit(",") + + TQString::fromLocal8Bit("}"); } else { - return startPar + cText + endPar + QString::fromLocal8Bit("{") + - QString::number( regexp->min() ) + QString::fromLocal8Bit(",") + - QString::number( regexp->max() ) + QString::fromLocal8Bit("}"); + return startPar + cText + endPar + TQString::fromLocal8Bit("{") + + TQString::number( regexp->min() ) + TQString::fromLocal8Bit(",") + + TQString::number( regexp->max() ) + TQString::fromLocal8Bit("}"); } } -QString QtRegExpConverter::toString( TextRegExp* regexp, bool /*markSelection*/ ) +TQString QtRegExpConverter::toString( TextRegExp* regexp, bool /*markSelection*/ ) { - QValueList<QChar> list; - list << QChar('$') - << QChar('^') - << QChar('.') - << QChar('*') - << QChar('+') - << QChar('?') - << QChar('[') - << QChar(']') - << QChar('\\') - << QChar('{') - << QChar('}') - << QChar('(') - << QChar(')') - << QChar('|'); - - QString res = escape( regexp->text(), list, QChar('\\') ); + TQValueList<TQChar> list; + list << TQChar('$') + << TQChar('^') + << TQChar('.') + << TQChar('*') + << TQChar('+') + << TQChar('?') + << TQChar('[') + << TQChar(']') + << TQChar('\\') + << TQChar('{') + << TQChar('}') + << TQChar('(') + << TQChar(')') + << TQChar('|'); + + TQString res = escape( regexp->text(), list, TQChar('\\') ); return res; } -QString QtRegExpConverter::name() +TQString QtRegExpConverter::name() { - return QString::fromLatin1( "Qt" ); + return TQString::fromLatin1( "Qt" ); } int QtRegExpConverter::features() @@ -293,7 +293,7 @@ int QtRegExpConverter::features() return WordBoundary | NonWordBoundary | PosLookAhead | NegLookAhead | CharacterRangeNonItems | ExtRange; } -RegexpHighlighter* QtRegExpConverter::highlighter( QTextEdit* edit ) +RegexpHighlighter* QtRegExpConverter::highlighter( TQTextEdit* edit ) { return new QtRegexpHighlighter( edit ); } |