summaryrefslogtreecommitdiffstats
path: root/libkdchart/KDXMLTools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libkdchart/KDXMLTools.cpp')
-rw-r--r--libkdchart/KDXMLTools.cpp330
1 files changed, 165 insertions, 165 deletions
diff --git a/libkdchart/KDXMLTools.cpp b/libkdchart/KDXMLTools.cpp
index a78c163..bff4c72 100644
--- a/libkdchart/KDXMLTools.cpp
+++ b/libkdchart/KDXMLTools.cpp
@@ -27,118 +27,118 @@
**
**********************************************************************/
#include "KDXMLTools.h"
-#include <qbuffer.h>
-#include <qimage.h>
+#include <tqbuffer.h>
+#include <tqimage.h>
#include <zlib.h>
namespace KDXML {
- void createBoolNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, bool value )
+ void createBoolNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, bool value )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
- QDomText elementContent =
+ tqparent.appendChild( newElement );
+ TQDomText elementContent =
doc.createTextNode( value ? "true" : "false" );
newElement.appendChild( elementContent );
}
- void createOrientationNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, Qt::Orientation value )
+ void createOrientationNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, Qt::Orientation value )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
- QDomText elementContent =
+ tqparent.appendChild( newElement );
+ TQDomText elementContent =
doc.createTextNode( (Qt::Vertical == value) ? "vertical" : "horizontal" );
newElement.appendChild( elementContent );
}
- void createSizeNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QSize& value )
+ void createSizeNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQSize& value )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
+ tqparent.appendChild( newElement );
newElement.setAttribute( "Width", value.width() );
newElement.setAttribute( "Height", value.height() );
}
- void createIntNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, int value )
+ void createIntNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, int value )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
- QDomText elementContent =
- doc.createTextNode( QString::number( value ) );
+ tqparent.appendChild( newElement );
+ TQDomText elementContent =
+ doc.createTextNode( TQString::number( value ) );
newElement.appendChild( elementContent );
}
- void createDoubleNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, double value )
+ void createDoubleNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, double value )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
- QDomText elementContent =
- doc.createTextNode( QString::number( value ) );
+ tqparent.appendChild( newElement );
+ TQDomText elementContent =
+ doc.createTextNode( TQString::number( value ) );
newElement.appendChild( elementContent );
}
- void createStringNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName,
- const QString& text )
+ void createStringNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName,
+ const TQString& text )
{
- QDomElement newElement =
+ TQDomElement newElement =
doc.createElement( elementName );
- parent.appendChild( newElement );
- QDomText elementContent =
+ tqparent.appendChild( newElement );
+ TQDomText elementContent =
doc.createTextNode( text );
newElement.appendChild( elementContent );
}
- void createColorNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QColor& color )
+ void createColorNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQColor& color )
{
- QDomElement colorElement = doc.createElement( elementName );
- parent.appendChild( colorElement );
+ TQDomElement colorElement = doc.createElement( elementName );
+ tqparent.appendChild( colorElement );
colorElement.setAttribute( "Red",
- QString::number( color.red() ) );
+ TQString::number( color.red() ) );
colorElement.setAttribute( "Green",
- QString::number( color.green() ) );
+ TQString::number( color.green() ) );
colorElement.setAttribute( "Blue",
- QString::number( color.blue() ) );
+ TQString::number( color.blue() ) );
}
- void createBrushNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QBrush& brush )
+ void createBrushNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQBrush& brush )
{
- QDomElement brushElement = doc.createElement( elementName );
- parent.appendChild( brushElement );
+ TQDomElement brushElement = doc.createElement( elementName );
+ tqparent.appendChild( brushElement );
createColorNode( doc, brushElement, "Color", brush.color() );
createStringNode( doc, brushElement, "Style",
KDXML::brushStyleToString( brush.style() ) );
- if( brush.style() == Qt::CustomPattern && brush.pixmap() )
+ if( brush.style() == TQt::CustomPattern && brush.pixmap() )
createPixmapNode( doc, brushElement, "Pixmap", *brush.pixmap() );
}
- void createPixmapNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QPixmap& pixmap )
+ void createPixmapNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQPixmap& pixmap )
{
- QDomElement pixmapElement = doc.createElement( elementName );
- parent.appendChild( pixmapElement );
+ TQDomElement pixmapElement = doc.createElement( elementName );
+ tqparent.appendChild( pixmapElement );
createStringNode( doc, pixmapElement, "Format", "XPM.GZ" );
if( pixmap.isNull() ){
@@ -147,19 +147,19 @@ namespace KDXML {
}else{
// Convert the pixmap to an image, save that image to an in-memory
// XPM representation and compress this representation. This
- // conforms to the file format Qt Designer uses.
- QByteArray ba;
- QBuffer buffer( ba );
+ // conforms to the file format TQt Designer uses.
+ TQByteArray ba;
+ TQBuffer buffer( ba );
buffer.open( IO_WriteOnly );
- QImageIO imgio( &buffer, "XPM" );
- QImage image = pixmap.convertToImage();
+ TQImageIO imgio( &buffer, "XPM" );
+ TQImage image = pixmap.convertToImage();
imgio.setImage( image );
imgio.write();
buffer.close();
ulong len = ba.size() * 2;
- QByteArray bazip( len );
+ TQByteArray bazip( len );
::compress( (uchar*) bazip.data(), &len, (uchar*) ba.data(), ba.size() );
- QString dataString;
+ TQString dataString;
static const char hexchars[] = "0123456789abcdef";
for ( int i = 0; i < (int)len; ++i ) {
uchar c = (uchar) bazip[i];
@@ -172,126 +172,126 @@ namespace KDXML {
}
- void createRectNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QRect& rect )
+ void createRectNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQRect& rect )
{
- QDomElement rectElement = doc.createElement( elementName );
- parent.appendChild( rectElement );
- QDomElement xElement = doc.createElement( "X" );
+ TQDomElement rectElement = doc.createElement( elementName );
+ tqparent.appendChild( rectElement );
+ TQDomElement xElement = doc.createElement( "X" );
rectElement.appendChild( xElement );
- QDomText xContent = doc.createTextNode( QString::number( rect.x() ) );
+ TQDomText xContent = doc.createTextNode( TQString::number( rect.x() ) );
xElement.appendChild( xContent );
- QDomElement yElement = doc.createElement( "Y" );
+ TQDomElement yElement = doc.createElement( "Y" );
rectElement.appendChild( yElement );
- QDomText yContent = doc.createTextNode( QString::number( rect.y() ) );
+ TQDomText yContent = doc.createTextNode( TQString::number( rect.y() ) );
yElement.appendChild( yContent );
- QDomElement widthElement = doc.createElement( "Width" );
+ TQDomElement widthElement = doc.createElement( "Width" );
rectElement.appendChild( widthElement );
- QDomText widthContent = doc.createTextNode( QString::number( rect.width() ) );
+ TQDomText widthContent = doc.createTextNode( TQString::number( rect.width() ) );
widthElement.appendChild( widthContent );
- QDomElement heightElement = doc.createElement( "Height" );
+ TQDomElement heightElement = doc.createElement( "Height" );
rectElement.appendChild( heightElement );
- QDomText heightContent = doc.createTextNode( QString::number( rect.height() ) );
+ TQDomText heightContent = doc.createTextNode( TQString::number( rect.height() ) );
heightElement.appendChild( heightContent );
}
- void createStringListNodes( QDomDocument& doc, QDomNode& parent,
- const QString& elementName,
- const QStringList* list )
+ void createStringListNodes( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName,
+ const TQStringList* list )
{
if( !list )
return;
- for( QStringList::ConstIterator it = list->begin();
+ for( TQStringList::ConstIterator it = list->begin();
it != list->end(); ++it ) {
- QDomElement element = doc.createElement( elementName );
- parent.appendChild( element );
- QDomText elementContent = doc.createTextNode( *it );
+ TQDomElement element = doc.createElement( elementName );
+ tqparent.appendChild( element );
+ TQDomText elementContent = doc.createTextNode( *it );
element.appendChild( elementContent );
}
}
- void createFontNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QFont& font )
+ void createFontNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQFont& font )
{
- QDomElement fontElement = doc.createElement( elementName );
- parent.appendChild( fontElement );
+ TQDomElement fontElement = doc.createElement( elementName );
+ tqparent.appendChild( fontElement );
createStringNode( doc, fontElement, "Family", font.family() );
createIntNode( doc, fontElement, "PointSize", font.pointSize() );
createIntNode( doc, fontElement, "Weight", font.weight() );
createBoolNode( doc, fontElement, "Italic", font.italic() );
-#if COMPAT_QT_VERSION < 0x030000
- // Qt 3 handles the charset internally.
+#if COMPAT_TQT_VERSION < 0x030000
+ // TQt 3 handles the charset internally.
createIntNode( doc, fontElement, "CharSet", font.charSet() );
#endif
}
- void createPenNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QPen& pen )
+ void createPenNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQPen& pen )
{
- QDomElement penElement = doc.createElement( elementName );
- parent.appendChild( penElement );
+ TQDomElement penElement = doc.createElement( elementName );
+ tqparent.appendChild( penElement );
createIntNode( doc, penElement, "Width", pen.width() );
createColorNode( doc, penElement, "Color", pen.color() );
createStringNode( doc, penElement, "Style", penStyleToString( pen.style() ) );
}
- void createDateTimeNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName,
- const QDateTime& datetime )
+ void createDateTimeNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName,
+ const TQDateTime& datetime )
{
- QDomElement dateTimeElement = doc.createElement( elementName );
- parent.appendChild( dateTimeElement );
+ TQDomElement dateTimeElement = doc.createElement( elementName );
+ tqparent.appendChild( dateTimeElement );
createDateNode( doc, dateTimeElement, "Date", datetime.date() );
createTimeNode( doc, dateTimeElement, "Time", datetime.time() );
}
- void createDateNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QDate& date )
+ void createDateNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQDate& date )
{
- QDomElement dateElement = doc.createElement( elementName );
- parent.appendChild( dateElement );
- dateElement.setAttribute( "Year", QString::number( date.year() ) );
- dateElement.setAttribute( "Month", QString::number( date.month() ) );
- dateElement.setAttribute( "Day", QString::number( date.day() ) );
+ TQDomElement dateElement = doc.createElement( elementName );
+ tqparent.appendChild( dateElement );
+ dateElement.setAttribute( "Year", TQString::number( date.year() ) );
+ dateElement.setAttribute( "Month", TQString::number( date.month() ) );
+ dateElement.setAttribute( "Day", TQString::number( date.day() ) );
}
- void createTimeNode( QDomDocument& doc, QDomNode& parent,
- const QString& elementName, const QTime& time )
+ void createTimeNode( TQDomDocument& doc, TQDomNode& tqparent,
+ const TQString& elementName, const TQTime& time )
{
- QDomElement timeElement = doc.createElement( elementName );
- parent.appendChild( timeElement );
+ TQDomElement timeElement = doc.createElement( elementName );
+ tqparent.appendChild( timeElement );
timeElement.setAttribute( "Hour",
- QString::number( time.hour() ) );
+ TQString::number( time.hour() ) );
timeElement.setAttribute( "Minute",
- QString::number( time.minute() ) );
+ TQString::number( time.minute() ) );
timeElement.setAttribute( "Second",
- QString::number( time.second() ) );
+ TQString::number( time.second() ) );
timeElement.setAttribute( "Millisecond",
- QString::number( time.msec() ) );
+ TQString::number( time.msec() ) );
}
- QString penStyleToString( Qt::PenStyle style )
+ TQString penStyleToString( Qt::PenStyle style )
{
switch( style ) {
- case Qt::NoPen:
+ case TQt::NoPen:
return "NoPen";
- case Qt::SolidLine:
+ case TQt::SolidLine:
return "SolidLine";
- case Qt::DashLine:
+ case TQt::DashLine:
return "DashLine";
- case Qt::DotLine:
+ case TQt::DotLine:
return "DotLine";
- case Qt::DashDotLine:
+ case TQt::DashDotLine:
return "DashDotLine";
- case Qt::DashDotDotLine:
+ case TQt::DashDotDotLine:
return "DashDotDotLine";
default: // should not happen
return "SolidLine";
@@ -300,7 +300,7 @@ namespace KDXML {
- QString brushStyleToString( Qt::BrushStyle style )
+ TQString brushStyleToString( Qt::BrushStyle style )
{
// PENDING(kalle) Support custom patterns
switch( style ) {
@@ -340,14 +340,14 @@ namespace KDXML {
}
- bool readStringNode( const QDomElement& element, QString& value )
+ bool readStringNode( const TQDomElement& element, TQString& value )
{
value = element.text();
return true;
}
- bool readIntNode( const QDomElement& element, int& value )
+ bool readIntNode( const TQDomElement& element, int& value )
{
bool ok = false;
int temp = element.text().toInt( &ok );
@@ -357,7 +357,7 @@ namespace KDXML {
}
- bool readDoubleNode( const QDomElement& element, double& value )
+ bool readDoubleNode( const TQDomElement& element, double& value )
{
bool ok = false;
double temp = element.text().toDouble( &ok );
@@ -367,7 +367,7 @@ namespace KDXML {
}
- bool readBoolNode( const QDomElement& element, bool& value )
+ bool readBoolNode( const TQDomElement& element, bool& value )
{
if( element.text() == "true" ) {
value = true;
@@ -380,7 +380,7 @@ namespace KDXML {
}
- bool readOrientationNode( const QDomElement& element, Qt::Orientation& value )
+ bool readOrientationNode( const TQDomElement& element, Qt::Orientation& value )
{
if( element.text() == "vertical" ) {
value = Qt::Vertical;
@@ -393,7 +393,7 @@ namespace KDXML {
}
- bool readSizeNode( const QDomElement& element, QSize& value )
+ bool readSizeNode( const TQDomElement& element, TQSize& value )
{
bool ok = false;
int width, height;
@@ -411,7 +411,7 @@ namespace KDXML {
}
- bool readColorNode( const QDomElement& element, QColor& value )
+ bool readColorNode( const TQDomElement& element, TQColor& value )
{
bool ok = true;
int red=0, green=0, blue=0;
@@ -438,21 +438,21 @@ namespace KDXML {
}
- bool readBrushNode( const QDomElement& element, QBrush& brush )
+ bool readBrushNode( const TQDomElement& element, TQBrush& brush )
{
bool ok = true;
- QColor tempColor;
+ TQColor tempColor;
Qt::BrushStyle tempStyle=Qt::SolidPattern;
- QPixmap tempPixmap;
- QDomNode node = element.firstChild();
+ TQPixmap tempPixmap;
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Color" ) {
ok = ok & readColorNode( element, tempColor );
} else if( tagName == "Style" ) {
- QString value;
+ TQString value;
ok = ok & readStringNode( element, value );
tempStyle = stringToBrushStyle( value );
} else if( tagName == "Pixmap" ) {
@@ -475,18 +475,18 @@ namespace KDXML {
}
- bool readPixmapNode( const QDomElement& element, QPixmap& pixmap )
+ bool readPixmapNode( const TQDomElement& element, TQPixmap& pixmap )
{
bool ok = true;
unsigned long tempLength;
- QString tempData;
- QDomNode node = element.firstChild();
+ TQString tempData;
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Format" ) {
- QString formatName;
+ TQString formatName;
ok = ok & readStringNode( element, formatName );
#ifndef NDEBUG
if( formatName != "XPM.GZ" )
@@ -507,7 +507,7 @@ namespace KDXML {
if( ok ) {
if( 0 < tempLength ) {
- // Decode the image file format in the same way Qt Designer does.
+ // Decode the image file format in the same way TQt Designer does.
char *ba = new char[ tempData.length() / 2 ];
for ( int i = 0; i < (int)tempData.length() / 2; ++i ) {
char h = tempData[ 2 * i ].latin1();
@@ -527,10 +527,10 @@ namespace KDXML {
if( tempLength < tempData.length() * 5 )
tempLength = tempData.length() * 5;
- QByteArray baunzip( tempLength );
+ TQByteArray baunzip( tempLength );
::uncompress( (uchar*) baunzip.data(), &tempLength,
(uchar*) ba, tempData.length()/2 );
- QImage image;
+ TQImage image;
image.loadFromData( (const uchar*)baunzip.data(), tempLength, "XPM" );
if( image.isNull() )
@@ -545,23 +545,23 @@ namespace KDXML {
}
- bool readPenNode( const QDomElement& element, QPen& pen )
+ bool readPenNode( const TQDomElement& element, TQPen& pen )
{
bool ok = true;
int tempWidth;
- QColor tempColor;
+ TQColor tempColor;
Qt::PenStyle tempStyle=Qt::SolidLine;
- QDomNode node = element.firstChild();
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Width" ) {
ok = ok & readIntNode( element, tempWidth );
} else if( tagName == "Color" ) {
ok = ok & readColorNode( element, tempColor );
} else if( tagName == "Style" ) {
- QString value;
+ TQString value;
ok = ok & readStringNode( element, value );
tempStyle = stringToPenStyle( value );
} else {
@@ -580,18 +580,18 @@ namespace KDXML {
return ok;
}
- bool readFontNode( const QDomElement& element, QFont& font )
+ bool readFontNode( const TQDomElement& element, TQFont& font )
{
bool ok = true;
- QString family;
+ TQString family;
int pointSize, weight;
bool italic;
int charSet;
- QDomNode node = element.firstChild();
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Family" ) {
ok = ok & readStringNode( element, family );
} else if( tagName == "PointSize" ) {
@@ -614,24 +614,24 @@ namespace KDXML {
font.setPointSize( pointSize );
font.setWeight( weight );
font.setItalic( italic );
-#if COMPAT_QT_VERSION < 0x030000
- // Qt 3 handles charsets internally.
- font.setCharSet( (QFont::CharSet)charSet );
+#if COMPAT_TQT_VERSION < 0x030000
+ // TQt 3 handles charsets internally.
+ font.setCharSet( (TQFont::CharSet)charSet );
#endif
}
return ok;
}
- bool readRectNode( const QDomElement& element, QRect& value )
+ bool readRectNode( const TQDomElement& element, TQRect& value )
{
bool ok = true;
int width, height, x, y;
- QDomNode node = element.firstChild();
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Width" ) {
ok = ok & readIntNode( element, width );
} else if( tagName == "Height" ) {
@@ -659,16 +659,16 @@ namespace KDXML {
- bool readDateTimeNode( const QDomElement& element, QDateTime& datetime )
+ bool readDateTimeNode( const TQDomElement& element, TQDateTime& datetime )
{
bool ok = true;
- QDate tempDate;
- QTime tempTime;
- QDomNode node = element.firstChild();
+ TQDate tempDate;
+ TQTime tempTime;
+ TQDomNode node = element.firstChild();
while( !node.isNull() ) {
- QDomElement element = node.toElement();
+ TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
- QString tagName = element.tagName();
+ TQString tagName = element.tagName();
if( tagName == "Date" ) {
ok = ok & readDateNode( element, tempDate );
} else if( tagName == "Time" ) {
@@ -689,7 +689,7 @@ namespace KDXML {
}
- bool readDateNode( const QDomElement& element, QDate& value )
+ bool readDateNode( const TQDomElement& element, TQDate& value )
{
bool ok = true;
int year=0, month=0, day=0;
@@ -717,7 +717,7 @@ namespace KDXML {
- bool readTimeNode( const QDomElement& element, QTime& value )
+ bool readTimeNode( const TQDomElement& element, TQTime& value )
{
bool ok = true;
int hour=0, minute=0, second=0, msec=0;
@@ -750,7 +750,7 @@ namespace KDXML {
- Qt::PenStyle stringToPenStyle( const QString& style )
+ Qt::PenStyle stringToPenStyle( const TQString& style )
{
if( style == "NoPen" )
return Qt::NoPen;
@@ -769,7 +769,7 @@ namespace KDXML {
}
- Qt::BrushStyle stringToBrushStyle( const QString& style )
+ Qt::BrushStyle stringToBrushStyle( const TQString& style )
{
// PENDING(kalle) Support custom patterns
if( style == "NoBrush" )