summaryrefslogtreecommitdiffstats
path: root/kbabel/common/poinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kbabel/common/poinfo.cpp')
-rw-r--r--kbabel/common/poinfo.cpp172
1 files changed, 86 insertions, 86 deletions
diff --git a/kbabel/common/poinfo.cpp b/kbabel/common/poinfo.cpp
index b7beba7d..68e13da8 100644
--- a/kbabel/common/poinfo.cpp
+++ b/kbabel/common/poinfo.cpp
@@ -42,13 +42,13 @@
#include <kstandarddirs.h>
#include <ksavefile.h>
-#include <qdatastream.h>
-#include <qdatetime.h>
-#include <qdict.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qregexp.h>
-#include <qtextcodec.h>
+#include <tqdatastream.h>
+#include <tqdatetime.h>
+#include <tqdict.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqregexp.h>
+#include <tqtextcodec.h>
#include "libgettext/pofiles.h"
#include "libgettext/tokens.h"
@@ -61,10 +61,10 @@ using namespace KBabel;
struct poInfoCacheItem
{
PoInfo info;
- QDateTime lastModified;
+ TQDateTime lastModified;
};
-inline QDataStream& operator << ( QDataStream& stream, poInfoCacheItem* item )
+inline TQDataStream& operator << ( TQDataStream& stream, poInfoCacheItem* item )
{
// Note: if you change anything here, do not forget to increase the #define POINFOCACHE_VERSION
stream << item->info.total;
@@ -84,7 +84,7 @@ inline QDataStream& operator << ( QDataStream& stream, poInfoCacheItem* item )
return stream;
}
-inline QDataStream& operator >> ( QDataStream& stream, poInfoCacheItem* item )
+inline TQDataStream& operator >> ( TQDataStream& stream, poInfoCacheItem* item )
{
stream >> item->info.total;
stream >> item->info.fuzzy;
@@ -104,10 +104,10 @@ inline QDataStream& operator >> ( QDataStream& stream, poInfoCacheItem* item )
}
// Cache of PO-file items
-static QDict<poInfoCacheItem> _poInfoCache;
+static TQDict<poInfoCacheItem> _poInfoCache;
// File name of cache
-static QString _poInfoCacheName;
+static TQString _poInfoCacheName;
// flag to stop current reading
bool PoInfo::stopStaticRead;
@@ -117,9 +117,9 @@ bool PoInfo::_gettextPluralForm;
// Note: We only read the cache file if the data seems usable. If not, we will re-generate the data.
void PoInfo::cacheRead()
{
- QFile cacheFile( _poInfoCacheName );
+ TQFile cacheFile( _poInfoCacheName );
if( cacheFile.open( IO_ReadOnly ) ) {
- QDataStream s( &cacheFile );
+ TQDataStream s( &cacheFile );
// Check the file cache version.
// If it is not the current version, we do not read the cache file
@@ -132,13 +132,13 @@ void PoInfo::cacheRead()
}
/*
- * Check the version of the QDataStream with which the cache file was written
+ * Check the version of the TQDataStream with which the cache file was written
*
* If the cache file was written by an incompatible future version of Qt,
* the cache file will not be read.
*
* On the other side, a cache file written by a previous version of Qt can be read,
- * by setting the version of the QDataStream used.
+ * by setting the version of the TQDataStream used.
*/
Q_INT32 qdatastreamVersion;
s >> qdatastreamVersion;
@@ -146,12 +146,12 @@ void PoInfo::cacheRead()
s.setVersion( qdatastreamVersion );
}
else {
- // QDataStream version seems stupid, so abort
- kdDebug(KBABEL) << "Wrong QDataStream version: " << qdatastreamVersion << endl;
+ // TQDataStream version seems stupid, so abort
+ kdDebug(KBABEL) << "Wrong TQDataStream version: " << qdatastreamVersion << endl;
return;
}
- QString url;
+ TQString url;
while( !s.atEnd() ) {
poInfoCacheItem* item = new poInfoCacheItem;
s >> url;
@@ -168,7 +168,7 @@ void PoInfo::cacheWrite()
// (especially if two instances would write into the same cache file)
KSaveFile cacheFile( _poInfoCacheName );
- QDataStream* stream = cacheFile.dataStream();
+ TQDataStream* stream = cacheFile.dataStream();
if( stream ) {
@@ -182,9 +182,9 @@ void PoInfo::cacheWrite()
const Q_INT32 qdatastreamVersion = stream->version();
*stream << qdatastreamVersion;
- QDictIterator<poInfoCacheItem> it( _poInfoCache ); // iterator for dict
+ TQDictIterator<poInfoCacheItem> it( _poInfoCache ); // iterator for dict
for ( ; it.current(); ++it ) {
- if( QFile::exists( it.currentKey() ) ) {
+ if( TQFile::exists( it.currentKey() ) ) {
*stream << it.currentKey();
*stream << it.current();
}
@@ -194,12 +194,12 @@ void PoInfo::cacheWrite()
}
}
else {
- kdWarning(KBABEL) << "Could not create QDataStream for cache file: " << _poInfoCacheName << endl;
+ kdWarning(KBABEL) << "Could not create TQDataStream for cache file: " << _poInfoCacheName << endl;
cacheFile.abort();
}
}
-bool PoInfo::cacheFind(const QString url, PoInfo& info)
+bool PoInfo::cacheFind(const TQString url, PoInfo& info)
{
// Read cache if it has not been read, and set up post routine to write it
static bool _cacheIsRead = false;
@@ -211,7 +211,7 @@ bool PoInfo::cacheFind(const QString url, PoInfo& info)
poInfoCacheItem *item = _poInfoCache.find( url );
if( item ) {
- QFileInfo fi( url );
+ TQFileInfo fi( url );
if( fi.lastModified() == item->lastModified ) {
info = item->info;
@@ -221,29 +221,29 @@ bool PoInfo::cacheFind(const QString url, PoInfo& info)
return false;
}
-void PoInfo::cacheSave(const QString url, PoInfo& info)
+void PoInfo::cacheSave(const TQString url, PoInfo& info)
{
poInfoCacheItem *item = new poInfoCacheItem;
- QFileInfo fi( url );
+ TQFileInfo fi( url );
item->info = info;
item->lastModified = fi.lastModified();
_poInfoCache.insert( url, item );
}
-QTextCodec* PoInfo::codecForFile(QString gettextHeader)
+TQTextCodec* PoInfo::codecForFile(TQString gettextHeader)
{
- 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(gettextHeader) == -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())
{
@@ -252,27 +252,27 @@ QTextCodec* PoInfo::codecForFile(QString gettextHeader)
// at least utf8, so utf8-codec can be used for both.
if( charset == "CHARSET")
{
- codec=QTextCodec::codecForName("utf8");
+ codec=TQTextCodec::codecForName("utf8");
kdDebug(KBABEL)
- << QString("file seems to be a template: using utf8 encoding.")
+ << TQString("file seems to be a template: using utf8 encoding.")
<< endl;
}
else
{
- codec=QTextCodec::codecForName(charset.latin1());
+ codec=TQTextCodec::codecForName(charset.latin1());
}
if(!codec)
{
kdWarning(KBABEL) << "charset found, but no codec available, using UTF8 instead" << endl;
- codec=QTextCodec::codecForName("utf8");
+ codec=TQTextCodec::codecForName("utf8");
}
}
else
{
// No charset? So it is probably ASCII, therefore UTF-8
kdWarning(KBABEL) << "No charset defined! Assuming UTF-8!" << endl;
- codec=QTextCodec::codecForName("utf8");
+ codec=TQTextCodec::codecForName("utf8");
}
return codec;
@@ -285,12 +285,12 @@ PoInfo PoInfo::headerInfo(const CatalogItem& headerItem)
// Note that the "line" defined by the \n can be different than the line of the file.
// We join all lines of the header and then split the result again at the \n sequence
- const QStringList header=QStringList::split("\\n",headerItem.msgstrAsList().join(QString()));
+ const TQStringList header=TQStringList::split("\\n",headerItem.msgstrAsList().join(TQString()));
PoInfo info;
// extract information from the header
- QStringList::const_iterator it;
+ TQStringList::const_iterator it;
// The header of a Gettext .po file is consisted of lines of key and value
for(it=header.begin();it!=header.end();++it)
@@ -301,8 +301,8 @@ PoInfo PoInfo::headerInfo(const CatalogItem& headerItem)
if (res>=0)
{
knownKey=true; // We know most keys, if not it will be changed to false in the "else" case
- const QString key=(*it).left(res).simplifyWhiteSpace();
- QString value=(*it).mid(res+1);
+ const TQString key=(*it).left(res).simplifyWhiteSpace();
+ TQString value=(*it).mid(res+1);
// "Chop" the \n at the end
if (value.endsWith("\\n"))
value.remove(value.length()-2,2); // ### Qt4: use value.chop(2)
@@ -332,7 +332,7 @@ PoInfo PoInfo::headerInfo(const CatalogItem& headerItem)
}
if (!knownKey)
{
- QString line=(*it);
+ TQString line=(*it);
if(line.right(2)=="\\n")
line.remove(line.length()-2,2); // ### Qt4: use value.chop(2)
@@ -350,28 +350,28 @@ PoInfo PoInfo::headerInfo(const CatalogItem& headerItem)
}
-ConversionStatus PoInfo::info(const QString& url, PoInfo& info, QStringList &wordList, bool updateWordList, bool interactive)
+ConversionStatus PoInfo::info(const TQString& url, PoInfo& info, TQStringList &wordList, bool updateWordList, bool interactive)
{
return PoInfo::info( url, info, wordList, updateWordList, interactive, true);
}
-ConversionStatus PoInfo::info(const QString& url, PoInfo& info, QStringList &wordList, bool updateWordList, bool interactive, bool msgfmt)
+ConversionStatus PoInfo::info(const TQString& url, PoInfo& info, TQStringList &wordList, bool updateWordList, bool interactive, bool msgfmt)
{
stopStaticRead = false;
if( !updateWordList && PoInfo::cacheFind( url, info ) )
return OK;
- QString target;
+ TQString target;
if(KIO::NetAccess::download(KURL( url ), target, 0))
{
- QFile file(target);
+ TQFile file(target);
if ( msgfmt )
{
// First check file with msgfmt to be sure, it is syntactically correct
Msgfmt msgfmt;
- QString output;
+ TQString output;
Msgfmt::Status stat = msgfmt.checkSyntax( target , output );
if(stat == Msgfmt::SyntaxError)
{
@@ -422,7 +422,7 @@ ConversionStatus PoInfo::info(const QString& url, PoInfo& info, QStringList &wor
if( temp.isFuzzy() ) temp.removeFuzzy();
//find out the codec
- QTextCodec* codec = codecForFile( temp.msgstr().first() );
+ TQTextCodec* codec = codecForFile( temp.msgstr().first() );
if( !codec ) return PARSE_ERROR;
// convert from UTF-8 using codec
@@ -447,27 +447,27 @@ ConversionStatus PoInfo::info(const QString& url, PoInfo& info, QStringList &wor
if( updateWordList )
{
// FIXME: should care about plural forms in msgid
- QString st = temp.msgid().first().simplifyWhiteSpace().lower();
- QStringList sl = QStringList::split( ' ', st );
+ TQString st = temp.msgid().first().simplifyWhiteSpace().lower();
+ TQStringList sl = TQStringList::split( ' ', st );
while(!sl.isEmpty())
{
- QString w = sl.first();
+ TQString w = sl.first();
sl.pop_front();
if( !wordList.contains(w) ) wordList.append( w );
}
st = temp.msgstr().join(" " ).simplifyWhiteSpace().lower();
- sl = QStringList::split( ' ', st );
+ sl = TQStringList::split( ' ', st );
while(!sl.isEmpty())
{
- QString w = sl.first();
+ TQString w = sl.first();
sl.pop_front();
if( !wordList.contains(w) ) wordList.append( w );
}
st = temp.comment().simplifyWhiteSpace().lower();
- sl = QStringList::split( ' ', st );
+ sl = TQStringList::split( ' ', st );
while(!sl.isEmpty())
{
- QString w = sl.first();
+ TQString w = sl.first();
sl.pop_front();
if( !wordList.contains(w) ) wordList.append( w );
}
@@ -504,12 +504,12 @@ ConversionStatus PoInfo::info(const QString& url, PoInfo& info, QStringList &wor
return OK;
}
-bool PoInfo::findInFile( const QString& url, FindOptions options )
+bool PoInfo::findInFile( const TQString& url, FindOptions options )
{
enum {Begin, Comment, Msgid, Msgstr, Msgctxt} part = Begin;
stopStaticRead = false;
- QString target;
+ TQString target;
if(KIO::NetAccess::download(KURL( url ), target, 0))
{
std::ifstream* stream = new std::ifstream( target.local8Bit());
@@ -523,8 +523,8 @@ bool PoInfo::findInFile( const QString& url, FindOptions options )
// prepare the search
- QString searchStr = options.findStr;
- QRegExp regexp( searchStr );
+ TQString searchStr = options.findStr;
+ TQRegExp regexp( searchStr );
if( options.isRegExp )
regexp.setCaseSensitive( options.caseSensitive );
@@ -540,14 +540,14 @@ bool PoInfo::findInFile( const QString& url, FindOptions options )
return false; // header is not at the beginning, broken file
}
- QTextCodec* codec = codecForFile( temp.msgstr().first() );
+ TQTextCodec* codec = codecForFile( temp.msgstr().first() );
if( !codec )
{
return false;
}
// now parse the rest of the file
- QString text;
+ TQString text;
int pos,len;
while(lexer->lastToken != T_EOF)
@@ -565,10 +565,10 @@ bool PoInfo::findInFile( const QString& url, FindOptions options )
{
if( options.wholeWords) {
len = searchStr.length();
- QString pre = text.mid(pos-1,1);
- QString post = text.mid(pos+len,1);
- if( !pre.contains( QRegExp("[a-zA-Z0-9]")) &&
- !post.contains( QRegExp("[a-zA-Z0-9]") )
+ TQString pre = text.mid(pos-1,1);
+ TQString post = text.mid(pos+len,1);
+ if( !pre.contains( TQRegExp("[a-zA-Z0-9]")) &&
+ !post.contains( TQRegExp("[a-zA-Z0-9]") )
) {
delete lexer;
delete stream;
@@ -615,10 +615,10 @@ bool PoInfo::findInFile( const QString& url, FindOptions options )
{
if( options.wholeWords) {
len = searchStr.length();
- QString pre = text.mid(pos-1,1);
- QString post = text.mid(pos+len,1);
- if( !pre.contains( QRegExp("[a-zA-Z0-9]")) &&
- !post.contains( QRegExp("[a-zA-Z0-9]") )
+ TQString pre = text.mid(pos-1,1);
+ TQString post = text.mid(pos+len,1);
+ if( !pre.contains( TQRegExp("[a-zA-Z0-9]")) &&
+ !post.contains( TQRegExp("[a-zA-Z0-9]") )
) {
delete lexer;
delete stream;
@@ -674,9 +674,9 @@ ConversionStatus PoInfo::fastRead( CatalogItem& item, GettextFlexLexer *lexer, b
// comment
if( lexer->lastToken == T_COMMENT )
{
- QString _comment = QString::fromUtf8(lexer->YYText());
+ TQString _comment = TQString::fromUtf8(lexer->YYText());
while( lexer->yylex() == T_COMMENT )
- _comment += "\n"+QString::fromUtf8(lexer->YYText());
+ _comment += "\n"+TQString::fromUtf8(lexer->YYText());
item.setComment( _comment );
// kdDebug(KBABEL) << "Comment: " << _comment << endl;
}
@@ -700,12 +700,12 @@ ConversionStatus PoInfo::fastRead( CatalogItem& item, GettextFlexLexer *lexer, b
if( lexer->lastToken != T_MSGID ) return PARSE_ERROR;
if( lexer->yylex() != T_STRING ) return PARSE_ERROR;
- QStringList msgids = item.msgid();
- QStringList::Iterator it = msgids.begin();
- *it = QString::fromUtf8(lexer->YYText());
+ TQStringList msgids = item.msgid();
+ TQStringList::Iterator it = msgids.begin();
+ *it = TQString::fromUtf8(lexer->YYText());
if( storeText )
while( lexer->yylex() == T_STRING )
- (*it) += ("\n"+ QString::fromUtf8(lexer->YYText()) );
+ (*it) += ("\n"+ TQString::fromUtf8(lexer->YYText()) );
else {
if( lexer->yylex() == T_STRING ) // this is not header
{
@@ -721,12 +721,12 @@ ConversionStatus PoInfo::fastRead( CatalogItem& item, GettextFlexLexer *lexer, b
{
_gettextPluralForm = true;
if( lexer->yylex() != T_STRING ) return PARSE_ERROR;
- QStringList msgids = item.msgid();
+ TQStringList msgids = item.msgid();
it = msgids.fromLast();
- *it = QString::fromUtf8(lexer->YYText());
+ *it = TQString::fromUtf8(lexer->YYText());
if( storeText )
while( lexer->yylex() == T_STRING )
- (*it)+="\n"+ QString::fromUtf8(lexer->YYText());
+ (*it)+="\n"+ TQString::fromUtf8(lexer->YYText());
else while( lexer->yylex() == T_STRING );
item.setMsgid( msgids );
// kdDebug(KBABEL) << "Msgid_plural: " << *it << endl;
@@ -739,12 +739,12 @@ ConversionStatus PoInfo::fastRead( CatalogItem& item, GettextFlexLexer *lexer, b
{
if( lexer->yylex() != T_STRING ) return PARSE_ERROR;
- QStringList msgstrs = item.msgstr();
+ TQStringList msgstrs = item.msgstr();
it = msgstrs.begin();
- *it = QString::fromUtf8(lexer->YYText());
+ *it = TQString::fromUtf8(lexer->YYText());
if( storeText || item.msgid().first().isEmpty() ) // if we should store the text or it is a header
while( lexer->yylex() == T_STRING )
- (*it)+= ("\n"+ QString::fromUtf8(lexer->YYText()));
+ (*it)+= ("\n"+ TQString::fromUtf8(lexer->YYText()));
else
if( lexer->yylex() == T_STRING ) // check next token, whether it is really translated
{
@@ -756,21 +756,21 @@ ConversionStatus PoInfo::fastRead( CatalogItem& item, GettextFlexLexer *lexer, b
}
else
{
- QStringList msgstrs = item.msgstr();
- QString s = QString::fromUtf8(lexer->YYText());
- while( lexer->lastToken == T_MSGSTR && s.contains( QRegExp("^msgstr\\[[0-9]+\\]" ) ) )
+ TQStringList msgstrs = item.msgstr();
+ TQString s = TQString::fromUtf8(lexer->YYText());
+ while( lexer->lastToken == T_MSGSTR && s.contains( TQRegExp("^msgstr\\[[0-9]+\\]" ) ) )
{
if( lexer->yylex() != T_STRING ) return PARSE_ERROR;
it = msgstrs.fromLast();
- *it = QString::fromUtf8(lexer->YYText());
+ *it = TQString::fromUtf8(lexer->YYText());
if( storeText )
do {
- (*it)+="\n"+QString::fromUtf8(lexer->YYText());
+ (*it)+="\n"+TQString::fromUtf8(lexer->YYText());
} while( lexer->yylex() == T_STRING );
else while( lexer->yylex() == T_STRING );
// kdDebug(KBABEL) << "Msgstr: " << *it << endl;
- s = QString::fromUtf8(lexer->YYText());
+ s = TQString::fromUtf8(lexer->YYText());
}
item.setMsgstr( msgstrs );
}