diff options
| author | 2023-04-30 18:30:36 -0400 | |
|---|---|---|
| committer | 2023-04-30 18:30:36 -0400 | |
| commit | 3565aad630864ecdbe53fdaa501ea708555b3c7c (patch) | |
| tree | c743e4ad0bad39ebdb2f514c7cc52d34a257ebbe /SQLiteStudio3/guiSQLiteStudio/sqleditor.h | |
| parent | 1fdc150116cad39aae5c5da407c3312b47a59e3a (diff) | |
New upstream version 3.4.4+dfsg.upstream/3.4.4+dfsg
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/sqleditor.h')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/sqleditor.h | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/sqleditor.h b/SQLiteStudio3/guiSQLiteStudio/sqleditor.h index ca79a1c..4af89c1 100644 --- a/SQLiteStudio3/guiSQLiteStudio/sqleditor.h +++ b/SQLiteStudio3/guiSQLiteStudio/sqleditor.h @@ -1,9 +1,9 @@ #ifndef SQLEDITOR_H #define SQLEDITOR_H +#include "common/strhash.h" #include "guiSQLiteStudio_global.h" #include "common/extactioncontainer.h" -#include "db/db.h" #include "sqlitesyntaxhighlighter.h" #include <QPlainTextEdit> #include <QTextEdit> @@ -18,6 +18,8 @@ class SqlEditor; class SearchTextDialog; class SearchTextLocator; class LazyTrigger; +class Db; +class QTimer; #ifdef Q_OS_OSX # define COMPLETE_REQ_KEY Qt::META @@ -40,19 +42,20 @@ CFG_KEY_LIST(SqlEditor, QObject::tr("SQL editor input field"), CFG_KEY_ENTRY(FIND_PREV, QKeySequence::FindPrevious, QObject::tr("Find previous")) CFG_KEY_ENTRY(REPLACE, QKeySequence::Replace, QObject::tr("Replace in text")) CFG_KEY_ENTRY(DELETE_LINE, Qt::CTRL + Qt::Key_D, QObject::tr("Delete current line")) - CFG_KEY_ENTRY(COMPLETE, COMPLETE_REQ_KEY + Qt::Key_Space, QObject::tr("Request code assistant")) + CFG_KEY_ENTRY(COMPLETE, COMPLETE_REQ_KEY + Qt::Key_Space, QObject::tr("Request code assistant")) CFG_KEY_ENTRY(FORMAT_SQL, Qt::CTRL + Qt::Key_T, QObject::tr("Format contents")) CFG_KEY_ENTRY(MOVE_BLOCK_DOWN, Qt::ALT + Qt::Key_Down, QObject::tr("Move selected block of text one line down")) CFG_KEY_ENTRY(MOVE_BLOCK_UP, Qt::ALT + Qt::Key_Up, QObject::tr("Move selected block of text one line up")) CFG_KEY_ENTRY(COPY_BLOCK_DOWN, Qt::ALT + Qt::CTRL + Qt::Key_Down, QObject::tr("Copy selected block of text and paste it a line below")) CFG_KEY_ENTRY(COPY_BLOCK_UP, Qt::ALT + Qt::CTRL + Qt::Key_Up, QObject::tr("Copy selected block of text and paste it a line above")) CFG_KEY_ENTRY(TOGGLE_COMMENT, Qt::CTRL + Qt::Key_Slash, QObject::tr("Toggle comment")) + CFG_KEY_ENTRY(INCR_FONT_SIZE, Qt::CTRL + Qt::Key_Plus, QObject::tr("Increase font size", "sql editor")) + CFG_KEY_ENTRY(DECR_FONT_SIZE, Qt::CTRL + Qt::Key_Minus, QObject::tr("Decrease font size", "sql editor")) ) class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContainer { - Q_OBJECT - Q_ENUMS(Action) + Q_OBJECT public: enum Action @@ -78,13 +81,20 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine FIND_NEXT, FIND_PREV, REPLACE, - TOGGLE_COMMENT + TOGGLE_COMMENT, + WORD_WRAP, + INCR_FONT_SIZE, + DECR_FONT_SIZE }; + Q_ENUM(Action) enum ToolBar { }; + static void createStaticActions(); + static void staticInit(); + explicit SqlEditor(QWidget *parent = 0); ~SqlEditor(); @@ -102,9 +112,17 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine void saveSelection(); void restoreSelection(); QToolBar* getToolBar(int toolbar) const; - + void setCurrentQueryHighlighting(bool enabled); bool getVirtualSqlCompleteSemicolon() const; void setVirtualSqlCompleteSemicolon(bool value); + bool getHighlightingSyntax() const; + void setOpenSaveActionsEnabled(bool value); + + static QHash<Action, QAction*> staticActions; + static bool wrapWords; + + bool getAlwaysEnforceErrorsChecking() const; + void setAlwaysEnforceErrorsChecking(bool newAlwaysEnforceErrorsChecking); protected: void setupDefShortcuts(); @@ -116,7 +134,9 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine void mouseMoveEvent(QMouseEvent* e); void mousePressEvent(QMouseEvent* e); void resizeEvent(QResizeEvent *e); - void changeEvent(QEvent*e); + void changeEvent(QEvent* e); + void showEvent(QShowEvent* event); + void dropEvent(QDropEvent* e); private: class LineNumberArea : public QWidget @@ -162,7 +182,6 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine */ void markErrorAt(int start, int end, bool limitedDamage = false); void deletePreviousChars(int length = 1); - void refreshValidObjects(); void checkForSyntaxErrors(); void checkForValidObjects(); void setObjectLinks(bool enabled); @@ -171,8 +190,9 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine void lineNumberAreaPaintEvent(QPaintEvent* event); int lineNumberAreaWidth(); void highlightParenthesis(QList<QTextEdit::ExtraSelection>& selections); + void highlightCurrentQuery(QList<QTextEdit::ExtraSelection>& selections); void highlightCurrentLine(QList<QTextEdit::ExtraSelection>& selections); - void highlightCurrentCursorContext(); + void highlightCurrentCursorContext(bool delayedCall = false); const TextBlockData::Parenthesis* matchParenthesis(QList<const TextBlockData::Parenthesis*> parList, const TextBlockData::Parenthesis* thePar); void markMatchedParenthesis(int pos1, int pos2, QList<QTextEdit::ExtraSelection>& selections); void doBackspace(int repeats = 1); @@ -211,8 +231,7 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine bool deletionKeyPressed = false; LazyTrigger* queryParserTrigger = nullptr; Parser* queryParser = nullptr; - QHash<QString,QStringList> objectsInNamedDb; - QMutex objectsInNamedDbMutex; + StrHash<QStringList> objectsInNamedDb; bool objectLinksEnabled = false; QList<DbObject> validDbObjects; QWidget* lineNumberArea = nullptr; @@ -224,6 +243,11 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine int storedSelectionStart = 0; int storedSelectionEnd = 0; bool richFeaturesEnabled = true; + bool alwaysEnforceErrorsChecking = false; + bool highlightingSyntax = true; + QBrush currentQueryBrush; + QTimer* currentQueryTimer = nullptr; + bool openSaveActionsEnabled = true; /** * @brief virtualSqlExpression @@ -245,12 +269,14 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine bool virtualSqlCompleteSemicolon = false; QString createTriggerTable; QString loadedFile; - QFuture<void> objectsInNamedDbFuture; + QFutureWatcher<QHash<QString,QStringList>>* objectsInNamedDbWatcher = nullptr; + void changeFontSize(int factor); static const int autoCompleterDelay = 300; static const int queryParserDelay = 500; private slots: + void highlightSyntax(); void customContextMenuRequested(const QPoint& pos); void updateUndoAction(bool enabled); void updateRedoAction(bool enabled); @@ -268,7 +294,8 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine void completerLeftPressed(); void completerRightPressed(); void parseContents(); - void scheduleQueryParser(bool force = false); + void scheduleQueryParserForSchemaRefresh(); + void scheduleQueryParser(bool force = false, bool skipCompleter = false); void updateLineNumberAreaWidth(); void updateLineNumberArea(const QRect&rect, int dy); void cursorMoved(); @@ -291,6 +318,16 @@ class GUI_API_EXPORT SqlEditor : public QPlainTextEdit, public ExtActionContaine void changeFont(const QVariant& font); void configModified(); void toggleComment(); + void wordWrappingChanged(const QVariant& value); + void currentCursorContextDelayedHighlight(); + void fontSizeChangeRequested(int delta); + void incrFontSize(); + void decrFontSize(); + void moveCursorTo(int pos); + + public slots: + void colorsConfigChanged(); + void refreshValidObjects(); signals: void errorsChecked(bool haveErrors); |
