ScriptEdit.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SCRIPTEDIT_H
00030 #define SCRIPTEDIT_H
00031
00032 #include "ScriptingEnv.h"
00033 #include "Script.h"
00034
00035 #include <QMenu>
00036 #include <QTextEdit>
00037
00038 class QAction;
00039 class QMenu;
00040 class QCompleter;
00041
00048 class ScriptEdit: public QTextEdit, public scripted
00049 {
00050 Q_OBJECT
00051
00052 public:
00053 ScriptEdit(ScriptingEnv *env, QWidget *parent=0, const char *name=0);
00055 void customEvent(QEvent*);
00057 int lineNumber(int pos) const;
00058 bool error(){return d_error;};
00059
00060 void setCompleter(QCompleter *c);
00061
00062 public slots:
00063 void execute();
00064 void executeAll();
00065 void evaluate();
00066 void print();
00067 void exportPDF(const QString& fileName);
00068 QString exportASCII(const QString &file=QString::null);
00069 QString importASCII(const QString &file=QString::null);
00070 void insertFunction(const QString &);
00071 void insertFunction(QAction * action);
00072 void setContext(QObject *context) { myScript->setContext(context); }
00073 void scriptPrint(const QString&);
00074 void updateIndentation();
00075 void setDirPath(const QString& path);
00076
00077 signals:
00078 void dirPathChanged(const QString& path);
00079
00080 protected:
00081 virtual void contextMenuEvent(QContextMenuEvent *e);
00082 virtual void keyPressEvent(QKeyEvent *e);
00083 void focusInEvent(QFocusEvent *e);
00084
00085 private:
00086 Script *myScript;
00087 QAction *actionExecute, *actionExecuteAll, *actionEval, *actionPrint, *actionImport, *actionExport;
00089 QMenu *functionsMenu;
00091 QTextCursor printCursor;
00092 QString scriptsDirPath;
00093
00095 QTextBlockFormat d_fmt_default;
00097 QTextBlockFormat d_fmt_success;
00099 QTextBlockFormat d_fmt_failure;
00101 bool d_error;
00103 bool d_changing_fmt;
00104
00105 QCompleter *d_completer;
00106
00107 private slots:
00109
00113 void insertErrorMsg(const QString &message);
00115 void handleContentsChange(int position, int chars_removed, int chars_added);
00116
00117 void insertCompletion(const QString &completion);
00118
00119 private:
00120 QString textUnderCursor() const;
00121 };
00122
00123 #endif