kumirprogram.h 3.36 KB
Newer Older
victor's avatar
 
victor committed
1 2 3 4 5 6
#ifndef COREGUI_KUMIRPROGRAM_H
#define COREGUI_KUMIRPROGRAM_H

#include <QtCore>
#include <QtGui>
#include "interfaces/generatorinterface.h"
victor's avatar
 
victor committed
7
#include "interfaces/actorinterface.h"
victor's avatar
 
victor committed
8
#include "interfaces/runinterface.h"
victor's avatar
 
victor committed
9
#include "interfaces/editorinterface.h"
victor's avatar
 
victor committed
10 11
#include "stdlib/connector.h"
#include "terminal.h"
victor's avatar
 
victor committed
12
#include "extensionsystem/kplugin.h"
victor's avatar
 
victor committed
13 14 15 16

namespace CoreGUI {

using Shared::GeneratorInterface;
victor's avatar
 
victor committed
17
using Shared::ActorInterface;
victor's avatar
 
victor committed
18
using Shared::RunInterface;
victor's avatar
 
victor committed
19
using Shared::EditorInterface;
victor's avatar
 
victor committed
20
using Terminal::Term;
victor's avatar
 
victor committed
21
using StdLib::Connector;
victor's avatar
 
victor committed
22
using namespace ExtensionSystem;
victor's avatar
 
victor committed
23 24 25 26 27 28

class KumirProgram : public QObject
{
    Q_OBJECT
public:
    explicit KumirProgram(QObject *parent = 0);
victor's avatar
 
victor committed
29
    void setNativeGenerator(GeneratorInterface * cpp);
victor's avatar
 
victor committed
30
    inline void setBytecodeGenerator(GeneratorInterface * bc) { plugin_bytcodeGenerator = bc; }
victor's avatar
 
victor committed
31
    inline void setEditorPlugin(EditorInterface * ed) { plugin_editor = ed; }
victor's avatar
 
victor committed
32
    void setAST(const AST::Data * ast);
victor's avatar
 
victor committed
33 34 35
    inline QActionGroup * actions() { return gr_actions; }
    inline bool isRunning() const { return e_state!=Idle; }
    inline void setSourceFileName(const QString & s) { s_sourceFileName = s; }
victor's avatar
 
victor committed
36
    inline void setDocumentId(int id) { if (e_state==Idle) i_documentId = id; }
victor's avatar
 
victor committed
37
    inline int documentId() const { return i_documentId; }
victor's avatar
 
victor committed
38
    void setTerminal(Term * t, QDockWidget * w);
victor's avatar
 
victor committed
39
    void setBytecodeRun(KPlugin * run);
victor's avatar
 
victor committed
40 41
    void addActor(KPlugin * a, QDockWidget * w);
    inline QString endStatus() const { return s_endStatus; }
victor's avatar
 
victor committed
42
    ~KumirProgram();
victor's avatar
 
victor committed
43
    class KumirVariablesWebObject * variablesWebObject();
victor's avatar
 
victor committed
44
signals:
victor's avatar
 
victor committed
45
    void giveMeAProgram();
victor's avatar
 
victor committed
46 47 48

public slots:
    void fastRun();
victor's avatar
 
victor committed
49
    void blindRun();
victor's avatar
 
victor committed
50 51 52 53 54
    void regularRun();
    void stepRun();
    void stepIn();
    void stepOut();
    void stop();
victor's avatar
 
victor committed
55 56 57 58
    void switchGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState cur);
    void handleActorCommandFinished();
    void handleActorCommand(const QString & actorName, const QString & command, const QVariantList & arguments);
    void handleActorResetRequest(const QString & actorName);
victor's avatar
 
victor committed
59
    void handleLineChanged(int lineNo);
victor's avatar
 
victor committed
60
    void handleMarginTextRequest(int lineNo, const QString & text);
victor's avatar
 
victor committed
61
    void handleMarginClearRequest(int fromLine, int toLine);
victor's avatar
 
victor committed
62 63 64
private slots:
    void handleProcessFinished(int exitCode, QProcess::ExitStatus);
    void handleProcessError(QProcess::ProcessError);
victor's avatar
 
victor committed
65
    void handleRunnerStopped(int);
victor's avatar
 
victor committed
66
    void handleInputDone(const QVariantList & data);
victor's avatar
 
victor committed
67
private:
victor's avatar
 
victor committed
68
    void timerEvent(QTimerEvent *e);
victor's avatar
 
victor committed
69
    void prepareKumirRunner();
victor's avatar
 
victor committed
70 71
    enum State { Idle, FastRun, RegularRun, StepRun } e_state;
    const AST::Data * m_ast;
victor's avatar
 
victor committed
72
    QString s_endStatus;
victor's avatar
 
victor committed
73
    QProcess * m_process;
victor's avatar
 
victor committed
74
    Term * m_terminal;
victor's avatar
 
victor committed
75
    QDockWidget * m_terminalWindow;
victor's avatar
 
victor committed
76
    GeneratorInterface * plugin_nativeGenerator;
victor's avatar
 
victor committed
77
    GeneratorInterface * plugin_bytcodeGenerator;
victor's avatar
 
victor committed
78
    RunInterface * plugin_bytecodeRun;
victor's avatar
 
victor committed
79
    EditorInterface * plugin_editor;
victor's avatar
 
victor committed
80
    QAction * a_fastRun;
victor's avatar
 
victor committed
81
    QAction * a_blindRun;
victor's avatar
 
victor committed
82 83 84 85 86 87 88 89
    QAction * a_regularRun;
    QAction * a_stepRun;
    QAction * a_stepIn;
    QAction * a_stepOut;
    QAction * a_stop;
    QActionGroup * gr_actions;
    QString s_sourceFileName;
    Connector * m_connector;
victor's avatar
 
victor committed
90 91
    QMap<QString,QDockWidget*> m_actorWindows;
    QMap<QString,ActorInterface*> m_actors;
victor's avatar
 
victor committed
92
    int i_documentId;
victor's avatar
 
victor committed
93
    bool b_blind;
victor's avatar
 
victor committed
94
    class KumirVariablesWebObject * m_variablesWebObject;
victor's avatar
 
victor committed
95
    int i_timerId;
victor's avatar
 
victor committed
96 97 98 99 100
};

} // namespace CoreGui

#endif // COREGUI_KUMIRPROGRAM_H