summaryrefslogtreecommitdiffstats
path: root/part/kxedocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'part/kxedocument.cpp')
-rw-r--r--part/kxedocument.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/part/kxedocument.cpp b/part/kxedocument.cpp
index 8f48529..52394fa 100644
--- a/part/kxedocument.cpp
+++ b/part/kxedocument.cpp
@@ -37,16 +37,16 @@
#include <kurl.h>
#include <kurlrequester.h>
-#include <qcombobox.h>
-#include <qbuffer.h>
-#include <qregexp.h>
-#include <qtextcodec.h>
-#include <qlabel.h>
-#include <qcheckbox.h>
-
-KXEDocument::KXEDocument(QObject *parent, const char *name)
- :QObject (parent,name),
- QDomDocument(),
+#include <tqcombobox.h>
+#include <tqbuffer.h>
+#include <tqregexp.h>
+#include <tqtextcodec.h>
+#include <tqlabel.h>
+#include <tqcheckbox.h>
+
+KXEDocument::KXEDocument(TQObject *parent, const char *name)
+ :TQObject (parent,name),
+ TQDomDocument(),
KXMLGUIClient()
{
m_bDocIsCompressed = false;
@@ -63,7 +63,7 @@ KXEDocument::~KXEDocument()
}
-bool KXEDocument::save(const QString &strFileName)
+bool KXEDocument::save(const TQString &strFileName)
{
if (this->documentElement().isNull() &&
KMessageBox::warningContinueCancel(0,
@@ -73,14 +73,14 @@ bool KXEDocument::save(const QString &strFileName)
return false;
}
- QString strXML;
+ TQString strXML;
- QTextStream streamXML(&strXML, IO_WriteOnly);
+ TQTextStream streamXML(&strXML, IO_WriteOnly);
int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps();
- ((QDomDocument*)this)->save(streamXML, iIndent);
+ ((TQDomDocument*)this)->save(streamXML, iIndent);
- QString strEncoding;
- QTextCodec *pTextCodec;
+ TQString strEncoding;
+ TQTextCodec *pTextCodec;
// find encoding info
if(strXML.left(5) == "<?xml")
@@ -91,9 +91,9 @@ bool KXEDocument::save(const QString &strFileName)
iStart += 8; // skip encoding
// search " or ' after encoding
- if((iStart = strXML.find(QRegExp("[\"']"), iStart)) > 0)
+ if((iStart = strXML.find(TQRegExp("[\"']"), iStart)) > 0)
{
- QChar ch = strXML[iStart];
+ TQChar ch = strXML[iStart];
iStart++; // skip ch
if((iEnd = strXML.find(ch, iStart)) > 0)
{
@@ -104,23 +104,23 @@ bool KXEDocument::save(const QString &strFileName)
}
if(strEncoding.length() <= 0)
- pTextCodec = QTextCodec::codecForLocale(); // default
+ pTextCodec = TQTextCodec::codecForLocale(); // default
else
- pTextCodec = QTextCodec::codecForName(strEncoding);
+ pTextCodec = TQTextCodec::codecForName(strEncoding);
if(pTextCodec == 0)
{ if(KMessageBox::questionYesNo(0, i18n("Codec for encoding %1 not found ! Continue saving ?").arg(strEncoding)) != KMessageBox::Yes)
return false;
}
- QCString strDecoded;
+ TQCString strDecoded;
if(pTextCodec)
{ strDecoded = pTextCodec->fromUnicode(strXML);
}
// save string to file
if(!m_bDocIsCompressed)
- { QFile file(strFileName);
+ { TQFile file(strFileName);
if(file.open(IO_WriteOnly) == true)
{ file.writeBlock(strDecoded, strDecoded.length());
file.flush();
@@ -134,7 +134,7 @@ bool KXEDocument::save(const QString &strFileName)
}
else
{ // obtain file extension -----------------------------------------
- QString strExtension;
+ TQString strExtension;
int iPos = strFileName.findRev('.');
@@ -167,14 +167,14 @@ bool KXEDocument::save(const QString &strFileName)
return true;
}
-bool KXEDocument::open(const QString &strFileName)
+bool KXEDocument::open(const TQString &strFileName)
{
- QString strCompressedTarEntryName;
+ TQString strCompressedTarEntryName;
kdDebug() << "KXEDocument::open: opening file " << strFileName << endl;
// obtain file extension -----------------------------------------
- QString strExtension;
+ TQString strExtension;
int iPos = strFileName.findRev('.');
@@ -182,7 +182,7 @@ bool KXEDocument::open(const QString &strFileName)
{ strExtension = strFileName.mid(iPos + 1);
}
- QString strTmpfileName;
+ TQString strTmpfileName;
if ( KXMLEditorFactory::configuration()->archexts()->extensions().contains(strExtension) )
{
@@ -196,7 +196,7 @@ bool KXEDocument::open(const QString &strFileName)
}
tmp.setAutoDelete(false);
- QFile &fileTemporary = *(tmp.file());
+ TQFile &fileTemporary = *(tmp.file());
if(strExtension == "svgz")
@@ -211,12 +211,12 @@ bool KXEDocument::open(const QString &strFileName)
{ m_strCompressedTarEntryName = m_strCompressedTarEntryName.mid(iPos + 1);
}
- QIODevice *pIODevice = KFilterDev::deviceForFile(strFileName, "application/x-gzip");
+ TQIODevice *pIODevice = KFilterDev::deviceForFile(strFileName, "application/x-gzip");
if(pIODevice->open( IO_ReadOnly ))
{
- QTextStream stream(pIODevice);
- QString line;
+ TQTextStream stream(pIODevice);
+ TQString line;
//int i = 1;
while ( !stream.atEnd() )
{
@@ -263,7 +263,7 @@ bool KXEDocument::open(const QString &strFileName)
if(entry && entry->isFile())
{ const KArchiveFile *pTarFile = static_cast <const KArchiveFile *> (entry);
- QBuffer buffer(pTarFile->data());
+ TQBuffer buffer(pTarFile->data());
buffer.open(IO_ReadOnly);
fileTemporary.writeBlock(buffer.buffer(), buffer.size());
@@ -284,7 +284,7 @@ bool KXEDocument::open(const QString &strFileName)
// ( 1.) parse the file and fill our document
- QFile file(m_bDocIsCompressed ? strTmpfileName : strFileName);
+ TQFile file(m_bDocIsCompressed ? strTmpfileName : strFileName);
if(! file.open(IO_ReadOnly))
{
kdDebug() << "KXEDocument::openFile: Can't open file." << endl;
@@ -292,42 +292,42 @@ bool KXEDocument::open(const QString &strFileName)
}
// auxiliary file for obtaining encoding info
- QFile fileAux(m_bDocIsCompressed ? strTmpfileName : strFileName);
+ TQFile fileAux(m_bDocIsCompressed ? strTmpfileName : strFileName);
if(! fileAux.open(IO_ReadOnly))
{
kdDebug() << "KXEDocument::openFile: Can't open file." << endl;
return false;
}
- QTextStream txtStreamLocal( & file );
+ TQTextStream txtStreamLocal( & file );
// Lookup at XML document encoding -----------------------------------------------
- QTextStream txtStreamAux( & fileAux );
- QString strFirstLine = txtStreamAux.readLine();
+ TQTextStream txtStreamAux( & fileAux );
+ TQString strFirstLine = txtStreamAux.readLine();
fileAux.close();
int iStart, iEnd;
if((iStart = strFirstLine.find("encoding", 0)) > 0)
{
- QString strEncoding;
+ TQString strEncoding;
// info about encoding found;
iStart += 8; // skip encoding
// search " or ' after encoding
- if((iStart = strFirstLine.find(QRegExp("[\"']"), iStart)) > 0)
+ if((iStart = strFirstLine.find(TQRegExp("[\"']"), iStart)) > 0)
{
- QChar ch = strFirstLine[iStart];
+ TQChar ch = strFirstLine[iStart];
iStart++; // skip ch
if((iEnd = strFirstLine.find(ch, iStart)) > 0)
{
strEncoding = strFirstLine.mid(iStart, iEnd - iStart);
- QTextCodec *pTextCodec = QTextCodec::codecForName(strEncoding);
+ TQTextCodec *pTextCodec = TQTextCodec::codecForName(strEncoding);
if(pTextCodec)
txtStreamLocal.setCodec(pTextCodec);
else
{
KMessageBox::sorry(0, i18n("Codec for encoding %1 not found ! Using locale encoding for load.").arg(strEncoding));
- txtStreamLocal.setEncoding(QTextStream::Locale);
+ txtStreamLocal.setEncoding(TQTextStream::Locale);
}
}
}
@@ -335,24 +335,24 @@ bool KXEDocument::open(const QString &strFileName)
else
{
// XML documment dont have info about encoding, set default UTF-8
- txtStreamLocal.setCodec(QTextCodec::codecForName("UTF-8"));
+ txtStreamLocal.setCodec(TQTextCodec::codecForName("UTF-8"));
}
//--------------------------------------------------------------------------------
- QString strFileContents = txtStreamLocal.read();
+ TQString strFileContents = txtStreamLocal.read();
file.close();
if(m_bDocIsCompressed)
{
- QDir dir;
+ TQDir dir;
dir.remove(strTmpfileName);
}
- //-- Set string with XML to QDomDocument ------------------------------------------
- QString strErrorMsg;
+ //-- Set string with XML to TQDomDocument ------------------------------------------
+ TQString strErrorMsg;
int iErrorLine, iErrorColumn;
- QDomDocument * pNewDoc = new QDomDocument; // first try with a new document
+ TQDomDocument * pNewDoc = new TQDomDocument; // first try with a new document
if( ! pNewDoc->setContent(strFileContents, true, &strErrorMsg, &iErrorLine, &iErrorColumn) )
{ kdDebug() << "KXEDocument::openFile: Failed parsing the file." << endl;
@@ -368,8 +368,8 @@ bool KXEDocument::open(const QString &strFileName)
// The following commented code is performance wise buggy, because the string
// gets parsed a second time. I replaced it with this code.
// copy the content of the parsed document to this one
- QDomNode e = pNewDoc->removeChild( pNewDoc->documentElement() );
- QDomDocument::operator=( *pNewDoc );
+ TQDomNode e = pNewDoc->removeChild( pNewDoc->documentElement() );
+ TQDomDocument::operator=( *pNewDoc );
appendChild( e );
// Here comes the "buggy" code.
//this->setContent(pNewDoc->toString(),true,0,0); // and take the new one
@@ -397,37 +397,37 @@ void KXEDocument::setURL(KURL url)
emit sigURLChanged(url);
}
-void KXEDocument::updateNodeCreated(const QDomNode & node)
+void KXEDocument::updateNodeCreated(const TQDomNode & node)
{
emit sigNodeCreated(node);
setModified();
}
-void KXEDocument::updateNodeDeleted(const QDomNode & node)
+void KXEDocument::updateNodeDeleted(const TQDomNode & node)
{
emit sigNodeDeleted(node);
setModified();
}
-void KXEDocument::updateNodeChanged( const QDomElement & domElement )
+void KXEDocument::updateNodeChanged( const TQDomElement & domElement )
{
emit sigNodeChanged(domElement);
setModified();
}
-void KXEDocument::updateNodeChanged( const QDomCharacterData & node )
+void KXEDocument::updateNodeChanged( const TQDomCharacterData & node )
{
emit sigNodeChanged(node);
setModified();
}
-void KXEDocument::updateNodeChanged( const QDomProcessingInstruction &domProcInstr )
+void KXEDocument::updateNodeChanged( const TQDomProcessingInstruction &domProcInstr )
{
emit sigNodeChanged(domProcInstr);
setModified();
}
-void KXEDocument::updateNodeMoved( const QDomNode & node )
+void KXEDocument::updateNodeMoved( const TQDomNode & node )
{
emit sigNodeMoved(node);
setModified();
@@ -435,7 +435,7 @@ void KXEDocument::updateNodeMoved( const QDomNode & node )
void KXEDocument::attachStylesheet(const KURL& stylesheet)
{
- setSpecProcInstr("xml-stylesheet",QString("type = 'text/xsl' href = '")+stylesheet.url()+"' ");
+ setSpecProcInstr("xml-stylesheet",TQString("type = 'text/xsl' href = '")+stylesheet.url()+"' ");
}
void KXEDocument::detachStylesheet()
@@ -445,7 +445,7 @@ void KXEDocument::detachStylesheet()
void KXEDocument::attachSchema(const KURL& schema)
{
- QDomElement domElement = documentElement();
+ TQDomElement domElement = documentElement();
if (!domElement.isNull())
{
domElement.setAttributeNS(SCHEMA_NAMESPACE,
@@ -459,7 +459,7 @@ void KXEDocument::attachSchema(const KURL& schema)
void KXEDocument::detachSchema()
{
- QDomElement domElement = this->documentElement();
+ TQDomElement domElement = this->documentElement();
if (!domElement.isNull())
{
domElement.removeAttributeNS(SCHEMA_NAMESPACE,SCHEMA_ATTRIBUTE);
@@ -469,16 +469,16 @@ void KXEDocument::detachSchema()
}
}
-void KXEDocument::setSpecProcInstr(const QString& target, const QString& data)
+void KXEDocument::setSpecProcInstr(const TQString& target, const TQString& data)
{
// removing old one
removeSpecProcInstr(target);
// create new one
if (!data.isEmpty())
{
- QDomProcessingInstruction domProcInstr = this->createProcessingInstruction(target,data);
+ TQDomProcessingInstruction domProcInstr = this->createProcessingInstruction(target,data);
- QDomNode node = getSpecProcInstr("xml");
+ TQDomNode node = getSpecProcInstr("xml");
if (!node.isNull())
// if there is already xml instruction, then put that one below it
this->insertAfter(domProcInstr,node);
@@ -491,25 +491,25 @@ void KXEDocument::setSpecProcInstr(const QString& target, const QString& data)
setModified();
}
-void KXEDocument::removeSpecProcInstr(const QString &target)
+void KXEDocument::removeSpecProcInstr(const TQString &target)
{
- QDomNode domNode = getSpecProcInstr(target);
+ TQDomNode domNode = getSpecProcInstr(target);
if (!domNode.isNull())
{
updateNodeDeleted(domNode);
- ((QDomDocument*)this)->removeChild(domNode);
+ ((TQDomDocument*)this)->removeChild(domNode);
setModified();
}
}
-QDomNode KXEDocument::getSpecProcInstr(const QString& target)
+TQDomNode KXEDocument::getSpecProcInstr(const TQString& target)
{
- QDomNode result;
- QDomNodeList domNodeList = this->childNodes();
+ TQDomNode result;
+ TQDomNodeList domNodeList = this->childNodes();
for (uint i=0;i<domNodeList.count();i++)
if (domNodeList.item(i).isProcessingInstruction())
{
- QDomProcessingInstruction domProcInstr = domNodeList.item(i).toProcessingInstruction();
+ TQDomProcessingInstruction domProcInstr = domNodeList.item(i).toProcessingInstruction();
if (domProcInstr.target()==target)
return domNodeList.item(i);
}
@@ -542,7 +542,7 @@ void KXEDocument::newFile()
}
case KXENewFileSettings::UseDefaults:
- setSpecProcInstr( "xml", QString( "version='%1' encoding='%2'" ).arg(KXMLEditorFactory::configuration()->newfile()->dfltVersion()).arg(KXMLEditorFactory::configuration()->newfile()->dfltEncoding()) );
+ setSpecProcInstr( "xml", TQString( "version='%1' encoding='%2'" ).arg(KXMLEditorFactory::configuration()->newfile()->dfltVersion()).arg(KXMLEditorFactory::configuration()->newfile()->dfltEncoding()) );
break;
}
emit sigOpened();
@@ -553,7 +553,7 @@ void KXEDocument::newFile()
KCommand * KXEDocument::actDetachStylesheet()
{
- QDomNode domNode = getSpecProcInstr("xml-stylesheet");
+ TQDomNode domNode = getSpecProcInstr("xml-stylesheet");
if (!domNode.isNull())
{
KCommand *pCmd = new KXEStylesheetDetachCommand(this,domNode.toProcessingInstruction().data());
@@ -568,8 +568,8 @@ KCommand * KXEDocument::actAttachStylesheet()
dlg.Label->setText(i18n("Stylesheet URL:"));
if (dlg.exec())
{
- QDomNode domNode = getSpecProcInstr("xml-stylesheet");
- QString data = "";
+ TQDomNode domNode = getSpecProcInstr("xml-stylesheet");
+ TQString data = "";
if (!domNode.isNull())
data = domNode.toProcessingInstruction().data();
KCommand *pCmd = new KXEStylesheetAttachCommand(this,data,dlg.attachURI->url());
@@ -610,7 +610,7 @@ KCommand * KXEDocument::actAttachSchema()
// Instert or edit special processing instruction <?xml ... ?>
KCommand * KXEDocument::actVersionEncoding()
{
- QDomNode node = getSpecProcInstr("xml");
+ TQDomNode node = getSpecProcInstr("xml");
KXESpecProcInstrDialog dlg;
if(!node.isNull())
@@ -621,7 +621,7 @@ KCommand * KXEDocument::actVersionEncoding()
if(dlg.exec())
{
- QString strOldData = "";
+ TQString strOldData = "";
if (!node.isNull())
strOldData = node.toProcessingInstruction().data();
KCommand *pCmd = new KXEVersionEncodingCommand(this,strOldData,dlg.getData());