[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-workspace] plasma/generic/runners/calculator: the thread handling is consistent and fast enough
From: Aaron Seigo <aseigo () kde ! org>
Date: 2013-02-13 13:02:49
Message-ID: 20130213130249.77447A6091 () git ! kde ! org
[Download RAW message or body]
Git commit 144dee0f134043a0bf5600912573d39f78179a7a by Aaron Seigo.
Committed on 13/02/2013 at 14:01.
Pushed by aseigo into branch 'master'.
the thread handling is consistent and fast enough to drop the '=' requirement now
M +4 -7 plasma/generic/runners/calculator/calculatorrunner.cpp
http://commits.kde.org/kde-workspace/144dee0f134043a0bf5600912573d39f78179a7a
diff --git a/plasma/generic/runners/calculator/calculatorrunner.cpp \
b/plasma/generic/runners/calculator/calculatorrunner.cpp index 684bc4e..54c3b72 \
100644
--- a/plasma/generic/runners/calculator/calculatorrunner.cpp
+++ b/plasma/generic/runners/calculator/calculatorrunner.cpp
@@ -49,6 +49,7 @@ CalculatorRunner::CalculatorRunner( QObject* parent, const \
QVariantList &args )
QString description = i18n("Calculates the value of :q: when :q: is made up of \
numbers and "
"mathematical symbols such as +, -, /, * and ^.");
+ addSyntax(Plasma::RunnerSyntax(":q:", description));
addSyntax(Plasma::RunnerSyntax("=:q:", description));
addSyntax(Plasma::RunnerSyntax(":q:=", description));
}
@@ -63,11 +64,11 @@ CalculatorRunner::~CalculatorRunner()
void CalculatorRunner::powSubstitutions(QString& cmd)
{
if (cmd.contains("e+", Qt::CaseInsensitive)) {
- cmd=cmd.replace("e+", "*10^", Qt::CaseInsensitive);
+ cmd = cmd.replace("e+", "*10^", Qt::CaseInsensitive);
}
if (cmd.contains("e-", Qt::CaseInsensitive)) {
- cmd=cmd.replace("e-", "*10^-", Qt::CaseInsensitive);
+ cmd = cmd.replace("e-", "*10^-", Qt::CaseInsensitive);
}
// the below code is scary mainly because we have to honor priority
@@ -204,7 +205,7 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
//no meanless space between friendly guys: helps simplify code
cmd = cmd.trimmed().remove(' ');
- if (cmd.length() < 4) {
+ if (cmd.length() < 3) {
return;
}
@@ -226,9 +227,6 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
cmd.remove(0, cmd.indexOf('=') + 1);
} else if (cmd.endsWith('=')) {
cmd.chop(1);
- } else {
- // we don't have an actionable equation here
- return;
}
if (cmd.isEmpty()) {
@@ -241,7 +239,6 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
#endif
QString result = calculate(cmd);
-
if (!result.isEmpty() && result != cmd) {
if (toHex) {
result = "0x" + QString::number(result.toInt(), 16).toUpper();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic