00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SQLEDITOR_H
00009 #define SQLEDITOR_H
00010
00011 #include <QWidget>
00012 #include <QFileSystemWatcher>
00013
00014 #include "ui_sqleditor.h"
00015 #include "sqlparser/tosqlparse.h"
00016
00017 class QTextDocument;
00018 class QLabel;
00019 class QProgressDialog;
00020
00021
00022
00029 class SqlEditor : public QMainWindow
00030 {
00031 Q_OBJECT
00032
00033 public:
00034 SqlEditor(QWidget * parent = 0);
00035 ~SqlEditor(){};
00036
00037 void saveOnExit();
00038
00039 void setFileName(const QString & fname);
00040 QString fileName() { return m_fileName; };
00041
00042 void setStatusMessage(const QString & message = 0);
00043
00044 signals:
00049 void showSqlResult(QString command);
00051 void sqlScriptStart();
00054 void showSqlScriptResult(QString line);
00055
00058 void buildTree();
00060 void rebuildViewTree(QString schema, QString name);
00061
00062 private:
00063 Ui::SqlEditor ui;
00064
00065 QString m_fileName;
00066 QFileSystemWatcher * m_fileWatcher;
00067
00068 QLabel * changedLabel;
00069 QLabel * cursorLabel;
00070 QString cursorTemplate;
00071
00073 bool canceled;
00074 bool m_scriptCancelled;
00076 QProgressDialog * progress;
00080 bool setProgress(int p);
00081
00082 void showEvent(QShowEvent * event);
00083 bool changedConfirm();
00084 void saveFile();
00085 void open(const QString & newFile);
00086
00090 QString query();
00092 QString prepareExec(toSQLParse::tokenizer &tokens, int line, int pos);
00093
00094 void find(QString ttf, bool forward);
00095
00097 void setFileWatcher(const QString & newFileName);
00098
00099 private slots:
00100 void action_Run_SQL_triggered();
00101 void actionRun_Explain_triggered();
00102 void actionRun_as_Script_triggered();
00103 void action_Open_triggered();
00104 void action_Save_triggered();
00105 void action_New_triggered();
00106 void actionSave_As_triggered();
00107 void actionCreateView_triggered();
00108 void sqlTextEdit_cursorPositionChanged(int,int);
00109 void documentChanged(bool state);
00110 void cancel();
00111
00112 void actionSearch_triggered();
00113 void searchEdit_textChanged(const QString & text);
00114 void findPrevious();
00115 void findNext();
00117 void externalFileChange(const QString & path);
00118
00119 void scriptCancelled();
00120 };
00121
00122 #endif