refs #568, allow to stash from DB data view (model view)

* added required signal slots
* moved models for stashing into aircraft model view
* allow to unselect when stashed
* fixed DB object highlighting and resize row height automatically
This commit is contained in:
Klaus Basan
2016-01-09 03:37:07 +01:00
parent 0326356f43
commit 11ee49a382
12 changed files with 209 additions and 106 deletions

View File

@@ -70,21 +70,35 @@ namespace BlackGui
return delta;
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
int CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::replaceOrAddObjectsByKey(const ContainerType &container)
{
if (container.isEmpty()) { return 0; }
ContainerType copy(this->container());
int c = copy.replaceOrAddObjectsByKey(container);
if (c == 0) { return 0; }
this->updateContainerMaybeAsync(copy);
return c;
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::customMenu(QMenu &menu) const
{
CViewBase<ModelClass, ContainerType, ObjectType>::customMenu(menu);
if (this->m_menus.testFlag(CViewBase<ModelClass, ContainerType, ObjectType>::MenuHighlightDbData))
{
menu.addSeparator();
QAction *a = menu.addAction(CIcons::database16(), "Highlight DB data", this, SLOT(ps_toggleDbData()));
if (!menu.isEmpty())
{
menu.addSeparator();
}
QAction *a = menu.addAction(CIcons::database16(), "Highlight DB data", this, SLOT(ps_toggleHighlightDbData()));
a->setCheckable(true);
a->setChecked(this->derivedModel()->highlightDbData());
}
}
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_toggleDbData()
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_toggleHighlightDbData()
{
bool h = this->derivedModel()->highlightDbData();
this->derivedModel()->setHighlightDbData(!h);