mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
MainWindow: Don't open new SQL tab when the current one is empty
When opening an SQL file don't open a new tab for it when the current one is completely empty and could be used just as well.
This commit is contained in:
@@ -1145,7 +1145,15 @@ void MainWindow::openSqlFile()
|
||||
{
|
||||
QFile f(file);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
unsigned int index = openSqlTab();
|
||||
|
||||
// Decide wether to open a new tab or take the current one
|
||||
unsigned int index;
|
||||
SqlExecutionArea* current_tab = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
|
||||
if(current_tab->getSql().isEmpty() && current_tab->getModel()->rowCount() == 0)
|
||||
index = ui->tabSqlAreas->currentIndex();
|
||||
else
|
||||
index = openSqlTab();
|
||||
|
||||
qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(index))->getEditor()->setPlainText(f.readAll());
|
||||
QFileInfo fileinfo(file);
|
||||
ui->tabSqlAreas->setTabText(index, fileinfo.fileName());
|
||||
|
||||
Reference in New Issue
Block a user