diff --git a/CMakeLists.txt b/CMakeLists.txt index bef574c2..fa6b288f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,96 +1,95 @@ project(cantor) cmake_minimum_required (VERSION 3.1.0 FATAL_ERROR) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_definitions(-DMAKE_CANTORLIBS_LIB) - # KDE Application Version, managed by release script set (KDE_APPLICATIONS_VERSION_MAJOR "18") set (KDE_APPLICATIONS_VERSION_MINOR "11") set (KDE_APPLICATIONS_VERSION_MICRO "70") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") set(KF5_MIN_VERSION "5.49.0") find_package(ECM 5.15.0 REQUIRED CONFIG) set(CMAKE_MODULE_PATH ${cantor_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) find_package(Qt5 5.6.0 CONFIG REQUIRED Core Widgets PrintSupport Svg Xml XmlPatterns Test) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED Config Crash Completion DocTools NewStuff IconThemes TextEditor CoreAddons Archive Parts SyntaxHighlighting TextWidgets KIO XmlGui I18n) if(NOT WIN32) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED Pty) endif() include(FeatureSummary) include(ECMInstallIcons) include(ECMSetupVersion) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings) include(ECMAddAppIcon) +include(GenerateExportHeader) if(NOT WIN32) set_package_properties(LibSpectre PROPERTIES DESCRIPTION "A PostScript rendering library" URL "http://libspectre.freedesktop.org/wiki/" TYPE OPTIONAL PURPOSE "Support for rendering EPS files in Cantor") find_package(LibSpectre) if(LIBSPECTRE_FOUND) set(WITH_EPS On) else(LIBSPECTRE_FOUND) set(WITH_EPS Off) endif(LIBSPECTRE_FOUND) else(NOT WIN32) set(WITH_EPS Off) endif(NOT WIN32) find_package(Discount 2.2.0) set_package_properties(Discount PROPERTIES DESCRIPTION "A C implementation of the Markdown markup language" URL "https://www.pell.portland.or.us/~orc/Code/discount/" TYPE OPTIONAL PURPOSE "Used for Markdown entries in Cantor") add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) if (CMAKE_BUILD_TYPE STREQUAL "RELEASE") add_definitions(-DQT_NO_DEBUG_OUTPUT) endif (CMAKE_BUILD_TYPE STREQUAL "RELEASE") kde_enable_exceptions() add_subdirectory(doc) add_subdirectory(src) add_subdirectory(icons) install(FILES org.kde.cantor.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/backends/maxima/CMakeLists.txt b/src/backends/maxima/CMakeLists.txt index 82ab5305..8ad1e96c 100644 --- a/src/backends/maxima/CMakeLists.txt +++ b/src/backends/maxima/CMakeLists.txt @@ -1,35 +1,33 @@ set( MaximaBackend_SRCS maximabackend.cpp maximasession.cpp maximaexpression.cpp maximaextensions.cpp maximahighlighter.cpp maximakeywords.cpp maximacompletionobject.cpp maximasyntaxhelpobject.cpp maximavariablemodel.cpp ) kconfig_add_kcfg_files(MaximaBackend_SRCS settings.kcfgc) install(FILES maximabackend.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) ki18n_wrap_ui(MaximaBackend_SRCS settings.ui) add_backend(maximabackend ${MaximaBackend_SRCS}) -if(NOT WIN32) - target_link_libraries(cantor_maximabackend KF5::Pty KF5::SyntaxHighlighting) -endif(NOT WIN32) +target_link_libraries(cantor_maximabackend KF5::SyntaxHighlighting) if(BUILD_TESTING) add_executable( testmaxima testmaxima.cpp) add_test(NAME testmaxima COMMAND testmaxima) target_link_libraries( testmaxima Qt5::Test cantorlibs cantortest ) endif() install( FILES cantor_maxima.knsrc DESTINATION ${KDE_INSTALL_CONFDIR} ) install( FILES cantor-initmaxima.lisp DESTINATION ${KDE_INSTALL_DATADIR}/cantor/maximabackend) diff --git a/src/backends/python/CMakeLists.txt b/src/backends/python/CMakeLists.txt index 2c1a9659..2d10bf67 100644 --- a/src/backends/python/CMakeLists.txt +++ b/src/backends/python/CMakeLists.txt @@ -1,26 +1,28 @@ set( PythonBackend_SRCS pythonbackend.cpp pythonsession.cpp pythonexpression.cpp pythonkeywords.cpp pythonhighlighter.cpp pythoncompletionobject.cpp pythonextensions.cpp ) qt5_add_resources(PythonBackend_RSCS python.qrc) ki18n_wrap_ui(PythonBackend_SRCS settings.ui) add_library(cantor_pythonbackend SHARED ${PythonBackend_SRCS} ${PythonBackend_RSCS}) +generate_export_header(cantor_pythonbackend) + target_link_libraries(cantor_pythonbackend cantorlibs KF5::KIOCore KF5::ConfigCore KF5::ConfigGui KF5::SyntaxHighlighting Qt5::DBus ) install(TARGETS cantor_pythonbackend DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) #install(DIRECTORY . DESTINATION ${KDE_INSTALL_DATADIR}/cantor/pythonbackend FILES_MATCHING PATTERN "*.py") diff --git a/src/backends/python/pythonbackend.h b/src/backends/python/pythonbackend.h index 035da6d6..0afc9efc 100644 --- a/src/backends/python/pythonbackend.h +++ b/src/backends/python/pythonbackend.h @@ -1,40 +1,41 @@ /* 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. --- Copyright (C) 2012 Filipe Saraiva */ #ifndef _PYTHONBACKEND_H #define _PYTHONBACKEND_H #include "backend.h" +#include -class CANTOR_EXPORT PythonBackend : public Cantor::Backend +class CANTOR_PYTHONBACKEND_EXPORT PythonBackend : public Cantor::Backend { Q_OBJECT public: explicit PythonBackend(QObject* parent = nullptr, const QList args = QList()); ~PythonBackend() override; Cantor::Backend::Capabilities capabilities() const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override = 0; }; #endif /* _PYTHONBACKEND_H */ diff --git a/src/backends/python/pythonsession.h b/src/backends/python/pythonsession.h index 9a6c6c01..cd5574ea 100644 --- a/src/backends/python/pythonsession.h +++ b/src/backends/python/pythonsession.h @@ -1,106 +1,107 @@ /* 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. --- Copyright (C) 2012 Filipe Saraiva Copyright (C) 2015 Minh Ngo */ #ifndef _PYTHONSESSION_H #define _PYTHONSESSION_H #include "session.h" +#include #include namespace Cantor { class DefaultVariableModel; } class PythonExpression; class KDirWatch; class QDBusInterface; class KProcess; -class CANTOR_EXPORT PythonSession : public Cantor::Session +class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session { Q_OBJECT public: PythonSession(Cantor::Backend* backend, int pythonVersion, const QString serverName, const QString DbusChannelName); ~PythonSession() override = default; void login() override; void logout() override; void interrupt() override; void runExpression(PythonExpression* expr); Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; Cantor::CompletionObject* completionFor(const QString& command, int index=-1) override; QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; QAbstractItemModel* variableModel() override; void setWorksheetPath(const QString& path) override; virtual bool integratePlots() const = 0; virtual QStringList autorunScripts() const = 0; private: KDirWatch* m_watch; QStringList m_listPlotName; Cantor::DefaultVariableModel* m_variableModel; QList m_runningExpressions; PythonExpression* m_currentExpression; QDBusInterface* m_pIface; KProcess* m_pProcess; QString serverName; QString DbusChannelName; QString worksheetPath; protected: QString m_output; QString m_error; private: void listVariables(); void getPythonCommandOutput(const QString& commandProcessing); QString identifyPythonModule(const QString& command) const; QString identifyVariableModule(const QString& command) const; bool identifyKeywords(const QString& command); void runPythonCommand(const QString& command) const; QString getOutput() const; QString getError() const; virtual void readExpressionOutput(const QString& commandProcessing); protected: void updateOutput(); private Q_SLOTS: void readOutput(const QString& commandProcessing); void plotFileChanged(const QString& filename); void expressionFinished(); Q_SIGNALS: void updateHighlighter(); void newVariable(const QString variable); }; #endif /* _PYTHONSESSION_H */ diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index a49f7eea..25cef825 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,91 +1,91 @@ set( cantor_LIB_SRCS session.cpp expression.cpp backend.cpp result.cpp textresult.cpp imageresult.cpp epsresult.cpp latexresult.cpp latexrenderer.cpp helpresult.cpp animationresult.cpp extension.cpp assistant.cpp completionobject.cpp syntaxhelpobject.cpp defaulthighlighter.cpp defaultvariablemodel.cpp panelplugin.cpp panelpluginhandler.cpp worksheetaccess.cpp directives/plotdirectives.cpp ) Set( cantor_LIB_HDRS cantor_macros.h - cantor_export.h #base classes backend.h session.h expression.h extension.h syntaxhelpobject.h completionobject.h #results animationresult.h epsresult.h helpresult.h imageresult.h latexresult.h result.h textresult.h #helper classes defaulthighlighter.h defaultvariablemodel.h worksheetaccess.h ) ki18n_wrap_ui(cantor_LIB_SRCS directives/axisrange.ui directives/plottitle.ui) kconfig_add_kcfg_files(cantor_LIB_SRCS settings.kcfgc) install(FILES cantor_libs.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) configure_file (config-cantorlib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-cantorlib.h ) add_library( cantorlibs SHARED ${cantor_LIB_SRCS} ) +generate_export_header(cantorlibs BASE_NAME cantor) kcoreaddons_desktop_to_json(cantorlibs cantor_assistant.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_backend.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_panelplugin.desktop DEFAULT_SERVICE_TYPE) target_link_libraries( cantorlibs KF5::Completion KF5::IconThemes KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::Archive KF5::ConfigCore KF5::ConfigGui KF5::I18n KF5::XmlGui ${QT5_LIBRARIES} Qt5::Xml ) set_target_properties( cantorlibs PROPERTIES VERSION ${KDE_APPLICATIONS_VERSION} SOVERSION 18 ) install( TARGETS cantorlibs ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES ${cantor_LIB_HDRS} DESTINATION ${KDE_INSTALL_INCLUDEDIR}/cantor COMPONENT Devel ) if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/src/lib/assistant.h b/src/lib/assistant.h index 95e0415b..8809a54a 100644 --- a/src/lib/assistant.h +++ b/src/lib/assistant.h @@ -1,115 +1,115 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _ASSISTANT_H #define _ASSISTANT_H #include #include #include -#include "cantor_export.h" +#include namespace Cantor { class Backend; class AssistantPrivate; /** * An Assistant is a dialog for simplifying common tasks, like integrating, solving, or running scripts * To perform their task, they rely on one or more Extensions, to translate to the backends specific syntax. * @see Extension */ class CANTOR_EXPORT Assistant : public QObject, public KXMLGUIClient { Q_OBJECT public: /** * Create a new assistant * @param parent the parent Object @see QObject **/ explicit Assistant( QObject* parent ); /** * Destructor */ ~Assistant() override; /** * Sets the backend, this Assistant operates on * @param backend the new backend */ void setBackend(Backend* backend); /** * Sets the properties of this Assistant * according to KPluginMetaData * @param info KPluginMetaData */ void setPluginInfo(KPluginMetaData info); /** * Returns a list of all extensions, the current backend * must provide to make this Assistant work. If it doesn't * this Assistant won't be shown in the Menu * @return list of required extensions */ QStringList requiredExtensions(); /** * shows the assistants dialog or gui it offers, and returns a list of commands * to be run, to achieve the desired effect * @param parent the parent widget, each created Widget should use */ virtual QStringList run(QWidget* parent) = 0; /** * initialize the needed KActions/integrate into the menu bars */ virtual void initActions() = 0; /** * Returns the icon, this Assistant is using * @return icon, this Assistant is using */ QString icon(); /** * Returns the name of the assistant * @return name of the assistant */ QString name(); /** * Returns the backend, this assistant operates on * @return backend, this assistant operates on */ Backend* backend(); Q_SIGNALS: /** * signal emitted, if the user has requested this Assistant to run * e.g. by clicking on its action in the menu */ void requested(); private: AssistantPrivate* d; }; } #endif /* _ASSISTANT_H */ diff --git a/src/lib/backend.h b/src/lib/backend.h index 1a596731..586c4543 100644 --- a/src/lib/backend.h +++ b/src/lib/backend.h @@ -1,218 +1,218 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _BACKEND_H #define _BACKEND_H #include #include #include #include -#include "cantor_export.h" +#include class KConfigSkeleton; class QWidget; /** * Namespace collecting all Classes of the Cantor Libraries */ namespace Cantor { class Session; class Extension; class BackendPrivate; /** * The Backend class provides access to information about the backend. * It provides access to what features are supported by the backend, and * a factory method to create a new Session * It needs to be subclassed by all Backends. * * @author Alexander Rieder */ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient { Q_OBJECT public: /** * This enum is used to specify the Features, supported by a backend. */ enum Capability{ Nothing = 0x0, ///< the Backend doesn't support any of the optional features LaTexOutput = 0x1, ///< it can output results as LaTeX code InteractiveMode = 0x2, /**< it supports an interactive workflow. (It means a command can ask for additional input while running */ SyntaxHighlighting = 0x4, ///< it offers a custom Syntax Highlighter Completion = 0x8, ///< it offers completion of partially typed commands SyntaxHelp = 0x10, /**< it offers help about a commands syntax, that will be shown in a tooltip */ VariableManagement= 0x20 ///< it offers access to the variables (for variable management panel) }; Q_DECLARE_FLAGS(Capabilities, Capability) protected: /** * Create a new Backend. Normally the static createBackend factory method * should be used. * @param parent the Parent object * @param args optional arguments (not used) */ explicit Backend( QObject* parent = nullptr,const QList& args=QList() ); /** * Destructor. Doesn't anything. */ ~Backend() override; public: /** * Creates a new Session. It is the way to go to create a Session, * don't call new Session on your own. * @return a new Session of this Backend, or 0 if creating failed */ virtual Session* createSession() = 0; /** * Returns list of the supported optional features * @return a list of features, containing items of the Capability enum, ORed together */ virtual Capabilities capabilities() const = 0; /** * Returns whether all of this backends requirements are fulfilled, or if some are missing. * @return @c true if all the requirements needed to use this Backend are fulfilled * @return @c false some requirements are missing. e.g. the maxima executable can not be found * @see Capability */ virtual bool requirementsFullfilled() const; /** * Returns a unique string to identify this backend. * In contrast to name() this string isn't translated * @return string to identify backend */ virtual QString id() const = 0; /** * Returns the recommended version of the backend supported by Cantor * @return the recommended version of the backend */ virtual QString version() const; //Stuff extracted from the .desktop file /** * Returns the name of the backend * @return the backends name */ QString name() const; /** * Returns a short comment about the backend. * @return comment about the backend */ QString comment() const; /** * Returns the icon to use with this backend * @return name of the icon */ QString icon() const; /** * Returns the Url of the Homepage for the Backend * @return the url */ QString url() const; /** * Returns an Url pointing to the Help of the Backend * The method should be overwritten by all Backends(who have an online help) * You should make the returned Url translateble, e.g. by doing something like: * return i18nc("the url to the documentation of KAlgebra, please check if there is a translated version and use the correct url", * "http://docs.kde.org/stable/en/kdeedu/kalgebra/"); * @return Url of the help */ virtual QUrl helpUrl() const; /** * Returns if the backend should be enabled (shown in the Backend dialog) * @return @c true, if the enabled flag is set to true, and the requirements are fulfilled * @return @c false, if the backend was purposly disabled, or requirements are missing * @see requirementsFullfilled() */ bool isEnabled() const; /** * Enables/disables this backend * @param enabled true to enable backend false to disable */ void setEnabled(bool enabled); /** * Returns a longer description of the Backend, e.g. purpose, strengths etc. * It should help the user to decide between the different Backends * @return a description of the backend. It can contain html */ virtual QString description() const; /** * Returns a Widget for configuring this backend * @return Widget for usage in the Settings dialog */ virtual QWidget* settingsWidget(QWidget* parent) const; /** * Returns a KConfig object, containing all the settings, * the backend might need * @return a KConfigSkeleton object, for configuring this backend */ virtual KConfigSkeleton* config() const; /** * Returns a list of the names of all the Extensions supported by this backend * @return a list of the names of all the Extensions supported by this backend * @see extension(const QString& name) */ QStringList extensions() const; /** * Returns an Extension of this backend for the given name, or null * if the Backend doesn't have an extension with this name. * @return Pointer to the Extension object with the given name */ Extension * extension(const QString& name) const; /** * Returns a list of the names of all the installed and enabled backends * @return a list of the names of all the installed and enabled backends * @see isEnabled() */ static QStringList listAvailableBackends(); /** * Returns Pointers to all the installed backends * @return Pointers to all the installed backends */ static QList availableBackends(); /** * Returns the backend with the given name, or null if it isn't found * @return the backend with the given name, or null if it isn't found */ static Backend* createBackend(const QString& name); private: BackendPrivate* d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(Backend::Capabilities) } #endif /* _BACKEND_H */ diff --git a/src/lib/cantor_export.h b/src/lib/cantor_export.h deleted file mode 100644 index 6550ac76..00000000 --- a/src/lib/cantor_export.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - 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. - - --- - Copyright (C) 2009 Alexander Rieder - */ - -#ifndef _CANTOR_EXPORT_H -#define _CANTOR_EXPORT_H - -#ifndef CANTOR_EXPORT -# if defined(MAKE_CANTORLIBS_LIB) -// We are building this library -# define CANTOR_EXPORT Q_DECL_EXPORT -# else -// We are using this library -# define CANTOR_EXPORT Q_DECL_IMPORT -# endif -#endif - -#ifndef CANTORTEST_EXPORT -# if defined(MAKE_CANTORTEST_LIB) -// We are building this library -# define CANTORTEST_EXPORT Q_DECL_EXPORT -# else -// We are using this library -# define CANTORTEST_EXPORT Q_DECL_IMPORT -# endif -#endif - -# ifndef CANTOR_EXPORT_DEPRECATED -# define CANTOR_EXPORT_DEPRECATED Q_DECL_DEPRECATED CANTOR_EXPORT -# endif - -#endif /* _CANTOR_EXPORT_H */ diff --git a/src/lib/completionobject.h b/src/lib/completionobject.h index 6aeebb6b..2e23157b 100644 --- a/src/lib/completionobject.h +++ b/src/lib/completionobject.h @@ -1,224 +1,224 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _COMPLETIONOBJECT_H #define _COMPLETIONOBJECT_H #include -#include "cantor_export.h" +#include namespace Cantor { class CompletionObjectPrivate; class Session; /** * This Object is used to provide a Tab Completion, in an asynchronous way. * Each backend, supporting tab completion, needs to provide their own * CompletionObject, that reimplements the fetching of the completions * and emits done() as soon as the completions are available * * @author Alexander Rieder */ class CANTOR_EXPORT CompletionObject : public KCompletion { Q_OBJECT public: /** * Constructor * @param parent the session, this object belongs to */ explicit CompletionObject(Session* parent); ///Destructor ~CompletionObject() override; enum LineCompletionMode { PreliminaryCompletion, ///< Only insert the completion FinalCompletion ///< also add () for functions, etc }; /** * Returns a list of completions * @return a list of completions */ QStringList completions() const; /** * Returns the last completion * @return the last completion */ QString completion() const; /** * returns the command, this completion is for * @return the command, this completion is for */ QString command() const; /** * returns the session, this object belongs to * @return the session, this object belongs to */ Session* session() const; /** * Sets the line and cursor index at which a completion should be found * This triggers an asynchronous fetching of completions, * which emits done() when done. * @param line the line that is to be completed * @param index the cursor postition in line */ void setLine(const QString& line, int index); /** * Takes the changed line and updates the command accordingly. * This triggers an asynchronous fetching of completions, * which emits done() when done. * @param line the line that is to be completed * @param index the cursor position in line */ void updateLine(const QString& line, int index); /** * Takes a completion and a completion mode and triggers and calculates * the new line with this completion. If the completion mode is * FinalCompletion some postprocessing is done asynchronously. * Emits lineDone when finished. * @param comp the completion that's to be processed * @param type whether the completion is final */ void completeLine(const QString& comp, LineCompletionMode mode); protected: enum IdentifierType { VariableType, ///< a variable FunctionWithArguments, ///< a function that takes arguments FunctionType = FunctionWithArguments, ///< an alias for function with arguments FunctionWithoutArguments, ///< a function that takes no arguments KeywordType, ///< a keyword UnknownType ///< no identifier type was found }; /** * returns the identifier for fetchIdentifierType * @return the identifier for fetchIdentifierType */ QString identifier() const; /** * Sets the completions * @param completions list of possible completions */ void setCompletions(const QStringList& completions); /** * sets the command/command-part * @param cmd the command/command-part */ void setCommand(const QString& cmd); /** * Find an identifier in cmd that ends at index * @param cmd the command * @param index the index to look at */ virtual int locateIdentifier(const QString& cmd, int index) const; /** * return true if c may be used in identifier names * @param c the character */ virtual bool mayIdentifierContain(QChar c) const; /** * return true if identifier names can begin with c * @param c the character */ virtual bool mayIdentifierBeginWith(QChar c) const; /** * Completes line with function identifier and emits lineDone with the * completed line. Helper function for completeLine. * @param type whether the function takes arguments, default: FunctionWithArguments */ void completeFunctionLine(IdentifierType type = FunctionWithArguments); /** * Completes line with keyword identifier and emits lineDone with the * completed line. Helper function for completeLine. */ void completeKeywordLine(); /** * Completes line with variable identifier and emits lineDone with the * completed line. Helper function for completeLine. */ void completeVariableLine(); /** * Completes line with identifier of unknown type and emits lineDone with * the completed line. Helper function for completeLine. */ void completeUnknownLine(); protected Q_SLOTS: /** * This function should be reimplemented to start the actual fetching * of the completions. It can be asynchronous. * Remember to emit fetchingDone, if the fetching is complete */ virtual void fetchCompletions() = 0; /** * Fetch the identifier type of d->identifier; reimplemented in * the backends. Emit fetchingTypeDone when done. */ virtual void fetchIdentifierType(); /** * Find the completion. To be called when fetching is done. * Emits done() when done. */ void findCompletion(); /** * Calls the appropriate complete*Line based on type * @param type the identifier type found in line() */ void completeLineWithType(Cantor::CompletionObject::IdentifierType type); /** * Handle a completion request after a opening parenthesis. * @param type the type of the identifier before the parenthesis */ void handleParenCompletionWithType(Cantor::CompletionObject::IdentifierType type); Q_SIGNALS: /** * indicates that the fetching of completions is done */ void fetchingDone(); /** * indicates that the type of identifier() was found and passes the * type as an argument * @param type the identifier type */ void fetchingTypeDone(Cantor::CompletionObject::IdentifierType type); /** * indicates that the possible completions and a common completion string * have been found */ void done(); /** * emitted when the line completion is done, passes the new line and * the cursor index * @param line the new line * @param index the new cursor index */ void lineDone(QString line, int index); private: CompletionObjectPrivate* d; }; } #endif /* _COMPLETIONOBJECT_H */ diff --git a/src/lib/defaulthighlighter.h b/src/lib/defaulthighlighter.h index 82953872..4b59aeaa 100644 --- a/src/lib/defaulthighlighter.h +++ b/src/lib/defaulthighlighter.h @@ -1,183 +1,183 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef DEFAULTHIGHLIGHTER_H #define DEFAULTHIGHLIGHTER_H -#include "cantor_export.h" +#include #include class QGraphicsTextItem; namespace Cantor { class DefaultHighlighterPrivate; /** * The DefaultHighlighter is an implementation QSyntaxHighlighter. * It covers most common cases of syntax highlighting for Cantor's command entries. * * When creating a custom highlighter, for example for a new backend, you should use * the provided functions addPairs(), addRule() and/or addRules(). * * If you need more specific functionality, subclass highlightBlock(). Usually it's a good idea to also call * DefaultHighlighter's implementation from it. * * @author Alexander Rieder */ class CANTOR_EXPORT DefaultHighlighter : public QSyntaxHighlighter { Q_OBJECT public: explicit DefaultHighlighter(QObject* parent); ~DefaultHighlighter() override; /** * Change the item being highlighted. */ void setTextItem(QGraphicsTextItem* item); public Q_SLOTS: /** * Called when the cursor moved. Rehighlights accordingly. */ void positionChanged(const QTextCursor&); protected: /** * This method is called by Cantor's KTextEdit and is where all the highlighting must take place. * The default implementation calls highlightPairs(), highlightWords() and highlightRegExps(). * */ void highlightBlock(const QString& text) override; bool skipHighlighting(const QString& text); QTextCharFormat functionFormat() const; QTextCharFormat variableFormat() const; QTextCharFormat objectFormat() const; QTextCharFormat keywordFormat() const; QTextCharFormat numberFormat() const; QTextCharFormat operatorFormat() const; QTextCharFormat errorFormat() const; QTextCharFormat commentFormat() const; QTextCharFormat stringFormat() const; QTextCharFormat matchingPairFormat() const; QTextCharFormat mismatchingPairFormat() const; /** * Call this to add a pair of symbols for highlighting. * The default implementation of the class already adds (), {} and [], so no need to add those. * For example, if you wanted to highlight angle-brackets, you would use: * @code * addPair('<', '>'); * @endcode * @param openSymbol the opening symbol of the pair * @param closeSymbol the closing symbol of the pair * @sa highlightPairs */ void addPair(QChar openSymbol, QChar closeSymbol); /** * Highlights all instances of the @p word in the text with the specified @p format * @param word the word to highlight * @param format the format to be used for displaying the word */ void addRule(const QString& word, const QTextCharFormat& format); /** * Highlights all parts of the text matched by the regular expression @p regexp in the text * with the specified @p format * @param regexp the regular expression used to look for matches * @param format the format used to display the matching parts of the text */ void addRule(const QRegExp& regexp, const QTextCharFormat& format); /** * Convenience method, highlights all items in @p conditions with the specified @p format * @code * QStringList greenWords; * greenWords << "tree" << "forest" << "grass"; * addRules(greenWords, greenWordFormat); * @endcode * @param conditions any Qt container of QRegExp or QString. */ void addRules(const QStringList& conditions, const QTextCharFormat& format); /** * Convenience method, equivalent to @code addRules(functions, functionFormat()) @endcode */ void addFunctions(const QStringList& functions); /** * Convenience method, equivalent to @code addRules(variables, variableFormat()) @endcode */ void addVariables(const QStringList& variables); /** * Convenience method, equivalent to @code addRules(keywords, keywordFormat()) @endcode */ void addKeywords(const QStringList& keywords); /** * Removes any rules previously added for the word @p word */ void removeRule(const QString& word); /** * Removes any rules previously added for the regular expression @p regexp */ void removeRule(const QRegExp& regexp); /** * Convenience method, removes all rules with conditions from @p conditions * @sa removeRule, addRules */ void removeRules(const QStringList& conditions); /** * Highlight pairs added with addPair() * @sa addPair */ void highlightPairs(const QString& text); /** * Highlights words added with addRule() * @sa addRule, addRules */ void highlightWords(const QString& text); /** * Highlights all matches from regular expressions added with addRule() * @sa addRule, addRules */ void highlightRegExps(const QString& text); /** * Returns a string that contains a regular expression that matches for characters thar are allowed inside * words for this backend. For example, maxima or scilab allow % at the beginning of variable names */ virtual QString nonSeparatingCharacters() const; private Q_SLOTS: void updateFormats(); Q_SIGNALS: void rulesChanged(); private: DefaultHighlighterPrivate* d; }; } #endif diff --git a/src/lib/directives/plotdirectives.h b/src/lib/directives/plotdirectives.h index f1f0e05d..4e014261 100644 --- a/src/lib/directives/plotdirectives.h +++ b/src/lib/directives/plotdirectives.h @@ -1,75 +1,75 @@ /* 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. --- Copyright (C) 2010 Oleksiy Protas */ #ifndef _PLOT_DIRECTIVES_H #define _PLOT_DIRECTIVES_H #include "extension.h" -#include "cantor_export.h" +#include //TODO: comments namespace Cantor { class CANTOR_EXPORT PlotTitleDirective : public AdvancedPlotExtension::PlotDirective { public: PLOT_DIRECTIVE_DISPATCHING(PlotTitleDirective); const QString& title() const; explicit PlotTitleDirective(const QString& str); static AdvancedPlotExtension::DirectiveProducer* widget(QWidget* parent); private: QString m_title; }; class CANTOR_EXPORT AbstractScaleDirective : public AdvancedPlotExtension::PlotDirective { public: PLOT_DIRECTIVE_DISPATCHING(AbstractScaleDirective); double min() const; double max() const; protected: AbstractScaleDirective(double a,double b); private: double m_min; double m_max; }; class CANTOR_EXPORT OrdinateScaleDirective : public AbstractScaleDirective { public: PLOT_DIRECTIVE_DISPATCHING(OrdinateScaleDirective); OrdinateScaleDirective(double a,double b); static AdvancedPlotExtension::DirectiveProducer* widget(QWidget* parent); }; class CANTOR_EXPORT AbscissScaleDirective : public AbstractScaleDirective { public: PLOT_DIRECTIVE_DISPATCHING(AbscissScaleDirective); AbscissScaleDirective(double a,double b); static AdvancedPlotExtension::DirectiveProducer* widget(QWidget* parent); }; } #endif // _PLOT_DIRECTIVES_H diff --git a/src/lib/epsresult.h b/src/lib/epsresult.h index 66bc4e66..4fe1d2e8 100644 --- a/src/lib/epsresult.h +++ b/src/lib/epsresult.h @@ -1,58 +1,58 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _EPSRESULT_H #define _EPSRESULT_H #include "result.h" -#include "cantor_export.h" +#include #include namespace Cantor { class EpsResultPrivate; class CANTOR_EXPORT EpsResult : public Result { public: enum {Type=5}; explicit EpsResult( const QUrl& url); ~EpsResult() override; QString toHtml() override; QString toLatex() override; QVariant data() override; QUrl url() override; int type() override; QString mimeType() override; QDomElement toXml(QDomDocument& doc) override; void saveAdditionalData(KZip* archive) override; void save(const QString& filename) override; private: EpsResultPrivate* d; }; } #endif /* _EPSRESULT_H */ diff --git a/src/lib/expression.h b/src/lib/expression.h index c36fb78f..e28789bb 100644 --- a/src/lib/expression.h +++ b/src/lib/expression.h @@ -1,261 +1,261 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _EXPRESSION_H #define _EXPRESSION_H #include #include -#include "cantor_export.h" +#include class KZip; /** * Namespace collecting all Classes of the Cantor Libraries */ namespace Cantor { class Session; class Result; class LatexRenderer; class ExpressionPrivate; /** * An Expression object is used, to store the information needed when running a command of a Session * Evaluation of Expression is an asynchronous process in most cases, so most of the members * of this class are not useful directly after its construction. Therefore there are signals * indicating, when the Expression goes through the different stages of the Running process. * An Expression is never constructed directly, but by using Session::evaluateExpression() * * @author Alexander Rieder */ class CANTOR_EXPORT Expression : public QObject { Q_OBJECT public: enum Status{ Computing, ///< The Expression is still being computed Done, ///< The Running of the Expression is finished successfully Error, ///< An Error occurred when running the Expression Interrupted, ///< The Expression was interrupted by the user while running Queued ///< The Expression is in expression queue, waited for Computing }; /** * Enum indicating how this Expression behaves on finishing */ enum FinishingBehavior { DoNotDelete, ///< This Expression will not be deleted. This is the normal behaviour DeleteOnFinish /** < The Object will delete itself when finished. This is used for fire-and-forget commands. * All output/results will be dropped */ }; /** * Expression constructor. Should only be called from Session::evaluateExpression * @param session the session, this Expression belongs to * @param internal \c true if this expression is internal expression */ explicit Expression( Session* session, bool internal = false); /** * destructor */ ~Expression() override; /** * Evaluate the Expression. before this is called, you should set the Command first * This method can be implemented asynchronous, thus the Evaluation doesn't need to happen in the method, * It can also only be scheduled for evaluating. * @see setCommand() */ virtual void evaluate() = 0; /** * Interrupt the running of the Expression. * This should set the state to Interrupted. */ virtual void interrupt() = 0; /** * Returns the unique id of the Expression * or -1 for internal expressions * @return the unique id of the Expression */ int id(); /** * set the id of the Expression. It should be unique * @param id the new Id */ void setId(int id); /** * set the finishing behaviour * @param behavior the new Finishing Behaviour */ void setFinishingBehavior(FinishingBehavior behavior); /** * get the Expressions finishing behaviour * @return the current finishing behaviour */ FinishingBehavior finishingBehavior(); /** * Sets the command, represented by this Expression * @param cmd the command */ void setCommand( const QString& cmd ); /** * Returns the command, represented by this Expression * @return the command, represented by this Expression */ QString command(); /** * Adds some additional information/input to this expression. * this is needed, when the Expression has emitted the needsAdditionalInformation signal, * and the user has answered the question. This is used for e.g. if maxima asks whether * n+1 is zero or not when running the command "integrate(x^n,x)" * This method is part of the InteractiveMode feature */ virtual void addInformation(const QString& information); /** * Sets the error message * @param cmd the error message * @see errorMessage() */ void setErrorMessage( const QString& cmd); /** * returns the Error message, if an error occurred during * the evaluation of the expression. * @return the error message */ QString errorMessage(); /** * The result of this Expression. It can have different types, represented by various * subclasses of Result, like text, image, etc. * The result will be null, until the computation is completed. * When the result changes, the gotResult() signal is emitted. * The Result object is owned by the Expression, and will get deleted, as * soon as the Expression dies, or newer results appear. * @return the result of the Expression, 0 if it isn't yet set */ Result* result(); /*! * in case the expression has multiple outputs/results, those can be obtained with this functions. * Everything else said for \sa result() applies here too. * @return the vector with results, or an empty vector if nor results are available yet. */ const QVector& results() const; /** * Deletes the result of this expression. * */ void clearResult(); /** * Returns the status of this Expression * @return the status of this Expression */ Status status(); /** * Set the status * statusChanged will be emitted * @param status the new status */ void setStatus(Status status); /** * Returns the Session, this Expression belongs to */ Session* session(); /** * returns whether or not this expression is internal, or * comes from the user */ bool isInternal(); Q_SIGNALS: /** * the Id of this Expression changed */ void idChanged(); /** * A Result of the Expression has arrived */ void gotResult(); /** * emitted when the results of the expression were deleted. * @see clearResult() */ void resultCleared(); /** * emitted when the result at the position @c index was replaced by a new result. */ void resultReplaced(int index); /** * the status of the Expression has changed. * @param status the new status */ void statusChanged(Cantor::Expression::Status status); /** * the Expression needs more information for the evaluation * @see addInformation() * @param question question, the user needs to answer */ void needsAdditionalInformation(const QString& question); //These are protected, because only subclasses will handle results/status changes protected: /** * Set the result of the Expression. * this will cause gotResult() to be emitted * The old result will be deleted, and the Expression * takes over ownership of the result object, taking * care of deleting it. * @param result the new result */ void setResult(Result* result); void addResult(Result*); void replaceResult(int index, Result* result); protected: //returns a string of latex commands, that is inserted into the header. //used for example if special packages are needed virtual QString additionalLatexHeaders(); private: void renderResultAsLatex(Result* result); void latexRendered(LatexRenderer* renderer, Result* result); private: ExpressionPrivate* d; }; } #endif /* _EXPRESSION_H */ diff --git a/src/lib/extension.h b/src/lib/extension.h index 3d46a229..0a18243c 100644 --- a/src/lib/extension.h +++ b/src/lib/extension.h @@ -1,493 +1,493 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _EXTENSION_H #define _EXTENSION_H #include #include #include #include #include -#include "cantor_export.h" +#include namespace Cantor { /** * This is the base class for all Extensions. * An Extension provides a set of Methods to * accomplish specific tasks. This is used to * abstract away the backends syntax for common * tasks like solving equations etc. to be able * to provide Backend independent Dialogs * * @author Alexander Rieder */ class CANTOR_EXPORT Extension : public QObject { Q_OBJECT public: ///Default constructor Extension( const QString& name, QObject* parent ); ~Extension() override = default; }; //Some basic interfaces for extensions /** * An Extension providing commands for command history */ class CANTOR_EXPORT HistoryExtension : public Extension { Q_OBJECT public: explicit HistoryExtension(QObject* parent); ~HistoryExtension() override; public Q_SLOTS: /** * Returns a command that retrieves the last result * @return command that retrieves the last result */ virtual QString lastResult() = 0; }; /** * An Extension providing commands to interact * with external scripts */ class CANTOR_EXPORT ScriptExtension : public Extension { Q_OBJECT public: explicit ScriptExtension(QObject* parent); ~ScriptExtension() override; public Q_SLOTS: /** * returns the command for running a script * @param path path to the script file * @return command for running a script */ virtual QString runExternalScript(const QString& path) = 0; /** * returns the file filter used for Script Files (e.g. *.py) * @return file filter used for Script Files (e.g. *.py) */ virtual QString scriptFileFilter() = 0; /** * returns the name of the language to use for syntax highlighting * in the script editor (e.g. python). The value returned must match * the name attribute from the xml language description in KTexteditor. * @return name of the language to use for syntax highlighting (e.g. python) */ virtual QString highlightingMode() = 0; /** * returns a string used to separate commands (usually ;) * @return a string used to separate commands (usually ;) */ virtual QString commandSeparator(); /** * returns a string used to start a comment (usually #) * @return a string used to start a comment (usually #) */ virtual QString commentStartingSequence(); /** * returns a string used to end a comment (usually "") * @return a string used to end a comment (usually "") */ virtual QString commentEndingSequence(); }; /** * An extension providing the basic computations * in computer algebra, like solving, simplifying * etc **/ class CANTOR_EXPORT CASExtension : public Extension { Q_OBJECT public: explicit CASExtension(QObject* parent); ~CASExtension() override; public Q_SLOTS: /** * returns the command for solving a set of equations * @param equations a list of equations * @param variables a list of variables that should be solved for * @return command for solving a set of equations */ virtual QString solve(const QStringList& equations, const QStringList& variables) = 0; /** * returns the command for simplifying an expression * @param expression the expression that should be simplified * @return command for simplifying the expression */ virtual QString simplify(const QString& expression) = 0; /** * returns the command for expanding an expression * @param expression the expression that should be expanded * @return command for expanded the expression */ virtual QString expand(const QString& expression) = 0; }; /** * An extension providing the basic calculus * stuff like limits, differentiate, integrate etc. */ class CANTOR_EXPORT CalculusExtension : public Extension { Q_OBJECT public: explicit CalculusExtension(QObject* parent); ~CalculusExtension() override; public Q_SLOTS: /** * returns the command for calculating a limit if an expression * @param expression the expression * @param variable the variable * @param limit the value, the variable approaches * @return the limit of the expression */ virtual QString limit(const QString& expression, const QString& variable, const QString& limit) = 0; /** * returns the command for calculating a differential * @param function the function * @param variable the variable, after which should be differentiated * @param times how often should be differentiated * @return the command to compute the differential */ virtual QString differentiate(const QString& function,const QString& variable, int times) = 0; /** * returns the command for calculating an integral * @param function the function * @param variable the variable, after which should be integrated * @return the command to compute the integrate */ virtual QString integrate(const QString& function, const QString& variable) = 0; /** * returns the command for calculating a definite integral * @param function the function * @param variable the variable, after which should be integrated * @param left the left border of the integral * @param right the right border of the integral * @return the command to compute the integrate */ virtual QString integrate(const QString& function,const QString& variable, const QString& left, const QString& right) = 0; }; /** * An extension providing basic plotting facilities */ class CANTOR_EXPORT PlotExtension : public Extension { Q_OBJECT public: typedef QPair Interval; typedef QPair VariableParameter; explicit PlotExtension(QObject* parent); ~PlotExtension() override; public Q_SLOTS: /** * returns the command for plotting a 2 dimensional function. * @param function the function to plot * @param variable the variable * @param left the left border of the plot * @param right the right border of the plot * @return the command for plotting */ virtual QString plotFunction2d(const QString& function, const QString& variable, const QString& left, const QString& right) = 0; /** * returns the command for plotting a 3 dimensional function. * @param function the function to plot * @param var1 the parameters for Variable1 (name, interval) * @param var2 the parameters for Variable2 (name, interval) * @return the command for plotting */ virtual QString plotFunction3d(const QString& function, const VariableParameter& var1, const VariableParameter& var2) = 0; }; #define PLOT_DIRECTIVE_DISPATCHING(x) QString dispatch(const Cantor::AdvancedPlotExtension::AcceptorBase& acc) const \ { \ const Cantor::AdvancedPlotExtension::DirectiveAcceptor* adaptor= \ dynamic_cast*>(&acc); \ if (adaptor==NULL) { qDebug()<<"Backend incapable of processing directives of type "#x; return QLatin1String(""); } \ else \ return adaptor->accept(*this); \ } /** * An extension providing advanced plotting facilities. Will supersede PlotExtension */ class CANTOR_EXPORT AdvancedPlotExtension : public Extension { Q_OBJECT public: explicit AdvancedPlotExtension(QObject* parent); ~AdvancedPlotExtension() override; // TODO comment class PlotDirective; // TODO move the hell out of here class CANTOR_EXPORT DirectiveProducer : public QWidget { public: explicit DirectiveProducer(QWidget* parent); virtual PlotDirective* produceDirective() const=0; }; template class DirectiveControl : protected UI, public DirectiveProducer { public: DirectiveControl(QWidget* parent) : DirectiveProducer(parent) { UI::setupUi(this); } protected: using AbstractParent = DirectiveControl; }; class CANTOR_EXPORT AcceptorBase { public: /** * utilitary typename for easing the code */ using widgetProc = DirectiveProducer *(*)(QWidget *); /** * returns a constant reference to the list of widget generating procedures * which contains means of creating all the widgets a backend knows how to process * @return the constant reference to a QVector of QWidget* (*)(QWidget*) pointers */ const QVector& widgets() const; protected: /** * constructor only allowed for derived classes **/ AcceptorBase(); virtual ~AcceptorBase() = default; QVector m_widgets; }; template class DirectiveAcceptor : virtual public AcceptorBase { public: /** * virtual interface to acceptor function mechanics * @param directive the directive to process * @return the parameter corresponding the directive */ virtual QString accept(const Directive& directive) const=0; protected: /** * constructor only allowed for derived classes **/ DirectiveAcceptor(); }; class CANTOR_EXPORT PlotDirective { public: virtual ~PlotDirective() = default; /** * creates a new widget for editing the value and returns the pointer to it * @param parent the pointer to parent widget passed to newly created widget * @return pointer to the newly-created widget */ static QWidget* widget(QWidget* parent); /** * in order to make dual dispatching this should be present in any derived class * without virtual keyword and with correct class name **/ virtual PLOT_DIRECTIVE_DISPATCHING(PlotDirective); // TODO: find a workaround not to put class names manually protected: /** * only derived classes may construct **/ PlotDirective() = default; }; public Q_SLOTS: /** * returns the command for plotting a 2 dimensional data set. * @param expression the expression to plot * @param directives the array of directives toward the generator * @return the command for plotting */ QString plotFunction2d(const QString& expression, const QVector& directives) const; /** * returns the parameter expression according to a directive. * @param directive the directive toward the generator * @return the parameter for plotting */ QString dispatchDirective(const Cantor::AdvancedPlotExtension::PlotDirective& directive) const; protected: /** * returns the command name for plotting a 2 dimensional data set. * @return the command for plotting */ virtual QString plotCommand() const=0; /** * returns the separator symbol in a plotting command. * @return the separator symbol or string */ virtual QString separatorSymbol() const; }; template AdvancedPlotExtension::DirectiveAcceptor::DirectiveAcceptor() { m_widgets.push_back(&Directive::widget); } /** * An extension for basic Linear Algebra */ class CANTOR_EXPORT LinearAlgebraExtension : public Extension { Q_OBJECT public: enum VectorType { ColumnVector, RowVector }; using Matrix = QList; explicit LinearAlgebraExtension(QObject* parent); ~LinearAlgebraExtension() override; public Q_SLOTS: //Commands to create Vectors/Matrices /** * creates a vector with the given entries * @param entries the entries of the new vector * @param type the type of the vector (row/column) * @return the command for creating the vector */ virtual QString createVector(const QStringList& entries, Cantor::LinearAlgebraExtension::VectorType type) = 0; /** * creates a null vector, of the given size/type * @param size size of the vector * @param type type of the vector * @return the command used for creating a nullvector **/ virtual QString nullVector(int size, Cantor::LinearAlgebraExtension::VectorType type); /** * creates a matrix with the given entries * @param matrix the entries of the matrix * @return the command to create this matrix */ virtual QString createMatrix(const Matrix& matrix) = 0; /** * creates an identity matrix of the given size * @param size size of the matrix * @return the command used to create the matrix */ virtual QString identityMatrix(int size); /** * creates a null matrix, of the given size * @param rows number of rows * @param columns number of columns * @return the command to create this matrix */ virtual QString nullMatrix(int rows,int columns); //basic functions /** * compute the rank of a matrix * @param matrix the name of the matrix, the rank should be computed of * @return the command for calculating the rank */ virtual QString rank(const QString& matrix) = 0; /** * invert a given matrix * @param matrix the name of the matrix, that should be inverted * @return the command for inverting the matrix */ virtual QString invertMatrix(const QString& matrix) = 0; /** * calculate the characteristic polynom of a matrix * @param matrix the name of the matrix, the charpoly should be computed of * @return the command */ virtual QString charPoly(const QString& matrix) = 0; /** * calculate the eigen vectors of a matrix * @param matrix the name of the matrix, the eigenvectors should be computed of * @return the command */ virtual QString eigenVectors(const QString& matrix) = 0; /** * calculate the eigen values of a matrix * @param matrix the name of the matrix, the eigenvalues should be computed of * @return the command */ virtual QString eigenValues(const QString& matrix) = 0; }; class CANTOR_EXPORT VariableManagementExtension : public Extension { Q_OBJECT public: explicit VariableManagementExtension( QObject* parent ); ~VariableManagementExtension() override; public Q_SLOTS: virtual QString addVariable(const QString& name, const QString& value) = 0; virtual QString setValue(const QString& name,const QString& value) = 0; virtual QString removeVariable(const QString& name) = 0; virtual QString saveVariables(const QString& fileName) = 0; virtual QString loadVariables(const QString& fileName) = 0; virtual QString clearVariables() = 0; }; /** * An extension for library/module import */ class CANTOR_EXPORT PackagingExtension : public Extension { Q_OBJECT public: explicit PackagingExtension(QObject* parent); ~PackagingExtension() override; public Q_SLOTS: /** * import library/module * @param package the library/module name * @return the command for import library/module */ virtual QString importPackage(const QString& package) = 0; }; } #endif /* _EXTENSION_H */ diff --git a/src/lib/latexrenderer.h b/src/lib/latexrenderer.h index 5906d21f..58206c74 100644 --- a/src/lib/latexrenderer.h +++ b/src/lib/latexrenderer.h @@ -1,78 +1,78 @@ /* 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. --- Copyright (C) 2011 Alexander Rieder */ #ifndef _LATEXRENDERER_H #define _LATEXRENDERER_H #include -#include "cantor_export.h" +#include namespace Cantor{ class LatexRendererPrivate; class CANTOR_EXPORT LatexRenderer : public QObject { Q_OBJECT public: enum Method{ LatexMethod = 0, MmlMethod = 1}; enum EquationType{ InlineEquation = 0, FullEquation = 1}; explicit LatexRenderer( QObject* parent = nullptr); ~LatexRenderer() override; QString latexCode() const; void setLatexCode(const QString& src); QString header() const; void addHeader(const QString& header); void setHeader(const QString& header); Method method() const; void setMethod( Method method); void setEquationOnly(bool isEquationOnly); bool isEquationOnly() const; void setEquationType(EquationType type); EquationType equationType() const; QString errorMessage() const; bool renderingSuccessful() const; QString imagePath() const; Q_SIGNALS: void done(); void error(); public Q_SLOTS: void render(); void renderBlocking(); private: void setErrorMessage(const QString& msg); private Q_SLOTS: void renderWithLatex(); void renderWithMml(); void convertToPs(); void convertingDone(); private: LatexRendererPrivate* d; }; } #endif /* _LATEXRENDERER_H */ diff --git a/src/lib/latexresult.h b/src/lib/latexresult.h index 7e62e0b4..1ed65d26 100644 --- a/src/lib/latexresult.h +++ b/src/lib/latexresult.h @@ -1,66 +1,66 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _LATEXRESULT_H #define _LATEXRESULT_H #include "epsresult.h" -#include "cantor_export.h" +#include namespace Cantor{ class LatexResultPrivate; /**Class used for LaTeX results, it is basically an Eps result, but it exports a different type, and additionally stores the LaTeX code, used to generate the Eps, so it can be retrieved later **/ class CANTOR_EXPORT LatexResult : public EpsResult { public: enum {Type=7}; LatexResult( const QString& code, const QUrl& url, const QString& plain = QString()); ~LatexResult() override; int type() override; QString mimeType() override; bool isCodeShown(); void showCode(); void showRendered(); QString code(); QString plain(); QString toHtml() override; QString toLatex() override; QVariant data() override; QDomElement toXml(QDomDocument& doc) override; void save(const QString& filename) override; private: LatexResultPrivate* d; }; } #endif /* _LATEXRESULT_H */ diff --git a/src/lib/panelplugin.h b/src/lib/panelplugin.h index 1d640a21..a3e6ca27 100644 --- a/src/lib/panelplugin.h +++ b/src/lib/panelplugin.h @@ -1,116 +1,116 @@ /* 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. --- Copyright (C) 2010 Alexander Rieder */ #ifndef _PANEL_PLUGIN_H #define _PANEL_PLUGIN_H #include class KPluginMetaData; #include "backend.h" -#include "cantor_export.h" +#include namespace Cantor { class Session; class PanelPluginPrivate; /** * A plugin provides some additional features for the worksheet */ class CANTOR_EXPORT PanelPlugin : public QObject { Q_OBJECT public: /** * Create a new PanelPlugin * @param parent the parent Object @see QObject **/ PanelPlugin( QObject* parent ); /** * Destructor */ ~PanelPlugin() override; /** * Sets the properties of this PanelPlugin * according to KPluginMetaData * @param info KPluginMetaData */ void setPluginInfo(const KPluginMetaData&); /** * Returns a list of all extensions, the current backend * must provide to make this PanelPlugin work. If it doesn't * this PanelPlugin won't be enabled * @return list of required extensions */ QStringList requiredExtensions(); /** * Returns the capabilities, the current backend * must provide to make this PanelPlugin work. If it doesn't * this PanelPlugin won't be enabled * @return the required capabilities */ virtual Backend::Capabilities requiredCapabilities(); /** * Returns the name of the plugin * @return name of the plugin */ QString name(); /** * returns the widget, provided by this plugin * @return the widget, provided by this plugin **/ virtual QWidget* widget() = 0; void setParentWidget(QWidget* widget); QWidget* parentWidget(); /** * sets the session this plugin operates on **/ void setSession(Session* session); /** * returns the session */ Session* session(); Q_SIGNALS: void requestRunCommand(const QString& cmd); void visibilityRequested(); protected: virtual void onSessionChanged(); private: PanelPluginPrivate* d; }; } #endif /* _PANEL_PLUGIN_H */ diff --git a/src/lib/panelpluginhandler.h b/src/lib/panelpluginhandler.h index db66b306..d629470b 100644 --- a/src/lib/panelpluginhandler.h +++ b/src/lib/panelpluginhandler.h @@ -1,65 +1,65 @@ /* 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. --- Copyright (C) 2010 Alexander Rieder */ #ifndef _PANELPLUGINHANDLER_H #define _PANELPLUGINHANDLER_H #include -#include "cantor_export.h" +#include namespace Cantor { class PanelPluginHandlerPrivate; class PanelPlugin; class Session; /** * Simple interface that exports a list of known PanelPlugins. * Needed as the Panel must be handled by the Shell while plugins * belong to the Part. */ class CANTOR_EXPORT PanelPluginHandler : public QObject { Q_OBJECT public: explicit PanelPluginHandler(QObject* parent); ~PanelPluginHandler() override; QList plugins(); void addPlugin(PanelPlugin* plugin); void setSession(Session* session); Q_SIGNALS: void pluginsChanged(); private: void loadPlugins(); private: PanelPluginHandlerPrivate* d; }; } #endif /* _PANELPLUGINHANDLER_H */ diff --git a/src/lib/result.h b/src/lib/result.h index 71ff9b71..2918fef0 100644 --- a/src/lib/result.h +++ b/src/lib/result.h @@ -1,113 +1,113 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _RESULT_H #define _RESULT_H #include #include -#include "cantor_export.h" +#include class KZip; namespace Cantor { class ResultPrivate; /** * Base class for different results, like text, image, animation. etc. */ class CANTOR_EXPORT Result { public: /** * Default constructor */ Result( ); /** * Destructor */ virtual ~Result(); /** * returns html code, that represents this result, * e.g. an img tag for images * @return html code representing this result */ virtual QString toHtml() = 0; /** * returns latex code, that represents this result * e.g. a includegraphics command for images * it falls back to toHtml if not implemented * @return latex code representing this result */ virtual QString toLatex(); /** * returns data associated with this result * (text/images/etc) * @return data associated with this result */ virtual QVariant data() = 0; /** * returns an url, data for this result resides at * @return an url, data for this result resides at */ virtual QUrl url(); /** * returns an unique number, representing the type of this * result. Every subclass should define their own Type. * @return the type of this result */ virtual int type() = 0; /** * returns the mimetype, this result is * @return the mimetype, this result is */ virtual QString mimeType() = 0; /** * returns a DomElement, containing the information of the result * @param doc DomDocument used for storing the information * @return DomElement, containing the information of the result */ virtual QDomElement toXml(QDomDocument& doc) = 0; /** * saves all the data, that can't be saved in xml * in an extra file in the archive. */ virtual void saveAdditionalData(KZip* archive); /** * saves this to a file * @param filename name of the file */ virtual void save(const QString& filename) = 0; private: ResultPrivate* d; }; } #endif /* _RESULT_H */ diff --git a/src/lib/session.h b/src/lib/session.h index faf127fe..95fb8c10 100644 --- a/src/lib/session.h +++ b/src/lib/session.h @@ -1,221 +1,221 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _SESSION_H #define _SESSION_H #include -#include "cantor_export.h" +#include #include "expression.h" class QTextEdit; class QSyntaxHighlighter; class QAbstractItemModel; /** * Namespace collecting all Classes of the Cantor Libraries */ namespace Cantor { class Backend; class SessionPrivate; class CompletionObject; class SyntaxHelpObject; /** * The Session object is the main class used to interact with a Backend. * It is used to evaluate Expressions, get completions, syntax highlighting, etc. * * @author Alexander Rieder */ class CANTOR_EXPORT Session : public QObject { Q_OBJECT public: enum Status { Running, ///< the session is busy, running some expression Done, ///< the session has done all the jobs, and is now waiting for more Disable ///< the session don't login yet, or already logout }; /** * Create a new Session. This should not yet set up the complete session, * thats job of the login() function * @see login() */ explicit Session( Backend* backend); /** * Destructor */ ~Session() override; /** * Login to the Session. In this function you should do anything needed to set up * the session, and make it ready for usage. The method should be implemented non-blocking. * Emit loginStarted() prior to connection to the actual backend in order to notify cantor_part about it. * If the logging in is completed, the loginDone() signal must be emitted */ virtual void login() = 0; /** * Log out of the Session. Destroy everything specific to a single session, e.g. * stop all the running processes etc. Also logout session status must be Status::Disable * NOTE: restarting the session consists of first logout() and then login() */ virtual void logout() = 0; /** * Passes the given command to the backend and returns a Pointer * to a new Expression object, which will emit the gotResult() * signal as soon as the computation is done. The result will * then be accessible by Expression::result() * @param command the command that should be run by the backend. * @param finishingBehavior the FinishingBehaviour that should be used for this command. @see Expression::FinishingBehaviour * @param isInternal true, if is it internal command @see Expression::Expression(Session*, bool) * @return an Expression object, representing this command */ virtual Expression* evaluateExpression(const QString& command, Expression::FinishingBehavior finishingBehavior = Expression::FinishingBehavior::DoNotDelete, bool internal = false) = 0; /** * Append the expression to queue . * @see expressionQueue() const */ void enqueueExpression(Expression*); /** * Interrupts all the running calculations in this session */ virtual void interrupt() = 0; /** * Returns tab-completion, for this command/command-part. * The return type is a CompletionObject. The fetching * of the completions works asynchronously, you'll have to * listen to the done() Signal of the returned object * @param cmd The partial command that should be completed * @param index The index (cursor position) at which completion * was invoked. Defaults to -1, indicating the end of the string. * @return a Completion object, representing this completion * @see CompletionObject */ virtual CompletionObject* completionFor(const QString& cmd, int index = -1); /** * Returns Syntax help, for this command. * It returns a SyntaxHelpObject, that will fetch the * needed information asynchronously. You need to listen * to the done() Signal of the Object * @param cmd the command, syntax help is requested for * @return SyntaxHelpObject, representing the help request * @see SyntaxHelpObject */ virtual SyntaxHelpObject* syntaxHelpFor(const QString& cmd); /** * returns a syntax highlighter for this session * @param parent QObject the Highlighter's parent * @return QSyntaxHighlighter doing the highlighting for this Session */ virtual QSyntaxHighlighter* syntaxHighlighter(QObject* parent); /** * returns a Model to interact with the variables * @return QAbstractItemModel to interact with the variables */ virtual QAbstractItemModel* variableModel(); /** * Enables/disables Typesetting for this session. * For this setting to make effect, the Backend must support * LaTeX typesetting (as indicated by the capabilities() flag. * @param enable true to enable, false to disable typesetting */ virtual void setTypesettingEnabled(bool enable); /** * Updates the worksheet path in the session. * This can be useful to set the path of the currently opened * Cantor project file in the backend interpreter. * Default implementation does nothing. Derived classes have * to implement the proper logic if this feature is supported. * @param path the new absolute path to the worksheet. */ virtual void setWorksheetPath(const QString& path); /** * Returns the Backend, this Session is for * @return the Backend, this Session is for */ Backend* backend(); /** * Returns the status this Session has * @return the status this Session has */ Cantor::Session::Status status(); /** * Returns whether typesetting is enabled or not * @return whether typesetting is enabled or not */ bool isTypesettingEnabled(); /** * Returns the next available Expression id * It is basically a counter, incremented for * each new Expression * @return next Expression id */ int nextExpressionId(); protected: /** * Change the status of the Session. This will cause the * stausChanged signal to be emitted * @param newStatus the new status of the session */ void changeStatus(Cantor::Session::Status newStatus); /** * Session can process one single expression at one time. * Any other expressions submitted by the user are queued first until they get processed. * The expression queue implements the FIFO mechanism. * The queud expression have the status \c Expression::Queued. */ QList& expressionQueue() const; /** * Execute first expression in expression queue. * Also, this function changes the status from Queued to Computing. * @see expressionQueue() const */ virtual void runFirstExpression(); Q_SIGNALS: void statusChanged(Cantor::Session::Status newStatus); void loginStarted(); void loginDone(); void error(const QString& msg); private: SessionPrivate* d; }; } #endif /* _SESSION_H */ diff --git a/src/lib/syntaxhelpobject.h b/src/lib/syntaxhelpobject.h index fe530502..355ad107 100644 --- a/src/lib/syntaxhelpobject.h +++ b/src/lib/syntaxhelpobject.h @@ -1,101 +1,101 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _SYNTAXHELPOBJECT_H #define _SYNTAXHELPOBJECT_H #include -#include "cantor_export.h" +#include namespace Cantor{ class SyntaxHelpObjectPrivate; class Session; /** * Object, used to display Syntax information to a given command * It is designed for asynchronous use. The Object emits done * as soon as fetching of the Help is finished * * @author Alexander Rieder **/ class CANTOR_EXPORT SyntaxHelpObject : public QObject { Q_OBJECT public: /** * Construct a HelpObject, for the given command, belonging to the Session session. * @param command Command the help should be fetched for * @param session Session the HelpObject belongs to */ SyntaxHelpObject( const QString& command, Session* session ); /** * Destructor */ ~SyntaxHelpObject() override; /** * Start fetching the syntax help, emitting done() when done. */ void fetchSyntaxHelp(); /** * Returns Html text of the Syntax Help */ QString toHtml(); /** * Returns the command, this SyntaxHelp is for * @return the command, this SyntaxHelp is for */ QString command(); /** * Returns the Session, this Object belongs to * @return the Session, this Object belongs to */ Session* session(); Q_SIGNALS: /** * The SyntaxHelpObject is done, fetching the Information. * The syntax help can be shown now */ void done(); protected Q_SLOTS: /** * This method should fetch the Syntax help information from the backend */ virtual void fetchInformation() = 0; protected: /** * Set the html syntax help * @param result the html syntax help */ void setHtml(const QString& result); private: SyntaxHelpObjectPrivate* d; }; } #endif /* _SYNTAXHELPOBJECT_H */ diff --git a/src/lib/test/CMakeLists.txt b/src/lib/test/CMakeLists.txt index 119a4213..562e0861 100644 --- a/src/lib/test/CMakeLists.txt +++ b/src/lib/test/CMakeLists.txt @@ -1,10 +1,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..) set(cantortest_SRCS backendtest.cpp) add_library( cantortest SHARED ${cantortest_SRCS} ) +generate_export_header(cantortest) target_link_libraries( cantortest cantorlibs Qt5::Test) diff --git a/src/lib/test/backendtest.h b/src/lib/test/backendtest.h index c9442c24..43cad268 100644 --- a/src/lib/test/backendtest.h +++ b/src/lib/test/backendtest.h @@ -1,63 +1,63 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef BACKENDTEST_H #define BACKENDTEST_H #include #include #include -#include "cantor_export.h" +#include namespace Cantor { class Session; class Expression; } class CANTORTEST_EXPORT BackendTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void cleanupTestCase(); protected: Cantor::Expression* evalExp(const QString& exp); /** * simple method that removes whitespaces/other irrelevant stuff, * so comparing results is easier */ QString cleanOutput( const QString& out ); Cantor::Session* session(); /** * simple method that blocks and waits for a signal to be emitted */ void waitForSignal( QObject* sender, const char* signal); private: void createSession(); Cantor::Session* m_session; virtual QString backendName() = 0; }; #endif // BACKENDTEST_H diff --git a/src/lib/textresult.h b/src/lib/textresult.h index bd1856e8..093cca28 100644 --- a/src/lib/textresult.h +++ b/src/lib/textresult.h @@ -1,61 +1,61 @@ /* 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. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _TEXTRESULT_H #define _TEXTRESULT_H #include "result.h" -#include "cantor_export.h" +#include namespace Cantor { class TextResultPrivate; class CANTOR_EXPORT TextResult : public Result { public: enum { Type=1 }; enum Format { PlainTextFormat, LatexFormat}; TextResult(const QString& text); TextResult(const QString& text, const QString& plain); ~TextResult() override; QString toHtml() override; QVariant data() override; QString plain(); int type() override; QString mimeType() override; Format format(); void setFormat(Format f); QDomElement toXml(QDomDocument& doc) override; void save(const QString& filename) override; private: TextResultPrivate* d; }; } #endif /* _TEXTRESULT_H */ diff --git a/src/lib/worksheetaccess.h b/src/lib/worksheetaccess.h index 0e156c7e..c183652c 100644 --- a/src/lib/worksheetaccess.h +++ b/src/lib/worksheetaccess.h @@ -1,59 +1,59 @@ /* 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. --- Copyright (C) 2015 Alexander Rieder */ #ifndef _WORKSHEET_ACCESS_INTERFACE_H #define _WORKSHEET_ACCESS_INTERFACE_H -#include "cantor_export.h" +#include #include namespace Cantor { class Session; class CANTOR_EXPORT WorksheetAccessInterface : public QObject { Q_OBJECT public: static QLatin1String Name; explicit WorksheetAccessInterface(QObject* parent); ~WorksheetAccessInterface() override = default; public: virtual QByteArray saveWorksheetToByteArray() = 0; virtual void loadWorksheetFromByteArray(QByteArray* data) = 0; virtual Session* session() = 0; public Q_SLOTS: virtual void evaluate() = 0; virtual void interrupt() = 0; Q_SIGNALS: void modified(); }; } #endif