Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,27 +1952,30 @@ void MainWindow::changeSqlTab(int index)

void MainWindow::openSqlFile()
{
QString file = FileDialog::getOpenFileName(
QStringList wfiles = FileDialog::getOpenFileNames(
OpenSQLFile,
this,
tr("Select SQL file to open"),
tr("Text files(*.sql *.txt);;All files(*)"));

if(QFile::exists(file))
for(QString file: wfiles)
{
// Decide whether to open a new tab or take the current one
int index;
SqlExecutionArea* current_tab = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
if(current_tab && current_tab->getSql().isEmpty() && current_tab->getModel()->rowCount() == 0)
index = ui->tabSqlAreas->currentIndex();
else
index = openSqlTab();

SqlExecutionArea* sqlarea = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(index));
sqlarea->openFile(file);

QFileInfo fileinfo(file);
ui->tabSqlAreas->setTabText(index, fileinfo.fileName());
if(QFile::exists(file))
{
// Decide whether to open a new tab or take the current one
int index;
SqlExecutionArea* current_tab = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
if(current_tab && current_tab->getSql().isEmpty() && current_tab->getModel()->rowCount() == 0)
index = ui->tabSqlAreas->currentIndex();
else
index = openSqlTab();

SqlExecutionArea* sqlarea = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(index));
sqlarea->openFile(file);

QFileInfo fileinfo(file);
ui->tabSqlAreas->setTabText(index, fileinfo.fileName());
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ You can drag SQL statements from an object row and drop them into other applicat
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>526</height>
<width>692</width>
<height>489</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
Expand Down Expand Up @@ -721,15 +721,15 @@ You can drag SQL statements from an object row and drop them into other applicat
</item>
<item>
<widget class="QTabWidget" name="tabSqlAreas">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="movable">
<bool>true</bool>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
Expand All @@ -744,7 +744,7 @@ You can drag SQL statements from an object row and drop them into other applicat
<x>0</x>
<y>0</y>
<width>1037</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="fileMenu">
Expand Down Expand Up @@ -1503,10 +1503,10 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
<normaloff>:/icons/document_open</normaloff>:/icons/document_open</iconset>
</property>
<property name="text">
<string>Open SQL file</string>
<string>Open SQL file(s)</string>
</property>
<property name="whatsThis">
<string>This button opens a file containing SQL statements and loads it in a new editor tab</string>
<string>This button opens files containing SQL statements and loads them in new editor tabs</string>
</property>
</action>
<action name="actionSqlSaveFile">
Expand Down