1 #ifndef SQLEXECUTIONAREA_H 2 #define SQLEXECUTIONAREA_H 3 4 #include <QWidget> 5 #include <QFileSystemWatcher> 6 7 class SqlTextEdit; 8 class SqliteTableModel; 9 class DBBrowserDB; 10 class ExtendedTableWidget; 11 12 class QTextEdit; 13 14 namespace Ui { 15 class SqlExecutionArea; 16 } 17 18 class SqlExecutionArea : public QWidget 19 { 20 Q_OBJECT 21 22 public: 23 explicit SqlExecutionArea(DBBrowserDB& _db, QWidget* parent = nullptr); 24 ~SqlExecutionArea() override; 25 26 QString getSql() const; 27 QString getSelectedSql() const; 28 void setSql(const QString& sql); 29 30 void openFile(const QString& filename); 31 void saveFile(const QString& filename); 32 fileName()33 QString fileName() const { return sqlFileName; } setFileName(const QString & filename)34 void setFileName(const QString& filename) { sqlFileName = filename; } 35 getModel()36 SqliteTableModel* getModel() { return model; } 37 SqlTextEdit* getEditor(); 38 ExtendedTableWidget *getTableResult(); 39 QTextEdit* getStatusEdit(); 40 inErrorState()41 bool inErrorState() const { return error_state; } 42 43 // Save window state to settings 44 static void saveState(); 45 46 public slots: 47 void finishExecution(const QString& result, const bool ok); 48 void saveAsCsv(); 49 void reloadSettings(); 50 void fetchedData(); 51 void setFindFrameVisibility(bool show); 52 53 private slots: 54 void findPrevious(); 55 void findNext(); 56 void findLineEdit_textChanged(const QString& text); 57 void hideFindFrame(); 58 59 void fileChanged(const QString& filename); 60 61 signals: 62 void findFrameVisibilityChanged(bool visible); 63 64 private: 65 void find(QString expr, bool forward); 66 DBBrowserDB& db; 67 SqliteTableModel* model; 68 QString sqlFileName; 69 QFileSystemWatcher fileSystemWatch; 70 Ui::SqlExecutionArea* ui; 71 bool m_columnsResized; // This is set to true if the columns of the table view were already adjusted to fit their contents 72 bool showErrorIndicators; 73 bool error_state; 74 }; 75 76 #endif 77