From 5f5e7c5455d52826b0bd50f64fcffb7695ce970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 29 Jun 2013 12:56:53 +0200 Subject: Initial TQt conversion --- src/fileexporterbibtex.cpp | 108 ++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'src/fileexporterbibtex.cpp') diff --git a/src/fileexporterbibtex.cpp b/src/fileexporterbibtex.cpp index 240754d..03ed618 100644 --- a/src/fileexporterbibtex.cpp +++ b/src/fileexporterbibtex.cpp @@ -42,7 +42,7 @@ namespace BibTeX delete[] m_iconvBuffer; } - bool FileExporterBibTeX::save( QIODevice* iodevice, const File* bibtexfile, QStringList * /*errorLog*/ ) + bool FileExporterBibTeX::save( TQIODevice* iodevice, const File* bibtexfile, TQStringList * /*errorLog*/ ) { m_mutex.lock(); bool result = TRUE; @@ -53,11 +53,11 @@ namespace BibTeX * in the correct order. */ - QValueList parameterCommentsList; - QValueList preambleList; - QValueList macroList; - QValueList crossRefingEntryList; - QValueList remainingList; + TQValueList parameterCommentsList; + TQValueList preambleList; + TQValueList macroList; + TQValueList crossRefingEntryList; + TQValueList remainingList; for ( File::ElementList::const_iterator it = bibtexfile->elements.begin(); it != bibtexfile->elements.end() && result && !cancelFlag; it++ ) { @@ -77,12 +77,12 @@ namespace BibTeX else { Comment *comment = dynamic_cast( *it ); - QString commentText = QString::null; + TQString commentText = TQString::null; /** check if this file requests a special encoding */ if ( comment != NULL && comment->useCommand() && (( commentText = comment->text().lower() ) ).startsWith( "x-kbibtex-encoding=" ) ) { m_encoding = commentText.mid( 19 ); - qDebug( "Switching encoding to <%s>", m_encoding.latin1() ); + tqDebug( "Switching encoding to <%s>", m_encoding.latin1() ); parameterCommentsList.append( comment ); } else @@ -99,34 +99,34 @@ namespace BibTeX m_iconvHandle = iconv_open( encodingTo, "utf-8" ); /** before anything else, write parameter comments */ - for ( QValueList::iterator it = parameterCommentsList.begin(); it != parameterCommentsList.end() && result && !cancelFlag; it++ ) + for ( TQValueList::iterator it = parameterCommentsList.begin(); it != parameterCommentsList.end() && result && !cancelFlag; it++ ) { result &= writeComment( *iodevice, *it ); emit progress( ++currentPos, totalElements ); } /** first, write preambles and strings (macros) at the beginning */ - for ( QValueList::iterator it = preambleList.begin(); it != preambleList.end() && result && !cancelFlag; it++ ) + for ( TQValueList::iterator it = preambleList.begin(); it != preambleList.end() && result && !cancelFlag; it++ ) { result &= writePreamble( *iodevice, *it ); emit progress( ++currentPos, totalElements ); } - for ( QValueList::iterator it = macroList.begin(); it != macroList.end() && result && !cancelFlag; it++ ) + for ( TQValueList::iterator it = macroList.begin(); it != macroList.end() && result && !cancelFlag; it++ ) { result &= writeMacro( *iodevice, *it ); emit progress( ++currentPos, totalElements ); } /** second, write cross-referencing elements */ - for ( QValueList::iterator it = crossRefingEntryList.begin(); it != crossRefingEntryList.end() && result && !cancelFlag; it++ ) + for ( TQValueList::iterator it = crossRefingEntryList.begin(); it != crossRefingEntryList.end() && result && !cancelFlag; it++ ) { result &= writeEntry( *iodevice, *it ); emit progress( ++currentPos, totalElements ); } /** third, write remaining elements */ - for ( QValueList::iterator it = remainingList.begin(); it != remainingList.end() && result && !cancelFlag; it++ ) + for ( TQValueList::iterator it = remainingList.begin(); it != remainingList.end() && result && !cancelFlag; it++ ) { Entry *entry = dynamic_cast( *it ); if ( entry != NULL ) @@ -145,7 +145,7 @@ namespace BibTeX return result && !cancelFlag; } - bool FileExporterBibTeX::save( QIODevice* iodevice, const Element* element, QStringList * /*errorLog*/ ) + bool FileExporterBibTeX::save( TQIODevice* iodevice, const Element* element, TQStringList * /*errorLog*/ ) { m_mutex.lock(); bool result = FALSE; @@ -185,44 +185,44 @@ namespace BibTeX cancelFlag = TRUE; } - bool FileExporterBibTeX::writeEntry( QIODevice &device, const Entry* entry ) + bool FileExporterBibTeX::writeEntry( TQIODevice &device, const Entry* entry ) { - writeString( device, QString( "@%1{ %2" ).arg( applyKeywordCasing( entry->entryTypeString() ) ).arg( entry->id() ) ); + writeString( device, TQString( "@%1{ %2" ).arg( applyKeywordCasing( entry->entryTypeString() ) ).arg( entry->id() ) ); for ( Entry::EntryFields::ConstIterator it = entry->begin(); it != entry->end(); ++it ) { EntryField *field = *it; - QString text = valueToString( field->value(), field->fieldType(), field->fieldTypeName() ); + TQString text = valueToString( field->value(), field->fieldType(), field->fieldTypeName() ); if ( m_protectCasing && dynamic_cast( field->value()->items.first() ) != NULL && ( field->fieldType() == EntryField::ftTitle || field->fieldType() == EntryField::ftBookTitle || field->fieldType() == EntryField::ftSeries ) ) addProtectiveCasing( text ); - writeString( device, QString( ",\n\t%1 = %2" ).arg( field->fieldTypeName() ).arg( text ) ); + writeString( device, TQString( ",\n\t%1 = %2" ).arg( field->fieldTypeName() ).arg( text ) ); } writeString( device, "\n}\n\n" ); return TRUE; } - bool FileExporterBibTeX::writeMacro( QIODevice &device, const Macro *macro ) + bool FileExporterBibTeX::writeMacro( TQIODevice &device, const Macro *macro ) { - QString text = valueToString( macro->value() ); + TQString text = valueToString( macro->value() ); if ( m_protectCasing ) addProtectiveCasing( text ); - writeString( device, QString( "@%1{ %2 = %3 }\n\n" ).arg( applyKeywordCasing( "String" ) ).arg( macro->key() ).arg( text ) ); + writeString( device, TQString( "@%1{ %2 = %3 }\n\n" ).arg( applyKeywordCasing( "String" ) ).arg( macro->key() ).arg( text ) ); return TRUE; } - bool FileExporterBibTeX::writeComment( QIODevice &device, const Comment *comment ) + bool FileExporterBibTeX::writeComment( TQIODevice &device, const Comment *comment ) { if ( !comment->useCommand() ) { - QString text = comment->text() ; + TQString text = comment->text() ; if ( m_encoding == "latex" ) text = EncoderLaTeX::currentEncoderLaTeX() ->encode( text ); - QStringList commentLines = QStringList::split( '\n', text ); - for ( QStringList::Iterator it = commentLines.begin(); it != commentLines.end(); it++ ) + TQStringList commentLines = TQStringList::split( '\n', text ); + for ( TQStringList::Iterator it = commentLines.begin(); it != commentLines.end(); it++ ) { writeString( device, ( *it ).append( "\n" ) ); } @@ -230,27 +230,27 @@ namespace BibTeX } else { - QString text = comment->text() ; + TQString text = comment->text() ; if ( m_encoding == "latex" ) text = EncoderLaTeX::currentEncoderLaTeX() ->encode( text ); - writeString( device, QString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Comment" ) ).arg( text ) ); + writeString( device, TQString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Comment" ) ).arg( text ) ); } return TRUE; } - bool FileExporterBibTeX::writePreamble( QIODevice &device, const Preamble* preamble ) + bool FileExporterBibTeX::writePreamble( TQIODevice &device, const Preamble* preamble ) { - writeString( device, QString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Preamble" ) ).arg( valueToString( preamble->value() ) ) ); + writeString( device, TQString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Preamble" ) ).arg( valueToString( preamble->value() ) ) ); return TRUE; } - bool FileExporterBibTeX::writeString( QIODevice &device, const QString& text ) + bool FileExporterBibTeX::writeString( TQIODevice &device, const TQString& text ) { size_t utf8datasize = 1; - QCString utf8 = text.utf8(); + TQCString utf8 = text.utf8(); char *utf8data = utf8.data(); utf8datasize = utf8.length(); char *outputdata = m_iconvBuffer; @@ -259,20 +259,20 @@ namespace BibTeX size_t result = iconv( m_iconvHandle, &utf8data, &utf8datasize, &outputdata, &outputdatasize ); if ( result != 0 ) { - qWarning( "Cannot convert string using iconv" ); + tqWarning( "Cannot convert string using iconv" ); return false; } if ( device.writeBlock( m_iconvBuffer, m_iconvBufferSize - outputdatasize ) != ( int )( m_iconvBufferSize - outputdatasize ) ) { - qWarning( "Cannot write string to device" ); + tqWarning( "Cannot write string to device" ); return false; } return true; } - void FileExporterBibTeX::setStringDelimiter( const QChar& stringOpenDelimiter, const QChar& stringCloseDelimiter ) + void FileExporterBibTeX::setStringDelimiter( const TQChar& stringOpenDelimiter, const TQChar& stringCloseDelimiter ) { m_stringOpenDelimiter = stringOpenDelimiter; m_stringCloseDelimiter = stringCloseDelimiter; @@ -283,7 +283,7 @@ namespace BibTeX m_keywordCasing = keywordCasing; } - void FileExporterBibTeX::setEncoding( const QString& encoding ) + void FileExporterBibTeX::setEncoding( const TQString& encoding ) { m_encoding = encoding; } @@ -293,16 +293,16 @@ namespace BibTeX m_protectCasing = protectCasing; } - QString FileExporterBibTeX::valueToString( const Value *value, const EntryField::FieldType fieldType, const QString &fieldTypeName ) + TQString FileExporterBibTeX::valueToString( const Value *value, const EntryField::FieldType fieldType, const TQString &fieldTypeName ) { if ( value == NULL ) return ""; - QString result; + TQString result; bool isFirst = TRUE; EncoderLaTeX *encoder = EncoderLaTeX::currentEncoderLaTeX(); - for ( QValueList::ConstIterator it = value->items.begin(); it != value->items.end(); ++it ) + for ( TQValueList::ConstIterator it = value->items.begin(); it != value->items.end(); ++it ) { if ( !isFirst ) result.append( " # " ); @@ -314,7 +314,7 @@ namespace BibTeX result.append( macroKey->text() ); else { - QString text; + TQString text; BibTeX::PersonContainer *personContainer = dynamic_cast( *it ); BibTeX::PlainText *plainText = dynamic_cast( *it ); BibTeX::KeywordContainer *keywordContainer = dynamic_cast( *it ); @@ -324,7 +324,7 @@ namespace BibTeX else if ( keywordContainer != NULL ) { bool first = TRUE; - for ( QValueList::Iterator it = keywordContainer->keywords.begin(); it != keywordContainer->keywords.end(); ++it ) + for ( TQValueList::Iterator it = keywordContainer->keywords.begin(); it != keywordContainer->keywords.end(); ++it ) { if ( !first ) text.append( ", " ); @@ -336,14 +336,14 @@ namespace BibTeX else if ( personContainer != NULL ) { bool first = TRUE; - for ( QValueList::Iterator it = personContainer->persons.begin(); it != personContainer->persons.end(); ++it ) + for ( TQValueList::Iterator it = personContainer->persons.begin(); it != personContainer->persons.end(); ++it ) { if ( !first ) text.append( " and " ); else first = FALSE; - QString v = ( *it )->firstName(); + TQString v = ( *it )->firstName(); if ( !v.isEmpty() ) { bool requiresQuoting = requiresPersonQuoting( v, FALSE ); @@ -367,12 +367,12 @@ namespace BibTeX * Thus we split the von-Parts from the surname (= everything after the first upcase char). * FIXME: Make the personContainer aware of von-Parts and jr-Parts, instead. */ - QStringList list = QStringList::split( " ", v ); - QString von; - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) + TQStringList list = TQStringList::split( " ", v ); + TQString von; + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { - QString str = *it; - if ( str != "others" && str[0].category() == QChar::Letter_Lowercase ) + TQString str = *it; + if ( str != "others" && str[0].category() == TQChar::Letter_Lowercase ) { von += *it; von += " "; @@ -404,8 +404,8 @@ namespace BibTeX * as quote chars as string delimiters would result * in parser failures */ - QChar stringOpenDelimiter = m_stringOpenDelimiter; - QChar stringCloseDelimiter = m_stringCloseDelimiter; + TQChar stringOpenDelimiter = m_stringOpenDelimiter; + TQChar stringCloseDelimiter = m_stringCloseDelimiter; if ( text.contains( '"' ) && ( m_stringOpenDelimiter == '"' || m_stringCloseDelimiter == '"' ) ) { stringOpenDelimiter = '{'; @@ -419,12 +419,12 @@ namespace BibTeX return result; } - void FileExporterBibTeX::removeBackslashQuoting( QString &text ) + void FileExporterBibTeX::removeBackslashQuoting( TQString &text ) { text.replace( "\\&", "&" ).replace( "\\#", "#" ).replace( "\\_", "_" ).replace( "\\%", "%" ); } - QString FileExporterBibTeX::applyKeywordCasing( const QString &keyword ) + TQString FileExporterBibTeX::applyKeywordCasing( const TQString &keyword ) { switch ( m_keywordCasing ) { @@ -435,12 +435,12 @@ namespace BibTeX } } - bool FileExporterBibTeX::requiresPersonQuoting( const QString &text, bool isLastName ) + bool FileExporterBibTeX::requiresPersonQuoting( const TQString &text, bool isLastName ) { if ( isLastName && !text.contains( " " ) ) /** Last name contains NO spaces, no quoting necessary */ return FALSE; - else if ( isLastName && text[0].category() == QChar::Letter_Lowercase ) + else if ( isLastName && text[0].category() == TQChar::Letter_Lowercase ) /** Last name starts with lower case character (e.g. as in "van der Linden") */ return FALSE; else if ( !isLastName && !text.contains( " and " ) ) @@ -464,7 +464,7 @@ namespace BibTeX return FALSE; } - void FileExporterBibTeX::addProtectiveCasing( QString &text ) + void FileExporterBibTeX::addProtectiveCasing( TQString &text ) { if (( text[0] != '"' || text[text.length()-1] != '"' ) && ( text[0] != '{' || text[text.length()-1] != '}' ) ) { -- cgit v1.2.3