mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 19:35:33 +08:00
refs #377 usability improvements
* allow to toggle between single, multi and extended selection * all DB data can be read by menu * fixed load/save (test data) from disk
This commit is contained in:
@@ -82,8 +82,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CDataInfoAreaComponent::writeDbDataToResourceDir() const
|
bool CDataInfoAreaComponent::writeDbDataToResourceDir() const
|
||||||
{
|
{
|
||||||
bool s = hasProvider() &&
|
if (!this->hasProvider() || !this->canConnectSwiftDb())
|
||||||
this->writeDbDataToDisk(CProject::getSwiftStaticDbFilesDir());
|
{
|
||||||
|
CLogMessage(this).warning("No connection to DB yet, no new data loaded which can be written");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write to disk
|
||||||
|
bool s = this->writeDbDataToDisk(CProject::getSwiftStaticDbFilesDir());
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Written DB data");
|
CLogMessage(this).info("Written DB data");
|
||||||
@@ -103,7 +109,7 @@ namespace BlackGui
|
|||||||
// info
|
// info
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Read DB data: %1") << CProject::getSwiftStaticDbFilesDir();
|
CLogMessage(this).info("Read DB data from directory: %1") << CProject::getSwiftStaticDbFilesDir();
|
||||||
this->ui->comp_DbAircraftIcao->showLoadIndicator();
|
this->ui->comp_DbAircraftIcao->showLoadIndicator();
|
||||||
this->ui->comp_DbAirlineIcao->showLoadIndicator();
|
this->ui->comp_DbAirlineIcao->showLoadIndicator();
|
||||||
this->ui->comp_DbCountries->showLoadIndicator();
|
this->ui->comp_DbCountries->showLoadIndicator();
|
||||||
@@ -155,6 +161,11 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDataInfoAreaComponent::requestUpdateOfAllDbData()
|
||||||
|
{
|
||||||
|
this->triggerRead(CEntityFlags::AllDbEntities, QDateTime());
|
||||||
|
}
|
||||||
|
|
||||||
void CDataInfoAreaComponent::requestUpdatedData(CEntityFlags::Entity entity)
|
void CDataInfoAreaComponent::requestUpdatedData(CEntityFlags::Entity entity)
|
||||||
{
|
{
|
||||||
bool requested = false;
|
bool requested = false;
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ namespace BlackGui
|
|||||||
//! Load from resource dir
|
//! Load from resource dir
|
||||||
bool readDbDataFromResourceDir();
|
bool readDbDataFromResourceDir();
|
||||||
|
|
||||||
|
//! Request update of all DB data
|
||||||
|
void requestUpdateOfAllDbData();
|
||||||
|
|
||||||
//! Load new data (based on timestamp, incremental)
|
//! Load new data (based on timestamp, incremental)
|
||||||
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entity);
|
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entity);
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingSimulatorModelMenu(this));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingSimulatorModelMenu(this));
|
||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CRemoveDbModelsMenu(this));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CModelStashTools(this));
|
||||||
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->m_cachedOwnModels.get());
|
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->m_cachedOwnModels.get());
|
||||||
|
|
||||||
// how to display forms
|
// how to display forms
|
||||||
@@ -94,7 +94,7 @@ namespace BlackGui
|
|||||||
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||||
|
|
||||||
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true));
|
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true));
|
||||||
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CRemoveDbModelsMenu(this));
|
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CModelStashTools(this));
|
||||||
this->ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true);
|
this->ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true);
|
||||||
this->ui->tvp_AircraftModelsForVPilot->addFilterDialog();
|
this->ui->tvp_AircraftModelsForVPilot->addFilterDialog();
|
||||||
const CAircraftModelList cachedModels(m_cachedVPilotModels.get());
|
const CAircraftModelList cachedModels(m_cachedVPilotModels.get());
|
||||||
@@ -165,6 +165,7 @@ namespace BlackGui
|
|||||||
void CDbMappingComponent::setProvider(BlackMisc::Network::IWebDataServicesProvider *provider)
|
void CDbMappingComponent::setProvider(BlackMisc::Network::IWebDataServicesProvider *provider)
|
||||||
{
|
{
|
||||||
CWebDataServicesAware::setProvider(provider);
|
CWebDataServicesAware::setProvider(provider);
|
||||||
|
this->m_autostashDialog->setProvider(provider);
|
||||||
this->ui->editor_Livery->setProvider(provider);
|
this->ui->editor_Livery->setProvider(provider);
|
||||||
this->ui->editor_Distributor->setProvider(provider);
|
this->ui->editor_Distributor->setProvider(provider);
|
||||||
this->ui->editor_AircraftIcao->setProvider(provider);
|
this->ui->editor_AircraftIcao->setProvider(provider);
|
||||||
@@ -309,6 +310,11 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::ps_displayAutoStashingDialog()
|
||||||
|
{
|
||||||
|
this->m_autostashDialog->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::ps_removeDbModelsFromView()
|
void CDbMappingComponent::ps_removeDbModelsFromView()
|
||||||
{
|
{
|
||||||
QStringList modelStrings(this->getModelStrings());
|
QStringList modelStrings(this->getModelStrings());
|
||||||
@@ -447,7 +453,7 @@ namespace BlackGui
|
|||||||
if (!sims.isEmpty()) { o = o.append(" ").append(sims); }
|
if (!sims.isEmpty()) { o = o.append(" ").append(sims); }
|
||||||
}
|
}
|
||||||
QString f = this->ui->tvp_OwnAircraftModels->derivedModel()->hasFilter() ? "F" : "";
|
QString f = this->ui->tvp_OwnAircraftModels->derivedModel()->hasFilter() ? "F" : "";
|
||||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->tvp_AircraftModelsForVPilot->rowCount()) + f;
|
o = CGuiUtility::replaceTabCountValue(o, this->ui->tvp_OwnAircraftModels->rowCount()) + f;
|
||||||
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
|
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,26 +634,34 @@ namespace BlackGui
|
|||||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::CRemoveDbModelsMenu::customMenu(QMenu &menu) const
|
void CDbMappingComponent::CModelStashTools::customMenu(QMenu &menu) const
|
||||||
{
|
{
|
||||||
CDbMappingComponent *mapComp = mappingComponent();
|
CDbMappingComponent *mapComp = mappingComponent();
|
||||||
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
|
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
|
||||||
int dbModels = mapComp->getModelsCount();
|
bool canConnectDb = mapComp->canConnectSwiftDb();
|
||||||
if (dbModels > 0)
|
|
||||||
|
if (canConnectDb)
|
||||||
{
|
{
|
||||||
if (!mapComp->currentModelView()->isEmpty())
|
if (!mapComp->currentModelView()->isEmpty())
|
||||||
{
|
{
|
||||||
this->addSeparator(menu);
|
this->addSeparator(menu);
|
||||||
|
int dbModels = mapComp->getModelsCount();
|
||||||
|
if (dbModels > 0)
|
||||||
|
{
|
||||||
|
// we have keys and data where we could delete them from
|
||||||
|
const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from " + mapComp->currentTabText());
|
||||||
|
menu.addAction(CIcons::delete16(), msgDelete, mapComp, SLOT(ps_removeDbModelsFromView()));
|
||||||
|
}
|
||||||
|
|
||||||
// we have keys and data where we could delete them from
|
// we have keys and data where we could delete them from
|
||||||
QString m("Delete " + QString::number(dbModels) + " DB model(s) from " + mapComp->currentTabText());
|
const QString msgAutoStash("Auto stashing");
|
||||||
menu.addAction(CIcons::delete16(), m, mapComp, SLOT(ps_removeDbModelsFromView()));
|
menu.addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, SLOT(ps_displayAutoStashingDialog()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->nestedCustomMenu(menu);
|
this->nestedCustomMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbMappingComponent *CDbMappingComponent::CRemoveDbModelsMenu::mappingComponent() const
|
CDbMappingComponent *CDbMappingComponent::CModelStashTools::mappingComponent() const
|
||||||
{
|
{
|
||||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "blackgui/menudelegate.h"
|
#include "blackgui/menudelegate.h"
|
||||||
#include "blackgui/enableforviewbasedindicator.h"
|
#include "blackgui/enableforviewbasedindicator.h"
|
||||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||||
|
#include "blackgui/components/dbautostashingcomponent.h"
|
||||||
#include "blackgui/views/aircraftmodelview.h"
|
#include "blackgui/views/aircraftmodelview.h"
|
||||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||||
@@ -175,11 +176,15 @@ namespace BlackGui
|
|||||||
//! Stash current model
|
//! Stash current model
|
||||||
void ps_stashCurrentModel();
|
void ps_stashCurrentModel();
|
||||||
|
|
||||||
|
//! Display auto stashing dialog
|
||||||
|
void ps_displayAutoStashingDialog();
|
||||||
|
|
||||||
//! Remove DB models from current view
|
//! Remove DB models from current view
|
||||||
void ps_removeDbModelsFromView();
|
void ps_removeDbModelsFromView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||||
|
QScopedArrayPointer<CDbAutoStashingComponent> m_autostashDialog { new CDbAutoStashingComponent(this) };
|
||||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||||
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
||||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||||
@@ -240,13 +245,15 @@ namespace BlackGui
|
|||||||
CDbMappingComponent *mappingComponent() const;
|
CDbMappingComponent *mappingComponent() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Menu for removing DB models from current view
|
//! Menu for tools:
|
||||||
|
//! 1) removing DB models from current view and
|
||||||
|
//! 2) for auto stashing
|
||||||
//! \note This is a specific menu for that very component
|
//! \note This is a specific menu for that very component
|
||||||
class CRemoveDbModelsMenu : public BlackGui::IMenuDelegate
|
class CModelStashTools : public BlackGui::IMenuDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CRemoveDbModelsMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
CModelStashTools(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -207,11 +207,15 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (sm == SingleSelection)
|
if (sm == SingleSelection)
|
||||||
{
|
{
|
||||||
menu.addAction(QIcon(), "Switch to multi selection", this, SLOT(ps_toggleSelectionMode()));
|
QAction *a = menu.addAction(QIcon(), "Switch to multi selection", this, SLOT(ps_toggleSelectionMode()));
|
||||||
|
a->setData("multi");
|
||||||
|
a = menu.addAction(QIcon(), "Switch to extended selection", this, SLOT(ps_toggleSelectionMode()));
|
||||||
|
a->setData("extended");
|
||||||
}
|
}
|
||||||
else if (sm == MultiSelection || sm == ExtendedSelection)
|
else if (sm == MultiSelection || sm == ExtendedSelection)
|
||||||
{
|
{
|
||||||
menu.addAction(QIcon(), "Switch to single selection", this, SLOT(ps_toggleSelectionMode()));
|
QAction *a = menu.addAction(QIcon(), "Switch to single selection", this, SLOT(ps_toggleSelectionMode()));
|
||||||
|
a->setData("single");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sm != NoSelection)
|
if (sm != NoSelection)
|
||||||
@@ -532,10 +536,30 @@ namespace BlackGui
|
|||||||
if (this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection)
|
if (this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection)
|
||||||
{
|
{
|
||||||
if (this->selectionMode() == SingleSelection)
|
if (this->selectionMode() == SingleSelection)
|
||||||
|
{
|
||||||
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
if (action && action->data().canConvert<QString>())
|
||||||
|
{
|
||||||
|
QString data(action->data().toString().toLower());
|
||||||
|
if (data.startsWith('e'))
|
||||||
|
{
|
||||||
|
this->setSelectionMode(ExtendedSelection);
|
||||||
|
}
|
||||||
|
else if (data.startsWith('m'))
|
||||||
|
{
|
||||||
|
this->setSelectionMode(MultiSelection);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
this->setSelectionMode(this->m_originalSelectionMode);
|
this->setSelectionMode(this->m_originalSelectionMode);
|
||||||
}
|
}
|
||||||
else if (this->selectionMode() == MultiSelection)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->setSelectionMode(this->m_originalSelectionMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this->selectionMode() == MultiSelection || this->selectionMode() == ExtendedSelection)
|
||||||
{
|
{
|
||||||
this->setSelectionMode(SingleSelection);
|
this->setSelectionMode(SingleSelection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace BlackMisc
|
|||||||
AllIcaoEntities = AircraftIcaoEntity | AirlineIcaoEntity, ///< all ICAO codes
|
AllIcaoEntities = AircraftIcaoEntity | AirlineIcaoEntity, ///< all ICAO codes
|
||||||
AllIcaoAndCountries = AircraftIcaoEntity | AirlineIcaoEntity | CountryEntity, ///< all ICAO codes and countries
|
AllIcaoAndCountries = AircraftIcaoEntity | AirlineIcaoEntity | CountryEntity, ///< all ICAO codes and countries
|
||||||
DistributorLiveryModel = DistributorEntity | LiveryEntity | ModelEntity, ///< Combinded
|
DistributorLiveryModel = DistributorEntity | LiveryEntity | ModelEntity, ///< Combinded
|
||||||
|
AllDbEntities = AllIcaoEntities | DistributorLiveryModel, ///< All DB stuff
|
||||||
AllEntities = 0xFFFF ///< everything
|
AllEntities = 0xFFFF ///< everything
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Entity, EntityFlag)
|
Q_DECLARE_FLAGS(Entity, EntityFlag)
|
||||||
|
|||||||
@@ -156,10 +156,11 @@ void CSwiftData::initDynamicMenus()
|
|||||||
{
|
{
|
||||||
Q_ASSERT_X(this->ui->comp_MainInfoArea, Q_FUNC_INFO, "Missing main info area");
|
Q_ASSERT_X(this->ui->comp_MainInfoArea, Q_FUNC_INFO, "Missing main info area");
|
||||||
Q_ASSERT_X(this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), Q_FUNC_INFO, "Missing DB info area");
|
Q_ASSERT_X(this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), Q_FUNC_INFO, "Missing DB info area");
|
||||||
this->ui->menu_Mapping->addAction(CIcons::load16(), "Load DB data", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(readDbDataFromResourceDir()));
|
this->ui->menu_Mapping->addAction(CIcons::database16(), "Load all DB data", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(requestUpdateOfAllDbData()));
|
||||||
if (CProject::isRunningInDeveloperEnvironment() && this->m_webDataReader && this->m_webDataReader->canConnectSwiftDb())
|
this->ui->menu_Mapping->addAction(CIcons::load16(), "Load DB test data from disk", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(readDbDataFromResourceDir()));
|
||||||
|
if (CProject::isRunningInDeveloperEnvironment())
|
||||||
{
|
{
|
||||||
this->ui->menu_Mapping->addAction(CIcons::save16(), "Save DB data", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(writeDbDataToResourceDir()));
|
this->ui->menu_Mapping->addAction(CIcons::save16(), "Save DB test data to disk", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(writeDbDataToResourceDir()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user