[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [abakus] /: optionally build abakus qt only; needs some further work though
From: Mathias Kraus <k.hias () gmx ! de>
Date: 2013-03-24 13:31:59
Message-ID: 20130324133159.703B2A6058 () git ! kde ! org
[Download RAW message or body]
Git commit 70a8e305e54efc3bbb82d973ae450b7a83183f3e by Mathias Kraus.
Committed on 22/03/2013 at 00:11.
Pushed by mkraus into branch 'master'.
optionally build abakus qt only; needs some further work though
A +88 -0 abakus-qt.pro
A +14 -0 qmake/bison/bison.pri
A +8 -0 qmake/flex/flex.pri
A +221 -0 qml-qt/ConfigPanel.qml [License: UNKNOWN] *
A +5 -0 qml-qt/ContextMenu.qml [License: UNKNOWN] *
A +34 -0 qml-qt/Editor.qml [License: UNKNOWN] *
A +166 -0 qml-qt/MainView.qml [License: UNKNOWN] *
A +98 -0 qml-qt/MathExpressionItem.qml [License: UNKNOWN] *
A +152 -0 qml-qt/MathSidebar.qml [License: UNKNOWN] *
A +86 -0 qml-qt/ResultViewItem.qml [License: UNKNOWN] *
A +109 -0 qml-qt/SidebarGrip.qml [License: UNKNOWN] *
A +78 -0 qml-qt/TrigonometricMode.qml [License: UNKNOWN] *
A +19 -0 qml-qt/main.qml [License: UNKNOWN] *
M +0 -2 src/function.cpp
M +8 -3 src/functionmodel.cpp
M +8 -1 src/functionmodelitem.cpp
M +13 -4 src/main.cpp
M +34 -15 src/mainwindow.cpp
M +7 -2 src/mainwindow.h
M +7 -3 src/numeralmodel.cpp
M +8 -1 src/numeralmodelitem.cpp
M +11 -2 src/numerictypes.cpp
M +47 -26 src/parser.yy
M +0 -2 src/resultmodel.cpp
M +22 -4 src/settingscore.cpp
M +1 -1 src/settingscore.h
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/abakus/70a8e305e54efc3bbb82d973ae450b7a83183f3e
diff --git a/abakus-qt.pro b/abakus-qt.pro
new file mode 100644
index 0000000..0c53f9a
--- /dev/null
+++ b/abakus-qt.pro
@@ -0,0 +1,88 @@
+TARGET = abakus
+
+BUILD_DIR = build-qt
+RCC_DIR = build-qt/RCCFiles
+UI_DIR = build-qt/UICFiles
+MOC_DIR = build-qt/MOCFiles
+OBJECTS_DIR = build-qt/ObjFiles
+
+CONFIG(debug, debug|release) {
+ DESTDIR = "debug"
+}
+CONFIG(release, debug|release) {
+ DESTDIR = "release"
+}
+
+DEFINES += ABAKUS_QTONLY
+
+# Additional import path used to resolve QML modules in Creator's code model
+QML_IMPORT_PATH += /usr/lib/kde4/imports
+
+QT += declarative
+
+# If your application uses the Qt Mobility libraries, uncomment the following
+# lines and add the respective components to the MOBILITY variable.
+# CONFIG += mobility
+# MOBILITY +=
+
+# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
+# CONFIG += qdeclarative-boostable
+
+unix:LIBS+= -L/usr/lib -lmpfr
+
+INCLUDEPATH += src
+
+include(qmake/bison/bison.pri)
+BISONSOURCES = src/parser.yy
+include(qmake/flex/flex.pri)
+FLEXSOURCES = src/lexer.ll
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += src/main.cpp \
+ src/settingscore.cpp \
+ src/settings.cpp \
+ src/resultmodelitem.cpp \
+ src/resultmodel.cpp \
+ src/result.cpp \
+ src/numerictypes.cpp \
+ src/numeralmodelitem.cpp \
+ src/numeralmodel.cpp \
+ src/node.cpp \
+ src/mainwindow.cpp \
+ src/functionmodelitem.cpp \
+ src/functionmodel.cpp \
+ src/function.cpp
+
+# Please do not modify the following two lines. Required for deployment.
+#include(qt/qmlapplicationviewer/qmlapplicationviewer.pri)
+#qtcAddDeployment()
+
+HEADERS += \
+ src/sharedptr.h \
+ src/settingscore.h \
+ src/settings.h \
+ src/resultmodelitem.h \
+ src/resultmodel.h \
+ src/result.h \
+ src/numerictypes.h \
+ src/numeralmodelitem.h \
+ src/numeralmodel.h \
+ src/node.h \
+ src/mainwindow.h \
+ src/functionmodelitem.h \
+ src/functionmodel.h \
+ src/function.h
+
+qml.path = $$DESTDIR/qml
+qml.files += qml-qt/main.qml
+qml.files += qml-qt/ConfigPanel.qml
+qml.files += qml-qt/ContextMenu.qml
+qml.files += qml-qt/Editor.qml
+qml.files += qml-qt/MainView.qml
+qml.files += qml-qt/MathExpressionItem.qml
+qml.files += qml-qt/MathSidebar.qml
+qml.files += qml-qt/ResultViewItem.qml
+qml.files += qml-qt/SidebarGrip.qml
+qml.files += qml-qt/TrigonometricMode.qml
+
+INSTALLS += qml
diff --git a/qmake/bison/bison.pri b/qmake/bison/bison.pri
new file mode 100644
index 0000000..d61e9e3
--- /dev/null
+++ b/qmake/bison/bison.pri
@@ -0,0 +1,14 @@
+bison.name = Bison ${QMAKE_FILE_IN}
+bison.input = BISONSOURCES
+bison.output = $$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.cpp
+bison.commands = bison -d -o $$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.cpp \
${QMAKE_FILE_IN} +bison.CONFIG += target_predeps
+bison.variable_out = GENERATED_SOURCES
+silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands
+QMAKE_EXTRA_COMPILERS += bison
+bison_header.input = BISONSOURCES
+bison_header.output = $$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.hpp
+bison_header.commands = bison -d -o \
$$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.cpp ${QMAKE_FILE_IN} \
+bison_header.CONFIG += target_predeps no_link +silent:bison_header.commands = @echo \
Bison ${QMAKE_FILE_IN} && $$bison.commands +QMAKE_EXTRA_COMPILERS += bison_header
diff --git a/qmake/flex/flex.pri b/qmake/flex/flex.pri
new file mode 100644
index 0000000..062bfdb
--- /dev/null
+++ b/qmake/flex/flex.pri
@@ -0,0 +1,8 @@
+flex.name = Flex ${QMAKE_FILE_IN}
+flex.input = FLEXSOURCES
+flex.output = $$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.cpp
+flex.commands = flex -o $$BUILD_DIR/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}.cpp \
${QMAKE_FILE_IN} +flex.CONFIG += target_predeps
+flex.variable_out = GENERATED_SOURCES
+silent:flex.commands = @echo Lex ${QMAKE_FILE_IN} && $$flex.commands
+QMAKE_EXTRA_COMPILERS += flex
diff --git a/qml-qt/ConfigPanel.qml b/qml-qt/ConfigPanel.qml
new file mode 100644
index 0000000..2640f6e
--- /dev/null
+++ b/qml-qt/ConfigPanel.qml
@@ -0,0 +1,221 @@
+import QtQuick 1.1
+import abakus 1.0 as Abakus
+
+Item {
+ id: root
+
+ property int settingsPanelHeigth: 80
+ property int buttonHeight
+ property QtObject mainWindowObject
+
+ signal settingsPanelVisibleChanged(bool settingsVisible)
+
+ signal rejectFocus()
+
+ Abakus.Settings {
+ id: settings
+
+ onPrecisionChanged: precisionText.text = precision < 0 ? i18n("Auto") : \
precision +
+ onCompactModeChanged: compactModeButton.checked = compactMode
+
+ Component.onCompleted: {
+ precisionText.text = precision < 0 ? i18n("Auto") : precision
+ compactModeButton.checked = compactMode
+ }
+ }
+
+ Row {
+ id: toolbarButtons
+ height: root.buttonHeight
+ anchors.left: root.left
+ anchors.top: root.top
+
+ Item { //ToolButton
+ id: settingsButton
+ height: parent.height
+ //flat: true
+ //checkable: true
+ //iconSource: "configure"
+
+ //onCheckedChanged: {
+ // if(checked) settings.compactMode = false
+ // settingsPanelVisibleChanged(checked)
+ //}
+ }
+
+ Item { //ToolButton
+ id: compactModeButton
+ height: parent.height
+ //flat: true
+ //checkable:true
+ //iconSource: "merge"
+
+ //onCheckedChanged: {
+ // if(checked) settingsButton.checked = false
+ // settings.compactMode = checked
+ //}
+ }
+
+ Item { //ToolButton
+ id: help
+ height: parent.height
+ //flat: true
+ //iconSource: "help-about"
+
+ //onClicked: {
+ // var position = mapToItem(null, 0, height)
+ // mainWindowObject.showHelpMenu(position.x, position.y)
+ //}
+ }
+ }
+
+ Item {
+ id: settingsPanel
+ anchors.left: root.left
+ anchors.right: root.right
+ anchors.top: toolbarButtons.bottom
+ anchors.bottom: root.bottom
+ clip: true
+
+ Column {
+ width: 150
+ height: parent.height
+ anchors.left: parent.left
+ anchors.top: parent. top
+
+ Row {
+ width: parent.width
+
+ Text {
+ id: precisionLabel
+ height: buttonHeight
+ verticalAlignment: Text.AlignVCenter
+ text: i18n("Decimal Precision:")
+ }
+
+ Item {
+ id: precisionComboBox
+ width: parent.width - precisionLabel.width
+ height: buttonHeight
+
+ property bool editCustom: false
+
+ Item {
+ anchors.fill: parent
+ //imagePath: "widgets/lineedit"
+ //prefix: "base"
+ visible: !precisionComboBox.editCustom
+
+ Text {
+ id: precisionText
+ anchors.fill: parent
+ anchors.leftMargin: 6
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onDoubleClicked: {
+ precisionComboBox.editCustom = true
+ precisionCustom.text = (precisionText.text == \
i18n("Auto")) ? "" : precisionText.text + \
precisionCustom.forceActiveFocus() + }
+ }
+ }
+
+ TextInput {
+ id: precisionCustom
+ anchors.fill: parent
+ validator: IntValidator{bottom: 1; top: 75;}
+ visible: precisionComboBox.editCustom
+
+ onAccepted: {
+ precisionComboBox.editCustom = false
+ precisionComboBox.focus = false
+ settings.precision = parseInt(precisionCustom.text)
+ root.rejectFocus()
+ }
+
+ onActiveFocusChanged: {
+ if(!activeFocus && precisionComboBox.editCustom)
+ {
+ precisionComboBox.editCustom = false
+ }
+ }
+ }
+
+ Item { //ToolButton
+ width: height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.margins: 1
+ //flat: true
+ //iconSource: precisionComboBox.editCustom ? "key-enter" : \
"arrow-down" +
+ property ContextMenu contextMenu
+ /*onClicked: {
+ if (!precisionComboBox.editCustom)
+ {
+ if (!contextMenu) {
+ contextMenu = \
contextMenuComponent.createObject(precisionComboBox) + \
} + contextMenu.open()
+ }
+ else if(precisionCustom.acceptableInput)
+ {
+ precisionComboBox.editCustom = false
+ precisionComboBox.focus = false
+ settings.precision = parseInt(precisionCustom.text)
+ root.rejectFocus()
+ }
+ }*/
+ }
+ }
+ }
+
+ Item { //ToolButton
+ id: configureShortcuts
+ width: parent.width
+ height: buttonHeight
+ /*flat: true
+ iconSource: "configure-shortcuts"
+ text: i18n("Configure Shortcuts...")
+
+ onClicked: mainWindowObject.configureShortcuts()*/
+ }
+
+ Item { //ToolButton
+ id: clearHistory
+ width: parent.width
+ height: buttonHeight
+ /*flat: true
+ iconSource: "edit-clear-list"
+ text: i18n("Clear History")
+
+ onClicked: mainWindowObject.clearHistory()*/
+ }
+
+ /*Component {
+ id: contextMenuComponent
+ PlasmaComponents.ContextMenu {
+ visualParent: precisionComboBox
+ PlasmaComponents.MenuItem {
+ text: i18n("Automatic")
+ onClicked: settings.precision = -1
+ }
+ PlasmaComponents.MenuItem {
+ text: i18n("Custom (1...75)")
+ onClicked: {
+ precisionComboBox.editCustom = true
+ precisionCustom.text = ""
+ precisionCustom.forceActiveFocus()
+ }
+ }
+ }
+ }*/
+ }
+ }
+}
diff --git a/qml-qt/ContextMenu.qml b/qml-qt/ContextMenu.qml
new file mode 100644
index 0000000..fe42e56
--- /dev/null
+++ b/qml-qt/ContextMenu.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.1
+
+//this is just a workaround because PlasmaComponents.ContextMenu doesn't work
+Item{ //ContextMenu{
+}
diff --git a/qml-qt/Editor.qml b/qml-qt/Editor.qml
new file mode 100644
index 0000000..f0b1228
--- /dev/null
+++ b/qml-qt/Editor.qml
@@ -0,0 +1,34 @@
+import QtQuick 1.1
+
+FocusScope {
+ id: root
+
+ property alias text: textField.text
+ property QtObject mainWindowObject
+
+ TextInput {
+ id: textField
+ anchors.fill: parent
+ font.pixelSize: 12
+ focus: true
+ //clearButtonShown: true
+ //placeholderText: i18n("Enter expression")
+
+ onAccepted: {
+ mainWindowObject.slotEvaluate(text)
+ textField.selectAll()
+ }
+
+ onTextChanged: mainWindowObject.slotTextChanged(text)
+
+ Keys.onUpPressed: mainWindowObject.historyPrevious()
+ Keys.onDownPressed: mainWindowObject.historyNext()
+
+ Connections {
+ target: mainWindowObject
+
+ onSetFocusToEditor: root.focus = true
+ onSetEditorText: textField.text = editorText
+ }
+ }
+}
diff --git a/qml-qt/MainView.qml b/qml-qt/MainView.qml
new file mode 100644
index 0000000..44ac70a
--- /dev/null
+++ b/qml-qt/MainView.qml
@@ -0,0 +1,166 @@
+import QtQuick 1.1
+import abakus 1.0 as Abakus
+
+Item {
+ id: baseItem
+
+ property int sidebarWidth: sidebar.width
+ property int sidebarTabBarHeight: 25
+ property int toolbarHeight: 25
+ property int editorHeight: 25
+
+ Keys.onPressed: if(event.key == Qt.Key_Escape) editor.focus = true
+
+ Abakus.Settings {
+ id: settings
+ }
+
+ Item {
+ id: toolbar
+ height: toolbarHeight
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: sidebar.left
+
+ ConfigPanel {
+ id: configPanel
+ width: parent.width
+ height: parent.height
+ anchors.left: parent.left
+ anchors.top: parent.top
+ buttonHeight: toolbarHeight
+ mainWindowObject: mainWindow
+
+ onSettingsPanelVisibleChanged: {
+ toolbar.state = settingsVisible ? "settingsVisible" : ""
+ editor.focus = !settingsVisible
+ }
+
+ onRejectFocus: editor.forceActiveFocus()
+ }
+
+ TrigonometricMode {
+ id: trigMode
+ height: toolbarHeight
+ anchors.right: sidebarGrip.left
+ anchors.rightMargin: 5
+ anchors.top: parent.top
+ }
+
+ SidebarGrip {
+ id: sidebarGrip
+ width: 15
+ height: toolbarHeight
+ anchors.right: parent.right
+ anchors.top: parent.top
+
+ onShowToolTip: mainWindow.showToolTip(xPosition, yPosition, toolTipText)
+ onHideToolTip: mainWindow.hideToolTip()
+ }
+
+ states: State {
+ name: "settingsVisible"
+ PropertyChanges { target: toolbar; height: toolbarHeight + \
configPanel.settingsPanelHeigth } + }
+
+ transitions: Transition {
+ NumberAnimation { property: "height"; duration: 100; easing.type: \
Easing.InOutQuad } + }
+ }
+
+ Item {
+ id: historyBase
+ anchors.top: toolbar.bottom
+ anchors.left: parent.left
+ anchors.right: sidebar.left
+ anchors.bottom: editor.top
+ visible: !settings.compactMode
+
+ ListView {
+ id: history
+ anchors.fill: parent
+ currentIndex: count -1
+ clip: true
+
+ property int minTagSize: 0
+
+ model: resultModel
+ delegate: ResultViewItem {
+ currentHistoryIndex: history.currentIndex
+ currentMinTagSize: history.minTagSize
+
+ onExpressionSelected: editor.text = expression
+ onResultSelected: editor.text += result
+ onTagSelected: editor.text += tag
+
+ Component.onCompleted: {
+ mainWindow.addVisibleHistoryItemIndex(model.index)
+ history.updateTagWidth()
+ }
+
+ Component.onDestruction: {
+ mainWindow.removeVisibleHistoryItemIndex(model.index)
+ history.updateTagWidth()
+ }
+ }
+
+ Text {
+ id: tagItemDummy
+ font.pixelSize: 12
+ font.italic: true
+ visible: false
+ }
+
+ function updateTagWidth() {
+ var i = 0
+ var itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
+ var minTagSize = 0
+
+ while(itemIndexNext > -1)
+ {
+ tagItemDummy.text = mainWindow.getTag(itemIndexNext)
+ if(minTagSize < tagItemDummy.width)
+ {
+ minTagSize = tagItemDummy.width
+ }
+ ++i
+ itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
+ }
+
+ tagItemDummy.text = ""
+ history.minTagSize = minTagSize
+ }
+
+ Component.onCompleted: history.positionViewAtEnd()
+ }
+ }
+
+ MathSidebar {
+ id: sidebar
+ width: 200
+ tabBarHeight: sidebarTabBarHeight
+ anchors.top: parent.top
+ anchors.left: parent.right
+ anchors.bottom: parent.bottom
+
+ onNumeralSelected: editor.text += numeralName
+ onNumeralRemoved: mainWindow.removeNumeral(numeralName)
+
+ onFunctionSelected: editor.text += functionName
+ onFunctionRemoved: mainWindow.removeFunction(functionName)
+
+ onRejectFocus: editor.focus = true
+ }
+
+ Editor {
+ id: editor
+ height: editorHeight
+ anchors.left: parent.left
+ anchors.right: sidebar.left
+ anchors.bottom: parent.bottom
+ focus: true
+ mainWindowObject: mainWindow
+ }
+
+ Component.onCompleted: editor.forceActiveFocus()
+}
diff --git a/qml-qt/MathExpressionItem.qml b/qml-qt/MathExpressionItem.qml
new file mode 100644
index 0000000..a7b94cd
--- /dev/null
+++ b/qml-qt/MathExpressionItem.qml
@@ -0,0 +1,98 @@
+import QtQuick 1.1
+
+Item {
+ id: root
+ width: parent.width
+ height: 20
+
+ //imagePath: "widgets/listitem"
+ //prefix: itemHovered ? "pressed" : "normal"
+
+ signal selected()
+ signal removed()
+
+ property string nameString
+ property string valueString
+ property string typeString
+ property bool itemRemovable: typeString == "User Defined"
+ property bool itemHovered: false
+ property bool removeItemHovered: false
+
+ Item {
+ width: 50
+ height: parent.height
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.leftMargin: 3
+
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 12
+ clip: true
+ text: nameString
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: root.selected()
+ onDoubleClicked: console.log("TODO")
+ onEntered: root.itemHovered = true
+ onExited: root.itemHovered = false
+ }
+ }
+
+ Item {
+ width: parent.width - 50
+ height: parent.height
+ anchors.right: parent.right
+ anchors.top: parent.top
+
+ Item {
+ anchors.fill: parent
+
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 12
+ clip: true
+ text: valueString
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: root.selected()
+ onDoubleClicked: console.log("TODO")
+ onEntered: root.itemHovered = true
+ onExited: root.itemHovered = false
+ }
+ }
+
+ Item {
+ width: parent.height
+ height: parent.height
+ anchors.right: parent.right
+ visible: root.itemRemovable
+
+ /*imagePath: "widgets/listitem"
+ prefix: root.removeItemHovered ? "pressed" : ""
+
+ PlasmaCore.IconItem {
+ anchors.fill: parent
+ source: root.itemHovered || root.removeItemHovered ? "list-remove" : \
"" + }*/
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: root.itemRemovable
+ onEntered: root.removeItemHovered = true
+ onExited: root.removeItemHovered = false
+ onClicked: root.removed()
+ }
+ }
+ }
+}
diff --git a/qml-qt/MathSidebar.qml b/qml-qt/MathSidebar.qml
new file mode 100644
index 0000000..7fa635f
--- /dev/null
+++ b/qml-qt/MathSidebar.qml
@@ -0,0 +1,152 @@
+import QtQuick 1.1
+import abakus 1.0 as Abakus
+
+Item {
+ id: root
+
+ property alias tabBarHeight: sidebarTabBar.height
+
+ signal numeralSelected(string numeralName)
+ signal numeralRemoved(string numeralName)
+
+ signal functionSelected(string functionName)
+ signal functionRemoved(string functionName)
+
+ signal rejectFocus()
+
+ states: State {
+ name: "shown"
+ AnchorChanges { target: root; anchors.left: undefined; anchors.right: \
parent.right } + }
+
+ transitions: Transition {
+ AnchorAnimation { duration: 100; easing.type: Easing.InOutQuad }
+ }
+
+ Abakus.Settings {
+ id: settings
+
+ onCompactModeChanged: root.state = (mathematicalSidebarVisible && \
!compactMode) ? "shown" : "" +
+ onMathematicalSidebarWidthChanged: root.width = mathematicalSidebarWidth
+
+ onMathematicalSidebarVisibleChanged: root.state = \
(mathematicalSidebarVisible && !compactMode) ? "shown" : "" +
+ Component.onCompleted: {
+ root.width = mathematicalSidebarWidth
+ root.state = (mathematicalSidebarVisible && !compactMode) ? "shown" : ""
+ }
+ }
+
+ Item {
+ id: sidebarTabBar
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.leftMargin: 2
+
+ property bool tabBarLoaded: false
+
+ /*PlasmaComponents.TabButton { id: numeralsTabButton; tab: numeralsTab; \
text: i18n("Numerals"); property string tabString: "numerals" } + \
PlasmaComponents.TabButton { id: functionsTabButton; tab: functionsTab; text: \
i18n("Functions"); property string tabString: "functions" } +
+ onCurrentTabChanged: if(tabBarLoaded) settings.mathematicalSidebarActiveView \
= sidebarTabBar.currentTab.tabString +
+ Component.onCompleted: {
+ if(settings.mathematicalSidebarActiveView == "numerals")
+ {
+ sidebarTabBar.currentTab = numeralsTabButton
+ sidebarTabGroup.currentTab = numeralsTab
+ }
+ else
+ {
+ sidebarTabBar.currentTab = functionsTabButton
+ sidebarTabGroup.currentTab = functionsTab
+ }
+ tabBarLoaded = true
+ }*/
+ }
+
+ Column {
+ id: sidebarTabGroup
+ anchors.left: parent.left
+ anchors.top: sidebarTabBar.bottom
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.leftMargin: 2
+
+ /*PlasmaExtras.ScrollArea {
+ id: numeralsTab
+ anchors.fill: parent*/
+
+ ListView {
+ id: numerals
+ anchors.fill: parent
+ clip: true
+
+ model: numeralModel
+ delegate: MathExpressionItem {
+ nameString: model.name
+ valueString: model.valueString
+ typeString: model.typeString
+ onSelected: root.numeralSelected(model.name)
+ onRemoved: root.numeralRemoved(model.name)
+ onFocusChanged: root.rejectFocus()
+ }
+
+ section.property: "typeString"
+ section.criteria: ViewSection.FullString
+ section.delegate: Item {
+ width: parent.width
+ height: 20
+
+ //imagePath: "widgets/listitem"
+ //prefix: "section"
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 12
+ text: section
+ }
+ }
+
+ }
+
+ /*PlasmaExtras.ScrollArea {
+ id: functionsTab
+ anchors.fill: parent*/
+
+ ListView {
+ id: functions
+ anchors.fill: parent
+ clip: true
+
+ model: functionModel
+ delegate: MathExpressionItem {
+ nameString: model.name + "(" + model.variable + ")"
+ valueString: model.value
+ typeString: model.typeString
+ onSelected: root.functionSelected(model.name)
+ onRemoved: root.functionRemoved(model.name)
+ onFocusChanged: root.rejectFocus()
+ }
+
+ section.property: "typeString"
+ section.criteria: ViewSection.FullString
+ section.delegate: Item {
+ width: parent.width
+ height: 20
+
+ //imagePath: "widgets/listitem"
+ //prefix: "section"
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 12
+ text: section
+ }
+ }
+ }
+
+ }
+}
diff --git a/qml-qt/ResultViewItem.qml b/qml-qt/ResultViewItem.qml
new file mode 100644
index 0000000..359fcb9
--- /dev/null
+++ b/qml-qt/ResultViewItem.qml
@@ -0,0 +1,86 @@
+import QtQuick 1.1
+
+Row {
+ id: root
+ width: parent.width
+ height: 20
+
+ property string rowBackground: model.index % 2 == 0 ? "white" : "whitesmoke"
+ property string highlightColor: "lightblue"
+
+ property int currentHistoryIndex: 0
+ property int currentMinTagSize: 0
+
+ signal expressionSelected(string expression)
+ signal resultSelected(string result)
+ signal tagSelected(string tag)
+
+ Rectangle {
+ id: expressionItem
+ width: parent.width - resultItem.width - tagItem.width
+ height: parent.height
+ color: model.index == currentHistoryIndex ? highlightColor : rowBackground
+
+ Text {
+ height: parent.height
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 12
+ color: "darkgrey"
+ clip: true
+ text: model.expression
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.expressionSelected(model.expression)
+ onDoubleClicked: console.log("TODO")
+ }
+ }
+ }
+
+ Rectangle {
+ id: resultItem
+ width: resultItemText.width
+ height: parent.height
+ color: model.index == currentHistoryIndex ? highlightColor : rowBackground
+
+ Text {
+ id: resultItemText
+ height: parent.height
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 12
+ clip: true
+ text: model.result
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.resultSelected(model.result)
+ onDoubleClicked: console.log("TODO")
+ }
+ }
+ }
+
+ Rectangle {
+ id: tagItem
+ width: model.tag == "" ? 0 : currentMinTagSize
+ height: parent.height
+ color: model.index == currentHistoryIndex ? highlightColor : rowBackground
+
+ Text {
+ height: parent.height
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 12
+ font.italic: true
+ color: "darkgrey"
+ text: model.tag
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.tagSelected(model.tag)
+ onDoubleClicked: {}//do nothing
+ }
+ }
+ }
+}
diff --git a/qml-qt/SidebarGrip.qml b/qml-qt/SidebarGrip.qml
new file mode 100644
index 0000000..8086d05
--- /dev/null
+++ b/qml-qt/SidebarGrip.qml
@@ -0,0 +1,109 @@
+import QtQuick 1.1
+import abakus 1.0 as Abakus
+
+Item {
+ id: root
+
+ property bool itemHovered
+
+ signal showToolTip(int xPosition, int yPosition, string toolTipText)
+ signal hideToolTip()
+
+ QtObject {
+ id: internal
+
+ property bool sidebarShown: settings.mathematicalSidebarVisible && \
!settings.compactMode + property int latestSidebarWidth
+ property int xPositionOnChangeStart
+ property bool sidebarWidthChanged: false
+ }
+
+ Abakus.Settings {
+ id: settings
+ }
+
+ Item {
+ width: parent.width + 5
+ height: parent.height
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+
+ //imagePath: "widgets/listitem"
+ //prefix: itemHovered ? "pressed" : ""
+ }
+
+ Item {
+ id: sign
+ width: parent.width < parent.height ? parent.width : parent.height
+ height: width
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ //svg: PlasmaCore.Svg { imagePath: "widgets/arrows" }
+ //elementId: (settings.mathematicalSidebarVisible && !settings.compactMode) \
? "right-arrow" : "left-arrow" + }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ Timer {
+ interval: 1000
+ running: mouseArea.containsMouse && !mouseArea.pressed && tooltip.length
+
+ property string tooltip: internal.sidebarShown ? i18n("Click to hide \
sidebar\nClick and drag to change sidebar width") : i18n("Click to show sidebar") + \
+ onTriggered: {
+ var position = mapToItem(null, 0, height)
+ if(internal.sidebarShown)
+ {
+ root.showToolTip(position.x, position.y, tooltip)
+ }
+ else
+ {
+ root.showToolTip(position.x, position.y, tooltip)
+ }
+ }
+ }
+
+ onEntered: root.itemHovered = true
+ onExited: {
+ root.itemHovered = false
+ root.hideToolTip()
+ }
+
+ onClicked: if(!internal.sidebarWidthChanged) {
+ if(settings.compactMode)
+ {
+ settings.compactMode = false
+ settings.mathematicalSidebarVisible = true
+ }
+ else
+ {
+ settings.mathematicalSidebarVisible = \
!settings.mathematicalSidebarVisible + }
+
+ }
+
+ onPressed: {
+ if(mouse.button == Qt.LeftButton) {
+ internal.xPositionOnChangeStart = mapToItem(null, mouse.x, 0).x
+ internal.sidebarWidthChanged = false
+ }
+ }
+
+ onPositionChanged: {
+ if(internal.sidebarShown && (mouse.buttons & Qt.LeftButton)) {
+ var currentX = mapToItem(null, mouse.x, 0).x
+ if(internal.sidebarWidthChanged) {
+ settings.mathematicalSidebarWidth = internal.latestSidebarWidth \
+ (internal.xPositionOnChangeStart - currentX) + }
+ else if(Math.abs(internal.xPositionOnChangeStart - currentX) > 1) {
+ internal.latestSidebarWidth = settings.mathematicalSidebarWidth
+ internal.xPositionOnChangeStart = currentX
+ internal.sidebarWidthChanged = true
+ }
+ }
+ }
+ }
+}
diff --git a/qml-qt/TrigonometricMode.qml b/qml-qt/TrigonometricMode.qml
new file mode 100644
index 0000000..4816ba2
--- /dev/null
+++ b/qml-qt/TrigonometricMode.qml
@@ -0,0 +1,78 @@
+import QtQuick 1.1
+import abakus 1.0 as Abakus
+
+Item {
+ id: root
+
+ QtObject {
+ id: internal
+
+ property ContextMenu contextMenu
+ }
+
+ Abakus.Settings {
+ id: settings
+ }
+
+ Text {
+ id: degrees
+ visible: false
+ text: i18n("Degrees")
+ }
+
+ Text {
+ id: radians
+ visible: false
+ text: i18n("Radians")
+ }
+
+ Item {
+ id: trigModeFrame
+ width: (degrees.width > radians.width) ? degrees.width + 1.25 * height : \
radians.width + 1.25 * height + height: parent.height
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ //imagePath: "widgets/lineedit"
+ //prefix: "base"
+
+ Text {
+ id: trigModeText
+ anchors.fill: parent
+ anchors.leftMargin: 6
+ verticalAlignment: Text.AlignVCenter
+ text: settings.trigMode == Abakus.Settings.Degrees ? degrees.text: \
radians.text + }
+
+ Item { //ToolButton
+ width: height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.margins: 1
+ /*flat: true
+ iconSource: "arrow-down"
+
+ onClicked: {
+ if (!internal.contextMenu) {
+ internal.contextMenu = \
contextMenuComponent.createObject(trigModeFrame) + }
+ internal.contextMenu.open()
+ }*/
+ }
+ }
+
+ /*Component {
+ id: contextMenuComponent
+ PlasmaComponents.ContextMenu {
+ visualParent: trigModeFrame
+ PlasmaComponents.MenuItem {
+ text: degrees.text
+ onClicked: settings.trigMode = Abakus.Settings.Degrees
+ }
+ PlasmaComponents.MenuItem {
+ text: radians.text
+ onClicked: settings.trigMode = Abakus.Settings.Radians
+ }
+ }
+ }*/
+}
diff --git a/qml-qt/main.qml b/qml-qt/main.qml
new file mode 100644
index 0000000..a0734b7
--- /dev/null
+++ b/qml-qt/main.qml
@@ -0,0 +1,19 @@
+import QtQuick 1.1
+
+Item {
+
+ Loader {
+ id: displayLoader
+ anchors.fill: parent
+ }
+
+ Timer {
+ id: delayedLoadingTimer
+ interval: 25
+ running: false
+ repeat: false
+ onTriggered: displayLoader.source = "MainView.qml"
+ }
+
+ Component.onCompleted: delayedLoadingTimer.running = true
+}
diff --git a/src/function.cpp b/src/function.cpp
index 62edcd9..c1b8bdf 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -46,6 +46,4 @@ Abakus::Number evaluateFunction(const Function *func, const \
Abakus::Number value return (value.*(func->fn))();
}
-#include "function.moc"
-
// vim: set et sw=4 ts=8:
diff --git a/src/functionmodel.cpp b/src/functionmodel.cpp
index 91cc982..5aaef8b 100644
--- a/src/functionmodel.cpp
+++ b/src/functionmodel.cpp
@@ -21,7 +21,14 @@
#include "node.h"
#include "numerictypes.h"
-#include <KLocale>
+#include <QRegExp>
+#include <QStringList>
+
+#ifdef ABAKUS_QTONLY
+ #define i18n tr
+#else
+ #include <KLocale>
+#endif
// Used to try and avoid recursive function definitions
class DupFinder : public NodeFunctor
@@ -327,6 +334,4 @@ QStringList \
FunctionModel::functionList(FunctionModel::FunctionType type) return functions;
}
-#include "functionmodel.moc"
-
// vim: set et sw=4 ts=8:
diff --git a/src/functionmodelitem.cpp b/src/functionmodelitem.cpp
index bdbf508..90ee61c 100644
--- a/src/functionmodelitem.cpp
+++ b/src/functionmodelitem.cpp
@@ -20,7 +20,14 @@
#include "functionmodelitem.h"
#include "node.h"
-#include <KLocale>
+#include <QLocale>
+#include <QString>
+
+#ifdef ABAKUS_QTONLY
+ #define i18n /*TODO*/
+#else
+ #include <KLocale>
+#endif
FunctionModelItem::FunctionModelItem(Function* function, FunctionItemType type)
: m_type(type)
diff --git a/src/main.cpp b/src/main.cpp
index d76002d..456e643 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,10 +20,14 @@
#include "mainwindow.h"
-#include <KAboutData>
-#include <KApplication>
-#include <KCmdLineArgs>
-#include <KLocale>
+#ifdef ABAKUS_QTONLY
+ #include <QApplication>
+#else
+ #include <KAboutData>
+ #include <KApplication>
+ #include <KCmdLineArgs>
+ #include <KLocale>
+#endif
#include <mpfr.h>
@@ -31,6 +35,9 @@ const char *const version = "0.92";
int main(int argc, char **argv)
{
+#ifdef ABAKUS_QTONLY
+ QApplication app(argc, argv);
+#else
KAboutData *about = new KAboutData(
"abakus", // appName
"abakus", // i18n catalog
@@ -64,6 +71,8 @@ int main(int argc, char **argv)
KCmdLineArgs::init(argc, argv, about);
KApplication app;
+#endif
+
MainWindow *win = new MainWindow;
win->show();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index ec9ad63..7d4e96f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -28,16 +28,21 @@
#include <qdeclarative.h>
#include <QDeclarativeContext>
#include <QDeclarativeView>
+#include <QMenu>
#include <QToolTip>
-#include <KAction>
-#include <KActionCollection>
-#include <KCmdLineArgs>
-#include <kdeclarative.h>
-#include <KHelpMenu>
-#include <KMenu>
-#include <KShortcutsDialog>
-#include <KStandardDirs>
+#ifdef ABAKUS_QTONLY
+ #define i18n tr
+#else
+ #include <KAction>
+ #include <KActionCollection>
+ #include <KCmdLineArgs>
+ #include <kdeclarative.h>
+ #include <KHelpMenu>
+ #include <KMenu>
+ #include <KShortcutsDialog>
+ #include <KStandardDirs>
+#endif
MainWindow::MainWindow() :
m_helpMenu(0),
@@ -51,8 +56,10 @@ MainWindow::MainWindow() :
m_settingscore->loadSettings();
slotUpdateSize();
+#ifndef ABAKUS_QTONLY
setAutoSaveSettings();
-
+#endif
+
m_visibleHistoryItemIndices.clear();
connect(m_settingscore->instance(), SIGNAL(precisionChanged()), this, \
SLOT(slotRedrawResults())); @@ -75,6 +82,9 @@ MainWindow::MainWindow() :
m_declarativeView->setAttribute(Qt::WA_TranslucentBackground);
m_declarativeView->setWindowFlags(Qt::FramelessWindowHint);
+#ifdef ABAKUS_QTONLY
+ m_declarativeView->setSource(QUrl::fromLocalFile("qml/main.qml"));
+#else
// initialize kdeclarative
KDeclarative kDeclarative;
kDeclarative.setDeclarativeEngine(m_declarativeView->engine());
@@ -83,15 +93,18 @@ MainWindow::MainWindow() :
QString filePath = KStandardDirs::locate("appdata", "qml/main.qml");
m_declarativeView->setSource(QUrl::fromLocalFile(filePath));
+#endif
setCentralWidget(m_declarativeView);
m_declarativeView->setFocus();
+#ifdef ABAKUS_QTONLY
+ m_helpMenu = new QMenu();
+#else
KHelpMenu* helpMenu = new KHelpMenu(this, KCmdLineArgs::aboutData(), true);
m_helpMenu = helpMenu->menu();
-
-// m_dcopInterface = new AbakusIface();
+#endif
}
bool MainWindow::queryExit()
@@ -104,7 +117,11 @@ bool MainWindow::queryExit()
m_settingscore->setWindowSize(windowSize);
m_settingscore->saveSettings();
m_resultItemModel->clear();
- return KMainWindow::queryExit();
+#ifdef ABAKUS_QTONLY
+ return QMainWindow::close();
+#else
+ return KMainWindow::queryExit();
+#endif
}
void MainWindow::slotEvaluate(const QString &expression)
@@ -189,7 +206,9 @@ void MainWindow::showHelpMenu(int xPosition, int yPosition)
void MainWindow::configureShortcuts()
{
+#ifndef ABAKUS_QTONLY
KShortcutsDialog::configure(m_settingscore->actionCollection(), \
KShortcutsEditor::LetterShortcutsDisallowed); +#endif
}
void MainWindow::showToolTip(const int xPosition, const int yPosition, const \
QString& toolTipText) @@ -279,6 +298,7 @@ int MainWindow::getParenthesesLevel(const \
QString &str)
void MainWindow::setupShortcuts()
{
+#ifndef ABAKUS_QTONLY
KActionCollection* actionCollection = m_settingscore->actionCollection();
actionCollection->addAssociatedWidget(this);
@@ -309,6 +329,7 @@ void MainWindow::setupShortcuts()
a = actionCollection->addAction("select_edit", this, \
SIGNAL(setFocusToEditor())); a->setText(i18n("Select Editor"));
a->setShortcut(Qt::Key_F6);
+#endif
}
void MainWindow::slotToggleMathematicalSidebar()
@@ -333,7 +354,7 @@ QString MainWindow::interpolateExpression(const QString &text)
unsigned numPos = stackStr.mid(1).toUInt();
if(!m_resultItemModel->stackValue(numPos, value)) {
- m_resultItemModel->addMessage(str, i18n("Marker %1 is not set", \
stackStr)); + m_resultItemModel->addMessage(str, i18n("Marker %1 is not \
set").arg(stackStr)); return QString();
}
@@ -349,6 +370,4 @@ void MainWindow::slotRedrawResults()
NumeralModel::instance()->slotRedrawItems();
}
-#include "mainwindow.moc"
-
// vim: set et ts=8 sw=4:
diff --git a/src/mainwindow.h b/src/mainwindow.h
index e58b88a..21799a4 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -23,7 +23,12 @@
#include "numerictypes.h"
#include "settingscore.h"
-#include <KMainWindow>
+#ifdef ABAKUS_QTONLY
+ #include <QMainWindow>
+ #define KMainWindow QMainWindow
+#else
+ #include <KMainWindow>
+#endif
class ResultModel;
@@ -31,7 +36,7 @@ class QDeclarativeContext;
class QDeclarativeView;
class QMenu;
-// Main window class, handles events and layout and stuff
+// Main window class, handles events and stuff
class MainWindow : public KMainWindow
{
Q_OBJECT
diff --git a/src/numeralmodel.cpp b/src/numeralmodel.cpp
index 15f0043..22b1336 100644
--- a/src/numeralmodel.cpp
+++ b/src/numeralmodel.cpp
@@ -19,7 +19,13 @@
#include "numeralmodel.h"
-#include <KLocale>
+#include <QStringList>
+
+#ifdef ABAKUS_QTONLY
+ #define i18n tr
+#else
+ #include <KLocale>
+#endif
NumeralModel *NumeralModel::m_manager = 0;
@@ -228,6 +234,4 @@ QString NumeralModel::description(const QString &name)
return QString();
}
-#include "numeralmodel.moc"
-
// vim: set et ts=8 sw=4 encoding=utf-8:
diff --git a/src/numeralmodelitem.cpp b/src/numeralmodelitem.cpp
index 6d73eae..a8a1813 100644
--- a/src/numeralmodelitem.cpp
+++ b/src/numeralmodelitem.cpp
@@ -19,7 +19,14 @@
#include "numeralmodelitem.h"
-#include <KLocale>
+#include <QLocale>
+#include <QString>
+
+#ifdef ABAKUS_QTONLY
+ #define i18n /*TODO*/
+#else
+ #include <KLocale>
+#endif
NumeralModelItem::NumeralModelItem(const QString &name, const Abakus::Number &value, \
NumeralItemType type, const QString &description)
: m_name(name), m_value(value), m_valueString(value.toString()), \
m_description(description), m_type(type)
diff --git a/src/numerictypes.cpp b/src/numerictypes.cpp
index 1e0b660..696c987 100644
--- a/src/numerictypes.cpp
+++ b/src/numerictypes.cpp
@@ -19,8 +19,12 @@
#include "numerictypes.h"
-#include <KLocale>
-#include <KGlobal>
+#ifdef ABAKUS_QTONLY
+ #include <QLocale>
+#else
+ #include <KLocale>
+ #include <KGlobal>
+#endif
#include <QRegExp>
@@ -37,7 +41,12 @@ QString convertToString(const mpfr_ptr& number, const \
Abakus::NumeralSystem base QRegExp zeroKiller ("0*$");
mp_exp_t exp;
int desiredPrecision = Abakus::m_prec;
+#ifdef ABAKUS_QTONLY
+ QLocale locale;
+ QString decimalSymbol = locale.decimalPoint();
+#else
QString decimalSymbol = KGlobal::locale()->decimalSymbol();
+#endif
if(desiredPrecision < 0)
desiredPrecision = 8;
diff --git a/src/parser.yy b/src/parser.yy
index e09d79e..b891086 100644
--- a/src/parser.yy
+++ b/src/parser.yy
@@ -27,8 +27,13 @@
#include "numeralmodel.h"
#include "result.h"
-#include <KLocale>
-#include <KGlobal>
+#ifdef ABAKUS_QTONLY
+ #define i18n QObject::tr
+ #include <QLocale>
+#else
+ #include <KLocale>
+ #include <KGlobal>
+#endif
extern char *yytext;
@@ -105,7 +110,7 @@ S: error '=' {
// Can't assign to a function.
S: FUNC '=' {
- QString s(i18n("You can't assign to function %1", QString($1->name())));
+ QString s(i18n("You can't assign to function %1").arg(QString($1->name())));
Result::setLastResult(s);
YYABORT;
@@ -121,14 +126,14 @@ ASSIGN: '(' { --gCheckIdents; } IDENT ')' '=' {
// since normally functions and variables with the same name can coexist, but
// I don't want to duplicate code all over the place.
S: SET DERIV {
- QString s(i18n("Function %1 is built-in and cannot be overridden.", \
QLatin1String("deriv"))); + QString s(i18n("Function %1 is built-in and cannot be \
overridden.").arg(QLatin1String("deriv"))); Result::setLastResult(s);
YYABORT;
}
S: DERIV '=' {
- QString s(i18n("Function %1 is built-in and cannot be overridden.", \
QLatin1String("deriv"))); + QString s(i18n("Function %1 is built-in and cannot be \
overridden.").arg(QLatin1String("deriv"))); Result::setLastResult(s);
YYABORT;
@@ -144,7 +149,7 @@ S: SET FUNC ASSIGN EXP {
FunctionModel *manager = FunctionModel::instance();
if(manager->isFunction(funcName) && !manager->isFunctionUserDefined(funcName)) {
- QString s(i18n("Function %1 is built-in and cannot be overridden.", \
funcName)); + QString s(i18n("Function %1 is built-in and cannot be \
overridden.").arg(funcName)); Result::setLastResult(s);
YYABORT;
@@ -153,7 +158,7 @@ S: SET FUNC ASSIGN EXP {
QByteArray fnName = funcName.toLatin1();
BaseFunction *newFn = new UserDefinedFunction(fnName.data(), $4);
if(!manager->addFunction(newFn, ident)) {
- QString s(i18n("Unable to define function %1 because it is recursive.", \
funcName)); + QString s(i18n("Unable to define function %1 because it is \
recursive.").arg(funcName)); Result::setLastResult(s);
YYABORT;
@@ -169,7 +174,7 @@ S: SET IDENT ASSIGN EXP {
++gCheckIdents;
if(NumeralModel::instance()->isValueSet($2->name())) {
- QString s(i18n("You can't assign to variable %1", QString($2->name())));
+ QString s(i18n("You can't assign to variable %1").arg(QString($2->name())));
Result::setLastResult(s);
YYABORT;
@@ -199,14 +204,14 @@ S: REMOVE FUNC '(' ')' {
// Can't remove an ident using remove-func syntax.
S: REMOVE IDENT '(' ')' {
// This is an error
- Result::setLastResult(Result(i18n("Function %1 is not defined.", \
QString($2->name())))); + Result::setLastResult(Result(i18n("Function %1 is not \
defined.").arg(QString($2->name())))); YYABORT;
}
// This happens when the user tries to remove a function that's not defined.
S: REMOVE IDENT '(' IDENT ')' {
// This is an error
- Result::setLastResult(Result(i18n("Function %1 is not defined.", \
QString($2->name())))); + Result::setLastResult(Result(i18n("Function %1 is not \
defined.").arg(QString($2->name())))); YYABORT;
}
@@ -222,9 +227,9 @@ S: REMOVE IDENT {
else {
QString s;
if(manager->isValueSet($2->name()))
- s = i18n("Can't remove predefined variable %1.", QString($2->name()));
+ s = i18n("Can't remove predefined variable \
%1.").arg(QString($2->name())); else
- s = i18n("Can't remove undefined variable %1.", QString($2->name()));
+ s = i18n("Can't remove undefined variable \
%1.").arg(QString($2->name()));
Result::setLastResult(s);
@@ -239,7 +244,7 @@ S: SET IDENT '=' EXP {
if($2->name() == "pi" && $4->value() == Abakus::Number("3.0"))
Result::setLastResult(i18n("This isn't Indiana, you can't just change \
pi")); else
- Result::setLastResult(i18n("%1 is a constant", QString($2->name())));
+ Result::setLastResult(i18n("%1 is a \
constant").arg(QString($2->name())));
YYABORT;
}
@@ -258,7 +263,7 @@ S: IDENT '=' EXP {
if($1->name() == "pi" && $3->value() == Abakus::Number("3.0"))
Result::setLastResult(i18n("This isn't Indiana, you can't just change \
pi")); else
- Result::setLastResult(i18n("%1 is a constant", QString($1->name())));
+ Result::setLastResult(i18n("%1 is a \
constant").arg(QString($1->name())));
YYABORT;
}
@@ -270,13 +275,13 @@ S: IDENT '=' EXP {
}
S: NUMBER '=' {
- Result::setLastResult(i18n("Can't assign to %1", $1->value().toString()));
+ Result::setLastResult(i18n("Can't assign to %1").arg($1->value().toString()));
YYABORT;
}
// Can't call this as a function.
TERM: IDENT '(' {
- Result::setLastResult(i18n("%1 isn't a function (or operator expected)", \
QString($1->name()))); + Result::setLastResult(i18n("%1 isn't a function (or \
operator expected)").arg(QString($1->name()))); YYABORT;
}
@@ -325,8 +330,12 @@ TERM: VALUE { $$ = $1; }
VALUE: NUMBER { $$ = $1; }
NUMBER: NUM {
- KLocale *locale = KGlobal::locale();
- QChar decimal = locale->decimalSymbol()[0];
+#ifdef ABAKUS_QTONLY
+ QLocale locale;
+ QChar decimal = locale.decimalPoint();
+#else
+ QChar decimal = KGlobal::locale()->decimalSymbol()[0];
+#endif
// Replace current decimal separator with US Decimal separator to be
// evil.
@@ -341,8 +350,12 @@ NUMBER: NUM {
}
NUMBER: NUMBIN {
- KLocale *locale = KGlobal::locale();
- QChar decimal = locale->decimalSymbol()[0];
+#ifdef ABAKUS_QTONLY
+ QLocale locale;
+ QChar decimal = locale.decimalPoint();
+#else
+ QChar decimal = KGlobal::locale()->decimalSymbol()[0];
+#endif
// Replace current decimal separator with US Decimal separator to be
// evil.
@@ -357,8 +370,12 @@ NUMBER: NUMBIN {
}
NUMBER: NUMOCT {
- KLocale *locale = KGlobal::locale();
- QChar decimal = locale->decimalSymbol()[0];
+#ifdef ABAKUS_QTONLY
+ QLocale locale;
+ QChar decimal = locale.decimalPoint();
+#else
+ QChar decimal = KGlobal::locale()->decimalSymbol()[0];
+#endif
// Replace current decimal separator with US Decimal separator to be
// evil.
@@ -376,8 +393,12 @@ NUMBER: NUMOCT {
}
NUMBER: NUMHEX {
- KLocale *locale = KGlobal::locale();
- QChar decimal = locale->decimalSymbol()[0];
+#ifdef ABAKUS_QTONLY
+ QLocale locale;
+ QChar decimal = locale.decimalPoint();
+#else
+ QChar decimal = KGlobal::locale()->decimalSymbol()[0];
+#endif
// Replace current decimal separator with US Decimal separator to be
// evil.
@@ -412,7 +433,7 @@ TERM: NUMBER '(' EXP ')' {
TERM: NUMBER IDENT {
if(gCheckIdents > 0 && !NumeralModel::instance()->isValueSet($2->name())) {
- Result::setLastResult(i18n("Unknown variable %1", QString($2->name())));
+ Result::setLastResult(i18n("Unknown variable %1").arg(QString($2->name())));
YYABORT;
}
@@ -423,7 +444,7 @@ VALUE: IDENT {
if(gCheckIdents <= 0 || NumeralModel::instance()->isValueSet($1->name()))
$$ = $1;
else {
- Result::setLastResult(i18n("Unknown variable %1", QString($1->name())));
+ Result::setLastResult(i18n("Unknown variable %1").arg(QString($1->name())));
YYABORT;
}
}
diff --git a/src/resultmodel.cpp b/src/resultmodel.cpp
index bd2be46..2fe093c 100644
--- a/src/resultmodel.cpp
+++ b/src/resultmodel.cpp
@@ -212,6 +212,4 @@ QList< ResultModelItem* > ResultModel::resultList()
return m_resultModelItems;
}
-#include "resultmodel.moc"
-
// vim: set et sw=4 ts=8:
diff --git a/src/settingscore.cpp b/src/settingscore.cpp
index 285f0db..0c932b6 100644
--- a/src/settingscore.cpp
+++ b/src/settingscore.cpp
@@ -26,10 +26,20 @@
#include "node.h"
#include "resultmodel.h"
-#include <KActionCollection>
-#include <KConfig>
-#include <KConfigGroup>
-#include <KGlobal>
+#ifdef ABAKUS_QTONLY
+ #include <QSettings>
+ class KActionCollection
+ {
+ public:
+ KActionCollection(QObject* parent = 0){};
+ ~KActionCollection(){};
+ };
+#else
+ #include <KActionCollection>
+ #include <KConfig>
+ #include <KConfigGroup>
+ #include <KGlobal>
+#endif
SettingsCore* SettingsCore::m_instance = 0;
@@ -60,6 +70,9 @@ SettingsCore::~SettingsCore()
void SettingsCore::loadSettings()
{
+#ifdef ABAKUS_QTONLY
+ //TODO
+#else
KConfigGroup config = KGlobal::config()->group("Settings");
QString mode = config.readEntry("Trigonometric mode", "Degrees");
@@ -150,10 +163,14 @@ void SettingsCore::loadSettings()
}
m_actionCollection->readSettings();
+#endif
}
void SettingsCore::saveSettings()
{
+#ifdef ABAKUS_QTONLY
+ //TODO
+#else
KConfigGroup config = KGlobal::config()->group("Settings");
config.writeEntry("Trigonometric mode",
@@ -265,6 +282,7 @@ void SettingsCore::saveSettings()
config.sync();
m_actionCollection->writeSettings();
+#endif
}
int SettingsCore::precision()
diff --git a/src/settingscore.h b/src/settingscore.h
index ef7e9e4..4cb64ba 100644
--- a/src/settingscore.h
+++ b/src/settingscore.h
@@ -73,7 +73,7 @@ signals:
private:
SettingsCore();
- ~SettingsCore();
+ virtual ~SettingsCore();
static SettingsCore* m_instance;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic