diff options
Diffstat (limited to 'quanta/parsers/parser.cpp')
-rw-r--r-- | quanta/parsers/parser.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/quanta/parsers/parser.cpp b/quanta/parsers/parser.cpp index 7559f1ec..1225aaa3 100644 --- a/quanta/parsers/parser.cpp +++ b/quanta/parsers/parser.cpp @@ -14,18 +14,18 @@ ***************************************************************************/ //qt includes -#include <qeventloop.h> -#include <qstring.h> -#include <qpoint.h> -#include <qregexp.h> -#include <qcstring.h> -#include <qstringlist.h> -#include <qstrlist.h> -#include <qdatetime.h> -#include <qfile.h> -#include <qtextcodec.h> -#include <qvaluelist.h> -#include <qvaluestack.h> +#include <tqeventloop.h> +#include <tqstring.h> +#include <tqpoint.h> +#include <tqregexp.h> +#include <tqcstring.h> +#include <tqstringlist.h> +#include <tqstrlist.h> +#include <tqdatetime.h> +#include <tqfile.h> +#include <tqtextcodec.h> +#include <tqvaluelist.h> +#include <tqvaluestack.h> //standard library includes #include <stdio.h> @@ -65,10 +65,10 @@ #include <ktexteditor/viewcursorinterface.h> extern GroupElementMapList globalGroupMap; -static const QChar space(' '); +static const TQChar space(' '); extern int NN; -extern QMap<Node*, int> nodes; +extern TQMap<Node*, int> nodes; Parser::Parser() { @@ -79,10 +79,10 @@ Parser::Parser() m_parsingNeeded = true; m_parseIncludedFiles = true; m_saParser = new SAParser(); - connect(m_saParser, SIGNAL(rebuildStructureTree(bool)), SIGNAL(rebuildStructureTree(bool))); - connect(m_saParser, SIGNAL(cleanGroups()), SLOT(cleanGroups())); + connect(m_saParser, TQT_SIGNAL(rebuildStructureTree(bool)), TQT_SIGNAL(rebuildStructureTree(bool))); + connect(m_saParser, TQT_SIGNAL(cleanGroups()), TQT_SLOT(cleanGroups())); ParserCommon::includeWatch = new KDirWatch(); - connect(ParserCommon::includeWatch, SIGNAL(dirty(const QString&)), SLOT(slotIncludedFileChanged(const QString&))); + connect(ParserCommon::includeWatch, TQT_SIGNAL(dirty(const TQString&)), TQT_SLOT(slotIncludedFileChanged(const TQString&))); } Parser::~Parser() @@ -94,7 +94,7 @@ Parser::~Parser() Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, Node **lastNode, Node *a_node) { //first parse as an XML document - QString textLine; + TQString textLine; textLine.fill(space, startCol); int line = startLine; int col = 0; @@ -147,7 +147,7 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No currentNode = ParserCommon::createTextNode(write, currentNode, line, specialStartPos, parentNode); if (!rootNode) rootNode = currentNode; - QString foundText = m_dtd->specialAreaStartRx.cap(); + TQString foundText = m_dtd->specialAreaStartRx.cap(); //create a toplevel node for the special area AreaStruct area(line, specialStartPos, line, specialStartPos + foundText.length() - 1); Node *node = ParserCommon::createScriptTagNode(write, area, foundText, m_dtd, parentNode, currentNode); @@ -247,7 +247,7 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No //build an xml tag node here AreaStruct area(tagStartLine, tagStartPos, tagEndLine, tagEndCol); tag = new Tag(area, write, m_dtd, true); - QString tagStr = tag->tagStr(); + TQString tagStr = tag->tagStr(); tag->type = Tag::XmlTag; tag->validXMLTag = (openNum == 0); tag->single = QuantaCommon::isSingleTag(m_dtd->name, tag->name); @@ -282,15 +282,15 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No if (!rootNode) rootNode = node; //find the DTD that needs to be used for the special area - QString tmpStr = m_dtd->specialTags[tag->name.lower()]; + TQString tmpStr = m_dtd->specialTags[tag->name.lower()]; int defPos = tmpStr.find('['); - QString defValue; + TQString defValue; if (defPos != 0) { defValue = tmpStr.mid(defPos+1, tmpStr.findRev(']')-defPos-1).stripWhiteSpace(); tmpStr = tmpStr.left(defPos); } - QString s = tag->attributeValue(tmpStr); + TQString s = tag->attributeValue(tmpStr); if (s.isEmpty()) s = defValue; const DTDStruct *dtd = DTDs::ref()->find(s); @@ -325,7 +325,7 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No qTag = QuantaCommon::tagFromDTD(m_dtd, parentNode->tag->name); if ( qTag ) { - QString searchFor = (m_dtd->caseSensitive)?tag->name:tag->name.upper(); + TQString searchFor = (m_dtd->caseSensitive)?tag->name:tag->name.upper(); searchFor.remove('/'); if ( qTag->stoppingTags.contains(searchFor)) { @@ -364,7 +364,7 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No { //handle the case when a tag is a stopping tag for parent, and grandparent and so on. Node *n = parentNode; - QString searchFor = (m_dtd->caseSensitive)?tag->name:tag->name.upper(); + TQString searchFor = (m_dtd->caseSensitive)?tag->name:tag->name.upper(); while (qTag && n) { qTag = QuantaCommon::tagFromDTD(m_dtd, n->tag->name); @@ -505,7 +505,7 @@ Node *Parser::parseArea(int startLine, int startCol, int endLine, int endCol, No from Nodes */ Node *Parser::parse(Document *w, bool force) { - QTime t; + TQTime t; t.start(); QuantaView *view = ViewManager::ref()->activeView(); //If VPL is loaded, there shouldn't be any rebuild @@ -527,8 +527,8 @@ Node *Parser::parse(Document *w, bool force) Node::deleteNode(baseNode); baseNode = 0L; kdDebug(24000) << "Node objects after delete = " << NN << " ; list count = " << nodes.count() << endl; -/* QMap<Node*, int> nList = nodes; - for (QValueList<Node*>::ConstIterator it = nList.constBegin(); it != nList.constEnd(); ++it) +/* TQMap<Node*, int> nList = nodes; + for (TQValueList<Node*>::ConstIterator it = nList.constBegin(); it != nList.constEnd(); ++it) Node::deleteNode(*it); kdDebug(24000) << "Node objects after cleanup = " << NN << " ; list count = " << nodes.count() << endl; */ } @@ -567,7 +567,7 @@ Node *Parser::parse(Document *w, bool force) emit nodeTreeChanged(); if (saParserEnabled) - QTimer::singleShot(0, this, SLOT(slotParseInDetail())); + TQTimer::singleShot(0, this, TQT_SLOT(slotParseInDetail())); return m_node; } @@ -702,8 +702,8 @@ bool Parser::invalidArea(Document *w, AreaStruct &area, Node **firstNode, Node * w->viewCursorIf->cursorPositionReal(&line, &col); Node *node = nodeAt(line, col, false); int bl, bc, el, ec; - QString text; - QString tagStr; + TQString text; + TQString tagStr; area.bLine = area.bCol = 0; area.eLine = maxLines; area.eCol = w->editIf->lineLength(maxLines) - 1; @@ -976,7 +976,7 @@ void Parser::deleteNodes(Node *firstNode, Node *lastNode, NodeModifsSet *modifs) Node *Parser::rebuild(Document *w) { kdDebug(24000) << "Rebuild started. " << endl; - QTime t; + TQTime t; t.start(); bool saParserEnabled = m_saParser->parsingEnabled(); @@ -1002,8 +1002,8 @@ Node *Parser::rebuild(Document *w) m_saParser->setParsingEnabled(false); m_saParser->init(0L, w); parsingEnabled = true; - QString text; - QString tagStr; + TQString text; + TQString tagStr; Node *firstNode = 0L; Node *lastNode = 0L; @@ -1020,7 +1020,7 @@ Node *Parser::rebuild(Document *w) return n; } - kdDebug(24000) << QString("Invalid area: %1,%2,%3,%4").arg(area.bLine).arg(area.bCol).arg(area.eLine).arg(area.eCol) << "\n"; + kdDebug(24000) << TQString("Invalid area: %1,%2,%3,%4").arg(area.bLine).arg(area.bCol).arg(area.eLine).arg(area.eCol) << "\n"; // kdDebug(24000) << "lastNode1: " << lastNode << " " << lastNode->tag << endl; deleteNodes(firstNode->nextSibling(), lastNode, modifs); @@ -1082,7 +1082,7 @@ Node *Parser::rebuild(Document *w) lastNode->tag->endPos(area.eLine, area.eCol); Tag *_tag = new Tag(*(lastNode->tag)); lastNode->tag->setTagPosition(area); - QString s = write->text(area); + TQString s = write->text(area); lastNode->tag->setStr(s); if (!s.simplifyWhiteSpace().isEmpty()) { @@ -1141,7 +1141,7 @@ Node *Parser::rebuild(Document *w) qTag = QuantaCommon::tagFromDTD(m_dtd, node->parent->tag->name); if ( qTag ) { - QString searchFor = (m_dtd->caseSensitive)?lastNode->tag->name:lastNode->tag->name.upper(); + TQString searchFor = (m_dtd->caseSensitive)?lastNode->tag->name:lastNode->tag->name.upper(); searchFor.remove('/'); if ( qTag->stoppingTags.contains( searchFor ) ) { @@ -1172,7 +1172,7 @@ Node *Parser::rebuild(Document *w) { //handle the case when a tag is a stopping tag for parent, and grandparent and so on. I'm not sure it's needed here, but anyway... Node *n = node->parent; - QString searchFor = (m_dtd->caseSensitive) ? lastNode->tag->name : lastNode->tag->name.upper(); + TQString searchFor = (m_dtd->caseSensitive) ? lastNode->tag->name : lastNode->tag->name.upper(); while (qTag && n) { qTag = QuantaCommon::tagFromDTD(m_dtd, n->tag->name); @@ -1226,7 +1226,7 @@ Node *Parser::rebuild(Document *w) return n; } /* if (lastNode) - QString s = lastNode->tag->tagStr();*/ + TQString s = lastNode->tag->tagStr();*/ } } /* kdDebug(24000)<< "END"<< endl; @@ -1244,7 +1244,7 @@ Node *Parser::rebuild(Document *w) m_saParser->init(m_node, w); if (saParserEnabled) - QTimer::singleShot(0, this, SLOT(slotParseInDetail())); + TQTimer::singleShot(0, this, TQT_SLOT(slotParseInDetail())); emit nodeTreeChanged(); m_parsingNeeded = false; return m_node; @@ -1297,7 +1297,7 @@ void Parser::clearGroups() ParserCommon::includedFilesDTD.clear(); delete ParserCommon::includeWatch; ParserCommon::includeWatch = new KDirWatch(); - connect(ParserCommon::includeWatch, SIGNAL(dirty(const QString&)), SLOT(slotIncludedFileChanged(const QString&))); + connect(ParserCommon::includeWatch, TQT_SIGNAL(dirty(const TQString&)), TQT_SLOT(slotIncludedFileChanged(const TQString&))); m_parseIncludedFiles = true; } @@ -1345,7 +1345,7 @@ void Parser::cleanGroups() { delete ParserCommon::includeWatch; ParserCommon::includeWatch = new KDirWatch(); - connect(ParserCommon::includeWatch, SIGNAL(dirty(const QString&)), SLOT(slotIncludedFileChanged(const QString&))); + connect(ParserCommon::includeWatch, TQT_SIGNAL(dirty(const TQString&)), TQT_SLOT(slotIncludedFileChanged(const TQString&))); parseIncludedFiles(); } } @@ -1404,33 +1404,33 @@ struct GroupElementPosition{ int endPos; }; -void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) +void Parser::parseIncludedFile(const TQString& fileName, const DTDStruct *dtd) { #ifdef DEBUG_PARSER kdDebug(24000) << "parseIncludedFile: " << fileName << endl; #endif StructTreeGroup group; - QString content; - QFile file(fileName); + TQString content; + TQFile file(fileName); if (file.open(IO_ReadOnly)) { IncludedGroupElements *elements = &includedMap[fileName]; - QTextStream str(&file); - QString encoding; + TQTextStream str(&file); + TQString encoding; KTextEditor::EncodingInterface* encodingIf = dynamic_cast<KTextEditor::EncodingInterface*>(write->doc()); if (encodingIf) encoding = encodingIf->encoding(); if (encoding.isEmpty()) encoding = "utf8"; //final fallback - str.setCodec(QTextCodec::codecForName(encoding)); + str.setCodec(TQTextCodec::codecForName(encoding)); content = str.read(); file.close(); if (dtd->specialAreas.count()) { int areaPos = 0; int lastAreaPos = 0; - QString foundStr; - QString specialEndStr; + TQString foundStr; + TQString specialEndStr; while (areaPos != -1) { areaPos = content.find(dtd->specialAreaStartRx, lastAreaPos); @@ -1452,7 +1452,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) QuantaCommon::removeCommentsAndQuotes(foundStr, dtd); //gather the starting position of structures - QValueList<uint> structPositions; + TQValueList<uint> structPositions; int structPos = 0; while (structPos !=-1) { @@ -1464,10 +1464,10 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) } } - QValueList<GroupElementPosition> gPositions; + TQValueList<GroupElementPosition> gPositions; //go through the list of found structures and search for groups int structStartPosition = 0; //from where to start the group search. This is before the structure begin position - QString savedStr = foundStr; + TQString savedStr = foundStr; for (uint i = 0; i < structPositions.count(); i++) { foundStr = savedStr; @@ -1492,7 +1492,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) pos = foundStr.length(); int structEndPos = pos; foundStr = foundStr.left(pos); - QString spaces; + TQString spaces; spaces.fill(' ', pos - structPos + 1); foundStr.replace(structPos, pos - structPos + 1, spaces); @@ -1522,7 +1522,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) //now check which groups are present in this area structPos = pos + 1; - QValueList<StructTreeGroup>::ConstIterator it; + TQValueList<StructTreeGroup>::ConstIterator it; for (it = dtd->structTreeGroups.begin(); it != dtd->structTreeGroups.end(); ++it) { group = *it; @@ -1535,7 +1535,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) if (pos != -1) { int l; - QString ss = group.definitionRx.cap(); + TQString ss = group.definitionRx.cap(); if (group.definitionRx.pos(1) > pos) { pos = group.definitionRx.pos(1); @@ -1546,7 +1546,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) { l = group.definitionRx.cap().length(); } - QString s = content.mid(areaPos + pos, l); + TQString s = content.mid(areaPos + pos, l); pos += l; if (!(*elements)[group.name].contains(s)) { @@ -1554,7 +1554,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) tag->name = s; tag->setDtd(dtd); tag->setWrite(write); - QString s2 = content.left(areaPos + pos); + TQString s2 = content.left(areaPos + pos); int newLineNum = s2.contains('\n'); int tmpCol = s2.length() - s2.findRev('\n') - 1; tag->setTagPosition(newLineNum, tmpCol - s.length(), newLineNum, tmpCol); @@ -1565,7 +1565,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) groupElement->node = node; groupElement->parentNode = 0L; int minPos = areaPos + pos + 1; - for (QValueList<GroupElementPosition>::Iterator gPosIt = gPositions.begin(); gPosIt != gPositions.end(); ++gPosIt) + for (TQValueList<GroupElementPosition>::Iterator gPosIt = gPositions.begin(); gPosIt != gPositions.end(); ++gPosIt) { GroupElementPosition gPos = (*gPosIt); if ( (areaPos + pos > gPos.startPos) && (areaPos + pos < gPos.endPos) && (gPos.startPos < minPos)) @@ -1604,7 +1604,7 @@ void Parser::parseIncludedFile(const QString& fileName, const DTDStruct *dtd) } } -void Parser::slotIncludedFileChanged(const QString& fileName) +void Parser::slotIncludedFileChanged(const TQString& fileName) { int pos = ParserCommon::includedFiles.findIndex(fileName); if (pos != -1) @@ -1640,8 +1640,8 @@ void Parser::parseForXMLGroup(Node *node) { XMLStructGroup group = xmlGroupIt.data(); Tag *newTag = new Tag(*node->tag); - QString title = ""; - QStringList::Iterator it; + TQString title = ""; + TQStringList::Iterator it; for (it = group.attributes.begin(); it != group.attributes.end(); ++it) { if (newTag->hasAttribute(*it)) @@ -1674,10 +1674,10 @@ bool Parser::parseScriptInsideTag(Node *startNode) const DTDStruct *dtd = startNode->tag->dtd(); if (dtd->specialAreas.count()) { - QString foundText; - QString s; - QString specialEndStr; - QString text = startNode->tag->tagStr(); + TQString foundText; + TQString s; + TQString specialEndStr; + TQString text = startNode->tag->tagStr(); int pos = 0; int col = startNode->tag->structBeginStr.length(); @@ -1751,7 +1751,7 @@ void Parser::synchParseInDetail() void Parser::setSAParserEnabled(bool enabled) { m_saParser->setParsingEnabled(enabled); - //kapp->processEvents(QEventLoop::ExcludeUserInput | QEventLoop::ExcludeSocketNotifiers); //this makes sure that the parsing is really disabled + //kapp->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers); //this makes sure that the parsing is really disabled } #include "parser.moc" |