diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:51:49 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:51:49 +0000 |
commit | 4ae0c208b66e0f7954e194384464fe2d0a2c56dd (patch) | |
tree | b0a7cd1c184f0003c0292eb416ed27f674f9cc43 /kbabel/filters/gettext/gettextimport.cpp | |
parent | 1964ea0fb4ab57493ca2ebb709c8d3b5395fd653 (diff) | |
download | tdesdk-4ae0c208b66e0f7954e194384464fe2d0a2c56dd.tar.gz tdesdk-4ae0c208b66e0f7954e194384464fe2d0a2c56dd.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1157652 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbabel/filters/gettext/gettextimport.cpp')
-rw-r--r-- | kbabel/filters/gettext/gettextimport.cpp | 208 |
1 files changed, 104 insertions, 104 deletions
diff --git a/kbabel/filters/gettext/gettextimport.cpp b/kbabel/filters/gettext/gettextimport.cpp index 3f54301d..9210c1a9 100644 --- a/kbabel/filters/gettext/gettextimport.cpp +++ b/kbabel/filters/gettext/gettextimport.cpp @@ -39,10 +39,10 @@ #include <catalogitem.h> #include <resources.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qregexp.h> -#include <qtextcodec.h> +#include <tqfile.h> +#include <tqfileinfo.h> +#include <tqregexp.h> +#include <tqtextcodec.h> #include <kapplication.h> #include <kdebug.h> @@ -53,11 +53,11 @@ K_EXPORT_COMPONENT_FACTORY( kbabel_gettextimport, KGenericFactory<GettextImportP using namespace KBabel; -GettextImportPlugin::GettextImportPlugin(QObject* parent, const char* name, const QStringList &) : CatalogImportPlugin(parent,name) +GettextImportPlugin::GettextImportPlugin(TQObject* parent, const char* name, const TQStringList &) : CatalogImportPlugin(parent,name) { } -ConversionStatus GettextImportPlugin::load(const QString& filename, const QString&) +ConversionStatus GettextImportPlugin::load(const TQString& filename, const TQString&) { kdDebug( KBABEL ) << k_funcinfo << endl; @@ -66,7 +66,7 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin return NO_FILE; } - QFileInfo info(filename); + TQFileInfo info(filename); if(!info.exists() || info.isDir()) return NO_FILE; @@ -74,7 +74,7 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin if(!info.isReadable()) return NO_PERMISSIONS; - QFile file(filename); + TQFile file(filename); if ( !file.open( IO_ReadOnly ) ) return NO_PERMISSIONS; @@ -82,23 +82,23 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin uint oldPercent = 0; emit signalResetProgressBar(i18n("loading file"),100); - QByteArray ba = file.readAll(); + TQByteArray ba = file.readAll(); file.close(); // find codec for file bool hadCodec; - QTextCodec* codec=codecForArray( ba, &hadCodec ); + TQTextCodec* codec=codecForArray( ba, &hadCodec ); bool recoveredErrorInHeader = false; - QTextStream stream(ba,IO_ReadOnly); + TQTextStream stream(ba,IO_ReadOnly); if(codec) stream.setCodec(codec); else { kdWarning() << "No encoding declared or found, using UTF-8" << endl; - stream.setEncoding( QTextStream::UnicodeUTF8 ); + stream.setEncoding( TQTextStream::UnicodeUTF8 ); #ifdef __GNUC__ # warning Default UTF-8 encoding needs to be improved #endif @@ -106,12 +106,12 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin //recoveredErrorInHeader = true; } - QIODevice *dev = stream.device(); + TQIODevice *dev = stream.device(); int fileSize = dev->size(); // if somethings goes wrong with the parsing, we don't have deleted the old contents CatalogItem tempHeader; - QStringList tempObsolete; + TQStringList tempObsolete; kdDebug(KBABEL) << "start parsing..." << endl; @@ -139,15 +139,15 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin { // The header must have an empty msgid kdWarning(KBABEL) << "Header entry has non-empty msgid. Creating a temporary header! " << _msgid << endl; - tempHeader.setMsgid( QStringList() ); - QStringList tmp; + tempHeader.setMsgid( TQStringList() ); + TQStringList tmp; tmp.append( "Content-Type: text/plain; charset=UTF-8\\n" // Unknown charset "Content-Transfer-Encoding: 8bit\\n" "Mime-Version: 1.0" ); tempHeader.setMsgstr( tmp ); // We keep the comment of the first entry, as it might really be a header comment (at least partially) - const QString comment( "# Header entry was created by KBabel!\n#\n" + _comment ); + const TQString comment( "# Header entry was created by KBabel!\n#\n" + _comment ); tempHeader.setComment( comment ); recoveredErrorInHeader = true; } @@ -167,7 +167,7 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin // now parse the rest of the file uint counter=0; - QValueList<uint> errorIndex; + TQValueList<uint> errorIndex; bool recoveredError=false; bool docbookFile=false; @@ -289,17 +289,17 @@ ConversionStatus GettextImportPlugin::load(const QString& filename, const QStrin } } -QTextCodec* GettextImportPlugin::codecForArray(QByteArray& array, bool* hadCodec) +TQTextCodec* GettextImportPlugin::codecForArray(TQByteArray& array, bool* hadCodec) { if(hadCodec) { *hadCodec=false; } - QTextStream stream( array, IO_ReadOnly ); - // ### TODO Qt4: see if it can be done with QByteArray alone, in an encoding-neutral way. + TQTextStream stream( array, IO_ReadOnly ); + // ### TODO Qt4: see if it can be done with TQByteArray alone, in an encoding-neutral way. // Set ISO-8859-1 as it is a relatively neutral encoding when reading (compared to UTF-8 or a random locale encoing) - stream.setEncoding( QTextStream::Latin1 ); + stream.setEncoding( TQTextStream::Latin1 ); // first read header ConversionStatus status = readHeader(stream); @@ -309,19 +309,19 @@ QTextCodec* GettextImportPlugin::codecForArray(QByteArray& array, bool* hadCodec return 0; } - const QString head = _msgstr.first(); + const TQString head = _msgstr.first(); - QRegExp regexp("Content-Type:\\s*\\w+/[-\\w]+;?\\s*charset\\s*=\\s*(\\S+)\\s*\\\\n"); + TQRegExp regexp("Content-Type:\\s*\\w+/[-\\w]+;?\\s*charset\\s*=\\s*(\\S+)\\s*\\\\n"); if( regexp.search( head ) == -1 ) { kdDebug(KBABEL) << "no charset entry found" << endl; return 0; } - const QString charset = regexp.cap(1); + const TQString charset = regexp.cap(1); kdDebug(KBABEL) << "charset: " << charset << endl; - QTextCodec* codec=0; + TQTextCodec* codec=0; if(!charset.isEmpty()) { @@ -333,14 +333,14 @@ QTextCodec* GettextImportPlugin::codecForArray(QByteArray& array, bool* hadCodec if(hadCodec) *hadCodec=false; - codec=QTextCodec::codecForName("utf8"); + codec=TQTextCodec::codecForName("utf8"); kdDebug(KBABEL) - << QString("file seems to be a template: using utf-8 encoding.") + << TQString("file seems to be a template: using utf-8 encoding.") << endl; } else { - codec=QTextCodec::codecForName(charset.latin1()); + codec=TQTextCodec::codecForName(charset.latin1()); if(hadCodec) *hadCodec=true; } @@ -360,7 +360,7 @@ QTextCodec* GettextImportPlugin::codecForArray(QByteArray& array, bool* hadCodec return codec; } -ConversionStatus GettextImportPlugin::readHeader(QTextStream& stream) +ConversionStatus GettextImportPlugin::readHeader(TQTextStream& stream) { CatalogItem temp; int filePos=stream.device()->at(); @@ -380,25 +380,25 @@ ConversionStatus GettextImportPlugin::readHeader(QTextStream& stream) return PARSE_ERROR; } -ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) +ConversionStatus GettextImportPlugin::readEntry(TQTextStream& stream) { //kdDebug( KBABEL ) << k_funcinfo << " START" << endl; enum {Begin,Comment,Msgctxt,Msgid,Msgstr} part=Begin; - QString line; + TQString line; bool error=false; bool recoverableError=false; bool seenMsgctxt=false; _msgstr.clear(); - _msgstr.append(QString()); + _msgstr.append(TQString()); _msgid.clear(); - _msgid.append(QString()); - _msgctxt=QString(); - _comment=QString(); + _msgid.append(TQString()); + _msgctxt=TQString(); + _comment=TQString(); _gettextPluralForm=false; _obsolete=false; - QStringList::Iterator msgstrIt=_msgstr.begin(); + TQStringList::Iterator msgstrIt=_msgstr.begin(); while( !stream.eof() ) { @@ -439,34 +439,34 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) part=Comment; _comment=line; } - else if(line.find(QRegExp("^msgctxt\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgctxt\\s*\".*\"$")) != -1) { part=Msgctxt; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgctxt\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgctxt\\s*\"")); + line.remove(TQRegExp("\"$")); _msgctxt=line; seenMsgctxt=true; } - else if(line.find(QRegExp("^msgid\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\".*\"$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; } // one of the quotation marks is missing - else if(line.find(QRegExp("^msgid\\s*\"?.*\"?$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\"?.*\"?$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"?")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; @@ -494,34 +494,34 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) { _comment+=("\n"+line); } - else if(line.find(QRegExp("^msgctxt\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgctxt\\s*\".*\"$")) != -1) { part=Msgctxt; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgctxt\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgctxt\\s*\"")); + line.remove(TQRegExp("\"$")); _msgctxt=line; seenMsgctxt=true; } - else if(line.find(QRegExp("^msgid\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\".*\"$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; } // one of the quotation marks is missing - else if(line.find(QRegExp("^msgid\\s*\"?.*\"?$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\"?.*\"?$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"?")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; @@ -539,11 +539,11 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) { if(line.isEmpty()) continue; - else if(line.find(QRegExp("^\".*\\n?\"$")) != -1) + else if(line.find(TQRegExp("^\".*\\n?\"$")) != -1) { // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^\"")); + line.remove(TQRegExp("\"$")); // add Msgctxt line to item if(_msgctxt.isEmpty()) @@ -551,24 +551,24 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) else _msgctxt+=("\n"+line); } - else if(line.find(QRegExp("^msgid\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\".*\"$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; } // one of the quotation marks is missing - else if(line.find(QRegExp("^msgid\\s*\"?.*\"?$")) != -1) + else if(line.find(TQRegExp("^msgid\\s*\"?.*\"?$")) != -1) { part=Msgid; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid\\s*\"?")); + line.remove(TQRegExp("\"$")); (*(_msgid).begin())=line; @@ -586,13 +586,13 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) { if(line.isEmpty()) continue; - else if(line.find(QRegExp("^\".*\\n?\"$")) != -1) + else if(line.find(TQRegExp("^\".*\\n?\"$")) != -1) { // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^\"")); + line.remove(TQRegExp("\"$")); - QStringList::Iterator it; + TQStringList::Iterator it; if(_gettextPluralForm) it = _msgid.fromLast(); else @@ -604,26 +604,26 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) else (*it)+=("\n"+line); } - else if(line.find(QRegExp("^msgid_plural\\s*\".*\"$")) != -1) + else if(line.find(TQRegExp("^msgid_plural\\s*\".*\"$")) != -1) { part=Msgid; _gettextPluralForm = true; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid_plural\\s*\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid_plural\\s*\"")); + line.remove(TQRegExp("\"$")); _msgid.append(line); } // one of the quotation marks is missing - else if(line.find(QRegExp("^msgid_plural\\s*\"?.*\"?$")) != -1) + else if(line.find(TQRegExp("^msgid_plural\\s*\"?.*\"?$")) != -1) { part=Msgid; _gettextPluralForm = true; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgid_plural\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgid_plural\\s*\"?")); + line.remove(TQRegExp("\"$")); _msgid.append(line); @@ -631,24 +631,24 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) recoverableError=true; } else if(!_gettextPluralForm - && (line.find(QRegExp("^msgstr\\s*\".*\\n?\"$")) != -1)) + && (line.find(TQRegExp("^msgstr\\s*\".*\\n?\"$")) != -1)) { part=Msgstr; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\s*\"?")); + line.remove(TQRegExp("\"$")); (*msgstrIt)=line; } else if(!_gettextPluralForm - && line.find(QRegExp("^msgstr\\s*\"?.*\\n?\"?$")) != -1) + && line.find(TQRegExp("^msgstr\\s*\"?.*\\n?\"?$")) != -1) { part=Msgstr; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\s*\"?")); + line.remove(TQRegExp("\"$")); (*msgstrIt)=line; @@ -656,24 +656,24 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) recoverableError=true; } else if( _gettextPluralForm - && (line.find(QRegExp("^msgstr\\[0\\]\\s*\".*\\n?\"$")) != -1)) + && (line.find(TQRegExp("^msgstr\\[0\\]\\s*\".*\\n?\"$")) != -1)) { part=Msgstr; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\[0\\]\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\[0\\]\\s*\"?")); + line.remove(TQRegExp("\"$")); (*msgstrIt)=line; } else if( _gettextPluralForm - && (line.find(QRegExp("^msgstr\\[0\\]\\s*\"?.*\\n?\"?$")) != -1)) + && (line.find(TQRegExp("^msgstr\\[0\\]\\s*\"?.*\\n?\"?$")) != -1)) { part=Msgstr; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\[0\\]\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\[0\\]\\s*\"?")); + line.remove(TQRegExp("\"$")); (*msgstrIt)=line; @@ -694,15 +694,15 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) break; } // a line of the msgid with a missing quotation mark - else if(line.find(QRegExp("^\"?.+\\n?\"?$")) != -1) + else if(line.find(TQRegExp("^\"?.+\\n?\"?$")) != -1) { recoverableError=true; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^\"")); + line.remove(TQRegExp("\"$")); - QStringList::Iterator it; + TQStringList::Iterator it; if( _gettextPluralForm ) it = _msgid.fromLast(); else @@ -726,11 +726,11 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) if(line.isEmpty()) continue; // another line of the msgstr - else if(line.find(QRegExp("^\".*\\n?\"$")) != -1) + else if(line.find(TQRegExp("^\".*\\n?\"$")) != -1) { // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^\"")); + line.remove(TQRegExp("\"$")); if((*msgstrIt).isEmpty()) (*msgstrIt)=line; @@ -738,27 +738,27 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) (*msgstrIt)+=("\n"+line); } else if( _gettextPluralForm - && (line.find(QRegExp("^msgstr\\[[0-9]+\\]\\s*\".*\\n?\"$")) != -1)) + && (line.find(TQRegExp("^msgstr\\[[0-9]+\\]\\s*\".*\\n?\"$")) != -1)) { // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\[[0-9]+\\]\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\[[0-9]+\\]\\s*\"?")); + line.remove(TQRegExp("\"$")); msgstrIt=_msgstr.append(line); } else if( _gettextPluralForm - && (line.find(QRegExp("^msgstr\\[[0-9]\\]\\s*\"?.*\\n?\"?$")) != -1)) + && (line.find(TQRegExp("^msgstr\\[[0-9]\\]\\s*\"?.*\\n?\"?$")) != -1)) { // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^msgstr\\[[0-9]\\]\\s*\"?")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^msgstr\\[[0-9]\\]\\s*\"?")); + line.remove(TQRegExp("\"$")); msgstrIt=_msgstr.append(line); if(!line.isEmpty()) recoverableError=true; } - else if((line.find(QRegExp("^\\s*msgid")) != -1) || (line.find(QRegExp("^\\s*#")) != -1)) + else if((line.find(TQRegExp("^\\s*msgid")) != -1) || (line.find(TQRegExp("^\\s*#")) != -1)) { // We have read successfully one entry, so end loop. stream.device()->at(pos);// reset position in stream to beginning of this line @@ -771,13 +771,13 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) break; } // another line of the msgstr with a missing quotation mark - else if(line.find(QRegExp("^\"?.+\\n?\"?$")) != -1) + else if(line.find(TQRegExp("^\"?.+\\n?\"?$")) != -1) { recoverableError=true; // remove quotes at beginning and the end of the lines - line.remove(QRegExp("^\"")); - line.remove(QRegExp("\"$")); + line.remove(TQRegExp("^\"")); + line.remove(TQRegExp("\"$")); if((*msgstrIt).isEmpty()) (*msgstrIt)=line; @@ -800,7 +800,7 @@ ConversionStatus GettextImportPlugin::readEntry(QTextStream& stream) << "msgid:\n" << _msgid.first() << "\n" << "msgid_plural:\n" << _msgid.last() << "\n" << endl; int counter=0; - for(QStringList::Iterator it = _msgstr.begin(); it != _msgstr.end(); ++it) + for(TQStringList::Iterator it = _msgstr.begin(); it != _msgstr.end(); ++it) { kdDebug(KBABEL) << "msgstr[" << counter << "]:\n" << (*it) << endl; |