summaryrefslogtreecommitdiffstats
path: root/kommander/widget/expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kommander/widget/expression.cpp')
-rw-r--r--kommander/widget/expression.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/kommander/widget/expression.cpp b/kommander/widget/expression.cpp
index 88d46b51..d29d94e8 100644
--- a/kommander/widget/expression.cpp
+++ b/kommander/widget/expression.cpp
@@ -22,17 +22,17 @@ Expression::Expression() : m_start(0), m_error(false)
{
}
-Expression::Expression(const QString& expr)
+Expression::Expression(const TQString& expr)
{
*this = expr;
}
-Expression& Expression::operator=(const QString& s)
+Expression& Expression::operator=(const TQString& s)
{
m_start = 0;
m_error = false;
m_parts.clear();
- const QString single = "()<>!+-/*%";
+ const TQString single = "()<>!+-/*%";
int start = 0;
int len = s.length();
int i = 0;
@@ -41,30 +41,30 @@ Expression& Expression::operator=(const QString& s)
if (((s[i] == '>' || s[i] == '<' || s[i] == '=' || s[i] == '!') &&
s[i + 1] == '=') || (s[i] == '<' && s[i + 1] == '>'))
{
- m_parts.append(QVariant(s.mid(i, 2)));
+ m_parts.append(TQVariant(s.mid(i, 2)));
i += 2;
} else if (s[i].isDigit())
{
i++;
bool decimal = false;
- while (i < len && (s[i].isDigit() || (!decimal && s[i] == QChar('.'))))
+ while (i < len && (s[i].isDigit() || (!decimal && s[i] == TQChar('.'))))
{
if (s[i] == '.')
decimal = true;
i++;
}
if (decimal)
- m_parts.append(QVariant(s.mid(start, i - start).toDouble()));
+ m_parts.append(TQVariant(s.mid(start, i - start).toDouble()));
else
- m_parts.append(QVariant(s.mid(start, i - start).toInt()));
+ m_parts.append(TQVariant(s.mid(start, i - start).toInt()));
} else if (single.contains(s[i]))
- m_parts.append(QVariant(QString(s[i++])));
+ m_parts.append(TQVariant(TQString(s[i++])));
else if (s[i] == '\"')
{
i++;
while (i < len && s[i] != '\"')
i++;
- m_parts.append(QVariant(s.mid(start + 1, i - start - 1)));
+ m_parts.append(TQVariant(s.mid(start + 1, i - start - 1)));
i++;
} else if (s[i].isSpace())
while (i < len && s[i].isSpace())
@@ -73,25 +73,25 @@ Expression& Expression::operator=(const QString& s)
{
while (i < len && !s[i].isSpace())
i++;
- QString keyword = s.mid(start, i - start);
+ TQString keyword = s.mid(start, i - start);
if (keyword == "true")
- m_parts.append(QVariant(true));
+ m_parts.append(TQVariant(true));
else if (keyword == "false")
- m_parts.append(QVariant(false));
+ m_parts.append(TQVariant(false));
else /* will be deprecated soon */
- m_parts.append(QVariant(keyword));
+ m_parts.append(TQVariant(keyword));
}
start = i;
}
return *this;
}
-QString Expression::next() const
+TQString Expression::next() const
{
if (m_start < m_parts.count())
return m_parts[m_start].toString();
else
- return QString();
+ return TQString();
}
bool Expression::validate()
@@ -100,11 +100,11 @@ bool Expression::validate()
setError();
return !m_error;
}
-Expression::Type Expression::commonType(const QVariant v1, const QVariant v2) const
+Expression::Type Expression::commonType(const TQVariant v1, const TQVariant v2) const
{
- if (v1.type() == QVariant::String || v2.type() == QVariant::String)
+ if (v1.type() == TQVariant::String || v2.type() == TQVariant::String)
return TypeString;
- else if (v1.type() == QVariant::Double || v2.type() == QVariant::Double)
+ else if (v1.type() == TQVariant::Double || v2.type() == TQVariant::Double)
return TypeDouble;
return TypeInt;
}
@@ -115,7 +115,7 @@ static int expression_compareDouble(const double A, const double B)
}
-int Expression::compare(const QVariant v1, const QVariant v2) const
+int Expression::compare(const TQVariant v1, const TQVariant v2) const
{
switch (commonType(v1, v2)) {
case TypeString: return v1.toString().compare(v2.toString());
@@ -132,22 +132,22 @@ void Expression::setError(int pos)
m_error = true;
}
-QVariant Expression::parseNumber()
+TQVariant Expression::parseNumber()
{
if (!validate())
return -1;
return m_parts[m_start++];
}
-QVariant Expression::parseMinus()
+TQVariant Expression::parseMinus()
{
if (!validate()) return -1;
bool sign = next() == "-";
if (sign)
{
m_start++;
- QVariant value = parseNumber();
- if (value.type() == QVariant::Double)
+ TQVariant value = parseNumber();
+ if (value.type() == TQVariant::Double)
return -value.toDouble();
else
return -value.toInt();
@@ -158,13 +158,13 @@ QVariant Expression::parseMinus()
-QVariant Expression::parseBracket()
+TQVariant Expression::parseBracket()
{
if (!validate()) return -1;
if (next() == "(")
{
m_start++;
- QVariant value = parse();
+ TQVariant value = parse();
if (next() == ")")
m_start++;
else
@@ -176,15 +176,15 @@ QVariant Expression::parseBracket()
}
-QVariant Expression::parseMultiply()
+TQVariant Expression::parseMultiply()
{
if (!validate()) return -1;
- QVariant value = parseBracket();
- QString op = next();
+ TQVariant value = parseBracket();
+ TQString op = next();
while (op == "*" || op == "/" || op == "%")
{
m_start++;
- QVariant value2 = parseBracket();
+ TQVariant value2 = parseBracket();
Type mode = commonType(value, value2);
if (op == "*")
{
@@ -216,15 +216,15 @@ QVariant Expression::parseMultiply()
return value;
}
-QVariant Expression::parseAdd()
+TQVariant Expression::parseAdd()
{
if (!validate()) return -1;
- QVariant value = parseMultiply();
- QString op = next();
+ TQVariant value = parseMultiply();
+ TQString op = next();
while (op == "+" || op == "-")
{
m_start++;
- QVariant value2 = parseMultiply();
+ TQVariant value2 = parseMultiply();
Type mode = commonType(value, value2);
if (op == "+")
if (mode == TypeDouble)
@@ -241,15 +241,15 @@ QVariant Expression::parseAdd()
return value;
}
-QVariant Expression::parseComparison()
+TQVariant Expression::parseComparison()
{
if (!validate()) return -1;
- QVariant value = parseAdd();
- QString cmp = next();
+ TQVariant value = parseAdd();
+ TQString cmp = next();
if (cmp == "<" || cmp == "<=" || cmp == "==" || cmp == ">=" || cmp == ">" || cmp == "<>" || cmp == "!=")
{
m_start++;
- QVariant value2 = parseAdd();
+ TQVariant value2 = parseAdd();
if (cmp == "<")
return compare(value, value2) < 0;
else if (cmp == "<=")
@@ -266,7 +266,7 @@ QVariant Expression::parseComparison()
return value;
}
-QVariant Expression::parseNot()
+TQVariant Expression::parseNot()
{
if (next() == "!" || next() == "not")
{
@@ -277,10 +277,10 @@ QVariant Expression::parseNot()
return parseComparison();
}
-QVariant Expression::parseAnd()
+TQVariant Expression::parseAnd()
{
if (!validate()) return -1;
- QVariant value = parseNot();
+ TQVariant value = parseNot();
while (next() == "&&" || next() == "and")
{
m_start++;
@@ -290,10 +290,10 @@ QVariant Expression::parseAnd()
return value;
}
-QVariant Expression::parseOr()
+TQVariant Expression::parseOr()
{
if (!validate()) return -1;
- QVariant value = parseAnd();
+ TQVariant value = parseAnd();
while (next() == "||" || next() == "or")
{
m_start++;
@@ -302,31 +302,31 @@ QVariant Expression::parseOr()
return value;
}
-QVariant Expression::parse()
+TQVariant Expression::parse()
{
return parseOr();
}
-QVariant Expression::value(bool* valid)
+TQVariant Expression::value(bool* valid)
{
m_start = 0;
m_error = false;
- QVariant val = parse();
+ TQVariant val = parse();
if (valid)
*valid = !m_error && m_start == m_parts.count();
return val;
}
-QVariant Expression::value(const QString& s, bool* valid)
+TQVariant Expression::value(const TQString& s, bool* valid)
{
*this = s;
return value(valid);
}
-bool Expression::isTrue(const QString& s, bool* valid)
+bool Expression::isTrue(const TQString& s, bool* valid)
{
- QVariant v = value(s, valid);
- return (v.type() == QVariant::String && !v.toString().isNull()) ||
- (v.type() != QVariant::String && v.toInt() != 0);
+ TQVariant v = value(s, valid);
+ return (v.type() == TQVariant::String && !v.toString().isNull()) ||
+ (v.type() != TQVariant::String && v.toInt() != 0);
}