From 0a6e0958c03e41c87b15557b6f407874f20c2f8d Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:39:55 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1157642 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- keduca/libkeduca/fileread.cpp | 146 +++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 73 deletions(-) (limited to 'keduca/libkeduca/fileread.cpp') diff --git a/keduca/libkeduca/fileread.cpp b/keduca/libkeduca/fileread.cpp index db8f56cb..7632b6fd 100644 --- a/keduca/libkeduca/fileread.cpp +++ b/keduca/libkeduca/fileread.cpp @@ -25,12 +25,12 @@ #include #include -#include -#include -#include +#include +#include +#include -FileRead::FileRead( QObject *parent, const char *name ) - :QObject(parent, name), +FileRead::FileRead( TQObject *parent, const char *name ) + :TQObject(parent, name), _changed(false), _tmpfile(0) { @@ -41,7 +41,7 @@ FileRead::~FileRead() } bool FileRead::openFile(const KURL &url) { - QString tmpFile; + TQString tmpFile; bool returnval=false; if( KIO::NetAccess::download( url, tmpFile, 0 ) ) { @@ -58,15 +58,15 @@ bool FileRead::openFile(const KURL &url) { return returnval; } -bool FileRead::loadFile(const QString &filename) +bool FileRead::loadFile(const TQString &filename) { - QDomDocument doc("document.xml"); + TQDomDocument doc("document.xml"); KMimeType::Ptr type = KMimeType::findByFileContent(filename); kdDebug() << "FileRead::loadFile(): MIME-Type is " << type->name() << endl; - QFile file(filename); + TQFile file(filename); if(!file.open(IO_ReadOnly)) { @@ -82,26 +82,26 @@ bool FileRead::loadFile(const QString &filename) doc.setContent(qUncompress(file.readAll())); } - QDomElement docElem = doc.documentElement(); + TQDomElement docElem = doc.documentElement(); if( (doc.doctype().isNull()) || (doc.doctype().name() != "educa") ) { file.close(); return false; } - QDomNode n = docElem.firstChild(); + TQDomNode n = docElem.firstChild(); - QDomNodeList dnList = n.childNodes(); + TQDomNodeList dnList = n.childNodes(); for( unsigned int i = 0; i < dnList.count(); ++i) { // ------------------- INFORMATION BODY ----------------------- - QDomElement element = dnList.item(i).toElement(); + TQDomElement element = dnList.item(i).toElement(); if( element.tagName() == "default" || element.tagName() == "author" ) { if( element.tagName() == "default" ) { _header.insert( "image", element.attribute( "image", "default.png" ) ); } if( element.tagName() == "author" ) { - QDomNodeList AuthordnList = element.childNodes(); + TQDomNodeList AuthordnList = element.childNodes(); for( unsigned int i = 0; i < AuthordnList.count(); ++i) { - QDomElement authorelement = AuthordnList.item(i).toElement(); + TQDomElement authorelement = AuthordnList.item(i).toElement(); _header.insert( authorelement.tagName(), authorelement.text() ); } } @@ -117,17 +117,17 @@ bool FileRead::loadFile(const QString &filename) { insertQuestion(); // --------------------- QUESTION ATTRIBUTE------------------------ - QDomElement elementNODE = dnList.item(i).toElement(); + TQDomElement elementNODE = dnList.item(i).toElement(); setQuestion( QF_TYPE, elementNODE.attribute( "type", "1" ).toInt() ); setQuestion( QF_PICTURE, elementNODE.attribute( "image", "" ) ); setQuestion( QF_TIME, elementNODE.attribute( "time", "0" ).toInt() ); setQuestion( QF_POINTS, elementNODE.attribute( "points", "0" ).toInt() ); - QDomNodeList quList = elementNODE.childNodes(); + TQDomNodeList quList = elementNODE.childNodes(); for( unsigned int x = 0; x < quList.count(); ++x) { // --------------------- QUESTION AND RESPONSES------------------ - QDomElement element = quList.item(x).toElement(); + TQDomElement element = quList.item(x).toElement(); if( element.tagName() == "text" ) setQuestion( QF_TEXT, element.text() ); if( element.tagName() == "true" ) setAnswer( element.text(), true, element.attribute( "points", "0" ).toInt() ); if( element.tagName() == "false" ) setAnswer( element.text(), false,element.attribute( "points", "0" ).toInt() ); @@ -146,7 +146,7 @@ bool FileRead::loadFile(const QString &filename) { insertResult(); // --------------------- QUESTION ATTRIBUTE------------------------ - QDomElement elementNODE = dnList.item(i).toElement(); + TQDomElement elementNODE = dnList.item(i).toElement(); setResult( RS_TEXT, elementNODE.text() ); setResult( RS_PICTURE, elementNODE.attribute( "image", "" ) ); setResult( RS_MIN, elementNODE.attribute( "min", "0" ).toInt() ); @@ -162,7 +162,7 @@ bool FileRead::loadFile(const QString &filename) return true; } -void FileRead::setQuestion( QuestionField field, const QString& text) +void FileRead::setQuestion( QuestionField field, const TQString& text) { // QF_text, QF_picture, QF_type, QF_time, QF_tip, QF_explain switch( field ) @@ -180,7 +180,7 @@ void FileRead::setQuestion( QuestionField field, const QString& text) (*_recordQuestions).explain = text; break; default: - kdDebug()<<"FileRead::setQuestion(QuestionField field, QString text) called for not handled field value "<name(), copyimages, saveCompressed) ) { // upload the file KIO::Job * job = KIO::file_copy( KURL::fromPathOrURL( _tmpfile->name() ), _currentURL, -1, true /*overwrite*/ ); - connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotUploadFinished (KIO::Job *) ) ); + connect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotUploadFinished (KIO::Job *) ) ); return true; } } @@ -679,15 +679,15 @@ bool FileRead::saveFile( const KURL &url, bool copyimages, bool saveCompressed ) return false; } -bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveCompressed ) +bool FileRead::saveFile( const TQString &filename, bool copyimages, bool saveCompressed ) { - QDomDocument doc("document.xml"); - QTextStream stream; - QString line; - QByteArray data; - QBuffer buffer(data); - QFile file(filename); - QStringList copyJOB; + TQDomDocument doc("document.xml"); + TQTextStream stream; + TQString line; + TQByteArray data; + TQBuffer buffer(data); + TQFile file(filename); + TQStringList copyJOB; stream.setDevice(&buffer); @@ -705,13 +705,13 @@ bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveComp } */ - QString head( "" ); + TQString head( "" ); doc.setContent( head ); - QDomElement Root = doc.createElement("Document"); + TQDomElement Root = doc.createElement("Document"); doc.appendChild( Root ); - QDomElement NodeInfo = doc.createElement("Info"); + TQDomElement NodeInfo = doc.createElement("Info"); Root.appendChild( NodeInfo ); insertXML( doc, NodeInfo, "title", _header["title"] ); @@ -722,12 +722,12 @@ bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveComp if( !(_header["image"]).isEmpty() ) { - QDomElement Nodedefault = doc.createElement("default"); + TQDomElement Nodedefault = doc.createElement("default"); if( copyimages ) { copyJOB.append( _header["image"] ); - Nodedefault.setAttribute( "image", QFileInfo(_header["image"]).fileName() ); + Nodedefault.setAttribute( "image", TQFileInfo(_header["image"]).fileName() ); } else { Nodedefault.setAttribute( "image", _header["image"]); } @@ -736,26 +736,26 @@ bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveComp if( !_header["name"].isEmpty() || !_header["email"].isEmpty() || !_header["www"].isEmpty() ) { - QDomElement Nodeauthor = doc.createElement("author"); + TQDomElement Nodeauthor = doc.createElement("author"); NodeInfo.appendChild( Nodeauthor ); if( !_header["name"].isEmpty() ) insertXML( doc, Nodeauthor, "name", _header["name"] ); if( !_header["email"].isEmpty() ) insertXML( doc, Nodeauthor, "email", _header["email"] ); if( !_header["www"].isEmpty() ) insertXML( doc, Nodeauthor, "www", _header["www"] ); } - QDomElement NodeData = doc.createElement("Data"); + TQDomElement NodeData = doc.createElement("Data"); Root.appendChild( NodeData ); recordFirst(); while ( !recordEOF() ) { - QDomElement question = doc.createElement("question"); + TQDomElement question = doc.createElement("question"); if( !getQuestion( QF_PICTURE ).isEmpty() ) { if( copyimages ) { copyJOB.append( getQuestion( QF_PICTURE ) ); - question.setAttribute("image", QFileInfo( getQuestion( QF_PICTURE ) ).fileName() ); + question.setAttribute("image", TQFileInfo( getQuestion( QF_PICTURE ) ).fileName() ); } else { question.setAttribute("image", getQuestion( QF_PICTURE ) ); } @@ -770,16 +770,16 @@ bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveComp { if( getAnswerValue() ) { - QDomElement domELEMENT = doc.createElement( "true" ); + TQDomElement domELEMENT = doc.createElement( "true" ); if( getAnswerPoints() > 0 ) domELEMENT.setAttribute("points", getAnswerPoints() ); - QDomText DATAelement = doc.createTextNode( getAnswer( AF_TEXT ) ); + TQDomText DATAelement = doc.createTextNode( getAnswer( AF_TEXT ) ); question.appendChild( domELEMENT ); domELEMENT.appendChild( DATAelement ); } else { // insertXML( doc, question, "false", getAnswer( AF_text ) ); - QDomElement domELEMENT = doc.createElement( "false" ); + TQDomElement domELEMENT = doc.createElement( "false" ); if( getAnswerPoints() > 0 ) domELEMENT.setAttribute("points", getAnswerPoints() ); - QDomText DATAelement = doc.createTextNode( getAnswer( AF_TEXT ) ); + TQDomText DATAelement = doc.createTextNode( getAnswer( AF_TEXT ) ); question.appendChild( domELEMENT ); domELEMENT.appendChild( DATAelement ); } @@ -814,7 +814,7 @@ bool FileRead::saveFile( const QString &filename, bool copyimages, bool saveComp } /** Save results */ -bool FileRead::saveResults( const KURL &url, const QString &results ) +bool FileRead::saveResults( const KURL &url, const TQString &results ) { if (url.isValid()) { @@ -847,7 +847,7 @@ bool FileRead::saveResults( const KURL &url, const QString &results ) if( saveResults(_tmpfile->name(), results) ) { // upload the file KIO::Job * job = KIO::file_copy( KURL::fromPathOrURL( _tmpfile->name() ), _currentURL, -1, true /*overwrite*/ ); - connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotUploadFinished (KIO::Job *) ) ); + connect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotUploadFinished (KIO::Job *) ) ); return true; } } @@ -856,11 +856,11 @@ bool FileRead::saveResults( const KURL &url, const QString &results ) return false; } -bool FileRead::saveResults( const QString &filename, const QString &results ) +bool FileRead::saveResults( const TQString &filename, const TQString &results ) { - QTextStream stream; - QFile file(filename); - QStringList copyJOB; + TQTextStream stream; + TQFile file(filename); + TQStringList copyJOB; stream.setDevice(&file); @@ -875,30 +875,30 @@ bool FileRead::saveResults( const QString &filename, const QString &results ) } /** Insert xml format data */ -void FileRead::insertXML( QDomDocument &doc, QDomElement &parent, const QString &tagName, const QString &data) +void FileRead::insertXML( TQDomDocument &doc, TQDomElement &parent, const TQString &tagName, const TQString &data) { - QDomElement domELEMENT = doc.createElement( tagName ); - QDomText DATAelement = doc.createTextNode( data ); + TQDomElement domELEMENT = doc.createElement( tagName ); + TQDomText DATAelement = doc.createTextNode( data ); parent.appendChild( domELEMENT ); domELEMENT.appendChild( DATAelement ); } /** Insert xml data format */ -void FileRead::insertXML( QDomDocument &doc, QDomElement &parent, const QString &data) +void FileRead::insertXML( TQDomDocument &doc, TQDomElement &parent, const TQString &data) { - QDomText DATAelement = doc.createTextNode( data ); + TQDomText DATAelement = doc.createTextNode( data ); parent.appendChild( DATAelement ); } /** Get Header */ -QString FileRead::getHeader(const QString &head) +TQString FileRead::getHeader(const TQString &head) { return _header[head]; } /** Set header data */ -void FileRead::setHeader( const QString field, const QString value) +void FileRead::setHeader( const TQString field, const TQString value) { _changed = _header[field]!=value; -- cgit v1.2.1