aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
commit7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch)
treea35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h155
1 files changed, 155 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h b/SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h
new file mode 100644
index 0000000..0052a74
--- /dev/null
+++ b/SQLiteStudio3/guiSQLiteStudio/windows/editorwindow.h
@@ -0,0 +1,155 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+#include "db/db.h"
+#include "mdichild.h"
+#include "common/extactioncontainer.h"
+#include "guiSQLiteStudio_global.h"
+#include <QWidget>
+
+namespace Ui {
+ class EditorWindow;
+}
+
+class SqlQueryModel;
+class QComboBox;
+class QActionGroup;
+class DbListModel;
+class QLabel;
+class QLineEdit;
+class ExtLineEdit;
+class IntValidator;
+class FormView;
+class SqlQueryItem;
+class SqlEditor;
+
+CFG_KEY_LIST(EditorWindow, QObject::tr("SQL editor window"),
+ CFG_KEY_ENTRY(EXEC_QUERY, Qt::Key_F9, QObject::tr("Execute query"))
+ CFG_KEY_ENTRY(EXPLAIN_QUERY, Qt::Key_F8, QObject::tr("Execute \"EXPLAIN\" query"))
+ CFG_KEY_ENTRY(PREV_DB, Qt::CTRL + Qt::Key_Up, QObject::tr("Switch current working database to previous on the list"))
+ CFG_KEY_ENTRY(NEXT_DB, Qt::CTRL + Qt::Key_Down, QObject::tr("Switch current working database to next on the list"))
+ CFG_KEY_ENTRY(SHOW_NEXT_TAB, Qt::ALT + Qt::Key_Right, QObject::tr("Go to next editor tab"))
+ CFG_KEY_ENTRY(SHOW_PREV_TAB, Qt::ALT + Qt::Key_Left, QObject::tr("Go to previous editor tab"))
+ CFG_KEY_ENTRY(FOCUS_RESULTS_BELOW, Qt::ALT + Qt::Key_PageDown, QObject::tr("Move keyboard input focus to the results view below"))
+ CFG_KEY_ENTRY(FOCUS_EDITOR_ABOVE, Qt::ALT + Qt::Key_PageUp, QObject::tr("Move keyboard input focus to the SQL editor above"))
+)
+
+class GUI_API_EXPORT EditorWindow : public MdiChild
+{
+ Q_OBJECT
+ Q_ENUMS(Action)
+
+ public:
+ enum class ResultsDisplayMode
+ {
+ SEPARATE_TAB = 0,
+ BELOW_QUERY = 1
+ };
+
+ enum Action
+ {
+ EXEC_QUERY,
+ EXPLAIN_QUERY,
+ RESULTS_IN_TAB,
+ RESULTS_BELOW,
+ CURRENT_DB,
+ NEXT_DB,
+ PREV_DB,
+ SHOW_NEXT_TAB,
+ SHOW_PREV_TAB,
+ FOCUS_RESULTS_BELOW,
+ FOCUS_EDITOR_ABOVE,
+ CLEAR_HISTORY,
+ EXPORT_RESULTS,
+ CREATE_VIEW_FROM_QUERY
+ };
+
+ enum ToolBar
+ {
+ TOOLBAR_MAIN
+ };
+
+ enum class ActionGroup
+ {
+ RESULTS_POSITIONING
+ };
+
+ explicit EditorWindow(QWidget *parent = 0);
+ EditorWindow(const EditorWindow& editor);
+ ~EditorWindow();
+
+ static void staticInit();
+ static void insertAction(ExtActionPrototype* action, ToolBar toolbar = TOOLBAR_MAIN);
+ static void insertActionBefore(ExtActionPrototype* action, Action beforeAction, ToolBar toolbar = TOOLBAR_MAIN);
+ static void insertActionAfter(ExtActionPrototype* action, Action afterAction, ToolBar toolbar = TOOLBAR_MAIN);
+ static void removeAction(ExtActionPrototype* action, ToolBar toolbar = TOOLBAR_MAIN);
+
+ QSize sizeHint() const;
+ QAction* getAction(Action action);
+ QString getQueryToExecute(bool doSelectCurrentQuery = false);
+ bool setCurrentDb(Db* db);
+ void setContents(const QString& sql);
+ QString getContents() const;
+ void execute();
+ QToolBar* getToolBar(int toolbar) const;
+ SqlEditor* getEditor() const;
+ bool isUncommited() const;
+ QString getQuitUncommitedConfirmMessage() const;
+
+ protected:
+ void changeEvent(QEvent *e);
+ QVariant saveSession();
+ bool restoreSession(const QVariant& sessionValue);
+ Icon* getIconNameForMdiWindow();
+ QString getTitleForMdiWindow();
+ Db* getCurrentDb();
+
+ private:
+ static void createStaticActions();
+ static void loadTabsMode();
+
+ void init();
+ void createActions();
+ void createDbCombo();
+ void setupDefShortcuts();
+ void selectCurrentQuery(bool fallBackToPreviousIfNecessary = false);
+ void updateShortcutTips();
+
+ static ResultsDisplayMode resultsDisplayMode;
+ static QHash<Action,QAction*> staticActions;
+ static QHash<ActionGroup,QActionGroup*> staticActionGroups;
+
+ Ui::EditorWindow *ui = nullptr;
+ SqlQueryModel* resultsModel = nullptr;
+ QHash<ActionGroup,QActionGroup*> actionGroups;
+ QComboBox* dbCombo = nullptr;
+ DbListModel* dbComboModel = nullptr;
+ int sqlEditorNum = 1;
+ qint64 lastQueryHistoryId = 0;
+ QString lastSuccessfulQuery;
+
+ private slots:
+ void execQuery(bool explain = false);
+ void explainQuery();
+ void dbChanged();
+ void executionSuccessful();
+ void executionFailed(const QString& errorText);
+ void totalRowsAndPagesAvailable();
+ void updateResultsDisplayMode();
+ void prevDb();
+ void nextDb();
+ void showNextTab();
+ void showPrevTab();
+ void focusResultsBelow();
+ void focusEditorAbove();
+ void historyEntrySelected(const QModelIndex& current, const QModelIndex& previous);
+ void historyEntryActivated(const QModelIndex& current);
+ void clearHistory();
+ void exportResults();
+ void createViewFromQuery();
+ void updateState();
+};
+
+GUI_API_EXPORT int qHash(EditorWindow::ActionGroup action);
+
+#endif // EDITOR_H