kumirprogram.h 3.07 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
#include "terminal.h"
victor's avatar
 
victor committed
11
#include "extensionsystem/kplugin.h"
victor's avatar
 
victor committed
12

victor's avatar
 
victor committed
13

victor's avatar
 
victor committed
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 namespace ExtensionSystem;
victor's avatar
 
victor committed
22 23 24 25 26

class KumirProgram : public QObject
{
    Q_OBJECT
public:
Victor Yacovlev's avatar
Victor Yacovlev committed
27 28 29 30 31 32 33
    enum RunEndStatus {
        Running,
        Finished,
        Terminated,
        Exception
    };

victor's avatar
 
victor committed
34
    explicit KumirProgram(QObject *parent = 0);
35 36 37 38

    inline Shared::Editor::InstanceInterface * editorInstance() const {
        return editor_;
    }
Victor Yacovlev's avatar
Victor Yacovlev committed
39
    void setEditorInstance(Shared::Editor::InstanceInterface * editor);
40 41

    inline QActionGroup * actions() { return actions_; }
Victor Yacovlev's avatar
Victor Yacovlev committed
42
    inline QActionGroup * breakpointActions() { return breakpointActions_; }
43 44
    inline bool isRunning() const { return state_!=Idle; }
    inline void setMainWidget(QWidget * w) { mainWidget_ = w; }
victor's avatar
 
victor committed
45
    void setTerminal(Term * t, QDockWidget * w);
46 47
    static Shared::GeneratorInterface * kumirCodeGenerator();
    static Shared::GeneratorInterface * kumirNativeGenerator();
Victor Yacovlev's avatar
Victor Yacovlev committed
48

Victor Yacovlev's avatar
Victor Yacovlev committed
49 50
    inline QString endStatusText() const { return endStatusText_; }
    inline RunEndStatus endStatus() const { return endStatus_; }
Victor Yacovlev's avatar
FS#1254  
Victor Yacovlev committed
51
    inline void setCourseManagerRequest() { courseManagerRequest_ = true; }
Victor Yacovlev's avatar
Victor Yacovlev committed
52
    static Shared::RunInterface * runner();
victor's avatar
 
victor committed
53
signals:
victor's avatar
 
victor committed
54
    void giveMeAProgram();
victor's avatar
 
victor committed
55 56

public slots:
victor's avatar
 
victor committed
57
    void blindRun();
victor's avatar
 
victor committed
58
    void regularRun();
victor's avatar
 
victor committed
59
    void testingRun();
victor's avatar
 
victor committed
60 61 62
    void stepRun();
    void stepIn();
    void stepOut();
Victor Yacovlev's avatar
Victor Yacovlev committed
63
    void runToCursor();
victor's avatar
 
victor committed
64
    void stop();
victor's avatar
 
victor committed
65
    void switchGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState cur);
66
    void handleLineChanged(int lineNo, quint32 colStart, quint32 colEnd);
victor's avatar
 
victor committed
67
    void handleMarginTextRequest(int lineNo, const QString & text);
victor's avatar
 
victor committed
68
    void handleMarginClearRequest(int fromLine, int toLine);
69
    void handleMarginTextReplace(int,const QString&,bool);
victor's avatar
 
victor committed
70
private slots:
victor's avatar
 
victor committed
71
    void handleRunnerStopped(int);
Victor Yacovlev's avatar
Victor Yacovlev committed
72

victor's avatar
 
victor committed
73
private:
74 75 76 77
    void createActions();
    void createConnections();


78
    void setAllActorsAnimationFlag(bool animationEnabled);
79
    bool prepareRunner(Shared::GeneratorInterface::DebugLevel);
80 81 82

private /*fields*/:
    enum State { Idle, RegularRun, BlindRun, StepRun, TestingRun } state_;
Victor Yacovlev's avatar
Victor Yacovlev committed
83 84
    RunEndStatus endStatus_;
    QString endStatusText_;
85 86 87 88 89 90 91 92 93 94
    Term * terminal_;
    Shared::Editor::InstanceInterface * editor_;
    QWidget * mainWidget_;

    QAction * blindRunAction_;
    QAction * regularRunAction_;
    QAction * testingRunAction_;
    QAction * stepRunAction_;
    QAction * stepInAction_;
    QAction * stepOutAction_;
Victor Yacovlev's avatar
Victor Yacovlev committed
95
    QAction * runToCursorAction_;
96
    QAction * stopAction_;
Victor Yacovlev's avatar
Victor Yacovlev committed
97
    QAction * toggleBreakpointAction_;
98
    QActionGroup * actions_;
Victor Yacovlev's avatar
Victor Yacovlev committed
99
    QActionGroup * breakpointActions_;
Victor Yacovlev's avatar
Victor Yacovlev committed
100

Victor Yacovlev's avatar
FS#1254  
Victor Yacovlev committed
101 102
    bool courseManagerRequest_;

victor's avatar
 
victor committed
103
    bool b_processUserTerminated;
victor's avatar
 
victor committed
104 105 106 107 108
};

} // namespace CoreGui

#endif // COREGUI_KUMIRPROGRAM_H