mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Ref T264, sued "new signal syntax" with some QShortcuts and as a result made some slots "normal functions"
This commit is contained in:
@@ -87,10 +87,10 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
ui->comp_SimulatorSelector->setValue(simulator);
|
||||||
ui->le_Simulator->setText(simulator.toQString(true));
|
ui->le_Simulator->setText(simulator.toQString(true));
|
||||||
const QPointer<CDbOwnModelSetComponent> guard(this);
|
const QPointer<CDbOwnModelSetComponent> myself(this);
|
||||||
QTimer::singleShot(500, [ = ]()
|
QTimer::singleShot(500, [ = ]()
|
||||||
{
|
{
|
||||||
if (guard.isNull() || !sApp || sApp->isShuttingDown()) { return; }
|
if (myself.isNull() || !sApp || sApp->isShuttingDown()) { return; }
|
||||||
this->updateViewToCurrentModels();
|
this->updateViewToCurrentModels();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbOwnModelSetComponent::viewModelChanged()
|
void CDbOwnModelSetComponent::viewModelChanged()
|
||||||
{
|
{
|
||||||
ui->pb_SaveAsSetForSimulator->setEnabled(true);
|
const bool hasData = ui->tvp_OwnModelSet->rowCount() > 0;
|
||||||
|
ui->pb_SaveAsSetForSimulator->setEnabled(hasData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &simulator)
|
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &simulator)
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ namespace BlackGui
|
|||||||
this->standardInit(new CAircraftModelListModel(CAircraftModelListModel::OwnAircraftModelClient, this));
|
this->standardInit(new CAircraftModelListModel(CAircraftModelListModel::OwnAircraftModelClient, this));
|
||||||
|
|
||||||
// shortcut
|
// shortcut
|
||||||
new QShortcut(CShortcut::keyStash(), this, SLOT(ps_requestStash()), nullptr, Qt::WidgetShortcut);
|
QShortcut *stashShortcut = new QShortcut(CShortcut::keyStash(), this);
|
||||||
|
stashShortcut->setContext(Qt::WidgetShortcut);
|
||||||
|
connect(stashShortcut, &QShortcut::activated, this, &CAircraftModelView::requestedStash);
|
||||||
|
|
||||||
// default mode
|
// default mode
|
||||||
CAircraftModelListModel::AircraftModelMode mode = derivedModel()->getModelMode();
|
CAircraftModelListModel::AircraftModelMode mode = derivedModel()->getModelMode();
|
||||||
@@ -205,7 +207,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (CGuiUtility::hasSwiftVariantMimeType(mime))
|
if (CGuiUtility::hasSwiftVariantMimeType(mime))
|
||||||
{
|
{
|
||||||
CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime));
|
const CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime));
|
||||||
if (valueVariant.isValid())
|
if (valueVariant.isValid())
|
||||||
{
|
{
|
||||||
if (valueVariant.canConvert<CAircraftModel>())
|
if (valueVariant.canConvert<CAircraftModel>())
|
||||||
@@ -294,8 +296,8 @@ namespace BlackGui
|
|||||||
if (!m_menuFlagActions.contains(MenuCanStashModels))
|
if (!m_menuFlagActions.contains(MenuCanStashModels))
|
||||||
{
|
{
|
||||||
CMenuActions ma;
|
CMenuActions ma;
|
||||||
ma.addAction(CIcons::appDbStash16(), "Stash selected", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_requestStash });
|
ma.addAction(CIcons::appDbStash16(), "Stash selected", CMenuAction::pathStash(), { this, &CAircraftModelView::requestedStash });
|
||||||
QAction *added = ma.addAction(CIcons::appDbStash16(), "Stashing clears selection (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_stashingClearsSelection });
|
QAction *added = ma.addAction(CIcons::appDbStash16(), "Stashing clears selection (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::stashingClearsSelection });
|
||||||
added->setCheckable(true);
|
added->setCheckable(true);
|
||||||
m_menuFlagActions.insert(MenuCanStashModels, ma);
|
m_menuFlagActions.insert(MenuCanStashModels, ma);
|
||||||
}
|
}
|
||||||
@@ -316,7 +318,7 @@ namespace BlackGui
|
|||||||
if (!m_menuFlagActions.contains(MenuHighlightStashed))
|
if (!m_menuFlagActions.contains(MenuHighlightStashed))
|
||||||
{
|
{
|
||||||
CMenuActions ma;
|
CMenuActions ma;
|
||||||
QAction *added = ma.addAction(CIcons::appDbStash16(), "Highlight stashed (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_toggleHighlightStashedModels });
|
QAction *added = ma.addAction(CIcons::appDbStash16(), "Highlight stashed (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::toggleHighlightStashedModels });
|
||||||
added->setCheckable(true);
|
added->setCheckable(true);
|
||||||
m_menuFlagActions.insert(MenuHighlightStashed, ma);
|
m_menuFlagActions.insert(MenuHighlightStashed, ma);
|
||||||
}
|
}
|
||||||
@@ -354,33 +356,33 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (models.isEmpty())
|
if (models.isEmpty())
|
||||||
{
|
{
|
||||||
emit jsonModelsForSimulatorLoaded(CSimulatorInfo());
|
emit this->jsonModelsForSimulatorLoaded(CSimulatorInfo());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emit jsonModelsForSimulatorLoaded(models.simulatorsWithMaxEntries());
|
emit this->jsonModelsForSimulatorLoaded(models.simulatorsWithMaxEntries());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftModelView::ps_toggleHighlightStashedModels()
|
void CAircraftModelView::toggleHighlightStashedModels()
|
||||||
{
|
{
|
||||||
bool h = derivedModel()->highlightModelStrings();
|
bool h = derivedModel()->highlightModelStrings();
|
||||||
derivedModel()->setHighlightModelStrings(!h);
|
derivedModel()->setHighlightModelStrings(!h);
|
||||||
emit toggledHighlightStashedModels();
|
emit toggledHighlightStashedModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftModelView::ps_toogleHighlightInvalidModels()
|
void CAircraftModelView::toggleHighlightInvalidModels()
|
||||||
{
|
{
|
||||||
bool h = this->highlightModelStrings();
|
bool h = this->highlightModelStrings();
|
||||||
this->setHighlightModelStrings(!h);
|
this->setHighlightModelStrings(!h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftModelView::ps_stashingClearsSelection()
|
void CAircraftModelView::stashingClearsSelection()
|
||||||
{
|
{
|
||||||
m_stashingClearsSelection = !m_stashingClearsSelection;
|
m_stashingClearsSelection = !m_stashingClearsSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftModelView::ps_requestStash()
|
void CAircraftModelView::requestedStash()
|
||||||
{
|
{
|
||||||
if (!m_menus.testFlag(MenuCanStashModels)) { return; }
|
if (!m_menus.testFlag(MenuCanStashModels)) { return; }
|
||||||
if (!this->hasSelection()) { return; }
|
if (!this->hasSelection()) { return; }
|
||||||
|
|||||||
@@ -134,20 +134,19 @@ namespace BlackGui
|
|||||||
virtual void jsonLoadedAndModelUpdated(const BlackMisc::Simulation::CAircraftModelList &models) override;
|
virtual void jsonLoadedAndModelUpdated(const BlackMisc::Simulation::CAircraftModelList &models) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
//! Highlight stashed models
|
|
||||||
void ps_toggleHighlightStashedModels();
|
|
||||||
|
|
||||||
//! Toggle highlight invalid models
|
//! Toggle highlight invalid models
|
||||||
void ps_toogleHighlightInvalidModels();
|
void toggleHighlightInvalidModels();
|
||||||
|
|
||||||
//! Toggle if stashing unselects
|
//! Toggle if stashing unselects
|
||||||
void ps_stashingClearsSelection();
|
void stashingClearsSelection();
|
||||||
|
|
||||||
|
//! Highlight stashed models
|
||||||
|
void toggleHighlightStashedModels();
|
||||||
|
|
||||||
//! Stash shortcut pressed
|
//! Stash shortcut pressed
|
||||||
void ps_requestStash();
|
void requestedStash();
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_stashingClearsSelection = true; //!< stashing unselects
|
bool m_stashingClearsSelection = true; //!< stashing unselects
|
||||||
BlackMisc::Simulation::CSimulatorInfo m_loadingRequiresSimulator; //!< simulator required when loading
|
BlackMisc::Simulation::CSimulatorInfo m_loadingRequiresSimulator; //!< simulator required when loading
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -88,16 +88,30 @@ namespace BlackGui
|
|||||||
this->setTextElideMode(Qt::ElideMiddle);
|
this->setTextElideMode(Qt::ElideMiddle);
|
||||||
|
|
||||||
// shortcuts
|
// shortcuts
|
||||||
QShortcut *filter = new QShortcut(CShortcut::keyDisplayFilter(), this, SLOT(ps_displayFilterDialog()), nullptr, Qt::WidgetShortcut);
|
QShortcut *filter = new QShortcut(CShortcut::keyDisplayFilter(), this);
|
||||||
|
connect(filter, &QShortcut::activated, this, &CViewBaseNonTemplate::displayFilterDialog);
|
||||||
filter->setObjectName("Filter shortcut for " + this->objectName());
|
filter->setObjectName("Filter shortcut for " + this->objectName());
|
||||||
QShortcut *clearSelection = new QShortcut(CShortcut::keyClearSelection(), this, SLOT(clearSelection()), nullptr, Qt::WidgetShortcut);
|
filter->setContext(Qt::WidgetShortcut);
|
||||||
|
|
||||||
|
QShortcut *clearSelection = new QShortcut(CShortcut::keyClearSelection(), this);
|
||||||
|
connect(clearSelection, &QShortcut::activated, this, &CViewBaseNonTemplate::clearSelection);
|
||||||
clearSelection->setObjectName("Clear selection shortcut for " + this->objectName());
|
clearSelection->setObjectName("Clear selection shortcut for " + this->objectName());
|
||||||
QShortcut *saveJson = new QShortcut(CShortcut::keySaveViews(), this, SLOT(ps_saveJsonAction()), nullptr, Qt::WidgetShortcut);
|
clearSelection->setContext(Qt::WidgetShortcut);
|
||||||
|
|
||||||
|
QShortcut *saveJson = new QShortcut(CShortcut::keySaveViews(), this);
|
||||||
|
connect(saveJson, &QShortcut::activated, this, &CViewBaseNonTemplate::saveJsonAction);
|
||||||
saveJson->setObjectName("Save JSON for " + this->objectName());
|
saveJson->setObjectName("Save JSON for " + this->objectName());
|
||||||
QShortcut *deleteRow = new QShortcut(CShortcut::keyDelete(), this, SLOT(ps_removeSelectedRows()), nullptr, Qt::WidgetShortcut);
|
saveJson->setContext(Qt::WidgetShortcut);
|
||||||
deleteRow->setObjectName("Delete selected rows for " + this->objectName());
|
|
||||||
QShortcut *copy = new QShortcut(CShortcut::keyCopy(), this, SLOT(ps_copy()), nullptr, Qt::WidgetShortcut);
|
QShortcut *deleteRow = new QShortcut(CShortcut::keyDelete(), this);
|
||||||
copy->setObjectName("Copy rows for " + this->objectName());
|
connect(deleteRow, &QShortcut::activated, this, &CViewBaseNonTemplate::ps_removeSelectedRows);
|
||||||
|
deleteRow->setObjectName("Remove selected rows for " + this->objectName());
|
||||||
|
deleteRow->setContext(Qt::WidgetShortcut);
|
||||||
|
|
||||||
|
QShortcut *copy = new QShortcut(CShortcut::keyCopy(), this);
|
||||||
|
connect(copy, &QShortcut::activated, this, &CViewBaseNonTemplate::ps_copy);
|
||||||
|
copy->setObjectName("Copy selection shortcut for " + this->objectName());
|
||||||
|
copy->setContext(Qt::WidgetShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CViewBaseNonTemplate::~CViewBaseNonTemplate()
|
CViewBaseNonTemplate::~CViewBaseNonTemplate()
|
||||||
@@ -251,14 +265,14 @@ namespace BlackGui
|
|||||||
if (m_filterWidget)
|
if (m_filterWidget)
|
||||||
{
|
{
|
||||||
const bool dialog = qobject_cast<QDialog *>(m_filterWidget);
|
const bool dialog = qobject_cast<QDialog *>(m_filterWidget);
|
||||||
if (dialog) ma.addAction(CIcons::filter16(), "Show filter", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::ps_displayFilterDialog }, CShortcut::keyDisplayFilter());
|
if (dialog) ma.addAction(CIcons::filter16(), "Show filter", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::displayFilterDialog }, CShortcut::keyDisplayFilter());
|
||||||
ma.addAction(CIcons::filter16(), "Remove Filter", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::ps_removeFilter });
|
ma.addAction(CIcons::filter16(), "Remove Filter", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::ps_removeFilter });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MenuMaterializeFilter: { ma.addAction(CIcons::tableRelationship16(), "Materialize filtered data", CMenuAction::pathViewFilter(), { this, &CViewBaseNonTemplate::materializeFilter }); 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 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; }
|
case MenuSave: { ma.addAction(CIcons::disk16(), "Save data in file", CMenuAction::pathViewLoadSave(), { this, &CViewBaseNonTemplate::saveJsonAction }, CShortcut::keySaveViews()); break; }
|
||||||
case MenuCut:
|
case MenuCut:
|
||||||
{
|
{
|
||||||
if (!QApplication::clipboard()) break;
|
if (!QApplication::clipboard()) break;
|
||||||
@@ -565,7 +579,7 @@ namespace BlackGui
|
|||||||
return this->performUpdateContainer(variant, sort, resize);
|
return this->performUpdateContainer(variant, sort, resize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::ps_displayFilterDialog()
|
void CViewBaseNonTemplate::displayFilterDialog()
|
||||||
{
|
{
|
||||||
if (!m_menus.testFlag(MenuFilter)) { return; }
|
if (!m_menus.testFlag(MenuFilter)) { return; }
|
||||||
if (!m_filterWidget) { return; }
|
if (!m_filterWidget) { return; }
|
||||||
@@ -582,7 +596,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::ps_saveJsonAction()
|
void CViewBaseNonTemplate::saveJsonAction()
|
||||||
{
|
{
|
||||||
if (this->isEmpty()) { return; }
|
if (this->isEmpty()) { return; }
|
||||||
if (!m_menus.testFlag(MenuSave)) { return; }
|
if (!m_menus.testFlag(MenuSave)) { return; }
|
||||||
|
|||||||
@@ -429,6 +429,12 @@ namespace BlackGui
|
|||||||
//! Draw drop indicator
|
//! Draw drop indicator
|
||||||
virtual void drawDropIndicator(bool indicator) = 0;
|
virtual void drawDropIndicator(bool indicator) = 0;
|
||||||
|
|
||||||
|
//! Save JSON for action/menu, no return signatur
|
||||||
|
void saveJsonAction();
|
||||||
|
|
||||||
|
//! Display the filter dialog
|
||||||
|
void displayFilterDialog();
|
||||||
|
|
||||||
//! Settings have been changed
|
//! Settings have been changed
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
@@ -463,9 +469,6 @@ namespace BlackGui
|
|||||||
//! Helper method with template free signature serving as callback from threaded worker
|
//! Helper method with template free signature serving as callback from threaded worker
|
||||||
int ps_updateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize);
|
int ps_updateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize);
|
||||||
|
|
||||||
//! Display the filter dialog
|
|
||||||
void ps_displayFilterDialog();
|
|
||||||
|
|
||||||
//! Remove filter
|
//! Remove filter
|
||||||
virtual void ps_removeFilter() = 0;
|
virtual void ps_removeFilter() = 0;
|
||||||
|
|
||||||
@@ -493,9 +496,6 @@ namespace BlackGui
|
|||||||
//! Save JSON
|
//! Save JSON
|
||||||
virtual BlackMisc::CStatusMessage ps_saveJson() = 0;
|
virtual BlackMisc::CStatusMessage ps_saveJson() = 0;
|
||||||
|
|
||||||
//! Save JSON for action/menu, no return signatur
|
|
||||||
void ps_saveJsonAction();
|
|
||||||
|
|
||||||
//! Trigger reload from backend by signal requestUpdate();
|
//! Trigger reload from backend by signal requestUpdate();
|
||||||
void ps_triggerReload();
|
void ps_triggerReload();
|
||||||
|
|
||||||
@@ -517,10 +517,6 @@ namespace BlackGui
|
|||||||
//! Highlight DB data
|
//! Highlight DB data
|
||||||
virtual void ps_toggleHighlightDbData() {}
|
virtual void ps_toggleHighlightDbData() {}
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! Remove selected rows
|
|
||||||
void ps_removeSelectedRows();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! \name Change selection modes @{
|
//! \name Change selection modes @{
|
||||||
void setMultiSelection();
|
void setMultiSelection();
|
||||||
@@ -528,6 +524,9 @@ namespace BlackGui
|
|||||||
void setSingleSelection();
|
void setSingleSelection();
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Remove selected rows
|
||||||
|
void ps_removeSelectedRows();
|
||||||
|
|
||||||
//! Toggle auto display flag
|
//! Toggle auto display flag
|
||||||
void toggleAutoDisplay();
|
void toggleAutoDisplay();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user