mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-10 05:38:32 -06:00
Fix bug which made tables from other schemas inaccessible in Browse Data
Fix a bug which made tables from other schemas than the main schema inaccessible in the Browse Data tab. Most notably this always selects table "main"."tbl" instead of for example "temp"."tbl". See issue #2348.
This commit is contained in:
@@ -144,7 +144,7 @@ void MainWindow::init()
|
||||
// Set up DB structure tab
|
||||
dbStructureModel = new DbStructureModel(db, this);
|
||||
connect(&db, &DBBrowserDB::structureUpdated, this, [this]() {
|
||||
QString old_table = QString::fromStdString(ui->tableBrowser->currentlyBrowsedTableName().name());
|
||||
sqlb::ObjectIdentifier old_table = ui->tableBrowser->currentlyBrowsedTableName();
|
||||
dbStructureModel->reloadData();
|
||||
populateStructure(old_table);
|
||||
});
|
||||
@@ -612,7 +612,7 @@ void MainWindow::fileNewInMemoryDatabase()
|
||||
createTable();
|
||||
}
|
||||
|
||||
void MainWindow::populateStructure(const QString& old_table)
|
||||
void MainWindow::populateStructure(const sqlb::ObjectIdentifier& old_table)
|
||||
{
|
||||
// Refresh the structure tab
|
||||
ui->dbTreeWidget->setRootIndex(dbStructureModel->index(1, 0)); // Show the 'All' part of the db structure
|
||||
|
||||
@@ -128,7 +128,7 @@ public slots:
|
||||
void dbState(bool dirty);
|
||||
void refresh();
|
||||
void switchToBrowseDataTab(sqlb::ObjectIdentifier tableToBrowse = sqlb::ObjectIdentifier());
|
||||
void populateStructure(const QString& old_table = QString());
|
||||
void populateStructure(const sqlb::ObjectIdentifier& old_table = sqlb::ObjectIdentifier{});
|
||||
void reloadSettings();
|
||||
bool closeFiles();
|
||||
|
||||
|
||||
@@ -359,9 +359,9 @@ void TableBrowser::reset()
|
||||
|
||||
sqlb::ObjectIdentifier TableBrowser::currentlyBrowsedTableName() const
|
||||
{
|
||||
return sqlb::ObjectIdentifier(ui->comboBrowseTable->model()->data(dbStructureModel->index(ui->comboBrowseTable->currentIndex(),
|
||||
DbStructureModel::ColumnSchema,
|
||||
ui->comboBrowseTable->rootModelIndex())).toString().toStdString(),
|
||||
return sqlb::ObjectIdentifier(dbStructureModel->index(ui->comboBrowseTable->currentIndex(),
|
||||
DbStructureModel::ColumnSchema,
|
||||
ui->comboBrowseTable->rootModelIndex()).data().toString().toStdString(),
|
||||
ui->comboBrowseTable->currentData(Qt::EditRole).toString().toStdString()); // Use the edit role here to make sure we actually get the
|
||||
// table name without the schema bit in front of it.
|
||||
}
|
||||
@@ -376,13 +376,13 @@ void TableBrowser::setSettings(const sqlb::ObjectIdentifier& table, const Browse
|
||||
m_settings[table] = table_settings;
|
||||
}
|
||||
|
||||
void TableBrowser::setStructure(QAbstractItemModel* model, const QString& old_table)
|
||||
void TableBrowser::setStructure(QAbstractItemModel* model, const sqlb::ObjectIdentifier& old_table)
|
||||
{
|
||||
dbStructureModel = model;
|
||||
ui->comboBrowseTable->setModel(model);
|
||||
|
||||
ui->comboBrowseTable->setRootModelIndex(dbStructureModel->index(0, 0)); // Show the 'browsable' section of the db structure tree
|
||||
int old_table_index = ui->comboBrowseTable->findText(old_table);
|
||||
int old_table_index = ui->comboBrowseTable->findText(QString::fromStdString(old_table.toDisplayString()));
|
||||
if(old_table_index == -1 && ui->comboBrowseTable->count()) // If the old table couldn't be found anymore but there is another table, select that
|
||||
ui->comboBrowseTable->setCurrentIndex(0);
|
||||
else if(old_table_index == -1) // If there aren't any tables to be selected anymore, clear the table view
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
BrowseDataTableSettings& settings(const sqlb::ObjectIdentifier& object);
|
||||
void setSettings(const sqlb::ObjectIdentifier& table, const BrowseDataTableSettings& table_settings);
|
||||
|
||||
void setStructure(QAbstractItemModel* model, const QString& old_table = QString());
|
||||
void setStructure(QAbstractItemModel* model, const sqlb::ObjectIdentifier& old_table = sqlb::ObjectIdentifier{});
|
||||
|
||||
SqliteTableModel* model() { return m_model; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user