Minor mapping tool improvements, including scrollTo first highlighted row

This commit is contained in:
Klaus Basan
2019-04-11 19:27:37 +02:00
parent 8915625357
commit 9436bce9be
4 changed files with 39 additions and 3 deletions

View File

@@ -551,15 +551,15 @@ namespace BlackGui
}
QAction *a = new QAction(CIcons::appDistributors16(), "Apply distributor preferences", this);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::distributorPreferencesChanged);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::distributorPreferencesChanged, Qt::QueuedConnection);
m_setActions.append(a);
a = new QAction(CIcons::delete16(), "Reduce models (remove duplicates)", this);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::reduceModels);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::reduceModels, Qt::QueuedConnection);
m_setActions.append(a);
a = new QAction(CIcons::delete16(), "Remove excluded models", this);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::removeExcludedModels);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::removeExcludedModels, Qt::QueuedConnection);
m_setActions.append(a);
}
menuActions.addMenuModelSet();

View File

@@ -182,6 +182,10 @@ namespace BlackGui
this->setHighlight(true);
this->setHighlightColor(Qt::red);
this->setHighlightModels(invaliddModels);
const int r = this->rowOf(invaliddModels.front());
const QModelIndex i = m_model->index(r, 0);
this->scrollTo(i);
}
}

View File

@@ -218,6 +218,32 @@ namespace BlackGui
return m_model->container();
}
template<class T>
QList<int> CViewBase<T>::rowsOf(const ContainerType &container) const
{
QList<int> rows;
for (const ObjectType &o : container)
{
const int i = this->rowOf(o);
if (i >= 0) { rows.push_back(i); }
}
return rows;
}
template<class T>
int CViewBase<T>::rowOf(const ObjectType &obj) const
{
//! \fixme KB 4-19 any smarter solution?
const ContainerType objects = m_model->containerOrFilteredContainer();
int i = 0;
for (const ObjectType &o : objects)
{
if (o == obj) { return i; }
++i;
}
return -1;
}
template <class T>
const typename CViewBase<T>::ContainerType &CViewBase<T>::containerOrFilteredContainer(bool *filtered) const
{

View File

@@ -660,6 +660,12 @@ namespace BlackGui
//! Access to container
const ContainerType &container() const;
//! The rows of the given objects
QList<int> rowsOf(const ContainerType &container) const;
//! The row of the given object
int rowOf(const ObjectType &obj) const;
//! \copydoc BlackGui::Models::CListModelBase::containerOrFilteredContainer
const ContainerType &containerOrFilteredContainer(bool *filtered = nullptr) const;