Fix show filename in tab after opening file and make F5 execute shortcut

work.
This commit is contained in:
eelke 2019-12-03 19:08:13 +01:00
parent e53b85bd86
commit 47b3ea83e9
3 changed files with 11 additions and 2 deletions

View file

@ -507,7 +507,7 @@ void DatabaseWindow::on_actionNewSql_triggered()
{ {
auto *ct = new QueryTool(this, this); auto *ct = new QueryTool(this, this);
ct->addAction(actionExecuteQuery); ct->addAction(actionExecuteQuery);
addPage(ct, "query"); addPage(ct, "new");
ct->newdoc(); ct->newdoc();
} }
@ -519,7 +519,8 @@ void DatabaseWindow::on_actionOpenSql_triggered()
if ( ! file_name.isEmpty()) { if ( ! file_name.isEmpty()) {
auto *ct = new QueryTool(this, this); auto *ct = new QueryTool(this, this);
if (ct->load(file_name)) { if (ct->load(file_name)) {
addPage(ct, ""); ct->addAction(actionExecuteQuery);
addPage(ct, ct->title());
} }
else { else {
delete ct; delete ct;

View file

@ -234,6 +234,12 @@ void QueryTool::cancel()
m_dbConnection.cancel(); m_dbConnection.cancel();
} }
QString QueryTool::title() const
{
QFileInfo fileInfo(m_fileName);
QString fn(fileInfo.fileName());
return fn;
}
void QueryTool::setFileName(const QString &filename) void QueryTool::setFileName(const QString &filename)
{ {

View file

@ -53,6 +53,8 @@ public:
bool isNew() const { return m_new; } bool isNew() const { return m_new; }
void focusEditor(); void focusEditor();
QString title() const;
public slots: public slots:
void execute(); void execute();
/// Save the document under its current name, a file save dialog will be shown if this is a new document /// Save the document under its current name, a file save dialog will be shown if this is a new document