summaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-27 05:58:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-27 05:58:16 +0000
commitf636ba5ba2df9d34d56b1c85f24c6598fa1cb645 (patch)
tree5365045e6bce685a7cbaeb81b4797a719e86089f /src/common.cpp
parent63862fdfcb61f302ef69e86d40772bb1318d3763 (diff)
downloadkdiff3-f636ba5ba2df9d34d56b1c85f24c6598fa1cb645.tar.gz
kdiff3-f636ba5ba2df9d34d56b1c85f24c6598fa1cb645.zip
TQt4 port kdiff3
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1238464 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp164
1 files changed, 82 insertions, 82 deletions
diff --git a/src/common.cpp b/src/common.cpp
index a05920e..4249daf 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -20,12 +20,12 @@
#include "common.h"
#include <map>
-#include <qfont.h>
-#include <qcolor.h>
-#include <qsize.h>
-#include <qpoint.h>
-#include <qstringlist.h>
-#include <qtextstream.h>
+#include <tqfont.h>
+#include <tqcolor.h>
+#include <tqsize.h>
+#include <tqpoint.h>
+#include <tqstringlist.h>
+#include <tqtextstream.h>
ValueMap::ValueMap()
{
@@ -35,58 +35,58 @@ ValueMap::~ValueMap()
{
}
-void ValueMap::save( QTextStream& ts )
+void ValueMap::save( TQTextStream& ts )
{
- std::map<QString,QString>::iterator i;
+ std::map<TQString,TQString>::iterator i;
for( i=m_map.begin(); i!=m_map.end(); ++i)
{
- QString key = i->first;
- QString val = i->second;
+ TQString key = i->first;
+ TQString val = i->second;
ts << key << "=" << val << "\n";
}
}
-QString ValueMap::getAsString()
+TQString ValueMap::getAsString()
{
- QString result;
- std::map<QString,QString>::iterator i;
+ TQString result;
+ std::map<TQString,TQString>::iterator i;
for( i=m_map.begin(); i!=m_map.end(); ++i)
{
- QString key = i->first;
- QString val = i->second;
+ TQString key = i->first;
+ TQString val = i->second;
result += key + "=" + val + "\n";
}
return result;
}
-void ValueMap::load( QTextStream& ts )
+void ValueMap::load( TQTextStream& ts )
{
while ( !ts.eof() )
{ // until end of file...
- QString s = ts.readLine(); // line of text excluding '\n'
- int pos = s.find('=');
+ TQString s = ts.readLine(); // line of text excluding '\n'
+ int pos = s.tqfind('=');
if( pos > 0 ) // seems not to have a tag
{
- QString key = s.left(pos);
- QString val = s.mid(pos+1);
+ TQString key = s.left(pos);
+ TQString val = s.mid(pos+1);
m_map[key] = val;
}
}
}
/*
-void ValueMap::load( const QString& s )
+void ValueMap::load( const TQString& s )
{
int pos=0;
while ( pos<(int)s.length() )
{ // until end of file...
- int pos2 = s.find('=', pos);
- int pos3 = s.find('\n', pos2 );
+ int pos2 = s.tqfind('=', pos);
+ int pos3 = s.tqfind('\n', pos2 );
if (pos3<0)
pos3=s.length();
if( pos2 > 0 ) // seems not to have a tag
{
- QString key = s.mid(pos, pos2-pos);
- QString val = s.mid(pos2+1, pos3-pos2-1);
+ TQString key = s.mid(pos, pos2-pos);
+ TQString val = s.mid(pos2+1, pos3-pos2-1);
m_map[key] = val;
}
pos = pos3;
@@ -96,7 +96,7 @@ void ValueMap::load( const QString& s )
// safeStringJoin and safeStringSplit allow to convert a stringlist into a string and back
// safely, even if the individual strings in the list contain the separator character.
-QString safeStringJoin(const QStringList& sl, char sepChar, char metaChar )
+TQString safeStringJoin(const TQStringList& sl, char sepChar, char metaChar )
{
// Join the strings in the list, using the separator ','
// If a string contains the separator character, it will be replaced with "\,".
@@ -104,19 +104,19 @@ QString safeStringJoin(const QStringList& sl, char sepChar, char metaChar )
assert(sepChar!=metaChar);
- QString sep;
+ TQString sep;
sep += sepChar;
- QString meta;
+ TQString meta;
meta += metaChar;
- QString safeString;
+ TQString safeString;
- QStringList::const_iterator i;
+ TQStringList::const_iterator i;
for (i=sl.begin(); i!=sl.end(); ++i)
{
- QString s = *i;
- s.replace(meta, meta+meta); // "\" -> "\\"
- s.replace(sep, meta+sep); // "," -> "\,"
+ TQString s = *i;
+ s.tqreplace(meta, meta+meta); // "\" -> "\\"
+ s.tqreplace(sep, meta+sep); // "," -> "\,"
if ( i==sl.begin() )
safeString = s;
else
@@ -126,14 +126,14 @@ QString safeStringJoin(const QStringList& sl, char sepChar, char metaChar )
}
// Split a string that was joined with safeStringJoin
-QStringList safeStringSplit(const QString& s, char sepChar, char metaChar )
+TQStringList safeStringSplit(const TQString& s, char sepChar, char metaChar )
{
assert(sepChar!=metaChar);
- QStringList sl;
+ TQStringList sl;
// Miniparser
int i=0;
int len=s.length();
- QString b;
+ TQString b;
for(i=0;i<len;++i)
{
if ( i+1<len && s[i]==metaChar && s[i+1]==metaChar ){ b+=metaChar; ++i; }
@@ -153,26 +153,26 @@ QStringList safeStringSplit(const QString& s, char sepChar, char metaChar )
-static QString numStr(int n)
+static TQString numStr(int n)
{
- QString s;
+ TQString s;
s.setNum( n );
return s;
}
-static QString subSection( const QString& s, int idx, char sep )
+static TQString subSection( const TQString& s, int idx, char sep )
{
int pos=0;
while( idx>0 )
{
- pos = s.find( sep, pos );
+ pos = s.tqfind( sep, pos );
--idx;
if (pos<0) break;
++pos;
}
if ( pos>=0 )
{
- int pos2 = s.find( sep, pos );
+ int pos2 = s.tqfind( sep, pos );
if ( pos2>0 )
return s.mid(pos, pos2-pos);
else
@@ -182,61 +182,61 @@ static QString subSection( const QString& s, int idx, char sep )
return "";
}
-static int num( QString& s, int idx )
+static int num( TQString& s, int idx )
{
return subSection( s, idx, ',').toInt();
}
-void ValueMap::writeEntry(const QString& k, const QFont& v )
+void ValueMap::writeEntry(const TQString& k, const TQFont& v )
{
- m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
+ m_map[k] = v.family() + "," + TQString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
}
-void ValueMap::writeEntry(const QString& k, const QColor& v )
+void ValueMap::writeEntry(const TQString& k, const TQColor& v )
{
m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
}
-void ValueMap::writeEntry(const QString& k, const QSize& v )
+void ValueMap::writeEntry(const TQString& k, const TQSize& v )
{
m_map[k] = numStr(v.width()) + "," + numStr(v.height());
}
-void ValueMap::writeEntry(const QString& k, const QPoint& v )
+void ValueMap::writeEntry(const TQString& k, const TQPoint& v )
{
m_map[k] = numStr(v.x()) + "," + numStr(v.y());
}
-void ValueMap::writeEntry(const QString& k, int v )
+void ValueMap::writeEntry(const TQString& k, int v )
{
m_map[k] = numStr(v);
}
-void ValueMap::writeEntry(const QString& k, bool v )
+void ValueMap::writeEntry(const TQString& k, bool v )
{
m_map[k] = numStr(v);
}
-void ValueMap::writeEntry(const QString& k, const QString& v )
+void ValueMap::writeEntry(const TQString& k, const TQString& v )
{
m_map[k] = v;
}
-void ValueMap::writeEntry(const QString& k, const char* v )
+void ValueMap::writeEntry(const TQString& k, const char* v )
{
m_map[k] = v;
}
-void ValueMap::writeEntry(const QString& k, const QStringList& v, char separator )
+void ValueMap::writeEntry(const TQString& k, const TQStringList& v, char separator )
{
m_map[k] = safeStringJoin(v, separator);
}
-QFont ValueMap::readFontEntry(const QString& k, QFont* defaultVal )
+TQFont ValueMap::readFontEntry(const TQString& k, TQFont* defaultVal )
{
- QFont f = *defaultVal;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ TQFont f = *defaultVal;
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
f.setFamily( subSection( i->second, 0, ',' ) );
@@ -248,76 +248,76 @@ QFont ValueMap::readFontEntry(const QString& k, QFont* defaultVal )
return f;
}
-QColor ValueMap::readColorEntry(const QString& k, QColor* defaultVal )
+TQColor ValueMap::readColorEntry(const TQString& k, TQColor* defaultVal )
{
- QColor c= *defaultVal;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ TQColor c= *defaultVal;
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
- QString s = i->second;
- c = QColor( num(s,0),num(s,1),num(s,2) );
+ TQString s = i->second;
+ c = TQColor( num(s,0),num(s,1),num(s,2) );
}
return c;
}
-QSize ValueMap::readSizeEntry(const QString& k, QSize* defaultVal )
+TQSize ValueMap::readSizeEntry(const TQString& k, TQSize* defaultVal )
{
- QSize size = defaultVal ? *defaultVal : QSize(600,400);
- std::map<QString,QString>::iterator i = m_map.find( k );
+ TQSize size = defaultVal ? *defaultVal : TQSize(600,400);
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
- QString s = i->second;
- size = QSize( num(s,0),num(s,1) );
+ TQString s = i->second;
+ size = TQSize( num(s,0),num(s,1) );
}
return size;
}
-QPoint ValueMap::readPointEntry(const QString& k, QPoint* defaultVal)
+TQPoint ValueMap::readPointEntry(const TQString& k, TQPoint* defaultVal)
{
- QPoint point = defaultVal ? *defaultVal : QPoint(0,0);
- std::map<QString,QString>::iterator i = m_map.find( k );
+ TQPoint point = defaultVal ? *defaultVal : TQPoint(0,0);
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
- QString s = i->second;
- point = QPoint( num(s,0),num(s,1) );
+ TQString s = i->second;
+ point = TQPoint( num(s,0),num(s,1) );
}
return point;
}
-bool ValueMap::readBoolEntry(const QString& k, bool bDefault )
+bool ValueMap::readBoolEntry(const TQString& k, bool bDefault )
{
bool b = bDefault;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
- QString s = i->second;
+ TQString s = i->second;
b = (bool)num(s,0);
}
return b;
}
-int ValueMap::readNumEntry(const QString& k, int iDefault )
+int ValueMap::readNumEntry(const TQString& k, int iDefault )
{
int ival = iDefault;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
- QString s = i->second;
+ TQString s = i->second;
ival = num(s,0);
}
return ival;
}
-QString ValueMap::readEntry(const QString& k, const QString& sDefault )
+TQString ValueMap::readEntry(const TQString& k, const TQString& sDefault )
{
- QString sval = sDefault;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ TQString sval = sDefault;
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
sval = i->second;
@@ -326,11 +326,11 @@ QString ValueMap::readEntry(const QString& k, const QString& sDefault )
return sval;
}
-QStringList ValueMap::readListEntry(const QString& k, const QStringList& defaultVal, char separator )
+TQStringList ValueMap::readListEntry(const TQString& k, const TQStringList& defaultVal, char separator )
{
- QStringList strList;
+ TQStringList strList;
- std::map<QString,QString>::iterator i = m_map.find( k );
+ std::map<TQString,TQString>::iterator i = m_map.find( k );
if ( i!=m_map.end() )
{
strList = safeStringSplit( i->second, separator );