refs #618, GUI dialog to create own model set

* new tab in model mapping component
* form + dialog to select appropriate models
This commit is contained in:
Klaus Basan
2016-03-14 20:27:46 +01:00
parent 17cbd31095
commit 42d5ceff32
14 changed files with 992 additions and 74 deletions

View File

@@ -0,0 +1,115 @@
/* Copyright (C) 2016
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "dbownmodelsetcomponent.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackgui/models/aircrafticaolistmodel.h"
#include "dbmappingcomponent.h"
#include "dbownmodelsetdialog.h"
#include "ui_dbownmodelsetcomponent.h"
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
using namespace BlackGui::Models;
using namespace BlackGui::Views;
namespace BlackGui
{
namespace Components
{
CDbOwnModelSetComponent::CDbOwnModelSetComponent(QWidget *parent) :
QFrame(parent),
CDbMappingComponentAware(parent),
ui(new Ui::CDbOwnModelSetComponent)
{
ui->setupUi(this);
ui->tvp_OwnModelSet->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
ui->tvp_OwnModelSet->menuRemoveItems(CAircraftModelView::MenuDisplayAutomaticallyAndRefresh | CAircraftModelView::MenuStashing | CAircraftModelView::MenuBackend | CAircraftModelView::MenuRefresh);
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows);
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
}
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
{
// void
}
Views::CAircraftModelView *CDbOwnModelSetComponent::getView() const
{
return ui->tvp_OwnModelSet;
}
void CDbOwnModelSetComponent::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
{
this->ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
this->ui->pb_SaveAsSetForSimulator->setText("save for " + simulator.toQString());
this->ui->pb_SaveAsSetForSimulator->setEnabled(!models.isEmpty());
this->m_simulator = simulator;
}
void CDbOwnModelSetComponent::setMappingComponent(CDbMappingComponent *component)
{
CDbMappingComponentAware::setMappingComponent(component);
if (component)
{
connect(this->getMappingComponent(), &CDbMappingComponent::tabIndexChanged, this, &CDbOwnModelSetComponent::ps_tabChanged);
}
}
void CDbOwnModelSetComponent::ps_tabChanged(int index)
{
CDbMappingComponent::TabIndex ti = static_cast<CDbMappingComponent::TabIndex>(index);
if (ti == CDbMappingComponent::TabOwnModelSet)
{
// myself
this->getMappingComponent()->resizeForSelect();
}
else
{
// others
}
}
void CDbOwnModelSetComponent::ps_buttonClicked()
{
const QObject *sender = QObject::sender();
if (sender == ui->pb_CreateNewSet)
{
if (!this->m_modelSetDialog)
{
this->m_modelSetDialog.reset(new CDbOwnModelSetDialog(this));
this->m_modelSetDialog->setMappingComponent(this->getMappingComponent());
}
if (this->getMappingComponent()->getOwnModelsCount() > 0)
{
this->m_modelSetDialog->setModal(true);
this->m_modelSetDialog->reloadData();
QDialog::DialogCode rc = static_cast<QDialog::DialogCode>(
this->m_modelSetDialog->exec()
);
if (rc == QDialog::Accepted)
{
this->setModelSet(this->m_modelSetDialog->getModelSet(), this->m_modelSetDialog->getSimulatorInfo());
}
}
else
{
static const CStatusMessage m(CStatusMessage(this, CStatusMessage::SeverityError, "No model data"));
this->getMappingComponent()->showOverlayMessage(m);
}
}
else if (sender == ui->pb_LoadExistingSet)
{
this->ui->tvp_OwnModelSet->showFileLoadDialog();
}
}
} // ns
} // ns