mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
refs #757, materialize filtered data
* menu item / flag * functions in view class * some minor formatting
This commit is contained in:
committed by
Roland Winklmeier
parent
c848d7ca61
commit
610dba2028
@@ -41,12 +41,10 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
namespace BlackMisc { namespace Simulation { class CAircraftModel; } }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters { class CAircraftModelFilterDialog; }
|
||||
namespace Menus { class CMenuActions; }
|
||||
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft view
|
||||
|
||||
@@ -257,6 +257,7 @@ namespace BlackGui
|
||||
ma.addAction(CIcons::filter16(), "Remove Filter", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::ps_removeFilter });
|
||||
break;
|
||||
}
|
||||
case MenuMaterializeFilter: { ma.addAction(CIcons::tableRelationship16(), "Materialize filtered data", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::materializeFilter }); break; }
|
||||
case MenuLoad: { ma.addAction(CIcons::disk16(), "Load from file", CMenuAction::pathViewLoadSave(), { this, &CViewBaseNonTemplate::ps_loadJsonAction }); break; }
|
||||
case MenuSave: { ma.addAction(CIcons::disk16(), "Save data in file", CMenuAction::pathViewLoadSave(), { this, &CViewBaseNonTemplate::ps_saveJsonAction }, CShortcut::keySaveViews()); break; }
|
||||
default:
|
||||
@@ -297,6 +298,10 @@ namespace BlackGui
|
||||
if (this->m_menus.testFlag(MenuFilter))
|
||||
{
|
||||
menuActions.addActions(this->initMenuActions(MenuFilter));
|
||||
if (this->m_menus.testFlag(MenuMaterializeFilter))
|
||||
{
|
||||
menuActions.addActions(this->initMenuActions(MenuMaterializeFilter));
|
||||
}
|
||||
}
|
||||
|
||||
// selection menus, not in menu action list because it depends on current selection
|
||||
@@ -967,6 +972,17 @@ namespace BlackGui
|
||||
return this->m_model->clearHighlighting();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::materializeFilter()
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
if (!this->m_model->hasFilter()) { return; }
|
||||
if (this->isEmpty()) { return; }
|
||||
ContainerType filtered(this->m_model->containerFiltered());
|
||||
this->removeFilter();
|
||||
this->updateContainerMaybeAsync(filtered);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::rowCount() const
|
||||
{
|
||||
|
||||
@@ -107,10 +107,11 @@ namespace BlackGui
|
||||
MenuDisplayAutomatically = 1 << 4, //!< allow to switch display automatically
|
||||
MenuDisplayAutomaticallyAndRefresh = MenuDisplayAutomatically | MenuRefresh, //!< should come together
|
||||
MenuFilter = 1 << 5, //!< filter can be opened
|
||||
MenuSave = 1 << 6, //!< save as JSON
|
||||
MenuLoad = 1 << 7, //!< load from JSON
|
||||
MenuToggleSelectionMode = 1 << 8, //!< allow to toggle selection mode
|
||||
MenuOrderable = 1 << 9, //!< items can be ordered (if container is BlackMisc::IOrderableList
|
||||
MenuMaterializeFilter = 1 << 6, //!< materialize filter (filtered data become model data)
|
||||
MenuSave = 1 << 7, //!< save as JSON
|
||||
MenuLoad = 1 << 8, //!< load from JSON
|
||||
MenuToggleSelectionMode = 1 << 9, //!< allow to toggle selection mode
|
||||
MenuOrderable = 1 << 10, //!< items can be ordered (if container is BlackMisc::IOrderableList
|
||||
MenuStandard = MenuClear | MenuRemoveSelectedRows | MenuRefresh | MenuBackend |
|
||||
MenuDisplayAutomatically | MenuFilter | MenuSave | MenuLoad | MenuToggleSelectionMode,
|
||||
MenuLoadAndSave = MenuLoad | MenuSave,
|
||||
@@ -119,8 +120,8 @@ namespace BlackGui
|
||||
MenuDefaultDbViews = MenuToggleSelectionMode | MenuBackend,
|
||||
// special menus, should be in derived classes, but enums cannot be inherited
|
||||
// maybe shifted in the future to elsewhere
|
||||
MenuHighlightStashed = 1 << 10, //!< highlight stashed models
|
||||
MenuCanStashModels = 1 << 11, //!< stash models
|
||||
MenuHighlightStashed = 1 << 11, //!< highlight stashed models
|
||||
MenuCanStashModels = 1 << 12, //!< stash models
|
||||
MenuStashing = MenuHighlightStashed | MenuCanStashModels,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Menu, MenuFlag)
|
||||
@@ -312,6 +313,9 @@ namespace BlackGui
|
||||
//! Clear any highlighted objects
|
||||
virtual void clearHighlighting() = 0;
|
||||
|
||||
//! Materialize filter
|
||||
virtual void materializeFilter() = 0;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CViewBaseNonTemplate(QWidget *parent);
|
||||
@@ -547,6 +551,7 @@ namespace BlackGui
|
||||
virtual int removeSelectedRows() override;
|
||||
virtual void presizeOrFullResizeToContents() override;
|
||||
virtual void clearHighlighting() override;
|
||||
virtual void materializeFilter() override;
|
||||
//! @}
|
||||
|
||||
//! \name BlackGui::Views::CViewBaseNonTemplate implementations
|
||||
|
||||
Reference in New Issue
Block a user