diff --git a/pglab/DatabaseWindow.cpp b/pglab/DatabaseWindow.cpp index 92ae164..88dc5a7 100644 --- a/pglab/DatabaseWindow.cpp +++ b/pglab/DatabaseWindow.cpp @@ -507,7 +507,7 @@ void DatabaseWindow::on_actionNewSql_triggered() { auto *ct = new QueryTool(this, this); ct->addAction(actionExecuteQuery); - addPage(ct, "query"); + addPage(ct, "new"); ct->newdoc(); } @@ -519,7 +519,8 @@ void DatabaseWindow::on_actionOpenSql_triggered() if ( ! file_name.isEmpty()) { auto *ct = new QueryTool(this, this); if (ct->load(file_name)) { - addPage(ct, ""); + ct->addAction(actionExecuteQuery); + addPage(ct, ct->title()); } else { delete ct; diff --git a/pglab/QueryTool.cpp b/pglab/QueryTool.cpp index 75eab46..a952a1b 100644 --- a/pglab/QueryTool.cpp +++ b/pglab/QueryTool.cpp @@ -234,6 +234,12 @@ void QueryTool::cancel() m_dbConnection.cancel(); } +QString QueryTool::title() const +{ + QFileInfo fileInfo(m_fileName); + QString fn(fileInfo.fileName()); + return fn; +} void QueryTool::setFileName(const QString &filename) { diff --git a/pglab/QueryTool.h b/pglab/QueryTool.h index 1e836a4..9d23315 100644 --- a/pglab/QueryTool.h +++ b/pglab/QueryTool.h @@ -53,6 +53,8 @@ public: bool isNew() const { return m_new; } void focusEditor(); + QString title() const; + public slots: void execute(); /// Save the document under its current name, a file save dialog will be shown if this is a new document