diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 00000000..f2781d62 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,4 @@ +{ + "phabricator.uri" : "https://phabricator.kde.org/", + "project.name" : "Cantor" +} diff --git a/src/animationresultitem.h b/src/animationresultitem.h index e6ecff70..2694d0ae 100644 --- a/src/animationresultitem.h +++ b/src/animationresultitem.h @@ -1,68 +1,70 @@ /* 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 Martin Kuettler */ #ifndef ANIMATIONRESULTITEM_H #define ANIMATIONRESULTITEM_H #include "resultitem.h" #include "worksheetimageitem.h" class QMovie; +class CommandEntry; +class WorksheetEntry; class AnimationResultItem : public WorksheetImageItem, public ResultItem { Q_OBJECT public: explicit AnimationResultItem(QGraphicsObject*, Cantor::Result*); ~AnimationResultItem() override = default; using WorksheetImageItem::setGeometry; double setGeometry(double x, double y, double w) override; void populateMenu(QMenu*, QPointF) override; void update() override; void deleteLater() override; QRectF boundingRect() const override; double width() const override; double height() const override; protected Q_SLOTS: void saveResult(); void stopMovie(); void pauseMovie(); private: void setMovie(QMovie*); private Q_SLOTS: void updateFrame(); void updateSize(QSize); private: double m_height; QMovie* m_movie; }; #endif //ANIMATIONRESULTITEM_H diff --git a/src/backends/R/rsession.h b/src/backends/R/rsession.h index 78125410..0be88e92 100644 --- a/src/backends/R/rsession.h +++ b/src/backends/R/rsession.h @@ -1,63 +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 _RSESSION_H #define _RSESSION_H #include #include #include "session.h" #include "rserver_interface.h" +class RExpression; +class RVariableModel; class QProcess; namespace Cantor { +class DefaultVariableModel; } class RSession : public Cantor::Session { Q_OBJECT public: explicit RSession( Cantor::Backend* backend); ~RSession() override; void login() override; void logout() override; void interrupt() override; 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; void runFirstExpression() override; void sendInputToServer(const QString& input); protected Q_SLOTS: void serverChangedStatus(int status); void expressionFinished(int returnCode, const QString& text, const QStringList& files); void inputRequested(QString info); private: QProcess* m_process; org::kde::Cantor::R* m_rServer; }; #endif /* _RSESSION_H */ diff --git a/src/backends/julia/juliasession.h b/src/backends/julia/juliasession.h index 86446dfe..46fd00bb 100644 --- a/src/backends/julia/juliasession.h +++ b/src/backends/julia/juliasession.h @@ -1,145 +1,149 @@ /* 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) 2016 Ivan Lakhtanov */ #pragma once #include #include #include #include "session.h" +class JuliaExpression; +class JuliaCompletionObject; +class JuliaVariableModel; class KProcess; class QDBusInterface; namespace Cantor { + class DefaultVariableModel; } /** * Implements a Cantor session for the Julia backend * * It communicates through DBus interface with JuliaServer */ class JuliaSession: public Cantor::Session { Q_OBJECT public: /** * Constructs session * * @param backend owning backend */ explicit JuliaSession(Cantor::Backend *backend); ~JuliaSession() override; /** * @see Cantor::Session::login */ void login() override; /** * @see Cantor::Session::logout */ void logout() override; /** * @see Cantor::Session::interrupt */ void interrupt() override; /** * @see Cantor::Session::evaluateExpression */ Cantor::Expression *evaluateExpression( const QString &command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; /** * @see Cantor::Session::completionFor */ Cantor::CompletionObject *completionFor( const QString &cmd, int index = -1) override; /** * @see Cantor::Session::syntaxHighlighter */ QSyntaxHighlighter *syntaxHighlighter(QObject *parent) override; /** * @return indicator if config says to integrate plots into worksheet */ bool integratePlots(); private Q_SLOTS: /** * Called when async call to JuliaServer is finished */ void onResultReady(); // Handler for cantor_juliaserver crashes void reportServerProcessError(QProcess::ProcessError serverError); private: KProcess *m_process; //< process to run JuliaServer inside QDBusInterface *m_interface; //< interface to JuliaServer /// Cache to speedup modules whos calls QMap m_whos_cache; void runFirstExpression() override; /** * Runs Julia piece of code in synchronous mode * * @param command command to execute */ void runJuliaCommand(const QString &command) const; /** * Runs Julia piece of code in asynchronous mode. When finished * onResultReady is called * * @param command command to execute */ void runJuliaCommandAsync(const QString &command); /** * Helper method to get QString returning function result * * @param method DBus method to call * @return result of the method */ QString getStringFromServer(const QString &method); /** * @return stdout of the last executed command */ QString getOutput(); /** * @return stderr of the last executed command */ QString getError(); /** * @return indicator of exception occurred during the last command execution */ bool getWasException(); }; diff --git a/src/backends/kalgebra/kalgebrasession.h b/src/backends/kalgebra/kalgebrasession.h index ce947b38..29fea8cf 100644 --- a/src/backends/kalgebra/kalgebrasession.h +++ b/src/backends/kalgebra/kalgebrasession.h @@ -1,57 +1,58 @@ /************************************************************************************* * Copyright (C) 2009 by Aleix Pol * * * * 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_SESSION_H #define KALGEBRA_SESSION_H #include "session.h" class OperatorsModel; +class KAlgebraExpression; namespace Analitza { class Analyzer; class VariablesModel; } class KAlgebraSession : public Cantor::Session { Q_OBJECT public: explicit KAlgebraSession( Cantor::Backend* backend); ~KAlgebraSession() override; void login() override; void logout() override; void interrupt() override; Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override; Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override; Analitza::Analyzer* analyzer() const { return m_analyzer; } OperatorsModel* operatorsModel(); QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; QAbstractItemModel* variableDataModel() const override; private: Analitza::Analyzer* m_analyzer; OperatorsModel* m_operatorsModel; Analitza::VariablesModel* m_variablesModel; }; #endif diff --git a/src/backends/maxima/maximasession.h b/src/backends/maxima/maximasession.h index f845b0f7..86092f9e 100644 --- a/src/backends/maxima/maximasession.h +++ b/src/backends/maxima/maximasession.h @@ -1,72 +1,74 @@ /* Tims 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-2012 Alexander Rieder */ #ifndef _MAXIMASESSION_H #define _MAXIMASESSION_H #include "session.h" #include "expression.h" #include #include +class MaximaExpression; +class MaximaVariableModel; class MaximaSession : public Cantor::Session { Q_OBJECT public: static const QRegularExpression MaximaOutputPrompt; static const QRegularExpression MaximaInputPrompt; explicit MaximaSession( Cantor::Backend* backend); void login() override; void logout() override; Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; void interrupt() override; void sendInputToProcess(const QString&); void setTypesettingEnabled(bool) override; Cantor::CompletionObject* completionFor(const QString& command, int index=-1) override; Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& command) override; QSyntaxHighlighter* syntaxHighlighter(QObject*) override; void runFirstExpression() override; public Q_SLOTS: void readStdOut(); void readStdErr(); private Q_SLOTS: void currentExpressionChangedStatus(Cantor::Expression::Status); void restartMaxima(); void restartsCooledDown(); void reportProcessError(QProcess::ProcessError); private: void write(const QString&); QProcess* m_process; QString m_cache; bool m_justRestarted; }; #endif /* _MAXIMASESSION_H */ diff --git a/src/backends/octave/octavehighlighter.h b/src/backends/octave/octavehighlighter.h index f6f5ea4b..876be08e 100644 --- a/src/backends/octave/octavehighlighter.h +++ b/src/backends/octave/octavehighlighter.h @@ -1,39 +1,40 @@ /* Copyright (C) 2010 Miha Čančula 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 OCTAVEHIGHLIGHTER_H #define OCTAVEHIGHLIGHTER_H #include "defaulthighlighter.h" #include namespace Cantor { + class Expression; } class OctaveHighlighter : public Cantor::DefaultHighlighter { Q_OBJECT public: OctaveHighlighter(QObject* parent, Cantor::Session* session); ~OctaveHighlighter() override = default; }; #endif // OCTAVEHIGHLIGHTER_H diff --git a/src/backends/octave/octavesession.h b/src/backends/octave/octavesession.h index e681282f..581b3735 100644 --- a/src/backends/octave/octavesession.h +++ b/src/backends/octave/octavesession.h @@ -1,81 +1,83 @@ /* Copyright (C) 2010 Miha Čančula 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 OCTAVESESSION_H #define OCTAVESESSION_H #include #include #include #include #include namespace Cantor { +class DefaultVariableModel; } class KDirWatch; +class OctaveExpression; class KProcess; class OctaveSession : public Cantor::Session { Q_OBJECT public: explicit OctaveSession(Cantor::Backend* backend); ~OctaveSession() override; void interrupt() override; Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior finishingBehavior = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; void logout() override; void login() override; Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override; Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override; QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; void runFirstExpression() override; bool isIntegratedPlotsEnabled() const; private: const static QRegularExpression PROMPT_UNCHANGEABLE_COMMAND; private: KProcess* m_process; QTextStream m_stream; QRegularExpression m_prompt; QRegularExpression m_subprompt; int m_previousPromptNumber; bool m_syntaxError; QString m_output; bool m_isIntegratedPlotsEnabled; // Better move it in worksheet, like isCompletion, etc. private: void readFromOctave(QByteArray data); bool isDoNothingCommand(const QString& command); bool isSpecialOctaveCommand(const QString& command); private Q_SLOTS: void readOutput(); void readError(); void currentExpressionStatusChanged(Cantor::Expression::Status status); void processError(); void runSpecificCommands(); }; #endif // OCTAVESESSION_H diff --git a/src/backends/python/pythonsession.h b/src/backends/python/pythonsession.h index e6afccfc..53b63e90 100644 --- a/src/backends/python/pythonsession.h +++ b/src/backends/python/pythonsession.h @@ -1,77 +1,64 @@ /* 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 #include -<<<<<<< Updated upstream class PythonSession : public Cantor::Session -======= -namespace Cantor { - class DefaultVariableModel; -} - -class PythonExpression; -class PythonVariableModel; -class QDBusInterface; -class KProcess; - -class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session ->>>>>>> Stashed changes { Q_OBJECT public: PythonSession(Cantor::Backend* backend); ~PythonSession() override; void login() override; void logout() override; void interrupt() override; 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; void setWorksheetPath(const QString& path) override; private: QProcess* m_process; QString m_worksheetPath; QString m_output; private Q_SLOT: void readOutput(); void reportServerProcessError(QProcess::ProcessError serverError); private: void runFirstExpression() override; void sendCommand(const QString& command, const QStringList arguments = QStringList()) const; }; #endif /* _PYTHONSESSION_H */ diff --git a/src/backends/qalculate/qalculatesession.h b/src/backends/qalculate/qalculatesession.h index a5701a69..73109fa7 100644 --- a/src/backends/qalculate/qalculatesession.h +++ b/src/backends/qalculate/qalculatesession.h @@ -1,89 +1,90 @@ /************************************************************************************* * Copyright (C) 2009 by Milian Wolff * * * * 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 QALCULATE_SESSION_H #define QALCULATE_SESSION_H #include "session.h" #include "qalculateexpression.h" #include #include #include #include #include namespace Cantor { class DefaultVariableModel; } +class QalculateEngine; class QProcess; class QalculateSession : public Cantor::Session { Q_OBJECT private: Cantor::DefaultVariableModel* m_variableModel; QProcess* m_process; QalculateExpression* m_currentExpression; QString m_output; QString m_finalOutput; QString m_currentCommand; QString m_saveError; QQueue m_expressionQueue; QQueue m_commandQueue; bool m_isSaveCommand; private: void runExpressionQueue(); void runCommandQueue(); QString parseSaveCommand(QString& currentCmd); void storeVariables(QString& currentCmd, QString output); public: explicit QalculateSession( Cantor::Backend* backend); ~QalculateSession() override; void login() override; void logout() override; void interrupt() override; Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override; Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override; QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; void runExpression(); Cantor::DefaultVariableModel* variableModel() const override; public: QMap variables; public Q_SLOTS: void readOutput(); void readError(); void processStarted(); void currentExpressionStatusChanged(Cantor::Expression::Status status); }; #endif diff --git a/src/backends/sage/sagesession.h b/src/backends/sage/sagesession.h index dead37cd..e2fdba91 100644 --- a/src/backends/sage/sagesession.h +++ b/src/backends/sage/sagesession.h @@ -1,109 +1,110 @@ /* Tims 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 _SAGESESSION_H #define _SAGESESSION_H #include "session.h" #include "expression.h" #include #include +class SageExpression; class KPtyProcess; class SageSession : public Cantor::Session { Q_OBJECT public: static const QByteArray SagePrompt; static const QByteArray SageAlternativePrompt; //small helper class to deal with sage versions //Note: major version -1 is treated as most current class VersionInfo{ public: explicit VersionInfo(int major = -1, int minor = -1); //bool operator <=(VersionInfo v2); bool operator <(VersionInfo other) const; bool operator <=(VersionInfo other) const; bool operator >(VersionInfo other) const; bool operator >=(VersionInfo other) const; bool operator ==( VersionInfo other) const; // These are not called major() and minor() because some libc's have // macros with those names. int majorVersion() const; int minorVersion() const; private: int m_major; int m_minor; }; explicit SageSession( Cantor::Backend* backend); ~SageSession() override; void login() override; void logout() override; Cantor::Expression* evaluateExpression(const QString& command,Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; void runFirstExpression() override; void interrupt() override; void sendInputToProcess(const QString& input); void setTypesettingEnabled(bool enable) override; void setWorksheetPath(const QString& path) override; Cantor::CompletionObject* completionFor(const QString& command, int index=-1) override; QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; VersionInfo sageVersion(); public Q_SLOTS: void readStdOut(); void readStdErr(); private Q_SLOTS: void currentExpressionChangedStatus(Cantor::Expression::Status); void processFinished(int exitCode, QProcess::ExitStatus); void reportProcessError(QProcess::ProcessError); void fileCreated(const QString& path); private: void defineCustomFunctions(); bool updateSageVersion(); private: KPtyProcess* m_process; bool m_isInitialized; QString m_tmpPath; KDirWatch m_dirWatch; bool m_waitingForPrompt; QString m_outputCache; VersionInfo m_sageVersion; bool m_haveSentInitCmd; QString m_worksheetPath; }; #endif /* _SAGESESSION_H */ diff --git a/src/cantor.h b/src/cantor.h index a8cc09c9..72e80dfb 100644 --- a/src/cantor.h +++ b/src/cantor.h @@ -1,127 +1,124 @@ /* Copyright (C) 2009 Alexander Rieder 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 CANTOR_H #define CANTOR_H #include #include #include #include #include class QTabWidget; -<<<<<<< Updated upstream class KTextEdit; class KRecentFilesAction; -======= ->>>>>>> Stashed changes namespace Cantor{ class WorksheetAccessInterface; } namespace KParts{ class ReadWritePart; } /** * This is the application "Shell". It has a menubar, toolbar, and * statusbar but relies on the "Part" to do all the real work. */ class CantorShell : public KParts::MainWindow { Q_OBJECT public: /** * Default Constructor */ CantorShell(); /** * Default Destructor */ ~CantorShell() override; Cantor::WorksheetAccessInterface* currentWorksheetAccessInterface(); void addWorksheet(); protected: /** * This method is called when it is time for the app to save its * properties for session management purposes. */ void saveProperties(KConfigGroup &) override; /** * This method is called when this app is restored. The KConfig * object points to the session management config file that was saved * with @ref saveProperties */ void readProperties(const KConfigGroup &) override; public Q_SLOTS: void addWorksheet(const QString& backendName); /// Use this method/slot to load whatever file/URL you have void load(const QUrl& url); private Q_SLOTS: void fileNew(); void fileOpen(); void onWorksheetSave(const QUrl& url); void optionsConfigureKeys(); void activateWorksheet(int index); void setTabCaption(const QString& tab, const QIcon& icon); void closeTab(int index = -1); void showSettings(); void downloadExamples(); void openExample(); void updatePanel(); void updateNewSubmenu(); void pluginVisibilityRequested(); private: void setupActions(); void closeEvent(QCloseEvent*) override; bool reallyClose(bool checkAllParts = true); void updateWindowTitle(const QString& fileName); KParts::ReadWritePart* findPart(QWidget* widget); private: QMap m_pluginsVisibility; QList m_parts; KParts::ReadWritePart* m_part; QTabWidget* m_tabWidget; QList m_panels; QList m_newBackendActions; QDockWidget* m_helpDocker; KRecentFilesAction* m_recentProjectsAction; // For better UX: set previous used filter in "Open" action as default filter QString m_previousFilter; }; #endif // CANTOR_H diff --git a/src/cantor_part.h b/src/cantor_part.h index b2d451e8..452198ac 100644 --- a/src/cantor_part.h +++ b/src/cantor_part.h @@ -1,188 +1,189 @@ /* 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 CANTORPART_H #define CANTORPART_H #include #include #include #include class QWidget; class Worksheet; class WorksheetView; +class SarchBar; class SearchBar; class ScriptEditorWidget; class KAboutData; class QAction; class KToggleAction; class QProgressDialog; namespace Cantor{ class PanelPluginHandler; } /** * This is a "Part". It that does all the real work in a KPart * application. * * @short Main Part * @author Alexander Rieder */ class CantorPart : public KParts::ReadWritePart { Q_OBJECT public: /** * Default constructor */ CantorPart(QWidget *parentWidget,QObject *parent, const QVariantList &args); /** * Destructor */ ~CantorPart() override; /** * This is a virtual function inherited from KParts::ReadWritePart. * A shell will use this to inform this Part if it should act * read-only */ void setReadWrite(bool rw) override; /** * Reimplemented to disable and enable Save action */ void setModified(bool modified) override; KAboutData& createAboutData(); Worksheet* worksheet(); Q_SIGNALS: void setCaption(const QString& caption, const QIcon& icon); void showHelp(const QString& help); void worksheetSave(const QUrl& url); public Q_SLOTS: void updateCaption(); protected: /** * This must be implemented by each part */ bool openFile() override; /** * This must be implemented by each read-write part */ bool saveFile() override; /** * Called when this part becomes the active one, * or if it looses activity **/ void guiActivateEvent( KParts::GUIActivateEvent * event ) override; void loadAssistants(); void adjustGuiToSession(); void setReadOnly(); protected Q_SLOTS: void fileSaveAs(); void fileSavePlain(); void exportToLatex(); void evaluateOrInterrupt(); void restartBackend(); void enableTypesetting(bool enable); void showBackendHelp(); void print(); void printPreview(); void worksheetStatusChanged(Cantor::Session::Status stauts); void showSessionError(const QString& error); void worksheetSessionLoginStarted(); void worksheetSessionLoginDone(); void initialized(); void pluginsChanged(); void runCommand(const QString& value); void runAssistant(); void publishWorksheet(); void showScriptEditor(bool show); void scriptEditorClosed(); void runScript(const QString& file); void showSearchBar(); void showExtendedSearchBar(); void findNext(); void findPrev(); void searchBarDeleted(); /** sets the status message, or cached it, if the StatusBar is blocked. * Use this method instead of "emit setStatusBarText" */ void setStatusMessage(const QString& message); /** Shows an important status message. It makes sure the message is displayed, * by blocking the statusbarText for 3 seconds */ void showImportantStatusMessage(const QString& message); /** Blocks the StatusBar for new messages, so the currently shown one won't be overridden */ void blockStatusBar(); /** Removes the block from the StatusBar, and shows the last one of the StatusMessages that where set during the block **/ void unblockStatusBar(); private: Worksheet *m_worksheet; WorksheetView *m_worksheetview; SearchBar *m_searchBar; QPointer m_scriptEditor; Cantor::PanelPluginHandler* m_panelHandler; QProgressDialog* m_initProgressDlg; bool m_showProgressDlg; QAction * m_evaluate; QAction * m_restart; QAction * m_save; QAction * m_findNext; QAction * m_findPrev; KToggleAction* m_typeset; KToggleAction* m_highlight; KToggleAction* m_completion; KToggleAction* m_exprNumbering; KToggleAction* m_animateWorksheet; KToggleAction* m_embeddedMath; QAction * m_showBackendHelp; QVector m_editActions; QString m_cachedStatusMessage; bool m_statusBarBlocked; unsigned int m_sessionStatusCounter; }; #endif // CANTORPART_H diff --git a/src/commandentry.h b/src/commandentry.h index b566c4a5..535d5ad6 100644 --- a/src/commandentry.h +++ b/src/commandentry.h @@ -1,195 +1,192 @@ /* 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 Copyright (C) 2012 Martin Kuettler Copyright (C) 2018 Alexander Semke */ #ifndef COMMANDENTRY_H #define COMMANDENTRY_H #include #include #include "worksheetentry.h" #include "lib/expression.h" class Worksheet; class ResultItem; -<<<<<<< Updated upstream class QTimer; class QJsonObject; -======= ->>>>>>> Stashed changes namespace Cantor{ class Result; class CompletionObject; class SyntaxHelpObject; } class CommandEntry : public WorksheetEntry { Q_OBJECT public: static const QString Prompt; static const QString MidPrompt; static const QString HidePrompt; explicit CommandEntry(Worksheet* worksheet); ~CommandEntry() override; enum {Type = UserType + 2}; int type() const override; QString command(); void setExpression(Cantor::Expression* expr); Cantor::Expression* expression(); QString currentLine(); bool isEmpty() override; void setContent(const QString& content) override; void setContent(const QDomElement& content, const KZip& file) override; void setContentFromJupyter(const QJsonObject& cell) override; QDomElement toXml(QDomDocument& doc, KZip* archive) override; QJsonValue toJupyterJson() override; QString toPlain(const QString& commandSep, const QString& commentStartingSeq, const QString& commentEndingSeq) override; void setCompletion(Cantor::CompletionObject* tc); void setSyntaxHelp(Cantor::SyntaxHelpObject* sh); bool acceptRichText() override; void removeContextHelp(); void interruptEvaluation() override; bool isShowingCompletionPopup(); bool focusEntry(int pos = WorksheetTextItem::TopLeft, qreal xCoord = 0) override; void layOutForWidth(qreal entry_zone_x, qreal w, bool force = false) override; qreal promptItemWidth(); WorksheetTextItem* highlightItem() override; WorksheetCursor search(const QString& pattern, unsigned flags, QTextDocument::FindFlags qt_flags, const WorksheetCursor& pos = WorksheetCursor()) override; public Q_SLOTS: bool evaluateCurrentItem() override; bool evaluate(WorksheetEntry::EvaluationOption evalOp = FocusNext) override; void addInformation(); void removeResults(); void removeResult(Cantor::Result* result); void showCompletion() override; void selectPreviousCompletion(); void updateEntry() override; void updatePrompt(const QString& postfix = CommandEntry::Prompt); void expressionChangedStatus(Cantor::Expression::Status status); void showAdditionalInformationPrompt(const QString& question); void showCompletions(); void applySelectedCompletion(); void completedLineChanged(); void showSyntaxHelp(); void completeLineTo(const QString& line, int index); void startRemoving() override; void moveToNextItem(int pos, qreal x); void moveToPreviousItem(int pos, qreal x); void populateMenu(QMenu* menu, QPointF pos) override; protected: bool wantToEvaluate() override; private: WorksheetTextItem* currentInformationItem(); bool informationItemHasFocus(); bool focusWithinThisItem(); QPoint getPopupPosition(); QPoint toGlobalPosition(QPointF localPos); void initMenus(); private: enum CompletionMode { PreliminaryCompletion, FinalCompletion }; private Q_SLOTS: void invalidate(); void resultDeleted(); void clearResultItems(); void collapseResults(); void expandResults(); void removeResultItem(int index); void replaceResultItem(int index); void updateCompletions(); void completeCommandTo(const QString& completion, CommandEntry::CompletionMode mode = PreliminaryCompletion); void changeResultCollapsingAction(); void backgroundColorChanged(QAction*); void textColorChanged(QAction*); void fontBoldTriggered(); void fontItalicTriggered(); void fontIncreaseTriggered(); void fontDecreaseTriggered(); void fontSelectTriggered(); void resetFontTriggered(); void animatePromptItem(); void setMidPrompt(); void setHidePrompt(); private: static const double HorizontalSpacing; static const double VerticalSpacing; WorksheetTextItem* m_promptItem; WorksheetTextItem* m_commandItem; QVector m_resultItems; bool m_resultsCollapsed; WorksheetTextItem* m_errorItem; QList m_informationItems; Cantor::Expression* m_expression; Cantor::CompletionObject* m_completionObject; QPointer m_completionBox; Cantor::SyntaxHelpObject* m_syntaxHelpObject; EvaluationOption m_evaluationOption; QPropertyAnimation* m_promptItemAnimation; bool m_menusInitialized; bool m_textColorCustom; bool m_backgroundColorCustom; //formatting QActionGroup* m_backgroundColorActionGroup; QMenu* m_backgroundColorMenu; QActionGroup* m_textColorActionGroup; QColor m_defaultDefaultTextColor; QMenu* m_textColorMenu; QMenu* m_fontMenu; }; #endif // COMMANDENTRY_H diff --git a/src/imageresultitem.h b/src/imageresultitem.h index 00b2a041..ce827078 100644 --- a/src/imageresultitem.h +++ b/src/imageresultitem.h @@ -1,52 +1,53 @@ /* 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 Martin Kuettler */ #ifndef IMAGERESULTITEM_H #define IMAGERESULTITEM_H #include "resultitem.h" #include "worksheetimageitem.h" +class CommandEntry; class EpsRenderer; class ImageResultItem : public WorksheetImageItem, public ResultItem { Q_OBJECT public: explicit ImageResultItem(QGraphicsObject* parent, Cantor::Result* result); ~ImageResultItem() override = default; using WorksheetImageItem::setGeometry; double setGeometry(double x, double y, double w) override; void populateMenu(QMenu* menu, QPointF pos) override; void update() override; QRectF boundingRect() const override; double width() const override; double height() const override; void deleteLater() override; protected Q_SLOTS: void saveResult(); }; #endif // IMAGERESULTITEM_H diff --git a/src/lib/expression.h b/src/lib/expression.h index 7df29ace..75f43c35 100644 --- a/src/lib/expression.h +++ b/src/lib/expression.h @@ -1,284 +1,285 @@ /* 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" class QFileSystemWatcher; +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(); /** * Returns the command, adapted for using by appropriate Backend * The return value can be equal or not to @ref command() * Backend should use this function, instead of @ref command() */ virtual QString internalCommand(); /** * 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 removeResult(Result* result); /** * Deletes the all results of this expression. * */ void clearResults(); /** * 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 clearResults() */ void resultsCleared(); /** * emitted when the results of the expression were deleted. * @see clearResult(Result* result) */ void resultRemoved(int index); /** * 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: // Protected constructor, useful for derived classes with own id setting strategy Expression(Session* session, bool internal, int id); /** * 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); //returns a string of latex commands, that is inserted into the header. //used for example if special packages are needed virtual QString additionalLatexHeaders(); QFileSystemWatcher* fileWatcher(); private: void renderResultAsLatex(Result* result); void latexRendered(LatexRenderer* renderer, Result* result); private: ExpressionPrivate* d; }; } #endif /* _EXPRESSION_H */ diff --git a/src/lib/session.h b/src/lib/session.h index 5ac4e398..f22e1851 100644 --- a/src/lib/session.h +++ b/src/lib/session.h @@ -1,272 +1,273 @@ /* 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 #include "cantor_export.h" #include "expression.h" #include "defaultvariablemodel.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; class DefaultVariableModel; /** * 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); /** * Similar to Session::Session, but also specify variable model for automatically handles model's updates */ explicit Session( Backend* backend, DefaultVariableModel* model); /** * 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 after logout session status must be Status::Disable * Default implementation does basic operations for all sessions (for example, variable model cleanup) * NOTE: restarting the session consists of first logout() and then login() */ virtual void logout(); /** * 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 internal true, if it is an 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 * After this function expression queue must be clean */ 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 or nullptr, if * this backend have a variable model, which not inherit from * default variable model class (in this case @see variableDataModel()) * @return DefaultVariableModel to interact with the variables */ virtual DefaultVariableModel* variableModel() const; /** * returns QAbstractItemModel to interact with the variables */ virtual QAbstractItemModel* variableDataModel() const; /** * 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(); /** * This method dequeues the expression and goes to the next expression, if the queue is not empty. * Also, this method updates the variable model, if needed. * If the queue is empty, the session status is set to Done. * @param setDoneAfterUpdate enable setting status to Done after variable update, if queue is empty */ virtual void finishFirstExpression(bool setDoneAfterUpdate = false); /** * Starts variable update immedeatly, useful for subclasses, which run internal command * which could change variables listen */ virtual void updateVariables(); /** * Setting variable model, useful if model constructor requires functional session */ void setVariableModel(DefaultVariableModel* model); /** * Search file for session in AppDataLocation and in GenericDataLocation */ QString locateCantorFile(const QString& partialPath, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); QStringList locateAllCantorFiles(const QString& partialPath, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); /** * Sometimes backend process/server could crash, stop responding, in other words, session can't * continue to work without restart. * This method will notify about session crashing with automatically logout * and another actions, which needed to do in situations like that */ void reportSessionCrash(const QString& additionalInfo = QString()); 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/scripteditor/scripteditorwidget.h b/src/scripteditor/scripteditorwidget.h index afe2ced4..bba26cfe 100644 --- a/src/scripteditor/scripteditorwidget.h +++ b/src/scripteditor/scripteditorwidget.h @@ -1,61 +1,62 @@ /* 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 _SCRIPTEDITORWIDGET_H #define _SCRIPTEDITORWIDGET_H #include class QTemporaryFile; +class QGridLayout; namespace KTextEditor { class View; class Document; } class ScriptEditorWidget : public KXmlGuiWindow { Q_OBJECT public: explicit ScriptEditorWidget( const QString& filter, const QString& highlightingMode, QWidget* parent = nullptr ); ~ScriptEditorWidget() override; void open(const QUrl &url); Q_SIGNALS: void runScript(const QString& filename); private Q_SLOTS: void newScript(); void open(); void run(); void updateCaption(); protected: bool queryClose() override; private: QString m_filter; KTextEditor::View* m_editor; KTextEditor::Document* m_script; QTemporaryFile* m_tmpFile; }; #endif /* _SCRIPTEDITORWIDGET_H */ diff --git a/src/searchbar.h b/src/searchbar.h index 0c60567f..c6e2e9dd 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -1,111 +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) 2012 Martin Kuettler */ #ifndef SEARCHBAR_H #define SEARCHBAR_H #include #include #include #include "ui_standardsearchbar.h" #include "ui_extendedsearchbar.h" #include "worksheetcursor.h" class Worksheet; +class WorksheetEntry; +class WorksheetTextItem; class QMenu; class SearchBar : public QWidget { Q_OBJECT public: SearchBar(QWidget* parent, Worksheet* worksheet); ~SearchBar() override; void showStandard(); void showExtended(); void next(); void prev(); void searchForward(bool skipFirstChar = false); void searchBackward(bool skipFirstChar = false); public Q_SLOTS: void on_close_clicked(); void on_openExtended_clicked(); void on_openStandard_clicked(); void on_next_clicked(); void on_previous_clicked(); void on_replace_clicked(); void on_replaceAll_clicked(); void on_pattern_textChanged(const QString& p); void on_replacement_textChanged(const QString& r); void on_addFlag_clicked(); void on_removeFlag_clicked(); void on_matchCase_toggled(bool b); void invalidateStartCursor(); void invalidateCurrentCursor(); protected Q_SLOTS: void toggleFlag(); private: void updateSearchLocations(); void fillLocationsMenu(QMenu* menu, int flags); void setupStdUi(); void setupExtUi(); void setStatus(QString); void clearStatus(); void setStartCursor(WorksheetCursor cursor); void setCurrentCursor(WorksheetCursor cursor); Worksheet* worksheet(); QPushButton* nextButton(); QPushButton* previousButton(); private: Ui::StandardSearchBar* m_stdUi; Ui::ExtendedSearchBar* m_extUi; WorksheetCursor m_startCursor; WorksheetCursor m_currentCursor; Worksheet* m_worksheet; QString m_pattern; QString m_replacement; QTextDocument::FindFlags m_qtFlags; unsigned int m_searchFlags; bool m_atBeginning; bool m_atEnd; bool m_notFound; }; #endif // SEARCHBAR_H diff --git a/src/worksheetentry.h b/src/worksheetentry.h index d64e976d..b8edf974 100644 --- a/src/worksheetentry.h +++ b/src/worksheetentry.h @@ -1,224 +1,225 @@ /* 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 Martin Kuettler */ #ifndef WORKSHEETENTRY_H #define WORKSHEETENTRY_H #include #include #include #include "worksheet.h" #include "worksheettextitem.h" #include "worksheetcursor.h" #include "worksheetcontrolitem.h" class TextEntry; class MarkdownEntry; class CommandEntry; class ImageEntry; class PageBreakEntry; +class LaTeXEntry; class WorksheetTextItem; class ActionBar; class QPainter; class QWidget; class QPropertyAnimation; class QJsonObject; struct AnimationData; class WorksheetEntry : public QGraphicsObject { Q_OBJECT public: explicit WorksheetEntry(Worksheet* worksheet); ~WorksheetEntry() override; enum {Type = UserType}; int type() const override; virtual bool isEmpty()=0; static WorksheetEntry* create(int t, Worksheet* worksheet); WorksheetEntry* next() const; WorksheetEntry* previous() const; void forceRemove(); void setNext(WorksheetEntry*); void setPrevious(WorksheetEntry*); QRectF boundingRect() const override; void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; virtual bool acceptRichText() = 0; virtual void setContent(const QString& content)=0; virtual void setContent(const QDomElement& content, const KZip& file)=0; virtual void setContentFromJupyter(const QJsonObject& cell)=0; virtual QDomElement toXml(QDomDocument& doc, KZip* archive)=0; virtual QJsonValue toJupyterJson()=0; virtual QString toPlain(const QString& commandSep, const QString& commentStartingSeq, const QString& commentEndingSeq)=0; virtual void interruptEvaluation()=0; virtual void showCompletion(); virtual bool focusEntry(int pos = WorksheetTextItem::TopLeft, qreal xCoord = 0); virtual qreal setGeometry(qreal x, qreal entry_zone_x, qreal y, qreal w); virtual void layOutForWidth(qreal entry_zone_x, qreal w, bool force = false) = 0; QPropertyAnimation* sizeChangeAnimation(QSizeF s = QSizeF()); virtual void populateMenu(QMenu* menu, QPointF pos); bool aboutToBeRemoved(); QSizeF size(); enum EvaluationOption { InternalEvaluation, DoNothing, FocusNext, EvaluateNext }; virtual WorksheetTextItem* highlightItem(); bool hasActionBar(); enum SearchFlag {SearchCommand=1, SearchResult=2, SearchError=4, SearchText=8, SearchLaTeX=16, SearchAll=31}; virtual WorksheetCursor search(const QString& pattern, unsigned flags, QTextDocument::FindFlags qt_flags, const WorksheetCursor& pos = WorksheetCursor()); bool isCellSelected(); void setCellSelected(bool); public Q_SLOTS: virtual bool evaluate(WorksheetEntry::EvaluationOption evalOp = FocusNext) = 0; virtual bool evaluateCurrentItem(); virtual void updateEntry() = 0; void insertCommandEntry(); void insertTextEntry(); void insertMarkdownEntry(); void insertLatexEntry(); void insertImageEntry(); void insertPageBreakEntry(); void insertCommandEntryBefore(); void insertTextEntryBefore(); void insertMarkdownEntryBefore(); void insertLatexEntryBefore(); void insertImageEntryBefore(); void insertPageBreakEntryBefore(); void convertToCommandEntry(); void convertToTextEntry(); void convertToMarkdownEntry(); void convertToLatexEntry(); void convertToImageEntry(); void converToPageBreakEntry(); virtual void sizeAnimated(); virtual void startRemoving(); bool stopRemoving(); void moveToPreviousEntry(int pos = WorksheetTextItem::BottomRight, qreal x = 0); void moveToNextEntry(int pos = WorksheetTextItem::TopLeft, qreal x = 0); void recalculateSize(); // similar to recalculateSize, but the size change is animated void animateSizeChange(); // animate the size change and the opacity of item void fadeInItem(QGraphicsObject* item = nullptr, const char* slot = nullptr); void fadeOutItem(QGraphicsObject* item = nullptr, const char* slot = "deleteLater()"); void endAnimation(); void showActionBar(); void hideActionBar(); void startDrag(QPointF grabPos = QPointF()); void moveToNext(bool updateLayout = true); void moveToPrevious(bool updateLayout = true); Q_SIGNALS: void aboutToBeDeleted(); protected: Worksheet* worksheet(); WorksheetView* worksheetView(); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void evaluateNext(EvaluationOption opt); void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override; void setSize(QSizeF size); bool animationActive(); void updateSizeAnimation(QSizeF size); void invokeSlotOnObject(const char* slot, QObject* obj); virtual void addActionsToBar(ActionBar* actionBar); virtual bool wantToEvaluate() = 0; virtual bool wantFocus(); QJsonObject jupyterMetadata() const; void setJupyterMetadata(QJsonObject metadata); void recalculateControlGeometry(); protected Q_SLOTS: virtual void remove(); void deleteActionBar(); void deleteActionBarAnimation(); public: static const qreal VerticalMargin; static const qreal ControlElementWidth; static const qreal ControlElementBorder; static const qreal RightMargin; protected: WorksheetControlItem m_controlElement; private: QSizeF m_size; qreal m_entry_zone_x; WorksheetEntry* m_prev; WorksheetEntry* m_next; Q_PROPERTY(QSizeF size READ size WRITE setSize) AnimationData* m_animation; ActionBar* m_actionBar; QPropertyAnimation* m_actionBarAnimation; bool m_aboutToBeRemoved; QJsonObject* m_jupyterMetadata; bool m_isCellSelected{false}; }; #endif // WORKSHEETENTRY_H