mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-24 02:42:52 +00:00
kdeplasma-addons: reimplement calculator applet and move it to kde-workspace repo
because there are two applets that essentially do the same and there is also the kcalc application one of the applets (qalculate) is dropped Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e89c2966f3
commit
c15b5a7078
28 changed files with 0 additions and 3809 deletions
|
@ -17,13 +17,6 @@ set_package_properties(KDE4Workspace PROPERTIES
|
||||||
PURPOSE "Needed for building several Plasma plugins"
|
PURPOSE "Needed for building several Plasma plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_optional_find_package(Qalculate)
|
|
||||||
set_package_properties(Qalculate PROPERTIES
|
|
||||||
DESCRIPTION "Qalculate Library"
|
|
||||||
URL "http://qalculate.sourceforge.net/"
|
|
||||||
PURPOSE "Needed for building the Qalculate plasma applet"
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/libs
|
${CMAKE_CURRENT_SOURCE_DIR}/libs
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,7 +6,6 @@ add_subdirectory(bball)
|
||||||
add_subdirectory(blackboard)
|
add_subdirectory(blackboard)
|
||||||
add_subdirectory(bookmarks)
|
add_subdirectory(bookmarks)
|
||||||
add_subdirectory(bubblemon)
|
add_subdirectory(bubblemon)
|
||||||
add_subdirectory(calculator)
|
|
||||||
add_subdirectory(fifteenPuzzle)
|
add_subdirectory(fifteenPuzzle)
|
||||||
add_subdirectory(fileWatcher)
|
add_subdirectory(fileWatcher)
|
||||||
add_subdirectory(frame)
|
add_subdirectory(frame)
|
||||||
|
@ -33,7 +32,3 @@ if(KDE4WORKSPACE_FOUND)
|
||||||
add_subdirectory(weather)
|
add_subdirectory(weather)
|
||||||
add_subdirectory(icontasks)
|
add_subdirectory(icontasks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (QALCULATE_FOUND)
|
|
||||||
add_subdirectory(qalculate)
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
project(plasma-calculator)
|
|
||||||
|
|
||||||
install(DIRECTORY package/
|
|
||||||
DESTINATION ${KDE4_DATA_INSTALL_DIR}/plasma/plasmoids/calculator)
|
|
||||||
|
|
||||||
install(FILES package/metadata.desktop
|
|
||||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
|
||||||
RENAME plasma-applet-calculator.desktop)
|
|
|
@ -1,2 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_calculator.pot
|
|
|
@ -1,392 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (C) 2012 by Davide Bettio <davide.bettio@kdemail.net> *
|
|
||||||
* Copyright (C) 2012 by Luiz Romário Santana Rios <luizromario@gmail.com> *
|
|
||||||
* Copyright (C) 2007 by Henry Stanaland <stanaland@gmail.com> *
|
|
||||||
* Copyright (C) 2008 by Laurent Montel <montel@kde.org> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program; if not, write to the *
|
|
||||||
* Free Software Foundation, Inc., *
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
import QtQuick 1.0;
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
|
||||||
import org.kde.locale 0.1 as Locale
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: main;
|
|
||||||
|
|
||||||
property int minimumWidth: 200;
|
|
||||||
property int minimumHeight: 250;
|
|
||||||
|
|
||||||
property int buttonHeight: (height - displayFrame.height - 6 * buttonsGrid.spacing) / 5;
|
|
||||||
property int buttonWidth: (width / 4) - buttonsGrid.spacing;
|
|
||||||
|
|
||||||
property real result: 0;
|
|
||||||
property bool hasResult: false;
|
|
||||||
property bool showingInput: true;
|
|
||||||
property bool showingResult: false;
|
|
||||||
property string operator: "";
|
|
||||||
property real operand: 0;
|
|
||||||
property bool commaPressed: false;
|
|
||||||
property int decimals: 0;
|
|
||||||
property int inputSize: 0;
|
|
||||||
|
|
||||||
property int maxInputLength: 15; // More than that and the number notation turns scientific
|
|
||||||
// (i.e.: 1.32324e+12)
|
|
||||||
|
|
||||||
Keys.onDigit0Pressed: { digitClicked(0); }
|
|
||||||
Keys.onDigit1Pressed: { digitClicked(1); }
|
|
||||||
Keys.onDigit2Pressed: { digitClicked(2); }
|
|
||||||
Keys.onDigit3Pressed: { digitClicked(3); }
|
|
||||||
Keys.onDigit4Pressed: { digitClicked(4); }
|
|
||||||
Keys.onDigit5Pressed: { digitClicked(5); }
|
|
||||||
Keys.onDigit6Pressed: { digitClicked(6); }
|
|
||||||
Keys.onDigit7Pressed: { digitClicked(7); }
|
|
||||||
Keys.onDigit8Pressed: { digitClicked(8); }
|
|
||||||
Keys.onDigit9Pressed: { digitClicked(9); }
|
|
||||||
Keys.onEscapePressed: { allClearClicked(); }
|
|
||||||
Keys.onDeletePressed: { clearClicked(); }
|
|
||||||
Keys.onPressed: {
|
|
||||||
switch (event.key) {
|
|
||||||
case Qt.Key_Plus:
|
|
||||||
setOperator("+");
|
|
||||||
break;
|
|
||||||
case Qt.Key_Minus:
|
|
||||||
setOperator("-");
|
|
||||||
break;
|
|
||||||
case Qt.Key_Asterisk:
|
|
||||||
setOperator("*");
|
|
||||||
break;
|
|
||||||
case Qt.Key_Slash:
|
|
||||||
setOperator("/");
|
|
||||||
break;
|
|
||||||
case Qt.Key_Period:
|
|
||||||
decimalClicked();
|
|
||||||
break;
|
|
||||||
case Qt.Key_Equal:
|
|
||||||
case Qt.Key_Return:
|
|
||||||
case Qt.Key_Enter:
|
|
||||||
equalsClicked();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function digitClicked(digit) {
|
|
||||||
if (inputSize >= maxInputLength) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showingResult) {
|
|
||||||
allClearClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commaPressed) {
|
|
||||||
++decimals;
|
|
||||||
tenToTheDecimals = Math.pow(10, decimals);
|
|
||||||
operand = (operand * tenToTheDecimals + digit) / tenToTheDecimals;
|
|
||||||
} else {
|
|
||||||
operand = operand * 10 + digit;
|
|
||||||
}
|
|
||||||
display.text = operand;
|
|
||||||
showingInput = true;
|
|
||||||
++inputSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
function decimalClicked() {
|
|
||||||
if (showingResult) {
|
|
||||||
allClearClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
commaPressed = true;
|
|
||||||
showingInput = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function doOperation() {
|
|
||||||
switch (operator) {
|
|
||||||
case "+":
|
|
||||||
result += operand;
|
|
||||||
break;
|
|
||||||
case "-":
|
|
||||||
result -= operand;
|
|
||||||
break;
|
|
||||||
case "*":
|
|
||||||
result *= operand;
|
|
||||||
break;
|
|
||||||
case "/":
|
|
||||||
result /= operand;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
display.text = algarismCount(result * Math.pow(10, decimals)) > maxInputLength ? "E" : result;
|
|
||||||
showingInput = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearOperand() {
|
|
||||||
operand = 0;
|
|
||||||
commaPressed = false;
|
|
||||||
decimals = 0;
|
|
||||||
inputSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setOperator(op) {
|
|
||||||
if (!hasResult) {
|
|
||||||
result = operand;
|
|
||||||
hasResult = true;
|
|
||||||
} else if (showingInput) {
|
|
||||||
doOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
clearOperand();
|
|
||||||
operator = op;
|
|
||||||
showingResult = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function equalsClicked() {
|
|
||||||
showingResult = true;
|
|
||||||
doOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearClicked() {
|
|
||||||
clearOperand();
|
|
||||||
operator = "";
|
|
||||||
display.text = operand;
|
|
||||||
showingInput = true;
|
|
||||||
showingResult = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function allClearClicked() {
|
|
||||||
clearClicked();
|
|
||||||
result = 0;
|
|
||||||
hasResult = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function algarismCount(number) {
|
|
||||||
return number == 0 ? 1 : Math.floor(Math.log(Math.abs(number))/Math.log(10)) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Locale.Locale {
|
|
||||||
id: locale;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.Theme {
|
|
||||||
id: plasmaTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: plasmoid;
|
|
||||||
onPopupEvent: {
|
|
||||||
main.focus = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
focus: true;
|
|
||||||
spacing: 4;
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: displayFrame;
|
|
||||||
width: buttonsGrid.width;
|
|
||||||
height: 2 * display.font.pixelSize;
|
|
||||||
imagePath: "widgets/frame";
|
|
||||||
prefix: "sunken";
|
|
||||||
|
|
||||||
TextEdit {
|
|
||||||
id: display;
|
|
||||||
anchors {
|
|
||||||
fill: parent;
|
|
||||||
margins: parent.margins.right;
|
|
||||||
}
|
|
||||||
text: "0";
|
|
||||||
font.pointSize: 16;
|
|
||||||
font.weight: Font.Bold;
|
|
||||||
color: plasmaTheme.viewTextColor;
|
|
||||||
horizontalAlignment: TextEdit.AlignRight;
|
|
||||||
verticalAlignment: TextEdit.AlignVCenter;
|
|
||||||
readOnly: true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Grid {
|
|
||||||
id: buttonsGrid;
|
|
||||||
columns: 4;
|
|
||||||
rows: 5;
|
|
||||||
spacing: 4;
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the clear button", "C");
|
|
||||||
onClicked: clearClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the division button", "÷");
|
|
||||||
onClicked: setOperator("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the multiplication button", "×");
|
|
||||||
onClicked: setOperator("*");
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the all clear button", "AC");
|
|
||||||
onClicked: allClearClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "7";
|
|
||||||
onClicked: digitClicked(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "8";
|
|
||||||
onClicked: digitClicked(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "9";
|
|
||||||
onClicked: digitClicked(9);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the minus button", "-");
|
|
||||||
onClicked: setOperator("-");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "4";
|
|
||||||
onClicked: digitClicked(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "5";
|
|
||||||
onClicked: digitClicked(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "6";
|
|
||||||
onClicked: digitClicked(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: i18nc("Text of the plus button", "+");
|
|
||||||
onClicked: setOperator("+");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "1";
|
|
||||||
onClicked: digitClicked(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "2";
|
|
||||||
onClicked: digitClicked(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: "3";
|
|
||||||
onClicked: digitClicked(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: ansPlaceHolder;
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: zeroPlaceHolder;
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: zeroPlaceHolder2;
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
text: locale.toLocale().decimalPoint;
|
|
||||||
onClicked: decimalClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: ansPlaceHolder2;
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
width: buttonWidth * 2 + buttonsGrid.spacing;
|
|
||||||
height: buttonHeight;
|
|
||||||
x: zeroPlaceHolder.x + buttonsGrid.x;
|
|
||||||
y: zeroPlaceHolder.y + buttonsGrid.y;
|
|
||||||
text: "0";
|
|
||||||
onClicked: digitClicked(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
|
||||||
id: ansButton;
|
|
||||||
width: buttonWidth;
|
|
||||||
height: buttonHeight * 2 + buttonsGrid.spacing;
|
|
||||||
x: ansPlaceHolder.x + buttonsGrid.x;
|
|
||||||
y: ansPlaceHolder.y + buttonsGrid.y;
|
|
||||||
text: i18nc("Text of the equals button", "=");
|
|
||||||
onClicked: equalsClicked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,135 +0,0 @@
|
||||||
[Desktop Entry]
|
|
||||||
Name=Calculator
|
|
||||||
Name[ar]=آلة حاسبة
|
|
||||||
Name[ast]=Calculadora
|
|
||||||
Name[bs]=kalkulator
|
|
||||||
Name[ca]=Calculadora
|
|
||||||
Name[ca@valencia]=Calculadora
|
|
||||||
Name[cs]=Kalkulačka
|
|
||||||
Name[da]=Lommeregner
|
|
||||||
Name[de]=Rechner
|
|
||||||
Name[el]=Αριθμομηχανή
|
|
||||||
Name[en_GB]=Calculator
|
|
||||||
Name[eo]=Kalkulilo
|
|
||||||
Name[es]=Calculadora
|
|
||||||
Name[et]=Kalkulaator
|
|
||||||
Name[eu]=Kalkulagailua
|
|
||||||
Name[fi]=Laskin
|
|
||||||
Name[fr]=Calculatrice
|
|
||||||
Name[ga]=Áireamhán
|
|
||||||
Name[gl]=Calculadora
|
|
||||||
Name[he]=מחשבון
|
|
||||||
Name[hr]=Kalkulator
|
|
||||||
Name[hu]=Számológép
|
|
||||||
Name[is]=Reiknivél
|
|
||||||
Name[it]=Calcolatrice
|
|
||||||
Name[ja]=計算機
|
|
||||||
Name[kk]=Калькулятор
|
|
||||||
Name[km]=ម៉ាស៊ីនគិតលេខ
|
|
||||||
Name[ko]=계산기
|
|
||||||
Name[ku]=Makîneya Hesaban
|
|
||||||
Name[lt]=Skaičiuotuvas
|
|
||||||
Name[lv]=Kalkulators
|
|
||||||
Name[mr]=गणकयंत्र
|
|
||||||
Name[nb]=Kalkulator
|
|
||||||
Name[nds]=Taschenreekner
|
|
||||||
Name[nl]=Rekenmachine
|
|
||||||
Name[nn]=Kalkulator
|
|
||||||
Name[oc]=Calculeta
|
|
||||||
Name[pa]=ਕੈਲਕੂਲੇਟਰ
|
|
||||||
Name[pl]=Kalkulator
|
|
||||||
Name[pt]=Calculadora
|
|
||||||
Name[pt_BR]=Calculadora
|
|
||||||
Name[ro]=Calculator
|
|
||||||
Name[ru]=Калькулятор
|
|
||||||
Name[sk]=Kalkulačka
|
|
||||||
Name[sl]=Računalo
|
|
||||||
Name[sq]=Makina Llogaritëse
|
|
||||||
Name[sr]=калкулатор
|
|
||||||
Name[sr@ijekavian]=калкулатор
|
|
||||||
Name[sr@ijekavianlatin]=kalkulator
|
|
||||||
Name[sr@latin]=kalkulator
|
|
||||||
Name[sv]=Miniräknare
|
|
||||||
Name[th]=เครื่องคิดเลข
|
|
||||||
Name[tr]=Hesap Makinesi
|
|
||||||
Name[ug]=ھېسابلىغۇچ
|
|
||||||
Name[uk]=Калькулятор
|
|
||||||
Name[wa]=Carculete
|
|
||||||
Name[x-test]=xxCalculatorxx
|
|
||||||
Name[zh_CN]=计算器
|
|
||||||
Name[zh_TW]=計算機
|
|
||||||
Comment=Calculate simple sums
|
|
||||||
Comment[ar]=احسب عمليات جمع بسيطة
|
|
||||||
Comment[ast]=Calcular sumes simples
|
|
||||||
Comment[bs]=Izračunajte jednostavne izraze
|
|
||||||
Comment[ca]=Calcula sumes senzilles
|
|
||||||
Comment[ca@valencia]=Calcula sumes senzilles
|
|
||||||
Comment[cs]=Jednoduché sčítání
|
|
||||||
Comment[da]=Beregn simple summer.
|
|
||||||
Comment[de]=Für kleine Rechenaufgaben
|
|
||||||
Comment[el]=Υπολογισμός απλών πράξεων
|
|
||||||
Comment[en_GB]=Calculate simple sums
|
|
||||||
Comment[es]=Calcular sumas sencillas
|
|
||||||
Comment[et]=Lihtne kalkulaator
|
|
||||||
Comment[eu]=Gehiketa errazak kalkulatu
|
|
||||||
Comment[fi]=Laske yksinkertaisia laskuja
|
|
||||||
Comment[fr]=Calcule des sommes simples
|
|
||||||
Comment[ga]=Áirigh suimeanna simplí
|
|
||||||
Comment[gl]=Calcula sumas simples
|
|
||||||
Comment[he]=מחשב סכומים פשוטים
|
|
||||||
Comment[hr]=Izračunaj jednostavne sume
|
|
||||||
Comment[hu]=Egyszerű számológép
|
|
||||||
Comment[is]=Reiknar einfaldar aðgerðir
|
|
||||||
Comment[it]=Calcola semplici somme
|
|
||||||
Comment[ja]=簡単な合計計算ができます
|
|
||||||
Comment[kk]=Қарапайым есептерді шығару
|
|
||||||
Comment[km]=គណនាផលបូកធម្មតា
|
|
||||||
Comment[ko]=간단한 계산기
|
|
||||||
Comment[ku]=Berhevkirinên hêsan hesab bike
|
|
||||||
Comment[lt]=Skaičiuoti paprastas sumas
|
|
||||||
Comment[lv]=Aprēķina vienkāršas summas
|
|
||||||
Comment[mr]=सोपी गणना करतो
|
|
||||||
Comment[nb]=Regn ut enkle regnestykker
|
|
||||||
Comment[nds]=Eenfache Saken utreken
|
|
||||||
Comment[nl]=Eenvoudige berekeningen
|
|
||||||
Comment[nn]=Grafisk kalkulator
|
|
||||||
Comment[pa]=ਸਧਾਰਨ ਜੋੜ ਕੱਢੋ
|
|
||||||
Comment[pl]=Obliczanie prostych sum
|
|
||||||
Comment[pt]=Calcular somas simples
|
|
||||||
Comment[pt_BR]=Calcula funções matemáticas básicas
|
|
||||||
Comment[ro]=Calculează sume simple
|
|
||||||
Comment[ru]=Вычисление простых выражений
|
|
||||||
Comment[sk]=Výpočet jednoduchých súm
|
|
||||||
Comment[sl]=Izračuna preproste vsote
|
|
||||||
Comment[sr]=Израчунајте једноставне изразе
|
|
||||||
Comment[sr@ijekavian]=Израчунајте једноставне изразе
|
|
||||||
Comment[sr@ijekavianlatin]=Izračunajte jednostavne izraze
|
|
||||||
Comment[sr@latin]=Izračunajte jednostavne izraze
|
|
||||||
Comment[sv]=Beräkna enkla summor
|
|
||||||
Comment[th]=คำนวณหาค่าที่ง่าย ๆ
|
|
||||||
Comment[tr]=Basit hesaplamalar yapın
|
|
||||||
Comment[uk]=Обчисліть прості суми
|
|
||||||
Comment[wa]=Cårculez des ptits carculs
|
|
||||||
Comment[x-test]=xxCalculate simple sumsxx
|
|
||||||
Comment[zh_CN]=计算简单的求和
|
|
||||||
Comment[zh_TW]=計算簡單的算式
|
|
||||||
Icon=accessories-calculator
|
|
||||||
Type=Service
|
|
||||||
ServiceTypes=Plasma/Applet,Plasma/PopupApplet
|
|
||||||
|
|
||||||
X-KDE-Library=plasma_applet_calculator
|
|
||||||
X-KDE-PluginInfo-Author=Henry Stanaland
|
|
||||||
X-KDE-PluginInfo-Email=stanaland@gmail.com
|
|
||||||
X-KDE-PluginInfo-Name=calculator
|
|
||||||
X-KDE-PluginInfo-Version=1.0
|
|
||||||
X-KDE-PluginInfo-Website=
|
|
||||||
X-KDE-PluginInfo-Category=Utilities
|
|
||||||
X-KDE-PluginInfo-Depends=
|
|
||||||
X-KDE-PluginInfo-License=GPL
|
|
||||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
||||||
|
|
||||||
X-Plasma-API=declarativeappletscript
|
|
||||||
X-Plasma-DefaultSize=200,250
|
|
||||||
X-Plasma-MainScript=ui/calculator.qml
|
|
||||||
X-Plasma-Requires-FileDialog=Unused
|
|
||||||
X-Plasma-Requires-LaunchApp=Unused
|
|
|
@ -1,34 +0,0 @@
|
||||||
project(plasma-qalculate)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
|
|
||||||
|
|
||||||
include_directories(${QALCULATE_INCLUDE_DIR})
|
|
||||||
|
|
||||||
# We add our source code here
|
|
||||||
set(qalculate_SRCS
|
|
||||||
qalculate_applet.cpp
|
|
||||||
qalculate_labels.cpp
|
|
||||||
qalculate_settings.cpp
|
|
||||||
qalculate_engine.cpp
|
|
||||||
qalculate_history.cpp
|
|
||||||
outputlabel.cpp
|
|
||||||
qalculate_graphicswidget.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Now make sure all files get to the right place
|
|
||||||
kde4_add_plugin(plasma_applet_qalculate ${qalculate_SRCS})
|
|
||||||
target_link_libraries(plasma_applet_qalculate
|
|
||||||
KDE4::plasma
|
|
||||||
KDE4::kdeui
|
|
||||||
KDE4::solid
|
|
||||||
KDE4::kio
|
|
||||||
${QALCULATE_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS plasma_applet_qalculate
|
|
||||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
|
||||||
|
|
||||||
install(FILES plasma-applet-qalculate.desktop
|
|
||||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
|
||||||
|
|
||||||
add_subdirectory(icons)
|
|
|
@ -1,674 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
|
@ -1,2 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
$XGETTEXT *.cpp -o $podir/plasma_applet_qalculate.pot
|
|
|
@ -1,25 +0,0 @@
|
||||||
Qalculate! Applet
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
You need KDE, version >= 4.2
|
|
||||||
|
|
||||||
-- Build instructions --
|
|
||||||
|
|
||||||
cd /where/your/applet/is/installed
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake .. -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
|
|
||||||
Restart plasma to load the applet
|
|
||||||
kquitapp plasma-desktop
|
|
||||||
plasma-desktop
|
|
||||||
|
|
||||||
or view it with
|
|
||||||
plasmoidviewer YourAppletName
|
|
||||||
|
|
||||||
You might need to run kbuildsycoca4
|
|
||||||
in order to get the .desktop file recognized.
|
|
||||||
|
|
||||||
APPLET WEBPAGE: http://wwwu.uni-klu.ac.at/magostin/qalculate.html
|
|
|
@ -1 +0,0 @@
|
||||||
kde4_install_icons( ${KDE4_ICON_INSTALL_DIR} )
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "outputlabel.h"
|
|
||||||
#include <QtGui/qgraphicssceneevent.h>
|
|
||||||
|
|
||||||
OutputLabel::OutputLabel(QGraphicsWidget *parent): Plasma::Label(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputLabel::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton) {
|
|
||||||
emit clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsProxyWidget::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OUTPUTLABEL_H
|
|
||||||
#define OUTPUTLABEL_H
|
|
||||||
|
|
||||||
#include <Plasma/Label>
|
|
||||||
|
|
||||||
class OutputLabel : public Plasma::Label
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
OutputLabel(QGraphicsWidget *parent=0);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void clicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // OUTPUTLABEL_H
|
|
|
@ -1,113 +0,0 @@
|
||||||
[Desktop Entry]
|
|
||||||
Name=Qalculate!
|
|
||||||
Name[ar]=الآلة حاسبة!
|
|
||||||
Name[ast]=Qalculate!
|
|
||||||
Name[bs]=Qalculate!
|
|
||||||
Name[ca]=Qalculate!
|
|
||||||
Name[ca@valencia]=Qalculate!
|
|
||||||
Name[cs]=Qalculate!
|
|
||||||
Name[da]=Qalculate!
|
|
||||||
Name[de]=Qalculate!
|
|
||||||
Name[el]=Qalculate!
|
|
||||||
Name[en_GB]=Qalculate!
|
|
||||||
Name[es]=Qalculate!
|
|
||||||
Name[et]=Qalculate!
|
|
||||||
Name[fi]=Qalculate!
|
|
||||||
Name[fr]=Calcule !
|
|
||||||
Name[ga]=Qalculate!
|
|
||||||
Name[gl]=Calculadora
|
|
||||||
Name[hr]=Qalculate!
|
|
||||||
Name[hu]=Qalculate!
|
|
||||||
Name[it]=Qalculate!
|
|
||||||
Name[ja]=Qalculate!
|
|
||||||
Name[kk]=Qalculate!
|
|
||||||
Name[km]=Qalculate!
|
|
||||||
Name[ko]=Qalculate!
|
|
||||||
Name[lt]=Qalculate!
|
|
||||||
Name[lv]=Qalculate!
|
|
||||||
Name[mr]=क्वेल्क्युलेट!
|
|
||||||
Name[nb]=Qalculate!
|
|
||||||
Name[nds]=Qalculate!
|
|
||||||
Name[nl]=Qalculate!
|
|
||||||
Name[nn]=Qalculate!
|
|
||||||
Name[pa]=ਕੈਲਕੂਲੇਟ!
|
|
||||||
Name[pl]=Qalculate!
|
|
||||||
Name[pt]=Qalculate!
|
|
||||||
Name[pt_BR]=Qalculate!
|
|
||||||
Name[ro]=Qalculează!
|
|
||||||
Name[ru]=Qalculate!
|
|
||||||
Name[sk]=Qalculate!
|
|
||||||
Name[sl]=Qalculate!
|
|
||||||
Name[sr]=Калкулејт
|
|
||||||
Name[sr@ijekavian]=Калкулејт
|
|
||||||
Name[sr@ijekavianlatin]=Qalculate!
|
|
||||||
Name[sr@latin]=Qalculate!
|
|
||||||
Name[sv]=Beräkna!
|
|
||||||
Name[tr]=Hesapla!
|
|
||||||
Name[ug]=Qalculate!
|
|
||||||
Name[uk]=Qalculate!
|
|
||||||
Name[wa]=Qarculete !
|
|
||||||
Name[x-test]=xxQalculate!xx
|
|
||||||
Name[zh_CN]=计算器
|
|
||||||
Name[zh_TW]=Qalculate!
|
|
||||||
Comment=A powerful mathematical equation solver
|
|
||||||
Comment[bs]=Moćni rijesavač matematičkih jednačina
|
|
||||||
Comment[ca]=Una calculadora potent d'equacions matemàtiques
|
|
||||||
Comment[ca@valencia]=Una calculadora potent d'equacions matemàtiques
|
|
||||||
Comment[cs]=Mocný nástroj pro řešení matematických rovnic
|
|
||||||
Comment[da]=Et kraftfuldt værktøj til at løse matematiske ligninger
|
|
||||||
Comment[de]=Ein leistungsfähiges Miniprogramm zum Lösen von mathematischen Gleichungen
|
|
||||||
Comment[el]=Ένα πανίσχυρο εργαλείο επίλυσης μαθηματικών εξισώσεων
|
|
||||||
Comment[en_GB]=A powerful mathematical equation solver
|
|
||||||
Comment[es]=Un potente sistema de resolución de ecuaciones matemáticas
|
|
||||||
Comment[et]=Võimas võrrandilahendaja
|
|
||||||
Comment[fi]=Tehokas matemaattisten lausekkeiden ratkaisija
|
|
||||||
Comment[fr]=Un puissant résolveur d'équations mathématiques
|
|
||||||
Comment[gl]=Un poderoso aplicativo para resolver ecuacións matemáticas
|
|
||||||
Comment[hr]=Napredanrazrješivač matematičkih jednadžbi
|
|
||||||
Comment[hu]=Hatékony matematikai egyenletmegoldó
|
|
||||||
Comment[it]=Un potente solutore di equazioni matematiche
|
|
||||||
Comment[kk]=Математикалық теңдіктерінің күшті шешім тапқышы
|
|
||||||
Comment[km]=A powerful mathematical equation solver
|
|
||||||
Comment[ko]=강력한 공학용 계산기
|
|
||||||
Comment[lt]=Galingas matematinių lygčių sprendiklis
|
|
||||||
Comment[lv]=Spēcīgs matemātisko vienādojumu rēķinātājs
|
|
||||||
Comment[mr]=गणितीय समीकरण सोडविणारा
|
|
||||||
Comment[nb]=En kraftig matematisk likningsløser
|
|
||||||
Comment[nds]=En deegt mathemaatsch Glieken-Löser
|
|
||||||
Comment[nl]=Een krachtige oplosser van mathematische vergelijkingen
|
|
||||||
Comment[nn]=Kraftig likningsløysar
|
|
||||||
Comment[pa]=ਤਾਕਤਵਰ ਗਣਿਤ ਸਮੀਕਰਨ ਹੱਲਕਰਤਾ
|
|
||||||
Comment[pl]=Zaawansowane narzędzie do rozwiązywania równań matematycznych
|
|
||||||
Comment[pt]=Um sistema poderoso de resolução de equações matemáticas
|
|
||||||
Comment[pt_BR]=Poderoso sistema de resolução de equações matemáticas
|
|
||||||
Comment[ro]=Un rezolvator puternic de ecuații matematice
|
|
||||||
Comment[ru]=Полноценное решение математических уравнений
|
|
||||||
Comment[sk]=Silný nástroj na riešenie matematických rovníc
|
|
||||||
Comment[sl]=Zmogljiv reševalnik matematičnih enačb
|
|
||||||
Comment[sr]=Моћни решавач математичких једначина
|
|
||||||
Comment[sr@ijekavian]=Моћни рјешавач математичких једначина
|
|
||||||
Comment[sr@ijekavianlatin]=Moćni rješavač matematičkih jednačina
|
|
||||||
Comment[sr@latin]=Moćni rešavač matematičkih jednačina
|
|
||||||
Comment[sv]=Ett kraftfullt verktyg för lösning av matematiska ekvationer
|
|
||||||
Comment[tr]=Gelişmiş bir matematiksel eşitlik çözücü
|
|
||||||
Comment[uk]=Потужний інструмент розв’язання рівнянь
|
|
||||||
Comment[x-test]=xxA powerful mathematical equation solverxx
|
|
||||||
Comment[zh_CN]=强大的数学求值器
|
|
||||||
Comment[zh_TW]=強大的數學方程式解題器
|
|
||||||
Icon=qalculate-applet
|
|
||||||
Type=Service
|
|
||||||
|
|
||||||
X-KDE-ServiceTypes=Plasma/Applet
|
|
||||||
X-KDE-Library=plasma_applet_qalculate
|
|
||||||
X-KDE-PluginInfo-Author=Matteo Agostinelli
|
|
||||||
X-KDE-PluginInfo-Email=agostinelli@gmail.com
|
|
||||||
X-KDE-PluginInfo-Name=qalculate
|
|
||||||
X-KDE-PluginInfo-Version=0.7.2
|
|
||||||
X-KDE-PluginInfo-Website=
|
|
||||||
X-KDE-PluginInfo-Category=Utilities
|
|
||||||
X-KDE-PluginInfo-Depends=
|
|
||||||
X-KDE-PluginInfo-License=GPL
|
|
||||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
||||||
X-Plasma-Requires-FileDialog=Unused
|
|
||||||
X-Plasma-Requires-LaunchApp=Unused
|
|
|
@ -1,333 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qalculate_applet.h"
|
|
||||||
#include "qalculate_settings.h"
|
|
||||||
#include "qalculate_engine.h"
|
|
||||||
#include "qalculate_history.h"
|
|
||||||
#include "qalculate_graphicswidget.h"
|
|
||||||
|
|
||||||
#include "outputlabel.h"
|
|
||||||
|
|
||||||
#include <KLocale>
|
|
||||||
#include <KLineEdit>
|
|
||||||
#include <KPushButton>
|
|
||||||
#include <KIcon>
|
|
||||||
#include <KAction>
|
|
||||||
#include <KConfigDialog>
|
|
||||||
|
|
||||||
#include <Plasma/LineEdit>
|
|
||||||
#include <Plasma/PushButton>
|
|
||||||
#include <Plasma/Label>
|
|
||||||
#include <Plasma/Theme>
|
|
||||||
#include <Plasma/Containment>
|
|
||||||
#include <Plasma/ToolTipContent>
|
|
||||||
#include <Plasma/ToolTipManager>
|
|
||||||
|
|
||||||
#include <QGraphicsWidget>
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QtGui/qgraphicssceneevent.h>
|
|
||||||
|
|
||||||
|
|
||||||
K_EXPORT_PLASMA_APPLET(qalculate, QalculateApplet)
|
|
||||||
|
|
||||||
QalculateApplet::QalculateApplet(QObject *parent, const QVariantList &args)
|
|
||||||
: Plasma::PopupApplet(parent, args),
|
|
||||||
m_graphicsWidget(0),
|
|
||||||
m_input(0),
|
|
||||||
m_output(0)
|
|
||||||
{
|
|
||||||
// this will get us the standard applet background, for free!
|
|
||||||
setBackgroundHints(DefaultBackground);
|
|
||||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
|
||||||
|
|
||||||
m_settings = new QalculateSettings(this);
|
|
||||||
m_engine = new QalculateEngine(m_settings, this);
|
|
||||||
m_history = new QalculateHistory(this);
|
|
||||||
connect(m_engine, SIGNAL(formattedResultReady(QString)), this, SLOT(displayResult(QString)));
|
|
||||||
connect(m_engine, SIGNAL(resultReady(QString)), this, SLOT(createTooltip()));
|
|
||||||
connect(m_engine, SIGNAL(resultReady(QString)), this, SLOT(receivedResult(QString)));
|
|
||||||
connect(m_settings, SIGNAL(accepted()), this, SLOT(evalNoHist()));
|
|
||||||
|
|
||||||
setHasConfigurationInterface(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QalculateApplet::~QalculateApplet()
|
|
||||||
{
|
|
||||||
if (hasFailedToLaunch()) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
delete m_input;
|
|
||||||
delete m_output;
|
|
||||||
delete m_graphicsWidget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::init()
|
|
||||||
{
|
|
||||||
m_settings->readSettings();
|
|
||||||
if (m_settings->updateExchangeRatesAtStartup()) {
|
|
||||||
m_engine->updateExchangeRates();
|
|
||||||
}
|
|
||||||
m_history->setHistoryItems(m_settings->historyItems());
|
|
||||||
|
|
||||||
graphicsWidget();
|
|
||||||
setupActions();
|
|
||||||
setPopupIcon(KIcon("qalculate-applet"));
|
|
||||||
createTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::setupActions()
|
|
||||||
{
|
|
||||||
KAction *actionCopy = new KAction(KIcon("edit-copy"), i18n("&Copy result to clipboard"), this);
|
|
||||||
actionCopy->setShortcut(Qt::CTRL + Qt::Key_R);
|
|
||||||
connect(actionCopy, SIGNAL(triggered(bool)), m_engine, SLOT(copyToClipboard(bool)));
|
|
||||||
addAction("copyToClipboard", actionCopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
int QalculateApplet::simplificationSize()
|
|
||||||
{
|
|
||||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).pointSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QalculateApplet::resultSize()
|
|
||||||
{
|
|
||||||
return simplificationSize()*2;
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsWidget* QalculateApplet::graphicsWidget()
|
|
||||||
{
|
|
||||||
if (!m_graphicsWidget) {
|
|
||||||
m_graphicsWidget = new QalculateGraphicsWidget(this);
|
|
||||||
m_graphicsWidget->setMinimumWidth(200);
|
|
||||||
|
|
||||||
m_input = new Plasma::LineEdit;
|
|
||||||
m_input->nativeWidget()->setClickMessage(i18n("Enter an expression..."));
|
|
||||||
m_input->nativeWidget()->setClearButtonShown(true);
|
|
||||||
m_input->setAttribute(Qt::WA_NoSystemBackground);
|
|
||||||
connect(m_input, SIGNAL(returnPressed()), this, SLOT(evaluate()));
|
|
||||||
connect(m_input->nativeWidget(), SIGNAL(clearButtonClicked()), this, SLOT(clearOutputLabel()));
|
|
||||||
connect(m_input->nativeWidget(), SIGNAL(editingFinished()), this, SLOT(evalNoHist()));
|
|
||||||
m_input->setAcceptedMouseButtons(Qt::LeftButton);
|
|
||||||
m_input->setFocusPolicy(Qt::StrongFocus);
|
|
||||||
|
|
||||||
m_output = new OutputLabel;
|
|
||||||
m_output->nativeWidget()->setAlignment(Qt::AlignCenter);
|
|
||||||
m_output->nativeWidget()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
QFont f = m_output->nativeWidget()->font();
|
|
||||||
f.setBold(true);
|
|
||||||
f.setPointSize(resultSize() / 2);
|
|
||||||
m_output->nativeWidget()->setFont(f);
|
|
||||||
m_output->setFocusPolicy(Qt::NoFocus);
|
|
||||||
connect(m_output, SIGNAL(clicked()), this, SLOT(giveFocus()));
|
|
||||||
|
|
||||||
m_historyButton = new Plasma::PushButton;
|
|
||||||
m_historyButton->setText(i18n("Show History"));
|
|
||||||
m_historyButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
connect(m_historyButton->nativeWidget(), SIGNAL(clicked()), this, SLOT(showHistory()));
|
|
||||||
|
|
||||||
m_historyList = new QGraphicsLinearLayout(Qt::Vertical);
|
|
||||||
|
|
||||||
QPalette palette = m_output->palette();
|
|
||||||
palette.setColor(QPalette::WindowText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
|
|
||||||
m_output->nativeWidget()->setPalette(palette);
|
|
||||||
|
|
||||||
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
|
|
||||||
m_layout->insertItem(0, m_input);
|
|
||||||
m_layout->insertItem(1, m_output);
|
|
||||||
if (!m_history->historyItems().isEmpty()) {
|
|
||||||
m_layout->insertItem(2, m_historyButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_graphicsWidget->setLayout(m_layout);
|
|
||||||
m_graphicsWidget->setFocusPolicy(Qt::StrongFocus);
|
|
||||||
|
|
||||||
configChanged();
|
|
||||||
clearOutputLabel();
|
|
||||||
|
|
||||||
connect(m_graphicsWidget, SIGNAL(giveFocus()), this, SLOT(giveFocus()));
|
|
||||||
connect(m_graphicsWidget, SIGNAL(nextHistory()), this, SLOT(nextHistory()));
|
|
||||||
connect(m_graphicsWidget, SIGNAL(previousHistory()), this, SLOT(previousHistory()));
|
|
||||||
//connect(this, SIGNAL(activated()), this, SLOT(giveFocus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_graphicsWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList< QAction* > QalculateApplet::contextualActions()
|
|
||||||
{
|
|
||||||
return QList< QAction* >() << action("copyToClipboard");
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::createTooltip()
|
|
||||||
{
|
|
||||||
if (containment()->containmentType() == Plasma::Containment::DesktopContainment) {
|
|
||||||
Plasma::ToolTipManager::self()->hide(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::ToolTipContent data;
|
|
||||||
data.setMainText(i18n("Qalculate!"));
|
|
||||||
data.setSubText(m_engine->lastResult());
|
|
||||||
data.setImage(KIcon("qalculate-applet").pixmap(IconSize(KIconLoader::Desktop)));
|
|
||||||
Plasma::ToolTipManager::self()->setContent(this, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::createConfigurationInterface(KConfigDialog* parent)
|
|
||||||
{
|
|
||||||
m_settings->createConfigurationInterface(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::evaluate()
|
|
||||||
{
|
|
||||||
evalNoHist();
|
|
||||||
m_history->addItem(m_input->text());
|
|
||||||
m_settings->setHistoryItems(m_history->historyItems());
|
|
||||||
if (!m_history->historyItems().isEmpty() && m_layout->itemAt(2) != m_historyButton) {
|
|
||||||
m_layout->insertItem(2, m_historyButton);
|
|
||||||
}
|
|
||||||
hideHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::evalNoHist()
|
|
||||||
{
|
|
||||||
if (m_input->text().isEmpty()) {
|
|
||||||
clearOutputLabel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_engine->evaluate(m_input->text().replace(KGlobal::locale()->toLocale().decimalPoint(), "."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::displayResult(const QString& result)
|
|
||||||
{
|
|
||||||
m_output->setText(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::receivedResult(const QString& result)
|
|
||||||
{
|
|
||||||
if (m_settings->resultsInline()) {
|
|
||||||
m_input->setText(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_settings->copyToClipboard()) {
|
|
||||||
m_engine->copyToClipboard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::configChanged()
|
|
||||||
{
|
|
||||||
m_settings->readSettings();
|
|
||||||
if (m_settings->resultsInline()) {
|
|
||||||
m_output->hide();
|
|
||||||
m_layout->removeItem(m_output);
|
|
||||||
m_graphicsWidget->resize(m_input->size());
|
|
||||||
} else {
|
|
||||||
m_output->show();
|
|
||||||
m_layout->insertItem(1, m_output);
|
|
||||||
m_graphicsWidget->resize(m_graphicsWidget->preferredSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_settings->liveEvaluation()) {
|
|
||||||
connect(m_input, SIGNAL(textEdited(QString)), this, SLOT(evalNoHist()), Qt::UniqueConnection);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
disconnect(m_input, SIGNAL(textEdited(QString)), this, SLOT(evalNoHist()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::clearOutputLabel()
|
|
||||||
{
|
|
||||||
if (m_input->text().isEmpty()) {
|
|
||||||
m_output->nativeWidget()->setPixmap(KIcon("qalculate-applet").pixmap(IconSize(KIconLoader::Desktop)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::giveFocus()
|
|
||||||
{
|
|
||||||
m_graphicsWidget->setFocus();
|
|
||||||
m_input->setFocus();
|
|
||||||
m_input->nativeWidget()->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::nextHistory()
|
|
||||||
{
|
|
||||||
if (m_history->backup().isEmpty() && m_history->isAtEnd()) {
|
|
||||||
m_history->setBackup(m_input->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_input->setText(m_history->nextItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::previousHistory()
|
|
||||||
{
|
|
||||||
if (m_history->backup().isEmpty() && m_history->isAtEnd()) {
|
|
||||||
m_history->setBackup(m_input->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_input->setText(m_history->previousItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::showHistory()
|
|
||||||
{
|
|
||||||
if (m_history->backup().isEmpty() && m_history->isAtEnd()) {
|
|
||||||
m_history->setBackup(m_input->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_historyButton->text() == i18n("Show History")) {
|
|
||||||
QStringList itemList = m_history->historyItems();
|
|
||||||
int i = itemList.size() - 1;
|
|
||||||
|
|
||||||
//populate list
|
|
||||||
for( ; i >= 0; i-- )
|
|
||||||
{
|
|
||||||
if (!itemList.at(i).isEmpty()) {
|
|
||||||
OutputLabel *item = new OutputLabel;
|
|
||||||
item->setText(itemList.at(i));
|
|
||||||
m_historyList->addItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_historyButton->setText(i18n("Hide History"));
|
|
||||||
m_layout->addItem(m_historyList);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
hideHistory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateApplet::hideHistory()
|
|
||||||
{
|
|
||||||
if (m_historyButton->text() == i18n("Hide History")) {
|
|
||||||
//clear historyList
|
|
||||||
while (m_historyList->count() != 0) {
|
|
||||||
QGraphicsLayoutItem *item;
|
|
||||||
item = m_historyList->itemAt(0);
|
|
||||||
m_historyList->removeItem(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_layout->removeItem(m_historyList);
|
|
||||||
m_historyButton->setText(i18n("Show History"));
|
|
||||||
m_graphicsWidget->resize(m_graphicsWidget->preferredSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_qalculate_applet.cpp"
|
|
|
@ -1,142 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
* @brief This file contains the Qalculate! applet.
|
|
||||||
* @author Matteo Agostinelli <agostinelli@gmail.com> */
|
|
||||||
|
|
||||||
/*! \mainpage Qalculate! Plasma Applet
|
|
||||||
*
|
|
||||||
* \section intro_sec Introduction
|
|
||||||
*
|
|
||||||
* This is a calculator applet based on the Qalculate! library. It supports all basic operations
|
|
||||||
* plus some advanced features, such as symbolic expressions, unit and currency conversion, ...
|
|
||||||
*
|
|
||||||
* \section install_sec Installation
|
|
||||||
*
|
|
||||||
* Usual CMake / KDE procedure ...
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATEAPPLET_H
|
|
||||||
#define QALCULATEAPPLET_H
|
|
||||||
|
|
||||||
#include <Plasma/PopupApplet>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
class LineEdit;
|
|
||||||
class PushButton;
|
|
||||||
}
|
|
||||||
class OutputLabel;
|
|
||||||
|
|
||||||
class QalculateGraphicsWidget;
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
class QalculateSettings;
|
|
||||||
class QalculateEngine;
|
|
||||||
class QalculateHistory;
|
|
||||||
|
|
||||||
class KConfigDialog;
|
|
||||||
|
|
||||||
//! Qalculate! applet
|
|
||||||
/*! This is the main class of the applet.
|
|
||||||
*/
|
|
||||||
class QalculateApplet : public Plasma::PopupApplet
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
//! Basic Create.
|
|
||||||
QalculateApplet(QObject *parent, const QVariantList &args);
|
|
||||||
//! Basic Destroy.
|
|
||||||
~QalculateApplet();
|
|
||||||
|
|
||||||
//! Initializes the applet.
|
|
||||||
void init();
|
|
||||||
|
|
||||||
//! Returns the widget with the contents of the applet.
|
|
||||||
virtual QGraphicsWidget* graphicsWidget();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! The configuration has changed -> the plasmoid must react accordingly
|
|
||||||
void configChanged();
|
|
||||||
|
|
||||||
//! Navigate to the next history item
|
|
||||||
void nextHistory();
|
|
||||||
//! Navigate to the previous history item
|
|
||||||
void previousHistory();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void createConfigurationInterface(KConfigDialog *p_parent);
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
//! Evaluate the expression entered by the user
|
|
||||||
void evaluate();
|
|
||||||
//! Evaluate the expression without adding it to the history
|
|
||||||
void evalNoHist();
|
|
||||||
//! Display the result of the calculation
|
|
||||||
void displayResult(const QString&);
|
|
||||||
//! A slot to process the received result from the engine
|
|
||||||
void receivedResult(const QString&);
|
|
||||||
//! Give focus to the input line
|
|
||||||
void giveFocus();
|
|
||||||
//! Show the history
|
|
||||||
void showHistory();
|
|
||||||
//! Hide the history
|
|
||||||
void hideHistory();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//! The graphics widget
|
|
||||||
QalculateGraphicsWidget* m_graphicsWidget;
|
|
||||||
//! The main layout of the widget
|
|
||||||
QGraphicsLinearLayout *m_layout;
|
|
||||||
//! The applet's settings
|
|
||||||
QalculateSettings* m_settings;
|
|
||||||
//! The Qalculate! engine
|
|
||||||
QalculateEngine* m_engine;
|
|
||||||
//! History manager
|
|
||||||
QalculateHistory* m_history;
|
|
||||||
|
|
||||||
//! The input line where the user types the expression
|
|
||||||
Plasma::LineEdit *m_input;
|
|
||||||
//! The output label where the result is shown
|
|
||||||
OutputLabel *m_output;
|
|
||||||
//! Button which activates the menu
|
|
||||||
Plasma::PushButton *m_historyButton;
|
|
||||||
|
|
||||||
QGraphicsLinearLayout *m_historyList;
|
|
||||||
|
|
||||||
//! The size of the result
|
|
||||||
static int resultSize();
|
|
||||||
static int simplificationSize();
|
|
||||||
|
|
||||||
/** Gets a list of actions for the context menu. */
|
|
||||||
virtual QList<QAction*> contextualActions();
|
|
||||||
|
|
||||||
//! Setup actions
|
|
||||||
void setupActions();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! Create tooltip
|
|
||||||
void createTooltip();
|
|
||||||
//! Clear output label
|
|
||||||
void clearOutputLabel();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qalculate_engine.h"
|
|
||||||
#include "qalculate_settings.h"
|
|
||||||
#include "qalculate_labels.h"
|
|
||||||
|
|
||||||
#include <libqalculate/Calculator.h>
|
|
||||||
#include <libqalculate/ExpressionItem.h>
|
|
||||||
#include <libqalculate/Unit.h>
|
|
||||||
#include <libqalculate/Prefix.h>
|
|
||||||
#include <libqalculate/Variable.h>
|
|
||||||
#include <libqalculate/Function.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QClipboard>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
#include <KLocale>
|
|
||||||
#include <KIO/Job>
|
|
||||||
#include <KIO/NetAccess>
|
|
||||||
|
|
||||||
QalculateEngine::QalculateEngine(QalculateSettings* settings, QObject* parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_settings(settings)
|
|
||||||
{
|
|
||||||
m_lastResult = "";
|
|
||||||
|
|
||||||
new Calculator();
|
|
||||||
CALCULATOR->loadGlobalDefinitions();
|
|
||||||
CALCULATOR->loadLocalDefinitions();
|
|
||||||
CALCULATOR->loadGlobalCurrencies();
|
|
||||||
m_currenciesLoaded = CALCULATOR->loadExchangeRates();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateEngine::updateExchangeRates()
|
|
||||||
{
|
|
||||||
KUrl source = KUrl("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
|
|
||||||
KUrl dest = KUrl("~/.qalculate/eurofxref-daily.xml");
|
|
||||||
|
|
||||||
KIO::Job* getJob = KIO::file_copy(source, dest, -1, KIO::Overwrite | KIO::HideProgressInfo);
|
|
||||||
connect( getJob, SIGNAL(result(KJob*)), this, SLOT(updateResult(KJob*)) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateEngine::updateResult(KJob* job)
|
|
||||||
{
|
|
||||||
if (job->error()) {
|
|
||||||
kDebug() << i18n("The exchange rates could not be updated. The following error has been reported: %1",job->errorString());
|
|
||||||
} else {
|
|
||||||
// the exchange rates have been successfully updated, now load them
|
|
||||||
m_currenciesLoaded = CALCULATOR->loadExchangeRates();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateEngine::evaluate(const QString& expression)
|
|
||||||
{
|
|
||||||
if (expression.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString input = expression;
|
|
||||||
QByteArray ba = input.replace(QChar(0xA3), "GBP").replace(QChar(0xA5), "JPY").replace('$', "USD").replace(QChar(0x20AC), "EUR").toLatin1();
|
|
||||||
|
|
||||||
EvaluationOptions eo;
|
|
||||||
|
|
||||||
eo.auto_post_conversion = m_settings->convertToBestUnits() ? POST_CONVERSION_BEST : POST_CONVERSION_NONE;
|
|
||||||
eo.keep_zero_units = false;
|
|
||||||
|
|
||||||
switch (m_settings->angleUnit()) {
|
|
||||||
case 0:
|
|
||||||
eo.parse_options.angle_unit = ANGLE_UNIT_NONE;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
eo.parse_options.angle_unit = ANGLE_UNIT_RADIANS;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
eo.parse_options.angle_unit = ANGLE_UNIT_DEGREES;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
eo.parse_options.angle_unit = ANGLE_UNIT_GRADIANS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
eo.parse_options.rpn = m_settings->rpn();
|
|
||||||
eo.parse_options.base = m_settings->base();
|
|
||||||
eo.parse_options.preserve_format = m_settings->preserveFormat();
|
|
||||||
eo.parse_options.read_precision = (ReadPrecisionMode) m_settings->readPrecisionMode();
|
|
||||||
|
|
||||||
switch (m_settings->structuring()) {
|
|
||||||
case 0:
|
|
||||||
eo.structuring = STRUCTURING_NONE;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
eo.structuring = STRUCTURING_SIMPLIFY;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
eo.structuring = STRUCTURING_FACTORIZE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
MathStructure result = CALCULATOR->calculate(ba.constData(), eo);
|
|
||||||
|
|
||||||
PrintOptions po;
|
|
||||||
switch (m_settings->fractionDisplay()) {
|
|
||||||
case 0:
|
|
||||||
po.number_fraction_format = FRACTION_DECIMAL;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
po.number_fraction_format = FRACTION_DECIMAL_EXACT;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
po.number_fraction_format = FRACTION_FRACTIONAL;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
po.number_fraction_format = FRACTION_COMBINED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
po.indicate_infinite_series = m_settings->indicateInfiniteSeries();
|
|
||||||
po.use_all_prefixes = m_settings->useAllPrefixes();
|
|
||||||
po.use_denominator_prefix = m_settings->useDenominatorPrefix();
|
|
||||||
po.negative_exponents = m_settings->negativeExponents();
|
|
||||||
po.lower_case_e = true;
|
|
||||||
po.base = m_settings->baseDisplay();
|
|
||||||
po.decimalpoint_sign = KGlobal::locale()->toLocale().decimalPoint().unicode();
|
|
||||||
|
|
||||||
switch (m_settings->minExp()) {
|
|
||||||
case 0:
|
|
||||||
po.min_exp = EXP_NONE;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
po.min_exp = EXP_PURE;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
po.min_exp = EXP_SCIENTIFIC;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
po.min_exp = EXP_PRECISION;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
po.min_exp = EXP_BASE_3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.format(po);
|
|
||||||
|
|
||||||
m_lastResult = result.print(po).c_str();
|
|
||||||
emit resultReady(m_lastResult);
|
|
||||||
|
|
||||||
QalculateLabels label(m_settings);
|
|
||||||
emit formattedResultReady(label.drawStructure(result, po));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateEngine::copyToClipboard(bool flag)
|
|
||||||
{
|
|
||||||
Q_UNUSED(flag);
|
|
||||||
|
|
||||||
QApplication::clipboard()->setText(m_lastResult);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATEENGINE_H
|
|
||||||
#define QALCULATEENGINE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class QalculateSettings;
|
|
||||||
|
|
||||||
class KJob;
|
|
||||||
|
|
||||||
class QalculateEngine : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit QalculateEngine(QalculateSettings* settings, QObject* parent = 0);
|
|
||||||
|
|
||||||
QString lastResult() const {
|
|
||||||
return m_lastResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void evaluate(const QString& expression);
|
|
||||||
void updateExchangeRates();
|
|
||||||
|
|
||||||
void copyToClipboard(bool flag = true);
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void updateResult(KJob*);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void resultReady(const QString&);
|
|
||||||
void formattedResultReady(const QString&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QalculateSettings* m_settings;
|
|
||||||
|
|
||||||
QString m_lastResult;
|
|
||||||
bool m_currenciesLoaded;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QALCULATEENGINE_H
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TYou should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qalculate_graphicswidget.h"
|
|
||||||
|
|
||||||
#include <QtGui/qgraphicssceneevent.h>
|
|
||||||
|
|
||||||
QalculateGraphicsWidget::QalculateGraphicsWidget(QGraphicsItem* parent, Qt::WindowFlags wFlags): QGraphicsWidget(parent, wFlags)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateGraphicsWidget::keyPressEvent(QKeyEvent* event)
|
|
||||||
{
|
|
||||||
if (event->key() == Qt::Key_Up) {
|
|
||||||
emit previousHistory();
|
|
||||||
}
|
|
||||||
if (event->key() == Qt::Key_Down) {
|
|
||||||
emit nextHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsWidget::keyPressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateGraphicsWidget::focusInEvent(QFocusEvent* event)
|
|
||||||
{
|
|
||||||
if (event->gotFocus()) {
|
|
||||||
emit giveFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsWidget::focusInEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateGraphicsWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton) {
|
|
||||||
emit giveFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsItem::mousePressEvent(event);
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TYou should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATE_GRAPHICSWIDGET_H
|
|
||||||
#define QALCULATE_GRAPHICSWIDGET_H
|
|
||||||
|
|
||||||
#include <QtGui/QGraphicsWidget>
|
|
||||||
|
|
||||||
//! Qalculate! applet
|
|
||||||
/*! This is the main class of the applet.
|
|
||||||
*/
|
|
||||||
class QalculateGraphicsWidget : public QGraphicsWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit QalculateGraphicsWidget(QGraphicsItem* parent = 0, Qt::WindowFlags wFlags = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void keyPressEvent(QKeyEvent * event);
|
|
||||||
void focusInEvent(QFocusEvent* event);
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void previousHistory();
|
|
||||||
void nextHistory();
|
|
||||||
void giveFocus();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QALCULATE_GRAPHICSWIDGET_H
|
|
|
@ -1,113 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qalculate_history.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
QalculateHistory::QalculateHistory(QObject* parent): QObject(parent)
|
|
||||||
{
|
|
||||||
m_currentItem = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateHistory::addItem(const QString& expression)
|
|
||||||
{
|
|
||||||
m_history.push_back(expression);
|
|
||||||
m_backup = "";
|
|
||||||
m_currentItem = m_history.size() - 1;
|
|
||||||
if (m_history.size() > 10) {
|
|
||||||
m_history.removeFirst();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QalculateHistory::currentItem()
|
|
||||||
{
|
|
||||||
qDebug() << "Current item: " << m_currentItem;
|
|
||||||
qDebug() << "History size: " << m_history.size();
|
|
||||||
|
|
||||||
if (m_history.isEmpty()) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_currentItem >= m_history.size()) {
|
|
||||||
if (!backup().isEmpty()) {
|
|
||||||
m_currentItem = m_history.size();
|
|
||||||
return m_backup;
|
|
||||||
} else {
|
|
||||||
m_currentItem = m_history.size() - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_currentItem < 0) {
|
|
||||||
m_currentItem = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Final current item: " << m_currentItem;
|
|
||||||
qDebug() << "---";
|
|
||||||
|
|
||||||
return m_history.at(m_currentItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QalculateHistory::nextItem()
|
|
||||||
{
|
|
||||||
m_currentItem++;
|
|
||||||
return currentItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QalculateHistory::previousItem()
|
|
||||||
{
|
|
||||||
m_currentItem--;
|
|
||||||
return currentItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateHistory::setBackup(const QString& backup)
|
|
||||||
{
|
|
||||||
if (m_history.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backup != m_history.last()) {
|
|
||||||
m_backup = backup;
|
|
||||||
m_currentItem++;
|
|
||||||
} else {
|
|
||||||
m_backup = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QalculateHistory::backup() const
|
|
||||||
{
|
|
||||||
return m_backup;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QalculateHistory::isAtEnd() const
|
|
||||||
{
|
|
||||||
return m_currentItem >= 0 && m_history.size() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList QalculateHistory::historyItems() const
|
|
||||||
{
|
|
||||||
return m_history;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateHistory::setHistoryItems ( QStringList items )
|
|
||||||
{
|
|
||||||
m_history = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATE_HISTORY_H
|
|
||||||
#define QALCULATE_HISTORY_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
class QalculateHistory : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QalculateHistory(QObject* parent = 0);
|
|
||||||
|
|
||||||
void addItem(const QString&);
|
|
||||||
|
|
||||||
QString currentItem();
|
|
||||||
QString previousItem();
|
|
||||||
QString nextItem();
|
|
||||||
|
|
||||||
void setBackup(const QString&);
|
|
||||||
QString backup() const;
|
|
||||||
void setHistoryItems(QStringList items);
|
|
||||||
QStringList historyItems() const;
|
|
||||||
|
|
||||||
bool isAtEnd() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList m_history;
|
|
||||||
QString m_backup;
|
|
||||||
|
|
||||||
int m_currentItem;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QALCULATE_HISTORY_H
|
|
|
@ -1,855 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
* Copyright 2003-2007 Niklas Knutsson <nq@altern.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
#include "qalculate_labels.h"
|
|
||||||
#include "qalculate_settings.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define TEXT_TAGS "<font size=6>"
|
|
||||||
#define TEXT_TAGS_END "</font>"
|
|
||||||
#define TEXT_TAGS_SMALL "<font size=5>"
|
|
||||||
#define TEXT_TAGS_SMALL_END "</font>"
|
|
||||||
#define TEXT_TAGS_XSMALL "<font size=4>"
|
|
||||||
#define TEXT_TAGS_XSMALL_END "</font>"
|
|
||||||
|
|
||||||
#define STR_MARKUP_ADD_SMALL(str, str_add) if(ips.power_depth > 0) {str += TEXT_TAGS "<sup>"; str += str_add; str += "</sup>" TEXT_TAGS_END;} else {str += TEXT_TAGS_SMALL; str += str_add; str += TEXT_TAGS_SMALL_END;}
|
|
||||||
|
|
||||||
#define STR_MARKUP_ADD(str, str_add) if(ips.power_depth > 0) {str += TEXT_TAGS "<sup>"; str += str_add; str += "</sup>" TEXT_TAGS_END;} else {str += str_add;}
|
|
||||||
|
|
||||||
#define STR_MARKUP_PREPEND(str, str_add) QString str_prepend; if(ips.power_depth > 0) {str_prepend += TEXT_TAGS "<sup>"; str_prepend += str_add; str_prepend += "</sup>" TEXT_TAGS_END;} else {str_prepend += str_add;} str.prepend(str_prepend);
|
|
||||||
|
|
||||||
#define STR_MARKUP_BEGIN(str) if(ips.power_depth > 0) {str += TEXT_TAGS "<sup>";}
|
|
||||||
#define STR_MARKUP_END(str) if(ips.power_depth > 0) {str +="</sup>" TEXT_TAGS_END;}
|
|
||||||
|
|
||||||
#define STR_MARKUP_BEGIN_SMALL(str) if(ips.power_depth > 0) {str += TEXT_TAGS_SMALL "<sup>";} else {str += TEXT_TAGS_SMALL;}
|
|
||||||
#define STR_MARKUP_END_SMALL(str) if(ips.power_depth > 0) {str +="</sup>" TEXT_TAGS_SMALL_END;} else {str += TEXT_TAGS_SMALL_END;}
|
|
||||||
|
|
||||||
#define STR_MARKUP_BEGIN_CURSIVE(str) if(ips.power_depth > 0) {str += TEXT_TAGS "<i><sup>";} else {str += "<i>";}
|
|
||||||
#define STR_MARKUP_END_CURSIVE(str) if(ips.power_depth > 0) {str +="</sup></i>" TEXT_TAGS_END;} else {str += "</i>";}
|
|
||||||
|
|
||||||
QString QalculateLabels::drawStructure(MathStructure& m, const PrintOptions& po, InternalPrintStruct ips)
|
|
||||||
{
|
|
||||||
QString mstr;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//string result_str = m.print(po);
|
|
||||||
InternalPrintStruct ips_n = ips;
|
|
||||||
|
|
||||||
switch (m.type()) {
|
|
||||||
case STRUCT_NUMBER: {
|
|
||||||
string exp = "";
|
|
||||||
bool exp_minus;
|
|
||||||
ips_n.exp = &exp;
|
|
||||||
ips_n.exp_minus = &exp_minus;
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
mstr += m.number().print(po, ips_n).c_str();
|
|
||||||
if (!exp.empty()) {
|
|
||||||
if (po.lower_case_e) {
|
|
||||||
mstr += 'e';
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD_SMALL(mstr, "E");
|
|
||||||
}
|
|
||||||
if (exp_minus) {
|
|
||||||
mstr += '-';
|
|
||||||
}
|
|
||||||
mstr += exp.c_str();
|
|
||||||
}
|
|
||||||
if (po.base != BASE_DECIMAL && po.base != BASE_HEXADECIMAL && po.base > 0 && po.base <= 36) {
|
|
||||||
if (ips.power_depth == 0) {
|
|
||||||
mstr += "<sub>";
|
|
||||||
mstr += QString::number(po.base);
|
|
||||||
mstr += "</sub>";
|
|
||||||
} else {
|
|
||||||
mstr += TEXT_TAGS_SMALL "<sup>";
|
|
||||||
mstr += QString::number(po.base);
|
|
||||||
mstr += "</sup>" TEXT_TAGS_SMALL_END;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m.number().isInteger() && ips.depth == 0 && m_qalculateSettings->showOtherBases())
|
|
||||||
{
|
|
||||||
mstr += TEXT_TAGS_XSMALL;
|
|
||||||
PrintOptions po2 = po;
|
|
||||||
if (m_qalculateSettings->showBinary() && po.base != 2)
|
|
||||||
{
|
|
||||||
po2.base = 2;
|
|
||||||
mstr += "<br>0b";
|
|
||||||
mstr += m.number().print(po2, ips_n).c_str();
|
|
||||||
}
|
|
||||||
if (m_qalculateSettings->showOctal() && po.base != 8)
|
|
||||||
{
|
|
||||||
po2.base = 8;
|
|
||||||
mstr += "<br>0o";
|
|
||||||
mstr += m.number().print(po2, ips_n).c_str();
|
|
||||||
}
|
|
||||||
if (m_qalculateSettings->showDecimal() && po.base != 10)
|
|
||||||
{
|
|
||||||
po2.base = 10;
|
|
||||||
po2.min_exp = EXP_NONE;
|
|
||||||
mstr += "<br>0d";
|
|
||||||
mstr += m.number().print(po2, ips_n).c_str();
|
|
||||||
}
|
|
||||||
if (m_qalculateSettings->showHexadecimal() && po.base != 16)
|
|
||||||
{
|
|
||||||
po2.base = 16;
|
|
||||||
mstr += "<br>0x";
|
|
||||||
mstr += m.number().print(po2, ips_n).c_str();
|
|
||||||
}
|
|
||||||
mstr += TEXT_TAGS_XSMALL_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_SYMBOLIC: {
|
|
||||||
result_parts.push_back(m);
|
|
||||||
mstr = "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\">";
|
|
||||||
STR_MARKUP_BEGIN_CURSIVE(mstr);
|
|
||||||
mstr += m.symbol().c_str();
|
|
||||||
STR_MARKUP_END_CURSIVE(mstr);
|
|
||||||
mstr += "</a>";
|
|
||||||
mstr += "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\"></a>";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_POWER: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
ips_n.wrap = m[0].needsParenthesis(po, ips_n, m, 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
|
|
||||||
ips_n.division_depth++;
|
|
||||||
mstr += drawStructure(m[0], po, ips_n);
|
|
||||||
ips_n.division_depth--;
|
|
||||||
|
|
||||||
ips_n.power_depth++;
|
|
||||||
ips_n.wrap = m[1].needsParenthesis(po, ips_n, m, 2, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
|
|
||||||
PrintOptions po2 = po;
|
|
||||||
po2.show_ending_zeroes = false;
|
|
||||||
if (ips.power_depth > 0) {
|
|
||||||
mstr += TEXT_TAGS "<sup>" "^" "</sup>" TEXT_TAGS_END;
|
|
||||||
mstr += drawStructure(m[1], po2, ips_n);
|
|
||||||
} else {
|
|
||||||
mstr += drawStructure(m[1], po2, ips_n);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_VARIABLE: {
|
|
||||||
|
|
||||||
result_parts.push_back(m);
|
|
||||||
mstr = "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\">";
|
|
||||||
if (m.variable() == CALCULATOR->v_i) {
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_BEGIN_CURSIVE(mstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString str;
|
|
||||||
const ExpressionName *ename = &m.variable()->preferredDisplayName(po.abbreviate_names, po.use_unicode_signs, false, po.use_reference_names, po.can_display_unicode_string_function, po.can_display_unicode_string_arg);
|
|
||||||
if (ename->suffix && ename->name.length() > 1) {
|
|
||||||
size_t i = ename->name.rfind('_');
|
|
||||||
bool b = i == string::npos || i == ename->name.length() - 1 || i == 0;
|
|
||||||
size_t i2 = 1;
|
|
||||||
if (b) {
|
|
||||||
if (is_in(NUMBERS, ename->name[ename->name.length() - 1])) {
|
|
||||||
while (ename->name.length() > i2 + 1 && is_in(NUMBERS, ename->name[ename->name.length() - 1 - i2])) {
|
|
||||||
i2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str += ename->name.substr(0, ename->name.length() - i2).c_str();
|
|
||||||
} else {
|
|
||||||
str += ename->name.substr(0, i).c_str();
|
|
||||||
}
|
|
||||||
if (ips.power_depth == 0) str += "<sub>";
|
|
||||||
else str += TEXT_TAGS_SMALL "<sup>";
|
|
||||||
if (b) str += ename->name.substr(ename->name.length() - i2, i2).c_str();
|
|
||||||
else str += ename->name.substr(i + 1, ename->name.length() - (i + 1)).c_str();
|
|
||||||
if (ips.power_depth == 0) str += "</sub>";
|
|
||||||
else str += "</sup>" TEXT_TAGS_SMALL_END;
|
|
||||||
} else {
|
|
||||||
str += ename->name.c_str();
|
|
||||||
}
|
|
||||||
str.replace('_', ' ');
|
|
||||||
mstr += str;
|
|
||||||
|
|
||||||
if (m.variable() == CALCULATOR->v_i) {
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_END_CURSIVE(mstr);
|
|
||||||
}
|
|
||||||
mstr += "</a>";
|
|
||||||
/*result_parts.push_back(m);
|
|
||||||
mstr += "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\"></a>";*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_MULTIPLICATION: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
QString mul_str;
|
|
||||||
if (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_DOT && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_MULTIDOT, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mul_str, SIGN_MULTIDOT);
|
|
||||||
} else if (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_DOT && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_MULTIBULLET, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mul_str, SIGN_MULTIBULLET);
|
|
||||||
} else if (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_DOT && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_SMALLCIRCLE, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mul_str, SIGN_SMALLCIRCLE);
|
|
||||||
} else if (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_X && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_MULTIPLICATION, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mul_str, SIGN_MULTIPLICATION);
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(mul_str, QChar(0x22C5));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool par_prev = false;
|
|
||||||
vector<int> nm;
|
|
||||||
vector<QString> terms;
|
|
||||||
vector<bool> do_space;
|
|
||||||
for (size_t i = 0; i < m.size(); i++) {
|
|
||||||
ips_n.wrap = m[i].needsParenthesis(po, ips_n, m, i + 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
terms.push_back(drawStructure(m[i], po, ips_n));
|
|
||||||
if (!po.short_multiplication && i > 0) {
|
|
||||||
nm.push_back(-1);
|
|
||||||
} else if (i > 0) {
|
|
||||||
nm.push_back(m[i].neededMultiplicationSign(po, ips_n, m, i + 1, ips_n.wrap || (m[i].isPower() && m[i][0].needsParenthesis(po, ips_n, m[i], 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0)), par_prev, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0));
|
|
||||||
} else {
|
|
||||||
nm.push_back(-1);
|
|
||||||
}
|
|
||||||
do_space.push_back(!terms[i].endsWith(QLatin1String("valign=\"middle\">")));
|
|
||||||
par_prev = ips_n.wrap;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < terms.size(); i++) {
|
|
||||||
if (!po.short_multiplication && i > 0) {
|
|
||||||
if (do_space[i - 1]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
mstr += mul_str;
|
|
||||||
if (do_space[i]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
} else if (i > 0) {
|
|
||||||
switch (nm[i]) {
|
|
||||||
case MULTIPLICATION_SIGN_SPACE: {
|
|
||||||
if (do_space[i - 1] && do_space[i]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MULTIPLICATION_SIGN_OPERATOR: {
|
|
||||||
if (do_space[i - 1]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
mstr += mul_str;
|
|
||||||
if (do_space[i]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MULTIPLICATION_SIGN_OPERATOR_SHORT: {
|
|
||||||
mstr += mul_str;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mstr += terms[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_ADDITION: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
vector<QString> terms;
|
|
||||||
vector<bool> do_space;
|
|
||||||
for (size_t i = 0; i < m.size(); i++) {
|
|
||||||
if (m[i].type() == STRUCT_NEGATE && i > 0) {
|
|
||||||
ips_n.wrap = m[i][0].needsParenthesis(po, ips_n, m, i + 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
terms.push_back(drawStructure(m[i][0], po, ips_n));
|
|
||||||
} else {
|
|
||||||
ips_n.wrap = m[i].needsParenthesis(po, ips_n, m, i + 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
terms.push_back(drawStructure(m[i], po, ips_n));
|
|
||||||
}
|
|
||||||
do_space.push_back(!terms[i].endsWith(QLatin1String("valign=\"middle\">")));
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < terms.size(); i++) {
|
|
||||||
if (i > 0) {
|
|
||||||
if (do_space[i - 1]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
if (m[i].type() == STRUCT_NEGATE) {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_MINUS, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mstr, SIGN_MINUS);
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(mstr, "-");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(mstr, "+");
|
|
||||||
}
|
|
||||||
if (do_space[i]) {
|
|
||||||
STR_MARKUP_ADD(mstr, " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mstr += terms[i];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_FUNCTION: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
result_parts.push_back(m);
|
|
||||||
mstr = "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\">";
|
|
||||||
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
|
|
||||||
QString str;
|
|
||||||
const ExpressionName *ename = &m.function()->preferredDisplayName(po.abbreviate_names, po.use_unicode_signs, false, po.use_reference_names, po.can_display_unicode_string_function, po.can_display_unicode_string_arg);
|
|
||||||
if (ename->suffix && ename->name.length() > 1) {
|
|
||||||
size_t i = ename->name.rfind('_');
|
|
||||||
bool b = i == string::npos || i == ename->name.length() - 1 || i == 0;
|
|
||||||
size_t i2 = 1;
|
|
||||||
if (b) {
|
|
||||||
if (is_in(NUMBERS, ename->name[ename->name.length() - 1])) {
|
|
||||||
while (ename->name.length() > i2 + 1 && is_in(NUMBERS, ename->name[ename->name.length() - 1 - i2])) {
|
|
||||||
i2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str += ename->name.substr(0, ename->name.length() - i2).c_str();
|
|
||||||
} else {
|
|
||||||
str += ename->name.substr(0, i).c_str();
|
|
||||||
}
|
|
||||||
if (ips.power_depth == 0) str += "<sub>";
|
|
||||||
else str += TEXT_TAGS_SMALL "<sup>";
|
|
||||||
if (b) str += ename->name.substr(ename->name.length() - i2, i2).c_str();
|
|
||||||
else str += ename->name.substr(i + 1, ename->name.length() - (i + 1)).c_str();
|
|
||||||
if (ips.power_depth == 0) str += "</sub>";
|
|
||||||
else str += "</sup>" TEXT_TAGS_SMALL_END;
|
|
||||||
} else {
|
|
||||||
str += ename->name.c_str();
|
|
||||||
}
|
|
||||||
str.replace('_', ' ');
|
|
||||||
mstr += str;
|
|
||||||
|
|
||||||
mstr += '(';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
mstr += "</a>";
|
|
||||||
|
|
||||||
for (size_t index = 0; index < m.size(); index++) {
|
|
||||||
if (index > 0) {
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
mstr += po.comma().c_str();
|
|
||||||
mstr += ' ';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
}
|
|
||||||
mstr += drawStructure(m[index], po, ips_n);
|
|
||||||
}
|
|
||||||
STR_MARKUP_ADD(mstr, ")");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_UNIT: {
|
|
||||||
|
|
||||||
result_parts.push_back(m);
|
|
||||||
mstr = "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\">";
|
|
||||||
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
|
|
||||||
QString str;
|
|
||||||
const ExpressionName *ename = &m.unit()->preferredDisplayName(po.abbreviate_names, po.use_unicode_signs, m.isPlural(), po.use_reference_names, po.can_display_unicode_string_function, po.can_display_unicode_string_arg);
|
|
||||||
if (m.prefix()) {
|
|
||||||
//str += m.prefix()->name(po.abbreviate_names && ename->abbreviation && (ename->suffix || ename->name.find("_") == string::npos), po.use_unicode_signs, po.can_display_unicode_string_function, po.can_display_unicode_string_arg).c_str();
|
|
||||||
str += m.prefix()->name(po.abbreviate_names, po.use_unicode_signs, po.can_display_unicode_string_function, po.can_display_unicode_string_arg).c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ename->suffix && ename->name.length() > 1) {
|
|
||||||
size_t i = ename->name.rfind('_');
|
|
||||||
bool b = i == string::npos || i == ename->name.length() - 1 || i == 0;
|
|
||||||
size_t i2 = 1;
|
|
||||||
if (b) {
|
|
||||||
if (is_in(NUMBERS, ename->name[ename->name.length() - 1])) {
|
|
||||||
while (ename->name.length() > i2 + 1 && is_in(NUMBERS, ename->name[ename->name.length() - 1 - i2])) {
|
|
||||||
i2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str += ename->name.substr(0, ename->name.length() - i2).c_str();
|
|
||||||
} else {
|
|
||||||
str += ename->name.substr(0, i).c_str();
|
|
||||||
}
|
|
||||||
if (ips.power_depth == 0) str += "<sub>";
|
|
||||||
else str += TEXT_TAGS_SMALL "<sup>";
|
|
||||||
if (b) str += ename->name.substr(ename->name.length() - i2, i2).c_str();
|
|
||||||
else str += ename->name.substr(i + 1, ename->name.length() - (i + 1)).c_str();
|
|
||||||
if (ips.power_depth == 0) str += "</sub>";
|
|
||||||
else str += "</sup>" TEXT_TAGS_SMALL_END;
|
|
||||||
} else {
|
|
||||||
if (ename->name == "ohm" || ename->name == "ohms")
|
|
||||||
str += QChar(0x2126);
|
|
||||||
else if (ename->name == "oF")
|
|
||||||
str += QChar(0x2109);
|
|
||||||
else if (ename->name == "oC")
|
|
||||||
str += QChar(0x2103);
|
|
||||||
else if (ename->name == "GBP")
|
|
||||||
str += QChar(0xA3);
|
|
||||||
else if (ename->name == "JPY")
|
|
||||||
str += QChar(0xA5);
|
|
||||||
else if (ename->name == "EUR")
|
|
||||||
str += QChar(0x20AC);
|
|
||||||
else if (ename->name == "USD")
|
|
||||||
str += QChar(0x24);
|
|
||||||
else
|
|
||||||
str += ename->name.c_str();
|
|
||||||
}
|
|
||||||
str.replace('_', ' ');
|
|
||||||
mstr += str;
|
|
||||||
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
mstr += "</a>";
|
|
||||||
mstr += "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\"></a>";
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_INVERSE: {}
|
|
||||||
case STRUCT_DIVISION: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
ips_n.division_depth++;
|
|
||||||
|
|
||||||
bool flat = ips.division_depth > 0 || ips.power_depth > 0;
|
|
||||||
flat = true;
|
|
||||||
if (!flat && po.place_units_separately) {
|
|
||||||
flat = true;
|
|
||||||
size_t i = 0;
|
|
||||||
if (m.isDivision()) {
|
|
||||||
i = 1;
|
|
||||||
}
|
|
||||||
if (m[i].isMultiplication()) {
|
|
||||||
for (size_t i2 = 0; i2 < m[i].size(); i2++) {
|
|
||||||
if (!m[i][i2].isUnit_exp()) {
|
|
||||||
flat = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!m[i].isUnit_exp()) {
|
|
||||||
flat = false;
|
|
||||||
}
|
|
||||||
if (flat) {
|
|
||||||
ips_n.division_depth--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString num_str, den_str;
|
|
||||||
if (m.type() == STRUCT_DIVISION) {
|
|
||||||
ips_n.wrap = (!m[0].isDivision() || !flat || ips.division_depth > 0 || ips.power_depth > 0) && m[0].needsParenthesis(po, ips_n, m, 1, flat, ips.power_depth > 0);
|
|
||||||
num_str = drawStructure(m[0], po, ips_n);
|
|
||||||
} else {
|
|
||||||
MathStructure onestruct(1, 1);
|
|
||||||
ips_n.wrap = false;
|
|
||||||
num_str = drawStructure(onestruct, po, ips_n);
|
|
||||||
}
|
|
||||||
if (m.type() == STRUCT_DIVISION) {
|
|
||||||
ips_n.wrap = m[1].needsParenthesis(po, ips_n, m, 2, flat, ips.power_depth > 0);
|
|
||||||
den_str = drawStructure(m[1], po, ips_n);
|
|
||||||
} else {
|
|
||||||
ips_n.wrap = m[0].needsParenthesis(po, ips_n, m, 2, flat, ips.power_depth > 0);
|
|
||||||
den_str = drawStructure(m[0], po, ips_n);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flat) {
|
|
||||||
QString div_str;
|
|
||||||
if (po.use_unicode_signs && po.division_sign == DIVISION_SIGN_DIVISION && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_DIVISION, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(div_str, " " SIGN_DIVISION " ");
|
|
||||||
} else if (po.use_unicode_signs && po.division_sign == DIVISION_SIGN_DIVISION_SLASH && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_DIVISION_SLASH, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(div_str, " " SIGN_DIVISION_SLASH " ");
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(div_str, " / ");
|
|
||||||
}
|
|
||||||
mstr = num_str;
|
|
||||||
mstr += div_str;
|
|
||||||
mstr += den_str;
|
|
||||||
}
|
|
||||||
// else {
|
|
||||||
//
|
|
||||||
// int den_w, num_w, w = 0, h = 0;
|
|
||||||
//
|
|
||||||
// num_str.prepend(TEXT_TAGS);
|
|
||||||
// num_str += TEXT_TAGS_END;
|
|
||||||
// den_str.prepend(TEXT_TAGS);
|
|
||||||
// den_str += TEXT_TAGS_END;
|
|
||||||
//
|
|
||||||
// QSimpleRichText text_r(num_str, font); text_r.setWidth(10000);
|
|
||||||
// num_w = text_r.widthUsed();
|
|
||||||
// QSimpleRichText text_rn(den_str, font); text_rn.setWidth(10000);
|
|
||||||
// den_w = text_rn.widthUsed();
|
|
||||||
//
|
|
||||||
// w = den_w;
|
|
||||||
// if(num_w > w) w = num_w;
|
|
||||||
// w += 2;
|
|
||||||
//
|
|
||||||
// QSimpleRichText textsmall("<font size=\"1\">X</font>", font);
|
|
||||||
// h = (int) (textsmall.height() / 1.5);
|
|
||||||
// h += h % 2;
|
|
||||||
//
|
|
||||||
// string filename = getLocalDir();
|
|
||||||
// if(saved_divisionline_height != h) {
|
|
||||||
//
|
|
||||||
// QPixmap *pixmap = new QPixmap(10, h);
|
|
||||||
// pixmap->fill(cg.background());
|
|
||||||
// QPainter p(pixmap);
|
|
||||||
// QPen ppen = p.pen();
|
|
||||||
// ppen.setColor(cg.foreground());
|
|
||||||
// p.setPen(ppen);
|
|
||||||
// p.drawLine(0, h / 2, 10, h / 2);
|
|
||||||
// p.drawLine(0, h / 2 + 1, 10, h / 2 + 1);
|
|
||||||
// p.flush();
|
|
||||||
// p.end();
|
|
||||||
//
|
|
||||||
// pixmap->setMask(pixmap->createHeuristicMask());
|
|
||||||
// mkdir(filename.c_str(), S_IRWXU);
|
|
||||||
// filename += "tmp/";
|
|
||||||
// mkdir(filename.c_str(), S_IRWXU);
|
|
||||||
// filename += "divline.png";
|
|
||||||
// pixmap->save(filename.c_str(), "PNG", 100);
|
|
||||||
//
|
|
||||||
// delete pixmap;
|
|
||||||
//
|
|
||||||
// saved_divisionline_height = h;
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// filename += "tmp/divline.png";
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// mstr = TEXT_TAGS_END;
|
|
||||||
// mstr = "</td><td width=1 align=\"center\" valign=\"middle\">";
|
|
||||||
// mstr += num_str;
|
|
||||||
// mstr += "<br><font size=1><img align=\"middle\" width=";
|
|
||||||
// mstr += QString::number(w);
|
|
||||||
// mstr += " height=";
|
|
||||||
// mstr += QString::number(h);
|
|
||||||
// mstr += " src=\"";
|
|
||||||
// mstr += filename.c_str();
|
|
||||||
// mstr += "\"><br></font>";
|
|
||||||
// mstr += den_str;
|
|
||||||
// mstr += "</td><td width=1 align=\"center\" valign=\"middle\">";
|
|
||||||
// mstr += TEXT_TAGS;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_NEGATE: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
ips_n.wrap = m[0].needsParenthesis(po, ips_n, m, 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_MINUS, po.can_display_unicode_string_arg))) {
|
|
||||||
STR_MARKUP_ADD(mstr, SIGN_MINUS);
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(mstr, "-");
|
|
||||||
}
|
|
||||||
mstr += drawStructure(m[0], po, ips_n);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_VECTOR: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
// bool is_matrix = m.isMatrix();
|
|
||||||
if (!in_matrix) {
|
|
||||||
result_parts.push_back(m);
|
|
||||||
mstr = "<a name=\"";
|
|
||||||
mstr += QString::number(result_parts.size());
|
|
||||||
mstr += "\">";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m.size() == 0) {
|
|
||||||
STR_MARKUP_ADD(mstr, "( ");
|
|
||||||
} else {
|
|
||||||
STR_MARKUP_ADD(mstr, "(");
|
|
||||||
}
|
|
||||||
for (size_t index = 0; index < m.size(); index++) {
|
|
||||||
if (index > 0) {
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
mstr += CALCULATOR->getComma().c_str();
|
|
||||||
mstr += ' ';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
}
|
|
||||||
ips_n.wrap = m[index].needsParenthesis(po, ips_n, m, index + 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
mstr += drawStructure(m[index], po, ips_n);
|
|
||||||
}
|
|
||||||
STR_MARKUP_ADD(mstr, ")");
|
|
||||||
if (!in_matrix) mstr += "</a>";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRUCT_LOGICAL_AND: {
|
|
||||||
if (!po.preserve_format && m.size() == 2 && m[0].isComparison() && m[1].isComparison() && m[0].comparisonType() != COMPARISON_EQUALS && m[0].comparisonType() != COMPARISON_NOT_EQUALS && m[1].comparisonType() != COMPARISON_EQUALS && m[1].comparisonType() != COMPARISON_NOT_EQUALS && m[0][0] == m[1][0]) {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
bool do_space = true;
|
|
||||||
QString tstr;
|
|
||||||
ips_n.wrap = m[0][1].needsParenthesis(po, ips_n, m[0], 2, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
tstr = drawStructure(m[0][1], po, ips_n);
|
|
||||||
do_space = !tstr.endsWith(QLatin1String("valign=\"middle\">"));
|
|
||||||
mstr += tstr;
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
if (do_space) mstr += ' ';
|
|
||||||
switch (m[0].comparisonType()) {
|
|
||||||
case COMPARISON_LESS: {
|
|
||||||
mstr += ">";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_GREATER: {
|
|
||||||
mstr += "<";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_LESS: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_GREATER_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
mstr += SIGN_GREATER_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
mstr += ">=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_GREATER: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_LESS_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
mstr += SIGN_LESS_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
mstr += "<=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
|
|
||||||
ips_n.wrap = m[0][0].needsParenthesis(po, ips_n, m[0], 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
tstr = drawStructure(m[0][0], po, ips_n);
|
|
||||||
do_space = !tstr.endsWith(QLatin1String("valign=\"middle\">"));
|
|
||||||
if (do_space) mstr += ' ';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
mstr += tstr;
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
if (do_space) mstr += ' ';
|
|
||||||
|
|
||||||
switch (m[1].comparisonType()) {
|
|
||||||
case COMPARISON_GREATER: {
|
|
||||||
mstr += ">";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_LESS: {
|
|
||||||
mstr += "<";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_GREATER: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_GREATER_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
mstr += SIGN_GREATER_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
mstr += ">=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_LESS: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_LESS_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
mstr += SIGN_LESS_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
mstr += "<=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
|
|
||||||
ips_n.wrap = m[1][1].needsParenthesis(po, ips_n, m[1], 2, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
tstr = drawStructure(m[1][1], po, ips_n);
|
|
||||||
do_space = !tstr.endsWith(QLatin1String("valign=\"middle\">"));
|
|
||||||
if (do_space) mstr += ' ';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
mstr += tstr;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case STRUCT_COMPARISON: {}
|
|
||||||
case STRUCT_LOGICAL_XOR: {}
|
|
||||||
case STRUCT_LOGICAL_OR: {}
|
|
||||||
case STRUCT_BITWISE_AND: {}
|
|
||||||
case STRUCT_BITWISE_XOR: {}
|
|
||||||
case STRUCT_BITWISE_OR: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
QString str;
|
|
||||||
if (m.type() == STRUCT_COMPARISON) {
|
|
||||||
switch (m.comparisonType()) {
|
|
||||||
case COMPARISON_EQUALS: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_NOT_EQUALS: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_NOT_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
str += SIGN_NOT_EQUAL;
|
|
||||||
} else {
|
|
||||||
str += "!=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_GREATER: {
|
|
||||||
str += ">";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_LESS: {
|
|
||||||
str += "<";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_GREATER: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_GREATER_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
str += SIGN_GREATER_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
str += ">=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COMPARISON_EQUALS_LESS: {
|
|
||||||
if (po.use_unicode_signs && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_LESS_OR_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
str += SIGN_LESS_OR_EQUAL;
|
|
||||||
} else {
|
|
||||||
str += "<=";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (m.type() == STRUCT_LOGICAL_AND) {
|
|
||||||
str += "<a name=\"+Logical AND\">";
|
|
||||||
if (po.spell_out_logical_operators) str += "and";
|
|
||||||
else str += "&&";
|
|
||||||
str += "</a>";
|
|
||||||
} else if (m.type() == STRUCT_LOGICAL_OR) {
|
|
||||||
str += "<a name=\"+Logical inclusive OR\">";
|
|
||||||
if (po.spell_out_logical_operators) str += "or";
|
|
||||||
else str += "||";
|
|
||||||
str += "</a>";
|
|
||||||
} else if (m.type() == STRUCT_LOGICAL_XOR) {
|
|
||||||
str += "<a name=\"+Logical exclusive OR\">XOR</a>";
|
|
||||||
} else if (m.type() == STRUCT_BITWISE_AND) {
|
|
||||||
str += "<a name=\"+Bitwise AND\">&</a>";
|
|
||||||
} else if (m.type() == STRUCT_BITWISE_OR) {
|
|
||||||
str += "<a name=\"+Bitwise inclusive OR\">|</a>";
|
|
||||||
} else if (m.type() == STRUCT_BITWISE_XOR) {
|
|
||||||
str += "<a name=\"+Bitwise exclusive XOR\">XOR</a>";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool do_space = true, do_space_prev = true;
|
|
||||||
QString tstr;
|
|
||||||
for (size_t i = 0; i < m.size(); i++) {
|
|
||||||
do_space_prev = do_space;
|
|
||||||
ips_n.wrap = m[i].needsParenthesis(po, ips_n, m, i + 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
tstr = drawStructure(m[i], po, ips_n);
|
|
||||||
do_space = !tstr.endsWith(QLatin1String("valign=\"middle\">"));
|
|
||||||
if (i > 0) {
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
if (do_space_prev) mstr += ' ';
|
|
||||||
if (m.isComparison() && m.comparisonType() == COMPARISON_EQUALS) {
|
|
||||||
if (ips.depth == 0 && po.use_unicode_signs && (*po.is_approximate || m.isApproximate()) && (!po.can_display_unicode_string_function || (*po.can_display_unicode_string_function)(SIGN_ALMOST_EQUAL, po.can_display_unicode_string_arg))) {
|
|
||||||
mstr += SIGN_ALMOST_EQUAL;
|
|
||||||
} else {
|
|
||||||
mstr += '=';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mstr += str;
|
|
||||||
}
|
|
||||||
if (do_space) mstr += ' ';
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
}
|
|
||||||
mstr += tstr;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCT_BITWISE_NOT: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
|
|
||||||
mstr += "<a name=\"+Bitwise NOT\">~</a>";
|
|
||||||
|
|
||||||
ips_n.wrap = m[0].needsParenthesis(po, ips_n, m, 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
mstr += drawStructure(m[0], po, ips_n);
|
|
||||||
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCT_LOGICAL_NOT: {
|
|
||||||
|
|
||||||
ips_n.depth++;
|
|
||||||
|
|
||||||
STR_MARKUP_BEGIN(mstr);
|
|
||||||
|
|
||||||
mstr += "<a name=\"+Logical NOT\">!</a>";
|
|
||||||
|
|
||||||
ips_n.wrap = m[0].needsParenthesis(po, ips_n, m, 1, ips.division_depth > 0 || ips.power_depth > 0, ips.power_depth > 0);
|
|
||||||
mstr += drawStructure(m[0], po, ips_n);
|
|
||||||
|
|
||||||
STR_MARKUP_END(mstr);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCT_UNDEFINED: {
|
|
||||||
STR_MARKUP_ADD(mstr, "undefined");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ips.wrap) {
|
|
||||||
STR_MARKUP_PREPEND(mstr, "(");
|
|
||||||
STR_MARKUP_ADD(mstr, ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ips.depth == 0) {
|
|
||||||
mstr.prepend(TEXT_TAGS);
|
|
||||||
mstr += TEXT_TAGS_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mstr;
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
* Copyright 2003-2007 Niklas Knutsson <nq@altern.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATELABELS_H
|
|
||||||
#define QALCULATELABELS_H
|
|
||||||
|
|
||||||
#include <libqalculate/Calculator.h>
|
|
||||||
#include <libqalculate/Variable.h>
|
|
||||||
#include <libqalculate/Function.h>
|
|
||||||
#include <libqalculate/Unit.h>
|
|
||||||
#include <libqalculate/Prefix.h>
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class QalculateSettings;
|
|
||||||
|
|
||||||
class QalculateLabels
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QalculateLabels(const QalculateSettings* qalculateSettings):
|
|
||||||
m_qalculateSettings(qalculateSettings) {}
|
|
||||||
QString drawStructure(MathStructure& m, const PrintOptions& po, InternalPrintStruct ips = top_ips);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QalculateSettings *m_qalculateSettings;
|
|
||||||
std::vector<MathStructure> result_parts;
|
|
||||||
bool in_matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,273 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qalculate_settings.h"
|
|
||||||
#include "qalculate_applet.h"
|
|
||||||
|
|
||||||
#include <KConfigGroup>
|
|
||||||
#include <KConfigDialog>
|
|
||||||
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QSpinBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QGroupBox>
|
|
||||||
|
|
||||||
#include <KComboBox>
|
|
||||||
|
|
||||||
|
|
||||||
QalculateSettings::QalculateSettings(QalculateApplet* applet)
|
|
||||||
: QObject(0),
|
|
||||||
m_applet(applet)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::readSettings()
|
|
||||||
{
|
|
||||||
KConfigGroup cfg = m_applet->config();
|
|
||||||
|
|
||||||
// load settings
|
|
||||||
m_convertToBestUnits = cfg.readEntry("convertToBestUnits", true);
|
|
||||||
m_structuring = cfg.readEntry("structuring", 1);
|
|
||||||
m_fractionDisplay = cfg.readEntry("fractionDisplay", 0);
|
|
||||||
m_angleUnit = cfg.readEntry("angleUnit", 1);
|
|
||||||
m_readPrecisionMode = cfg.readEntry("readPrecisionMode", 0);
|
|
||||||
m_indicateInfiniteSeries = cfg.readEntry("indicateInfiniteSeries", false);
|
|
||||||
m_useAllPrefixes = cfg.readEntry("useAllPrefixes", false);
|
|
||||||
m_useDenominatorPrefix = cfg.readEntry("useDenominatorPrefix", true);
|
|
||||||
m_negativeExponents = cfg.readEntry("negativeExponents", false);
|
|
||||||
m_updateExchangeRatesAtStartup = cfg.readEntry("updateExchangeRatesAtStartup", true);
|
|
||||||
m_copyToClipboard = cfg.readEntry("copyToClipboard", false);
|
|
||||||
m_resultsInline = cfg.readEntry("resultsInline", false);
|
|
||||||
m_rpn = cfg.readEntry("rpn", false);
|
|
||||||
m_preserveFormat = cfg.readEntry("preserveFormat", false);
|
|
||||||
m_liveEvaluation = cfg.readEntry("liveEvaluation", false);
|
|
||||||
m_base = cfg.readEntry("base", 10);
|
|
||||||
m_baseDisplay = cfg.readEntry("baseDisplay", 10);
|
|
||||||
m_minExp = cfg.readEntry("minExp", 0);
|
|
||||||
m_showBinary = cfg.readEntry("showBinary", false);
|
|
||||||
m_showOctal = cfg.readEntry("showOctal", false);
|
|
||||||
m_showDecimal = cfg.readEntry("showDecimal", false);
|
|
||||||
m_showHexadecimal = cfg.readEntry("showHexadecimal", false);
|
|
||||||
m_historyItems = cfg.readEntry("historyItems", QStringList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::writeSettings()
|
|
||||||
{
|
|
||||||
KConfigGroup cfg = m_applet->config();
|
|
||||||
|
|
||||||
// write settings
|
|
||||||
cfg.writeEntry("convertToBestUnits", m_unitsCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("structuring", m_structuringCombo->currentIndex());
|
|
||||||
cfg.writeEntry("angleUnit", m_angleUnitCombo->currentIndex());
|
|
||||||
cfg.writeEntry("fractionDisplay", m_fractionCombo->currentIndex());
|
|
||||||
cfg.writeEntry("indicateInfiniteSeries", m_infiniteSeriesCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("useAllPrefixes", m_allPrefixesCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("useDenominatorPrefix", m_denominatorPrefixCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("negativeExponents", m_negativeExponentsCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("updateExchangeRatesAtStartup", m_exchangeRatesCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("copyToClipboard", m_copyToClipboardCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("resultsInline", m_resultsInlineCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("liveEvaluation", m_liveEvaluationCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("rpn", m_rpnCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("base", m_baseSpin->value());
|
|
||||||
cfg.writeEntry("baseDisplay", m_baseDisplaySpin->value());
|
|
||||||
cfg.writeEntry("minExp", m_minExpCombo->currentIndex());
|
|
||||||
cfg.writeEntry("showBinary", m_showBinaryCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("showOctal", m_showOctalCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("showDecimal", m_showDecimalCheck->checkState() == Qt::Checked);
|
|
||||||
cfg.writeEntry("showHexadecimal", m_showHexadecimalCheck->checkState() == Qt::Checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::createConfigurationInterface(KConfigDialog* parent)
|
|
||||||
{
|
|
||||||
m_configDialog = parent;
|
|
||||||
|
|
||||||
m_configDialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
|
|
||||||
connect(m_configDialog, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
|
||||||
connect(m_configDialog, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
|
||||||
|
|
||||||
QWidget *page = new QWidget();
|
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout(page);
|
|
||||||
// convert to best units
|
|
||||||
|
|
||||||
m_unitsCheck = new QCheckBox(i18n("Convert to &best units"), page);
|
|
||||||
m_unitsCheck->setCheckState(m_convertToBestUnits ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_unitsCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_copyToClipboardCheck = new QCheckBox(i18n("Copy result to clipboard"), page);
|
|
||||||
m_copyToClipboardCheck->setCheckState(m_copyToClipboard ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_copyToClipboardCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_resultsInlineCheck = new QCheckBox(i18n("Write results in input line edit"), page);
|
|
||||||
m_resultsInlineCheck->setCheckState(m_resultsInline ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_resultsInlineCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_liveEvaluationCheck = new QCheckBox(i18n("Live evaluation"), page);
|
|
||||||
m_liveEvaluationCheck->setCheckState(m_liveEvaluation ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_liveEvaluationCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
connect(m_liveEvaluationCheck, SIGNAL(stateChanged(int)), this, SLOT(checkValidity()));
|
|
||||||
m_rpnCheck = new QCheckBox(i18n("Enable reverse Polish notation"), page);
|
|
||||||
m_rpnCheck->setCheckState(m_rpn ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_rpnCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_baseSpin = new QSpinBox(page);
|
|
||||||
m_baseSpin->setValue(m_base);
|
|
||||||
m_baseSpin->setMinimum(2);
|
|
||||||
m_baseSpin->setMaximum(32);
|
|
||||||
connect(m_baseSpin, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_baseDisplaySpin = new QSpinBox(page);
|
|
||||||
m_baseDisplaySpin->setValue(m_baseDisplay);
|
|
||||||
m_baseDisplaySpin->setMinimum(2);
|
|
||||||
m_baseDisplaySpin->setMaximum(32);
|
|
||||||
connect(m_baseDisplaySpin, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_structuringCombo = new KComboBox(page);
|
|
||||||
m_structuringCombo->addItem(i18n("None"));
|
|
||||||
m_structuringCombo->addItem(i18n("Simplify"));
|
|
||||||
m_structuringCombo->addItem(i18n("Factorize"));
|
|
||||||
m_structuringCombo->setCurrentIndex(m_structuring);
|
|
||||||
connect(m_structuringCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_angleUnitCombo = new KComboBox(page);
|
|
||||||
m_angleUnitCombo->addItem(i18n("None"));
|
|
||||||
m_angleUnitCombo->addItem(i18n("Radians"));
|
|
||||||
m_angleUnitCombo->addItem(i18n("Degrees"));
|
|
||||||
m_angleUnitCombo->addItem(i18n("Gradians"));
|
|
||||||
m_angleUnitCombo->setCurrentIndex(m_angleUnit);
|
|
||||||
connect(m_angleUnitCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
layout->addRow(m_unitsCheck);
|
|
||||||
layout->addRow(m_copyToClipboardCheck);
|
|
||||||
layout->addRow(m_resultsInlineCheck);
|
|
||||||
layout->addRow(m_liveEvaluationCheck);
|
|
||||||
layout->addRow(m_rpnCheck);
|
|
||||||
layout->addRow(i18n("Structuring mode:"), m_structuringCombo);
|
|
||||||
layout->addRow(i18n("Angle unit:"), m_angleUnitCombo);
|
|
||||||
layout->addRow(i18n("Expression base:"), m_baseSpin);
|
|
||||||
layout->addRow(i18n("Result base:"), m_baseDisplaySpin);
|
|
||||||
|
|
||||||
m_configDialog->addPage(page, i18nc("Evaluation", "Evaluation Settings"), m_applet->icon());
|
|
||||||
|
|
||||||
QWidget *printPage = new QWidget();
|
|
||||||
|
|
||||||
QFormLayout *printLayout = new QFormLayout(printPage);
|
|
||||||
|
|
||||||
m_fractionCombo = new KComboBox(printPage);
|
|
||||||
m_fractionCombo->addItem(i18n("Decimal"));
|
|
||||||
m_fractionCombo->addItem(i18n("Exact"));
|
|
||||||
m_fractionCombo->addItem(i18n("Fractional"));
|
|
||||||
m_fractionCombo->addItem(i18n("Combined"));
|
|
||||||
m_fractionCombo->setCurrentIndex(m_fractionDisplay);
|
|
||||||
connect(m_fractionCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_minExpCombo = new KComboBox(printPage);
|
|
||||||
m_minExpCombo->addItem(i18n("None"));
|
|
||||||
m_minExpCombo->addItem(i18n("Pure"));
|
|
||||||
m_minExpCombo->addItem(i18n("Scientific"));
|
|
||||||
m_minExpCombo->addItem(i18n("Precision"));
|
|
||||||
m_minExpCombo->addItem(i18n("Engineering"));
|
|
||||||
m_minExpCombo->setCurrentIndex(m_minExp);
|
|
||||||
connect(m_minExpCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
m_infiniteSeriesCheck = new QCheckBox(i18n("Indicate infinite series"), printPage);
|
|
||||||
m_infiniteSeriesCheck->setCheckState(m_indicateInfiniteSeries ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_infiniteSeriesCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_allPrefixesCheck = new QCheckBox(i18n("Use all prefixes"), printPage);
|
|
||||||
m_allPrefixesCheck->setCheckState(m_useAllPrefixes ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_allPrefixesCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_denominatorPrefixCheck = new QCheckBox(i18n("Use denominator prefix"), printPage);
|
|
||||||
m_denominatorPrefixCheck->setCheckState(m_useDenominatorPrefix ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_denominatorPrefixCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_negativeExponentsCheck = new QCheckBox(i18n("Negative exponents"), printPage);
|
|
||||||
m_negativeExponentsCheck->setCheckState(m_negativeExponents ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_negativeExponentsCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
QGroupBox *showBasesBox = new QGroupBox(i18n("Show integers also in base:"), printPage);
|
|
||||||
QGridLayout *layoutBases = new QGridLayout(showBasesBox);
|
|
||||||
|
|
||||||
m_showBinaryCheck = new QCheckBox(i18n("Binary"), printPage);
|
|
||||||
m_showBinaryCheck->setCheckState(m_showBinary ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_showBinaryCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_showOctalCheck = new QCheckBox(i18n("Octal"), printPage);
|
|
||||||
m_showOctalCheck->setCheckState(m_showOctal ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_showOctalCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_showDecimalCheck = new QCheckBox(i18n("Decimal"), printPage);
|
|
||||||
m_showDecimalCheck->setCheckState(m_showDecimal ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_showDecimalCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
m_showHexadecimalCheck = new QCheckBox(i18n("Hexadecimal"), printPage);
|
|
||||||
m_showHexadecimalCheck->setCheckState(m_showHexadecimal ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_showHexadecimalCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
|
|
||||||
layoutBases->addWidget(m_showBinaryCheck, 0, 0);
|
|
||||||
layoutBases->addWidget(m_showOctalCheck, 1, 0);
|
|
||||||
layoutBases->addWidget(m_showDecimalCheck, 2, 0);
|
|
||||||
layoutBases->addWidget(m_showHexadecimalCheck, 3, 0);
|
|
||||||
|
|
||||||
printLayout->addRow(i18n("Number fraction format:"), m_fractionCombo);
|
|
||||||
printLayout->addRow(i18n("Numerical display:"), m_minExpCombo);
|
|
||||||
|
|
||||||
printLayout->addRow(m_infiniteSeriesCheck);
|
|
||||||
printLayout->addRow(m_allPrefixesCheck);
|
|
||||||
printLayout->addRow(m_denominatorPrefixCheck);
|
|
||||||
printLayout->addRow(m_negativeExponentsCheck);
|
|
||||||
printLayout->addRow(showBasesBox);
|
|
||||||
|
|
||||||
m_configDialog->addPage(printPage, i18nc("Print", "Print Settings"), m_applet->icon());
|
|
||||||
|
|
||||||
QWidget *currencyPage = new QWidget();
|
|
||||||
QFormLayout *currencyLayout = new QFormLayout(currencyPage);
|
|
||||||
|
|
||||||
m_exchangeRatesCheck = new QCheckBox(i18n("Update exchange rates at startup"), currencyPage);
|
|
||||||
m_exchangeRatesCheck->setCheckState(m_updateExchangeRatesAtStartup ? Qt::Checked : Qt::Unchecked);
|
|
||||||
connect(m_exchangeRatesCheck, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
|
||||||
currencyLayout->addRow(m_exchangeRatesCheck);
|
|
||||||
|
|
||||||
m_configDialog->addPage(currencyPage, i18nc("Currency", "Currency Settings"), m_applet->icon());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::configAccepted()
|
|
||||||
{
|
|
||||||
writeSettings();
|
|
||||||
readSettings();
|
|
||||||
emit accepted();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::checkValidity()
|
|
||||||
{
|
|
||||||
if (m_liveEvaluationCheck->checkState() == Qt::Checked) {
|
|
||||||
m_resultsInlineCheck->setCheckState(Qt::Unchecked);
|
|
||||||
m_resultsInlineCheck->setEnabled(false);
|
|
||||||
} else {
|
|
||||||
m_resultsInlineCheck->setEnabled(true);
|
|
||||||
m_resultsInlineCheck->setCheckState(m_resultsInline ? Qt::Checked : Qt::Unchecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QalculateSettings::setHistoryItems(QStringList items)
|
|
||||||
{
|
|
||||||
m_historyItems = items;
|
|
||||||
KConfigGroup cfg = m_applet->config();
|
|
||||||
cfg.writeEntry("historyItems", m_historyItems);
|
|
||||||
cfg.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,194 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009 Matteo Agostinelli <agostinelli@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QALCULATESETTINGS_H
|
|
||||||
#define QALCULATESETTINGS_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "qalculate_applet.h"
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
class KComboBox;
|
|
||||||
|
|
||||||
class QalculateSettings : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QalculateSettings(QalculateApplet* applet);
|
|
||||||
|
|
||||||
//! Convert the result to the best units
|
|
||||||
bool convertToBestUnits() const {
|
|
||||||
return m_convertToBestUnits;
|
|
||||||
}
|
|
||||||
//! Indicate infinite series
|
|
||||||
bool indicateInfiniteSeries() const {
|
|
||||||
return m_indicateInfiniteSeries;
|
|
||||||
}
|
|
||||||
//! Use all prefixes
|
|
||||||
bool useAllPrefixes() const {
|
|
||||||
return m_useAllPrefixes;
|
|
||||||
}
|
|
||||||
//! Use denominator prefixes
|
|
||||||
bool useDenominatorPrefix() const {
|
|
||||||
return m_useDenominatorPrefix;
|
|
||||||
}
|
|
||||||
//! Use negative exponents
|
|
||||||
bool negativeExponents() const {
|
|
||||||
return m_negativeExponents;
|
|
||||||
}
|
|
||||||
//! Update exchange rates at startup
|
|
||||||
bool updateExchangeRatesAtStartup() const {
|
|
||||||
return m_updateExchangeRatesAtStartup;
|
|
||||||
}
|
|
||||||
//! Copy the result of the evaluation to clipboard
|
|
||||||
bool copyToClipboard() const {
|
|
||||||
return m_copyToClipboard;
|
|
||||||
}
|
|
||||||
//! Write the results in the input line-edit
|
|
||||||
bool resultsInline() const {
|
|
||||||
return m_resultsInline;
|
|
||||||
}
|
|
||||||
//! Live evaluation
|
|
||||||
bool liveEvaluation() const {
|
|
||||||
return m_liveEvaluation;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Structuring of the resultsInline
|
|
||||||
//! @return 0, None
|
|
||||||
//! @return 1, Simplify
|
|
||||||
//! @return 2, Factorize
|
|
||||||
int structuring() const {
|
|
||||||
return m_structuring;
|
|
||||||
}
|
|
||||||
//! How to display fractions
|
|
||||||
//! @return 0, Decimal
|
|
||||||
//! @return 1, Exact
|
|
||||||
//! @return 2, Fractional
|
|
||||||
//! @return 3, Combined
|
|
||||||
int fractionDisplay() const {
|
|
||||||
return m_fractionDisplay;
|
|
||||||
}
|
|
||||||
//! Default unit for angles
|
|
||||||
//! @return 0, ANGLE_UNIT_NONE
|
|
||||||
//! @return 1, ANGLE_UNIT_RADIANS
|
|
||||||
//! @return 2, ANGLE_UNIT_DEGREES
|
|
||||||
//! @return 3, ANGLE_UNIT_GRADIANS
|
|
||||||
int angleUnit() const {
|
|
||||||
return m_angleUnit;
|
|
||||||
}
|
|
||||||
//! Use Reversed Polish Notation
|
|
||||||
bool rpn() const {
|
|
||||||
return m_rpn;
|
|
||||||
}
|
|
||||||
//! Base of parsed numbers
|
|
||||||
int base() const {
|
|
||||||
return m_base;
|
|
||||||
}
|
|
||||||
//! Base of displayed numbers
|
|
||||||
int baseDisplay() const {
|
|
||||||
return m_baseDisplay;
|
|
||||||
}
|
|
||||||
//! Read precision mode
|
|
||||||
//! @return 0, DONT_READ_PRECISION
|
|
||||||
//! @return 1, ALWAYS_READ_PRECISION
|
|
||||||
//! @return 2, READ_PRECISION_WHEN_DECIMALS
|
|
||||||
int readPrecisionMode() const {
|
|
||||||
return m_readPrecisionMode;
|
|
||||||
}
|
|
||||||
//! Preserve the expression structure as much as possible
|
|
||||||
bool preserveFormat() const {
|
|
||||||
return m_preserveFormat;
|
|
||||||
}
|
|
||||||
//! Numerical display
|
|
||||||
//! @return 0, NONE
|
|
||||||
//! @return 1, PURE
|
|
||||||
//! @return 2, SCIENTIFIC
|
|
||||||
//! @return 3, PRECISION
|
|
||||||
//! @return 4, ENGINEERING
|
|
||||||
int minExp() const {
|
|
||||||
return m_minExp;
|
|
||||||
}
|
|
||||||
//! History items
|
|
||||||
QStringList historyItems() const {
|
|
||||||
return m_historyItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool showBinary() const {
|
|
||||||
return m_showBinary;
|
|
||||||
}
|
|
||||||
bool showOctal() const {
|
|
||||||
return m_showOctal;
|
|
||||||
}
|
|
||||||
bool showDecimal() const {
|
|
||||||
return m_showDecimal;
|
|
||||||
}
|
|
||||||
bool showHexadecimal() const {
|
|
||||||
return m_showHexadecimal;
|
|
||||||
}
|
|
||||||
bool showOtherBases() const {
|
|
||||||
return m_showBinary || m_showOctal || m_showDecimal || m_showHexadecimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHistoryItems(QStringList items);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
|
||||||
|
|
||||||
//! Creates the configuration dialog contents.
|
|
||||||
void createConfigurationInterface(KConfigDialog *parent);
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void configAccepted();
|
|
||||||
void checkValidity();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void accepted();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QalculateApplet* m_applet;
|
|
||||||
KConfigDialog *m_configDialog;
|
|
||||||
|
|
||||||
bool m_convertToBestUnits, m_indicateInfiniteSeries, m_useAllPrefixes, m_useDenominatorPrefix, m_negativeExponents;
|
|
||||||
bool m_updateExchangeRatesAtStartup;
|
|
||||||
bool m_copyToClipboard, m_resultsInline;
|
|
||||||
bool m_rpn;
|
|
||||||
bool m_preserveFormat;
|
|
||||||
bool m_liveEvaluation;
|
|
||||||
bool m_showBinary, m_showOctal, m_showDecimal, m_showHexadecimal;
|
|
||||||
int m_structuring;
|
|
||||||
int m_fractionDisplay;
|
|
||||||
int m_angleUnit;
|
|
||||||
int m_base, m_baseDisplay;
|
|
||||||
int m_minExp;
|
|
||||||
int m_readPrecisionMode;
|
|
||||||
QStringList m_historyItems;
|
|
||||||
|
|
||||||
QCheckBox *m_unitsCheck, *m_infiniteSeriesCheck, *m_allPrefixesCheck, *m_denominatorPrefixCheck, *m_negativeExponentsCheck, *m_rpnCheck;
|
|
||||||
QCheckBox *m_exchangeRatesCheck;
|
|
||||||
QCheckBox *m_copyToClipboardCheck, *m_resultsInlineCheck, *m_liveEvaluationCheck;
|
|
||||||
KComboBox *m_structuringCombo, *m_fractionCombo, *m_angleUnitCombo, *m_minExpCombo;
|
|
||||||
QSpinBox *m_baseSpin, *m_baseDisplaySpin;
|
|
||||||
QCheckBox *m_showBinaryCheck, *m_showOctalCheck, *m_showDecimalCheck, *m_showHexadecimalCheck;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QALCULATESETTINGS_H
|
|
Loading…
Add table
Reference in a new issue