refs #768, allow reselection of values when a view is sorted

* reselect callbacks
* remark: Only working in some cases as sorting is part of the model, while selection is part of the view (and sorting can take place without the view knowing the model is sorted)
* allow to sort by property index
* renamed to m_sortColumn
This commit is contained in:
Klaus Basan
2016-10-17 02:49:54 +02:00
parent 93f0e6582b
commit 630fecf8e8
8 changed files with 145 additions and 36 deletions

View File

@@ -47,7 +47,14 @@ namespace BlackGui
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectDbKeys(const QList<KeyType> &keys)
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectDbKey(const KeyType &key)
{
const QSet<KeyType> set({key});
this->selectDbKeys(set);
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectDbKeys(const QSet<KeyType> &keys)
{
if (keys.isEmpty()) { return; }
this->clearSelection();
@@ -64,7 +71,15 @@ namespace BlackGui
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
int CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::removeDbKeys(const QList<KeyType> &keys)
QSet<KeyType> CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectedDbKeys() const
{
if (!this->hasSelection()) { return QSet<KeyType>(); }
const ContainerType selected(this->selectedObjects());
return selected.toDbKeySet();
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
int CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::removeDbKeys(const QSet<KeyType> &keys)
{
if (keys.isEmpty()) { return 0; }
if (this->isEmpty()) { return 0; }
@@ -148,6 +163,15 @@ namespace BlackGui
CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::customMenu(menuActions);
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::reselect(const ContainerType &selectedObjects)
{
if (!selectedObjects.isEmpty())
{
this->selectDbKeys(selectedObjects.toDbKeySet());
}
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::moveSelectedItems(int order)
{