mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
Minor mapping tool improvements, including scrollTo first highlighted row
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user