mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 10:20:17 -06:00
Clear the tree widget in the Structure tab when after closing a DB
Clear the tree widget in the 'Database Structure' tab of the main window after closing a database. See issue #44.
This commit is contained in:
@@ -125,6 +125,13 @@ void DbStructureModel::reloadData(DBBrowserDB* db)
|
||||
rootItem->removeChild(rootItem->child(0));
|
||||
}
|
||||
|
||||
// Return here if no DB is opened
|
||||
if(!db->isOpen())
|
||||
{
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the nodes for tables, indices, views and triggers
|
||||
QMap<QString, QTreeWidgetItem*> typeToParentItem;
|
||||
QTreeWidgetItem* itemTables = new QTreeWidgetItem(rootItem);
|
||||
|
||||
@@ -220,10 +220,15 @@ void MainWindow::populateStructure()
|
||||
{
|
||||
completerModelTables.clear();
|
||||
clearCompleterModelsFields();
|
||||
|
||||
// Refresh the structure tab
|
||||
db.updateSchema();
|
||||
dbStructureModel->reloadData(&db);
|
||||
ui->dbTreeWidget->expandToDepth(0);
|
||||
|
||||
if(!db.isOpen())
|
||||
return;
|
||||
|
||||
db.updateSchema();
|
||||
QStringList tblnames = db.getBrowsableObjectNames();
|
||||
sqliteHighlighterLogUser->setTableNames(tblnames);
|
||||
sqliteHighlighterLogApp->setTableNames(tblnames);
|
||||
@@ -267,10 +272,6 @@ void MainWindow::populateStructure()
|
||||
sqlarea->getEditor()->setDefaultCompleterModel(&completerModelTables);
|
||||
sqlarea->getEditor()->insertFieldCompleterModels(completerModelsFields);
|
||||
}
|
||||
|
||||
// Refresh the structure tab
|
||||
dbStructureModel->reloadData(&db);
|
||||
ui->dbTreeWidget->expandToDepth(0);
|
||||
}
|
||||
|
||||
void MainWindow::populateTable( const QString & tablename)
|
||||
|
||||
@@ -757,10 +757,14 @@ void DBBrowserDB::updateSchema( )
|
||||
sqlite3_stmt *vm;
|
||||
const char *tail;
|
||||
int err=0;
|
||||
lastErrorMessage = QObject::tr("no error");
|
||||
|
||||
objMap.clear();
|
||||
|
||||
lastErrorMessage = QObject::tr("no error");
|
||||
// Exit here is no DB is opened
|
||||
if(!isOpen())
|
||||
return;
|
||||
|
||||
QString statement = "SELECT type, name, sql, tbl_name FROM sqlite_master;";
|
||||
|
||||
QByteArray utf8Statement = statement.toUtf8();
|
||||
|
||||
Reference in New Issue
Block a user