diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:39:55 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:39:55 +0000 |
commit | 0a6e0958c03e41c87b15557b6f407874f20c2f8d (patch) | |
tree | 2cdd58c4013b1be09cfcbb4ddae2b05712b9aeee /keduca/libkeduca/fileread.cpp | |
parent | 83f9dfafc157ff7823804b3ff457b43d021a5b4b (diff) | |
download | tdeedu-0a6e0958c03e41c87b15557b6f407874f20c2f8d.tar.gz tdeedu-0a6e0958c03e41c87b15557b6f407874f20c2f8d.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1157642 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'keduca/libkeduca/fileread.cpp')
-rw-r--r-- | keduca/libkeduca/fileread.cpp | 146 |
1 files changed, 73 insertions, 73 deletions
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 <kdebug.h> #include <ktempfile.h> -#include <qfileinfo.h> -#include <qpixmap.h> -#include <qbuffer.h> +#include <tqfileinfo.h> +#include <tqpixmap.h> +#include <tqbuffer.h> -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 "<<field <<endl; + kdDebug()<<"FileRead::setQuestion(QuestionField field, TQString text) called for not handled field value "<<field <<endl; break; } _changed=true; @@ -206,7 +206,7 @@ void FileRead::setQuestion( QuestionField field, int value ) _changed=true; } -void FileRead::setResult( ResultField field, const QString& text) +void FileRead::setResult( ResultField field, const TQString& text) { // RS_text, QF_picture switch( field ) @@ -218,7 +218,7 @@ void FileRead::setResult( ResultField field, const QString& text) (*_recordResults).picture = text; break; default: - kdDebug()<<"FileRead::setResult(ResultField field, QString text) called for not handled field value "<<field <<endl; + kdDebug()<<"FileRead::setResult(ResultField field, TQString text) called for not handled field value "<<field <<endl; break; } _changed=true; @@ -241,7 +241,7 @@ void FileRead::setResult( ResultField field, int value ) _changed=true; } -void FileRead::setAnswer( const QString& text, bool value, int points) +void FileRead::setAnswer( const TQString& text, bool value, int points) { Answers tmpAnswers; @@ -405,7 +405,7 @@ unsigned int FileRead::recordAnswerCount() return (*_recordQuestions).listAnswers.count(); } -QString FileRead::getQuestion( QuestionField field ) +TQString FileRead::getQuestion( QuestionField field ) { // QF_text, QF_picture, QF_type, QF_time, QF_tip, QF_explain switch( field ) @@ -418,10 +418,10 @@ QString FileRead::getQuestion( QuestionField field ) return( (*_recordQuestions).picture ); break; case QF_POINTS: - return QString().setNum( (*_recordQuestions).points ); + return TQString().setNum( (*_recordQuestions).points ); break; case QF_TIME: - return QString().setNum( (*_recordQuestions).time ); + return TQString().setNum( (*_recordQuestions).time ); break; case QF_TIP: return (*_recordQuestions).tip; @@ -455,7 +455,7 @@ int FileRead::getQuestionInt( QuestionField field ) } } -QString FileRead::getAnswer( AnswerField field ) +TQString FileRead::getAnswer( AnswerField field ) { // AField { AF_text, AF_value, AF_picture, AF_point }; switch( field ) @@ -467,7 +467,7 @@ QString FileRead::getAnswer( AnswerField field ) // (*(*_recordQuestions).RecordAnswers).Value ? return i18n("True") : return i18n("False"); // break; case AF_POINT: - return QString().setNum( (*(*_recordQuestions).recordAnswers).points ); + return TQString().setNum( (*(*_recordQuestions).recordAnswers).points ); break; default: kdDebug()<<"FileRead::getAnswer() called for not handled field value "<<field <<endl; @@ -485,7 +485,7 @@ int FileRead::getAnswerPoints() return (*(*_recordQuestions).recordAnswers).points; } -QString FileRead::getResult( ResultField field ) +TQString FileRead::getResult( ResultField field ) { switch( field ) { @@ -496,10 +496,10 @@ QString FileRead::getResult( ResultField field ) return( (*_recordResults).picture ); break; case RS_MIN: - return QString().setNum( (*_recordResults).min ); + return TQString().setNum( (*_recordResults).min ); break; case RS_MAX: - return QString().setNum( (*_recordResults).max ); + return TQString().setNum( (*_recordResults).max ); break; default: kdDebug()<<"FileRead::getResult() called for not handled field value "<<field <<endl; @@ -555,9 +555,9 @@ bool FileRead::recordAnswerBOF() return _fileAnswerBOF; } -QString FileRead::getPicture() +TQString FileRead::getPicture() { - QString picture; + TQString picture; if( !getQuestion(QF_PICTURE).isEmpty() ) picture = getQuestion(QF_PICTURE); @@ -568,7 +568,7 @@ QString FileRead::getPicture() if( _currentURL.isLocalFile() && !KURL(picture).isValid() ) { - if( !QFileInfo(picture).exists() ) + if( !TQFileInfo(picture).exists() ) picture = _currentURL.directory(false,true) + picture; } else if( !_currentURL.isLocalFile() && !KURL(picture).isValid() ) picture = _currentURL.protocol() + "://" + _currentURL.host() + _currentURL.directory(false,true) + picture; @@ -578,16 +578,16 @@ QString FileRead::getPicture() return picture; } -QPixmap FileRead::getPicturePixmap() +TQPixmap FileRead::getPicturePixmap() { KURL picture ( getPicture() ); - QPixmap pict; + TQPixmap pict; if( KIO::NetAccess::download( picture, _tmpfileImage, 0 ) ) { kdDebug()<<"... load successful: "<< _tmpfileImage <<endl; - pict = QPixmap( _tmpfileImage ); + pict = TQPixmap( _tmpfileImage ); KIO::NetAccess::removeTempFile( _tmpfileImage ); } else @@ -670,7 +670,7 @@ bool FileRead::saveFile( const KURL &url, bool copyimages, bool saveCompressed ) if( saveFile(_tmpfile->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( "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><!DOCTYPE educa>" ); + TQString head( "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><!DOCTYPE educa>" ); 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; |