Import kalgebra_16.08.3.orig.tar.xz
authorMaximiliano Curia <maxy@debian.org>
Wed, 23 Nov 2016 19:54:48 +0000 (19:54 +0000)
committerMaximiliano Curia <maxy@debian.org>
Wed, 23 Nov 2016 19:54:48 +0000 (19:54 +0000)
[dgit import orig kalgebra_16.08.3.orig.tar.xz]

124 files changed:
CMakeLists.txt [new file with mode: 0644]
COPYING [new file with mode: 0644]
COPYING.DOC [new file with mode: 0644]
COPYING.LIB [new file with mode: 0644]
Mainpage.dox [new file with mode: 0644]
TODO [new file with mode: 0644]
calgebra/CMakeLists.txt [new file with mode: 0644]
calgebra/main.cpp [new file with mode: 0644]
calgebra/test_calgebra.py [new file with mode: 0644]
cmake/COPYING-CMAKE-SCRIPTS [new file with mode: 0644]
cmake/FindReadline.cmake [new file with mode: 0644]
config-kalgebra.h.cmake [new file with mode: 0644]
doc/CMakeLists.txt [new file with mode: 0644]
doc/commands.docbook [new file with mode: 0644]
doc/index.docbook [new file with mode: 0644]
doc/kalgebra-2dgraph-window.png [new file with mode: 0644]
doc/kalgebra-3dgraph-window.png [new file with mode: 0644]
doc/kalgebra-console-window.png [new file with mode: 0644]
doc/kalgebra-dictionary-window.png [new file with mode: 0644]
doc/kalgebra-main-window.png [new file with mode: 0644]
doc/view-fullscreen.png [new file with mode: 0644]
icons/64-apps-kalgebra.png [new file with mode: 0644]
icons/CMakeLists.txt [new file with mode: 0644]
icons/sc-apps-kalgebra.svgz [new file with mode: 0644]
kalgebra.kdev4 [new file with mode: 0644]
mobile/CMakeLists.txt [new file with mode: 0644]
mobile/kalgebramobile.cpp [new file with mode: 0644]
mobile/kalgebramobile.desktop [new file with mode: 0644]
mobile/kalgebramobile.h [new file with mode: 0644]
mobile/kalgebramobileharmattan.desktop [new file with mode: 0644]
mobile/main.cpp [new file with mode: 0644]
mobile/plugins/About.qml [new file with mode: 0644]
mobile/plugins/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/Console.qml [new file with mode: 0644]
mobile/plugins/Dictionary.qml [new file with mode: 0644]
mobile/plugins/Plot2D.qml [new file with mode: 0644]
mobile/plugins/Plot3D.qml [new file with mode: 0644]
mobile/plugins/Tables.qml [new file with mode: 0644]
mobile/plugins/VariablesView.qml [new file with mode: 0644]
mobile/plugins/kalgebraabout.json [new file with mode: 0644]
mobile/plugins/kalgebraconsole.json [new file with mode: 0644]
mobile/plugins/kalgebradictionary.json [new file with mode: 0644]
mobile/plugins/kalgebraplot2d.json [new file with mode: 0644]
mobile/plugins/kalgebraplot3d.json [new file with mode: 0644]
mobile/plugins/kalgebratables.json [new file with mode: 0644]
mobile/plugins/kalgebravariables.json [new file with mode: 0644]
mobile/plugins/resources/kde-edu-logo.png [new file with mode: 0644]
mobile/plugins/widgets/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/widgets/kde/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/widgets/kde/ConsoleDelegate.qml [new file with mode: 0644]
mobile/plugins/widgets/kde/KAlgebraMobile.qml [new file with mode: 0644]
mobile/plugins/widgets/kde/KAlgebraPage.qml [new file with mode: 0644]
mobile/plugins/widgets/kde/Keyboard.qml [new file with mode: 0644]
mobile/plugins/widgets/kde/SimpleListView.qml [new file with mode: 0644]
mobile/plugins/widgets/material/AddButton.qml [new file with mode: 0644]
mobile/plugins/widgets/material/Button.qml [new file with mode: 0644]
mobile/plugins/widgets/material/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/widgets/material/CalcButton.qml [new file with mode: 0644]
mobile/plugins/widgets/material/ComboBox.qml [new file with mode: 0644]
mobile/plugins/widgets/material/Dialog.qml [new file with mode: 0644]
mobile/plugins/widgets/material/ExpressionInput.qml [new file with mode: 0644]
mobile/plugins/widgets/material/KAlgebraMobile.qml [new file with mode: 0644]
mobile/plugins/widgets/material/KAlgebraPage.qml [new file with mode: 0644]
mobile/plugins/widgets/material/Label.qml [new file with mode: 0644]
mobile/plugins/widgets/material/RealInput.qml [new file with mode: 0644]
mobile/plugins/widgets/material/SimpleListView.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/Button.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/widgets/neutral/CalcButton.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/ExpressionInput.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/KAlgebraMobile.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/KAlgebraPage.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/Label.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/RealInput.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/ScrollDecorator.qml [new file with mode: 0644]
mobile/plugins/widgets/neutral/SimpleListView.qml [new file with mode: 0644]
mobile/plugins/widgets/qmldir [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/AddButton.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/Button.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/CMakeLists.txt [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/CalcButton.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/ComboBox.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/Dialog.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/ExpressionInput.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/Label.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/RealInput.qml [new file with mode: 0644]
mobile/plugins/widgets/qtcontrols/SimpleListView.qml [new file with mode: 0644]
mobile/pluginsmodel.cpp [new file with mode: 0644]
mobile/pluginsmodel.h [new file with mode: 0644]
mobile/resources.qrc [new file with mode: 0644]
org.kde.kalgebra.appdata.xml [new file with mode: 0644]
plasmoids/CMakeLists.txt [new file with mode: 0644]
plasmoids/calculator/CMakeLists.txt [new file with mode: 0644]
plasmoids/calculator/Messages.sh [new file with mode: 0644]
plasmoids/calculator/kalgebraplasma.cpp [new file with mode: 0644]
plasmoids/calculator/kalgebraplasma.h [new file with mode: 0644]
plasmoids/calculator/kalgebraplasmoid.desktop [new file with mode: 0644]
plasmoids/graphsplasmoid/contents/ui/config.ui [new file with mode: 0644]
plasmoids/graphsplasmoid/contents/ui/main.qml [new file with mode: 0644]
plasmoids/graphsplasmoid/metadata.desktop [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/Messages.sh [new file with mode: 0755]
src/askname.h [new file with mode: 0644]
src/consolehtml.cpp [new file with mode: 0644]
src/consolehtml.h [new file with mode: 0644]
src/dictionary.cpp [new file with mode: 0644]
src/dictionary.h [new file with mode: 0644]
src/functionedit.cpp [new file with mode: 0644]
src/functionedit.h [new file with mode: 0644]
src/kalgebra.cpp [new file with mode: 0644]
src/kalgebra.h [new file with mode: 0644]
src/kalgebra.xml [new file with mode: 0644]
src/main.cpp [new file with mode: 0644]
src/org.kde.kalgebra.desktop [new file with mode: 0755]
src/varedit.cpp [new file with mode: 0644]
src/varedit.h [new file with mode: 0644]
src/variablesdelegate.cpp [new file with mode: 0644]
src/variablesdelegate.h [new file with mode: 0644]
src/viewportwidget.cpp [new file with mode: 0644]
src/viewportwidget.h [new file with mode: 0644]
utils/CMakeLists.txt [new file with mode: 0644]
utils/main.cpp [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e212d3a
--- /dev/null
@@ -0,0 +1,75 @@
+project(kalgebra)
+cmake_minimum_required(VERSION 2.8.11)
+
+find_package(ECM 1.7.0 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH})
+
+find_package(Qt5 5.2 REQUIRED NO_MODULE COMPONENTS Qml Quick Xml Svg OpenGL PrintSupport Test)
+include(KDEInstallDirs)
+include(KDECompilerSettings NO_POLICY_SCOPE)
+include(KDECMakeSettings)
+include(ECMInstallIcons)
+include(FeatureSummary)
+include(ECMAddAppIcon)
+
+find_package(Analitza5 REQUIRED)
+
+set(MOBILE_BACKEND "kde" CACHE STRING "Backend to install, currently. Check /mobile/plugins/widgets/*")
+
+include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
+
+find_package(OpenGL)
+set(HAVE_OPENGL ${OPENGL_FOUND})
+set_package_properties(OpenGL PROPERTIES TYPE OPTIONAL
+                                         PURPOSE "Support for 3D graphs in KAlgebra"
+                                         URL "http://opengl.org")
+
+set(CURSES_NEED_NCURSES TRUE)
+find_package(Curses)
+find_package(Readline)
+
+set_package_properties(Readline PROPERTIES TYPE OPTIONAL
+                                           PURPOSE "Allows KAlgebra to provide a console interface."
+                                           URL "http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html")
+set_package_properties(Curses PROPERTIES TYPE OPTIONAL
+                                         PURPOSE "Allows KAlgebra to provide a console interface."
+                                         URL "http://www.gnu.org/software/ncurses/")
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kalgebra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config-kalgebra.h)
+add_definitions (-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
+
+if(${MOBILE_BACKEND} STREQUAL "kde")
+    find_package(KF5I18n ${KF5_VERSION} REQUIRED)
+    find_package(KF5ConfigWidgets ${KF5_VERSION} REQUIRED)
+    find_package(KF5WidgetsAddons ${KF5_VERSION} REQUIRED)
+    find_package(KF5KIO REQUIRED)
+    find_package(Qt5WebKitWidgets REQUIRED)
+    find_package(KF5DocTools)
+
+    add_subdirectory(src)
+    add_subdirectory(plasmoids)
+endif()
+
+add_subdirectory(icons)
+add_subdirectory(mobile)
+
+if(READLINE_FOUND AND CURSES_FOUND)
+    add_subdirectory(calgebra)
+endif()
+
+if(KF5DocTools_FOUND)
+  add_subdirectory(utils)
+
+  add_custom_target(commandsdoc
+    ${CMAKE_CURRENT_BINARY_DIR}/utils/docbook_analitzacommands commands.docbook
+    DEPENDS docbook_analitzacommands
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc/
+    COMMENT "Generating commands docbook information"
+  )
+
+  add_subdirectory(doc)
+endif()
+install(FILES org.kde.kalgebra.appdata.xml DESTINATION ${KDE_INSTALL_DATAROOTDIR}/appdata/)
+
+feature_summary(WHAT ALL   FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d159169
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  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
+this service 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 make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  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.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+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
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the 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 a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE 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.
+
+                     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
+convey 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 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.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision 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, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This 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.
diff --git a/COPYING.DOC b/COPYING.DOC
new file mode 100644 (file)
index 0000000..4a0fe1c
--- /dev/null
@@ -0,0 +1,397 @@
+               GNU Free Documentation License
+                 Version 1.2, November 2002
+
+
+ Copyright (C) 2000,2001,2002  Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+0. PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document "free" in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of "copyleft", which means that derivative
+works of the document must themselves be free in the same sense.  It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does.  But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book.  We recommend this License
+principally for works whose purpose is instruction or reference.
+
+
+1. APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License.  Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein.  The "Document", below,
+refers to any such manual or work.  Any member of the public is a
+licensee, and is addressed as "you".  You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A "Modified Version" of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A "Secondary Section" is a named appendix or a front-matter section of
+the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall subject
+(or to related matters) and contains nothing that could fall directly
+within that overall subject.  (Thus, if the Document is in part a
+textbook of mathematics, a Secondary Section may not explain any
+mathematics.)  The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The "Invariant Sections" are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License.  If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant.  The Document may contain zero
+Invariant Sections.  If the Document does not identify any Invariant
+Sections then there are none.
+
+The "Cover Texts" are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License.  A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A "Transparent" copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters.  A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text.  A copy that is not "Transparent" is called "Opaque".
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, LaTeX input format, SGML
+or XML using a publicly available DTD, and standard-conforming simple
+HTML, PostScript or PDF designed for human modification.  Examples of
+transparent image formats include PNG, XCF and JPG.  Opaque formats
+include proprietary formats that can be read and edited only by
+proprietary word processors, SGML or XML for which the DTD and/or
+processing tools are not generally available, and the
+machine-generated HTML, PostScript or PDF produced by some word
+processors for output purposes only.
+
+The "Title Page" means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page.  For works in
+formats which do not have any title page as such, "Title Page" means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+A section "Entitled XYZ" means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language.  (Here XYZ stands for a
+specific section name mentioned below, such as "Acknowledgements",
+"Dedications", "Endorsements", or "History".)  To "Preserve the Title"
+of such a section when you modify the Document means that it remains a
+section "Entitled XYZ" according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document.  These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+
+2. VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no other
+conditions whatsoever to those of this License.  You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute.  However, you may accept
+compensation in exchange for copies.  If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+
+3. COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover.  Both covers must also clearly and legibly identify
+you as the publisher of these copies.  The front cover must present
+the full title with all words of the title equally prominent and
+visible.  You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to give
+them a chance to provide you with an updated version of the Document.
+
+
+4. MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it.  In addition, you must do these things in the Modified Version:
+
+A. Use in the Title Page (and on the covers, if any) a title distinct
+   from that of the Document, and from those of previous versions
+   (which should, if there were any, be listed in the History section
+   of the Document).  You may use the same title as a previous version
+   if the original publisher of that version gives permission.
+B. List on the Title Page, as authors, one or more persons or entities
+   responsible for authorship of the modifications in the Modified
+   Version, together with at least five of the principal authors of the
+   Document (all of its principal authors, if it has fewer than five),
+   unless they release you from this requirement.
+C. State on the Title page the name of the publisher of the
+   Modified Version, as the publisher.
+D. Preserve all the copyright notices of the Document.
+E. Add an appropriate copyright notice for your modifications
+   adjacent to the other copyright notices.
+F. Include, immediately after the copyright notices, a license notice
+   giving the public permission to use the Modified Version under the
+   terms of this License, in the form shown in the Addendum below.
+G. Preserve in that license notice the full lists of Invariant Sections
+   and required Cover Texts given in the Document's license notice.
+H. Include an unaltered copy of this License.
+I. Preserve the section Entitled "History", Preserve its Title, and add
+   to it an item stating at least the title, year, new authors, and
+   publisher of the Modified Version as given on the Title Page.  If
+   there is no section Entitled "History" in the Document, create one
+   stating the title, year, authors, and publisher of the Document as
+   given on its Title Page, then add an item describing the Modified
+   Version as stated in the previous sentence.
+J. Preserve the network location, if any, given in the Document for
+   public access to a Transparent copy of the Document, and likewise
+   the network locations given in the Document for previous versions
+   it was based on.  These may be placed in the "History" section.
+   You may omit a network location for a work that was published at
+   least four years before the Document itself, or if the original
+   publisher of the version it refers to gives permission.
+K. For any section Entitled "Acknowledgements" or "Dedications",
+   Preserve the Title of the section, and preserve in the section all
+   the substance and tone of each of the contributor acknowledgements
+   and/or dedications given therein.
+L. Preserve all the Invariant Sections of the Document,
+   unaltered in their text and in their titles.  Section numbers
+   or the equivalent are not considered part of the section titles.
+M. Delete any section Entitled "Endorsements".  Such a section
+   may not be included in the Modified Version.
+N. Do not retitle any existing section to be Entitled "Endorsements"
+   or to conflict in title with any Invariant Section.
+O. Preserve any Warranty Disclaimers.
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant.  To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled "Endorsements", provided it contains
+nothing but endorsements of your Modified Version by various
+parties--for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version.  Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity.  If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+
+5. COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy.  If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled "History"
+in the various original documents, forming one section Entitled
+"History"; likewise combine any sections Entitled "Acknowledgements",
+and any sections Entitled "Dedications".  You must delete all sections
+Entitled "Endorsements".
+
+
+6. COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other documents
+released under this License, and replace the individual copies of this
+License in the various documents with a single copy that is included in
+the collection, provided that you follow the rules of this License for
+verbatim copying of each of the documents in all other respects.
+
+You may extract a single document from such a collection, and distribute
+it individually under this License, provided you insert a copy of this
+License into the extracted document, and follow this License in all
+other respects regarding verbatim copying of that document.
+
+
+7. AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an "aggregate" if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+
+8. TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections.  You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers.  In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled "Acknowledgements",
+"Dedications", or "History", the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+
+9. TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document except
+as expressly provided for under this License.  Any other attempt to
+copy, modify, sublicense or distribute the Document is void, and will
+automatically terminate your rights under this License.  However,
+parties who have received copies, or rights, from you under this
+License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+
+10. FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions
+of the GNU Free Documentation 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.  See
+http://www.gnu.org/copyleft/.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License "or any later version" applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation.  If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation.
+
+
+ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+    Copyright (c)  YEAR  YOUR NAME.
+    Permission is granted to copy, distribute and/or modify this document
+    under the terms of the GNU Free Documentation License, Version 1.2
+    or any later version published by the Free Software Foundation;
+    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+    A copy of the license is included in the section entitled "GNU
+    Free Documentation License".
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the "with...Texts." line with this:
+
+    with the Invariant Sections being LIST THEIR TITLES, with the
+    Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
diff --git a/COPYING.LIB b/COPYING.LIB
new file mode 100644 (file)
index 0000000..5bc8fb2
--- /dev/null
@@ -0,0 +1,481 @@
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, 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
+this service 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 make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+\f
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+\f
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+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
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library 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 Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "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
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY 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
+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey 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 library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library 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 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/Mainpage.dox b/Mainpage.dox
new file mode 100644 (file)
index 0000000..0322cd8
--- /dev/null
@@ -0,0 +1,5 @@
+/** @mainpage KAlgebra
+
+Here you will find the API documentation both for KAlgebra's Analitza library and KAlgebra code.
+
+*/
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..1fa5c2c
--- /dev/null
+++ b/TODO
@@ -0,0 +1,17 @@
+
+Analitza:
+- Partial derivatives
+- Simplification for x^3*3/x-> 3*x^2
+
+Expression:
+- Copy on write for m_tree
+
+2D:
+- Shared functions Console <-> 2D
+- Sort 2D functions
+- Moving on small viewport step is too large.
+- Review keyBindings for zooming out.
+
+Doc:
+- Document about piecewise
+- Document about anything else
diff --git a/calgebra/CMakeLists.txt b/calgebra/CMakeLists.txt
new file mode 100644 (file)
index 0000000..29bb7f8
--- /dev/null
@@ -0,0 +1,19 @@
+include(CheckFunctionExists)
+include(CMakePushCheckState)
+
+include_directories(${READLINE_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
+
+# check if we have recent version of Readline
+cmake_push_check_state(RESET)
+set(CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARY} ${CURSES_LIBRARIES})
+check_function_exists(free_history_entry HAVE_FREE_HISTORY_ENTRY)
+cmake_pop_check_state()
+if(HAVE_FREE_HISTORY_ENTRY)
+    add_definitions(-DHAVE_FREE_HISTORY_ENTRY)
+endif()
+
+add_executable(calgebra main.cpp)
+target_link_libraries(calgebra Qt5::Core ${READLINE_LIBRARY} KF5::Analitza)
+
+install(TARGETS calgebra ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+
diff --git a/calgebra/main.cpp b/calgebra/main.cpp
new file mode 100644 (file)
index 0000000..3c5a4c9
--- /dev/null
@@ -0,0 +1,158 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include <analitza/expression.h>
+#include <analitza/analyzer.h>
+
+#include <readline/readline.h>
+#include <readline/history.h>
+#include <QTime>
+#include <QFile>
+
+using namespace std;
+
+using Analitza::Expression;
+
+Analitza::Analyzer a;
+
+enum CalcType { Evaluate, Calculate };
+
+static const char* prompt=">>> ";
+static const char* insidePrompt="... ";
+
+struct Config {
+    CalcType calcType;
+    bool showElapsedType;
+};
+static Config configuration;
+
+void calculate(const Expression& e, CalcType t)
+{
+    Expression ans;
+    a.setExpression(e);
+    if(e.isCorrect()) {
+        QTime time;
+        if(configuration.showElapsedType) time.start();
+        
+        if(t==Calculate)
+            ans=a.calculate();
+        else
+            ans=a.evaluate();
+        
+        if(configuration.showElapsedType) qDebug() << "Ellapsed time: " << time.elapsed();
+    }
+    
+    if(a.isCorrect()) {
+        qDebug() << qPrintable(ans.toString());
+        a.insertVariable(QStringLiteral("ans"), ans);
+    } else {
+        QStringList errors = a.errors();
+        qDebug() << "Error:";
+        foreach(const QString &err, errors)
+            qDebug() << " -" << qPrintable(err);
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    configuration.calcType=Evaluate;
+    configuration.showElapsedType=false;
+    bool hasImports = false;
+    
+    for(int i=1; i<argc; ++i) {
+        QByteArray arg=argv[i];
+        if(arg=="--print-time")
+            configuration.showElapsedType=true;
+        else if(arg=="--calculate")
+            configuration.calcType=Calculate;
+        else if(arg=="--evaluate")
+            configuration.calcType=Evaluate;
+        else if(arg=="--help" || arg=="-h") {
+            qDebug() << "This is KAlgebra console version";
+            qDebug() << "Use: " << argv[0] << "[Options] ...";
+            qDebug() << "\t--evaluate:\tTries to simplify symbolically before calculating";
+            qDebug() << "\t--calculate:\tCalculates straight away. If some symbol is missing, it will fail";
+            qDebug() << "\t--print-time:\tOutputs the ellapsed time of an operation";
+            qDebug() << "\t--help:\t\twill print this help";
+            qDebug() << "\t...\t\tfiles that will be executed first";
+            return 0;
+        } else {
+//             hasImports = true;
+            QFile f(arg);
+            if(!f.open(QIODevice::ReadOnly)) {
+                qWarning() << "File not found: " << arg;
+                return 1;
+            }
+            
+            QTextStream str(&f);
+            a.importScript(&str);
+            
+            if(!a.isCorrect()) {
+                QStringList errors = a.errors();
+                qDebug() << "Error:";
+                foreach(const QString &err, errors)
+                    qDebug() << " -" << qPrintable(err);
+            }
+        }
+    }
+    
+    bool done=false;
+    bool inside=false;
+    
+    using_history();
+    QString entry;
+    while(!done && !hasImports) {
+        char * expr;
+        if(inside)
+            expr=readline(insidePrompt);
+        else
+            expr=readline(prompt);
+        
+        if(!expr)
+            done=true;
+        else if(*expr==0) {
+            inside=false;
+            entry.clear();
+        } else {
+            add_history(expr);
+            entry+=QString::fromUtf8(expr);
+            
+            if(Expression::isCompleteExpression(entry)) {
+                Expression e(entry);
+//                 qDebug() << entry << e.toString();
+                calculate(e, configuration.calcType);
+                inside =false;
+                entry.clear();
+            } else {
+                inside =true;
+            }
+        }
+    }
+    
+    for(int i=0; i<history_get_history_state()->length; i++) {
+        HIST_ENTRY *he = remove_history(i);
+#ifdef HAVE_FREE_HISTORY_ENTRY
+        free_history_entry(he);
+#else
+        free((void*)he->line);
+        free(he);
+#endif
+    }
+    qDebug("\nExit.");
+    return 0;
+}
diff --git a/calgebra/test_calgebra.py b/calgebra/test_calgebra.py
new file mode 100644 (file)
index 0000000..1506785
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+import subprocess
+
+input="fib:=n->piecewise { eq(n,0)?0, eq(n,1)?1, ?fib(n-1)+fib(n-2) }\n"
+
+i=15
+for a in range(i,29):
+       input += "fib(%d)\n" % (a)
+p = subprocess.Popen(["calgebra", "--calculate", "--print-time"], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+output=p.communicate(input)
+for line in output[1].split('\n'):
+       theLine = line.split('time:')
+       if len(theLine)>1:
+               #print str(i)+", "+theLine[1]
+               print theLine[1]
+               i+=1
+
diff --git a/cmake/COPYING-CMAKE-SCRIPTS b/cmake/COPYING-CMAKE-SCRIPTS
new file mode 100644 (file)
index 0000000..4b41776
--- /dev/null
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products 
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake
new file mode 100644 (file)
index 0000000..844f0a1
--- /dev/null
@@ -0,0 +1,12 @@
+# GNU Readline library finder
+if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
+       set(READLINE_FOUND TRUE)
+else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
+       FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
+       
+       FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
+        include(FindPackageHandleStandardArgs)
+        FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY )
+       
+       MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY)
+endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
diff --git a/config-kalgebra.h.cmake b/config-kalgebra.h.cmake
new file mode 100644 (file)
index 0000000..d3f2b49
--- /dev/null
@@ -0,0 +1 @@
+#cmakedefine HAVE_OPENGL 1
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..67e1bd7
--- /dev/null
@@ -0,0 +1,4 @@
+########### install files ###############
+#
+
+kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kalgebra)
diff --git a/doc/commands.docbook b/doc/commands.docbook
new file mode 100644 (file)
index 0000000..4e05137
--- /dev/null
@@ -0,0 +1,429 @@
+<!-- this file is autogenerated, if any change has to be done, please fix kdeedu/kalgebra/utils/main.cpp and its dependencies. Thank you, Aleix Pol --><chapter id='commands'>
+<title>Commands supported by KAlgebra</title>
+       <sect1 id='plus'><title>plus</title><itemizedlist>
+               <listitem><para>Name: plus</para></listitem>
+               <listitem><para>Description: Addition</para></listitem>
+               <listitem><para>Parameters: plus(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;x+2</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='times'><title>times</title><itemizedlist>
+               <listitem><para>Name: times</para></listitem>
+               <listitem><para>Description: Multiplication</para></listitem>
+               <listitem><para>Parameters: times(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;x*2</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='minus'><title>minus</title><itemizedlist>
+               <listitem><para>Name: minus</para></listitem>
+               <listitem><para>Description: Subtraction. Will remove all values from the first one.</para></listitem>
+               <listitem><para>Parameters: minus(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;x-2</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='divide'><title>divide</title><itemizedlist>
+               <listitem><para>Name: divide</para></listitem>
+               <listitem><para>Description: Division</para></listitem>
+               <listitem><para>Parameters: divide(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;x/2</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='quotient'><title>quotient</title><itemizedlist>
+               <listitem><para>Name: quotient</para></listitem>
+               <listitem><para>Description: Quotient</para></listitem>
+               <listitem><para>Parameters: quotient(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;quotient(x, 2)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='power'><title>power</title><itemizedlist>
+               <listitem><para>Name: power</para></listitem>
+               <listitem><para>Description: Power</para></listitem>
+               <listitem><para>Parameters: power(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;x^2</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='root'><title>root</title><itemizedlist>
+               <listitem><para>Name: root</para></listitem>
+               <listitem><para>Description: Root</para></listitem>
+               <listitem><para>Parameters: root(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;root(x, 2)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='factorial'><title>factorial</title><itemizedlist>
+               <listitem><para>Name: factorial</para></listitem>
+               <listitem><para>Description: Factorial. factorial(n)=n!</para></listitem>
+               <listitem><para>Parameters: factorial(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;factorial(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='and'><title>and</title><itemizedlist>
+               <listitem><para>Name: and</para></listitem>
+               <listitem><para>Description: Boolean and</para></listitem>
+               <listitem><para>Parameters: and(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { and(x&gt;-2, x&lt;2) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='or'><title>or</title><itemizedlist>
+               <listitem><para>Name: or</para></listitem>
+               <listitem><para>Description: Boolean or</para></listitem>
+               <listitem><para>Parameters: or(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { or(x&gt;2, x&gt;-2) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='xor'><title>xor</title><itemizedlist>
+               <listitem><para>Name: xor</para></listitem>
+               <listitem><para>Description: Boolean xor</para></listitem>
+               <listitem><para>Parameters: xor(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { xor(x&gt;0, x&lt;3) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='not'><title>not</title><itemizedlist>
+               <listitem><para>Name: not</para></listitem>
+               <listitem><para>Description: Boolean not</para></listitem>
+               <listitem><para>Parameters: not(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { not(x&gt;0) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='gcd'><title>gcd</title><itemizedlist>
+               <listitem><para>Name: gcd</para></listitem>
+               <listitem><para>Description: Greatest common divisor</para></listitem>
+               <listitem><para>Parameters: gcd(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;gcd(x, 3)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='lcm'><title>lcm</title><itemizedlist>
+               <listitem><para>Name: lcm</para></listitem>
+               <listitem><para>Description: Least common multiple</para></listitem>
+               <listitem><para>Parameters: lcm(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;lcm(x, 4)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='rem'><title>rem</title><itemizedlist>
+               <listitem><para>Name: rem</para></listitem>
+               <listitem><para>Description: Remainder</para></listitem>
+               <listitem><para>Parameters: rem(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;rem(x, 5)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='factorof'><title>factorof</title><itemizedlist>
+               <listitem><para>Name: factorof</para></listitem>
+               <listitem><para>Description: The factor of</para></listitem>
+               <listitem><para>Parameters: factorof(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;factorof(x, 3)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='max'><title>max</title><itemizedlist>
+               <listitem><para>Name: max</para></listitem>
+               <listitem><para>Description: Maximum</para></listitem>
+               <listitem><para>Parameters: max(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;max(x, 4)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='min'><title>min</title><itemizedlist>
+               <listitem><para>Name: min</para></listitem>
+               <listitem><para>Description: Minimum</para></listitem>
+               <listitem><para>Parameters: min(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;min(x, 4)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='lt'><title>lt</title><itemizedlist>
+               <listitem><para>Name: lt</para></listitem>
+               <listitem><para>Description: Less than. lt(a,b)=a&lt;b</para></listitem>
+               <listitem><para>Parameters: lt(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x&lt;4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='gt'><title>gt</title><itemizedlist>
+               <listitem><para>Name: gt</para></listitem>
+               <listitem><para>Description: Greater than. gt(a,b)=a&gt;b</para></listitem>
+               <listitem><para>Parameters: gt(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x&gt;4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='eq'><title>eq</title><itemizedlist>
+               <listitem><para>Name: eq</para></listitem>
+               <listitem><para>Description: Equal. eq(a,b) = a=b</para></listitem>
+               <listitem><para>Parameters: eq(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x=4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='neq'><title>neq</title><itemizedlist>
+               <listitem><para>Name: neq</para></listitem>
+               <listitem><para>Description: Not equal. neq(a,b)=a≠b</para></listitem>
+               <listitem><para>Parameters: neq(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x!=4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='leq'><title>leq</title><itemizedlist>
+               <listitem><para>Name: leq</para></listitem>
+               <listitem><para>Description: Less or equal. leq(a,b)=a≤b</para></listitem>
+               <listitem><para>Parameters: leq(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x&lt;=4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='geq'><title>geq</title><itemizedlist>
+               <listitem><para>Name: geq</para></listitem>
+               <listitem><para>Description: Greater or equal. geq(a,b)=a≥b</para></listitem>
+               <listitem><para>Parameters: geq(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { x&gt;=4 ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='implies'><title>implies</title><itemizedlist>
+               <listitem><para>Name: implies</para></listitem>
+               <listitem><para>Description: Boolean implication</para></listitem>
+               <listitem><para>Parameters: implies(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { implies(x&lt;0, x&lt;3) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='approx'><title>approx</title><itemizedlist>
+               <listitem><para>Name: approx</para></listitem>
+               <listitem><para>Description: Approximation. approx(a)=a±n</para></listitem>
+               <listitem><para>Parameters: approx(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { approx(x, 4) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='abs'><title>abs</title><itemizedlist>
+               <listitem><para>Name: abs</para></listitem>
+               <listitem><para>Description: Absolute value. abs(n)=|n|</para></listitem>
+               <listitem><para>Parameters: abs(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;abs(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='floor'><title>floor</title><itemizedlist>
+               <listitem><para>Name: floor</para></listitem>
+               <listitem><para>Description: Floor value. floor(n)=⌊n⌋</para></listitem>
+               <listitem><para>Parameters: floor(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;floor(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='ceiling'><title>ceiling</title><itemizedlist>
+               <listitem><para>Name: ceiling</para></listitem>
+               <listitem><para>Description: Ceil value. ceil(n)=⌈n⌉</para></listitem>
+               <listitem><para>Parameters: ceiling(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;ceiling(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='sin'><title>sin</title><itemizedlist>
+               <listitem><para>Name: sin</para></listitem>
+               <listitem><para>Description: Function to calculate the sine of a given angle</para></listitem>
+               <listitem><para>Parameters: sin(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;sin(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='cos'><title>cos</title><itemizedlist>
+               <listitem><para>Name: cos</para></listitem>
+               <listitem><para>Description: Function to calculate the cosine of a given angle</para></listitem>
+               <listitem><para>Parameters: cos(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;cos(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='tan'><title>tan</title><itemizedlist>
+               <listitem><para>Name: tan</para></listitem>
+               <listitem><para>Description: Function to calculate the tangent of a given angle</para></listitem>
+               <listitem><para>Parameters: tan(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;tan(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='sec'><title>sec</title><itemizedlist>
+               <listitem><para>Name: sec</para></listitem>
+               <listitem><para>Description: Secant</para></listitem>
+               <listitem><para>Parameters: sec(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;sec(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='csc'><title>csc</title><itemizedlist>
+               <listitem><para>Name: csc</para></listitem>
+               <listitem><para>Description: Cosecant</para></listitem>
+               <listitem><para>Parameters: csc(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;csc(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='cot'><title>cot</title><itemizedlist>
+               <listitem><para>Name: cot</para></listitem>
+               <listitem><para>Description: Cotangent</para></listitem>
+               <listitem><para>Parameters: cot(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;cot(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='sinh'><title>sinh</title><itemizedlist>
+               <listitem><para>Name: sinh</para></listitem>
+               <listitem><para>Description: Hyperbolic sine</para></listitem>
+               <listitem><para>Parameters: sinh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;sinh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='cosh'><title>cosh</title><itemizedlist>
+               <listitem><para>Name: cosh</para></listitem>
+               <listitem><para>Description: Hyperbolic cosine</para></listitem>
+               <listitem><para>Parameters: cosh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;cosh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='tanh'><title>tanh</title><itemizedlist>
+               <listitem><para>Name: tanh</para></listitem>
+               <listitem><para>Description: Hyperbolic tangent</para></listitem>
+               <listitem><para>Parameters: tanh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;tanh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='sech'><title>sech</title><itemizedlist>
+               <listitem><para>Name: sech</para></listitem>
+               <listitem><para>Description: Hyperbolic secant</para></listitem>
+               <listitem><para>Parameters: sech(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;sech(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='csch'><title>csch</title><itemizedlist>
+               <listitem><para>Name: csch</para></listitem>
+               <listitem><para>Description: Hyperbolic cosecant</para></listitem>
+               <listitem><para>Parameters: csch(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;csch(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='coth'><title>coth</title><itemizedlist>
+               <listitem><para>Name: coth</para></listitem>
+               <listitem><para>Description: Hyperbolic cotangent</para></listitem>
+               <listitem><para>Parameters: coth(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;coth(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arcsin'><title>arcsin</title><itemizedlist>
+               <listitem><para>Name: arcsin</para></listitem>
+               <listitem><para>Description: Arc sine</para></listitem>
+               <listitem><para>Parameters: arcsin(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arcsin(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arccos'><title>arccos</title><itemizedlist>
+               <listitem><para>Name: arccos</para></listitem>
+               <listitem><para>Description: Arc cosine</para></listitem>
+               <listitem><para>Parameters: arccos(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arccos(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arctan'><title>arctan</title><itemizedlist>
+               <listitem><para>Name: arctan</para></listitem>
+               <listitem><para>Description: Arc tangent</para></listitem>
+               <listitem><para>Parameters: arctan(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arctan(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arccot'><title>arccot</title><itemizedlist>
+               <listitem><para>Name: arccot</para></listitem>
+               <listitem><para>Description: Arc cotangent</para></listitem>
+               <listitem><para>Parameters: arccot(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arccot(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arccosh'><title>arccosh</title><itemizedlist>
+               <listitem><para>Name: arccosh</para></listitem>
+               <listitem><para>Description: Hyperbolic arc cosine</para></listitem>
+               <listitem><para>Parameters: arccosh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arccosh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arccsc'><title>arccsc</title><itemizedlist>
+               <listitem><para>Name: arccsc</para></listitem>
+               <listitem><para>Description: Arc cosecant</para></listitem>
+               <listitem><para>Parameters: arccsc(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arccsc(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arccsch'><title>arccsch</title><itemizedlist>
+               <listitem><para>Name: arccsch</para></listitem>
+               <listitem><para>Description: Hyperbolic arc cosecant</para></listitem>
+               <listitem><para>Parameters: arccsch(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arccsch(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arcsec'><title>arcsec</title><itemizedlist>
+               <listitem><para>Name: arcsec</para></listitem>
+               <listitem><para>Description: Arc secant</para></listitem>
+               <listitem><para>Parameters: arcsec(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arcsec(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arcsech'><title>arcsech</title><itemizedlist>
+               <listitem><para>Name: arcsech</para></listitem>
+               <listitem><para>Description: Hyperbolic arc secant</para></listitem>
+               <listitem><para>Parameters: arcsech(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arcsech(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arcsinh'><title>arcsinh</title><itemizedlist>
+               <listitem><para>Name: arcsinh</para></listitem>
+               <listitem><para>Description: Hyperbolic arc sine</para></listitem>
+               <listitem><para>Parameters: arcsinh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arcsinh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arctanh'><title>arctanh</title><itemizedlist>
+               <listitem><para>Name: arctanh</para></listitem>
+               <listitem><para>Description: Hyperbolic arc tangent</para></listitem>
+               <listitem><para>Parameters: arctanh(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arctanh(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='exp'><title>exp</title><itemizedlist>
+               <listitem><para>Name: exp</para></listitem>
+               <listitem><para>Description: Exponent (e^x)</para></listitem>
+               <listitem><para>Parameters: exp(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;exp(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='ln'><title>ln</title><itemizedlist>
+               <listitem><para>Name: ln</para></listitem>
+               <listitem><para>Description: Base-e logarithm</para></listitem>
+               <listitem><para>Parameters: ln(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;ln(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='log'><title>log</title><itemizedlist>
+               <listitem><para>Name: log</para></listitem>
+               <listitem><para>Description: Base-10 logarithm</para></listitem>
+               <listitem><para>Parameters: log(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;log(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='conjugate'><title>conjugate</title><itemizedlist>
+               <listitem><para>Name: conjugate</para></listitem>
+               <listitem><para>Description: Conjugate</para></listitem>
+               <listitem><para>Parameters: conjugate(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;conjugate(x*i)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='arg'><title>arg</title><itemizedlist>
+               <listitem><para>Name: arg</para></listitem>
+               <listitem><para>Description: Arg</para></listitem>
+               <listitem><para>Parameters: arg(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;arg(x*i)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='real'><title>real</title><itemizedlist>
+               <listitem><para>Name: real</para></listitem>
+               <listitem><para>Description: Real</para></listitem>
+               <listitem><para>Parameters: real(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;real(x*i)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='imaginary'><title>imaginary</title><itemizedlist>
+               <listitem><para>Name: imaginary</para></listitem>
+               <listitem><para>Description: Imaginary</para></listitem>
+               <listitem><para>Parameters: imaginary(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;imaginary(x*i)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='sum'><title>sum</title><itemizedlist>
+               <listitem><para>Name: sum</para></listitem>
+               <listitem><para>Description: Summatory</para></listitem>
+               <listitem><para>Parameters: sum(par1 : var=from..to)</para></listitem>
+               <listitem><para>Example: x-&gt;x*sum(t*t:t=0..3)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='product'><title>product</title><itemizedlist>
+               <listitem><para>Name: product</para></listitem>
+               <listitem><para>Description: Productory</para></listitem>
+               <listitem><para>Parameters: product(par1 : var=from..to)</para></listitem>
+               <listitem><para>Example: x-&gt;product(t+t:t=1..3)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='diff'><title>diff</title><itemizedlist>
+               <listitem><para>Name: diff</para></listitem>
+               <listitem><para>Description: Differentiation</para></listitem>
+               <listitem><para>Parameters: diff(par1 : var)</para></listitem>
+               <listitem><para>Example: x-&gt;(diff(x^2:x))(x)</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='card'><title>card</title><itemizedlist>
+               <listitem><para>Name: card</para></listitem>
+               <listitem><para>Description: Cardinal</para></listitem>
+               <listitem><para>Parameters: card(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;card(vector { x, 1, 2 })</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='scalarproduct'><title>scalarproduct</title><itemizedlist>
+               <listitem><para>Name: scalarproduct</para></listitem>
+               <listitem><para>Description: Scalar product</para></listitem>
+               <listitem><para>Parameters: scalarproduct(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;scalarproduct(vector { 0, x }, vector { x, 0 })[1]</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='selector'><title>selector</title><itemizedlist>
+               <listitem><para>Name: selector</para></listitem>
+               <listitem><para>Description: Select the par1-th element of par2 list or vector</para></listitem>
+               <listitem><para>Parameters: selector(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;scalarproduct(vector { 0, x }, vector { x, 0 })[1]</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='union'><title>union</title><itemizedlist>
+               <listitem><para>Name: union</para></listitem>
+               <listitem><para>Description: Joins several items of the same type</para></listitem>
+               <listitem><para>Parameters: union(... parameters, ...)</para></listitem>
+               <listitem><para>Example: x-&gt;union(list { 1, 2, 3 }, list { 4, 5, 6 })[rem(floor(x), 5)+3]</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='forall'><title>forall</title><itemizedlist>
+               <listitem><para>Name: forall</para></listitem>
+               <listitem><para>Description: For all</para></listitem>
+               <listitem><para>Parameters: forall(par1 : var)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { forall(t:t@list { true, false, false }) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='exists'><title>exists</title><itemizedlist>
+               <listitem><para>Name: exists</para></listitem>
+               <listitem><para>Description: Exists</para></listitem>
+               <listitem><para>Parameters: exists(par1 : var)</para></listitem>
+               <listitem><para>Example: x-&gt;piecewise { exists(t:t@list { true, false, false }) ? 1, ? 0 }</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='map'><title>map</title><itemizedlist>
+               <listitem><para>Name: map</para></listitem>
+               <listitem><para>Description: Applies a function to every element in a list</para></listitem>
+               <listitem><para>Parameters: map(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;map(x-&gt;x+x, list { 1, 2, 3, 4, 5, 6 })[rem(floor(x), 5)+3]</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='filter'><title>filter</title><itemizedlist>
+               <listitem><para>Name: filter</para></listitem>
+               <listitem><para>Description: Removes all elements that don't fit a condition</para></listitem>
+               <listitem><para>Parameters: filter(par1, par2)</para></listitem>
+               <listitem><para>Example: x-&gt;filter(u-&gt;rem(u, 2)=0, list { 2, 4, 3, 4, 8, 6 })[rem(floor(x), 5)+3]</para></listitem>
+       </itemizedlist></sect1>
+       <sect1 id='transpose'><title>transpose</title><itemizedlist>
+               <listitem><para>Name: transpose</para></listitem>
+               <listitem><para>Description: Transpose</para></listitem>
+               <listitem><para>Parameters: transpose(par1)</para></listitem>
+               <listitem><para>Example: x-&gt;transpose(matrix { matrixrow { 1, 2, 3, 4, 5, 6 } })[rem(floor(x), 5)+3][1]</para></listitem>
+       </itemizedlist></sect1>
+</chapter>
diff --git a/doc/index.docbook b/doc/index.docbook
new file mode 100644 (file)
index 0000000..daa8418
--- /dev/null
@@ -0,0 +1,508 @@
+<?xml version="1.0" ?>
+<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
+  <!ENTITY kappname "&kalgebra;">
+  <!ENTITY commands SYSTEM "commands.docbook">
+
+  <!ENTITY % addindex "IGNORE">
+  <!ENTITY % English "INCLUDE">
+]>
+
+<book id="kalgebra" lang="&language;">
+
+<bookinfo>
+<title>The &kalgebra; Handbook</title>
+
+<authorgroup>
+<author>
+<firstname>Aleix</firstname>
+<surname>Pol</surname>
+<affiliation>
+<address>&Aleix.Pol.mail;</address>
+</affiliation>
+</author>
+<!-- TRANS:ROLES_OF_TRANSLATORS -->
+</authorgroup>
+
+<copyright>
+<year>2007</year>
+<holder>&Aleix.Pol;</holder>
+</copyright>
+
+<legalnotice>&FDLNotice;</legalnotice>
+
+
+<date>2016-04-19</date>
+<releaseinfo>0.10 (Applications 16.04)</releaseinfo>
+
+<abstract>
+<para>
+&kalgebra; is an application that can replace your graphing calculator.
+It has numerical, logical, symbolic, and analysis features that let you calculate
+mathematical expressions on the calculator and graphically plot the results
+in 2D or 3D. &kalgebra; is rooted in the Mathematical Markup Language
+(MathML); however, one does not need to know MathML to use &kalgebra;.
+</para>
+</abstract>
+
+<keywordset>
+<keyword>KDE</keyword>
+<keyword>kdeedu</keyword>
+<keyword>graph</keyword>
+<keyword>mathematics</keyword>
+<keyword>2D</keyword>
+<keyword>3D</keyword>
+<keyword>mathML</keyword>
+</keywordset>
+
+</bookinfo>
+
+<chapter id="introduction">
+<title>Introduction</title>
+
+<para>
+&kalgebra; has numerous features that allow the user to perform all sorts
+of mathematical operations and show graphically. At one time, this
+program was MathML oriented. Now it can be used by anyone with a little
+mathematical knowledge to solve simple and advanced problems alike.
+</para>
+<!--FIXME Ask Burkhard where to put tutorials and if it is worth efforts to do. Example from UB page: http://swiftscythe.blogspot.de/2011/02/how-to-work-with-complex-numbers-in.html-->
+<para>
+It includes such features as:
+</para>
+
+
+<itemizedlist>
+<listitem><para>
+A calculator for quick and easy evaluation of math
+functions.
+</para></listitem>
+<listitem><para>
+Scripting capability for advanced series of calculations
+</para></listitem>
+<listitem><para>
+Language capabilities including function definition and syntax autocompletion.
+</para></listitem>
+<listitem><para>
+Calculus functions including symbolic differentiation, vector calculus,
+and list manipulation.
+</para></listitem>
+<listitem><para>
+Function plotting with live cursor for graphical root finding and other
+types of analysis.
+</para></listitem>
+<listitem><para>
+3D plotting for useful visualization of 3D functions.
+</para></listitem>
+<listitem><para>
+A built-in operator dictionary for quick reference to the many available
+functions.
+</para></listitem>
+</itemizedlist>
+
+<para>
+Below is a screenshot of the &kalgebra; application in action:
+</para>
+
+<screenshot>
+<screeninfo>Here's a screenshot of &kalgebra; main window</screeninfo>
+       <mediaobject>
+         <imageobject>
+           <imagedata fileref="kalgebra-main-window.png" format="PNG"/>
+         </imageobject>
+           <textobject>
+           <phrase>&kalgebra; main window</phrase>
+         </textobject>
+       </mediaobject>
+</screenshot>
+
+<para>
+When the user begins a &kalgebra; session, they are presented with a
+single window consisting of a <guilabel>Calculator</guilabel> tab,
+a <guilabel>2D Graph</guilabel> tab,
+a <guilabel>3D Graph</guilabel> tab and a
+<guilabel>Dictionary</guilabel> tab. Within each tab, you will find an
+input field to enter your functions or calculations, and a display field
+which shows the results.
+</para>
+
+<para>At any time the user may manage their session with the main menu
+<guilabel>Session</guilabel> options:</para>
+
+<variablelist>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;
+<keycap>N</keycap></keycombo></shortcut>
+<guimenu>Session</guimenu><guimenuitem>New</guimenuitem>
+</menuchoice></term>
+<listitem><para>Opens a new &kalgebra; window.</para></listitem>
+</varlistentry>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;&Shift;
+<keycap>F</keycap></keycombo></shortcut>
+<guimenu>Session</guimenu><guimenuitem>Full Screen Mode</guimenuitem>
+</menuchoice></term>
+<listitem><para>Toogle full screen mode for &kalgebra; window. The full
+screen mode can also be switched on and off using  <inlinemediaobject>
+<imageobject> <imagedata fileref="view-fullscreen.png" format="PNG"/>
+</imageobject> </inlinemediaobject> button at the top right part of
+&kalgebra; window.</para></listitem>
+</varlistentry>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;
+<keycap>Q</keycap></keycombo></shortcut>
+<guimenu>Session</guimenu><guimenuitem>Quit</guimenuitem>
+</menuchoice></term>
+<listitem><para>Shuts the program down.</para></listitem>
+</varlistentry>
+
+</variablelist>
+
+</chapter>
+
+<chapter id="syntax">
+<title>Syntax</title>
+<para>
+&kalgebra; uses an intuitive algebraic syntax for entering user functions,
+similar to that used on most modern graphing calculators. This section
+lists the fundamental built-in operators available in &kalgebra;. The
+author of &kalgebra; modeled this syntax after
+<ulink url="http://maxima.sourceforge.net/">Maxima</ulink> and
+  <ulink url="http://www.maplesoft.com/products/maple/">maple</ulink> for users
+that may be familiar with these programs.
+</para>
+
+<para>
+For users that are interested in the inner workings of &kalgebra;, user
+entered expressions are converted to MathML on the backend. A rudimentary
+understanding of the capabilities supported by MathML will go a long way
+toward revealing the inner capabilities of &kalgebra;.
+</para>
+
+<para>Here is a list of the available operators we have by now:</para>
+<itemizedlist>
+<listitem><para>+ - * / : Addition, subtraction, multiplication and
+division.</para> </listitem>
+<listitem><para>^, **: Power, you can use them both. Also it is possible to use
+the unicode ² characters. Powers are one way to make roots too, you can do it
+like: a**(1/b)</para></listitem>
+<listitem><para>-&gt; : lambda. It is the way to specify one or more free
+variables that will be  bound in a function. For example, in the expression,
+<userinput>length:=(x,y)->(x*x+y*y)^0.5</userinput>, the lambda operator is used to denote
+that x and y will be bound when the length function is used.
+</para></listitem>
+<listitem><para>x=a..b : This is used when we need to delimit a range
+(bounded variable+uplimit+downlimit). This means that x goes from a to b.</para></listitem>
+<listitem><para>() : It is used to specify a higher priority.</para></listitem>
+<listitem><para>abc(params) : Functions. When the parser finds a function, it checks
+if abc is an operator. If it is, it will be treated as an operator, if it is
+not, it will be treated as a user function.</para></listitem>
+<listitem><para>:= : Definition. It is used to define a variable value. You can
+do things like x:=3, x:=y being y defined or not or perimeter:=r->2*pi*r.
+</para></listitem>
+<listitem><para>? : Piecewise condition definition. Piecewise is the way we can define
+conditional operations in &kalgebra;. Put another way, this is a way of
+specifying an if, elseif, else condition. If we introduce the condition before the '?' it will
+use this condition only if it is true, if it finds a '?' without any condition, it will
+enter in the last instance.
+Example: piecewise { x=0 ? 0, x=1 ? x+1, ? x**2 }
+</para></listitem>
+<listitem><para>{ } : MathML container. It can be used to define a container. Mainly
+useful for working with piecewise.
+</para></listitem>
+<listitem><para>= &gt; &gt;= &lt; &lt;= : Value comparators for equal,
+greater, greater or equal, less and less or equal respectively</para></listitem>
+</itemizedlist>
+
+<para>Now you could ask me, why should the user mind about MathML? That’s easy.
+With this, we can operate with functions like cos(), sin(), any other
+trigonometrical functions, sum() or product(). It does not matter what kind it is.
+We can use plus(), times() and everything which has its operator. Boolean
+functions are implemented as well, so we can do something like or(1,0,0,0,0).</para>
+
+</chapter>
+
+<chapter id="using-calculator">
+<title>Using the Calculator</title>
+<para>&kalgebra;'s calculator is useful as a calculator on steroids. The
+user may enter expressions for evaluation in <guimenu>Calculate</guimenu>
+or <guimenu>Evaluate</guimenu> mode, depending on the <guimenu>Calculator</guimenu>
+menu selection.
+</para>
+<para>
+In evaluation mode &kalgebra; simplifies the expression even if it sees an undefined variable.
+When in calculation mode &kalgebra;, calculates everything and if it finds an undefined
+variable shows an error.
+</para>
+<para>
+In addition to displaying the user entered equations and results in the
+Calculator display, all variables that are declared are displayed in a
+persistent frame to the right. By double clicking on a variable you will see a
+dialog that lets you change their values (just a way to trick the log).
+</para>
+
+<para>
+The "ans" variable is special, every time you enter an expression, the
+"ans" variable value will be changed to the last result.
+</para>
+
+<para>The following are example functions that can be entered in
+the input field of the calculator window:</para>
+<itemizedlist>
+<listitem><para>sin(pi)</para></listitem>
+<listitem><para>k:=33</para></listitem>
+<listitem><para>sum(k*x : x=0..10)</para></listitem>
+<listitem><para>f:=p->p*k</para></listitem>
+<listitem><para>f(pi)</para></listitem>
+</itemizedlist>
+
+<para>
+The following shows a screenshot of the calculator window after entering
+the above example expressions:
+</para>
+<screenshot>
+<screeninfo>Screenshot of &kalgebra; calculator window with example expressions</screeninfo>
+       <mediaobject>
+         <imageobject>
+           <imagedata fileref="kalgebra-console-window.png" format="PNG"/>
+         </imageobject>
+           <textobject>
+           <phrase>&kalgebra; calculator window</phrase>
+         </textobject>
+       </mediaobject>
+</screenshot>
+
+
+<para>A user can control the execution of a series of calculations
+using the <guimenu>Calculator</guimenu> menu options:</para>
+
+<variablelist>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;
+<keycap>L</keycap></keycombo></shortcut>
+<guimenu>Calculator</guimenu><guimenuitem>Load Script</guimenuitem>
+</menuchoice></term>
+<listitem><para>Executes the instructions in a file sequentially.
+Useful if you want to define some libraries or resume some previous work.</para></listitem>
+</varlistentry>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;
+<keycap>G</keycap></keycombo></shortcut>
+<guimenu>Calculator</guimenu><guimenuitem>Save Script</guimenuitem>
+</menuchoice></term>
+<listitem><para>Saves the instructions you have typed since the session began to be able to reuse. Generates text files so it should be easy to fix
+using any text editor, like Kate.</para></listitem>
+</varlistentry>
+
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;
+<keycap>S</keycap></keycombo></shortcut>
+<guimenu>Calculator</guimenu><guimenuitem>Export Log</guimenuitem>
+</menuchoice></term>
+<listitem><para>Saves the log with all results into an &HTML; file to be able to print or publish.</para></listitem>
+</varlistentry>
+
+</variablelist>
+
+</chapter>
+
+<chapter id="two-D-graphs">
+<title>2D Graphs</title>
+<para>To add a new 2D graph on &kalgebra;, select the <guilabel>2D
+Graph</guilabel> tab and click the <guilabel>Add</guilabel> tab to add
+a new function. Your focus will go to an input text box where you can
+type your function.</para>
+
+<sect1 id="two-D-syntax">
+<title>Syntax</title>
+<para>If you want to use a typical f(x) function it is not necessary to specify
+it, but if you want a f(y) or a polar function, you will have to add y-&gt; and q-&gt;
+as the bounded variables.</para>
+
+<para>Examples:</para>
+<itemizedlist>
+<listitem><para>sin(x)</para></listitem>
+<listitem><para>x²</para></listitem>
+<listitem><para>y->sin(y)</para></listitem>
+<listitem><para>q->3*sin(7*q)</para></listitem>
+<listitem><para>t->vector{sin t, t**2}</para></listitem>
+</itemizedlist>
+<para>If you have entered the function click on the <guibutton>OK</guibutton> button to display the graph in the main window.</para>
+
+</sect1>
+
+<sect1 id="two-D-features">
+<title>Features</title>
+<para>You can set several graphs on the same view. Just use the <guilabel>Add</guilabel> button when
+you are in List mode. You can set each graph its own color.</para>
+
+<para>The view can be zoomed and moved with the mouse. Using the wheel
+you can zoom in and out. You can also select an area with the left button
+of the mouse and this area will be zoomed in. Move the view with the arrow keys.</para>
+
+<note>
+ <para>The viewport of 2D graphs can be explicitly defined using the <guilabel>Viewport</guilabel> tab on a <guilabel>2D Graph</guilabel> tab.</para>
+</note>
+<para>In the <guilabel>List</guilabel> tab, you can open an <guilabel>Editing</guilabel> tab to edit or remove a function with double-click and check or uncheck the check box next to the function name to show or hide it.</para>
+<para>In the <guimenu>2D Graph</guimenu> menu you find these options:</para>
+<itemizedlist>
+<listitem><para>Show or hide the grid</para></listitem>
+<listitem><para>Keep the aspect ratio while zooming</para></listitem>
+<listitem><para>Zoom in (<keycombo action="simul">&Ctrl;
+<keycap>+</keycap></keycombo>) and zoom out (<keycombo action="simul">&Ctrl;
+<keycap>-</keycap></keycombo>)</para></listitem>
+<listitem><para>Save (<keycombo action="simul">&Ctrl;
+<keycap>S</keycap></keycombo>) the graph as image file</para></listitem>
+<listitem><para>Reset the view to the original zoom</para></listitem>
+<listitem><para>Select a resolution for the graphs</para></listitem>
+</itemizedlist>
+
+<para>
+   Below is a screenshot of a user who's cursor is at the rightmost root
+   of the function, sin(1/x). The user who graphed it used very fine
+   resolution to make this graph (as it oscillates at higher and higher
+   frequency near the origin). There is also a live cursor feature
+   where whenever you move your cursor over a spot, it shows you the x
+   and y values in the bottom left corner of the screen. A live "tangent
+   line" is plotted on the function at the live cursor location.
+ </para>
+
+<screenshot>
+<screeninfo>Here's a screenshot of &kalgebra; 2D graph window</screeninfo>
+       <mediaobject>
+         <imageobject>
+           <imagedata fileref="kalgebra-2dgraph-window.png" format="PNG"/>
+         </imageobject>
+           <textobject>
+           <phrase>&kalgebra; 2D graph window</phrase>
+         </textobject>
+       </mediaobject>
+</screenshot>
+
+
+</sect1>
+
+</chapter>
+
+<chapter id="three-D-graphs">
+<title>3D Graphs</title>
+
+<para>To draw a 3D Graph with &kalgebra; select the <guilabel>3D Graph</guilabel> tab
+and you will see an input field at the bottom where you will type your function.
+Z cannot be defined yet. For the moment &kalgebra; only supports
+3D graphs explicitly dependent only on the x and y, such as (x,y)->x*y,
+where z=x*y.
+</para>
+
+<para>Examples:</para>
+<itemizedlist>
+<listitem><para>(x,y)->sin(x)*sin(y)</para></listitem>
+<listitem><para>(x,y)->x/y</para></listitem>
+</itemizedlist>
+
+<para>The view can be zoomed and moved with the mouse. Using the wheel
+you can zoom in and out. Hold the &LMB; and move the mouse to rotate the graph.</para>
+
+ <para>The left and right arrow keys rotate the graph around the z axis, the up and down arrow keys rotate around the horizontal axis of the view. Press <keycap>W</keycap> to zoom in the plot and <keycap>S</keycap> to zoom it out.</para>
+
+<para>In the <guimenu>3D Graph</guimenu> menu you find these options:</para>
+<itemizedlist>
+<!-- not in master for 4.11
+<listitem><para>Enable or disable transparency in the 3D graph menu</para></listitem>
+-->
+<listitem><para>Save (<keycombo action="simul">&Ctrl;
+<keycap>S</keycap></keycombo>) the graph as image file</para></listitem>
+<listitem><para>Reset the view to the original zoom in the 3D graph menu</para></listitem>
+<listitem><para>You can draw the graphs with dots, lines or solid styles in the 3D graph menu</para></listitem>
+</itemizedlist>
+
+<para>
+Below is a screenshot of the so-called "sombrero" function. This particular
+graph is shown using the 3D graph line-style.
+</para>
+
+<screenshot>
+<screeninfo>Here's a screenshot of &kalgebra; 3D graph window</screeninfo>
+       <mediaobject>
+         <imageobject>
+           <imagedata fileref="kalgebra-3dgraph-window.png" format="PNG"/>
+         </imageobject>
+           <textobject>
+           <phrase>&kalgebra; 3D graph window</phrase>
+         </textobject>
+       </mediaobject>
+</screenshot>
+
+</chapter>
+
+<chapter id="dictionary">
+<title>Dictionary</title>
+
+<para>
+  The dictionary provides a list of all &kalgebra; built in functions. It can be
+used to find the definition of an operation and its input parameters. It's a useful
+place to go to find the many capabilities of &kalgebra;.
+</para>
+
+ <para>
+   Below is a screenshot of the &kalgebra; dictionary lookup of the cosine function.
+ </para>
+
+<screenshot>
+<screeninfo>Here's a screenshot of the &kalgebra; dictionary window</screeninfo>
+       <mediaobject>
+         <imageobject>
+           <imagedata fileref="kalgebra-dictionary-window.png" format="PNG"/>
+         </imageobject>
+           <textobject>
+           <phrase>&kalgebra; dictionary window</phrase>
+         </textobject>
+       </mediaobject>
+</screenshot>
+
+
+</chapter>
+
+&commands;
+
+<chapter id="credits">
+<title>Credits and License</title>
+
+<itemizedlist>
+<listitem><para>Program copyright 2005-2009 &Aleix.Pol;</para>
+</listitem>
+</itemizedlist>
+
+<para>
+Documentation copyright 2007 &Aleix.Pol; &Aleix.Pol.mail;
+</para>
+
+<!-- TRANS:CREDIT_FOR_TRANSLATORS -->
+&underFDL;               <!-- FDL: do not remove -->
+&underGPL;              <!-- GPL License -->
+
+</chapter>
+
+&documentation.index;
+</book>
+
+<!--
+Local Variables:
+mode: sgml
+sgml-minimize-attributes:nil
+sgml-general-insert-case:lower
+sgml-indent-step:0
+sgml-indent-data:nil
+End:
+-->
diff --git a/doc/kalgebra-2dgraph-window.png b/doc/kalgebra-2dgraph-window.png
new file mode 100644 (file)
index 0000000..2e49ea1
Binary files /dev/null and b/doc/kalgebra-2dgraph-window.png differ
diff --git a/doc/kalgebra-3dgraph-window.png b/doc/kalgebra-3dgraph-window.png
new file mode 100644 (file)
index 0000000..42dc467
Binary files /dev/null and b/doc/kalgebra-3dgraph-window.png differ
diff --git a/doc/kalgebra-console-window.png b/doc/kalgebra-console-window.png
new file mode 100644 (file)
index 0000000..3da8277
Binary files /dev/null and b/doc/kalgebra-console-window.png differ
diff --git a/doc/kalgebra-dictionary-window.png b/doc/kalgebra-dictionary-window.png
new file mode 100644 (file)
index 0000000..eebbb08
Binary files /dev/null and b/doc/kalgebra-dictionary-window.png differ
diff --git a/doc/kalgebra-main-window.png b/doc/kalgebra-main-window.png
new file mode 100644 (file)
index 0000000..d80812f
Binary files /dev/null and b/doc/kalgebra-main-window.png differ
diff --git a/doc/view-fullscreen.png b/doc/view-fullscreen.png
new file mode 100644 (file)
index 0000000..f004b1d
Binary files /dev/null and b/doc/view-fullscreen.png differ
diff --git a/icons/64-apps-kalgebra.png b/icons/64-apps-kalgebra.png
new file mode 100644 (file)
index 0000000..3a3c63e
Binary files /dev/null and b/icons/64-apps-kalgebra.png differ
diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c52832e
--- /dev/null
@@ -0,0 +1,5 @@
+ecm_install_icons(ICONS
+    64-apps-kalgebra.png
+    sc-apps-kalgebra.svgz
+DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor )
+
diff --git a/icons/sc-apps-kalgebra.svgz b/icons/sc-apps-kalgebra.svgz
new file mode 100644 (file)
index 0000000..1b04487
--- /dev/null
@@ -0,0 +1,335 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="48"
+   height="48"
+   id="svg5453"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="kalgebra.svg">
+  <defs
+     id="defs5455">
+    <linearGradient
+       id="linearGradient4273"
+       inkscape:collect="always">
+      <stop
+         id="stop4275"
+         offset="0"
+         style="stop-color:#e3dfd6;stop-opacity:1" />
+      <stop
+         id="stop4277"
+         offset="1"
+         style="stop-color:#f4f1e8;stop-opacity:1" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient4273"
+       id="linearGradient4572"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1.0000006,0,0,0.90000037,-5.0183803e-4,52.379595)"
+       x1="409.57144"
+       y1="543.79797"
+       x2="409.57144"
+       y2="503.798" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient4273-0"
+       id="linearGradient4158"
+       x1="409.57144"
+       y1="543.79797"
+       x2="409.57144"
+       y2="503.798"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1.1250015,0,0,1,-51.071996,5.2734375e-5)" />
+    <linearGradient
+       gradientTransform="translate(-3.3300782e-5,2.6031494e-5)"
+       inkscape:collect="always"
+       xlink:href="#linearGradient4159"
+       id="linearGradient4309"
+       x1="409.57144"
+       y1="542.79797"
+       x2="409.57144"
+       y2="504.798"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       id="linearGradient4273-0">
+      <stop
+         id="stop4275-7"
+         offset="0"
+         style="stop-color:#343b40;stop-opacity:1" />
+      <stop
+         id="stop4277-1"
+         offset="1"
+         style="stop-color:#555e63;stop-opacity:1" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient4159">
+      <stop
+         style="stop-color:#2a2c2f;stop-opacity:1"
+         offset="0"
+         id="stop4161" />
+      <stop
+         style="stop-color:#424649;stop-opacity:1"
+         offset="1"
+         id="stop4163" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6165"
+       id="linearGradient6171"
+       x1="413.57144"
+       y1="528.79797"
+       x2="418.57144"
+       y2="533.79797"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6165">
+      <stop
+         style="stop-color:#bdb49e;stop-opacity:0.25882354"
+         offset="0"
+         id="stop6167" />
+      <stop
+         style="stop-color:#bdb49e;stop-opacity:0;"
+         offset="1"
+         id="stop6169" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient4410"
+       id="linearGradient4299"
+       x1="414.57144"
+       y1="531.79797"
+       x2="426.57144"
+       y2="543.79797"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient4410">
+      <stop
+         style="stop-color:#383e51;stop-opacity:1"
+         offset="0"
+         id="stop4412" />
+      <stop
+         style="stop-color:#655c6f;stop-opacity:0"
+         offset="1"
+         id="stop4414" />
+    </linearGradient>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="7.2708333"
+     inkscape:cx="0.41260734"
+     inkscape:cy="24"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     fit-margin-top="0"
+     fit-margin-left="0"
+     fit-margin-right="0"
+     fit-margin-bottom="0"
+     inkscape:window-width="1024"
+     inkscape:window-height="532"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:showpageshadow="false"
+     borderlayer="true"
+     showguides="true"
+     inkscape:snap-global="true"
+     inkscape:snap-bbox="true">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4063"
+       empspacing="2"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="true"
+       spacingx="1px"
+       spacingy="1px" />
+    <sodipodi:guide
+       position="1.99999,4"
+       orientation="0,46"
+       id="guide4527" />
+    <sodipodi:guide
+       position="45.99999,6"
+       orientation="0,-44"
+       id="guide4547" />
+    <sodipodi:guide
+       position="17.000012,8.0000264"
+       orientation="0,13.999969"
+       id="guide4244" />
+    <sodipodi:guide
+       position="14.000012,34.000026"
+       orientation="20,0"
+       id="guide4249" />
+    <sodipodi:guide
+       position="14.000012,14.000026"
+       orientation="0,20"
+       id="guide4251" />
+    <sodipodi:guide
+       position="34.000012,14.000026"
+       orientation="-20,0"
+       id="guide4253" />
+    <sodipodi:guide
+       position="34.000012,34.000026"
+       orientation="0,-20"
+       id="guide4255" />
+    <sodipodi:guide
+       position="16,34"
+       orientation="1.986328,0"
+       id="guide4277" />
+    <sodipodi:guide
+       position="16,32.013672"
+       orientation="9.013672,5.205078"
+       id="guide4279" />
+    <sodipodi:guide
+       position="21.205078,23"
+       orientation="0,1.794922"
+       id="guide4281" />
+    <sodipodi:guide
+       position="23,23"
+       orientation="-0.890625,0"
+       id="guide4283" />
+    <sodipodi:guide
+       position="23,23.890625"
+       orientation="-10.109375,-5.835938"
+       id="guide4285" />
+    <sodipodi:guide
+       position="17.164062,34"
+       orientation="0,-1.164062"
+       id="guide4287" />
+    <sodipodi:guide
+       position="16,34"
+       orientation="0,0"
+       id="guide4289" />
+    <sodipodi:guide
+       position="16,14.1"
+       orientation="-1.98633,0"
+       id="guide4291" />
+    <sodipodi:guide
+       position="16,16.08633"
+       orientation="-9.01367,5.20508"
+       id="guide4293" />
+    <sodipodi:guide
+       position="21.20508,25.1"
+       orientation="0,1.79492"
+       id="guide4295" />
+    <sodipodi:guide
+       position="23,25.1"
+       orientation="0.89062,0"
+       id="guide4297" />
+    <sodipodi:guide
+       position="23,24.20938"
+       orientation="10.10938,-5.83594"
+       id="guide4299" />
+    <sodipodi:guide
+       position="17.16406,14.1"
+       orientation="0,-1.16406"
+       id="guide4301" />
+    <sodipodi:guide
+       position="16,14.1"
+       orientation="0,0"
+       id="guide4303" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5458">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Capa 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-384.57143,-499.798)">
+    <rect
+       style="opacity:1;fill:url(#linearGradient4158);fill-opacity:1.0;stroke:none"
+       id="rect4139-5"
+       width="35.999992"
+       height="39.999969"
+       x="390.57144"
+       y="503.798"
+       ry="0" />
+    <rect
+       style="opacity:0.5;fill:url(#linearGradient4309);fill-opacity:1.0;stroke:none"
+       id="rect4250"
+       width="34"
+       height="37.999996"
+       x="391.57144"
+       y="504.798" />
+    <rect
+       style="fill:url(#linearGradient4572);fill-opacity:1;stroke:none"
+       id="rect4139"
+       width="32"
+       height="36.000004"
+       x="392.57144"
+       y="505.79797"
+       ry="0" />
+    <rect
+       style="fill:#da4453;fill-opacity:1;stroke:none;opacity:0.4"
+       id="rect4915"
+       width="1"
+       height="36"
+       x="395.57144"
+       y="505.798" />
+    <rect
+       style="fill:#007ad9;fill-opacity:1;stroke:none;opacity:0.4"
+       id="rect4917"
+       width="32"
+       height="1"
+       x="392.57144"
+       y="508.798" />
+    <rect
+       style="opacity:1;fill:#1c1e20;fill-opacity:1;stroke:none"
+       id="rect4167"
+       width="35.999989"
+       height="1.0000263"
+       x="390.57144"
+       y="542.79797" />
+    <path
+       style="fill:#bdb49e;fill-opacity:1;stroke:none"
+       d="m 400.57134,513.79804 0,1.98633 0,0.0137 0.008,0 4.59179,7.94922 -4.59961,7.96484 0,0.0859 0,1.90039 0,0.0996 16,0 0,-0.0996 0,-1.90039 0,-2 -2,0 0,2 -11.73827,0 4.04101,-7 0.60547,-1.04883 0,-0.002 -0.60547,-1.04883 -3.98437,-6.90039 9.68164,0 0,1 2,0 0,-3 -12.83594,0 -1.16406,0 z"
+       id="rect4259"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#ebebeb;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       d="m 424.57143,530.798 -9,9 0,-9 z"
+       id="path4252"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccc" />
+    <path
+       style="opacity:0.2;fill:url(#linearGradient4299);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       d="m 415.57143,539.798 4,4 7,0 0,-10 0,-1 -2,-2 z"
+       id="path4281"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccccccc" />
+    <path
+       style="fill:url(#linearGradient6171);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       d="m 416.57143,531.798 0,7 7,-7 z"
+       id="path6163"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccc" />
+  </g>
+</svg>
diff --git a/kalgebra.kdev4 b/kalgebra.kdev4
new file mode 100644 (file)
index 0000000..ea6725c
--- /dev/null
@@ -0,0 +1,3 @@
+[Project]
+Manager=KDevCMakeManager
+Name=kalgebra
diff --git a/mobile/CMakeLists.txt b/mobile/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3629682
--- /dev/null
@@ -0,0 +1,32 @@
+add_subdirectory(plugins)
+
+if(KF5I18n_FOUND)
+    add_definitions(-DKDECOMPONENTS)
+endif()
+
+qt5_add_resources(KALGEBRAMOBILE_SRCS resources.qrc)
+add_executable(kalgebramobile pluginsmodel.cpp
+    kalgebramobile.cpp main.cpp ${KALGEBRAMOBILE_SRCS})
+
+target_link_libraries(kalgebramobile Qt5::Qml Qt5::Quick Qt5::Gui
+    KF5::Analitza KF5::AnalitzaGui KF5::AnalitzaPlot)
+
+set(DESKTOPFILE_INSTALL ${KDE_INSTALL_APPDIR})
+if(${MOBILE_BACKEND} STREQUAL "harmattan")
+    set(DESKTOPFILE_INSTALL ${KDE_INSTALL_APPDIR}/..)
+elseif(${MOBILE_BACKEND} STREQUAL "material")
+#   Material requires QtSvg for icons
+#   if we don't link it here explicitly, androiddeployqt doesn't bring it
+    find_package(Qt5Svg REQUIRED)
+    target_link_libraries(kalgebramobile Qt5::Svg)
+elseif(KF5I18n_FOUND)
+    target_link_libraries(kalgebramobile KF5::I18n)
+endif()
+
+set(DESKTOPFILE kalgebramobile.desktop)
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/kalgebramobile${MOBILE_BACKEND}.desktop)
+    set(DESKTOPFILE kalgebramobile${MOBILE_BACKEND}.desktop)
+endif()
+
+install(TARGETS kalgebramobile ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+install(PROGRAMS ${DESKTOPFILE} DESTINATION ${DESKTOPFILE_INSTALL} )
diff --git a/mobile/kalgebramobile.cpp b/mobile/kalgebramobile.cpp
new file mode 100644 (file)
index 0000000..5522d47
--- /dev/null
@@ -0,0 +1,83 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "kalgebramobile.h"
+
+#include <analitzaplot/plotsmodel.h>
+#include <analitza/variables.h>
+#include <analitza/expression.h>
+
+#include <qqml.h>
+#include "pluginsmodel.h"
+
+using namespace Analitza;
+
+KAlgebraMobile* KAlgebraMobile::s_self=0;
+KAlgebraMobile* KAlgebraMobile::self() { return s_self; }
+
+KAlgebraMobile::KAlgebraMobile(QObject* parent)
+    : QObject(parent), m_functionsModel(0), m_vars(new Analitza::Variables)
+{
+    Q_ASSERT(s_self==0);
+    s_self=this;
+    
+    qmlRegisterType<PluginsModel>("org.kde.kalgebra.mobile", 1, 0, "PluginsModel");
+    qmlRegisterType<QAbstractItemModel>();
+}
+
+PlotsModel* KAlgebraMobile::functionsModel()
+{
+    if(!m_functionsModel) {
+        m_functionsModel = new Analitza::PlotsModel(this);
+        connect(m_functionsModel, &QAbstractItemModel::rowsRemoved, this, &KAlgebraMobile::functionRemoved);
+        connect(m_functionsModel, &QAbstractItemModel::rowsInserted, this, &KAlgebraMobile::functionInserted);
+        connect(m_functionsModel, &QAbstractItemModel::dataChanged, this, &KAlgebraMobile::functionModified);
+    }
+    
+    return m_functionsModel;
+}
+
+void KAlgebraMobile::functionInserted(const QModelIndex& parent, int start, int end)
+{
+    Q_ASSERT(!parent.isValid());
+    for(int i=start; i<=end; i++) {
+        QModelIndex idx = functionsModel()->index(i, 1);
+        m_vars->modify(idx.sibling(i,0).data().toString(), Analitza::Expression(idx.data().toString()));
+    }
+}
+
+void KAlgebraMobile::functionRemoved(const QModelIndex& parent, int start, int end)
+{
+    Q_ASSERT(!parent.isValid());
+    for(int i=start; i<=end; i++) {
+        QModelIndex idx = functionsModel()->index(i);
+        m_vars->remove(functionsModel()->data(idx, Qt::DisplayRole).toString());
+    }
+}
+
+void KAlgebraMobile::functionModified(const QModelIndex& idxA, const QModelIndex& idxB)
+{
+    if(idxB.column()==1) {
+        for(int i=idxA.row(); i<idxB.row(); ++i) {
+            QModelIndex idx = functionsModel()->index(i, 1);
+            m_vars->modify(idx.sibling(i,0).data().toString(), Analitza::Expression(idx.data().toString()));
+        }
+    } //else TODO: figure out how to control a "rename"
+}
+
+Analitza::Variables* KAlgebraMobile::variables() const { return m_vars; }
diff --git a/mobile/kalgebramobile.desktop b/mobile/kalgebramobile.desktop
new file mode 100644 (file)
index 0000000..ce5cde2
--- /dev/null
@@ -0,0 +1,138 @@
+[Desktop Entry]
+Name=KAlgebra Mobile
+Name[ast]=KAlgebra Mobile
+Name[bg]=KAlgebra (мобилен)
+Name[bs]=KAlgebra Mobile
+Name[ca]=KAlgebra mòbil
+Name[ca@valencia]=KAlgebra mòbil
+Name[cs]=Mobilní KAlgebra
+Name[da]=KAlgebra Mobile
+Name[de]=KAlgebra Mobil
+Name[el]=KAlgebra Mobile
+Name[en_GB]=KAlgebra Mobile
+Name[es]=KAlgebra móvil
+Name[et]=KAlgebra mobiilis
+Name[eu]=KAlgebra mugikorra
+Name[fi]=KAlgebra mobiililaitteille
+Name[fr]=KAlgebra Mobile
+Name[ga]=KAlgebra Soghluaiste
+Name[gl]=KAlgebra Mobile
+Name[hu]=KAlgebra Mobile
+Name[it]=KAlgebra Mobile
+Name[ja]=KAlgebra モバイル
+Name[kk]=KAlgebra Mobile
+Name[km]=KAlgebra Mobile
+Name[ko]=KAlgebra 모바일
+Name[lt]=KAlgebra Mobile
+Name[lv]=KAlgebra Mobile
+Name[mr]=के-एल्जिब्रा मोबाईल
+Name[nb]=KAlgebra mobil
+Name[nds]=KAlgebra för Mobilreedschappen
+Name[nl]=KAlgebra-mobiel
+Name[pa]=ਕੇ-ਐਲਜਬਰਾ ਮੋਬਾਇਲ
+Name[pl]=Mobilna KAlgebra
+Name[pt]=KAlgebra Móvel
+Name[pt_BR]=KAlgebra Móvel
+Name[ru]=Мобильная KAlgebra
+Name[sk]=KAlgebra Mobile
+Name[sl]=KAlgebra Mobile
+Name[sv]=Kalgebra för mobil
+Name[te]=కె అల్జీబ్రా మొబైలు
+Name[tr]=KAlgebra Mobil
+Name[ug]=كۆچمە ئۈسكۈنىلەر ئۈچۈن KAlgebra
+Name[uk]=Мобільна KAlgebra
+Name[x-test]=xxKAlgebra Mobilexx
+Name[zh_CN]=KAlgebra 移动
+Name[zh_TW]=KAlgebra 行動版
+GenericName=Pocket Graph Calculator
+GenericName[ast]=Calculadora gráfica de bolsín
+GenericName[bg]=Джобен графичен калкулатор
+GenericName[bs]=Džepni graf kalkulator
+GenericName[ca]=Calculadora gràfica de butxaca
+GenericName[ca@valencia]=Calculadora gràfica de butxaca
+GenericName[cs]=Kapesní grafická kalkulačka
+GenericName[da]=Graflommeregner
+GenericName[de]=Graphen-Taschenrechner
+GenericName[el]=Φορητός γραφικός υπολογιστής
+GenericName[en_GB]=Pocket Graph Calculator
+GenericName[es]=Calculadora gráfica de bolsillo
+GenericName[et]=Graafikute arvutaja taskus
+GenericName[eu]=Sakeleko grafikoen kalkulagailua
+GenericName[fi]=Graafinen laskin mobiililaitteille
+GenericName[fr]=Calculatrice graphique de poche
+GenericName[ga]=Áireamhán Grafach Póca
+GenericName[gl]=Calculadora gráfica de peto
+GenericName[hu]=Zsebszámológép
+GenericName[it]=Calcolatrice grafica tascabile
+GenericName[ja]=ポケットグラフ計算機
+GenericName[kk]=Ықшам график калькуляторы
+GenericName[km]=ម៉ាស៊ីន​គិត​លេខ​ក្រាហ្វិក​ដែល​ដាក់​តាម​ខ្លួន​បាន
+GenericName[ko]=포켓 그래핑 계산기
+GenericName[lt]=Kišeninis grafinis skaičiuotuvas
+GenericName[lv]=Kabatas grafiskais kalkulators
+GenericName[mr]=पाकिट आलेख गणकयंत्र
+GenericName[nb]=Grafikk-lommekalkulator
+GenericName[nds]=Taschenreekner för Diagrammen
+GenericName[nl]=Zakrekenmachine met grafieken
+GenericName[pa]=ਪਾਕਟ ਗਰਾਫ਼ ਕੈਲਕੂਲੇਟਰ
+GenericName[pl]=Kieszonkowy kalkulator graficzny
+GenericName[pt]=Calculadora Gráfica Portátil
+GenericName[pt_BR]=Calculadora gráfica portátil
+GenericName[ru]=Карманный графический калькулятор
+GenericName[sk]=Vrecková grafická kalkulačka
+GenericName[sl]=Žepno računalo z grafi
+GenericName[sv]=Grafminiräknare
+GenericName[te]=జేబులొ పట్టే రేఖాచిత్రం గనన యంత్రము
+GenericName[tr]=Cep Grafik Hesap Makinesi
+GenericName[uk]=Кишеньковий графічний калькулятор
+GenericName[x-test]=xxPocket Graph Calculatorxx
+GenericName[zh_CN]=口袋图形计算器
+GenericName[zh_TW]=行動版圖形計算器
+Comment=Pocket Math Expression Solver and Plotter
+Comment[ast]=Iguador y trazador de bolsín d'espresiones matemátiques
+Comment[bg]=Джобен инструмент за решаване на математически задачи
+Comment[bs]=Matematski sistem za rješavanje i crtač
+Comment[ca]=Solucionador i representador gràfic de butxaca d'expressions matemàtiques
+Comment[ca@valencia]=Solucionador i representador gràfic de butxaca d'expressions matemàtiques
+Comment[cs]=Kapesní řešitel a souřadnicový zapisovač matematických výrazů
+Comment[da]=Lommeregner til at løse og plotte matematiske udtryk
+Comment[de]=Mathematischer Taschengleichungslöser und -zeichner
+Comment[el]=Φορητός σχεδιαστής και επιλυτής μαθηματικών εκφράσεων
+Comment[en_GB]=Pocket Maths Expression Solver and Plotter
+Comment[es]=Resuelve y dibuja expresiones matemáticas
+Comment[et]=Matemaatiliste avaldiste lahendaja ja joonistaja taskus
+Comment[eu]=Sakeleko matematika adierazpenen ebazlea edo marrazlea
+Comment[fi]=Matemaattisten yhtälöiden ratkaisut ja kuvaajat mobiililaitteille
+Comment[fr]=Traceur et résolveur de poche d'expressions mathématiques
+Comment[ga]=Réiteoir agus Breacaire Matamaiticiúil don Phóca
+Comment[gl]=Resolve e debuxa expresións matemáticas
+Comment[hu]=Zsebszámológép matematikai kifejezések megoldására, görberajzolásra
+Comment[it]=Risolutore e disegnatore tascabile di espressioni matematiche
+Comment[ja]=ポケット数式ソルバー&プロッタ
+Comment[kk]=Математикалық теңеуді шешіп графигін салу
+Comment[km]=ឧបករណ៍​គូស​ក្រាហ្វិក និង​កម្មវិធី​ដោះស្រាយ​កន្សោម​​​គណិត​ដែល​ដាក់​តាម​ខ្លួន​បាន​
+Comment[ko]=포켓 수식 계산기와 그래핑 도구
+Comment[lt]=Matematinių reiškinių sprendikas ir grafikų braižiklis
+Comment[lv]=Kabatas matemātisko izteiksmju risinātājs un attēlotājs
+Comment[nb]=Matematisk uttrykksløser og plotter i lomma
+Comment[nds]=Taschenreekner för't Lösen un Utdrucken vun Diagrammen
+Comment[nl]=Op zak oplossen en plotten van wiskundige uitdrukkingen
+Comment[pl]=Kieszonkowe rozwiązywanie równań i rysowanie wykresów
+Comment[pt]=Resolução e Desenho de Expressões Matemáticas Portátil
+Comment[pt_BR]=Solucionador e visualizador portátil de expressões matemáticas
+Comment[ru]=Карманное решение и построение графиков математических выражений
+Comment[sk]=Vreckový riešiteľ a zapisovač matematických výrazov
+Comment[sl]=Žepni reševalnik matematičnih enačb in risalnik grafov
+Comment[sv]=Lösning och uppritning av matematiska uttryck i fickformat
+Comment[tr]=Cep Matematiksel İfade Çözücü ve Çizici
+Comment[ug]=كۆچمە ئۈسكۈنىلەر ئۈچۈن ماتېماتىكىلىق ئىپادىلەرنى يېشىش ۋە سىزىش قورالى
+Comment[uk]=Кишеньковий розв’язувач математичних рівнянь та графопобудовник
+Comment[x-test]=xxPocket Math Expression Solver and Plotterxx
+Comment[zh_CN]=口袋数学式解决与绘图工具
+Comment[zh_TW]=行動版數學解題與繪圖
+Exec=kalgebramobile %u
+MimeType=application/x-kalgebra;
+Icon=kalgebra
+Type=Application
+Terminal=false
+Categories=Qt;KDE;Education;Math;Science;
diff --git a/mobile/kalgebramobile.h b/mobile/kalgebramobile.h
new file mode 100644 (file)
index 0000000..d3cc7dd
--- /dev/null
@@ -0,0 +1,59 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef KALGEBRAMOBILE_H
+#define KALGEBRAMOBILE_H
+
+#include <QObject>
+
+class QModelIndex;
+namespace Analitza {
+    class Variables;
+    class PlotsModel;
+}
+
+class KAlgebraMobile : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(Analitza::Variables* variables READ variables NOTIFY variablesChanged)
+    public:
+        explicit KAlgebraMobile(QObject* parent=0);
+        
+        static KAlgebraMobile* self();
+        void notifyVariablesChanged() { variablesChanged(); }
+        
+    public Q_SLOTS:
+        Analitza::PlotsModel* functionsModel();
+        Analitza::Variables* variables() const;
+        
+    private Q_SLOTS:
+        void functionRemoved(const QModelIndex& parent, int start, int end);
+        void functionModified(const QModelIndex& idxA, const QModelIndex& idxB);
+        void functionInserted(const QModelIndex& parent, int start, int end);
+        
+    Q_SIGNALS:
+        void variablesChanged();
+        
+    private:
+        static KAlgebraMobile* s_self;
+        
+        Analitza::PlotsModel* m_functionsModel;
+        Analitza::Variables* m_vars;
+};
+
+#endif // KALGEBRAMOBILE_H
diff --git a/mobile/kalgebramobileharmattan.desktop b/mobile/kalgebramobileharmattan.desktop
new file mode 100644 (file)
index 0000000..df29dbc
--- /dev/null
@@ -0,0 +1,151 @@
+[Desktop Entry]
+Name=KAlgebra
+Name[ast]=KAlgebra
+Name[bg]=KAlgebra
+Name[bs]=Kalgebra
+Name[ca]=KAlgebra
+Name[ca@valencia]=KAlgebra
+Name[cs]=KAlgebra
+Name[csb]=KAlgebra
+Name[da]=KAlgebra
+Name[de]=KAlgebra
+Name[el]=KAlgebra
+Name[en_GB]=KAlgebra
+Name[eo]=KAlgebra
+Name[es]=KAlgebra
+Name[et]=KAlgebra
+Name[eu]=KAlgebra
+Name[fi]=KAlgebra
+Name[fr]=KAlgebra
+Name[ga]=KAlgebra
+Name[gl]=KAlgebra
+Name[gu]=KAlgebra
+Name[he]=KAlgebra
+Name[hi]=के-अलजेब्रा
+Name[hne]=के-अलजेब्रा
+Name[hr]=KAlgebra
+Name[hu]=KAlgebra
+Name[is]=KAlgebra
+Name[it]=KAlgebra
+Name[ja]=KAlgebra
+Name[kk]=KAlgebra
+Name[km]=KAlgebra
+Name[ko]=KAlgebra
+Name[lt]=KAlgebra
+Name[lv]=KAlgebra
+Name[ml]=കെ-ആള്‍ജിബ്ര
+Name[mr]=के-एल्जिब्रा
+Name[nb]=KAlgebra
+Name[nds]=KAlgebra
+Name[ne]=केडीई बीजगणित
+Name[nl]=KAlgebra
+Name[nn]=KAlgebra
+Name[pa]=ਕੇ-ਐਲਜਬਰਾ
+Name[pl]=KAlgebra
+Name[pt]=KAlgebra
+Name[pt_BR]=KAlgebra
+Name[ro]=KAlgebra
+Name[ru]=KAlgebra
+Name[si]=KAlgebra
+Name[sk]=KAlgebra
+Name[sl]=KAlgebra
+Name[sv]=Kalgebra
+Name[te]=కె అల్జీబ్రా
+Name[tr]=KAlgebra
+Name[ug]=KAlgebra
+Name[uk]=KАлгебра
+Name[x-test]=xxKAlgebraxx
+Name[zh_CN]=KAlgebra
+Name[zh_TW]=數學_KAlgebra
+GenericName=Pocket Graph Calculator
+GenericName[ast]=Calculadora gráfica de bolsín
+GenericName[bg]=Джобен графичен калкулатор
+GenericName[bs]=Džepni graf kalkulator
+GenericName[ca]=Calculadora gràfica de butxaca
+GenericName[ca@valencia]=Calculadora gràfica de butxaca
+GenericName[cs]=Kapesní grafická kalkulačka
+GenericName[da]=Graflommeregner
+GenericName[de]=Graphen-Taschenrechner
+GenericName[el]=Φορητός γραφικός υπολογιστής
+GenericName[en_GB]=Pocket Graph Calculator
+GenericName[es]=Calculadora gráfica de bolsillo
+GenericName[et]=Graafikute arvutaja taskus
+GenericName[eu]=Sakeleko grafikoen kalkulagailua
+GenericName[fi]=Graafinen laskin mobiililaitteille
+GenericName[fr]=Calculatrice graphique de poche
+GenericName[ga]=Áireamhán Grafach Póca
+GenericName[gl]=Calculadora gráfica de peto
+GenericName[hu]=Zsebszámológép
+GenericName[it]=Calcolatrice grafica tascabile
+GenericName[ja]=ポケットグラフ計算機
+GenericName[kk]=Ықшам график калькуляторы
+GenericName[km]=ម៉ាស៊ីន​គិត​លេខ​ក្រាហ្វិក​ដែល​ដាក់​តាម​ខ្លួន​បាន
+GenericName[ko]=포켓 그래핑 계산기
+GenericName[lt]=Kišeninis grafinis skaičiuotuvas
+GenericName[lv]=Kabatas grafiskais kalkulators
+GenericName[mr]=पाकिट आलेख गणकयंत्र
+GenericName[nb]=Grafikk-lommekalkulator
+GenericName[nds]=Taschenreekner för Diagrammen
+GenericName[nl]=Zakrekenmachine met grafieken
+GenericName[pa]=ਪਾਕਟ ਗਰਾਫ਼ ਕੈਲਕੂਲੇਟਰ
+GenericName[pl]=Kieszonkowy kalkulator graficzny
+GenericName[pt]=Calculadora Gráfica Portátil
+GenericName[pt_BR]=Calculadora gráfica portátil
+GenericName[ru]=Карманный графический калькулятор
+GenericName[sk]=Vrecková grafická kalkulačka
+GenericName[sl]=Žepno računalo z grafi
+GenericName[sv]=Grafminiräknare
+GenericName[te]=జేబులొ పట్టే రేఖాచిత్రం గనన యంత్రము
+GenericName[tr]=Cep Grafik Hesap Makinesi
+GenericName[uk]=Кишеньковий графічний калькулятор
+GenericName[x-test]=xxPocket Graph Calculatorxx
+GenericName[zh_CN]=口袋图形计算器
+GenericName[zh_TW]=行動版圖形計算器
+Comment=Pocket Math Expression Solver and Plotter
+Comment[ast]=Iguador y trazador de bolsín d'espresiones matemátiques
+Comment[bg]=Джобен инструмент за решаване на математически задачи
+Comment[bs]=Matematski sistem za rješavanje i crtač
+Comment[ca]=Solucionador i representador gràfic de butxaca d'expressions matemàtiques
+Comment[ca@valencia]=Solucionador i representador gràfic de butxaca d'expressions matemàtiques
+Comment[cs]=Kapesní řešitel a souřadnicový zapisovač matematických výrazů
+Comment[da]=Lommeregner til at løse og plotte matematiske udtryk
+Comment[de]=Mathematischer Taschengleichungslöser und -zeichner
+Comment[el]=Φορητός σχεδιαστής και επιλυτής μαθηματικών εκφράσεων
+Comment[en_GB]=Pocket Maths Expression Solver and Plotter
+Comment[es]=Resuelve y dibuja expresiones matemáticas
+Comment[et]=Matemaatiliste avaldiste lahendaja ja joonistaja taskus
+Comment[eu]=Sakeleko matematika adierazpenen ebazlea edo marrazlea
+Comment[fi]=Matemaattisten yhtälöiden ratkaisut ja kuvaajat mobiililaitteille
+Comment[fr]=Traceur et résolveur de poche d'expressions mathématiques
+Comment[ga]=Réiteoir agus Breacaire Matamaiticiúil don Phóca
+Comment[gl]=Resolve e debuxa expresións matemáticas
+Comment[hu]=Zsebszámológép matematikai kifejezések megoldására, görberajzolásra
+Comment[it]=Risolutore e disegnatore tascabile di espressioni matematiche
+Comment[ja]=ポケット数式ソルバー&プロッタ
+Comment[kk]=Математикалық теңеуді шешіп графигін салу
+Comment[km]=ឧបករណ៍​គូស​ក្រាហ្វិក និង​កម្មវិធី​ដោះស្រាយ​កន្សោម​​​គណិត​ដែល​ដាក់​តាម​ខ្លួន​បាន​
+Comment[ko]=포켓 수식 계산기와 그래핑 도구
+Comment[lt]=Matematinių reiškinių sprendikas ir grafikų braižiklis
+Comment[lv]=Kabatas matemātisko izteiksmju risinātājs un attēlotājs
+Comment[nb]=Matematisk uttrykksløser og plotter i lomma
+Comment[nds]=Taschenreekner för't Lösen un Utdrucken vun Diagrammen
+Comment[nl]=Op zak oplossen en plotten van wiskundige uitdrukkingen
+Comment[pl]=Kieszonkowe rozwiązywanie równań i rysowanie wykresów
+Comment[pt]=Resolução e Desenho de Expressões Matemáticas Portátil
+Comment[pt_BR]=Solucionador e visualizador portátil de expressões matemáticas
+Comment[ru]=Карманное решение и построение графиков математических выражений
+Comment[sk]=Vreckový riešiteľ a zapisovač matematických výrazov
+Comment[sl]=Žepni reševalnik matematičnih enačb in risalnik grafov
+Comment[sv]=Lösning och uppritning av matematiska uttryck i fickformat
+Comment[tr]=Cep Matematiksel İfade Çözücü ve Çizici
+Comment[ug]=كۆچمە ئۈسكۈنىلەر ئۈچۈن ماتېماتىكىلىق ئىپادىلەرنى يېشىش ۋە سىزىش قورالى
+Comment[uk]=Кишеньковий розв’язувач математичних рівнянь та графопобудовник
+Comment[x-test]=xxPocket Math Expression Solver and Plotterxx
+Comment[zh_CN]=口袋数学式解决与绘图工具
+Comment[zh_TW]=行動版數學解題與繪圖
+Exec=/opt/kalgebra/bin/kalgebra_hack.sh
+MimeType=application/x-kalgebra;
+Icon=kalgebraharmattan
+Type=Application
+Terminal=false
+Categories=Qt;KDE;Education;Math;
diff --git a/mobile/main.cpp b/mobile/main.cpp
new file mode 100644 (file)
index 0000000..536eb67
--- /dev/null
@@ -0,0 +1,65 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include <QGuiApplication>
+
+#ifdef KDECOMPONENTS
+#include <KLocalizedContext>
+#endif
+
+#include <QDebug>
+#include <QFileInfo>
+#include <QDir>
+#include <QStandardPaths>
+#include <QQuickView>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlApplicationEngine>
+#include <QIcon>
+
+#include "kalgebramobile.h"
+#include "pluginsmodel.h"
+
+int main(int argc, char *argv[])
+{
+//     KAboutData about("kalgebra", 0, ki18n(("KAlgebra Mobile")), "0.10", ki18n("A portable calculator"),
+//              KAboutData::License_GPL, ki18n("(C) 2006-2010 Aleix Pol Gonzalez"));
+//     about.addAuthor( ki18n("Aleix Pol Gonzalez"), KLocalizedString(), "aleixpol@kde.org" );
+//     KCmdLineArgs::init(argc, argv, &about);
+    QGuiApplication app(argc, argv);
+    app.setApplicationName(QStringLiteral("kalgebramobile"));
+//     app.setWindowIcon(QIcon::fromTheme("kalgebra"));
+    
+    KAlgebraMobile widget;
+    
+    QString main = PluginsModel::pluginsDirectoryPath()+"/widgets/KAlgebraMobile.qml";
+
+    QDir dir = QFileInfo(main).dir();
+    dir.cdUp();
+
+    QQmlApplicationEngine engine;
+    engine.rootContext()->setContextProperty(QStringLiteral("app"), &widget);
+    engine.addImportPath(dir.path());
+
+#ifdef KDECOMPONENTS
+    engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
+#endif
+
+    engine.load(QUrl::fromLocalFile(main));
+    return app.exec();
+}
diff --git a/mobile/plugins/About.qml b/mobile/plugins/About.qml
new file mode 100644 (file)
index 0000000..840cedf
--- /dev/null
@@ -0,0 +1,72 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    id: page
+    ColumnLayout {
+        anchors.margins: 20*page.dp
+        anchors.fill: parent
+        spacing: 20*page.dp
+        
+        Image {
+            id: icon
+            source: "qrc:/kalgebra.svgz"
+            Layout.fillWidth: true
+            fillMode: Image.PreserveAspectFit
+
+            MouseArea {
+                anchors.fill: parent
+                onClicked: Qt.openUrlExternally("http://edu.kde.org/applications/mathematics/kalgebra")
+            }
+        }
+        
+        Label {
+            Layout.fillWidth: true
+            
+            wrapMode: Text.WordWrap
+            horizontalAlignment: Text.AlignJustify
+            text: ("KAlgebra is brought to you by the lovely community of <a href='http://kde.org'>KDE</a> "+
+                    "and <a href='http://edu.kde.org/'>KDE Edu</a> from a Free Software envionment.")
+            onLinkActivated: Qt.openUrlExternally(link)
+        }
+        
+        Label {
+            Layout.fillWidth: true
+            
+            wrapMode: Text.WordWrap
+            horizontalAlignment: Text.AlignJustify
+            text: ("In case you want to learn more about KAlgebra, you can find more information "+
+                    "<a href='http://edu.kde.org/applications/mathematics/kalgebra/'>in the official site</a> and in "+
+                    "the <a href='http://userbase.kde.org/KAlgebra'>users wiki</a>.<br/>"+
+                    "If you have any problem with your software, please report it to <a href='http://bugs.kde.org'>our bug tracker</a>.")
+            onLinkActivated: Qt.openUrlExternally(link)
+        }
+        
+        Label {
+            Layout.fillWidth: true
+            
+            wrapMode: Text.WordWrap
+            horizontalAlignment: Text.AlignJustify
+            text: "Aleix Pol Gonzalez &lt;<a href='mailto:aleixpol@kde.org'>aleixpol@kde.org</a>&gt;"
+            onLinkActivated: Qt.openUrlExternally(link)
+        }
+        
+        Image {
+            source: "qrc:/kde-edu-logo.png"
+            Layout.fillWidth: true
+            fillMode: Image.PreserveAspectFit
+            Layout.maximumHeight: icon.height
+            
+            MouseArea {
+                anchors.fill: parent
+                onClicked: Qt.openUrlExternally("http://edu.kde.org")
+            }
+        }
+        Item {
+            Layout.fillHeight: true
+        }
+    }
+}
diff --git a/mobile/plugins/CMakeLists.txt b/mobile/plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6b17ce8
--- /dev/null
@@ -0,0 +1,9 @@
+add_subdirectory(widgets)
+
+install( FILES
+    Console.qml Plot2D.qml Plot3D.qml Tables.qml Dictionary.qml
+    About.qml VariablesView.qml
+    kalgebraabout.json
+    kalgebraconsole.json kalgebraplot2d.json kalgebraplot3d.json kalgebratables.json kalgebravariables.json kalgebradictionary.json
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/
+)
diff --git a/mobile/plugins/Console.qml b/mobile/plugins/Console.qml
new file mode 100644 (file)
index 0000000..4e8e43b
--- /dev/null
@@ -0,0 +1,54 @@
+import QtQuick 2.0
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    id: page
+    ListModel { id: itemModel }
+    
+    ExpressionInput {
+        id: input
+        focus: true
+        
+        Analitza {
+            id: a
+            variables: app.variables
+        }
+        
+        Keys.onReturnPressed: {
+            var res = a.execute(text)
+            
+            var toadd = ""
+            if(!a.isCorrect)
+                toadd = "Error: " + (res ? res : a.errors)
+            else
+                toadd = text + " = " + res.expression
+            
+            itemModel.insert(0, { result: toadd, resultsInput: text })
+            input.selectAll()
+            view.currentIndex = 0
+        }
+        
+        anchors {
+            top: parent.top
+            left: parent.left
+            right: parent.right
+            margins: page.dp*6
+        }
+    }
+    
+    SimpleListView {
+        id: view
+        model: itemModel
+        role: "result"
+        title: "Results"
+        
+        anchors {
+            top: input.bottom
+            bottom: parent.bottom
+            left: parent.left
+            right: parent.right
+        }
+    }
+}
diff --git a/mobile/plugins/Dictionary.qml b/mobile/plugins/Dictionary.qml
new file mode 100644 (file)
index 0000000..28763d7
--- /dev/null
@@ -0,0 +1,71 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    id: page
+    anchors.margins: 0
+
+    function updateGraph() {
+        view.model.clear();
+        view.resetViewport();
+        view.addFunction(operators.data(operators.index(chosebox.currentIndex,3)), app.variables);
+    }
+    
+    ColumnLayout {
+        id: descriptioncol
+
+        anchors.fill: parent
+        spacing: 10
+
+        ComboBox {
+            id: chosebox
+            Layout.fillWidth: true
+            textRole: "display"
+
+            model: OperatorsModel {
+                id: operators
+            }
+
+            onCurrentIndexChanged: {
+                page.updateGraph();
+            }
+        }
+
+        GridLayout {
+            id: descgrid
+            columns: 2
+            Layout.fillWidth: true
+
+            Label { text: operators.headerData(0,Qt.Horizontal) }
+            Label { text: operators.data(operators.index(chosebox.currentIndex,0)) }
+            Label { text: operators.headerData(1,Qt.Horizontal) }
+            Label { text: operators.data(operators.index(chosebox.currentIndex,1)) }
+            Label { text: operators.headerData(2,Qt.Horizontal) }
+            Label { text: operators.data(operators.index(chosebox.currentIndex,2)) }
+            Label { text: operators.headerData(3,Qt.Horizontal) }
+            Label { text: operators.data(operators.index(chosebox.currentIndex,3)) }
+        }
+
+        Rectangle {
+            color: 'white'
+            Layout.fillWidth: true
+            Layout.fillHeight: true
+
+            Graph2D {
+                id: view
+                anchors {
+                    fill: parent
+                }
+                model: PlotsModel {
+                    id: plotsModel
+                }
+                Component.onCompleted: {
+                    page.updateGraph();
+                }
+            }
+        }
+    }
+}
diff --git a/mobile/plugins/Plot2D.qml b/mobile/plugins/Plot2D.qml
new file mode 100644 (file)
index 0000000..30ddd53
--- /dev/null
@@ -0,0 +1,74 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 1.0 as Controls
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    id: page
+    anchors.margins: 0
+    
+    Rectangle {
+        anchors.fill: parent
+        height: 200
+        color: 'white'
+
+        Graph2D {
+            id: view
+            anchors.fill: parent
+            model: app.functionsModel()
+
+            Dialog {
+                id: dialog
+                height: Math.min((4*view.height)/5, list.contentHeight)+page.dp*10
+
+                SimpleListView {
+                    id: list
+                    anchors {
+                        fill: parent
+                        margins: page.dp*4
+                    }
+                    role: "description"
+                    model: app.functionsModel()
+
+                    header: RowLayout {
+                        width: parent.width
+                        ExpressionInput {
+                            id: input
+                            Layout.fillWidth: true
+                            text: "sin x"
+                            focus: true
+                            Component.onCompleted: selectAll()
+                            onAccepted: {
+                                input.selectAll()
+                                view.addFunction(input.text, app.variables)
+                            }
+                        }
+                        Button {
+                            iconName: "list-add"
+                            onClicked: {
+                                input.selectAll()
+                                view.addFunction(input.text, app.variables)
+                            }
+                        }
+                    }
+
+                    footer: Button {
+                        text: "Clear All"
+                        onClicked: {
+                            app.functionsModel().clear();
+                            view.resetViewport();
+                        }
+                    }
+                }
+            }
+
+            AddButton {
+                onClicked: {
+                    dialog.open();
+                }
+            }
+        }
+    }
+}
diff --git a/mobile/plugins/Plot3D.qml b/mobile/plugins/Plot3D.qml
new file mode 100644 (file)
index 0000000..5aa07a5
--- /dev/null
@@ -0,0 +1,87 @@
+/*************************************************************************************
+ *  Copyright (C) 2015 by Aleix Pol <aleixpol@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 2.0
+import QtQuick.Layouts 1.1
+import org.kde.analitza 1.1
+import widgets 1.0
+
+KAlgebraPage
+{
+    id: page
+    Graph3D
+    {
+        id: view
+        anchors.fill: parent
+
+        Dialog {
+            id: dialog
+            height: Math.min((4*view.height)/5, list.contentHeight)+page.dp*10
+
+            SimpleListView {
+                id: list
+                anchors {
+                    fill: parent
+                    margins: page.dp*4
+                }
+                role: "description"
+                model: view.model
+
+                header: RowLayout {
+                    width: parent.width
+                    ExpressionInput {
+                        id: input
+                        Layout.fillWidth: true
+                        text: "sin x*sin y"
+                        focus: true
+                        Component.onCompleted: selectAll()
+                        onAccepted: {
+                            input.selectAll()
+                            var err = view.addFunction(input.text, app.variables)
+                            if (err.length>0)
+                                console.warn("errors:", err)
+                        }
+                    }
+                    Button {
+                        iconName: "list-add"
+                        onClicked: {
+                            input.selectAll()
+                            var err = view.addFunction(input.text, app.variables)
+                            if (err.length>0)
+                                console.warn("errors:", err)
+                        }
+                    }
+                }
+
+                footer: Button {
+                    text: "Clear All"
+                    onClicked: {
+                        view.model.clear()
+                        view.resetView()
+                    }
+                }
+            }
+        }
+
+        AddButton {
+            onClicked: {
+                dialog.open();
+            }
+        }
+    }
+}
diff --git a/mobile/plugins/Tables.qml b/mobile/plugins/Tables.qml
new file mode 100644 (file)
index 0000000..0138807
--- /dev/null
@@ -0,0 +1,92 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    Analitza {
+        id: a
+        variables: app.variables
+    }
+    
+    function calculateTable() {
+        resultsModel.clear();
+        
+        var tmp = a.unusedVariableName()
+        var ret = a.insertVariable(tmp, a.dependenciesToLambda(input.text))
+        var ffrom=from.value, fto=to.value, fstep=step.value;
+//         console.log("chancho (" + ffrom + ", " + fto + " : " + fstep + ") " + ret);
+        if((fto-ffrom>0)!=(fstep>0)) {
+            fstep *= -1;
+            step.value = fstep
+        }
+//         console.log("chancho2 (" + ffrom + ", " + fto + " : " + fstep + ") " + ret);
+        
+        if(fstep==0) {
+            resultsModel.append( { element: "Errors: The step can't be 0" } );
+        } else if(!a.isCorrect) {
+            resultsModel.append( { element: "Errors: "+ (ret ? ret : a.errors) } );
+        } else {
+            for (var i=ffrom; i<=fto && a.isCorrect; i+=fstep) {
+                var args = new Array();
+                args[0]=i;
+    //             console.log("!!! " + i); 
+                var expr = a.executeFunc(tmp, args);
+                resultsModel.append( { element: i +" = "+ expr.expression } );
+            }
+        }
+        
+        a.removeVariable(tmp);
+    }
+    
+    ColumnLayout {
+        id: inputcol
+        
+        anchors {
+            top: parent.top
+            left: parent.left
+            right: parent.right
+        }
+        spacing: 10
+        
+        GridLayout {
+            id: ins
+            columns: 2
+            Layout.fillWidth: true
+            
+            Label { text: "Input:" }
+            ExpressionInput {
+                id: input
+                text: "sin x";
+                Layout.fillWidth: true
+                onAccepted: calculateTable();
+            }
+            Label { text: "From:" }   RealInput { id: from; text: "0"; Layout.fillWidth: true; onAccepted: calculateTable() }
+            Label { text: "To:" }     RealInput { id: to; text: "10"; Layout.fillWidth: true; onAccepted: calculateTable() }
+            Label { text: "Step:" }   RealInput { id: step; text: "1"; Layout.fillWidth: true; onAccepted: calculateTable() }
+        }
+        
+        Button {
+            anchors.right: parent.right
+            text: "Go!"
+            
+            onClicked: calculateTable()
+        }
+    }
+    
+    SimpleListView {
+        width: parent.width
+        anchors {
+            top: inputcol.bottom
+            bottom: parent.bottom
+            topMargin: 5
+        }
+        currentIndex: -1
+        clip: true
+        
+        model: ListModel { id: resultsModel }
+        role: "element"
+        title: "Results:"
+    }
+}
diff --git a/mobile/plugins/VariablesView.qml b/mobile/plugins/VariablesView.qml
new file mode 100644 (file)
index 0000000..573b2d4
--- /dev/null
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+import org.kde.analitza 1.0
+import widgets 1.0
+
+KAlgebraPage
+{
+    SimpleListView {
+        anchors.fill: parent
+        model: VariablesModel { variables: app.variables }
+        currentIndex: -1
+        role: "whatsThis"
+        title: "Variables"
+    }
+}
diff --git a/mobile/plugins/kalgebraabout.json b/mobile/plugins/kalgebraabout.json
new file mode 100644 (file)
index 0000000..a245f61
--- /dev/null
@@ -0,0 +1,12 @@
+{
+    "Icon": "help-about",
+    "Name": "About KAlgebra",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "-10",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "About.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebraconsole.json b/mobile/plugins/kalgebraconsole.json
new file mode 100644 (file)
index 0000000..2386f53
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "Scientific calculator",
+    "Icon": "utilities-terminal",
+    "Name": "Calculator",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "1000",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "Console.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebradictionary.json b/mobile/plugins/kalgebradictionary.json
new file mode 100644 (file)
index 0000000..9145137
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "List of available functions",
+    "Icon": "documentation",
+    "Name": "Dictionary",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "100",
+    "X-KDE-PluginInfo-Author": "Artur Puzio",
+    "X-KDE-PluginInfo-Email": "cytadela8@op.pl",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "Dictionary.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebraplot2d.json b/mobile/plugins/kalgebraplot2d.json
new file mode 100644 (file)
index 0000000..d37b466
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "Draws any 2D graph you want",
+    "Icon": "draw-bezier-curves",
+    "Name": "Graph 2D",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "100",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "Plot2D.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebraplot3d.json b/mobile/plugins/kalgebraplot3d.json
new file mode 100644 (file)
index 0000000..437b4f2
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "Draws any 3D graph you want",
+    "Icon": "adjustrgb",
+    "Name": "Graph 3D",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "100",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "Plot3D.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebratables.json b/mobile/plugins/kalgebratables.json
new file mode 100644 (file)
index 0000000..c10a32f
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "Easily create value tables",
+    "Icon": "kspread",
+    "Name": "Value Tables",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "10",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "Tables.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/kalgebravariables.json b/mobile/plugins/kalgebravariables.json
new file mode 100644 (file)
index 0000000..8ff056c
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "Comment": "Displays the stored values",
+    "Icon": "document-properties",
+    "Name": "Variables",
+    "ServiceTypes": "KAlgebra/Script",
+    "Type": "Service",
+    "X-KAlgebra-Priority": "0",
+    "X-KDE-PluginInfo-Author": "Aleix Pol Gonzalez",
+    "X-KDE-PluginInfo-Email": "aleixpol@kde.org",
+    "X-KDE-PluginInfo-License": "GPL",
+    "X-KDE-PluginInfo-Name": "VariablesView.qml",
+    "X-KDE-PluginInfo-Version": "1.0"
+}
diff --git a/mobile/plugins/resources/kde-edu-logo.png b/mobile/plugins/resources/kde-edu-logo.png
new file mode 100644 (file)
index 0000000..f652c40
Binary files /dev/null and b/mobile/plugins/resources/kde-edu-logo.png differ
diff --git a/mobile/plugins/widgets/CMakeLists.txt b/mobile/plugins/widgets/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a054b79
--- /dev/null
@@ -0,0 +1,6 @@
+add_subdirectory(${MOBILE_BACKEND})
+
+install( FILES
+    qmldir
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
diff --git a/mobile/plugins/widgets/kde/CMakeLists.txt b/mobile/plugins/widgets/kde/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d53a16f
--- /dev/null
@@ -0,0 +1,13 @@
+install( FILES
+    Keyboard.qml SimpleListView.qml
+    
+    KAlgebraPage.qml KAlgebraMobile.qml
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
+
+install(FILES
+    ../qtcontrols/AddButton.qml ../qtcontrols/ComboBox.qml ../qtcontrols/Dialog.qml ../qtcontrols/Label.qml
+    ../qtcontrols/Button.qml ../qtcontrols/CalcButton.qml ../qtcontrols/RealInput.qml ../qtcontrols/ExpressionInput.qml
+
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
diff --git a/mobile/plugins/widgets/kde/ConsoleDelegate.qml b/mobile/plugins/widgets/kde/ConsoleDelegate.qml
new file mode 100644 (file)
index 0000000..104eacf
--- /dev/null
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+
+Component {
+    Row {
+        anchors.horizontalCenter: parent.horizontalCenter
+        spacing: 10
+        Text {
+            id:exp
+            text: result
+        }
+        
+//         Rectangle {
+//             color: "blue"
+//             anchors.top: parent.top
+//             anchors.bottom: parent.bottom
+//             width: parent.height
+//         }
+//         
+//             Rectangle {
+//             Text {
+//                 text: value
+// //                 color: "green"
+//                     anchors.fill: parent
+//             }
+//                 color: "blue"
+//             }
+    }
+}
diff --git a/mobile/plugins/widgets/kde/KAlgebraMobile.qml b/mobile/plugins/widgets/kde/KAlgebraMobile.qml
new file mode 100644 (file)
index 0000000..2ef5ef5
--- /dev/null
@@ -0,0 +1,65 @@
+import QtQuick 2.2
+import QtQuick.Layouts 1.2
+import org.kde.kirigami 1.0
+import org.kde.analitza 1.0
+import org.kde.kalgebra.mobile 1.0
+
+ApplicationWindow
+{
+    id: rootItem
+    height: 600
+    width: 600
+    visible: true
+
+    globalDrawer: GlobalDrawer {
+        id: drawer
+
+        title: "KAlgebra"
+        titleIcon: "kalgebra"
+
+        Instantiator {
+            delegate: Action {
+                text: title
+                iconName: decoration
+                onTriggered: {
+                    var component = Qt.createComponent(model.path);
+                    if (component.status == Component.Error) {
+                        console.log("error", component.errorString());
+                        return;
+                    }
+
+                    try {
+                        rootItem.pageStack.clear();
+                        var obj = component.createObject(component);
+                        rootItem.pageStack.push(obj)
+                    } catch(e) {
+                        console.log("error", e)
+                    }
+                }
+            }
+            model: PluginsModel {}
+            onObjectAdded: {
+                var acts = [];
+                for(var v in drawer.actions) {
+                    acts.push(drawer.actions[v]);
+                }
+                acts.splice(index, 0, object)
+                drawer.actions = acts;
+            }
+            onObjectRemoved: {
+                var acts = [];
+                for(var v in drawer.actions) {
+                    acts.push(drawer.actions[v]);
+                }
+                drawer.actions.splice(drawer.actions.indexOf(object), 1)
+                drawer.actions = acts;
+            }
+        }
+
+        actions: []
+    }
+
+    Component.onCompleted: {
+        drawer.actions[0].trigger()
+    }
+}
diff --git a/mobile/plugins/widgets/kde/KAlgebraPage.qml b/mobile/plugins/widgets/kde/KAlgebraPage.qml
new file mode 100644 (file)
index 0000000..9bde5dd
--- /dev/null
@@ -0,0 +1,14 @@
+import org.kde.kirigami 1.0
+import QtQuick 2.1
+
+Page
+{
+    readonly property real dp: Units.devicePixelRatio
+    title: "KAlgebra"
+    default property alias contents: item.data
+
+    Item {
+        id: item
+        anchors.fill: parent
+    }
+}
diff --git a/mobile/plugins/widgets/kde/Keyboard.qml b/mobile/plugins/widgets/kde/Keyboard.qml
new file mode 100644 (file)
index 0000000..e92f118
--- /dev/null
@@ -0,0 +1,45 @@
+import QtQuick 2.0
+
+Row {
+    signal clear
+    
+    Grid {
+        id:nums
+        columns: 3
+        rows: 4
+        height: 300
+        anchors.top: parent.top
+        anchors.bottom: parent.bottom
+        
+        signal newInput(string text)
+        signal deleteChar
+        
+        CalcButton { text: "1" }
+        CalcButton { text: "2" }
+        CalcButton { text: "3" }
+        CalcButton { text: "4" }
+        CalcButton { text: "5" }
+        CalcButton { text: "6" }
+        CalcButton { text: "7" }
+        CalcButton { text: "8" }
+        CalcButton { text: "9" }
+        CalcButton { text: "." }
+        CalcButton { text: "0" }
+    }
+    
+    Flow {
+        flow: Flow.TopToBottom
+        
+        CalcButton { text: "-" }
+        CalcButton { text: "+" }
+        CalcButton { text: "*" }
+        CalcButton { text: "/" }
+        CalcButton { text: "(" }
+        CalcButton { text: ")" }
+        
+        Button { text: "AC"; onClicked: clear();}
+        
+        anchors.bottom: nums.bottom
+        anchors.top: nums.top
+    }
+}
\ No newline at end of file
diff --git a/mobile/plugins/widgets/kde/SimpleListView.qml b/mobile/plugins/widgets/kde/SimpleListView.qml
new file mode 100644 (file)
index 0000000..83f025c
--- /dev/null
@@ -0,0 +1,14 @@
+import org.kde.kirigami 1.0
+import QtQuick.Controls 1.1
+import QtQuick 2.0
+
+ListView
+{
+    id: scrollList
+    property string role: ""
+    property string title: ""
+    delegate: BasicListItem { label: model[role] }
+    header: Label { visible: ListView.view.title!=""; text: ListView.view.title }
+    clip: true
+}
+
diff --git a/mobile/plugins/widgets/material/AddButton.qml b/mobile/plugins/widgets/material/AddButton.qml
new file mode 100644 (file)
index 0000000..4e3e43a
--- /dev/null
@@ -0,0 +1,14 @@
+import Material 0.1
+
+ActionButton
+{
+    id: root
+
+    anchors {
+        right: parent.right
+        bottom: parent.bottom
+        margins: Units.dp(16)
+    }
+
+    iconName: "content/add"
+}
diff --git a/mobile/plugins/widgets/material/Button.qml b/mobile/plugins/widgets/material/Button.qml
new file mode 100644 (file)
index 0000000..f627249
--- /dev/null
@@ -0,0 +1,39 @@
+import Material 0.1
+import QtQuick 2.1
+import QtQuick.Layouts 1.1
+
+Loader
+{
+    id: root
+    property string iconName: ""
+    property string text: ""
+
+    signal clicked()
+
+    Component {
+        id: textComponent
+        Button {
+            text: root.text
+            elevation: 1
+        }
+    }
+
+    Component {
+        id: iconComponent
+        IconButton {
+            Layout.minimumWidth: implicitWidth*2
+            Layout.minimumHeight: implicitHeight*2
+            iconName: rootItem.iconConvert[root.iconName]
+        }
+    }
+
+    Layout.minimumWidth: item.Layout.minimumWidth
+    Layout.minimumHeight: item.Layout.minimumHeight
+
+    sourceComponent: root.text === "" ? iconComponent : textComponent
+
+    Connections {
+        target: root.item
+        onClicked: root.clicked()
+    }
+}
diff --git a/mobile/plugins/widgets/material/CMakeLists.txt b/mobile/plugins/widgets/material/CMakeLists.txt
new file mode 100644 (file)
index 0000000..126bd04
--- /dev/null
@@ -0,0 +1,8 @@
+install( FILES
+    Label.qml Button.qml CalcButton.qml ExpressionInput.qml
+    RealInput.qml SimpleListView.qml
+    AddButton.qml Dialog.qml ComboBox.qml
+    
+    KAlgebraPage.qml  KAlgebraMobile.qml
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
diff --git a/mobile/plugins/widgets/material/CalcButton.qml b/mobile/plugins/widgets/material/CalcButton.qml
new file mode 100644 (file)
index 0000000..8b0571b
--- /dev/null
@@ -0,0 +1,4 @@
+Button
+{
+    onClicked: doOp(text)
+}
diff --git a/mobile/plugins/widgets/material/ComboBox.qml b/mobile/plugins/widgets/material/ComboBox.qml
new file mode 100644 (file)
index 0000000..d8da7fb
--- /dev/null
@@ -0,0 +1,6 @@
+import Material 0.1
+
+MenuField {
+    id: root
+    property alias currentIndex: root.selectedIndex
+}
diff --git a/mobile/plugins/widgets/material/Dialog.qml b/mobile/plugins/widgets/material/Dialog.qml
new file mode 100644 (file)
index 0000000..8eb8921
--- /dev/null
@@ -0,0 +1,4 @@
+import Material 0.1
+
+BottomSheet {
+}
diff --git a/mobile/plugins/widgets/material/ExpressionInput.qml b/mobile/plugins/widgets/material/ExpressionInput.qml
new file mode 100644 (file)
index 0000000..2965bd8
--- /dev/null
@@ -0,0 +1,19 @@
+import Material 0.1
+import org.kde.analitza 1.0
+
+TextField
+{
+    placeholderText: "Expression to calculate..."
+    inputMethodHints: /*Qt.ImhPreferNumbers |*/ Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+
+    Analitza {
+        id: a
+        variables: app.variables
+    }
+
+    property var helperExpression: a.simplify(text)
+    hasError: !helperExpression.isCorrect
+    helperText: hasError ? helperExpression.toString() : helperExpression.expression
+
+    clip: true
+}
diff --git a/mobile/plugins/widgets/material/KAlgebraMobile.qml b/mobile/plugins/widgets/material/KAlgebraMobile.qml
new file mode 100644 (file)
index 0000000..280eeef
--- /dev/null
@@ -0,0 +1,90 @@
+import QtQuick 2.2
+import QtQuick.Layouts 1.2
+import Material 0.1
+import Material.ListItems 0.1 as ListItem
+import org.kde.analitza 1.0
+import org.kde.kalgebra.mobile 1.0
+
+ApplicationWindow
+{
+    id: rootItem
+    height: 600
+    width: 600
+    visible: true
+
+    theme {
+        primaryColor: Palette.colors["blue"]["500"]
+        primaryDarkColor: Palette.colors["blue"]["700"]
+        accentColor: Palette.colors["blue"]["A200"]
+        tabHighlightColor: "white"
+    }
+
+    readonly property var iconConvert: {
+        "utilities-terminal": "communication/dialpad",
+        "draw-bezier-curves": "action/trending_up",
+        "adjustrgb": "action/view_carousel",
+        "kspread": "editor/format_list_numbered",
+        "document-properties": "content/content_copy",
+        "help-about": "action/help",
+        "list-add": "content/add"
+    }
+    
+    initialPage: Page {
+        title: "KAlgebra"
+
+        tabs: navDrawer.enabled ? [] : plugins.titles
+        onSelectedTabChanged: {
+            mainUi.source = plugins.pluginPath(selectedTab);
+        }
+
+        backAction: navDrawer.action
+
+        NavigationDrawer {
+            id: navDrawer
+
+            width: Math.min(parent.width - Units.gu(1), Units.gu(7))
+            enabled: parent.width < Units.dp(700)
+
+            ListView {
+                spacing: 10
+                anchors.fill: parent
+                header: Rectangle {
+                    width: parent.width
+                    height: navDrawer.height/5
+                    color: "#4A66A0"
+                    Image {
+                        anchors {
+                            left: parent.left
+                            right: parent.right
+
+                            verticalCenter: parent.verticalCenter
+                            leftMargin: Units.dp(16)
+                            rightMargin: Units.dp(64)
+                            verticalCenterOffset: -height/20
+                        }
+                        fillMode: Image.PreserveAspectFit
+
+                        source: "qrc:/kde-edu-logo.png"
+                    }
+                }
+                delegate: ListItem.Subtitled {
+                    text: title
+                    subText: subtitle
+                    selected: mainUi.source == model.path
+                    iconName: rootItem.iconConvert[decoration]
+                    onClicked: {
+                        mainUi.source = model.path
+                        navDrawer.close()
+                    }
+                }
+                model: PluginsModel { id: plugins }
+            }
+        }
+
+        Loader {
+            id: mainUi
+            anchors.fill: parent
+            source: plugins.pluginPath(0)
+        }
+    }
+}
diff --git a/mobile/plugins/widgets/material/KAlgebraPage.qml b/mobile/plugins/widgets/material/KAlgebraPage.qml
new file mode 100644 (file)
index 0000000..5abff2a
--- /dev/null
@@ -0,0 +1,6 @@
+import Material 0.1
+
+Page
+{
+    property real dp: Units.dp(1)
+}
diff --git a/mobile/plugins/widgets/material/Label.qml b/mobile/plugins/widgets/material/Label.qml
new file mode 100644 (file)
index 0000000..d64ccc8
--- /dev/null
@@ -0,0 +1,4 @@
+import Material 0.1
+
+Label {
+}
diff --git a/mobile/plugins/widgets/material/RealInput.qml b/mobile/plugins/widgets/material/RealInput.qml
new file mode 100644 (file)
index 0000000..e36aa74
--- /dev/null
@@ -0,0 +1,46 @@
+import Material 0.1
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+
+RowLayout
+{
+    id: root
+    property alias text: input.text
+    property alias minimumValue: realvalidator.bottom
+    property alias maximumValue: realvalidator.top
+    readonly property double value: parseFloat(input.text)
+
+    signal accepted()
+
+    TextField
+    {
+        id: input
+        Layout.fillWidth: true
+
+        inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
+
+        validator: DoubleValidator { id: realvalidator }
+
+        Component.onCompleted: text=value
+
+        onAccepted: parent.accepted()
+    }
+
+    IconButton {
+        iconName: "hardware/keyboard_arrow_up"
+        onClicked: {
+            if(root.value+1<realvalidator.top) {
+                input.text=(root.value+1)
+            }
+        }
+    }
+
+    IconButton {
+        iconName: "hardware/keyboard_arrow_down"
+        onClicked: {
+            if(root.value-1>realvalidator.bottom) {
+                input.text=(root.value-1)
+            }
+        }
+    }
+}
diff --git a/mobile/plugins/widgets/material/SimpleListView.qml b/mobile/plugins/widgets/material/SimpleListView.qml
new file mode 100644 (file)
index 0000000..92035ce
--- /dev/null
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+import Material 0.1
+import Material.ListItems 0.1 as ListItem
+
+ListView
+{
+    id: viewItem
+    property string role: ""
+    property string title
+    clip: true
+
+    header: ListItem.Subheader {
+        text: ListView.view.title
+    }
+    delegate: ListItem.Standard {
+        text: model[role]
+        interactive: false
+    }
+
+    Scrollbar {
+        flickableItem: viewItem
+    }
+}
diff --git a/mobile/plugins/widgets/neutral/Button.qml b/mobile/plugins/widgets/neutral/Button.qml
new file mode 100644 (file)
index 0000000..1aafe2e
--- /dev/null
@@ -0,0 +1,31 @@
+import QtQuick 2.0
+
+Item {
+    property alias text: display.text
+    signal clicked
+    width: display.width+15
+    height: display.height+15
+    property alias implicitWidth: display.implicitWidth
+    property alias implicitHeight: display.implicitHeight
+    
+    SystemPalette { id: palette }
+    
+    Rectangle {
+        radius: 5
+        opacity: 0.3
+        anchors.fill: parent
+        anchors.margins: 2
+        color: palette.button
+        border.width: buttonArea.containsMouse ? 5 : 1
+        border.color: palette.buttonText
+    }
+    
+    Text { id: display; anchors.centerIn: parent; color: palette.buttonText }
+    
+    MouseArea {
+        anchors.fill: parent
+        hoverEnabled: true
+        id: buttonArea
+        onClicked: parent.clicked()
+    }
+}
diff --git a/mobile/plugins/widgets/neutral/CMakeLists.txt b/mobile/plugins/widgets/neutral/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5c90774
--- /dev/null
@@ -0,0 +1,7 @@
+install( FILES
+    Label.qml Button.qml CalcButton.qml ExpressionInput.qml
+    RealInput.qml SimpleListView.qml ScrollDecorator.qml
+    
+    KAlgebraPage.qml  KAlgebraMobile.qml
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
diff --git a/mobile/plugins/widgets/neutral/CalcButton.qml b/mobile/plugins/widgets/neutral/CalcButton.qml
new file mode 100644 (file)
index 0000000..60bd7e3
--- /dev/null
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Button
+{
+    onClicked: doOp(text)
+}
\ No newline at end of file
diff --git a/mobile/plugins/widgets/neutral/ExpressionInput.qml b/mobile/plugins/widgets/neutral/ExpressionInput.qml
new file mode 100644 (file)
index 0000000..a7b8809
--- /dev/null
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+TextInput
+{
+    SystemPalette { id: palette }
+    
+    height: input.font.pixelSize+5
+    Rectangle {
+        color: palette.base
+        anchors.fill: parent
+        z: parent.z-1
+    }
+
+//     placeholderText: "Expression to calculate..."
+    inputMethodHints: Qt.ImhPreferNumbers | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+}
diff --git a/mobile/plugins/widgets/neutral/KAlgebraMobile.qml b/mobile/plugins/widgets/neutral/KAlgebraMobile.qml
new file mode 100644 (file)
index 0000000..d96ccd1
--- /dev/null
@@ -0,0 +1,62 @@
+import org.kde.analitza 1.0
+import QtQuick 2.0
+import QtQuick.Window 2.1
+import org.kde.kalgebra.mobile 1.0
+
+Window
+{
+    id: rootItem
+    SystemPalette { id: palette }
+    color: palette.window
+    height: 600
+    width: 600
+    visible: true
+    
+    function goToPage(path) {
+        try {
+            var component = Qt.createComponent(path)
+            if (component.status == Component.Ready) {
+                var obj = component.createObject(rootItem)
+//                 obj.z = rootItem+1
+                obj.anchors.fill = pluginsView
+            } else {
+                console.log("Error loading component:", component.errorString());
+            }
+        } catch (e) {
+            console.log("error: "+e)
+        }
+    }
+    
+    ListView {
+        id: pluginsView
+        anchors.fill: parent
+        spacing: 10
+        header: Image {
+            source: "qrc:/kalgebra.png"
+            anchors.horizontalCenter: parent.horizontalCenter
+            
+            MouseArea {
+                anchors.fill: parent
+                onClicked: Qt.openUrlExternally("http://edu.kde.org/applications/mathematics/kalgebra/")
+            }
+        }
+        footer: Image {
+            source: "qrc:/kde-edu-logo.png"
+            anchors.horizontalCenter: parent.horizontalCenter
+            
+            MouseArea {
+                anchors.fill: parent
+                onClicked: Qt.openUrlExternally("http://edu.kde.org")
+            }
+        }
+        delegate:
+            Button {
+                text: title
+                onClicked: goToPage(model.path)
+                anchors.horizontalCenter: parent.horizontalCenter
+            }
+
+        
+        model: PluginsModel { id: plugins }
+    }
+}
diff --git a/mobile/plugins/widgets/neutral/KAlgebraPage.qml b/mobile/plugins/widgets/neutral/KAlgebraPage.qml
new file mode 100644 (file)
index 0000000..de7d79e
--- /dev/null
@@ -0,0 +1,19 @@
+import QtQuick 2.0
+
+Rectangle
+{
+    SystemPalette { id: palette }
+    color: palette.window
+    
+    Button {
+        text: "<-"
+        width: 50
+        height: 50
+        anchors {
+            bottom: parent.bottom
+            right: parent.right
+        }
+        onClicked: parent.destroy()
+        z: parent.z+1
+    }
+}
diff --git a/mobile/plugins/widgets/neutral/Label.qml b/mobile/plugins/widgets/neutral/Label.qml
new file mode 100644 (file)
index 0000000..cde67a8
--- /dev/null
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+Text {
+    SystemPalette { id: palette }
+    color: palette.text
+    onLinkActivated: Qt.openUrlExternally(link)
+}
diff --git a/mobile/plugins/widgets/neutral/RealInput.qml b/mobile/plugins/widgets/neutral/RealInput.qml
new file mode 100644 (file)
index 0000000..3160421
--- /dev/null
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+
+TextInput
+{
+    id: input
+    property alias minimumValue: realvalidator.bottom
+    property alias maximumValue: realvalidator.top
+    SystemPalette { id: palette }
+    
+    Rectangle { color: palette.base; anchors.fill: parent; z: parent.z-1; opacity: 1 }
+    
+    property double value: parseFloat(text)
+    inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
+    
+    validator: DoubleValidator { id: realvalidator }
+    
+    onTextChanged: value=parseFloat(text)
+    
+    Component.onCompleted: text=value
+    
+    Row {
+        anchors.right: parent.right
+        height: parent.height
+        Button {
+            text: "+"
+            height: parent.height
+            onClicked: {
+                if(input.value+1<maximumValue) {
+                    input.text=(input.value+1)
+                }
+            }
+        }
+        Button {
+            text: "-"
+            onClicked: {
+                if(input.value-1>minimumValue) {
+                    input.text=(input.value-1)
+                }
+            }
+            height: parent.height
+        }
+    }
+}
\ No newline at end of file
diff --git a/mobile/plugins/widgets/neutral/ScrollDecorator.qml b/mobile/plugins/widgets/neutral/ScrollDecorator.qml
new file mode 100644 (file)
index 0000000..a8a2906
--- /dev/null
@@ -0,0 +1,17 @@
+import QtQuick 2.0
+
+Rectangle {
+    property Flickable flickableItem: null
+    anchors {
+        right: flickableItem.right
+        rightMargin: 5
+    }
+    visible: flickableItem!=null
+    width: 5
+    opacity: 0.5
+    height: flickableItem.height/(flickableItem.contentHeight/flickableItem.height)
+    y: (flickableItem.contentY/flickableItem.contentHeight)*flickableItem.height
+    
+    SystemPalette { id: palette }
+    color: palette.text
+}
\ No newline at end of file
diff --git a/mobile/plugins/widgets/neutral/SimpleListView.qml b/mobile/plugins/widgets/neutral/SimpleListView.qml
new file mode 100644 (file)
index 0000000..52e6425
--- /dev/null
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+
+ListView
+{
+    id: viewItem
+    property string role: ""
+    property string title
+    
+    SystemPalette { id: palette }
+    clip: true
+    header: Label {
+        height: ListView.view.title=="" ? 0 : 1.5*implicitHeight
+        text: ListView.view.title
+        font.weight: Font.Bold
+        verticalAlignment: Text.AlignVCenter
+    }
+    delegate: Label { text: model[role] }
+    highlight: Rectangle { color: palette.midlight }
+    
+    ScrollDecorator {
+        flickableItem: viewItem
+    }
+}
diff --git a/mobile/plugins/widgets/qmldir b/mobile/plugins/widgets/qmldir
new file mode 100644 (file)
index 0000000..7b4c37d
--- /dev/null
@@ -0,0 +1,12 @@
+Label 1.0 Label.qml
+Button 1.0 Button.qml
+CalcButton 1.0 CalcButton.qml
+ExpressionInput 1.0 ExpressionInput.qml
+RealInput 1.0 RealInput.qml
+ToolTip 1.0 ToolTip.qml
+SimpleListView 1.0 SimpleListView.qml
+KAlgebraPage 1.0 KAlgebraPage.qml
+KAlgebraMobile 1.0 KAlgebraMobile.qml
+AddButton 1.0 AddButton.qml
+Dialog 1.0 Dialog.qml
+ComboBox 1.0 ComboBox.qml
diff --git a/mobile/plugins/widgets/qtcontrols/AddButton.qml b/mobile/plugins/widgets/qtcontrols/AddButton.qml
new file mode 100644 (file)
index 0000000..fe98048
--- /dev/null
@@ -0,0 +1,14 @@
+import QtQuick.Controls 1.1
+
+Button
+{
+    id: root
+
+    anchors {
+        right: parent.right
+        bottom: parent.bottom
+        margins: 20
+    }
+
+    iconName: "list-add"
+}
diff --git a/mobile/plugins/widgets/qtcontrols/Button.qml b/mobile/plugins/widgets/qtcontrols/Button.qml
new file mode 100644 (file)
index 0000000..e39a24b
--- /dev/null
@@ -0,0 +1,4 @@
+import QtQuick.Controls 1.0
+
+Button {
+}
diff --git a/mobile/plugins/widgets/qtcontrols/CMakeLists.txt b/mobile/plugins/widgets/qtcontrols/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e77daae
--- /dev/null
@@ -0,0 +1,7 @@
+install( FILES
+    Label.qml Button.qml CalcButton.qml ExpressionInput.qml
+    RealInput.qml SimpleListView.qml
+    
+    KAlgebraPage.qml  KAlgebraMobile.qml AddButton.qml Dialog.qml ComboBox.qml
+    DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/widgets/
+)
diff --git a/mobile/plugins/widgets/qtcontrols/CalcButton.qml b/mobile/plugins/widgets/qtcontrols/CalcButton.qml
new file mode 100644 (file)
index 0000000..8b0571b
--- /dev/null
@@ -0,0 +1,4 @@
+Button
+{
+    onClicked: doOp(text)
+}
diff --git a/mobile/plugins/widgets/qtcontrols/ComboBox.qml b/mobile/plugins/widgets/qtcontrols/ComboBox.qml
new file mode 100644 (file)
index 0000000..030ebfb
--- /dev/null
@@ -0,0 +1,4 @@
+import QtQuick.Controls 1.3
+
+ComboBox
+{}
diff --git a/mobile/plugins/widgets/qtcontrols/Dialog.qml b/mobile/plugins/widgets/qtcontrols/Dialog.qml
new file mode 100644 (file)
index 0000000..c981c80
--- /dev/null
@@ -0,0 +1,10 @@
+import QtQuick 2.1
+import QtQuick.Dialogs 1.2
+
+Dialog {
+    width: 100
+    height: 100
+
+    default property Item fu
+    contentItem: fu
+}
diff --git a/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml b/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml
new file mode 100644 (file)
index 0000000..632115f
--- /dev/null
@@ -0,0 +1,7 @@
+import QtQuick.Controls 1.0
+
+TextField
+{
+    placeholderText: "Expression to calculate..."
+    inputMethodHints: /*Qt.ImhPreferNumbers |*/ Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+}
diff --git a/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml b/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml
new file mode 100644 (file)
index 0000000..db4b8c4
--- /dev/null
@@ -0,0 +1,75 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import org.kde.analitza 1.0
+import org.kde.kalgebra.mobile 1.0
+
+ApplicationWindow
+{
+    id: rootItem
+    height: 600
+    width: 600
+    visible: true
+    
+    function goToPage(path, deco) {
+        try {
+            var component = Qt.createComponent(path)
+            if (component.status == Component.Ready)
+                pageStack.push(component);
+            else
+                console.log("Error loading component:", component.errorString());
+        } catch (e) {
+            console.log("error: "+e)
+        }
+    }
+    
+    Component {
+        id: pluginsView
+        ListView {
+            spacing: 10
+            header: Image {
+                source: "qrc:/kalgebra.png"
+                anchors.horizontalCenter: parent.horizontalCenter
+
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: Qt.openUrlExternally("http://edu.kde.org/applications/mathematics/kalgebra/")
+                }
+            }
+            footer: Image {
+                source: "qrc:/kde-edu-logo.png"
+                anchors.horizontalCenter: parent.horizontalCenter
+
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: Qt.openUrlExternally("http://edu.kde.org")
+                }
+            }
+            delegate:
+                Button {
+                    text: title
+                    onClicked: goToPage(model.path)
+                    anchors.horizontalCenter: parent.horizontalCenter
+                }
+            model: PluginsModel { id: plugins }
+        }
+    }
+
+    Action {
+        id: backAction
+        text: "Back"
+        shortcut: "Back"
+        tooltip: "Go back"
+        onTriggered: {
+            if (pageStack.depth==1)
+                Qt.quit();
+            else
+                pageStack.pop();
+        }
+    }
+
+    StackView {
+        id: pageStack
+        initialItem: pluginsView
+        anchors.fill: parent
+    }
+}
diff --git a/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml b/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml
new file mode 100644 (file)
index 0000000..53fe127
--- /dev/null
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Item
+{
+    property real dp: 1
+}
diff --git a/mobile/plugins/widgets/qtcontrols/Label.qml b/mobile/plugins/widgets/qtcontrols/Label.qml
new file mode 100644 (file)
index 0000000..f34d588
--- /dev/null
@@ -0,0 +1,4 @@
+import QtQuick.Controls 1.0
+
+Label {
+}
diff --git a/mobile/plugins/widgets/qtcontrols/RealInput.qml b/mobile/plugins/widgets/qtcontrols/RealInput.qml
new file mode 100644 (file)
index 0000000..c68de44
--- /dev/null
@@ -0,0 +1,46 @@
+import QtQuick.Controls 1.0
+import QtQuick 2.0
+
+TextField
+{
+    id: input
+    property alias minimumValue: realvalidator.bottom
+    property alias maximumValue: realvalidator.top
+    
+    property double value: parseFloat(text)
+    inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
+    
+    validator: DoubleValidator { id: realvalidator }
+    
+    onTextChanged: value=parseFloat(text)
+    
+    Component.onCompleted: text=value
+    
+    Row {
+        anchors {
+            right: parent.right
+            rightMargin: 2
+        }
+        spacing: 2
+        height: parent.height-4
+        y:2
+        Button {
+            text: "+"
+            height: parent.height
+            onClicked: {
+                if(input.value+1<maximumValue) {
+                    input.text=(input.value+1)
+                }
+            }
+        }
+        Button {
+            text: "-"
+            onClicked: {
+                if(input.value-1>minimumValue) {
+                    input.text=(input.value-1)
+                }
+            }
+            height: parent.height
+        }
+    }
+}
diff --git a/mobile/plugins/widgets/qtcontrols/SimpleListView.qml b/mobile/plugins/widgets/qtcontrols/SimpleListView.qml
new file mode 100644 (file)
index 0000000..a5db36e
--- /dev/null
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.1
+
+ColumnLayout
+{
+    id: viewItem
+    property string role: ""
+    property string title: ""
+    property alias currentIndex: table.currentRow
+    property alias model: table.model
+    property Component delegate
+    property Component header
+    property Component footer
+
+    Loader {
+        Layout.fillWidth: true
+        sourceComponent: parent.header
+    }
+
+    TableView
+    {
+        id: table
+        Layout.fillWidth: true
+        Layout.fillHeight: true
+
+        TableViewColumn {
+            role: viewItem.role
+            title: viewItem.title
+        }
+
+        itemDelegate: Item {
+            Label {
+                anchors.verticalCenter: parent.verticalCenter
+                text: styleData.value
+            }
+        }
+    }
+    Loader {
+        Layout.fillWidth: true
+        sourceComponent: parent.footer
+    }
+}
diff --git a/mobile/pluginsmodel.cpp b/mobile/pluginsmodel.cpp
new file mode 100644 (file)
index 0000000..0776561
--- /dev/null
@@ -0,0 +1,105 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+
+#include "pluginsmodel.h"
+#include <QDir>
+#include <QDebug>
+#include <QUrl>
+#include <QStandardPaths>
+#include <QJsonDocument>
+
+QString PluginsModel::pluginsDirectoryPath()
+{
+#ifdef __ANDROID__
+    return "/data/data/org.kde.kalgebramobile/qt-reserved-files/share/kalgebramobile/plugins";
+#else
+    return QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("plugins"), QStandardPaths::LocateDirectory);
+#endif
+}
+
+PluginsModel::PluginsModel(QObject* parent) :QStandardItemModel(parent)
+{
+    QStringList foundPlugins;
+    QDir dir(pluginsDirectoryPath());
+    foreach(const QString& file, dir.entryList(QStringList("*.json"))) {
+        foundPlugins += dir.absoluteFilePath(file);
+    }
+
+    qDebug() << "Plugins found:" << foundPlugins;
+
+    QList<QStandardItem*> items;
+    Q_FOREACH(const QString& file, foundPlugins) {
+        QFile f(file);
+        bool ret = f.open(QIODevice::ReadOnly);
+        if(!ret) {
+            qWarning() << "error opening " << file;
+            continue;
+        }
+//         qDebug() << "laaaaa" << f.readAll() << file;
+
+        QByteArray data = f.readAll();
+        QJsonDocument doc = QJsonDocument::fromJson(data);
+
+        QVariantMap cg = doc.toVariant().toMap();
+        QStandardItem* item = new QStandardItem;
+
+        QString scriptPath = dir.absoluteFilePath(cg.value(QStringLiteral("X-KDE-PluginInfo-Name"), QString()).toString());
+
+        Q_ASSERT(!scriptPath.isEmpty());
+
+        QVariant priority = cg.value(QStringLiteral("X-KAlgebra-Priority"), QString());
+        if(!priority.isValid())
+            priority = 1000;
+        
+        item->setData(QUrl::fromLocalFile(scriptPath), PathRole);
+        item->setData(priority, PriorityRole);
+        item->setData(cg.value(QStringLiteral("Name"), QString()), TitleRole);
+        item->setData(cg.value(QStringLiteral("Comment"), QStringLiteral("")), SubtitleRole);
+        item->setData(cg.value(QStringLiteral("Icon"), QString()), Qt::DecorationRole);
+        
+        items += item;
+    }
+    invisibleRootItem()->appendRows(items);
+    setSortRole(PriorityRole);
+    sort(0, Qt::DescendingOrder);
+}
+
+QHash<int, QByteArray> PluginsModel::roleNames() const
+{
+    QHash<int, QByteArray> rolenames=QStandardItemModel::roleNames();
+    rolenames.insert(PathRole, "path");
+    rolenames.insert(PriorityRole, "priority");
+    rolenames.insert(TitleRole, "title");
+    rolenames.insert(SubtitleRole, "subtitle");
+    return rolenames;
+}
+
+QString PluginsModel::pluginPath(int row)
+{
+    return data(index(row, 0), PathRole).toString();
+}
+
+QStringList PluginsModel::titles() const
+{
+    QStringList ret;
+    for (int i=0, c=rowCount(); i<c; ++i) {
+        ret += item(i, 0)->data(TitleRole).toString();
+    }
+    return ret;
+}
diff --git a/mobile/pluginsmodel.h b/mobile/pluginsmodel.h
new file mode 100644 (file)
index 0000000..1a09a4a
--- /dev/null
@@ -0,0 +1,45 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+
+#ifndef PLUGINSMODEL_H
+#define PLUGINSMODEL_H
+
+#include <QStandardItemModel>
+
+class PluginsModel : public QStandardItemModel
+{
+    Q_OBJECT
+    Q_PROPERTY(QStringList titles READ titles CONSTANT)
+    public:
+        enum Roles { PathRole = Qt::UserRole+1, PriorityRole, TitleRole, SubtitleRole };
+        Q_ENUMS(Roles)
+
+        explicit PluginsModel(QObject* parent = 0);
+        virtual QHash<int, QByteArray> roleNames() const;
+        
+        static QString pluginsDirectoryPath();
+
+        QStringList titles() const;
+
+    public Q_SLOTS:
+        ///qml can't access data. Yay!
+        QString pluginPath(int row);
+};
+
+#endif // PLUGINSMODEL_H
diff --git a/mobile/resources.qrc b/mobile/resources.qrc
new file mode 100644 (file)
index 0000000..5a7038e
--- /dev/null
@@ -0,0 +1,9 @@
+<RCC>
+       <qresource>
+               <file alias='kde-edu-logo.png'>plugins/resources/kde-edu-logo.png</file>
+    </qresource>
+    <qresource>
+               <file alias='kalgebra.png'>../icons/64-apps-kalgebra.png</file>
+               <file alias='kalgebra.svgz'>../icons/sc-apps-kalgebra.svgz</file>
+    </qresource>
+</RCC>
diff --git a/org.kde.kalgebra.appdata.xml b/org.kde.kalgebra.appdata.xml
new file mode 100644 (file)
index 0000000..dcf2d0f
--- /dev/null
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component type="desktop">
+  <id>org.kde.kalgebra.desktop</id>
+  <metadata_license>CC0-1.0</metadata_license>
+  <project_license>GPL-2.0+</project_license>
+  <name>KAlgebra</name>
+  <name xml:lang="ast">KAlgebra</name>
+  <name xml:lang="bs">Kalgebra</name>
+  <name xml:lang="ca">KAlgebra</name>
+  <name xml:lang="ca-valencia">KAlgebra</name>
+  <name xml:lang="cs">KAlgebra</name>
+  <name xml:lang="da">KAlgebra</name>
+  <name xml:lang="de">KAlgebra</name>
+  <name xml:lang="en-GB">KAlgebra</name>
+  <name xml:lang="es">KAlgebra</name>
+  <name xml:lang="et">KAlgebra</name>
+  <name xml:lang="fi">KAlgebra</name>
+  <name xml:lang="fr">KAlgebra</name>
+  <name xml:lang="gl">KAlgebra</name>
+  <name xml:lang="hu">KAlgebra</name>
+  <name xml:lang="it">KAlgebra</name>
+  <name xml:lang="ko">KAlgebra</name>
+  <name xml:lang="lt">KAlgebra</name>
+  <name xml:lang="nds">KAlgebra</name>
+  <name xml:lang="nl">KAlgebra</name>
+  <name xml:lang="nn">KAlgebra</name>
+  <name xml:lang="pl">KAlgebra</name>
+  <name xml:lang="pt">KAlgebra</name>
+  <name xml:lang="pt-BR">KAlgebra</name>
+  <name xml:lang="ru">KAlgebra</name>
+  <name xml:lang="sk">KAlgebra</name>
+  <name xml:lang="sl">KAlgebra</name>
+  <name xml:lang="sv">Kalgebra</name>
+  <name xml:lang="tr">KAlgebra</name>
+  <name xml:lang="uk">KAlgebra</name>
+  <name xml:lang="x-test">xxKAlgebraxx</name>
+  <name xml:lang="zh-CN">KAlgebra</name>
+  <name xml:lang="zh-TW">數學_KAlgebra</name>
+  <summary>Graph Calculator</summary>
+  <summary xml:lang="ast">Calculadora gráfica</summary>
+  <summary xml:lang="bs">Graf kalkulator</summary>
+  <summary xml:lang="ca">Calculadora gràfica</summary>
+  <summary xml:lang="ca-valencia">Calculadora gràfica</summary>
+  <summary xml:lang="cs">Kalkulačka grafů</summary>
+  <summary xml:lang="de">Graphenrechner</summary>
+  <summary xml:lang="en-GB">Graph Calculator</summary>
+  <summary xml:lang="es">Calculadora gráfica</summary>
+  <summary xml:lang="et">Graafide arvutaja</summary>
+  <summary xml:lang="fi">Graafinen laskin</summary>
+  <summary xml:lang="fr">Calculatrice graphique</summary>
+  <summary xml:lang="gl">Calculadora gráfica</summary>
+  <summary xml:lang="hu">Grafikus számológép</summary>
+  <summary xml:lang="it">Calcolatrice grafica</summary>
+  <summary xml:lang="ko">그래핑 계산기</summary>
+  <summary xml:lang="lt">Grafinis skaičiuotuvas</summary>
+  <summary xml:lang="nds">Funkschonenreekner</summary>
+  <summary xml:lang="nl">Rekenmachine met grafieken</summary>
+  <summary xml:lang="nn">Grafkalkulator</summary>
+  <summary xml:lang="pl">Kalkulator wykresów</summary>
+  <summary xml:lang="pt">Calculadora de Grafos</summary>
+  <summary xml:lang="pt-BR">Calculadora gráfica</summary>
+  <summary xml:lang="ru">Калькулятор с функцией построения графиков</summary>
+  <summary xml:lang="sk">Grafická kalkulačka</summary>
+  <summary xml:lang="sl">Računalo z grafi</summary>
+  <summary xml:lang="sv">Grafräknare</summary>
+  <summary xml:lang="tr">Grafik Hesap Makinesi</summary>
+  <summary xml:lang="uk">Графічний калькулятор</summary>
+  <summary xml:lang="x-test">xxGraph Calculatorxx</summary>
+  <summary xml:lang="zh-CN">图形计算器</summary>
+  <summary xml:lang="zh-TW">圖形計算器</summary>
+  <description>
+    <p>KAlgebra is an application that can replace your graphing calculator. It has numerical, logical, symbolic, and analysis features that let you calculate mathematical expressions on the console and graphically plot the results in 2D or 3D. KAlgebra is rooted in the Mathematical Markup Language (MathML); however, one does not need to know MathML to use KAlgebra.</p>
+    <p xml:lang="ast">KAlgebra ye una aplicación que pue trocar la to calculadora gráfica. Tien carauterístiques numbériques, llóxiques, simbóliques y d'analís que te permiten calcular espresiones matemátiques na consola y trazar gráficamente los resultaos en 2D ó 3D. KAlgebra ta arraigonáu nel llinguax matemáticu d'etiquetes (MathML); por embargu, naide necesita saber MathML pa usar KAlgebra</p>
+    <p xml:lang="ca">KAlgebra és una aplicació que pot reemplaçar la vostra calculadora gràfica. Té capacitats numèriques, lògiques i d'anàlisi que us permetran calcular expressions matemàtiques en una consola i dibuixar una gràfica dels resultats en 2D o 3D. KAlgebra té les seves arrels en el Llenguatge de Marcat Matemàtic (MathML); tanmateix, no us caldrà tenir coneixements de MathML per emprar el KAlgebra.</p>
+    <p xml:lang="ca-valencia">KAlgebra és una aplicació que pot reemplaçar la vostra calculadora gràfica. Té capacitats numèriques, lògiques i d'anàlisi que vos permetran calcular expressions matemàtiques en una consola i dibuixar una gràfica dels resultats en 2D o 3D. KAlgebra té les seues arrels en el Llenguatge de Marcat Matemàtic (MathML); tanmateix, no vos caldrà tindre coneixements de MathML per emprar el KAlgebra.</p>
+    <p xml:lang="de">KAlgebra ist eine Anwendung, die Ihren grafischen Taschenrechner ersetzt. KAlgebra hat numerische, logische, symbolische und analytische Fähigkeiten, mit denen Sie mathematische Ausdrücke in der Konsole auswerten und die Ergebnisse zwei- oder dreidimensional darstellen können. KAlgebra basiert auf der Sprache „Mathematical Markup Language“ (MathML), es sind jedoch keine Kenntnisse von MathML erforderlich, um KAlgebra erfolgreich einsetzen zu können.</p>
+    <p xml:lang="en-GB">KAlgebra is an application that can replace your graphing calculator. It has numerical, logical, symbolic, and analysis features that let you calculate mathematical expressions on the console and graphically plot the results in 2D or 3D. KAlgebra is rooted in the Mathematical Markup Language (MathML); however, one does not need to know MathML to use KAlgebra.</p>
+    <p xml:lang="es">KAlgebra es una aplicación que puede sustituir su calculadora gráfica. Contiene funciones numéricas, lógicas, simbólicas y de análisis que le permiten calcular expresiones matemáticas en la consola y dibujar gráficamente su resultado en dos o tres dimensiones. KAlgebra se basa fuertemente en el «lenguaje de marcado matemático» (MathML); sin embargo, no es necesario saber MathML para usar KAlgebra.</p>
+    <p xml:lang="et">KAlgebra on rakendus, mis võib asendada su senist graafikalkulaatorit Sel on arvulisi, loogilisi, sümbolilisi ja analüüsiomadusi, mis võimaldavad arvutada matemaatilisi avaldisi konsoolis ja lasta tulemusi kujutada graafiliselt nii tasapinnaliselt (2D) kui ka ruumiliselt (3D). KAlgebra juured on matemaatilises märkekeeles (MathML), kuid KAlgebra kasutamiseks ei ole MathML-i tundmine sugugi vajalik.</p>
+    <p xml:lang="fi">KAlgebralla voi korvata graafisen laskimen. Siinä on numeeriset, loogiset, symboliset ja analyysiominaisuudet, jotka tarvitaan matemaattisten lausekkeiden laskemiseen sekä tulosten piirtämiseen kaksi- tai kolmiulotteisesti. KAlgebra perustuu MathML:ään (Mathematical Markup Language), mutta sitä ei tarvitse osata käyttääkseen KAlgebraa.</p>
+    <p xml:lang="fr">KAlgebra est une application qui peut remplacer votre calculatrice graphique. Elle fournit des fonctions pour le calcul numérique, logique, symbolique et l'analyse qui vous permettent de calculer des expressions mathématiques dans la console et tracer graphiquement les résultats en 2D ou 3D. KAlgebra repose sur MathML, le langage de balise pour les mathématiques ; cependant, il n'est pas nécessaire de connaître MathML pour utiliser KAlgebra.</p>
+    <p xml:lang="gl">KAlgebra é un programa que pode substituír as calculadoras gráficas. Ten funcionalidades numéricas, lóxicas, simbólicas e de análise que permiten calcular expresións matemáticas na consola e trazar graficamente os resultados en 2D ou 3D. KAlgebra ten o seu alicerce na Linguaxe de Marcaxe Matemática (MathML); porén, non hai que saber nada do MathML para poder empregar o KAlgebra.</p>
+    <p xml:lang="hu">A KAlgebra a grafikus számológépe helyébe léphet. Numerikus, logikai, szimbolikus és analízis képességei lehetővé teszik matematikai kifejezések kiértékelését a konzolon, majd grafikus ábrázolását 2D-ben vagy 3D-ben. A KAlgebra erősen épít a MathML matematikai leírónyelv használatára, ugyanakkor nem szükséges MathML ismeret a KAlgebra használatához.</p>
+    <p xml:lang="it">KAlgebra è un'applicazione che può sostituire la tua calcolatrice grafica. Ha funzionalità numeriche, logiche, simboliche e di analisi che ti permettono di calcolare espressioni matematiche sulla console e visualizzarne il grafico in 2D o 3D. KAlgebra si basa sul linguaggio a marcatori di matematica («Mathematical Markup Language», MathML); tuttavia, non è necessario conoscere MathML per usare KAlgebra.</p>
+    <p xml:lang="nds">KAlgebra kannst Du ansteed Dien Grafik-Taschenreekner bruken. Dat gifft numeersche, logische, symboolsche un Analysis-Funkschonen, mit de Du mathemaatsch Utdrück op de Konsool utreken un de Resultaten graafsch in 2- un 3-D utgeven kannst. KAlgebra buut op de Mathemaatsch Schriftsatzspraak („Mathematical Markup Language – MathML“); man Du kannst KAlgebra ok bruken, wenn Du nix vun MathML afweetst.</p>
+    <p xml:lang="nl">KAlgebra kan uw grafische rekenmachine vervangen. Het heeft numerieke, logische, symbolische en analytische functies waarmee u wiskundige uitdrukkingen kunt berekenen in de console, en de resultaten in 2D of 3D kunt plotten. KAlgebra is gebaseerd op de Mathematical Markup Language (MathML), maar kennis daarvan is niet nodig om KAlgebra te kunnen gebruiken.</p>
+    <p xml:lang="pl">KAlgebra jest programem, który może zastąpić twój kalkulator graficzny. Ma możliwość przeprowadzania analiz numerycznych, logicznych i  symbolicznych, które umożliwiają obliczanie wyrażeń matematycznych w konsoli i rysowanie wyników w 2D lub 3D. KAlgebra jest zakorzeniona w Mathematical Markup Language (MathML); lecz nie trzeba znać MathML, aby używać KAlgebra.</p>
+    <p xml:lang="pt">O KAlgebra é uma aplicação que poderá substituir a sua calculadora gráfica. Ela tem funcionalidades numéricas, lógicas, simbólicas e de análise que lhe permitem calcular expressões matemáticas na consola e desenhar os resultados respectivos em 2D ou 3D. O KAlgebra baseia-se na Mathematical Markup Language (MathML); contudo, ninguém precisa de saber MathML para usar o KAlgebra.</p>
+    <p xml:lang="pt-BR">KAlgebra é um aplicativo que pode substituir a sua calculadora gráfica. Ele tem funcionalidades numéricas, lógicas, simbólicas e analíticas que lhe permitem calcular expressões matemáticas no console e desenhar graficamente os resultados em 2D ou 3D. O KAlgebra é baseado na Mathematical Markup Language (MathML). Entretanto, não é preciso conhecer o MathML para usar o KAlgebra.</p>
+    <p xml:lang="ru">KAlgebra — программа-калькулятор с функцией построения графиков. Позволяет вычислять значения выражений и строить двумерные и трёхмерные графики функций. В основе KAlgebra лежит язык математической разметки MathML, однако его знания не требуется для использования программы.</p>
+    <p xml:lang="sk">KAlgebra je aplikácia, ktorá môže nahradiť vašu grafickú kalkulačku. Má numerické, logické, symbolické a analytické funkcie, ktoré vám umožnia vypočítať matematické výrazy na konzole a graficky zakresliť výsledky v 3D alebo 3D. KAlgebra je založená na jazyku MathML; avšak nemusíte poznať tento jazyk na používanie tohto programu.</p>
+    <p xml:lang="sl">KAlgebra je program, ki lahko zamenja vaše grafično računalo. Ima zmožnosti za obdelavo številk, logike, simbolov in omogoča izračun matematičnih izrazov v konzoli ter njihov izris v 2D ali 3D. KAlgebra temelji na Matematičnem označevalnem jeziku (MathML), vendar ga za uporabo KAlgebre ni potrebno poznati.</p>
+    <p xml:lang="sv">Kalgebra; är ett program som kan ersätta en grafisk miniräknare. Det har numeriska, logiska, symboliska och analytiska funktioner som gör det möjligt att beräkna matematiska uttryck i terminalen och rita upp resultatet grafiskt i två eller tre dimensioner. Kalgebra är grundat på det matematiska taggspråket (MathML), men man behöver dock inte känna till MathML för att använda Kalgebra.</p>
+    <p xml:lang="tr">KAlgebra, grafik hesap makinanızın yerine geçebilecek bir uygulamadır. Sayısal, mantıksal, sembolik ve analiz özellikleriyle, terminal üzerinden matematiksel ifadeleri hesaplayabilir ve sonuçları 2D veya 3D olarak olarak grafik olarak çizdirebilirsiniz. KAlgebra, Matematiksel İşaret Dili (MathML) üzerine inşa edilmiştir; ancak, KAlgebra kullanmak için MathML bilmek zorunda değilsiniz.</p>
+    <p xml:lang="uk">KAlgebra; — програма, яка може замінити вам калькулятор з можливістю побудови графіків У програмі передбачено числові, логічні, символічні та аналітичні можливості, за допомогою яких ви зможете виконувати обчислення за формулами у консолі або будувати результати у форматі плоских кривих або просторових графіків. KAlgebra засновано на мові математичної розмітки (Mathematical Markup Language і MathML). Втім, для користування KAlgebra знати MathML не потрібно.</p>
+    <p xml:lang="x-test">xxKAlgebra is an application that can replace your graphing calculator. It has numerical, logical, symbolic, and analysis features that let you calculate mathematical expressions on the console and graphically plot the results in 2D or 3D. KAlgebra is rooted in the Mathematical Markup Language (MathML); however, one does not need to know MathML to use KAlgebra.xx</p>
+    <p xml:lang="zh-TW">KAlgebra 是一套可以取代您的圖形計算器的應用程式。它有數值、邏輯、符號與分析等功能,讓您計算您的數學式,並繪出平面或立體的圖形。KAlgebra 是基於 Mathematical Markup Language (MathML)。不過即使您不知道 MathML 也可以使用 KAlgebra。</p>
+  </description>
+  <url type="homepage">http://edu.kde.org/kalgebra/</url>
+  <url type="bugtracker">https://bugs.kde.org/enter_bug.cgi?format=guided&amp;product=kalgebra</url>
+  <url type="help">http://docs.kde.org/stable/en/kdeedu/kalgebra/index.html</url>
+  <screenshots>
+    <screenshot type="default">
+      <image>http://kde.org/images/screenshots/kalgebra.png</image>
+    </screenshot>
+  </screenshots>
+  <project_group>KDE</project_group>
+  <provides>
+    <binary>kalgebra</binary>
+  </provides>
+</component>
diff --git a/plasmoids/CMakeLists.txt b/plasmoids/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1882c04
--- /dev/null
@@ -0,0 +1,6 @@
+# add_subdirectory(calculator)
+# TODO: port to QML
+
+install(DIRECTORY graphsplasmoid/ DESTINATION ${KDE_INSTALL_DATADIR}/plasma/plasmoids/org.kde.graphsplasmoid)
+install(FILES graphsplasmoid/metadata.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} RENAME graphsplasmoid.desktop)
+
diff --git a/plasmoids/calculator/CMakeLists.txt b/plasmoids/calculator/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b9d449c
--- /dev/null
@@ -0,0 +1,11 @@
+project(kalgebra-plasmoid)
+
+add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+set(kalgebraplasma_SRCS kalgebraplasma.cpp)
+
+add_library(plasma_applet_kalgebra MODULE ${kalgebraplasma_SRCS})
+target_link_libraries(plasma_applet_kalgebra ${KF5::plasma}  KF5::Analitza)
+
+set(plugin_dir ${KDE_INSTALL_PLUGINDIR}/plugins/kalgebra)
+install(TARGETS plasma_applet_kalgebra DESTINATION ${KDE_INSTALL_PLUGINDIR})
+install(FILES kalgebraplasmoid.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
diff --git a/plasmoids/calculator/Messages.sh b/plasmoids/calculator/Messages.sh
new file mode 100644 (file)
index 0000000..0af2da1
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+$XGETTEXT *.cpp -o $podir/plasma_applet_kalgebraplasmoid.pot
diff --git a/plasmoids/calculator/kalgebraplasma.cpp b/plasmoids/calculator/kalgebraplasma.cpp
new file mode 100644 (file)
index 0000000..5a2da59
--- /dev/null
@@ -0,0 +1,159 @@
+/*************************************************************************************
+ *  Copyright (C) 2008 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "kalgebraplasma.h"
+
+#include <QFontMetrics>
+#include <QGraphicsProxyWidget>
+#include <QFont>
+#include <KIcon>
+#include <KIconLoader>
+
+#include <plasma/theme.h>
+#include <plasma/dataengine.h>
+#include <plasma/tooltipcontent.h>
+#include <plasma/tooltipmanager.h>
+
+#include <analitza/expression.h>
+
+using namespace Plasma;
+using Analitza::Expression;
+
+QColor KAlgebraPlasmoid::correctColor() { return Theme::defaultTheme()->color(Theme::TextColor);}
+QColor KAlgebraPlasmoid::errorColor() { return Qt::red; }
+int KAlgebraPlasmoid::simplificationSize() {  return Theme::defaultTheme()->font(Theme::DefaultFont).pointSize(); }
+
+KAlgebraPlasmoid::KAlgebraPlasmoid(QObject *parent, const QVariantList &args)
+    : PopupApplet(parent, args), m_widget(0), m_layout(0)
+{
+    KGlobal::locale()->insertCatalog("kalgebra");
+    setAspectRatioMode(IgnoreAspectRatio);
+    setAssociatedApplication("kalgebra");
+}
+
+KAlgebraPlasmoid::~KAlgebraPlasmoid() {}
+
+void KAlgebraPlasmoid::init()
+{
+//     updateFactor();
+    
+    setPopupIcon("kalgebra");
+}
+
+QQuickItem* KAlgebraPlasmoid::graphicsWidget()
+{
+    if(!m_widget) {
+        m_widget = new QQuickItem(this);
+        m_input = new Plasma::LineEdit(m_widget);
+        m_input->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+        m_input->setClearButtonShown(true);
+        
+        m_output = new Plasma::Label(m_widget);
+        m_output->setMinimumSize(20, 20);
+        m_output->nativeWidget()->setAlignment(Qt::AlignCenter);
+        m_output->setText(i18n("Enter some expression."));
+        
+        m_layout = new QGraphicsLinearLayout(m_widget);
+        m_layout->setOrientation(Qt::Vertical);
+        m_layout->addItem(m_input);
+        m_layout->addItem(m_output);
+        m_widget->setPreferredSize(300,300);
+        
+        connect(m_input, SIGNAL(editingFinished()), this, SLOT(addOperation()));
+        connect(m_input->nativeWidget(), SIGNAL(textChanged(QString)), this, SLOT(simplify()));
+    }
+    m_input->nativeWidget()->selectAll();
+    m_input->setFocus();
+    
+    return m_widget;
+}
+
+void KAlgebraPlasmoid::addOperation()
+{
+    if ( m_input->text().isEmpty() )
+        return;
+    
+    Expression res;
+    a.setExpression(Expression(m_input->text(), false));
+    if(a.isCorrect()) {
+        res=a.evaluate();
+    }
+    
+    QColor c;
+    if(a.isCorrect()) {
+        QString result=res.toString();
+        m_output->setText(result);
+        
+        Plasma::ToolTipContent data;
+        data.setMainText(i18n("KAlgebra"));
+        data.setSubText(i18n("%1 = %2", m_input->text(), result));
+        data.setImage(QIcon::fromTheme("kalgebra").pixmap(IconSize(KIconLoader::Desktop)));
+        Plasma::ToolTipManager::self()->setContent(this, data);
+        
+        c=correctColor();
+    } else {
+        m_output->setText(a.errors().join("\n"));
+        c=errorColor();
+    }
+    plasmoidFont(true, c, true);
+    update();
+}
+
+void KAlgebraPlasmoid::plasmoidFont(bool big, const QColor& c, bool bold)
+{
+    QFont f=m_output->nativeWidget()->font();
+    f.setBold(bold);
+    int size;
+    
+    if(big) {
+        size=(m_output->size().height()*2)/3;
+        f.setPointSize(size);
+        QFontMetrics fm(f);
+        
+        int w=m_output->size().width();
+        Q_ASSERT(w>0);
+        for(; fm.width(m_output->text()) > w; size--) {
+            f.setPointSize(size);
+            fm=QFontMetrics(f);
+        }
+    } else
+        size=simplificationSize();
+    f.setPointSize(size);
+    
+    QPalette palette = m_output->palette();
+    palette.setColor(QPalette::WindowText, c);
+    m_output->nativeWidget()->setPalette(palette);
+    m_output->nativeWidget()->setFont(f);
+}
+
+void KAlgebraPlasmoid::simplify()
+{
+    Expression e(m_input->text(), false);
+    if(e.isCorrect())
+        a.setExpression(e);
+    
+    if(e.isCorrect() && a.isCorrect()) {
+        a.simplify();
+        m_output->setText(a.expression().toString());
+        
+        plasmoidFont(false, correctColor(), true);
+    } else
+        m_output->setText(QString());
+}
+
+
diff --git a/plasmoids/calculator/kalgebraplasma.h b/plasmoids/calculator/kalgebraplasma.h
new file mode 100644 (file)
index 0000000..514aa59
--- /dev/null
@@ -0,0 +1,61 @@
+/*************************************************************************************
+ *  Copyright (C) 2008 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+
+#ifndef KALGEBRAPLASMA_HEADER
+#define KALGEBRAPLASMA_HEADER
+
+#include <Plasma/PopupApplet>
+#include <Plasma/Label>
+#include <Plasma/LineEdit>
+#include <QGraphicsLinearLayout>
+#include <analitza/analyzer.h>
+
+
+class KAlgebraPlasmoid : public Plasma::Applet
+{
+    Q_OBJECT
+    public:
+        KAlgebraPlasmoid(QObject *parent, const QVariantList &args);
+        ~KAlgebraPlasmoid();
+        
+        void init();
+        virtual QQuickItem* graphicsWidget();
+        
+    private Q_SLOTS:
+        void simplify();
+        void addOperation();
+        
+    private:
+        static QColor correctColor();
+        static QColor errorColor();
+        static int simplificationSize();
+        
+        void plasmoidFont(bool big, const QColor& c, bool bold);
+        
+        QQuickItem* m_widget;
+        QGraphicsLinearLayout* m_layout;
+        Plasma::LineEdit *m_input;
+        Plasma::Label *m_output;
+        Analitza::Analyzer a;
+};
+
+// This is the command that links your applet to the .desktop file
+K_EXPORT_PLASMA_APPLET(kalgebraplasmoid, KAlgebraPlasmoid)
+
+#endif
diff --git a/plasmoids/calculator/kalgebraplasmoid.desktop b/plasmoids/calculator/kalgebraplasmoid.desktop
new file mode 100644 (file)
index 0000000..f3782f8
--- /dev/null
@@ -0,0 +1,126 @@
+[Desktop Entry]
+Name=KAlgebra
+Name[ast]=KAlgebra
+Name[bg]=KAlgebra
+Name[bs]=Kalgebra
+Name[ca]=KAlgebra
+Name[ca@valencia]=KAlgebra
+Name[cs]=KAlgebra
+Name[csb]=KAlgebra
+Name[da]=KAlgebra
+Name[de]=KAlgebra
+Name[el]=KAlgebra
+Name[en_GB]=KAlgebra
+Name[eo]=KAlgebra
+Name[es]=KAlgebra
+Name[et]=KAlgebra
+Name[eu]=KAlgebra
+Name[fi]=KAlgebra
+Name[fr]=KAlgebra
+Name[ga]=KAlgebra
+Name[gl]=KAlgebra
+Name[gu]=KAlgebra
+Name[he]=KAlgebra
+Name[hi]=के-अलजेब्रा
+Name[hne]=के-अलजेब्रा
+Name[hr]=KAlgebra
+Name[hu]=KAlgebra
+Name[is]=KAlgebra
+Name[it]=KAlgebra
+Name[ja]=KAlgebra
+Name[kk]=KAlgebra
+Name[km]=KAlgebra
+Name[ko]=KAlgebra
+Name[lt]=KAlgebra
+Name[lv]=KAlgebra
+Name[ml]=കെ-ആള്‍ജിബ്ര
+Name[mr]=के-एल्जिब्रा
+Name[nb]=KAlgebra
+Name[nds]=KAlgebra
+Name[ne]=केडीई बीजगणित
+Name[nl]=KAlgebra
+Name[nn]=KAlgebra
+Name[pa]=ਕੇ-ਐਲਜਬਰਾ
+Name[pl]=KAlgebra
+Name[pt]=KAlgebra
+Name[pt_BR]=KAlgebra
+Name[ro]=KAlgebra
+Name[ru]=KAlgebra
+Name[si]=KAlgebra
+Name[sk]=KAlgebra
+Name[sl]=KAlgebra
+Name[sv]=Kalgebra
+Name[te]=కె అల్జీబ్రా
+Name[tr]=KAlgebra
+Name[ug]=KAlgebra
+Name[uk]=KАлгебра
+Name[x-test]=xxKAlgebraxx
+Name[zh_CN]=KAlgebra
+Name[zh_TW]=數學_KAlgebra
+Icon=kalgebra
+Comment=A Calculator
+Comment[ast]=Una calculadora
+Comment[bg]=Калкулатор
+Comment[bs]=Kalkulator
+Comment[ca]=Una calculadora
+Comment[ca@valencia]=Una calculadora
+Comment[cs]=Kalkulačka
+Comment[da]=En regnemaskine
+Comment[de]=Ein Taschenrechner
+Comment[el]=Ένας μικροϋπολογιστής
+Comment[en_GB]=A Calculator
+Comment[es]=Una calculadora
+Comment[et]=Arvutaja
+Comment[eu]=Kalkulagailu bat
+Comment[fi]=Laskin
+Comment[fr]=Une calculatrice
+Comment[ga]=Áireamhán
+Comment[gl]=Unha calculadora
+Comment[gu]=કેલ્ક્યુલેટર
+Comment[he]=מחשבון
+Comment[hne]=गनक
+Comment[hr]=Kalkulator
+Comment[hu]=Algebrai számológép
+Comment[is]=Reiknivél
+Comment[it]=Una calcolatrice
+Comment[ja]=計算機
+Comment[kk]=Калькулятор
+Comment[km]=ម៉ាស៊ីន​គិត​លេខ
+Comment[ko]=계산기
+Comment[lt]=Skaičiuotuvas
+Comment[lv]=Kalkulators
+Comment[ml]=ഗണനി
+Comment[mr]=गणकयंत्र
+Comment[nb]=En kalkulator
+Comment[nds]=En Rekenprogramm
+Comment[nl]=Een rekenmachine
+Comment[nn]=Tekstbasert kalkulator
+Comment[pa]=ਇੱਕ ਕੈਲਕੂਲੇਟਰ
+Comment[pl]=Kalkulator
+Comment[pt]=Uma Calculadora
+Comment[pt_BR]=Uma calculadora
+Comment[ro]=Un calculator
+Comment[ru]=Калькулятор
+Comment[sk]=Kalkulačka
+Comment[sl]=Računalo
+Comment[sv]=Kalkylator
+Comment[te]=గనన యంత్రము
+Comment[tr]=Bir Hesap Makinesi
+Comment[ug]=ھېسابلىغۇچ
+Comment[uk]=Калькулятор
+Comment[x-test]=xxA Calculatorxx
+Comment[zh_CN]=一个计算器
+Comment[zh_TW]=計算器
+Type=Service
+ServiceTypes=Plasma/Applet
+
+X-KDE-Library=plasma_applet_kalgebra
+X-KDE-PluginInfo-Author=Aleix Pol Gonzalez
+X-KDE-PluginInfo-Email=aleixpol@kde.org
+X-KDE-PluginInfo-Name=kalgebraplasmoid
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-Website=http://edu.kde.org/
+X-KDE-PluginInfo-Category=Education
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
diff --git a/plasmoids/graphsplasmoid/contents/ui/config.ui b/plasmoids/graphsplasmoid/contents/ui/config.ui
new file mode 100644 (file)
index 0000000..22ecd73
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>nowplayingConfig</class>
+ <widget class="QWidget" name="nowplayingConfig">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>351</width>
+    <height>341</height>
+   </rect>
+  </property>
+  <layout class="QFormLayout" name="formLayout">
+   <item row="1" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Function</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="kcfg_function"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/plasmoids/graphsplasmoid/contents/ui/main.qml b/plasmoids/graphsplasmoid/contents/ui/main.qml
new file mode 100644 (file)
index 0000000..1169c30
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *   Copyright 2012 Aleix Pol Gonzalez <aleixpol@kde.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.
+ */
+
+import QtQuick 2.0
+import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.analitza 1.0
+
+Item {
+    property Component compactRepresentation: Component {
+        PlasmaComponents.Button {
+            iconSource: "kalgebra"
+            onClicked: plasmoid.togglePopup()
+        }
+    }
+    property string displayedFunction
+    onDisplayedFunctionChanged: {
+        plots.clear()
+        view.addFunction(displayedFunction)
+    }
+    
+    PlasmaComponents.TextField {
+        id: input
+        anchors {
+            top: parent.top
+            left: parent.left
+            right: parent.right
+        }
+        onAccepted: {
+            displayedFunction = text
+            plasmoid.writeConfig("function", text)
+        }
+    }
+    
+    Component.onCompleted: {
+        plasmoid.addEventListener('ConfigChanged', function() {
+            displayedFunction = plasmoid.readConfig("function")
+            input.text = displayedFunction
+        });
+    }
+    
+    Graph2D {
+        id: view
+        anchors {
+            fill: parent
+            topMargin: input.height
+        }
+        
+        model: PlotsModel { id: plots }
+        
+        ticksShown: false
+    }
+}
diff --git a/plasmoids/graphsplasmoid/metadata.desktop b/plasmoids/graphsplasmoid/metadata.desktop
new file mode 100644 (file)
index 0000000..d9bef59
--- /dev/null
@@ -0,0 +1,90 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+ServiceTypes=Plasma/Applet
+Name=2D Plots
+Name[ast]=Trazaos 2D
+Name[bs]=2D crtanja
+Name[ca]=Gràfiques 2D
+Name[ca@valencia]=Gràfiques 2D
+Name[cs]=2D grafy
+Name[da]=2D-plot
+Name[de]=2D-Plots
+Name[el]=2D Γραφικές απεικονίσεις
+Name[en_GB]=2D Plots
+Name[es]=Gráficas 2D
+Name[et]=2D joonised
+Name[fi]=2D-kuvaajat
+Name[fr]=Tracés 2D
+Name[gl]=Gráficas en 2D
+Name[hu]=2D görbék
+Name[it]=Grafici 2D
+Name[kk]=2D графиктер
+Name[km]=ការ​គ្រោង​ធ្វេមាត្រ
+Name[ko]=2차원 플롯
+Name[lt]=2D grafikai
+Name[nb]=2D-plott
+Name[nds]=2D-Plots
+Name[nl]=2d-plots
+Name[pa]=2ਡੀ ਪਲਾਟ
+Name[pl]=Wykresy 2D
+Name[pt]=Gráficos 2D
+Name[pt_BR]=Gráficos em 2D
+Name[ru]=Двумерный график
+Name[sk]=2D zákresy
+Name[sl]=2D grafi
+Name[sv]=Tvådimensionella diagram
+Name[te]=2D ప్లాట్
+Name[tr]=2D Çizimler
+Name[uk]=Плоскі графіки
+Name[x-test]=xx2D Plotsxx
+Name[zh_CN]=二维绘图
+Name[zh_TW]=2D 繪圖
+Comment=Put the weirdest plots on your desktop!
+Comment[ast]=¡Pon los trazaos más estraños nel to escritoriu!
+Comment[bs]=Postavite najčudnije crteže na vašem desktopu
+Comment[ca]=Poseu les gràfiques més estranyes al vostre escriptori!
+Comment[ca@valencia]=Poseu les gràfiques més estranyes al vostre escriptori!
+Comment[cs]=Přidejte na svou plochu ty nejdivnější tvary.
+Comment[da]=Sæt de særeste plot på dit skrivebord!
+Comment[de]=Erstellt Plots für Ihre Arbeitsfläche.
+Comment[el]=Βάλτε τις πιο περίεργες γραφικές απεικονίσεις στην επιφάνεια εργασίας σας!
+Comment[en_GB]=Put the weirdest plots on your desktop!
+Comment[es]=Traza las gráficas más retorcidas en su escritorio
+Comment[et]=Aseta oma töölauale kõige veidramad joonised!
+Comment[fi]=Laita mitä ihmeellisimpiä kuvaajia työpöydällesi!
+Comment[fr]=Placez les tracés les plus étranges sur votre bureau !
+Comment[gl]=Poña as gráficas máis charramangueiras no seu escritorio!
+Comment[hu]=Tegye a legfurább görbéket az asztalára!
+Comment[it]=Metti i grafici più strani sul tuo desktop!
+Comment[kk]=Үстеліңізге сиқырлы графиктерді шығарыңыз!
+Comment[km]=Put the weirdest plots on your desktop!
+Comment[ko]=데스크톱에 재미있는 플롯을 그리십시오!
+Comment[lt]=Dėkite keisčiausius brėžinius ant savo darbalaukio!
+Comment[nb]=Legg de merkeligste plott på skrivebordet!
+Comment[nds]=De snaakschsten Plots för Dien Schriefdisch!
+Comment[nl]=Zet de wonderlijkste plots op uw bureaublad!
+Comment[pl]=Rysuj najdziwniejsze wykresy na swoim pulpicie!
+Comment[pt]=Coloque os gráficos mais estranhos no seu ecrã!
+Comment[pt_BR]=Coloque os gráficos mais estranhos na sua área de trabalho!
+Comment[ru]=Разместите на рабочем столе причудливые графики!
+Comment[sk]=Vložte najpodivnejšie zákresy na vašu plochu!
+Comment[sl]=Na namizje postavite čudaške grafe!
+Comment[sv]=Rita riktigt konstiga diagram på skrivbordet.
+Comment[tr]=Masaüstünüzde en tuhaf çizimleri koyun!
+Comment[uk]=Розташуйте на вашій стільниці найвигадливіше креслення!
+Comment[x-test]=xxPut the weirdest plots on your desktop!xx
+Comment[zh_CN]=在您的桌面上放上奇怪的图表!
+Comment[zh_TW]=在您的桌面上放最詭異的繪圖!
+Icon=kalgebra
+X-Plasma-API=declarativeappletscript
+X-Plasma-MainScript=ui/main.qml
+X-KDE-PluginInfo-Author=Aleix Pol Gonzalez
+X-KDE-PluginInfo-Email=aleixpol@kde.org
+X-KDE-PluginInfo-Name=org.kde.graphsplasmoid
+X-KDE-PluginInfo-Version=1.0
+X-KDE-PluginInfo-Website=http://edu.kde.org/kalgebra
+X-KDE-PluginInfo-Category=Education
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ef7bb58
--- /dev/null
@@ -0,0 +1,29 @@
+set(kalgebra_SRCS
+    kalgebra.cpp
+    dictionary.cpp
+    #console.cpp
+    consolehtml.cpp
+    varedit.cpp
+    main.cpp
+    variablesdelegate.cpp
+    viewportwidget.cpp
+    functionedit.cpp
+)
+
+#uncomment this if oxygen icons for kalgebra are available
+#kde4_add_app_icon(kalgebra_SRCS "${CMAKE_INSTALL_PREFIX}/share/icons/oxygen/*/apps/kalgebra.png")
+# kde4_add_app_icon(kalgebra_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-kalgebra.png") #FIXME: port!
+
+add_executable(kalgebra ${kalgebra_SRCS})
+target_link_libraries(kalgebra Qt5::Widgets Qt5::PrintSupport Qt5::WebKitWidgets KF5::I18n
+                               KF5::CoreAddons KF5::WidgetsAddons KF5::ConfigWidgets
+                               KF5::XmlGui # HelpMenu
+                               KF5::KIOCore
+                               KF5::I18n
+                               KF5::Analitza KF5::AnalitzaWidgets KF5::AnalitzaGui KF5::AnalitzaPlot)
+
+install(TARGETS kalgebra ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+install(PROGRAMS org.kde.kalgebra.desktop DESTINATION ${KDE_INSTALL_APPDIR} )
+install(FILES kalgebra.xml DESTINATION ${KDE_INSTALL_DATADIR}/katepart5/syntax )
+
+
diff --git a/src/Messages.sh b/src/Messages.sh
new file mode 100755 (executable)
index 0000000..77523eb
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+$XGETTEXT *.cpp -o $podir/kalgebra.pot
diff --git a/src/askname.h b/src/askname.h
new file mode 100644 (file)
index 0000000..b12b2f2
--- /dev/null
@@ -0,0 +1,53 @@
+/*************************************************************************************
+ *  Copyright (C) 2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef ASKNAME_H
+#define ASKNAME_H
+
+#include <QLineEdit>
+#include <QLabel>
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QRegExpValidator>
+
+class AskName : public QDialog
+{
+    public:
+        AskName(const QString& text, QWidget* parent) : QDialog(parent)
+        {
+            edit=new QLineEdit(this);
+            edit->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[a-zA-Z][\\w]*")), edit));
+            
+            QDialogButtonBox * buttonBox;
+            QVBoxLayout *items=new QVBoxLayout(this);
+            items->addWidget(new QLabel(text, this));
+            items->addWidget(edit);
+//             items->addItem(new QSpacerItem());
+            items->addWidget(buttonBox=new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this));
+            
+            connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
+            connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+        }
+        
+        QString name() const { return edit->text(); }
+    private:
+        QLineEdit *edit;
+};
+
+#endif
diff --git a/src/consolehtml.cpp b/src/consolehtml.cpp
new file mode 100644 (file)
index 0000000..a818049
--- /dev/null
@@ -0,0 +1,307 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "consolehtml.h"
+#include <QFile>
+#include <QClipboard>
+#include <QApplication>
+#include <QTemporaryFile>
+#include <qevent.h>
+#include <QDir>
+#include <qurlquery.h>
+#include <QWebFrame>
+
+#include <KStandardAction>
+#include <QMenu>
+#include <KLocalizedString>
+#include <QAction>
+#include <kio/copyjob.h>
+#include <kio/job.h>
+
+#include <analitza/variables.h>
+#include <analitza/expression.h>
+
+ConsoleHtml::ConsoleHtml(QWidget *parent)
+    : QWebView(parent), m_mode(Evaluation)
+{
+    page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+    setRenderHint(QPainter::TextAntialiasing);
+    
+    connect(this, &QWebView::linkClicked, this, &ConsoleHtml::openClickedUrl);
+    
+    QMetaObject::invokeMethod(this, "initialize", Qt::QueuedConnection);
+}
+
+ConsoleHtml::~ConsoleHtml()
+{
+    qDeleteAll(m_options);
+}
+
+void ConsoleHtml::initialize()
+{
+    QPalette p=qApp->palette();
+    
+    m_css ="<style type=\"text/css\">\n";
+    m_css +=QStringLiteral("\thtml { background-color: %1; }\n").arg(p.color(QPalette::Active, QPalette::Base).name()).toLatin1();
+    m_css +="\t.error { border-style: solid; border-width: 1px; border-color: #ff3b21; background-color: #ffe9c4; padding:7px;}\n";
+    m_css +="\t.last  { border-style: solid; border-width: 1px; border-color: #2020ff; background-color: #e0e0ff; padding:7px;}\n";
+    m_css +="\t.before { text-align:right; }\n";
+    m_css +="\t.op  { font-weight: bold; }\n";
+//     m_css +="\t.normal:hover  { border-style: solid; border-width: 1px; border-color: #777; }\n";
+    m_css +="\t.normal:hover  { background-color: #f7f7f7; }\n";
+    m_css +="\t.cont { color: #560000; }\n";
+    m_css +="\t.num { color: #0000C4; }\n";
+    m_css +="\t.sep { font-weight: bold; color: #0000FF; }\n";
+    m_css +="\t.var { color: #640000; }\n";
+    m_css +="\t.keyword { color: #000064; }\n";
+    m_css +="\t.func { color: #008600; }\n";
+    m_css +="\t.result { padding-left: 10%; }\n";
+    m_css +="\t.options { font-size: small; text-align:right }\n";
+    m_css +="\t.string { color: #bb0000 }\n";
+    m_css +="\tli { padding-left: 12px; padding-bottom: 4px; list-style-position: inside; }";
+    m_css +="\tp { font-size: " +QByteArray::number(QFontMetrics(QApplication::font()).height())+ "px; }";
+    m_css +="</style>\n";
+}
+
+void ConsoleHtml::openClickedUrl(const QUrl& url)
+{
+    QUrlQuery query(url);
+    QString id =query.queryItemValue(QStringLiteral("id"));
+    QString exp=query.queryItemValue(QStringLiteral("func"));
+    
+    foreach(InlineOptions* opt, m_options) {
+        if(opt->id() == id) {
+            opt->triggerOption(Analitza::Expression(exp, false));
+        }
+    }
+}
+
+bool ConsoleHtml::addOperation(const Analitza::Expression& e, const QString& input)
+{
+    QString result, newEntry;
+    Analitza::Expression res;
+    
+    a.setExpression(e);
+    if(a.isCorrect()) {
+        if(m_mode==Evaluation) {
+            res=a.evaluate();
+        } else {
+            res=a.calculate();
+        }
+    }
+    
+    QString options;
+    if(a.isCorrect()) {
+        result = res.toHtml();
+        
+        Analitza::Analyzer lambdifier(a.variables());
+        lambdifier.setExpression(res);
+        Analitza::Expression lambdaexp = lambdifier.dependenciesToLambda();
+        lambdifier.setExpression(lambdaexp);
+        
+        Analitza::ExpressionType functype = lambdifier.type();
+        
+        foreach(InlineOptions* opt, m_options) {
+            if(opt->matchesExpression(lambdaexp, functype)) {
+                QUrl url(QStringLiteral("/query"));
+                QUrlQuery query(url);
+                query.addQueryItem(QStringLiteral("id"), opt->id());
+                query.addQueryItem(QStringLiteral("func"), lambdaexp.toString());
+                url.setQuery(query);
+                
+                options += i18n(" <a href='%1'>%2</a>", url.toString(), opt->caption());
+            }
+        }
+        
+        if(!options.isEmpty())
+            options = "<div class='options'>"+i18n("Options: %1", options)+"</div>";
+        
+        a.insertVariable(QStringLiteral("ans"), res);
+        m_script += e; //Script won't have the errors
+        newEntry = QStringLiteral("%1<br />=<span class='result'>%2</span>").arg(e.toHtml()).arg(result);
+    } else {
+        m_htmlLog += i18n("<ul class='error'>Error: <b>%1</b><li>%2</li></ul>", input.toHtmlEscaped(), a.errors().join(QStringLiteral("</li>\n<li>")));
+    }
+    
+    updateView(newEntry, options);
+    
+    return a.isCorrect();
+}
+
+QString temporaryPath()
+{
+    QTemporaryFile temp(QStringLiteral("consolelog"));
+    temp.open();
+    temp.close();
+    temp.setAutoRemove(false);
+    return QDir::tempPath()+'/'+temp.fileName();
+}
+
+QString ConsoleHtml::retrieve(const QUrl& remoteUrl)
+{
+    QString path=temporaryPath();
+    
+    KIO::CopyJob* job=KIO::copyAs(remoteUrl, QUrl(path));
+    
+    bool ret = job->exec();
+    if(!ret)
+        path.clear();
+    
+    return path;
+}
+
+bool ConsoleHtml::loadScript(const QUrl& path)
+{
+    Q_ASSERT(!path.isEmpty());
+    
+    //FIXME: We have expression-only script support
+    bool correct=false;
+    QFile file(path.isLocalFile() ? path.toLocalFile() : retrieve(path));
+    
+    if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+        QTextStream stream(&file);
+        
+        a.importScript(&stream);
+        correct=a.isCorrect();
+    }
+    
+    if(!correct) {
+        m_htmlLog += i18n("<ul class='error'>Error: Could not load %1. <br /> %2</ul>", path.toString(), a.errors().join(QStringLiteral("<br/>")));
+        updateView(QString(), QString());
+    }
+    else
+        updateView(i18n("Imported: %1", path.toString()), QString());
+    
+    return correct;
+}
+
+bool ConsoleHtml::saveScript(const QUrl & path) const
+{
+    bool correct=false;
+    Q_ASSERT(!path.isEmpty());
+        
+    QString savePath=path.isLocalFile() ?  path.toLocalFile() : temporaryPath();
+    QFile file(savePath);
+    correct=file.open(QIODevice::WriteOnly | QIODevice::Text);
+    
+    if(correct) {
+        QTextStream out(&file);
+        foreach(const Analitza::Expression& exp, m_script)
+            out << exp.toString() << endl;
+    }
+    
+    if(!path.isLocalFile()) {
+        KIO::CopyJob* job=KIO::move(QUrl(savePath), path);
+        correct=job->exec();
+    }
+    return correct;
+}
+
+bool ConsoleHtml::saveLog(const QUrl& path) const
+{
+    Q_ASSERT(!path.isEmpty());
+    //FIXME: We have to choose between txt and html
+    bool correct=false;
+    QString savePath=path.isLocalFile() ?  path.toLocalFile() : temporaryPath();
+    QFile file(savePath);
+    correct=file.open(QIODevice::WriteOnly | QIODevice::Text);
+    
+    if(correct) {
+        QTextStream out(&file);
+        out << "<html>\n<head>" << m_css << "</head>" << endl;
+        out << "<body>" << endl;
+        foreach(const QString &entry, m_htmlLog)
+            out << "<p>" << entry << "</p>" << endl;
+        out << "</body>\n</html>" << endl;
+    }
+    
+    if(!path.isLocalFile()) {
+        KIO::CopyJob* job=KIO::move(QUrl(savePath), path);
+        correct=job->exec();
+    }
+    return correct;
+}
+
+void ConsoleHtml::updateView(const QString& newEntry, const QString& options)
+{
+    QByteArray code;
+    code += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
+    code += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<title> :) </title>\n";
+    code += m_css;
+    code += "</head>\n<body>";
+    foreach(const QString &entry, m_htmlLog)
+        code += "<p class='normal'>"+entry.toUtf8()+"</p>";
+
+    if(!newEntry.isEmpty()) {
+        m_htmlLog += newEntry;
+        code += options.toUtf8();
+        code += "<p class='last'>"+newEntry.toUtf8()+"</p>";
+    }
+    code += "</body></html>";
+
+    setContent(code);
+    
+    emit changed();
+
+    QWebFrame* mf = page()->mainFrame();
+    mf->setScrollBarValue(Qt::Vertical, mf->scrollBarMaximum(Qt::Vertical));
+}
+
+void ConsoleHtml::copy() const
+{
+    QApplication::clipboard()->setText(selectedText());
+}
+
+void ConsoleHtml::contextMenuEvent(QContextMenuEvent* ev)
+{
+    QMenu popup;
+    if(hasSelection()) {
+        popup.addAction(KStandardAction::copy(this, SLOT(copy()), &popup));
+        QAction *act=new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), i18n("Paste \"%1\" to input", selectedText()), &popup);
+        connect(act, SIGNAL(triggered()), SLOT(paste()));
+        popup.addAction(act);
+        popup.addSeparator();
+    }
+    popup.addAction(KStandardAction::clear(this, SLOT(clear()), &popup));
+    
+    popup.exec(ev->pos());
+}
+
+void ConsoleHtml::clear()
+{
+    m_script.clear();
+    m_htmlLog.clear();
+    updateView(QString(), QString());
+}
+
+void ConsoleHtml::modifyVariable(const QString& name, const Analitza::Expression& exp)
+{
+    a.variables()->modify(name, exp);
+}
+
+void ConsoleHtml::removeVariable(const QString & name)
+{
+    a.variables()->remove(name);
+}
+
+void ConsoleHtml::paste()
+{
+    emit paste(selectedText());
+}
+
+
diff --git a/src/consolehtml.h b/src/consolehtml.h
new file mode 100644 (file)
index 0000000..f4cad41
--- /dev/null
@@ -0,0 +1,126 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include <QWidget>
+#include <QWebView>
+
+#include <analitza/analyzer.h>
+
+class InlineOptions
+{
+    public:
+        virtual ~InlineOptions() {}
+        
+        virtual QString id() const = 0;
+        virtual QString caption() const = 0;
+        virtual bool matchesExpression(const Analitza::Expression& exp, const Analitza::ExpressionType& functype) const = 0;
+        virtual void triggerOption(const Analitza::Expression& exp) = 0;
+};
+
+/**
+ *    The Console widget is able to receive an operation, solve it and show the value.
+ *    It also is able to load scripts and save logs.
+ *    @author Aleix Pol Gonzalez
+ */
+
+class ConsoleHtml : public QWebView
+{
+    Q_OBJECT
+    public:
+        /** This enumeration controles the way the console will calculate and show his results. */
+        enum ConsoleMode {
+            Evaluation, /**< Simplifies the expression, tries to simplify when sees a variable not defined. */
+            Calculation /**< Calculates everything, if it finds a not defined variable shows an error. */
+        };
+        
+        /** Constructor. Creates a console widget. */
+        ConsoleHtml(QWidget *parent = 0);
+        
+        /** Destructor. */
+        virtual ~ConsoleHtml();
+        
+        /** Retrieves a pointer to the Analitza calculator associated. */
+        Analitza::Analyzer* analitza() { return &a; }
+        
+        /** Sets a @p newMode console mode. */
+        void setMode(ConsoleMode newMode) { m_mode = newMode; }
+        
+        /** Retrieves the console mode. */
+        ConsoleMode mode() const { return m_mode; }
+        
+        void addOptionsObserver(InlineOptions* opt) { m_options += opt; }
+
+        virtual void contextMenuEvent(QContextMenuEvent* ev);
+
+    public Q_SLOTS:
+        /** Adds the operation defined by the expression @p e. */
+        bool addOperation(const Analitza::Expression& e, const QString& input);
+        
+        /** Loads a script from @p path. */
+        bool loadScript(const QUrl& path);
+        
+        /** Save a script yo @p path. */
+        bool saveScript(const QUrl& path) const;
+        
+        /** Saves a log to @p path. */
+        bool saveLog(const QUrl& path) const;
+        
+        /** Flushes the contents. */
+        void clear();
+        
+        /** Copies the selected text to the clipboard */
+        void copy() const;
+        
+        void openClickedUrl(const QUrl& url);
+        
+    Q_SIGNALS:
+        /** Emits a notification that tells that the widget status. */
+        void status(const QString &msg);
+        
+        /** Emits that something has changed. */
+        void changed();
+        
+        /** Emits the selected code to be pasted somewhere */
+        void paste(const QString& code);
+        
+    private Q_SLOTS:
+        void initialize();
+        
+        void modifyVariable(const QString& name, const Analitza::Expression& exp);
+        void removeVariable(const QString& name);
+        void paste();
+        
+    private:
+        QString retrieve(const QUrl& remoteUrl);
+        
+        Analitza::Analyzer a;
+        void sendStatus(const QString& msg) { emit status(msg); }
+        ConsoleMode m_mode;
+        QList<Analitza::Expression> m_script;
+        QStringList m_htmlLog;
+        
+        void updateView(const QString& newEntry, const QString& options);
+        
+        QByteArray m_css;
+        QList<InlineOptions*> m_options;
+};
+
+#endif
diff --git a/src/dictionary.cpp b/src/dictionary.cpp
new file mode 100644 (file)
index 0000000..a345959
--- /dev/null
@@ -0,0 +1,124 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "dictionary.h"
+#include <analitza/variables.h>
+#include <analitza/expression.h>
+#include <analitzagui/operatorsmodel.h>
+#include <analitzagui/plotsview2d.h>
+#include <analitzaplot/plotsmodel.h>
+#include <analitzaplot/plotsfactory.h>
+#include <analitzaplot/functiongraph.h>
+
+#include <QLabel>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QFormLayout>
+#include <klocalizedstring.h>
+
+Dictionary::Dictionary(QWidget *p) : QWidget(p)
+{
+    m_ops=new OperatorsModel(this);
+    m_sortProxy = new QSortFilterProxyModel(this);
+    m_sortProxy->setSourceModel(m_ops);
+    m_sortProxy->sort(2, Qt::AscendingOrder);
+    m_sortProxy->setFilterKeyColumn(2);
+
+    m_vars = new Analitza::Variables;
+
+    QGroupBox *descr=new QGroupBox(i18n("Information"), this);
+    descr->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    QFormLayout *descrLayo=new QFormLayout;
+    QVBoxLayout *graphLayo=new QVBoxLayout(this);
+    m_name=new QLabel(descr);
+    m_descr=new QLabel(descr);
+    m_sample=new QLabel(descr);
+    m_example=new QLabel(descr);
+    m_funcs=new Analitza::PlotsModel(descr);
+    m_graph=new Analitza::PlotsView2D(descr);
+    m_graph->setTicksShown(0);
+    m_graph->setModel(m_funcs);
+    m_graph->setReadOnly(true);
+    m_graph->setViewport(QRect(QPoint(-30, 7), QPoint(30, -7)));
+    m_graph->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+    m_name->setIndent(10);
+    m_descr->setIndent(10);
+    m_sample->setIndent(10);
+    m_example->setIndent(10);
+
+    m_example->setTextInteractionFlags(Qt::TextSelectableByMouse);
+
+    descrLayo->addRow(i18n("<b>%1</b>", m_ops->headerData(0, Qt::Horizontal).toString()), m_name);
+    descrLayo->addRow(i18n("<b>%1</b>", m_ops->headerData(1, Qt::Horizontal).toString()), m_descr);
+    descrLayo->addRow(i18n("<b>%1</b>", m_ops->headerData(2, Qt::Horizontal).toString()), m_sample);
+    descrLayo->addRow(i18n("<b>%1</b>", m_ops->headerData(3, Qt::Horizontal).toString()), m_example);
+     descrLayo->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
+    graphLayo->addWidget(descr);
+    graphLayo->addWidget(m_graph);
+    descr->setLayout(descrLayo);
+
+    m_funcs->clear();
+//     connect(m_list, SIGNAL(clicked(QModelIndex)), this, SLOT(activated(QModelIndex)));
+}
+
+Dictionary::~Dictionary()
+{
+    delete m_vars;
+}
+
+void Dictionary::activated(const QModelIndex& idx, const QModelIndex& prev)
+{
+    Q_UNUSED(prev);
+
+    m_funcs->clear();
+    if(idx.isValid()) {
+        QModelIndex nameIdx, descriptionIdx, sampleIdx, exampleIdx;
+        nameIdx = idx.sibling(idx.row(), 0);
+        descriptionIdx = idx.sibling(idx.row(), 1);
+        sampleIdx = idx.sibling(idx.row(), 2);
+        exampleIdx = idx.sibling(idx.row(), 3);
+
+        QString name=m_sortProxy->data(nameIdx).toString();
+        QString description=m_sortProxy->data(descriptionIdx).toString();
+        QString sample=m_sortProxy->data(sampleIdx).toString();
+        QString example=m_sortProxy->data(exampleIdx).toString();
+
+        Analitza::Expression e(example, false);
+
+        m_name->setText(name);
+        m_descr->setText(description);
+        m_sample->setText(sample);
+        m_example->setText(example);
+
+        m_funcs->addPlot(Analitza::PlotsFactory::self()->requestPlot(e, Analitza::Dim2D, m_vars).create(QColor(0,150,0), QStringLiteral("dict")));
+    } else {
+        QString error;
+        m_name->setText(QString());
+        m_descr->setText(QString());
+        m_sample->setText(QString());
+        m_example->setText(QString());
+    }
+}
+
+void Dictionary::setFilter(const QString &filter)
+{
+    m_sortProxy->setFilterFixedString(filter);
+}
+
+
diff --git a/src/dictionary.h b/src/dictionary.h
new file mode 100644 (file)
index 0000000..d95fd03
--- /dev/null
@@ -0,0 +1,65 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef DICTIONARY_H
+#define DICTIONARY_H
+
+#include <QWidget>
+#include <QSortFilterProxyModel>
+
+namespace Analitza
+{
+class Variables;
+class PlotsView2D;
+class PlotsModel;
+}
+
+class QLabel;
+class QModelIndex;
+class OperatorsModel;
+
+/**
+    @author Aleix Pol
+*/
+class Dictionary : public QWidget
+{
+Q_OBJECT
+    public:
+        Dictionary(QWidget *p=0);
+        virtual ~Dictionary();
+        
+        QSortFilterProxyModel* model() const { return m_sortProxy; }
+        
+    public Q_SLOTS:
+        void activated(const QModelIndex& prev, const QModelIndex& );
+        void setFilter(const QString&);
+        
+    private:
+        QLabel *m_name;
+        QLabel *m_descr;
+        QLabel *m_sample;
+        QLabel *m_example;
+        
+        Analitza::PlotsView2D *m_graph;
+        Analitza::PlotsModel *m_funcs;
+        OperatorsModel *m_ops;
+        Analitza::Variables* m_vars;
+        QSortFilterProxyModel *m_sortProxy;
+};
+
+#endif
diff --git a/src/functionedit.cpp b/src/functionedit.cpp
new file mode 100644 (file)
index 0000000..be9285e
--- /dev/null
@@ -0,0 +1,321 @@
+/*************************************************************************************
+ *  Copyright (C) 2007-2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "functionedit.h"
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+
+#include <KColorScheme>
+
+#include <analitzagui/expressionedit.h>
+#include <analitza/analyzer.h>
+#include <analitza/expression.h>
+#include <analitza/variables.h>
+#include <analitza/value.h>
+#include <analitzagui/algebrahighlighter.h>
+#include <analitzagui/plotsview2d.h>
+#include <analitzaplot/planecurve.h>
+#include <analitzaplot/plotsmodel.h>
+#include <analitzaplot/plotsfactory.h>
+#include <klocalizedstring.h>
+
+using namespace Analitza;
+
+namespace {
+    static const int resolution = 200;
+}
+
+FunctionEdit::FunctionEdit(QWidget *parent)
+    : QWidget(parent), m_calcUplimit(0), m_calcDownlimit(0), m_modmode(false)
+{
+    setWindowTitle(i18n("Add/Edit a function"));
+    
+    QVBoxLayout *topLayout = new QVBoxLayout(this);
+    topLayout->setMargin(2);
+    topLayout->setSpacing(5);
+    
+    m_name = new QLineEdit(this);
+    
+    m_func = new ExpressionEdit(this);
+    m_func->setExamples(PlotsFactory::self()->examples(Dim2D));
+    m_func->setAns(QStringLiteral("x"));
+    connect(m_func, &QPlainTextEdit::textChanged, this, &FunctionEdit::edit);
+    connect(m_func, &ExpressionEdit::returnPressed, this, &FunctionEdit::ok);
+    
+    m_valid = new QLabel(this);
+    m_valid->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+    
+    QPalette p=palette();
+    p.setColor(QPalette::Active, QPalette::Base, Qt::white);
+    m_valid->setPalette(p);
+    
+    m_validIcon = new QLabel(this);
+    m_validIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    QLayout* validLayout=new QHBoxLayout;
+    validLayout->addWidget(m_validIcon);
+    validLayout->addWidget(m_valid);
+    
+    m_color = new KColorCombo(this);
+    m_color->setColor(QColor(0,150,0));
+    connect(m_color, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChange(int)));
+    
+    m_funcsModel=new PlotsModel(this);
+    m_funcsModel->setResolution(resolution);
+    
+    m_viewTabs=new QTabWidget(this);
+    
+    m_graph = new PlotsView2D(m_viewTabs);
+    m_graph->setModel(m_funcsModel);
+    m_graph->setViewport(QRectF(QPointF(-10.0, 10.0), QSizeF(20.0, -20.0)));
+    m_graph->setFocusPolicy(Qt::NoFocus);
+    m_graph->setMouseTracking(false);
+    m_graph->setFramed(true);
+    m_graph->setReadOnly(true);
+    m_graph->setTicksShown(Qt::Orientation(0));
+    
+    m_viewTabs->addTab(m_graph, QIcon::fromTheme(QStringLiteral("document-preview")), i18n("Preview"));
+    QWidget *options=new QWidget(m_viewTabs);
+    options->setLayout(new QVBoxLayout);
+    m_uplimit=new ExpressionEdit(options);
+    m_downlimit=new ExpressionEdit(options);
+    m_uplimit->setText(QStringLiteral("2*pi"));
+    m_downlimit->setText(QStringLiteral("0"));
+    options->layout()->addWidget(new QLabel(i18n("From:"), options));
+    options->layout()->addWidget(m_downlimit);
+    options->layout()->addWidget(new QLabel(i18n("To:"), options));
+    options->layout()->addWidget(m_uplimit);
+    options->layout()->addItem(new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Expanding));
+    m_viewTabs->addTab(options, QIcon::fromTheme(QStringLiteral("configure")), i18n("Options"));
+    connect(m_uplimit, &QPlainTextEdit::textChanged, this, &FunctionEdit::updateUplimit);
+    connect(m_downlimit, &QPlainTextEdit::textChanged, this, &FunctionEdit::updateDownlimit);
+    
+    QHBoxLayout *m_butts = new QHBoxLayout;
+    m_ok = new QPushButton(i18n("OK"), this);
+    m_ok->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
+    m_remove = new QPushButton(i18nc("@action:button", "Remove"), this);
+    m_remove->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
+    connect(m_ok, &QAbstractButton::clicked, this, &FunctionEdit::ok);
+    connect(m_remove, &QAbstractButton::clicked, this, &FunctionEdit::removeEditingPlot);
+    
+    topLayout->addWidget(m_name);
+    topLayout->addWidget(m_func);
+    topLayout->addWidget(m_color);
+    topLayout->addLayout(validLayout);
+    topLayout->addWidget(m_viewTabs);
+    topLayout->addLayout(m_butts);
+    
+    m_name->hide(); //FIXME: Remove this when the name has any sense
+    
+    m_butts->addWidget(m_ok);
+    m_butts->addWidget(m_remove);
+    
+    m_func->setFocus();
+    m_ok->setEnabled(false);
+    
+    QFont errorFont=m_valid->font();
+    errorFont.setBold(true);
+    m_valid->setFont(errorFont);
+}
+
+FunctionEdit::~FunctionEdit()
+{}
+
+void FunctionEdit::clear()
+{
+    m_func->setText(QString());
+    m_funcsModel->clear();
+    edit();
+}
+
+void FunctionEdit::setFunction(const QString &newText)
+{
+    m_func->setText(newText);
+    m_func->document()->setModified(true);
+}
+
+void FunctionEdit::setColor(const QColor &newColor)
+{
+    m_color->setColor(newColor);
+    if(m_funcsModel->rowCount()>0)
+          m_funcsModel->setData(m_funcsModel->index(0), newColor);
+}
+
+void FunctionEdit::colorChange(int)
+{
+    setColor(m_color->color());
+}
+
+static double calcExp(const Analitza::Expression& exp, Analitza::Variables* v, bool* corr)
+{
+    Q_ASSERT(exp.isCorrect());
+    Analitza::Analyzer d(v);
+    d.setExpression(exp);
+    Analitza::Expression r=d.calculate();
+    
+    *corr=r.isCorrect() && r.isReal();
+    
+    if(*corr)
+        return r.toReal().value();
+    else
+        return 0.;
+}
+
+void FunctionEdit::updateUplimit()
+{
+    bool corr = m_uplimit->isCorrect();
+    if(corr) {
+        Analitza::Expression e=m_uplimit->expression();
+        m_calcUplimit=calcExp(e, m_vars, &corr);
+        m_uplimit->setCorrect(corr);
+        if(corr)
+            edit();
+    }
+}
+
+void FunctionEdit::updateDownlimit()
+{
+    bool corr = m_downlimit->isCorrect();
+    if(corr) {
+        Analitza::Expression e=m_downlimit->expression();
+        m_calcDownlimit=calcExp(e, m_vars, &corr);
+        m_downlimit->setCorrect(corr);
+        if(corr)
+            edit();
+    }
+}
+
+void FunctionEdit::setState(const QString& text, bool negative)
+{
+    QFontMetrics fm(m_valid->font());
+    m_valid->setText(fm.elidedText(text, Qt::ElideRight, m_valid->width()));
+    m_valid->setToolTip(text);
+    
+    KColorScheme scheme(QPalette::Normal);
+    KColorScheme::ForegroundRole role = negative? KColorScheme::NegativeText : KColorScheme::PositiveText;
+    
+    QPalette p=m_valid->palette();
+    p.setColor(foregroundRole(), scheme.foreground(role).color());
+    m_valid->setPalette(p);
+    
+    if(negative)
+        m_validIcon->setPixmap(QIcon::fromTheme(QStringLiteral("flag-red")).pixmap(QSize(16,16)));
+    else
+        m_validIcon->setPixmap(QIcon::fromTheme(QStringLiteral("flag-green")).pixmap(QSize(16,16)));
+}
+
+///Let's see if the exp is correct
+void FunctionEdit::edit()
+{
+    if(m_func->text().isEmpty()) {
+        m_func->setCorrect(true);
+        m_ok->setEnabled(false);
+        m_valid->clear();
+        m_valid->setToolTip(QString());
+        m_validIcon->setPixmap(QIcon::fromTheme(QStringLiteral("flag-yellow")).pixmap(QSize(16,16)));
+        
+        m_funcsModel->clear();
+        m_graph->forceRepaint();
+        return;
+    }
+    
+    if(!m_uplimit->isCorrect() || !m_downlimit->isCorrect()) {
+        setState(i18n("The options you specified are not correct"), true);
+        return;
+    }
+    
+    if(m_calcDownlimit>m_calcUplimit) {
+        setState(i18n("Downlimit cannot be greater than uplimit"), true);
+        return;
+    }
+    bool added = false;
+    
+    PlaneCurve* f = 0;
+    PlotBuilder req = PlotsFactory::self()->requestPlot(expression(), Dim2D, m_vars);
+    if(req.canDraw())
+        f = createFunction();
+    
+    if(f && f->isCorrect())
+        f->update(QRect(-10, 10, 20, -20));
+    
+    m_funcsModel->clear();
+    if(f && f->isCorrect()) {
+        m_funcsModel->addPlot(f);
+        added=true;
+        setState(QStringLiteral("%1:=%2")
+            .arg(m_name->text()).arg(f->expression().toString()), false);
+    } else {
+        QStringList errors = req.errors();
+        if(f)
+            errors = f->errors();
+        Q_ASSERT(!errors.isEmpty());
+        
+        setState(errors.first(), true);
+        m_valid->setToolTip(errors.join(QStringLiteral("<br />")));
+        delete f;
+    }
+    m_func->setCorrect(added);
+    m_ok->setEnabled(added);
+}
+
+void FunctionEdit::ok()
+{
+    if(m_ok->isEnabled())
+        emit accept();
+}
+
+void FunctionEdit::focusInEvent(QFocusEvent *)
+{
+    m_func->setFocus();
+}
+
+PlaneCurve* FunctionEdit::createFunction() const
+{
+    PlotBuilder req = PlotsFactory::self()->requestPlot(expression(), Dim2D, m_vars);
+    PlaneCurve* curve = static_cast<PlaneCurve*>(req.create(color(), name()));
+    curve->setResolution(resolution);
+    if(m_calcUplimit != m_calcDownlimit) {
+        foreach(const QString& var, curve->parameters())
+            curve->setInterval(var, m_calcUplimit, m_calcDownlimit);
+    }
+    return curve;
+}
+
+Analitza::Expression FunctionEdit::expression() const
+{
+    return m_func->expression();
+}
+
+void FunctionEdit::setOptionsShown(bool shown)
+{
+    m_viewTabs->setVisible(shown);
+}
+
+void FunctionEdit::resizeEvent(QResizeEvent*)
+{
+    QFontMetrics fm(m_valid->font());
+    m_valid->setText(fm.elidedText(m_valid->toolTip(), Qt::ElideRight, m_valid->width()));
+}
+
+void FunctionEdit::setEditing(bool m)
+{
+    m_modmode=m;
+    m_remove->setVisible(m);
+}
diff --git a/src/functionedit.h b/src/functionedit.h
new file mode 100644 (file)
index 0000000..daaf767
--- /dev/null
@@ -0,0 +1,129 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef FUNCTIONEDIT_H
+#define FUNCTIONEDIT_H
+
+#include <QLabel>
+#include <QWidget>
+#include <QPushButton>
+#include <QLineEdit>
+
+#include <KColorCombo>
+
+class QTabWidget;
+namespace Analitza
+{
+class Variables;
+class Expression;
+class PlotsView2D;
+class PlotsModel;
+class PlaneCurve;
+class ExpressionEdit;
+}
+
+/**
+ *    The FunctionEdit dialog provides a way to specify functions.
+ *    @author Aleix Pol i Gonzalez
+ */
+
+class FunctionEdit : public QWidget
+{
+Q_OBJECT
+public:
+    /** Constructor. */
+    explicit FunctionEdit(QWidget *parent=0);
+    
+    /** Destructor. */
+    ~FunctionEdit();
+    
+    /** Retrieves the resulting expression text. */
+    Analitza::Expression expression() const;
+    
+    Analitza::PlaneCurve* createFunction() const;
+    
+    /** Sets an expression text to the ExpressionEdit widget. */
+    void setFunction(const QString &newText);
+    
+    /** Retrieves the selected color for the function */
+    QColor color() const { return m_color->color(); }
+    
+    /** Sets the selected color for the function.*/
+    void setColor(const QColor &newColor);
+    
+    /** Returns whether we are editing or adding a function. */
+    bool editing() const { return m_modmode; }
+    
+    /** Sets whether we are editing or adding a function. */
+    void setEditing(bool m);
+    
+    /** Sets a name to the function. (Not used YET) */
+    void setName(const QString& name) { m_name->setText(name); }
+    
+    /** Retrieves a name for the function. (Not used YET) */
+    QString name() const { return m_name->text(); }
+    
+    /** Sets the variables class to be used with the graph functions*/
+    void setVariables(Analitza::Variables* v) { m_vars=v; }
+    
+    Analitza::Variables* variables() const { return m_vars; }
+    
+    void setOptionsShown(bool shown);
+    
+    virtual void resizeEvent(QResizeEvent* ev);
+    
+public Q_SLOTS:
+    /** Clears the dialog. */
+    void clear();
+    
+Q_SIGNALS:
+    /** Tells that the result has been accepted. */
+    void accept();
+    
+    /** asks the currently edited plot to be removed. */
+    void removeEditingPlot();
+    
+private Q_SLOTS:
+    void edit();
+    void ok();
+    void colorChange(int);
+    void updateUplimit();
+    void updateDownlimit();
+    
+private:
+    void setState(const QString& text, bool negative);
+    void focusInEvent(QFocusEvent*);
+    
+    Analitza::ExpressionEdit *m_func;
+    Analitza::ExpressionEdit *m_uplimit, *m_downlimit;
+    double m_calcUplimit, m_calcDownlimit;
+    QLineEdit *m_name;
+    QPushButton *m_ok;
+    QLabel *m_valid;
+    QLabel *m_validIcon;
+    Analitza::PlotsView2D *m_graph;
+    KColorCombo *m_color;
+    Analitza::PlotsModel *m_funcsModel;
+    Analitza::Variables* m_vars = nullptr;
+    
+    bool m_modmode;
+    QTabWidget* m_viewTabs;
+    QPushButton* m_remove;
+};
+
+#endif
diff --git a/src/kalgebra.cpp b/src/kalgebra.cpp
new file mode 100644 (file)
index 0000000..a814e70
--- /dev/null
@@ -0,0 +1,749 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "kalgebra.h"
+#include "varedit.h"
+#include "consolehtml.h"
+#include "dictionary.h"
+#include "askname.h"
+#include "variablesdelegate.h"
+#include "viewportwidget.h"
+#include "functionedit.h"
+#ifdef HAVE_OPENGL
+#    include <analitzagui/plotsview3d.h>
+#endif
+
+#include <analitzagui/operatorsmodel.h>
+#include <analitzagui/expressionedit.h>
+#include <analitzagui/variablesmodel.h>
+#include <analitzagui/plotsview2d.h>
+#include <analitzaplot/plotsmodel.h>
+#include <analitzaplot/functiongraph.h>
+#include <analitzaplot/planecurve.h>
+#include <analitzaplot/plotsfactory.h>
+#include <analitza/variables.h>
+#include <analitza/value.h>
+
+#include <QVBoxLayout>
+#include <QHeaderView>
+#include <QDockWidget>
+#include <QTableView>
+#include <QPrinter>
+#include <QAction>
+#include <QFileDialog>
+#include <QStatusBar>
+#include <QMenuBar>
+#include <QToolButton>
+#include <QApplication>
+#include <klocalizedstring.h>
+#include <KHelpMenu>
+#include <KStandardAction>
+#include <KToggleFullScreenAction>
+#include <KRecentFilesAction>
+#include <kconfig.h>
+#include <QProcess>
+#include <QPointer>
+#include <kconfiggroup.h>
+
+class Add2DOption : public InlineOptions
+{
+    public:
+        Add2DOption(KAlgebra* c)
+        : m_kalgebra(c)
+        {}
+        
+        virtual QString id() const { return QStringLiteral("add2d"); }
+        virtual bool matchesExpression(const Analitza::Expression& exp, const Analitza::ExpressionType& /*functype*/) const {
+            return Analitza::PlotsFactory::self()->requestPlot(exp, Analitza::Dim2D).canDraw();
+        }
+
+        virtual QString caption() const { return i18n("Plot 2D"); }
+
+        virtual void triggerOption(const Analitza::Expression& exp) { m_kalgebra->add2D(exp); }
+    
+    private:
+        KAlgebra* m_kalgebra;
+};
+
+#ifdef HAVE_OPENGL
+class Add3DOption : public InlineOptions
+{
+    public:
+        Add3DOption(KAlgebra* c)
+        : m_kalgebra(c)
+        {}
+        
+        virtual QString id() const { return QStringLiteral("add3d"); }
+        virtual bool matchesExpression(const Analitza::Expression& exp, const Analitza::ExpressionType& /*functype*/) const
+        {
+            return Analitza::PlotsFactory::self()->requestPlot(exp, Analitza::Dim3D).canDraw();
+        }
+
+        virtual QString caption() const { return i18n("Plot 3D"); }
+
+        virtual void triggerOption(const Analitza::Expression& exp) { m_kalgebra->add3D(exp); }
+    
+    private:
+        KAlgebra* m_kalgebra;
+};
+#endif
+
+QColor randomFunctionColor() { return QColor::fromHsv(qrand()%255, 255, 255); }
+
+KAlgebra::KAlgebra(QWidget *parent)
+    : QMainWindow(parent)
+{
+    resize(900, 500);
+    
+    m_tabs = new QTabWidget;
+    setCentralWidget(m_tabs);
+    
+    setStatusBar(new QStatusBar(this));
+    setMenuBar(new QMenuBar(this));
+    
+    KToggleFullScreenAction* fullScreenAction = KStandardAction::fullScreen(this, SLOT(fullScreen(bool)), this, this);
+    
+    QMenu* g_menu = menuBar()->addMenu(i18n("Session"));
+    g_menu->addAction(KStandardAction::openNew(this, SLOT(newInstance()), this));
+    g_menu->addAction(fullScreenAction);
+    g_menu->addAction(KStandardAction::quit(this, SLOT(close()), this));
+    
+    QToolButton* fullScreenButton = new QToolButton(this);
+    fullScreenButton->setDefaultAction(fullScreenAction);
+    m_tabs->setCornerWidget(fullScreenButton);
+    
+    m_status = new QLabel(this);
+    statusBar()->insertWidget(0, m_status);
+    menuBar()->addMenu(QStringLiteral("|"))->setEnabled(false);
+    
+    ///////Console
+    QWidget *console = new QWidget(m_tabs);
+    QVBoxLayout *c_layo = new QVBoxLayout(console);
+    c_results = new ConsoleHtml(console);
+    c_results->setFocusPolicy(Qt::NoFocus);
+    c_dock_vars = new QDockWidget(i18n("Variables"), this);
+    c_dock_vars->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
+    addDockWidget(Qt::RightDockWidgetArea, c_dock_vars);
+    
+    c_varsModel=new Analitza::VariablesModel(c_results->analitza()->variables());
+    c_varsModel->setEditable(false);
+    
+    c_variables = new QTreeView(c_dock_vars);
+    c_variables->setModel(c_varsModel);
+    c_variables->setRootIsDecorated(false);
+    c_variables->header()->setStretchLastSection(true);
+    c_variables->setSelectionBehavior(QAbstractItemView::SelectRows);
+    c_variables->setSelectionMode(QAbstractItemView::SingleSelection);
+    
+    c_exp = new Analitza::ExpressionEdit(console);
+    c_exp->setAnalitza(c_results->analitza());
+    c_exp->setExamples(QStringList() << QStringLiteral("square:=x->x**2") << QStringLiteral("fib:=n->piecewise { eq(n,0)?0, eq(n,1)?1, ?fib(n-1)+fib(n-2) }"));
+    c_dock_vars->setWidget(c_variables);
+    
+    m_tabs->addTab(console, i18n("&Calculator"));
+    console->setLayout(c_layo);
+    c_layo->addWidget(c_results);
+    c_layo->addWidget(c_exp);
+    
+    connect(c_exp, &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::operate);
+    connect(c_results, &ConsoleHtml::status, this, &KAlgebra::changeStatusBar);
+    connect(c_results, &ConsoleHtml::changed, this, &KAlgebra::updateInformation);
+    connect(c_results, SIGNAL(changed()), c_exp, SLOT(updateCompleter()));
+    connect(c_results, SIGNAL(paste(QString)), c_exp, SLOT(insertText(QString)));
+    connect(c_variables, &QAbstractItemView::clicked, this, &KAlgebra::edit_var);
+    ////////menu
+    c_menu = menuBar()->addMenu(i18n("C&alculator"));
+    
+    c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("@item:inmenu", "&Load Script..."),
+                        this, SLOT(loadScript()), Qt::CTRL+Qt::Key_L);
+    c_recentScripts=new KRecentFilesAction(QIcon::fromTheme(QStringLiteral("document-open-recent")), i18n("Recent Scripts"), this);
+    connect(c_recentScripts, SIGNAL(urlSelected(QUrl)), this, SLOT(loadScript(QUrl)));
+    c_menu->addAction(c_recentScripts);
+    
+    c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-save")), i18nc("@item:inmenu", "&Save Script..."),
+                        this, SLOT(saveScript()), Qt::CTRL+Qt::Key_G);
+    c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-save")), i18nc("@item:inmenu", "&Export Log..."),
+                        this, SLOT(saveLog()), QKeySequence::Save);
+    c_menu->addSeparator()->setText(i18n("Execution Mode"));
+    QActionGroup *execGroup = new QActionGroup(c_menu);
+    QAction* calc = c_menu->addAction(i18nc("@item:inmenu", "Calculate"), this, SLOT(consoleCalculate()));
+    QAction* eval = c_menu->addAction(i18nc("@item:inmenu", "Evaluate"), this, SLOT(consoleEvaluate()));
+    
+    calc->setCheckable(true);
+    eval->setCheckable(true);
+    eval->setChecked(true);
+    execGroup->addAction(calc);
+    execGroup->addAction(eval);
+    c_menu->addSeparator();
+    c_menu->addAction(KStandardAction::clear(c_results, SLOT(clear()), this));
+    initializeRecentScripts();
+    ////////////
+    //////EOConsola
+    
+    //////2D Graph
+    b_funcsModel=new Analitza::PlotsModel(this);
+    
+    m_graph2d = new Analitza::PlotsView2D(m_tabs);
+    m_graph2d->setTicksShown(0);
+    m_graph2d->setModel(b_funcsModel);
+    
+    b_dock_funcs = new QDockWidget(i18n("Functions"), this);
+    b_tools = new QTabWidget(b_dock_funcs);
+    b_tools->setTabPosition(QTabWidget::South);
+    addDockWidget(Qt::RightDockWidgetArea, b_dock_funcs);
+    
+    b_funcs = new QTreeView(b_tools);
+    b_funcs->setRootIsDecorated(false);
+    b_funcs->setModel(b_funcsModel);
+    b_funcs->header()->resizeSections(QHeaderView::ResizeToContents);
+    b_funcs->setSelectionMode(QAbstractItemView::SingleSelection);
+    m_graph2d->setSelectionModel(b_funcs->selectionModel());
+    
+    b_tools->addTab(b_funcs, i18n("List"));
+    
+    b_funced = new FunctionEdit(b_tools);
+    b_funced->setVariables(c_varsModel->variables());
+    connect(b_funced, &FunctionEdit::accept, this, &KAlgebra::new_func);
+    connect(b_funced, &FunctionEdit::removeEditingPlot, this, &KAlgebra::remove_func);
+    b_tools->addTab(b_funced, QIcon::fromTheme(QStringLiteral("list-add")), i18n("&Add"));
+    
+    QTableView* b_varsView=new QTableView(b_tools);
+    b_varsModel=new Analitza::VariablesModel(b_funced->variables());
+    b_varsView->setModel(b_varsModel);
+    b_varsView->setShowGrid(false);
+    b_varsView->verticalHeader()->hide();
+    b_varsView->horizontalHeader()->setStretchLastSection(true);
+    b_varsView->setSelectionBehavior(QAbstractItemView::SelectRows);
+    b_varsView->setContextMenuPolicy(Qt::CustomContextMenu);
+    VariablesDelegate* delegate=new VariablesDelegate(b_varsView);
+    b_varsView->setItemDelegate(delegate);
+    b_tools->addTab(b_varsView, i18n("Variables"));
+    
+    ViewportWidget* b_viewport = new ViewportWidget(this);
+    b_viewport->setViewport(m_graph2d->definedViewport());
+    b_tools->addTab(b_viewport, i18n("Viewport"));
+    
+    b_dock_funcs->setWidget(b_tools);
+    b_dock_funcs->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
+    m_tabs->addTab(m_graph2d, i18n("&2D Graph"));
+    c_results->addOptionsObserver(new Add2DOption(this));
+    
+    connect(b_varsModel, &QAbstractItemModel::dataChanged, this, &KAlgebra::valueChanged);
+    connect(b_funcs, &QAbstractItemView::doubleClicked, this, &KAlgebra::edit_func);
+    connect(b_tools, &QTabWidget::currentChanged, this, &KAlgebra::functools);
+    connect(m_graph2d, &Analitza::PlotsView2D::status, this, &KAlgebra::changeStatusBar);
+    connect(m_graph2d, SIGNAL(viewportChanged(QRectF)), b_viewport, SLOT(setViewport(QRectF)));
+    connect(b_viewport, SIGNAL(viewportChange(QRectF)), m_graph2d, SLOT(changeViewport(QRectF)));
+    connect(b_varsView, &QWidget::customContextMenuRequested, this, &KAlgebra::varsContextMenu);
+    
+    ////////menu
+    b_menu = menuBar()->addMenu(i18n("2&D Graph"));
+    QAction* b_actions[6];
+    b_actions[0] = b_menu->addAction(i18n("&Grid"), this, SLOT(toggleSquares()));
+    b_actions[1] = b_menu->addAction(i18n("&Keep Aspect Ratio"), this, SLOT(toggleKeepAspect()));
+    b_menu->addAction(KStandardAction::save(this, SLOT(saveGraph()), this));
+    b_menu->addSeparator();
+    b_menu->addAction(KStandardAction::zoomIn(m_graph2d, SLOT(zoomIn()), this));
+    b_menu->addAction(KStandardAction::zoomOut(m_graph2d, SLOT(zoomOut()), this));
+    QAction* ac=KStandardAction::actualSize(m_graph2d, SLOT(resetViewport()), this);
+    ac->setShortcut(Qt::ControlModifier + Qt::Key_0);
+    b_menu->addAction(ac);
+    b_menu->addSeparator()->setText(i18n("Resolution"));
+    b_actions[2] = b_menu->addAction(i18nc("@item:inmenu", "Poor"), this, SLOT(set_res_low()));
+    b_actions[3] = b_menu->addAction(i18nc("@item:inmenu", "Normal"), this, SLOT(set_res_std()));
+    b_actions[4] = b_menu->addAction(i18nc("@item:inmenu", "Fine"), this, SLOT(set_res_fine()));
+    b_actions[5] = b_menu->addAction(i18nc("@item:inmenu", "Very Fine"), this, SLOT(set_res_vfine()));
+    m_graph2d->setContextMenuPolicy(Qt::ActionsContextMenu);
+    m_graph2d->addActions(b_menu->actions());
+    
+    QActionGroup *res = new QActionGroup(b_menu);
+    res->addAction(b_actions[2]);
+    res->addAction(b_actions[3]);
+    res->addAction(b_actions[4]);
+    res->addAction(b_actions[5]);
+    
+    b_actions[0]->setCheckable(true);
+    b_actions[0]->setChecked(true);
+    b_actions[1]->setCheckable(true);
+    b_actions[1]->setChecked(true);
+    b_actions[2]->setCheckable(true);
+    b_actions[3]->setCheckable(true);
+    b_actions[3]->setChecked(true);
+    b_actions[4]->setCheckable(true);
+    b_actions[5]->setCheckable(true);
+    set_res_std();
+    //////EO2D Graph
+    
+    /////3DGraph
+#ifdef HAVE_OPENGL
+    QWidget *tridim = new QWidget(m_tabs);
+    QVBoxLayout *t_layo = new QVBoxLayout(tridim);
+    t_exp = new Analitza::ExpressionEdit(tridim);
+    t_exp->setExamples(Analitza::PlotsFactory::self()->examples(Analitza::Dim3D));
+    t_exp->setAns(QStringLiteral("x"));
+    t_model3d = new Analitza::PlotsModel(this);
+    m_graph3d = new Analitza::PlotsView3D(tridim);
+    m_graph3d->setModel(t_model3d);
+    m_graph3d->setUseSimpleRotation(true);
+    
+    tridim->setLayout(t_layo);
+    m_tabs->addTab(tridim, i18n("&3D Graph"));
+    t_layo->addWidget(m_graph3d);
+    t_layo->addWidget(t_exp);
+    
+    connect(t_exp,  &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::new_func3d);
+    c_results->addOptionsObserver(new Add3DOption(this));
+    
+    ////////menu
+    t_menu = menuBar()->addMenu(i18n("3D &Graph"));
+    QAction* t_actions[5];
+    t_menu->addAction(KStandardAction::save(this, SLOT(save3DGraph()), this));
+    t_menu->addAction(QIcon::fromTheme(QStringLiteral("zoom-original")), i18n("&Reset View"), m_graph3d, SLOT(resetView()));
+    t_menu->addSeparator();
+    t_actions[2] = t_menu->addAction(i18n("Dots"), this, SLOT(set_dots()));
+    t_actions[3] = t_menu->addAction(i18n("Lines"), this, SLOT(set_lines()));
+    t_actions[4] = t_menu->addAction(i18n("Solid"), this, SLOT(set_solid()));
+    
+    QActionGroup *t_type = new QActionGroup(t_menu);
+    t_type->addAction(t_actions[2]);
+    t_type->addAction(t_actions[3]);
+    t_type->addAction(t_actions[4]);
+    
+    t_actions[2]->setCheckable(true);
+    t_actions[3]->setCheckable(true);
+    t_actions[4]->setCheckable(true);
+    t_actions[4]->setChecked(true);
+#endif
+    ////////////
+    //////EO3D Graph
+    menuBar()->addMenu(QStringLiteral("|"))->setEnabled(false);
+    
+    //Dictionary tab
+    d_dock = new QDockWidget(i18n("Operations"), this);
+    d_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
+    addDockWidget(Qt::RightDockWidgetArea, d_dock);
+    Dictionary *dic = new Dictionary(m_tabs);
+    m_tabs->addTab(dic, i18n("&Dictionary"));
+    
+    QWidget *w=new QWidget;
+    QLayout *leftLayo=new QVBoxLayout(w);
+    d_filter=new QLineEdit(w);
+    d_filter->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+    connect(d_filter, &QLineEdit::textChanged, dic, &Dictionary::setFilter);
+    connect(d_filter, &QLineEdit::textChanged, this, &KAlgebra::dictionaryFilterChanged);
+    d_list = new QListView(w);
+    d_list->setModel(dic->model());
+    d_list->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
+    leftLayo->addWidget(new QLabel(i18n("Look for:"), d_dock));
+    leftLayo->addWidget(d_filter);
+    leftLayo->addWidget(d_list);
+    d_dock->setWidget(w);
+    
+    connect(d_list->selectionModel(), &QItemSelectionModel::currentChanged,
+        dic, &Dictionary::activated);
+    
+    //EODictionary
+    //Ego's reminder
+    KHelpMenu* help = new KHelpMenu(this);
+    menuBar()->addMenu(help->menu());
+
+#pragma message("TODO: Port to PlotsModel")
+//     connect(b_funcsModel, SIGNAL(functionModified(QString,Analitza::Expression)),
+//             c_results, SLOT(modifyVariable(QString,Analitza::Expression)));
+//     connect(b_funcsModel, SIGNAL(functionRemoved(QString)),
+//             c_results, SLOT(removeVariable(QString)));
+    
+    connect(m_tabs, &QTabWidget::currentChanged, this, &KAlgebra::tabChanged);
+    tabChanged(0);
+}
+
+KAlgebra::~KAlgebra()
+{
+    KConfig conf(QStringLiteral("kalgebrarc"));
+    KConfigGroup config(&conf, "Default");
+    QStringList urls;
+    foreach(const QUrl& url, c_recentScripts->urls())
+        urls += url.toDisplayString();
+    
+    config.writeEntry("recent", urls);
+}
+
+void KAlgebra::initializeRecentScripts()
+{
+    KConfig conf(QStringLiteral("kalgebrarc"));
+    KConfigGroup config(&conf, "Default");
+    
+    QStringList urls=config.readEntry("recent", QStringList());
+    foreach(const QString& url, urls) {
+        c_recentScripts->addUrl(QUrl(url));
+    }
+}
+
+void KAlgebra::newInstance()
+{
+    QProcess::startDetached(QApplication::applicationFilePath());
+}
+
+void KAlgebra::add2D(const Analitza::Expression& exp)
+{
+    qDebug() << "adding" << exp.toString();
+    
+    Analitza::PlotBuilder req = Analitza::PlotsFactory::self()->requestPlot(exp, Analitza::Dim2D, c_results->analitza()->variables());
+    Analitza::PlotItem* curve = req.create(randomFunctionColor(), b_funcsModel->freeId());
+    b_funcsModel->addPlot(curve);
+    
+    m_tabs->setCurrentIndex(1);
+}
+
+void KAlgebra::new_func()
+{
+    Analitza::FunctionGraph* f=b_funced->createFunction();
+    
+    if(b_funced->editing()) {
+        QModelIndex idx = b_funcsModel->indexForName(f->name());
+        b_funcsModel->updatePlot(idx.row(), f);
+    } else {
+        b_funcsModel->addPlot(f);
+    }
+    
+    b_funced->setEditing(false);
+    b_funced->clear();
+    b_tools->setCurrentIndex(0);
+    b_funcs->setCurrentIndex(b_funcsModel->indexForName(f->name()));
+    m_graph2d->setFocus();
+}
+
+void KAlgebra::remove_func()
+{
+    Q_ASSERT(b_funced->editing());
+    b_funcsModel->removeRow(b_funcs->currentIndex().row());
+    
+    b_funced->setEditing(false);
+    b_funced->clear();
+    b_tools->setCurrentIndex(0);
+    b_funcs->setCurrentIndex(QModelIndex());
+    m_graph2d->setFocus();
+}
+
+void KAlgebra::edit_func(const QModelIndex &idx)
+{
+    b_tools->setTabText(1, i18n("&Editing"));
+    b_tools->setCurrentIndex(1);
+    b_funced->setName(b_funcsModel->data(idx.sibling(idx.row(), 0)).toString());
+    b_funced->setFunction(b_funcsModel->data(idx.sibling(idx.row(), 1)).toString());
+    b_funced->setEditing(true);
+    b_funced->setFocus();
+}
+
+void KAlgebra::functools(int i)
+{
+    if(i==0)
+        b_tools->setTabText(1, i18n("&Add"));
+    else {
+        b_funced->setName(b_funcsModel->freeId());
+        b_funced->setColor(randomFunctionColor());
+        b_funced->setEditing(false);
+        b_funced->setFocus();
+    }
+}
+
+void KAlgebra::edit_var(const QModelIndex &idx)
+{
+    if(idx.column()==0) {
+        c_exp->insertText(idx.data().toString());
+    } else {
+        QModelIndex idxName=idx.sibling(idx.row(), 0);
+        
+        QPointer<VarEdit> e(new VarEdit(this, false));
+        QString var = c_variables->model()->data(idxName, Qt::DisplayRole).toString();
+        
+        e->setAnalitza(c_results->analitza());
+        e->setName(var);
+        
+        if(e->exec() == QDialog::Accepted) {
+            QString str=var+" := "+e->val().toString();
+            c_results->addOperation(Analitza::Expression(str, false), str);
+        }
+        delete e;
+    }
+}
+
+void KAlgebra::operate()
+{
+    if(!c_exp->text().isEmpty()){
+        c_exp->setCorrect(c_results->addOperation(c_exp->expression(), c_exp->toPlainText()));
+        c_exp->selectAll();
+    }
+}
+
+void KAlgebra::changeStatusBar(const QString& msg)
+{
+//     statusBar()->showMessage(msg);
+    m_status->setText(msg);
+}
+
+void KAlgebra::loadScript()
+{
+    QUrl path = QFileDialog::getOpenFileUrl(this, i18n("Choose a script"), QUrl(), i18n("Script (*.kal)"));
+    
+    if(!path.isEmpty())
+        loadScript(path);
+}
+
+void KAlgebra::loadScript(const QUrl& path)
+{
+    bool loaded=c_results->loadScript(path);
+    
+    if(loaded)
+        c_recentScripts->addUrl(path);
+}
+
+void KAlgebra::saveScript()
+{
+    QUrl path = QFileDialog::getSaveFileUrl(this, QString(), QUrl(), i18n("Script (*.kal)"));
+    bool loaded=false;
+    if(!path.isEmpty())
+        loaded=c_results->saveScript(path);
+    
+    if(loaded)
+        c_recentScripts->addUrl(path);
+}
+
+void KAlgebra::saveLog()
+{
+    QUrl path = QFileDialog::getSaveFileUrl(this, QString(), QUrl(), i18n("HTML File (*.html)"));
+    if(!path.isEmpty())
+        c_results->saveLog(path);
+}
+
+void KAlgebra::set_res_low()    { b_funcsModel->setResolution(416); }
+void KAlgebra::set_res_std()    { b_funcsModel->setResolution(832); }
+void KAlgebra::set_res_fine()    { b_funcsModel->setResolution(1664);}
+void KAlgebra::set_res_vfine()    { b_funcsModel->setResolution(3328);}
+
+void KAlgebra::new_func3d()
+{
+#ifdef HAVE_OPENGL
+    Analitza::Expression exp = t_exp->expression();
+    Analitza::PlotBuilder plot = Analitza::PlotsFactory::self()->requestPlot(exp, Analitza::Dim3D, c_results->analitza()->variables());
+    if(plot.canDraw()) {
+        t_model3d->clear();
+        t_model3d->addPlot(plot.create(Qt::yellow, QStringLiteral("func3d")));
+    } else
+        changeStatusBar(i18n("Errors: %1", plot.errors().join(i18n(", "))));
+#endif
+}
+
+void KAlgebra::set_dots()
+{
+#ifdef HAVE_OPENGL
+    m_graph3d->setPlotStyle(Analitza::Dots);
+#endif
+}
+
+void KAlgebra::set_lines()
+{
+#ifdef HAVE_OPENGL
+    m_graph3d->setPlotStyle(Analitza::Wired);
+#endif
+}
+
+void KAlgebra::set_solid()
+{
+#ifdef HAVE_OPENGL
+    m_graph3d->setPlotStyle(Analitza::Solid);
+#endif
+}
+
+void KAlgebra::save3DGraph()
+{
+#ifdef HAVE_OPENGL
+    QString path = QFileDialog::getSaveFileName(this, QString(), QString(), i18n("PNG File (*.png);;PDF Document(*.pdf);;X3D Document (*.x3d)"));
+    if(!path.isEmpty()) {
+        if(path.endsWith(QLatin1String(".x3d"))) {
+            m_graph3d->exportSurfaces(path);
+        } else if(path.endsWith(QLatin1String(".pdf"))) {
+            QPixmap px = m_graph3d->renderPixmap();
+            QPrinter printer;
+            printer.setOutputFormat(QPrinter::PdfFormat);
+            printer.setOutputFileName(path);
+            printer.setPaperSize(px.size(), QPrinter::DevicePixel);
+            printer.setPageMargins(0,0,0,0, QPrinter::DevicePixel);
+            QPainter painter;
+            painter.begin(&printer);
+            painter.drawPixmap(QPoint(0,0), px);
+            painter.end();
+        } else {
+            QPixmap px = m_graph3d->renderPixmap();
+            px.save(path);
+        }
+    }
+#endif
+}
+
+void KAlgebra::toggleSquares()
+{
+    m_graph2d->setTicksShown(m_graph2d->ticksShown() ? (Qt::Horizontal|Qt::Vertical) : ~(Qt::Horizontal|Qt::Vertical));
+}
+
+void KAlgebra::toggleKeepAspect()
+{
+    m_graph2d->setKeepAspectRatio(!m_graph2d->keepAspectRatio());
+}
+
+void KAlgebra::saveGraph()
+{
+    QPointer<QFileDialog> dialog=new QFileDialog(this, i18n("Select where to put the rendered plot"), QString(), i18n("Image File (*.png);;SVG File (*.svg)"));
+    dialog->setConfirmOverwrite(true);
+    
+    if(dialog->exec() && !dialog->selectedFiles().isEmpty()) {
+        QString filter = dialog->selectedNameFilter();
+        QString filename = dialog->selectedFiles().first();
+        
+        bool isSvg = filename.endsWith(QLatin1String(".svg")) || (!filename.endsWith(QLatin1String(".png")) && filter.mid(2, 3)==QLatin1String("svg"));
+        Analitza::PlotsView2D::Format f = isSvg ? Analitza::PlotsView2D::SVG : Analitza::PlotsView2D::PNG;
+        m_graph2d->toImage(filename, f);
+    }
+    delete dialog;
+}
+
+void menuEnabledHelper(QMenu* m, bool enabled)
+{
+    m->setEnabled(enabled);
+    foreach(QAction* action, m->actions()) {
+        action->setEnabled(enabled);
+    }
+}
+
+void KAlgebra::tabChanged(int n)
+{
+    c_dock_vars->hide();
+    b_dock_funcs->hide();
+    d_dock->hide();
+    
+    menuEnabledHelper(c_menu, n==0);
+    menuEnabledHelper(b_menu, n==1);
+#ifdef HAVE_OPENGL
+    menuEnabledHelper(t_menu, n==2);
+#endif
+    m_status->clear();
+    
+    switch(n) {
+        case 0:
+            c_dock_vars->show();
+            c_dock_vars->raise();
+            c_exp->setFocus();
+            break;
+        case 1:
+            b_dock_funcs->show();
+            b_dock_funcs->raise();
+            
+            if(b_funcsModel->rowCount()==0)
+                b_tools->setCurrentIndex(1); //We set the Add tab
+//             b_add->setFocus();
+            break;
+#ifdef HAVE_OPENGL
+        case 2:
+            t_exp->setFocus();
+            break;
+#endif
+        case 3:
+            d_filter->setFocus();
+            d_dock->show();
+            d_dock->raise();
+        default:
+            break;
+    }
+    changeStatusBar(i18nc("@info:status", "Ready"));
+}
+
+void KAlgebra::select(const QModelIndex & idx)
+{
+    b_funcs->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
+}
+
+void KAlgebra::updateInformation()
+{
+    c_varsModel->updateInformation();
+    c_variables->header()->resizeSections(QHeaderView::ResizeToContents);
+}
+
+void KAlgebra::consoleCalculate()
+{
+    c_results->setMode(ConsoleHtml::Calculation);
+}
+
+void KAlgebra::consoleEvaluate()
+{
+    c_results->setMode(ConsoleHtml::Evaluation);
+}
+
+void KAlgebra::valueChanged()
+{
+    //FIXME: Should only repaint the affected ones.
+    if(b_funcsModel->rowCount()>0)
+        m_graph2d->updateFunctions(QModelIndex(), 0, b_funcsModel->rowCount()-1);
+}
+
+void KAlgebra::varsContextMenu(const QPoint& p)
+{
+    QPointer<QMenu> m=new QMenu;
+    m->addAction(i18n("Add variable"));
+    QAction* ac=m->exec(b_dock_funcs->widget()->mapToGlobal(p));
+    
+    if(ac) {
+        QPointer<AskName> a=new AskName(i18n("Enter a name for the new variable"), 0);
+        
+        if(a->exec()==QDialog::Accepted)
+            b_varsModel->insertVariable(a->name(), Analitza::Expression(Analitza::Cn(0)));
+        delete a;
+    }
+    delete m;
+}
+
+void KAlgebra::add3D(const Analitza::Expression& exp)
+{
+#ifdef HAVE_OPENGL
+    t_model3d->clear();
+    Analitza::PlotBuilder plot = Analitza::PlotsFactory::self()->requestPlot(exp, Analitza::Dim3D, c_results->analitza()->variables());
+    Q_ASSERT(plot.canDraw());
+    t_model3d->addPlot(plot.create(Qt::yellow, QStringLiteral("func3d_console")));
+    m_tabs->setCurrentIndex(2);
+#endif
+}
+
+void KAlgebra::dictionaryFilterChanged(const QString&)
+{
+    if(d_list->model()->rowCount()==1)
+        d_list->setCurrentIndex(d_list->model()->index(0,0));
+}
+
+void KAlgebra::fullScreen(bool isFull)
+{
+    m_tabs->setDocumentMode(isFull);
+    m_tabs->setTabEnabled(3, !isFull);
+    if(isFull) {
+        hide();
+        m_tabs->setParent(0);
+        setCentralWidget(0);
+        m_tabs->showFullScreen();
+    } else {
+        setCentralWidget(m_tabs);
+        show();
+    }
+}
diff --git a/src/kalgebra.h b/src/kalgebra.h
new file mode 100644 (file)
index 0000000..68905a3
--- /dev/null
@@ -0,0 +1,131 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef KALGEBRA_H
+#define KALGEBRA_H
+
+#include <QTreeView>
+#include <QPushButton>
+#include <QTabWidget>
+#include <QLabel>
+#include <QListView>
+#include <QMainWindow>
+#include <config-kalgebra.h>
+
+namespace Analitza {
+class PlotsView2D;
+class PlotsView3D;
+class PlotsModel;
+class VariablesModel;
+class ExpressionEdit;
+}
+
+class ConsoleHtml;
+class FunctionEdit;
+class KRecentFilesAction;
+
+namespace Analitza { class Expression; }
+
+class KAlgebra : public QMainWindow
+{
+    Q_OBJECT
+    public:
+        KAlgebra ( QWidget *parent=0 );
+        ~KAlgebra();
+        
+        void add2D(const Analitza::Expression& exp);
+        void add3D(const Analitza::Expression& exp);
+    private:
+        QLabel *m_status;
+        QTabWidget* m_tabs;
+        
+        //consoleeWidget
+        QMenu* c_menu;
+        KRecentFilesAction* c_recentScripts;
+        Analitza::ExpressionEdit *c_exp;
+        ConsoleHtml *c_results;
+        QTreeView *c_variables;
+        QDockWidget *c_dock_vars;
+        Analitza::VariablesModel* c_varsModel;
+        
+        //graf 2d
+        QMenu* b_menu;
+        Analitza::PlotsModel* b_funcsModel;
+        QTreeView *b_funcs;
+        QTabWidget *b_tools;
+        Analitza::PlotsView2D *m_graph2d;
+        QDockWidget *b_dock_funcs;
+        FunctionEdit *b_funced;
+        Analitza::VariablesModel* b_varsModel;
+
+#ifdef HAVE_OPENGL
+        //graph 3d
+        QMenu* t_menu;
+        Analitza::ExpressionEdit *t_exp;
+        Analitza::PlotsView3D *m_graph3d;
+        Analitza::PlotsModel* t_model3d;
+#endif
+        //Dictionary
+        QDockWidget *d_dock;
+        QListView *d_list;
+        QLineEdit *d_filter;
+        
+    private Q_SLOTS:
+        void newInstance();
+        void fullScreen(bool isFull);
+        
+        void initializeRecentScripts();
+        void operate();
+        void loadScript();
+        void loadScript(const QUrl& path);
+        void saveScript();
+        void saveLog();
+        void updateInformation();
+        void consoleCalculate();
+        void consoleEvaluate();
+        
+        void select(const QModelIndex& idx);
+        void new_func();
+        void remove_func();
+        void edit_func ( const QModelIndex & );
+        void edit_var ( const QModelIndex & );
+        void toggleSquares();
+        void toggleKeepAspect();
+        void set_res_low();
+        void set_res_std();
+        void set_res_fine();
+        void set_res_vfine();
+        void valueChanged();
+        void varsContextMenu(const QPoint&);
+        
+        void new_func3d();
+        void set_dots();
+        void set_lines();
+        void set_solid();
+        void save3DGraph();
+        
+        void saveGraph();
+        void functools ( int );
+        
+        void dictionaryFilterChanged(const QString& filter);
+        
+        void changeStatusBar ( const QString & );
+        void tabChanged ( int );
+};
+
+#endif
diff --git a/src/kalgebra.xml b/src/kalgebra.xml
new file mode 100644 (file)
index 0000000..d9b95c2
--- /dev/null
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE language SYSTEM "language.dtd">
+<!--
+  ====================================================================
+  KAlgebra syntax highlighting file for the KDE editors Kate and Kwrite
+  ====================================================================
+      based on KAlgebra 0.1.0
+
+  Change log:
+  22-Apr-10  Initial version
+
+  Author: Adria Arrufat
+  -->
+
+
+<language name="KAlgebra" version="1.0" kateversion="3.4" section="Scientific" extensions="*.kal" mimetype="text/KAlgebra Script" casesensitive="1" license="GPL" author="Adria Arrufat">
+
+  <highlighting>
+
+    <!-- Reserved keywords in KAlgebra -->
+    <list name="keywords">
+      <item> piecewise </item>
+      <item> list </item>
+      <item> vector </item>
+      <item> ? </item>
+      </list>
+
+    <list name="builtin">
+      <item> e </item>
+      <item> euler </item>
+      <item> false </item>
+      <item> pi </item>
+      <item> true </item>
+      <item> ans </item>
+    </list>
+
+    <list name="operations">
+      <item> @ </item>
+      <item> abs </item>
+      <item> and </item>
+      <item> approx </item>
+      <item> arccos </item>
+      <item> arccosh </item>
+      <item> arccot </item>
+      <item> arcsc </item>
+      <item> arcsch </item>
+      <item> arcsec </item>
+      <item> arcsech </item>
+      <item> arcsin </item>
+      <item> arcsinh </item>
+      <item> arctan </item>
+      <item> arctanh </item>
+      <item> card </item>
+      <item> ceiling </item>
+      <item> cos </item>
+      <item> cosh </item>
+      <item> cot </item>
+      <item> coth </item>
+      <item> csc </item>
+      <item> csch </item>
+      <item> diff </item>
+      <item> divide </item>
+      <item> eq </item>
+      <item> exp </item>
+      <item> factorial </item>
+      <item> factorof </item>
+      <item> floor </item>
+      <item> fmod </item>
+      <item> gcd </item>
+      <item> geq </item>
+      <item> gt </item>
+      <item> implies </item>
+      <item> lcm </item>
+      <item> leq </item>
+      <item> ln </item>
+      <item> log </item>
+      <item> lt </item>
+      <item> max </item>
+      <item> min </item>
+      <item> minus </item>
+      <item> neq </item>
+      <item> not </item>
+      <item> or </item>
+      <item> plus </item>
+      <item> power </item>
+      <item> product </item>
+      <item> quotient </item>
+      <item> rem </item>
+      <item> root </item>
+      <item> scalarprod </item>
+      <item> sec </item>
+      <item> sech </item>
+      <item> selector </item>
+      <item> sin </item>
+      <item> sinh </item>
+      <item> sum </item>em>
+      <item> tan </item>
+      <item> tanh </item>
+      <item> times </item>
+      <item> union </item>
+      <item> xor </item>
+    </list>
+
+
+    <contexts>
+
+      <context name="_normal" attribute="Normal Text" lineEndContext="#stay">
+
+        <!-- Look-ahead for adjoint ' after variable, number literal, closing braces and .' -->
+        <RegExpr context="_adjoint" attribute="Variable" String="[a-zA-Z]\w*(?=')" />
+        <RegExpr context="_adjoint" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?(?=')" />
+        <RegExpr context="_adjoint" attribute="Delimiter" String="[\)\]}](?=')" />
+        <RegExpr context="_adjoint" attribute="Operator" String="\.'(?=')" />
+
+        <!-- If ' is not the adjoint operator, it starts a string or an unterminated string;
+        strings can be also with ", and accept the respective delimiter in them either
+        by doubling it ('', "") or by escaping it (\', \") -->
+
+        <!-- Handling of keywords, functions, identifiers, numbers and braces -->
+        <keyword context="#stay" attribute="Keyword" String="keywords" />
+        <keyword context="#stay" attribute="Operations" String="operations" />
+        <keyword context="#stay" attribute="Builtin" String="builtin"/>
+        <RegExpr context="#stay" attribute="Variable" String="[a-zA-Z]\w*" />
+        <RegExpr context="#stay" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?" />
+        <AnyChar context="#stay" attribute="Delimiter" String="(){}"/>
+        
+        <!-- Comments-->
+        <Detect2Chars context="Commentar" attribute="Comment" char="/" char1="/"/>
+
+        <!-- operators -->
+        <StringDetect context="#stay" attribute="Operator" String="+"/>
+        <StringDetect context="#stay" attribute="Operator" String="-"/>
+        <StringDetect context="#stay" attribute="Operator" String="*"/>
+        <StringDetect context="#stay" attribute="Operator" String="/"/>
+        <StringDetect context="#stay" attribute="Operator" String="^"/>
+        <StringDetect context="#stay" attribute="Operator" String=","/>
+        <StringDetect context="#stay" attribute="Operator" String=":"/>
+        <StringDetect context="#stay" attribute="Operator" String="&lt;"/>
+        <StringDetect context="#stay" attribute="Operator" String="&gt;"/>
+        <StringDetect context="#stay" attribute="Operator" String="="/>
+
+      </context>
+      
+      <context attribute="Comment" lineEndContext="#pop" name="Commentar">
+        <Detect2Chars attribute="Comment" context="#pop" char="/" char1="/" endRegion="Comment"/>
+      </context>
+
+   <!--Context entered after encountering an ' adjoint operator -->
+      <context name="_adjoint" attribute="Operator" lineEndContext="#pop">
+        <RegExpr context="#pop" attribute="Operator" String="'+" />
+      </context>
+    </contexts>
+
+    <itemDatas>
+      <itemData name="Normal Text" defStyleNum="dsNormal"/>
+      <itemData name="Variable" defStyleNum="dsNormal" color="#AC0008" />
+      <itemData name="Operator" defStyleNum="dsNormal" bold="1"/>
+      <itemData name="Number" defStyleNum="dsFloat" color="#2b74c7"/>
+      <itemData name="Delimiter" defStyleNum="dsNormal" bold="1"/>
+      <itemData name="String" defStyleNum="dsString" color="#b20000"/>
+      <itemData name="Keyword"  defStyleNum="dsNormal" color="#AC0008"/>
+      <itemData name="Comment" defStyleNum="dsComment" color="#009900"/>
+      <itemData name="Operations" defStyleNum="dsFunction" color="#AC0008" selColor="#00ff00"/>
+      <itemData name="Builtin" defStyleNum="dsBaseN" color="#b28c00" />
+    </itemDatas>
+
+  </highlighting>
+
+  <general>
+   <keywords casesensitive="1"/>
+  </general>
+
+</language>
+<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..152fd04
--- /dev/null
@@ -0,0 +1,44 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include <QApplication>
+#include <QCommandLineParser>
+#include <KAboutData>
+#include <KLocalizedString>
+#include "kalgebra.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+    KLocalizedString::setApplicationDomain("kalgebra");
+    KAboutData about("kalgebra", "KAlgebra", "0.10", i18n("A portable calculator"),
+             KAboutLicense::GPL, i18n("(C) 2006-2016 Aleix Pol i Gonzalez"));
+    about.addAuthor( "Aleix Pol i Gonzalez", QString(), "aleixpol@kde.org" );
+    about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
+    KAboutData::setApplicationData(about);
+
+    QCommandLineParser parser;
+    about.setupCommandLine(&parser);
+    parser.process(app);
+    about.processCommandLine(&parser);
+
+    KAlgebra widget;
+    widget.show();
+    
+    return app.exec();
+}
diff --git a/src/org.kde.kalgebra.desktop b/src/org.kde.kalgebra.desktop
new file mode 100755 (executable)
index 0000000..3db1391
--- /dev/null
@@ -0,0 +1,176 @@
+[Desktop Entry]
+Name=KAlgebra
+Name[ast]=KAlgebra
+Name[bg]=KAlgebra
+Name[bs]=Kalgebra
+Name[ca]=KAlgebra
+Name[ca@valencia]=KAlgebra
+Name[cs]=KAlgebra
+Name[csb]=KAlgebra
+Name[da]=KAlgebra
+Name[de]=KAlgebra
+Name[el]=KAlgebra
+Name[en_GB]=KAlgebra
+Name[eo]=KAlgebra
+Name[es]=KAlgebra
+Name[et]=KAlgebra
+Name[eu]=KAlgebra
+Name[fi]=KAlgebra
+Name[fr]=KAlgebra
+Name[ga]=KAlgebra
+Name[gl]=KAlgebra
+Name[gu]=KAlgebra
+Name[he]=KAlgebra
+Name[hi]=के-अलजेब्रा
+Name[hne]=के-अलजेब्रा
+Name[hr]=KAlgebra
+Name[hu]=KAlgebra
+Name[is]=KAlgebra
+Name[it]=KAlgebra
+Name[ja]=KAlgebra
+Name[kk]=KAlgebra
+Name[km]=KAlgebra
+Name[ko]=KAlgebra
+Name[lt]=KAlgebra
+Name[lv]=KAlgebra
+Name[ml]=കെ-ആള്‍ജിബ്ര
+Name[mr]=के-एल्जिब्रा
+Name[nb]=KAlgebra
+Name[nds]=KAlgebra
+Name[ne]=केडीई बीजगणित
+Name[nl]=KAlgebra
+Name[nn]=KAlgebra
+Name[pa]=ਕੇ-ਐਲਜਬਰਾ
+Name[pl]=KAlgebra
+Name[pt]=KAlgebra
+Name[pt_BR]=KAlgebra
+Name[ro]=KAlgebra
+Name[ru]=KAlgebra
+Name[si]=KAlgebra
+Name[sk]=KAlgebra
+Name[sl]=KAlgebra
+Name[sv]=Kalgebra
+Name[te]=కె అల్జీబ్రా
+Name[tr]=KAlgebra
+Name[ug]=KAlgebra
+Name[uk]=KАлгебра
+Name[x-test]=xxKAlgebraxx
+Name[zh_CN]=KAlgebra
+Name[zh_TW]=數學_KAlgebra
+GenericName=Graph Calculator
+GenericName[ast]=Calculadora gráfica
+GenericName[bg]=Графичен калкулатор
+GenericName[bs]=Graf kalkulator
+GenericName[ca]=Calculadora gràfica
+GenericName[ca@valencia]=Calculadora gràfica
+GenericName[cs]=Kalkulačka grafů
+GenericName[csb]=Kalkùlator
+GenericName[da]=Diagramberegner
+GenericName[de]=Graphenrechner
+GenericName[el]=Γραφικός υπολογιστής
+GenericName[en_GB]=Graph Calculator
+GenericName[eo]=Kalkulilo de grafikaĵoj
+GenericName[es]=Calculadora gráfica
+GenericName[et]=Graafikute arvutaja
+GenericName[eu]=Grafikoen kalkulagailua
+GenericName[fa]=ماشین حساب گراف
+GenericName[fi]=Graafinen laskin
+GenericName[fr]=Calculatrice graphique
+GenericName[ga]=Áireamhán Grafach
+GenericName[gl]=Calculadora gráfica
+GenericName[gu]=આલેખ કેલ્ક્યુલેટર
+GenericName[he]=מחשבון גרפי
+GenericName[hi]=ग्राफ गणक
+GenericName[hne]=ग्राफ गनक
+GenericName[hu]=Függvényszámító
+GenericName[is]=Reiknivél fyrir gröf
+GenericName[it]=Calcolatrice grafica
+GenericName[ja]=グラフ計算機
+GenericName[kk]=График калькуляторы
+GenericName[km]=ម៉ាស៊ីន​គិតលេខ​ក្រាហ្វិក​
+GenericName[ko]=그래핑 계산기
+GenericName[lt]=Grafinis skaičiuotuvas
+GenericName[lv]=Grafiskais kalkulators
+GenericName[ml]=ഗ്രാഫ് ഗണനി
+GenericName[mr]=आलेख गणकयंत्र
+GenericName[nb]=Grafikk-kalkulator
+GenericName[nds]=Funkschonenreekner
+GenericName[ne]=ग्राफ गणकयन्त्र
+GenericName[nl]=Rekenmachine met grafieken
+GenericName[nn]=Ein grafkalkulator
+GenericName[pa]=ਗਰਾਫ਼ ਕੈਲਕੂਲੇਟਰ
+GenericName[pl]=Kalkulator wykresów
+GenericName[pt]=Calculadora Gráfica
+GenericName[pt_BR]=Calculadora gráfica
+GenericName[ru]=Графический калькулятор
+GenericName[sk]=Grafická kalkulačka
+GenericName[sl]=Računalo z grafi
+GenericName[sv]=Grafräknare
+GenericName[te]=రేఖాచిత్ర గనన యంత్రము
+GenericName[tr]=Grafik Hesap Makinesi
+GenericName[uk]=Графічний калькулятор
+GenericName[x-test]=xxGraph Calculatorxx
+GenericName[zh_CN]=图形计算器
+GenericName[zh_TW]=圖形計算器
+Comment=Math Expression Solver and Plotter
+Comment[ast]=Igua y traza espresiones matemátiques
+Comment[bg]=Решаване на математически задачи
+Comment[bs]=Matematski Sistem za rješavanje i crtač
+Comment[ca]=Soluciona i representa gràficament expressions matemàtiques
+Comment[ca@valencia]=Soluciona i representa gràficament expressions matemàtiques
+Comment[cs]=Řešitel a souřadnicový zapisovač matematických výrazů
+Comment[csb]=Rozrzeszëwôcz matematicznëch równaniów ë rësowôcz grafów
+Comment[da]=Løser og plotter til matematiske udtryk
+Comment[de]=Mathematische Gleichungslösung und -zeichnung
+Comment[el]=Σχεδιαστής και επιλυτής μαθηματικών εκφράσεων
+Comment[en_GB]=Mathematical Expression Solver and Plotter
+Comment[eo]=Solvilo kaj desegnilo de matematikaj esprimoj
+Comment[es]=Resuelve y dibuja expresiones matemáticas
+Comment[et]=Matemaatiliste avaldiste lahendaja ja joonistaja
+Comment[eu]=Matematika adierazpenen ebazlea edo marrazlea
+Comment[fa]=حل‌کننده و رسام عبارت ریاضی
+Comment[fi]=Matemaattisten yhtälöiden ratkaisut ja kuvaajat
+Comment[fr]=Traceur et résolveur d'expressions mathématiques
+Comment[ga]=Réiteoir agus Breacaire Sloinn Mhatamaiticiúla
+Comment[gl]=Ferramenta para resolver e debuxar expresións matemáticas
+Comment[gu]=ગાણિતિક સૂત્રો ઉકેલનાર અને આલેખનાર
+Comment[he]=פותר ומשרטט ביטויים מתמטיים
+Comment[hi]=गणित एक्सप्रेशन सुलझाने वाला तथा प्लॉटर
+Comment[hne]=गनित एक्सप्रेसन सुलझाने वाला अउ प्लाटर
+Comment[hr]=Rješavač i crtač za matematičke izraze
+Comment[hu]=Matematikai egyenletek megoldása, görberajzolás
+Comment[is]=Stærðfræðilausnir og plottun
+Comment[it]=Risolutore e disegnatore di espressioni matematiche
+Comment[ja]=数式ソルバー&プロッタ
+Comment[kk]=Математикалық өрнегін есептеп графигін салу
+Comment[km]=ឧបករណ៍​គូស​ក្រាហ្វិក និង​កម្មវិធី​ដោះស្រាយ​កន្សោម​​​គណិត
+Comment[ko]=수식 계산기와 그래핑 도구
+Comment[lt]=Matematinių reiškinių sprendikas ir grafikų braižiklis
+Comment[lv]=Matemātisko izteiksmju risinātājs un attēlotājs
+Comment[ml]=ഗണിതസൂത്ര പരിഹാരകനും പ്ലോട്ടറും
+Comment[nb]=Matematisk uttrykksløser og plotter
+Comment[nds]=Löser för mathemaatsche Utdrück un Bagenschriever
+Comment[ne]=म्याथ अभिव्यक्ति समाधानकर्ता र प्लोटर
+Comment[nl]=Oplossen en plotten van wiskundige expressies
+Comment[nn]=Matteoppgåveløysar og grafplottar
+Comment[pl]=Rozwiązywanie równań i rysowanie wykresów
+Comment[pt]=Resolução e Desenho de Expressões Matemáticas
+Comment[pt_BR]=Solucionador e visualizador de expressões matemáticas
+Comment[ru]=Решение и построение графиков математических выражений
+Comment[sk]=Riešiteľ a zapisovač matematických výrazov
+Comment[sl]=Reševalnik matematičnih enačb in risalnik grafov
+Comment[sv]=Lösning och uppritning av matematiska uttryck
+Comment[tr]=Matematiksel İfade Çözücü ve Çizici
+Comment[ug]=ماتېماتىكىلىق ئىپادىلەرنى يېشىش ۋە سىزىش قورالى
+Comment[uk]=Розв’язувач математичних виразів та графопобудовник
+Comment[x-test]=xxMath Expression Solver and Plotterxx
+Comment[zh_CN]=解数学式与绘图的工具
+Comment[zh_TW]=數學解題與繪圖
+Exec=kalgebra %u
+MimeType=application/x-kalgebra;
+Icon=kalgebra
+Type=Application
+X-DocPath=kalgebra/index.html
+Terminal=false
+Categories=Qt;KDE;Education;Math;Science;
+X-DBUS-ServiceName=org.kde.kalgebra
diff --git a/src/varedit.cpp b/src/varedit.cpp
new file mode 100644 (file)
index 0000000..af8de17
--- /dev/null
@@ -0,0 +1,132 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "varedit.h"
+#include <analitza/analyzer.h>
+#include <analitza/expression.h>
+#include <analitza/variables.h>
+#include <analitzagui/expressionedit.h>
+
+#include <QPushButton>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <klocalizedstring.h>
+
+VarEdit::VarEdit(QWidget *parent, bool modal)
+    : QDialog(parent), vars(0), m_correct(false)
+{
+    setWindowTitle(i18n("Add/Edit a variable"));
+    setModal(modal);
+
+    m_buttonBox = new QDialogButtonBox(this);
+    m_buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+    m_removeBtn = m_buttonBox->addButton(i18n("Remove Variable"), QDialogButtonBox::DestructiveRole);
+    m_removeBtn->setIcon(QIcon::fromTheme(QStringLiteral("edit-table-delete-row")));
+    
+    connect(m_removeBtn, &QAbstractButton::clicked, this, &VarEdit::removeVariable);
+    
+    connect( this, SIGNAL(applyClicked()), this, SLOT(accept()) );
+    connect( this, SIGNAL(okClicked()), this, SLOT(reject()) );
+    
+    m_exp = new Analitza::ExpressionEdit(this);
+    connect(m_exp, &QPlainTextEdit::textChanged, this, &VarEdit::edit);
+    connect(m_exp, &Analitza::ExpressionEdit::returnPressed, this, &VarEdit::ok);
+    
+    m_valid = new QLabel(this);
+    
+    QVBoxLayout *topLayout = new QVBoxLayout(this);
+    topLayout->addWidget(m_exp);
+    topLayout->addWidget(m_valid);
+    topLayout->addWidget(m_buttonBox);
+    
+    m_exp->setFocus();
+}
+
+void VarEdit::setName(const QString& newVar)
+{
+    m_var=newVar;
+    setWindowTitle(i18n("Edit '%1' value", newVar));
+    if(!vars)
+        m_exp->setText(i18n("not available"));
+    else {
+        m_exp->setExpression(Analitza::Expression(vars->value(newVar)->copy()));
+    }
+    m_removeBtn->setEnabled(vars && canRemove(newVar));
+}
+
+bool VarEdit::canRemove(const QString& name) const
+{
+    QHash<QString, Analitza::Object*>::const_iterator it = vars->constBegin(), itEnd = vars->constEnd();
+    for(; it!=itEnd; ++it) {
+        QStringList deps = AnalitzaUtils::dependencies(*it, QStringList());
+        if(deps.contains(name)) {
+            return false;
+        }
+    }
+    return true;
+}
+
+Analitza::Expression VarEdit::val()
+{
+    Analitza::Expression val;
+    Analitza::Analyzer a(vars);
+    
+    a.setExpression(m_exp->expression());
+    
+    if(a.isCorrect()) {
+        a.simplify();
+        val=a.expression();
+    }
+    
+    m_correct = a.isCorrect();
+    if(m_correct) {
+        m_valid->setText(i18n("<b style='color:#090'>%1 := %2</b>", m_var, val.toString()));
+        m_valid->setToolTip(QString());
+    } else {
+        m_valid->setText(i18n("<b style='color:red'>WRONG</b>"));
+        m_valid->setToolTip(a.errors().join(QStringLiteral("\n")));
+    }
+    m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_correct);
+    m_exp->setCorrect(m_correct);
+    
+    return val;
+}
+
+void VarEdit::edit()
+{
+    val();
+}
+
+void VarEdit::ok()
+{
+    if(m_correct)
+        accept();
+}
+
+void VarEdit::setAnalitza(Analitza::Analyzer * na)
+{
+    vars= na->variables();
+    m_exp->setAnalitza(na);
+}
+
+void VarEdit::removeVariable()
+{
+    vars->remove(m_var);
+    close();
+}
diff --git a/src/varedit.h b/src/varedit.h
new file mode 100644 (file)
index 0000000..f100dc4
--- /dev/null
@@ -0,0 +1,73 @@
+/*************************************************************************************
+ *  Copyright (C) 2007 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef VAREDIT_H
+#define VAREDIT_H
+
+#include <QDialog>
+#include <QLabel>
+
+class QDialogButtonBox;
+namespace Analitza
+{
+class Analyzer;
+class Variables;
+class Expression;
+class ExpressionEdit;
+}
+
+/**
+ *    The VarEdit provides a dialog to allow users to edit/create a variable.
+ *    @author Aleix Pol i Gonzalez
+ */
+
+class VarEdit : public QDialog
+{
+    Q_OBJECT
+    public:
+        /** Constructor. Creates a variable editing dialog. */
+        explicit VarEdit(QWidget *parent = 0, bool modal = false);
+        
+        /** Sets the editing variable name */
+        void setName(const QString& newVar);
+        
+        /** Sets an Analitza which will evaluate it. It may be interesting because variables can change. */
+        void setAnalitza(Analitza::Analyzer *na);
+        
+        /** Returns the resulting variable expression */
+        Analitza::Expression val();
+        
+    private:
+        bool canRemove(const QString& name) const;
+        
+        Analitza::ExpressionEdit *m_exp;
+        
+        QLabel *m_valid;
+        Analitza::Variables *vars;
+        bool m_correct;
+        QString m_var;
+        QDialogButtonBox* m_buttonBox;
+        QPushButton* m_removeBtn;
+
+    private Q_SLOTS:
+        void edit();
+        void ok();
+        void removeVariable();
+};
+
+#endif
diff --git a/src/variablesdelegate.cpp b/src/variablesdelegate.cpp
new file mode 100644 (file)
index 0000000..3173878
--- /dev/null
@@ -0,0 +1,41 @@
+/*************************************************************************************
+ *  Copyright (C) 2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "variablesdelegate.h"
+
+#include <QDoubleSpinBox>
+
+QWidget* VariablesDelegate::createEditor(QWidget* p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const
+{
+    QVariant val=idx.model()->data(idx);
+    if(val.type()==QVariant::Double) {
+        QDoubleSpinBox* spin=new QDoubleSpinBox(p);
+        spin->setDecimals(10);
+        return spin;
+    } else
+        return QItemDelegate::createEditor(p, opt, idx);
+}
+
+void VariablesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
+{
+    QDoubleSpinBox* spin=qobject_cast<QDoubleSpinBox*>(editor);
+    if(spin)
+        spin->setValue(index.model()->data(index).value<double>());
+    else
+        QItemDelegate::setEditorData(editor, index);
+}
diff --git a/src/variablesdelegate.h b/src/variablesdelegate.h
new file mode 100644 (file)
index 0000000..f486877
--- /dev/null
@@ -0,0 +1,32 @@
+/*************************************************************************************
+ *  Copyright (C) 2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef VARIABLESDELEGATE_H
+#define VARIABLESDELEGATE_H
+
+#include <QItemDelegate>
+
+class VariablesDelegate : public QItemDelegate
+{
+    public:
+        VariablesDelegate(QObject* parent=0) : QItemDelegate(parent) {}
+        virtual QWidget* createEditor (QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const;
+        virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
+};
+
+#endif // VARIABLESDELEGATE_H
diff --git a/src/viewportwidget.cpp b/src/viewportwidget.cpp
new file mode 100644 (file)
index 0000000..9ef317a
--- /dev/null
@@ -0,0 +1,76 @@
+/*************************************************************************************
+ *  Copyright (C) 2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include "viewportwidget.h"
+
+#include <QFormLayout>
+#include <QDoubleSpinBox>
+#include <QPushButton>
+#include <klocalizedstring.h>
+#include <limits>
+
+ViewportWidget::ViewportWidget(QWidget * parent)
+    : QWidget (parent)
+{
+    m_top=new QDoubleSpinBox(this);
+    m_left=new QDoubleSpinBox(this);
+    m_width=new QDoubleSpinBox(this);
+    m_height=new QDoubleSpinBox(this);
+
+//     const double LIMIT=std::numeric_limits<double>::max();
+    //Can't use limit, because otherwise Qt uses the value for the sizeHint and
+    //we get a huge window
+    const double LIMIT=5000;
+    m_top->setRange(-LIMIT, LIMIT);
+    m_left->setRange(-LIMIT, LIMIT);
+    m_width->setRange(0, LIMIT);
+    m_height->setRange(0, LIMIT);
+
+    QVBoxLayout* upperLayout=new QVBoxLayout;
+    QFormLayout* layout=new QFormLayout;
+    layout->addRow(i18n("Left:"), m_left);
+    layout->addRow(i18n("Top:"), m_top);
+    layout->addRow(i18n("Width:"), m_width);
+    layout->addRow(i18n("Height:"), m_height);
+
+    QPushButton *apply=new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18n("Apply"), this);
+    connect(apply, &QAbstractButton::clicked, this, &ViewportWidget::emitViewport);
+
+    upperLayout->addLayout(layout);
+    upperLayout->addWidget(apply);
+    setLayout(upperLayout);
+}
+
+QRectF ViewportWidget::viewport() const
+{
+    return QRectF(m_left->value(), m_top->value(),
+                  m_width->value(), -m_height->value());
+}
+
+void ViewportWidget::setViewport(const QRectF& current)
+{
+    m_top->setValue(current.top());
+    m_left->setValue(current.left());
+    m_width->setValue(current.width());
+    m_height->setValue(-current.height());
+}
+
+void ViewportWidget::emitViewport ()
+{
+    emit viewportChange(viewport());
+}
diff --git a/src/viewportwidget.h b/src/viewportwidget.h
new file mode 100644 (file)
index 0000000..b66a80f
--- /dev/null
@@ -0,0 +1,49 @@
+/*************************************************************************************
+ *  Copyright (C) 2009 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#ifndef VIEWPORTWIDGET_H
+#define VIEWPORTWIDGET_H
+
+#include <QWidget>
+class QDoubleSpinBox;
+
+class ViewportWidget : public QWidget
+{
+    Q_OBJECT
+    public:
+        explicit ViewportWidget(QWidget * parent = 0);
+        
+        QRectF viewport() const;
+        
+    public Q_SLOTS:
+        void setViewport(const QRectF& current);
+        
+    private Q_SLOTS:
+        void emitViewport();
+        
+    Q_SIGNALS:
+        void viewportChange(const QRectF& newViewport);
+        
+    private:
+        QDoubleSpinBox* m_left;
+        QDoubleSpinBox* m_top;
+        QDoubleSpinBox* m_width;
+        QDoubleSpinBox* m_height;
+};
+
+#endif // VIEWPORTDIALOG_H
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100644 (file)
index 0000000..36236e4
--- /dev/null
@@ -0,0 +1,2 @@
+add_executable(docbook_analitzacommands main.cpp)
+target_link_libraries(docbook_analitzacommands KF5::AnalitzaGui Qt5::Widgets Qt5::Core)
diff --git a/utils/main.cpp b/utils/main.cpp
new file mode 100644 (file)
index 0000000..66f88fa
--- /dev/null
@@ -0,0 +1,59 @@
+/*************************************************************************************
+ *  Copyright (C) 2010 by Aleix Pol <aleixpol@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   *
+ *************************************************************************************/
+
+#include <analitzagui/operatorsmodel.h>
+#include <QApplication>
+#include <QStringList>
+#include <QFile>
+#include <QTextStream>
+
+int main(int argc, char** argv)
+{
+    QApplication app(argc, argv);
+    OperatorsModel m;
+    
+    QFile f(app.arguments().last());
+    bool fileopened = f.open(QFile::WriteOnly);
+    Q_ASSERT(fileopened);
+    
+    QTextStream str(&f);
+    str.setCodec("UTF-8");
+    
+    str << "<!-- this file is autogenerated, if any change has to be done, please "
+                "fix kdeedu/kalgebra/utils/main.cpp and its dependencies. "
+                "Thank you, Aleix Pol -->";
+    str << "<chapter id='commands'>\n"
+                "<title>Commands supported by KAlgebra</title>\n";
+    
+    int rows = m.rowCount(), cols = m.columnCount();
+    QStringList colHeaders;
+    for(int i=0; i<cols; i++)
+        colHeaders += m.headerData(i, Qt::Horizontal).toString();
+    
+    for(int i=0; i<rows; i++) {
+        QString id = m.index(i,0).data().toString();
+        str << "\t<sect1 id='" << id << "'><title>" << id << "</title><itemizedlist>\n";
+        for(int c=0; c<cols; c++)
+            str << QStringLiteral("\t\t<listitem><para>%1: %2</para></listitem>").arg(colHeaders[c]).arg(m.index(i,c).data().toString().toHtmlEscaped()) << '\n';
+        
+        str << "\t</itemizedlist></sect1>\n";
+    }
+    str << "</chapter>\n";
+    
+    return 0;
+}