diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /kugar/lib/inputmask.cpp | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kugar/lib/inputmask.cpp')
-rw-r--r-- | kugar/lib/inputmask.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/kugar/lib/inputmask.cpp b/kugar/lib/inputmask.cpp index 75a72f61..08d67b26 100644 --- a/kugar/lib/inputmask.cpp +++ b/kugar/lib/inputmask.cpp @@ -17,61 +17,61 @@ namespace Kugar { -InputMask::InputMask( QObject *parent, const char *name ) - : QObject( parent, name ), - m_text( QString::null ), +InputMask::InputMask( TQObject *tqparent, const char *name ) + : TQObject( tqparent, name ), + m_text( TQString() ), m_maxLength( 32767 ), m_blank( ' ' ), - m_mask( QString::null ), - m_maskData( 0L ) + m_tqmask( TQString() ), + m_tqmaskData( 0L ) {} InputMask::~InputMask() { - delete [] m_maskData; + delete [] m_tqmaskData; } -QString InputMask::mask() const +TQString InputMask::tqmask() const { - return ( m_maskData ? m_mask + ';' + m_blank : QString::null ); + return ( m_tqmaskData ? m_tqmask + ';' + m_blank : TQString() ); } -void InputMask::setMask( const QString &mask ) +void InputMask::setMask( const TQString &tqmask ) { - parseInputMask( mask ); + parseInputMask( tqmask ); } -QString InputMask::formatText( const QString &txt ) +TQString InputMask::formatText( const TQString &txt ) { - return maskString( 0, txt, true ); + return tqmaskString( 0, txt, true ); } -void InputMask::parseInputMask( const QString &maskFields ) +void InputMask::parseInputMask( const TQString &tqmaskFields ) { - if ( maskFields.isEmpty() || maskFields.section( ';', 0, 0 ).isEmpty() ) + if ( tqmaskFields.isEmpty() || tqmaskFields.section( ';', 0, 0 ).isEmpty() ) { - if ( m_maskData ) + if ( m_tqmaskData ) { - delete [] m_maskData; - m_maskData = 0; + delete [] m_tqmaskData; + m_tqmaskData = 0; m_maxLength = 32767; } return ; } - m_mask = maskFields.section( ';', 0, 0 ); - m_blank = maskFields.section( ';', 1, 1 ).at( 0 ); + m_tqmask = tqmaskFields.section( ';', 0, 0 ); + m_blank = tqmaskFields.section( ';', 1, 1 ).at( 0 ); if ( m_blank.isNull() ) m_blank = ' '; - // calculate m_maxLength / m_maskData length + // calculate m_maxLength / m_tqmaskData length m_maxLength = 0; - QChar c = 0; + TQChar c = 0; uint i; - for ( i = 0; i < m_mask.length(); i++ ) + for ( i = 0; i < m_tqmask.length(); i++ ) { - c = m_mask.at( i ); - if ( i > 0 && m_mask.at( i - 1 ) == '\\' ) + c = m_tqmask.at( i ); + if ( i > 0 && m_tqmask.at( i - 1 ) == '\\' ) { m_maxLength++; continue; @@ -83,23 +83,23 @@ void InputMask::parseInputMask( const QString &maskFields ) m_maxLength++; } - delete [] m_maskData; - m_maskData = new MaskInputData[ m_maxLength ]; + delete [] m_tqmaskData; + m_tqmaskData = new MaskInputData[ m_maxLength ]; MaskInputData::Casemode m = MaskInputData::NoCaseMode; c = 0; bool s; bool escape = FALSE; int index = 0; - for ( i = 0; i < m_mask.length(); i++ ) + for ( i = 0; i < m_tqmask.length(); i++ ) { - c = m_mask.at( i ); + c = m_tqmask.at( i ); if ( escape ) { s = TRUE; - m_maskData[ index ].maskChar = c; - m_maskData[ index ].separator = s; - m_maskData[ index ].caseMode = m; + m_tqmaskData[ index ].tqmaskChar = c; + m_tqmaskData[ index ].separator = s; + m_tqmaskData[ index ].caseMode = m; index++; escape = FALSE; } @@ -144,18 +144,18 @@ void InputMask::parseInputMask( const QString &maskFields ) if ( !escape ) { - m_maskData[ index ].maskChar = c; - m_maskData[ index ].separator = s; - m_maskData[ index ].caseMode = m; + m_tqmaskData[ index ].tqmaskChar = c; + m_tqmaskData[ index ].separator = s; + m_tqmaskData[ index ].caseMode = m; index++; } } } } -bool InputMask::isValidInput( QChar key, QChar mask ) const +bool InputMask::isValidInput( TQChar key, TQChar tqmask ) const { - switch ( mask ) + switch ( tqmask ) { case 'A': if ( key.isLetter() && key != m_blank ) @@ -207,33 +207,33 @@ bool InputMask::isValidInput( QChar key, QChar mask ) const return FALSE; } -QString InputMask::maskString( uint pos, const QString &str, bool clear ) const +TQString InputMask::tqmaskString( uint pos, const TQString &str, bool clear ) const { if ( pos >= ( uint ) m_maxLength ) - return QString::fromLatin1( "" ); + return TQString::tqfromLatin1( "" ); - QString fill; + TQString fill; fill = clear ? clearString( 0, m_maxLength ) : m_text; uint strIndex = 0; - QString s = QString::fromLatin1( "" ); + TQString s = TQString::tqfromLatin1( "" ); int i = pos; while ( i < m_maxLength ) { if ( strIndex < str.length() ) { - if ( m_maskData[ i ].separator ) + if ( m_tqmaskData[ i ].separator ) { - s += m_maskData[ i ].maskChar; - if ( str[ ( int ) strIndex ] == m_maskData[ i ].maskChar ) + s += m_tqmaskData[ i ].tqmaskChar; + if ( str[ ( int ) strIndex ] == m_tqmaskData[ i ].tqmaskChar ) strIndex++; ++i; } else { - if ( isValidInput( str[ ( int ) strIndex ], m_maskData[ i ].maskChar ) ) + if ( isValidInput( str[ ( int ) strIndex ], m_tqmaskData[ i ].tqmaskChar ) ) { - switch ( m_maskData[ i ].caseMode ) + switch ( m_tqmaskData[ i ].caseMode ) { case MaskInputData::Upper: s += str[ ( int ) strIndex ].upper(); @@ -252,10 +252,10 @@ QString InputMask::maskString( uint pos, const QString &str, bool clear ) const int n = findInMask( i, TRUE, TRUE, str[ ( int ) strIndex ] ); if ( n != -1 ) { - if ( str.length() != 1 || i == 0 || ( i > 0 && ( !m_maskData[ i - 1 ].separator || m_maskData[ i - 1 ].maskChar != str[ ( int ) strIndex ] ) ) ) + if ( str.length() != 1 || i == 0 || ( i > 0 && ( !m_tqmaskData[ i - 1 ].separator || m_tqmaskData[ i - 1 ].tqmaskChar != str[ ( int ) strIndex ] ) ) ) { s += fill.mid( i, n - i + 1 ); - i = n + 1; // update i to find + 1 + i = n + 1; // update i to tqfind + 1 } } else @@ -265,7 +265,7 @@ QString InputMask::maskString( uint pos, const QString &str, bool clear ) const if ( n != -1 ) { s += fill.mid( i, n - i ); - switch ( m_maskData[ n ].caseMode ) + switch ( m_tqmaskData[ n ].caseMode ) { case MaskInputData::Upper: s += str[ ( int ) strIndex ].upper(); @@ -276,7 +276,7 @@ QString InputMask::maskString( uint pos, const QString &str, bool clear ) const default: s += str[ ( int ) strIndex ]; } - i = n + 1; // updates i to find + 1 + i = n + 1; // updates i to tqfind + 1 } } } @@ -290,32 +290,32 @@ QString InputMask::maskString( uint pos, const QString &str, bool clear ) const return s; } -QString InputMask::clearString( uint pos, uint len ) const +TQString InputMask::clearString( uint pos, uint len ) const { if ( pos >= ( uint ) m_maxLength ) - return QString::null; + return TQString(); - QString s; - int end = QMIN( ( uint ) m_maxLength, pos + len ); + TQString s; + int end = TQMIN( ( uint ) m_maxLength, pos + len ); for ( int i = pos; i < end; i++ ) - if ( m_maskData[ i ].separator ) - s += m_maskData[ i ].maskChar; + if ( m_tqmaskData[ i ].separator ) + s += m_tqmaskData[ i ].tqmaskChar; else s += m_blank; return s; } -QString InputMask::stripString( const QString &str ) const +TQString InputMask::stripString( const TQString &str ) const { - if ( !m_maskData ) + if ( !m_tqmaskData ) return str; - QString s; - int end = QMIN( m_maxLength, ( int ) str.length() ); + TQString s; + int end = TQMIN( m_maxLength, ( int ) str.length() ); for ( int i = 0; i < end; i++ ) - if ( m_maskData[ i ].separator ) - s += m_maskData[ i ].maskChar; + if ( m_tqmaskData[ i ].separator ) + s += m_tqmaskData[ i ].tqmaskChar; else if ( str[ i ] != m_blank ) s += str[ i ]; @@ -323,7 +323,7 @@ QString InputMask::stripString( const QString &str ) const return s; } -int InputMask::findInMask( int pos, bool forward, bool findSeparator, QChar searchChar ) const +int InputMask::findInMask( int pos, bool forward, bool findSeparator, TQChar searchChar ) const { if ( pos >= m_maxLength || pos < 0 ) return -1; @@ -336,16 +336,16 @@ int InputMask::findInMask( int pos, bool forward, bool findSeparator, QChar sear { if ( findSeparator ) { - if ( m_maskData[ i ].separator && m_maskData[ i ].maskChar == searchChar ) + if ( m_tqmaskData[ i ].separator && m_tqmaskData[ i ].tqmaskChar == searchChar ) return i; } else { - if ( !m_maskData[ i ].separator ) + if ( !m_tqmaskData[ i ].separator ) { if ( searchChar.isNull() ) return i; - else if ( isValidInput( searchChar, m_maskData[ i ].maskChar ) ) + else if ( isValidInput( searchChar, m_tqmaskData[ i ].tqmaskChar ) ) return i; } } |