mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T362, mapping component added workbench component
- adjusted UI - singe function to get view per tab - used setTabWidgetViewText
This commit is contained in:
@@ -96,6 +96,10 @@ namespace BlackGui
|
||||
ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this));
|
||||
ui->comp_StashAircraft->view()->setCustomMenu(new CStashToolsMenu(this));
|
||||
|
||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this));
|
||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this));
|
||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this));
|
||||
|
||||
// connects
|
||||
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::stashCurrentModel);
|
||||
|
||||
@@ -104,6 +108,11 @@ namespace BlackGui
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
|
||||
|
||||
connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::onModelRowSelected);
|
||||
connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::modelDataChangedDigest, this, &CDbMappingComponent::onWorkbenchDataChanged, Qt::QueuedConnection);
|
||||
connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
||||
connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
|
||||
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::modelDataChangedDigest, this, &CDbMappingComponent::onStashedModelsDataChangedDigest);
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::onModelRowSelected);
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::requestHandlingOfStashDrop, this, &CDbMappingComponent::handleStashDropRequest);
|
||||
@@ -129,6 +138,7 @@ namespace BlackGui
|
||||
ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
|
||||
ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
|
||||
ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModelSet, CIcons::appModels16());
|
||||
ui->tw_ModelsToBeMapped->setTabIcon(TabWorkbench, CIcons::wrench16());
|
||||
|
||||
// custom menu and shortcut
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@@ -203,9 +213,9 @@ namespace BlackGui
|
||||
if (sender == ui->comp_OwnModelSet->view()) { return ui->comp_OwnModelSet->view()->at(index); }
|
||||
|
||||
// no sender, use current tab
|
||||
const CAircraftModelView *v = this->currentModelView();
|
||||
if (!v) { return CAircraftModel(); }
|
||||
return v->at(index);
|
||||
const CAircraftModelView *mv = this->currentModelView();
|
||||
if (!mv) { return CAircraftModel(); }
|
||||
return mv->at(index);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::gracefulShutdown()
|
||||
@@ -217,20 +227,19 @@ namespace BlackGui
|
||||
|
||||
bool CDbMappingComponent::hasSelectedModelsToStash() const
|
||||
{
|
||||
const TabIndex tab = currentTabIndex();
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels: return ui->comp_OwnAircraftModels->view()->hasSelectedModelsToStash();
|
||||
case TabOwnModelSet: return ui->comp_OwnModelSet->view()->hasSelectedModelsToStash();
|
||||
case TabVPilot: return ui->tvp_AircraftModelsForVPilot->hasSelectedModelsToStash();
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
const CAircraftModelView *mv = this->currentModelView();
|
||||
if (!mv) { return false; }
|
||||
return mv->hasSelectedModelsToStash();
|
||||
}
|
||||
|
||||
CAircraftModelView *CDbMappingComponent::currentModelView() const
|
||||
{
|
||||
const TabIndex tab = currentTabIndex();
|
||||
return this->modelView(tab);
|
||||
}
|
||||
|
||||
CAircraftModelView *CDbMappingComponent::modelView(TabIndex tab) const
|
||||
{
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels: return ui->comp_OwnAircraftModels->view();
|
||||
@@ -285,16 +294,9 @@ namespace BlackGui
|
||||
|
||||
CAircraftModelList CDbMappingComponent::getSelectedModelsToStash() const
|
||||
{
|
||||
if (!hasSelectedModelsToStash()) { return CAircraftModelList(); }
|
||||
const TabIndex tab = currentTabIndex();
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels: return ui->comp_OwnAircraftModels->view()->selectedObjects();
|
||||
case TabOwnModelSet: return ui->comp_OwnModelSet->view()->selectedObjects();
|
||||
case TabVPilot: return ui->tvp_AircraftModelsForVPilot->selectedObjects();
|
||||
default: break;
|
||||
}
|
||||
return CAircraftModelList();
|
||||
const CAircraftModelView *mv = this->currentModelView();
|
||||
if (!mv || !mv->hasSelectedModelsToStash()) { return CAircraftModelList(); }
|
||||
return mv->selectedObjects();
|
||||
}
|
||||
|
||||
const CAircraftModelList &CDbMappingComponent::getStashedModels() const
|
||||
@@ -388,17 +390,8 @@ namespace BlackGui
|
||||
{
|
||||
const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings());
|
||||
if (modelStrings.isEmpty()) { return; }
|
||||
switch (currentTabIndex())
|
||||
{
|
||||
case TabVPilot:
|
||||
case TabOwnModels:
|
||||
case TabOwnModelSet:
|
||||
case TabStash:
|
||||
this->currentModelView()->removeModelsWithModelString(modelStrings);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CAircraftModelView *mv = this->currentModelView();
|
||||
if (mv) { mv->removeModelsWithModelString(modelStrings); }
|
||||
}
|
||||
|
||||
void CDbMappingComponent::showChangedAttributes()
|
||||
@@ -627,17 +620,22 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot);
|
||||
QString o = ui->tw_ModelsToBeMapped->tabText(i);
|
||||
const QString f = ui->tvp_AircraftModelsForVPilot->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, ui->tvp_AircraftModelsForVPilot->rowCount()) + f;
|
||||
ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||
ui->tvp_AircraftModelsForVPilot->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot));
|
||||
}
|
||||
|
||||
void CDbMappingComponent::onWorkbenchDataChanged(int count, bool withFilter)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
ui->comp_ModelWorkbench->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_Workbench));
|
||||
}
|
||||
|
||||
void CDbMappingComponent::onOwnModelsChangedDigest(int count, bool withFilter)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
|
||||
// non standard with sim
|
||||
const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModels);
|
||||
static const QString ot(ui->tw_ModelsToBeMapped->tabText(i));
|
||||
QString o(ot);
|
||||
@@ -702,11 +700,7 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels);
|
||||
QString o = ui->tw_ModelsToBeMapped->tabText(i);
|
||||
const QString f = ui->comp_StashAircraft->view()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, ui->comp_StashAircraft->view()->rowCount()) + f;
|
||||
ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||
ui->comp_StashAircraft->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels));
|
||||
|
||||
// update editors
|
||||
this->updateEditorsWhenApplicable();
|
||||
@@ -716,6 +710,8 @@ namespace BlackGui
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
|
||||
// none standard with simulator
|
||||
int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModelSet);
|
||||
QString o = "Model set " + ui->comp_OwnModelSet->getModelSetSimulator().toQString(true);
|
||||
const QString f = ui->comp_OwnModelSet->view()->hasFilter() ? "F" : "";
|
||||
|
||||
@@ -72,15 +72,16 @@ namespace BlackGui
|
||||
|
||||
public:
|
||||
//! Tab index.
|
||||
//! Must match real tab index
|
||||
//! \remark Must match real tab index
|
||||
enum TabIndex
|
||||
{
|
||||
NoValidTab = -1,
|
||||
TabOwnModelSet = 0,
|
||||
TabOwnModels = 1,
|
||||
TabStash = 2,
|
||||
TabModelMatcher = 3,
|
||||
TabVPilot = 4
|
||||
TabWorkbench = 2,
|
||||
TabStash = 3,
|
||||
TabModelMatcher = 4,
|
||||
TabVPilot = 5
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
@@ -113,6 +114,9 @@ namespace BlackGui
|
||||
//! Current model view
|
||||
Views::CAircraftModelView *currentModelView() const;
|
||||
|
||||
//! Current model view
|
||||
Views::CAircraftModelView *modelView(TabIndex tab) const;
|
||||
|
||||
//! Unvalidated consolidated aircraft model from the editor subparts (icao, distributor)
|
||||
//! \note not guaranteed to be valid, just a snapshot of its current editor state
|
||||
BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const;
|
||||
@@ -247,6 +251,9 @@ namespace BlackGui
|
||||
//! vPilot data changed
|
||||
void onVPilotDataChanged(int count, bool withFilter);
|
||||
|
||||
//! Workbench data changed
|
||||
void onWorkbenchDataChanged(int count, bool withFilter);
|
||||
|
||||
//! Tab index changed
|
||||
void onTabIndexChanged(int index);
|
||||
|
||||
|
||||
@@ -138,6 +138,38 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_Workbench">
|
||||
<attribute name="title">
|
||||
<string>Workbench</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="hl_Workbench">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDbModelWorkbenchComponent" name="comp_ModelWorkbench">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_StashAircraftModels">
|
||||
<attribute name="title">
|
||||
<string>Stashed models</string>
|
||||
@@ -287,7 +319,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>882</width>
|
||||
<width>885</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -378,6 +410,12 @@
|
||||
<header>blackgui/components/modelmatchercomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbModelWorkbenchComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbmodelworkbenchcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user