feat: carry selection over when switching views
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
cf3ccf376b
commit
5815546983
@ -51,12 +51,18 @@ void InstancesView::storeState()
|
|||||||
|
|
||||||
void InstancesView::switchDisplayMode(InstancesView::DisplayMode mode)
|
void InstancesView::switchDisplayMode(InstancesView::DisplayMode mode)
|
||||||
{
|
{
|
||||||
m_displayMode = mode;
|
const QModelIndex index = currentView()->currentIndex();
|
||||||
|
const QModelIndex sourceIndex = mappedIndex(index);
|
||||||
if (mode == DisplayMode::TableMode) {
|
if (mode == DisplayMode::TableMode) {
|
||||||
|
m_table->selectionModel()->setCurrentIndex(m_tableProxy->mapFromSource(sourceIndex),
|
||||||
|
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
setCurrentWidget(m_table);
|
setCurrentWidget(m_table);
|
||||||
} else {
|
} else {
|
||||||
|
m_grid->selectionModel()->setCurrentIndex(m_gridProxy->mapFromSource(sourceIndex),
|
||||||
|
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
setCurrentWidget(m_grid);
|
setCurrentWidget(m_grid);
|
||||||
}
|
}
|
||||||
|
m_displayMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstancesView::editSelected(InstanceList::Column targetColumn)
|
void InstancesView::editSelected(InstanceList::Column targetColumn)
|
||||||
@ -171,14 +177,6 @@ void InstancesView::activateInstance(const QModelIndex& index)
|
|||||||
|
|
||||||
void InstancesView::currentRowChanged(const QModelIndex& current, const QModelIndex& previous)
|
void InstancesView::currentRowChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
{
|
{
|
||||||
// don't fire event, if row changed in inactive model
|
|
||||||
QSortFilterProxyModel* m = m_tableProxy;
|
|
||||||
if (m_displayMode == GridMode)
|
|
||||||
m = m_gridProxy;
|
|
||||||
|
|
||||||
if (current.model() != m)
|
|
||||||
return;
|
|
||||||
|
|
||||||
InstancePtr inst1, inst2;
|
InstancePtr inst1, inst2;
|
||||||
if (current.isValid()) {
|
if (current.isValid()) {
|
||||||
int row = mappedIndex(current).row();
|
int row = mappedIndex(current).row();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user