mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-21 03:21:43 -06:00
Allow clicking cells with foreign key in order to jump to referenced cell
Add a tooltip to the database browser when you hover a cell with a foreign key set in order to show the referenced table and column. When clicking on such a cell while holding the Ctrl and Shift key (only one of them won't work because they are for multiselection and Alt doesn't do the trick on my system because it's just for grabbing and moving the window) try to jump to the table and row which is referenced in the clicked cell. See issue #192.
This commit is contained in:
@@ -265,11 +265,26 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
|
||||
if(m_data.at(index.row()).at(index.column()).isNull())
|
||||
return QColor(PreferencesDialog::getSettingsValue("databrowser", "null_bg_colour").toString());
|
||||
return QVariant();
|
||||
} else if(role == Qt::ToolTipRole) {
|
||||
sqlb::ForeignKeyClause fk = getForeignKeyClause(index.column()-1);
|
||||
if(fk.isSet())
|
||||
return tr("References %1(%2)\nHold Ctrl+Shift and click to jump there").arg(fk.table()).arg(fk.columns().join(','));
|
||||
else
|
||||
return QString();
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
sqlb::ForeignKeyClause SqliteTableModel::getForeignKeyClause(int column) const
|
||||
{
|
||||
DBBrowserObject obj = m_db->getObjectByName(m_sTable);
|
||||
if(obj.getname().size())
|
||||
return obj.table.fields().at(column)->foreignKey();
|
||||
else
|
||||
return sqlb::ForeignKeyClause();
|
||||
}
|
||||
|
||||
bool SqliteTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if(index.isValid() && role == Qt::EditRole)
|
||||
|
||||
Reference in New Issue
Block a user