diff options
author | Slávek Banko <[email protected]> | 2013-06-29 12:56:53 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2013-07-04 03:11:35 +0200 |
commit | 5f5e7c5455d52826b0bd50f64fcffb7695ce970d (patch) | |
tree | c8ee8792d3fb139365abbf70c2255f1e69d2aa34 /src/idsuggestions.cpp | |
parent | 251c9a439759c830d34c70683d0fc9454d703010 (diff) | |
download | kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.tar.gz kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.zip |
Initial TQt conversion
Diffstat (limited to 'src/idsuggestions.cpp')
-rw-r--r-- | src/idsuggestions.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/src/idsuggestions.cpp b/src/idsuggestions.cpp index 5704c1e..05d8a11 100644 --- a/src/idsuggestions.cpp +++ b/src/idsuggestions.cpp @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <qregexp.h> +#include <ntqregexp.h> #include <klocale.h> @@ -29,7 +29,7 @@ namespace KBibTeX { - const QRegExp IdSuggestions::unwantedChars = QRegExp( "[^-_:/=+a-zA-Z0-9]+" ); + const TQRegExp IdSuggestions::unwantedChars = TQRegExp( "[^-_:/=+a-zA-Z0-9]+" ); IdSuggestions::IdSuggestions() { @@ -45,9 +45,9 @@ namespace KBibTeX /** * Determine list of authors or editors for a given entry */ - QStringList IdSuggestions::authorsLastName( BibTeX::Entry *entry ) + TQStringList IdSuggestions::authorsLastName( BibTeX::Entry *entry ) { - QStringList result; + TQStringList result; /** retrieve field holding authors information for entry */ BibTeX::EntryField *field = entry->getField( BibTeX::EntryField::ftAuthor ); @@ -68,7 +68,7 @@ namespace KBibTeX return result; /** container not found or is empty */ /** iterate through container and fetch each author's last name */ - for ( QValueList<BibTeX::Person*>::ConstIterator it = personContainer->persons.begin(); it != personContainer->persons.end(); ++it ) + for ( TQValueList<BibTeX::Person*>::ConstIterator it = personContainer->persons.begin(); it != personContainer->persons.end(); ++it ) { result.append( normalizeText(( *it )->lastName() ) ); } @@ -80,26 +80,26 @@ namespace KBibTeX * Normalize a given text by removing spaces or other unwanted characters, * replace some accented and special characters by plain ASCII transliterations */ - QString IdSuggestions::normalizeText( const QString& text ) + TQString IdSuggestions::normalizeText( const TQString& text ) { - QString result = text; + TQString result = text; for ( int i = text.length() - 1; i >= 0; --i ) - result[i] = QChar( BibTeX::EncoderLaTeX::unicodeToASCII( result[i].unicode() ) ); + result[i] = TQChar( BibTeX::EncoderLaTeX::unicodeToASCII( result[i].unicode() ) ); return result.replace( unwantedChars, "" ); } - QString IdSuggestions::resolveConflict( BibTeX::File *file, const QString &id, BibTeX::Element *element ) + TQString IdSuggestions::resolveConflict( BibTeX::File *file, const TQString &id, BibTeX::Element *element ) { - QString result = id; + TQString result = id; BibTeX::Element *hit = file->containsKey( id ) ; if ( hit != NULL && hit != element ) { int i = 0; do { - result = QString( "%1-%2" ).arg( id ).arg( ++i ); + result = TQString( "%1-%2" ).arg( id ).arg( ++i ); hit = file->containsKey( result ); } while ( hit != NULL && hit != element ); @@ -124,9 +124,9 @@ namespace KBibTeX /** parse value item's text */ bool ok = FALSE; - QRegExp yearRegExp( "\\b(\\d{2})?\\d{2}\\b" ); + TQRegExp yearRegExp( "\\b(\\d{2})?\\d{2}\\b" ); yearRegExp.search( valueItem->text() ); - int year = QString( yearRegExp.cap( 0 ) ).toInt( &ok ); + int year = TQString( yearRegExp.cap( 0 ) ).toInt( &ok ); if ( !ok ) year = -1; return year; @@ -135,34 +135,34 @@ namespace KBibTeX /** * Determine title for a given entry */ - QString IdSuggestions::extractTitle( BibTeX::Entry *entry ) + TQString IdSuggestions::extractTitle( BibTeX::Entry *entry ) { /** retrieve field holding title information for entry */ BibTeX::EntryField *field = entry->getField( BibTeX::EntryField::ftTitle ); if ( field == NULL ) - return QString::null; /** no title field available */ + return TQString::null; /** no title field available */ /** *fetch value item holding title */ BibTeX::ValueItem *valueItem = field->value()->items.isEmpty() ? NULL : field->value()->items.first(); if ( valueItem == NULL ) - return QString::null; /** no value item found or is empty */ + return TQString::null; /** no value item found or is empty */ return valueItem->text(); } - QStringList IdSuggestions::createSuggestions( BibTeX::File *file, BibTeX::Entry *entry ) + TQStringList IdSuggestions::createSuggestions( BibTeX::File *file, BibTeX::Entry *entry ) { Settings * settings = Settings::self(); - const QStringList& formatStrList = settings->idSuggestions_formatStrList; - QStringList result; - QStringList allKeys = file != NULL ? file->allKeys() : QStringList(); + const TQStringList& formatStrList = settings->idSuggestions_formatStrList; + TQStringList result; + TQStringList allKeys = file != NULL ? file->allKeys() : TQStringList(); entry = new BibTeX::Entry( entry ); if ( file != NULL ) file->completeReferencedFields( entry ); - for ( QStringList::ConstIterator it = formatStrList.begin(); it != formatStrList.end(); ++it ) + for ( TQStringList::ConstIterator it = formatStrList.begin(); it != formatStrList.end(); ++it ) { - QString id = formatId( entry, *it ); + TQString id = formatId( entry, *it ); if ( id.isEmpty() || result.contains( id ) ) continue; if ( !result.contains( id ) ) @@ -174,33 +174,33 @@ namespace KBibTeX return result; } - QString IdSuggestions::createDefaultSuggestion( BibTeX::File *file, BibTeX::Entry *entry ) + TQString IdSuggestions::createDefaultSuggestion( BibTeX::File *file, BibTeX::Entry *entry ) { Settings * settings = Settings::self(); if ( settings->idSuggestions_default < 0 || settings->idSuggestions_default >= ( int )settings->idSuggestions_formatStrList.size() ) - return QString::null; + return TQString::null; entry = new BibTeX::Entry( entry ); if ( file != NULL ) file->completeReferencedFields( entry ); - QString result = formatId( entry, settings->idSuggestions_formatStrList[settings->idSuggestions_default] ); + TQString result = formatId( entry, settings->idSuggestions_formatStrList[settings->idSuggestions_default] ); delete entry; return result; } - QString IdSuggestions::formatId( BibTeX::Entry *entry, const QString& formatStr ) + TQString IdSuggestions::formatId( BibTeX::Entry *entry, const TQString& formatStr ) { - QString id; - QStringList tokenList = QStringList::split( '|', formatStr ); - for ( QStringList::ConstIterator tit = tokenList.begin(); tit != tokenList.end(); ++tit ) + TQString id; + TQStringList tokenList = TQStringList::split( '|', formatStr ); + for ( TQStringList::ConstIterator tit = tokenList.begin(); tit != tokenList.end(); ++tit ) id.append( translateToken( entry, *tit ) ); return id; } - QString IdSuggestions::translateToken( BibTeX::Entry *entry, const QString& token ) + TQString IdSuggestions::translateToken( BibTeX::Entry *entry, const TQString& token ) { switch ( token[0] ) { @@ -211,34 +211,34 @@ namespace KBibTeX { int year = extractYear( entry ); if ( year > -1 ) - return QString::number( year % 100 + 100 ).mid( 1 ); + return TQString::number( year % 100 + 100 ).mid( 1 ); else - return QString::null; + return TQString::null; } case 'Y': { int year = extractYear( entry ); if ( year > -1 ) - return QString::number( year % 10000 + 10000 ).mid( 1 ); + return TQString::number( year % 10000 + 10000 ).mid( 1 ); else - return QString::null; + return TQString::null; } case 't': return translateTitleToken( entry, token.mid( 1 ), FALSE ); case 'T': return translateTitleToken( entry, token.mid( 1 ), TRUE ); case '"': return token.mid( 1 ); - default: return QString::null; + default: return TQString::null; } } - QString IdSuggestions::translateAuthorsToken( BibTeX::Entry *entry, const QString& token, Authors selectAuthors ) + TQString IdSuggestions::translateAuthorsToken( BibTeX::Entry *entry, const TQString& token, Authors selectAuthors ) { struct IdSuggestionTokenInfo ati = evalToken( token ); - QString result; + TQString result; bool first = true, firstInserted = true; - QStringList authors = authorsLastName( entry ); - for ( QStringList::ConstIterator it = authors.begin(); it != authors.end(); ++it ) + TQStringList authors = authorsLastName( entry ); + for ( TQStringList::ConstIterator it = authors.begin(); it != authors.end(); ++it ) { - QString author = normalizeText( *it ).left( ati.len ); + TQString author = normalizeText( *it ).left( ati.len ); if ( selectAuthors == aAll || ( selectAuthors == aOnlyFirst && first ) || ( selectAuthors == aNotFirst && !first ) ) { if ( !firstInserted ) @@ -257,14 +257,14 @@ namespace KBibTeX return result; } - struct IdSuggestionTokenInfo IdSuggestions::evalToken( const QString& token ) + struct IdSuggestionTokenInfo IdSuggestions::evalToken( const TQString& token ) { unsigned int pos = 0; struct IdSuggestionTokenInfo result; result.len = 0x00ffffff; result.toLower = FALSE; result.toUpper = FALSE; - result.inBetween = QString::null; + result.inBetween = TQString::null; if ( token.length() > pos ) { @@ -290,23 +290,23 @@ namespace KBibTeX return result; } - QString IdSuggestions::translateTitleToken( BibTeX::Entry *entry, const QString& token, bool removeSmallWords ) + TQString IdSuggestions::translateTitleToken( BibTeX::Entry *entry, const TQString& token, bool removeSmallWords ) { struct IdSuggestionTokenInfo tti = evalToken( token ); Settings * settings = Settings::self(); - const QStringList smallWords = settings->idSuggestions_smallWords; + const TQStringList smallWords = settings->idSuggestions_smallWords; - QString result; + TQString result; bool first = TRUE; - QStringList titleWords = QStringList::split( QRegExp( "\\s+" ), extractTitle( entry ) ); - for ( QStringList::ConstIterator it = titleWords.begin(); it != titleWords.end(); ++it ) + TQStringList titleWords = TQStringList::split( TQRegExp( "\\s+" ), extractTitle( entry ) ); + for ( TQStringList::ConstIterator it = titleWords.begin(); it != titleWords.end(); ++it ) { if ( first ) first = FALSE; else result.append( tti.inBetween ); - QString lowerText = ( *it ).lower(); + TQString lowerText = ( *it ).lower(); if ( !removeSmallWords || !smallWords.contains( lowerText ) ) result.append( normalizeText( *it ).left( tti.len ) ); } @@ -320,12 +320,12 @@ namespace KBibTeX } /** convert a formatting string into a human readable version (even translated) */ - QString IdSuggestions::formatStrToHuman( const QString& formatStr ) + TQString IdSuggestions::formatStrToHuman( const TQString& formatStr ) { bool first = TRUE; - QString text; - QStringList elements = QStringList::split( '|', formatStr ); - for ( QStringList::iterator it = elements.begin();it != elements.end();++it ) + TQString text; + TQStringList elements = TQStringList::split( '|', formatStr ); + for ( TQStringList::iterator it = elements.begin();it != elements.end();++it ) { if ( first ) first = FALSE; else text.append( "\n" ); if (( *it )[0] == 'a' || ( *it )[0] == 'A' || ( *it )[0] == 'z' ) @@ -339,7 +339,7 @@ namespace KBibTeX if ( info.len < 0x00ffffff ) text.append( i18n( ", but only first letter of each last name", ", but only first %n letters of each last name", n ) ); if ( info.toUpper ) text.append( i18n( ", in upper case" ) ); else if ( info.toLower ) text.append( i18n( ", in lower case" ) ); - if ( info.inBetween != QString::null ) text.append( QString( i18n( ", with '%1' in between" ) ).arg( info.inBetween ) ); + if ( info.inBetween != TQString::null ) text.append( TQString( i18n( ", with '%1' in between" ) ).arg( info.inBetween ) ); } else if (( *it )[0] == 'y' ) text.append( i18n( "Year (2 digits)" ) ); else if (( *it )[0] == 'Y' ) text.append( i18n( "Year (4 digits)" ) ); @@ -351,10 +351,10 @@ namespace KBibTeX if ( info.len < 0x00ffffff ) text.append( i18n( ", but only first letter of each word", ", but only first %n letters of each word", n ) ); if ( info.toUpper ) text.append( i18n( ", in upper case" ) ); else if ( info.toLower ) text.append( i18n( ", in lower case" ) ); - if ( info.inBetween != QString::null ) text.append( QString( i18n( ", with '%1' in between" ) ).arg( info.inBetween ) ); + if ( info.inBetween != TQString::null ) text.append( TQString( i18n( ", with '%1' in between" ) ).arg( info.inBetween ) ); if (( *it )[0] == 'T' ) text.append( i18n( ", small words removed" ) ); } - else if (( *it )[0] == '"' ) text.append( QString( i18n( "Text: '%1'" ) ).arg(( *it ).mid( 1 ) ) ); + else if (( *it )[0] == '"' ) text.append( TQString( i18n( "Text: '%1'" ) ).arg(( *it ).mid( 1 ) ) ); else text.append( "?" ); } |