mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T554 UI stubs
This commit is contained in:
committed by
Mat Sutcliffe
parent
961afa531b
commit
16e3042cfb
88
src/blackgui/components/autopublishcomponent.cpp
Normal file
88
src/blackgui/components/autopublishcomponent.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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 "autopublishcomponent.h"
|
||||
#include "ui_autopublishcomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CAutoPublishComponent::CAutoPublishComponent(QWidget *parent) :
|
||||
COverlayMessagesFrame(parent),
|
||||
ui(new Ui::CAutoPublishComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Analyze, &QPushButton::released, this, &CAutoPublishComponent::analyzeAgainstDBData, Qt::QueuedConnection);
|
||||
connect(ui->pb_SendToDB, &QPushButton::released, this, &CAutoPublishComponent::sendToDb, Qt::QueuedConnection);
|
||||
connect(ui->pb_DeleteFiles, &QPushButton::released, this, &CAutoPublishComponent::deleteAllFiles, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
CAutoPublishComponent::~CAutoPublishComponent()
|
||||
{ }
|
||||
|
||||
int CAutoPublishComponent::readFiles()
|
||||
{
|
||||
const int r = m_data.readFromJsonFiles();
|
||||
this->displayData();
|
||||
return r;
|
||||
}
|
||||
|
||||
void CAutoPublishComponent::analyzeAgainstDBData()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
const CAircraftModelList dbModels = sGui->getWebDataServices()->getModels();
|
||||
const CStatusMessageList msgs = m_data.analyzeAgainstDBData(dbModels);
|
||||
this->showOverlayMessages(msgs);
|
||||
}
|
||||
|
||||
void CAutoPublishComponent::sendToDb()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (m_data.isEmpty())
|
||||
{
|
||||
this->showOverlayHTMLMessage("No data!", 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
const CAircraftModelList dbModels = sGui->getWebDataServices()->getModels();
|
||||
CStatusMessageList msgs = m_data.analyzeAgainstDBData(dbModels);
|
||||
if (!msgs.hasErrorMessages())
|
||||
{
|
||||
const CStatusMessageList publishMsgs = sGui->getWebDataServices()->asyncAutoPublish(m_data);
|
||||
msgs.push_back(publishMsgs);
|
||||
}
|
||||
this->showOverlayMessages(msgs);
|
||||
}
|
||||
|
||||
void CAutoPublishComponent::displayData()
|
||||
{
|
||||
ui->pte_Json->setPlainText(m_data.toDatabaseJson());
|
||||
ui->le_Summary->setText(m_data.getSummary());
|
||||
}
|
||||
|
||||
void CAutoPublishComponent::deleteAllFiles()
|
||||
{
|
||||
const int c = CAutoPublishData::deleteAutoPublishFiles();
|
||||
if (c > 0)
|
||||
{
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Deleted %1 file(s)").arg(c));
|
||||
}
|
||||
this->readFiles() ;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
58
src/blackgui/components/autopublishcomponent.h
Normal file
58
src/blackgui/components/autopublishcomponent.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_AUTOPUBLISHCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_AUTOPUBLISHCOMPONENT_H
|
||||
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackmisc/simulation/autopublishdata.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAutoPublishComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Data automatically collected and be be sent to backend
|
||||
class CAutoPublishComponent : public COverlayMessagesFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CAutoPublishComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAutoPublishComponent();
|
||||
|
||||
//! Read the files
|
||||
int readFiles();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAutoPublishComponent> ui;
|
||||
BlackMisc::Simulation::CAutoPublishData m_data;
|
||||
|
||||
//! Analyze against DB data
|
||||
void analyzeAgainstDBData();
|
||||
|
||||
//! Send to DB
|
||||
void sendToDb();
|
||||
|
||||
//! Display data in JSON text field
|
||||
void displayData();
|
||||
|
||||
//! Delete all files
|
||||
void deleteAllFiles();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
110
src/blackgui/components/autopublishcomponent.ui
Normal file
110
src/blackgui/components/autopublishcomponent.ui
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAutoPublishComponent</class>
|
||||
<widget class="QFrame" name="CAutoPublishComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>323</width>
|
||||
<height>389</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Auto publish information</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Summary">
|
||||
<property name="title">
|
||||
<string>Summary</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Summary">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Info">
|
||||
<property name="text">
|
||||
<string>swift automatically collects data about your used models. These collected data can help to improve the matching and interpolation experience. There are no hidden data, you can see the data as it is sent below.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_Summary">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_DBJson">
|
||||
<property name="title">
|
||||
<string>DB data (JSON)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_DBJson">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="pte_Json">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Buttons">
|
||||
<layout class="QHBoxLayout" name="hl_Buttons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SendToDB">
|
||||
<property name="text">
|
||||
<string>send to DB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Buttons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_DeleteFiles">
|
||||
<property name="text">
|
||||
<string>clean</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Analyze">
|
||||
<property name="text">
|
||||
<string>analyze</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>le_Summary</tabstop>
|
||||
<tabstop>pte_Json</tabstop>
|
||||
<tabstop>pb_SendToDB</tabstop>
|
||||
<tabstop>pb_DeleteFiles</tabstop>
|
||||
<tabstop>pb_Analyze</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
40
src/blackgui/components/autopublishdialog.cpp
Normal file
40
src/blackgui/components/autopublishdialog.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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 "autopublishdialog.h"
|
||||
#include "ui_autopublishdialog.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CAutoPublishDialog::CAutoPublishDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAutoPublishDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
CAutoPublishDialog::~CAutoPublishDialog()
|
||||
{ }
|
||||
|
||||
int CAutoPublishDialog::readFiles()
|
||||
{
|
||||
return ui->comp_AutoPublish->readFiles();
|
||||
}
|
||||
|
||||
int CAutoPublishDialog::readAndShow()
|
||||
{
|
||||
const int r = ui->comp_AutoPublish->readFiles();
|
||||
this->show();
|
||||
return r;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
48
src/blackgui/components/autopublishdialog.h
Normal file
48
src/blackgui/components/autopublishdialog.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_AUTOPUBLISHDIALOG_H
|
||||
#define BLACKGUI_COMPONENTS_AUTOPUBLISHDIALOG_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAutoPublishDialog; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! CAutoPublishComponent as dialog
|
||||
class BLACKGUI_EXPORT CAutoPublishDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CAutoPublishDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAutoPublishDialog();
|
||||
|
||||
//! \copydoc CAutoPublishComponent::readFiles
|
||||
int readFiles();
|
||||
|
||||
//! Read files and show dialog
|
||||
int readAndShow();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAutoPublishDialog> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
75
src/blackgui/components/autopublishdialog.ui
Normal file
75
src/blackgui/components/autopublishdialog.ui
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAutoPublishDialog</class>
|
||||
<widget class="QDialog" name="CAutoPublishDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Auto publish data</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_AutoPublishDialog">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAutoPublishComponent" name="comp_AutoPublish"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_AutoPublishDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAutoPublishComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/autopublishcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_AutoPublishDialog</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CAutoPublishDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_AutoPublishDialog</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CAutoPublishDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user