summaryrefslogtreecommitdiffstats
path: root/quanta/utility/quantacommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'quanta/utility/quantacommon.cpp')
-rw-r--r--quanta/utility/quantacommon.cpp212
1 files changed, 106 insertions, 106 deletions
diff --git a/quanta/utility/quantacommon.cpp b/quanta/utility/quantacommon.cpp
index 7cc7fb1b..93421764 100644
--- a/quanta/utility/quantacommon.cpp
+++ b/quanta/utility/quantacommon.cpp
@@ -18,13 +18,13 @@
#include <unistd.h>
//qt includes
-#include <qstringlist.h>
-#include <qdict.h>
-#include <qdir.h>
-#include <qdom.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qwidget.h>
+#include <tqstringlist.h>
+#include <tqdict.h>
+#include <tqdir.h>
+#include <tqdom.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqwidget.h>
//kde includes
#include <kapplication.h>
@@ -48,10 +48,10 @@
#include <ktoolbar.h>
#include <ktoolbarbutton.h>
#include <kstringhandler.h>
-#include <qwhatsthis.h>
-#include <qtimer.h>
-#include <qclipboard.h>
-#include <qdatastream.h>
+#include <tqwhatsthis.h>
+#include <tqtimer.h>
+#include <tqclipboard.h>
+#include <tqdatastream.h>
#include "qextfileinfo.h"
#include "quantacommon.h"
@@ -61,22 +61,22 @@
QConfig qConfig; //holds the main configuration settings
-QString tmpDir;
+TQString tmpDir;
-QRegExp scriptBeginRx;
-QRegExp scriptEndRx;
+TQRegExp scriptBeginRx;
+TQRegExp scriptEndRx;
Node *baseNode;
Parser *parser;
KDirWatch *fileWatcher;
KProgress *progressBar;
-QString toolbarExtension = ".toolbar.tgz";
-QRegExp newLineRx("\\n");
-QStringList charList; //hold the list of the &char; chars. See the data/chars file.
-QMap<int, QString> replacementMap;
-QPtrList<KTempFile> tempFileList;
-QPtrList<KTempDir> tempDirList;
+TQString toolbarExtension = ".toolbar.tgz";
+TQRegExp newLineRx("\\n");
+TQStringList charList; //hold the list of the &char; chars. See the data/chars file.
+TQMap<int, TQString> replacementMap;
+TQPtrList<KTempFile> tempFileList;
+TQPtrList<KTempDir> tempDirList;
bool typingInProgress;
QuantaCommon::QuantaCommon(){
@@ -86,9 +86,9 @@ QuantaCommon::~QuantaCommon(){
}
/** convert tag to upper or lower case */
-QString QuantaCommon::tagCase( const QString& tag)
+TQString QuantaCommon::tagCase( const TQString& tag)
{
- QString sTag = tag;
+ TQString sTag = tag;
switch (qConfig.tagCase)
{
@@ -100,9 +100,9 @@ QString QuantaCommon::tagCase( const QString& tag)
}
/** convert attr of tag to upper or lower case */
-QString QuantaCommon::attrCase( const QString& attr)
+TQString QuantaCommon::attrCase( const TQString& attr)
{
- QString sAttr = attr;
+ TQString sAttr = attr;
switch (qConfig.attrCase)
{
@@ -115,14 +115,14 @@ QString QuantaCommon::attrCase( const QString& attr)
/** returns the attribute value in quoted form, by taking care of the
quotation setting*/
-QString QuantaCommon::quoteAttributeValue(const QString& value)
+TQString QuantaCommon::quoteAttributeValue(const TQString& value)
{
- QString quote = qConfig.attrValueQuotation;
+ TQString quote = qConfig.attrValueQuotation;
return quote + value + quote;
}
/** Set's up the url correctly from urlString. */
-void QuantaCommon::setUrl(KURL &url, const QString& urlString)
+void QuantaCommon::setUrl(KURL &url, const TQString& urlString)
{
KURL oldUrl = url;
url = urlString;
@@ -136,7 +136,7 @@ void QuantaCommon::setUrl(KURL &url, const QString& urlString)
}
/** No descriptions */
-bool QuantaCommon::isSingleTag(const QString& dtdName, const QString& tag)
+bool QuantaCommon::isSingleTag(const TQString& dtdName, const TQString& tag)
{
bool single = false;
@@ -147,7 +147,7 @@ bool QuantaCommon::isSingleTag(const QString& dtdName, const QString& tag)
const DTDStruct* dtd = DTDs::ref()->find(dtdName);
if (dtd && !tag.isEmpty())
{
- QString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
+ TQString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
QTag* qtag = dtd->tagsList->find(searchForTag);
if (qtag)
single = qtag->isSingle();
@@ -157,14 +157,14 @@ bool QuantaCommon::isSingleTag(const QString& dtdName, const QString& tag)
}
/** No descriptions */
-bool QuantaCommon::isOptionalTag(const QString& dtdName, const QString& tag)
+bool QuantaCommon::isOptionalTag(const TQString& dtdName, const TQString& tag)
{
bool optional = false;
const DTDStruct* dtd = DTDs::ref()->find(dtdName);
if (dtd && !tag.isEmpty())
{
- QString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
+ TQString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
QTag* qtag = dtd->tagsList->find(searchForTag);
if (qtag)
optional = qtag->isOptional();
@@ -173,14 +173,14 @@ bool QuantaCommon::isOptionalTag(const QString& dtdName, const QString& tag)
return optional;
}
/** No descriptions */
-bool QuantaCommon::isKnownTag(const QString& dtdName, const QString& tag)
+bool QuantaCommon::isKnownTag(const TQString& dtdName, const TQString& tag)
{
bool known = false;
const DTDStruct* dtd = DTDs::ref()->find(dtdName);
if (dtd && !tag.isEmpty())
{
- QString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
+ TQString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
if (dtd->tagsList->find(searchForTag))
known = true;
}
@@ -188,14 +188,14 @@ bool QuantaCommon::isKnownTag(const QString& dtdName, const QString& tag)
return known;
}
-AttributeList* QuantaCommon::tagAttributes(const QString& dtdName, const QString& tag)
+AttributeList* QuantaCommon::tagAttributes(const TQString& dtdName, const TQString& tag)
{
AttributeList* attrs = 0L;
const DTDStruct* dtd = DTDs::ref()->find(dtdName);
if (dtd && !tag.isEmpty())
{
- QString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
+ TQString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
QTag* qtag = dtd->tagsList->find(searchForTag);
if (qtag)
attrs = qtag->attributes();
@@ -205,19 +205,19 @@ AttributeList* QuantaCommon::tagAttributes(const QString& dtdName, const QString
}
/** Returns the QTag object for the tag "tag" from the DTD named "dtdname". */
-QTag* QuantaCommon::tagFromDTD(const QString& dtdName, const QString& tag)
+QTag* QuantaCommon::tagFromDTD(const TQString& dtdName, const TQString& tag)
{
const DTDStruct* dtd = DTDs::ref()->find(dtdName);
return tagFromDTD(dtd, tag);
}
/** Returns the QTag object for the tag "tag" from the DTD. */
-QTag* QuantaCommon::tagFromDTD(const DTDStruct *dtd, const QString& tag)
+QTag* QuantaCommon::tagFromDTD(const DTDStruct *dtd, const TQString& tag)
{
QTag *qtag = 0;
if (dtd && !tag.isEmpty())
{
- QString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
+ TQString searchForTag = (dtd->caseSensitive) ? tag : tag.upper();
qtag = dtd->tagsList->find(searchForTag);
}
@@ -234,18 +234,18 @@ QTag* QuantaCommon::tagFromDTD(Node *node)
}
/** Returns an XML style string containing the GUI for attributes. */
-QString QuantaCommon::xmlFromAttributes(AttributeList* attributes)
+TQString QuantaCommon::xmlFromAttributes(AttributeList* attributes)
{
- QString xmlStr;
- QTextStream stream( &xmlStr, IO_WriteOnly );
- stream.setEncoding(QTextStream::UnicodeUTF8);
+ TQString xmlStr;
+ TQTextStream stream( &xmlStr, IO_WriteOnly );
+ stream.setEncoding(TQTextStream::UnicodeUTF8);
if (attributes)
{
int row = 0;
for ( uint i = 0; i< attributes->count();i++)
{
Attribute *attribute = attributes->at(i);
- QString name = attribute->name.left(1).upper()+attribute->name.right(attribute->name.length()-1);
+ TQString name = attribute->name.left(1).upper()+attribute->name.right(attribute->name.length()-1);
stream << " <attr name=\"" + attribute->name +"\" type=\""+attribute->type+"\"";
if (!attribute->defaultValue.isEmpty())
stream << " defaultValue=\"" + attribute->defaultValue + "\"";
@@ -301,13 +301,13 @@ KStandardDirs* QuantaCommon::pluginDirs(const char *type)
return dirs;
}
/** Return true, if the url belong to the mimetype group. */
-bool QuantaCommon::checkMimeGroup(const KURL& url, const QString& group)
+bool QuantaCommon::checkMimeGroup(const KURL& url, const TQString& group)
{
KMimeType::List list = KMimeType::allMimeTypes();
KMimeType::List::iterator it;
bool status = false;
KMimeType::Ptr mime = KMimeType::findByURL(url);
- QString mimetype = mime->name();
+ TQString mimetype = mime->name();
mimetype = mimetype.section('/',-1);
for ( it = list.begin(); it != list.end(); ++it )
{
@@ -327,7 +327,7 @@ bool QuantaCommon::checkMimeGroup(const KURL& url, const QString& group)
status = true;
} else
{
- QVariant v = mime->property("X-KDE-text");
+ TQVariant v = mime->property("X-KDE-text");
if (v.isValid())
status = v.toBool();
}
@@ -339,10 +339,10 @@ bool QuantaCommon::checkMimeGroup(const KURL& url, const QString& group)
}
/** Return true, if the url has the mimetype type. */
-bool QuantaCommon::checkMimeType(const KURL& url, const QString& type)
+bool QuantaCommon::checkMimeType(const KURL& url, const TQString& type)
{
bool status = false;
- QString mimetype = KMimeType::findByURL(url)->name();
+ TQString mimetype = KMimeType::findByURL(url)->name();
mimetype = mimetype.section('/',-1);
if (mimetype == type) status = true;
@@ -350,10 +350,10 @@ bool QuantaCommon::checkMimeType(const KURL& url, const QString& type)
}
/** Return true, if the url has exactly the mimetype type. */
-bool QuantaCommon::checkExactMimeType(const KURL& url, const QString& type)
+bool QuantaCommon::checkExactMimeType(const KURL& url, const TQString& type)
{
bool status = false;
- QString mimetype = KMimeType::findByURL(url)->name();
+ TQString mimetype = KMimeType::findByURL(url)->name();
if (mimetype == type) status = true;
return status;
@@ -371,15 +371,15 @@ KURL QuantaCommon::convertToPath(const KURL& url)
/** Return a string to be used when an url is saved to the project file.
Returns url.url() if it's an absolute url and
url.path() if the url is relative */
-QString QuantaCommon::qUrl(const KURL &url)
+TQString QuantaCommon::qUrl(const KURL &url)
{
- QString result = url.path();
+ TQString result = url.path();
if (url.path().startsWith("/")) result = url.url();
return result;
}
/** No descriptions */
-void QuantaCommon::dirCreationError(QWidget *widget, const KURL& url)
+void QuantaCommon::dirCreationError(TQWidget *widget, const KURL& url)
{
KMessageBox::error(widget, i18n("<qt>Cannot create folder<br><b>%1</b>.<br>Check that you have write permission in the parent folder or that the connection to<br><b>%2</b><br> is valid.</qt>")
.arg(url.prettyURL(0, KURL::StripFileProtocol))
@@ -388,26 +388,26 @@ void QuantaCommon::dirCreationError(QWidget *widget, const KURL& url)
/**
Adds the backslash before the special chars (like ?, *, . ) so the returned
string can be used in regular expressions.*/
-QString QuantaCommon::makeRxCompatible(const QString& s)
+TQString QuantaCommon::makeRxCompatible(const TQString& s)
{
const uint max = 7;
- const QRegExp rxs[max]={QRegExp("\\?"),
- QRegExp("\\*"),
- QRegExp("\\."),
- QRegExp("\\^"),
- QRegExp("\\$"),
- QRegExp("\\{"),
- QRegExp("\\}")
+ const TQRegExp rxs[max]={TQRegExp("\\?"),
+ TQRegExp("\\*"),
+ TQRegExp("\\."),
+ TQRegExp("\\^"),
+ TQRegExp("\\$"),
+ TQRegExp("\\{"),
+ TQRegExp("\\}")
};
- const QString strs[max]={QString("\\?"),
- QString("\\*"),
- QString("\\."),
- QString("\\^"),
- QString("\\$"),
- QString("\\{"),
- QString("\\}")
+ const TQString strs[max]={TQString("\\?"),
+ TQString("\\*"),
+ TQString("\\."),
+ TQString("\\^"),
+ TQString("\\$"),
+ TQString("\\{"),
+ TQString("\\}")
};
- QString str = s;
+ TQString str = s;
for (uint i = 0; i < max - 1; i++)
{
str.replace(rxs[i], strs[i]);
@@ -417,11 +417,11 @@ QString QuantaCommon::makeRxCompatible(const QString& s)
}
/** Returns the translated a_str in English. A "back-translation" useful e.g in case of CSS elements selected from a listbox. */
-QString QuantaCommon::i18n2normal(const QString& a_str)
+TQString QuantaCommon::i18n2normal(const TQString& a_str)
{
-//TODO: a QMap lookup would be faster, but we need a pre-built QMap<QString,QString>
+//TODO: a TQMap lookup would be faster, but we need a pre-built TQMap<TQString,TQString>
const int keywordNum = 15 *5;
- const QString keywords[keywordNum] =
+ const TQString keywords[keywordNum] =
{"normal", "italic", "oblique", "serif", "sans-serif",
"cursive", "fantasy", "monospace", "small-caps", "lighter",
"bold", "bolder", "xx-small", "x-small", "small",
@@ -437,7 +437,7 @@ QString QuantaCommon::i18n2normal(const QString& a_str)
"none", "pre", "nowrap", "disc", "circle",
"square", "decimal", "lower-roman","upper-roman","lower-alpha",
"upper-alpha","inside","outside", "auto", "both" };
- QString str = a_str;
+ TQString str = a_str;
if (!a_str.isEmpty())
{
for (int i = 0; i < keywordNum; i++)
@@ -452,15 +452,15 @@ QString QuantaCommon::i18n2normal(const QString& a_str)
return str;
}
-static const QChar space(' ');
+static const TQChar space(' ');
-void QuantaCommon::removeCommentsAndQuotes(QString &str, const DTDStruct *dtd)
+void QuantaCommon::removeCommentsAndQuotes(TQString &str, const DTDStruct *dtd)
{
//Replace all the commented strings and the escaped quotation marks (\", \')
// with spaces so they will not mess up our parsing
int pos = 0;
int l;
- QString s;
+ TQString s;
while (pos != -1)
{
pos = dtd->commentsStartRx.search(str, pos);
@@ -500,7 +500,7 @@ void QuantaCommon::removeCommentsAndQuotes(QString &str, const DTDStruct *dtd)
}
//Now replace the quoted strings with spaces
- QRegExp strRx("(\"[^\"]*\"|'[^']*')");
+ TQRegExp strRx("(\"[^\"]*\"|'[^']*')");
pos = 0;
while (pos != -1)
{
@@ -518,13 +518,13 @@ void QuantaCommon::removeCommentsAndQuotes(QString &str, const DTDStruct *dtd)
}
-bool QuantaCommon::insideCommentsOrQuotes(int position, const QString &string, const DTDStruct *dtd)
+bool QuantaCommon::insideCommentsOrQuotes(int position, const TQString &string, const DTDStruct *dtd)
{
//Return true if position is inside a commented or quoted string
- QString str = string;
+ TQString str = string;
int pos = 0;
int l;
- QString s;
+ TQString s;
while (pos != -1)
{
pos = dtd->commentsStartRx.search(str, pos);
@@ -568,7 +568,7 @@ bool QuantaCommon::insideCommentsOrQuotes(int position, const QString &string, c
}
//Now replace the quoted strings with spaces
- const QRegExp strRx("(\"[^\"]*\"|'[^']*')");
+ const TQRegExp strRx("(\"[^\"]*\"|'[^']*')");
pos = 0;
while (pos != -1)
{
@@ -589,14 +589,14 @@ bool QuantaCommon::insideCommentsOrQuotes(int position, const QString &string, c
return false;
}
-DCOPReply QuantaCommon::callDCOPMethod(const QString& interface, const QString& method, const QString& arguments)
+DCOPReply QuantaCommon::callDCOPMethod(const TQString& interface, const TQString& method, const TQString& arguments)
{
- QStringList argumentList = QStringList::split(",", arguments, true);
- QString app = "quanta";
+ TQStringList argumentList = TQStringList::split(",", arguments, true);
+ TQString app = "quanta";
if (!kapp->inherits("KUniqueApplication"))
{
pid_t pid = ::getpid();
- app += QString("-%1").arg(pid);
+ app += TQString("-%1").arg(pid);
}
DCOPRef quantaRef(app.utf8(), interface.utf8());
DCOPReply reply;
@@ -627,7 +627,7 @@ DCOPReply QuantaCommon::callDCOPMethod(const QString& interface, const QString&
return reply;
}
-void QuantaCommon::normalizeStructure(QString f,QStringList& l)
+void QuantaCommon::normalizeStructure(TQString f,TQStringList& l)
{
f.remove("\t");
f.remove("\n");
@@ -635,7 +635,7 @@ void QuantaCommon::normalizeStructure(QString f,QStringList& l)
while(f.contains("<"))
{
- QString z(f);
+ TQString z(f);
z.truncate(z.find(">")+1);
z.remove(0,z.find("<"));
f.remove(0,f.find(">")+1);
@@ -649,26 +649,26 @@ bool QuantaCommon::closesTag(Tag *tag1, Tag *tag2)
{
if (!tag2->nameSpace.isEmpty())
return false; //namespace missmatch
- QString tag1Name = tag1->dtd()->caseSensitive ? tag1->name : tag1->name.upper();
- QString tag2Name = tag2->dtd()->caseSensitive ? tag2->name : tag2->name.upper();
+ TQString tag1Name = tag1->dtd()->caseSensitive ? tag1->name : tag1->name.upper();
+ TQString tag2Name = tag2->dtd()->caseSensitive ? tag2->name : tag2->name.upper();
if ("/" + tag1Name != tag2Name)
return false; //not the closing tag
} else
{
if (tag2->nameSpace.isEmpty())
return false; //namespace missmatch
- QString tag1Name = tag1->dtd()->caseSensitive ? (tag1->nameSpace + tag1->name) : (tag1->nameSpace.upper() + tag1->name.upper());
- QString tag2Name = tag2->dtd()->caseSensitive ? (tag2->nameSpace + tag2->name) : (tag2->nameSpace.upper() + tag2->name.upper());
+ TQString tag1Name = tag1->dtd()->caseSensitive ? (tag1->nameSpace + tag1->name) : (tag1->nameSpace.upper() + tag1->name.upper());
+ TQString tag2Name = tag2->dtd()->caseSensitive ? (tag2->nameSpace + tag2->name) : (tag2->nameSpace.upper() + tag2->name.upper());
if ("/" + tag1Name != tag2Name)
return false; //namespace missmatch or not the closing tag
}
return true;
}
-bool QuantaCommon::closesTag(QString namespaceName, QString tagName, bool caseSensitive,
- QString namespaceName2, QString tagName2, bool caseSensitive2)
+bool QuantaCommon::closesTag(TQString namespaceName, TQString tagName, bool caseSensitive,
+ TQString namespaceName2, TQString tagName2, bool caseSensitive2)
{
- QString tag1Name, tag2Name;
+ TQString tag1Name, tag2Name;
if(namespaceName.isEmpty())
{
if(!namespaceName.isEmpty())
@@ -692,7 +692,7 @@ bool QuantaCommon::closesTag(QString namespaceName, QString tagName, bool caseSe
return true;
}
-int QuantaCommon::denyBinaryInsert(QWidget *window)
+int QuantaCommon::denyBinaryInsert(TQWidget *window)
{
int result = KMessageBox::questionYesNo(window, i18n("The file type is not recognized. \
Opening binary files may confuse Quanta.\n Are you sure you want to open this file?"),
@@ -700,25 +700,25 @@ int QuantaCommon::denyBinaryInsert(QWidget *window)
return result;
}
-bool QuantaCommon::checkOverwrite(const KURL& url, QWidget *window)
+bool QuantaCommon::checkOverwrite(const KURL& url, TQWidget *window)
{
bool result = true;
if (QExtFileInfo::exists(url, false, window))
{
if (KMessageBox::warningContinueCancel(window,
- i18n( "<qt>The file <b>%1</b> already exists.<br>Do you want to overwrite it?</qt>" ).arg(url.prettyURL(0, KURL::StripFileProtocol)), QString::null, i18n("Overwrite")) == KMessageBox::Cancel)
+ i18n( "<qt>The file <b>%1</b> already exists.<br>Do you want to overwrite it?</qt>" ).arg(url.prettyURL(0, KURL::StripFileProtocol)), TQString::null, i18n("Overwrite")) == KMessageBox::Cancel)
result = false;
}
return result;
}
-QStringList QuantaCommon::readPathListEntry(KConfig *config, const QString &pKey)
+TQStringList QuantaCommon::readPathListEntry(KConfig *config, const TQString &pKey)
{
- QStringList list = config->readPathListEntry(pKey);
- QStringList::Iterator end = list.end();
- for (QStringList::Iterator it = list.begin(); it != end; ++it)
+ TQStringList list = config->readPathListEntry(pKey);
+ TQStringList::Iterator end = list.end();
+ for (TQStringList::Iterator it = list.begin(); it != end; ++it)
{
KURL u = KURL::fromPathOrURL(*it);
if (u.isValid() && u.isLocalFile())
@@ -730,9 +730,9 @@ QStringList QuantaCommon::readPathListEntry(KConfig *config, const QString &pKey
return list;
}
-QString QuantaCommon::readPathEntry(KConfig *config, const QString &pKey)
+TQString QuantaCommon::readPathEntry(KConfig *config, const TQString &pKey)
{
- QString path = config->readPathEntry(pKey);
+ TQString path = config->readPathEntry(pKey);
KURL u = KURL::fromPathOrURL(path);
if (u.isValid() && u.isLocalFile())
{
@@ -742,12 +742,12 @@ QString QuantaCommon::readPathEntry(KConfig *config, const QString &pKey)
return path;
}
-QString QuantaCommon::encodedChar(uint code)
+TQString QuantaCommon::encodedChar(uint code)
{
if (replacementMap.contains(code))
- return QString("%1;").arg(replacementMap[code]);
+ return TQString("%1;").arg(replacementMap[code]);
else
- return QString("&#%1;").arg(code);
+ return TQString("&#%1;").arg(code);
}