mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
refactor: Remove unused weather models/views
This commit is contained in:
@@ -1,138 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "gui/models/cloudlayerlistmodel.h"
|
||||
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "gui/models/columnformatters.h"
|
||||
|
||||
using namespace swift::misc;
|
||||
using namespace swift::misc::physical_quantities;
|
||||
using namespace swift::misc::weather;
|
||||
|
||||
namespace swift::gui::models
|
||||
{
|
||||
|
||||
//! Relative Humidity
|
||||
class CPrecipitationRateFormatter : public CDefaultFormatter
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CPrecipitationRateFormatter(int alignment = alignDefault()) : CDefaultFormatter(alignment, false, roleDisplay())
|
||||
{}
|
||||
|
||||
//! \copydoc CDefaultFormatter::displayRole
|
||||
virtual CVariant displayRole(const CVariant &dataCVariant) const override
|
||||
{
|
||||
if (dataCVariant.canConvert<double>())
|
||||
{
|
||||
double rate = dataCVariant.value<double>();
|
||||
QString formattedString = QString::number(rate) + " mm/h";
|
||||
return formattedString;
|
||||
}
|
||||
Q_ASSERT_X(false, "CPrecipitationRateFormatter", "no double value");
|
||||
return CVariant();
|
||||
}
|
||||
};
|
||||
|
||||
//! Precipitation
|
||||
class CPrecipitationFormatter : public CDefaultFormatter
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CPrecipitationFormatter(int alignment = alignDefault()) : CDefaultFormatter(alignment, false, roleDisplay()) {}
|
||||
|
||||
//! \copydoc CDefaultFormatter::displayRole
|
||||
virtual CVariant displayRole(const CVariant &dataCVariant) const override
|
||||
{
|
||||
if (dataCVariant.canConvert<CCloudLayer::Precipitation>())
|
||||
{
|
||||
CCloudLayer::Precipitation precipitation = dataCVariant.value<CCloudLayer::Precipitation>();
|
||||
switch (precipitation)
|
||||
{
|
||||
case CCloudLayer::PrecipitationUnknown: return QString("Unknown");
|
||||
case CCloudLayer::NoPrecipitation: return QString("None");
|
||||
case CCloudLayer::Rain: return QString("Rain");
|
||||
case CCloudLayer::Snow: return QString("Snow");
|
||||
}
|
||||
}
|
||||
Q_ASSERT_X(false, "CPrecipitationFormatter", "no CCloudLayer::Precipitation value");
|
||||
return CVariant();
|
||||
}
|
||||
};
|
||||
|
||||
//! Clouds
|
||||
class CCloudsFormatter : public CDefaultFormatter
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CCloudsFormatter(int alignment = alignDefault()) : CDefaultFormatter(alignment, false, roleDisplay()) {}
|
||||
|
||||
//! \copydoc CDefaultFormatter::displayRole
|
||||
virtual CVariant displayRole(const CVariant &dataCVariant) const override
|
||||
{
|
||||
if (dataCVariant.canConvert<CCloudLayer::Clouds>())
|
||||
{
|
||||
CCloudLayer::Clouds clouds = dataCVariant.value<CCloudLayer::Clouds>();
|
||||
switch (clouds)
|
||||
{
|
||||
case CCloudLayer::NoClouds: return QString("None");
|
||||
case CCloudLayer::Cirrus: return QString("Cirrus");
|
||||
case CCloudLayer::Stratus: return QString("Stratus");
|
||||
case CCloudLayer::Cumulus: return QString("Cumulus");
|
||||
case CCloudLayer::Thunderstorm: return QString("Thunderstorm");
|
||||
case CCloudLayer::CloudsUnknown: return QString("N/A");
|
||||
}
|
||||
}
|
||||
Q_ASSERT_X(false, "CCloudsFormatter", "no CCloudLayer::Clouds value");
|
||||
return CVariant();
|
||||
}
|
||||
};
|
||||
|
||||
//! Relative Humidity
|
||||
class CCoverageFormatter : public CDefaultFormatter
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CCoverageFormatter(int alignment = alignDefault()) : CDefaultFormatter(alignment, false, roleDisplay()) {}
|
||||
|
||||
//! \copydoc CDefaultFormatter::displayRole
|
||||
virtual CVariant displayRole(const CVariant &dataCVariant) const override
|
||||
{
|
||||
if (dataCVariant.canConvert<int>())
|
||||
{
|
||||
int coverage = dataCVariant.value<int>();
|
||||
QString formattedString = QString::number(coverage) + " %";
|
||||
return formattedString;
|
||||
}
|
||||
Q_ASSERT_X(false, "CCoverageFormatter", "no int value");
|
||||
return CVariant();
|
||||
}
|
||||
};
|
||||
|
||||
CCloudLayerListModel::CCloudLayerListModel(QObject *parent) : CListModelBase("CloudLayerListModel", parent)
|
||||
{
|
||||
this->m_columns.addColumn(CColumn("base", CCloudLayer::IndexBase, new CAltitudeFormatter()));
|
||||
this->m_columns.addColumn(CColumn("top", CCloudLayer::IndexTop, new CAltitudeFormatter()));
|
||||
this->m_columns.addColumn(
|
||||
CColumn("precipitation rate", CCloudLayer::IndexPrecipitationRate, new CPrecipitationRateFormatter()));
|
||||
this->m_columns.addColumn(
|
||||
CColumn("precipitation", CCloudLayer::IndexPrecipitation, new CPrecipitationFormatter()));
|
||||
this->m_columns.addColumn(CColumn("clouds", CCloudLayer::IndexClouds, new CCloudsFormatter()));
|
||||
this->m_columns.addColumn(CColumn("coverage", CCloudLayer::IndexCoveragePercent, new CCoverageFormatter()));
|
||||
|
||||
// default sort order
|
||||
this->setSortColumnByPropertyIndex(CCloudLayer::IndexBase);
|
||||
this->m_sortOrder = Qt::AscendingOrder;
|
||||
|
||||
// force strings for translation in resource files
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "base");
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "top");
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "precipitation rate");
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "precipitation");
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "clouds");
|
||||
(void)QT_TRANSLATE_NOOP("ModelCloudLayerList", "coverage");
|
||||
}
|
||||
} // namespace swift::gui::models
|
||||
@@ -1,31 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef SWIFT_GUI_MODELS_CLOUDLAYERLISTMODEL_H
|
||||
#define SWIFT_GUI_MODELS_CLOUDLAYERLISTMODEL_H
|
||||
|
||||
#include "gui/models/listmodelbase.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/weather/cloudlayer.h"
|
||||
#include "misc/weather/cloudlayerlist.h"
|
||||
|
||||
class QObject;
|
||||
|
||||
namespace swift::gui::models
|
||||
{
|
||||
//! Cloud layer list model
|
||||
class SWIFT_GUI_EXPORT CCloudLayerListModel : public CListModelBase<swift::misc::weather::CCloudLayerList, false>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CCloudLayerListModel(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CCloudLayerListModel() {}
|
||||
};
|
||||
} // namespace swift::gui::models
|
||||
#endif // SWIFT_GUI_MODELS_CLOUDLAYERLISTMODEL_H
|
||||
@@ -1,34 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "windlayerlistmodel.h"
|
||||
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "gui/models/columnformatters.h"
|
||||
|
||||
using namespace swift::misc;
|
||||
using namespace swift::misc::physical_quantities;
|
||||
using namespace swift::misc::weather;
|
||||
|
||||
namespace swift::gui::models
|
||||
{
|
||||
CWindLayerListModel::CWindLayerListModel(QObject *parent) : CListModelBase("WindLayerListModel", parent)
|
||||
{
|
||||
m_columns.addColumn(CColumn("level", CWindLayer::IndexLevel, new CAltitudeFormatter()));
|
||||
m_columns.addColumn(CColumn("direction", CWindLayer::IndexDirection, new CAngleDegreeFormatter()));
|
||||
m_columns.addColumn(CColumn("speed", CWindLayer::IndexSpeed, new CSpeedKtsFormatter()));
|
||||
m_columns.addColumn(CColumn("gust speed", CWindLayer::IndexGustSpeed, new CSpeedKtsFormatter()));
|
||||
|
||||
// default sort order
|
||||
this->setSortColumnByPropertyIndex(CWindLayer::IndexLevel);
|
||||
m_sortOrder = Qt::AscendingOrder;
|
||||
|
||||
// force strings for translation in resource files
|
||||
(void)QT_TRANSLATE_NOOP("ModelWindLayerList", "level");
|
||||
(void)QT_TRANSLATE_NOOP("ModelWindLayerList", "direction");
|
||||
(void)QT_TRANSLATE_NOOP("ModelWindLayerList", "speed");
|
||||
(void)QT_TRANSLATE_NOOP("ModelWindLayerList", "gust speed");
|
||||
}
|
||||
} // namespace swift::gui::models
|
||||
@@ -1,31 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef SWIFT_GUI_MODELS_WINDLAYERLISTMODEL_H
|
||||
#define SWIFT_GUI_MODELS_WINDLAYERLISTMODEL_H
|
||||
|
||||
#include "gui/models/listmodelbase.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/weather/windlayer.h"
|
||||
#include "misc/weather/windlayerlist.h"
|
||||
|
||||
class QObject;
|
||||
|
||||
namespace swift::gui::models
|
||||
{
|
||||
//! Wind layer list model
|
||||
class SWIFT_GUI_EXPORT CWindLayerListModel : public CListModelBase<swift::misc::weather::CWindLayerList, false>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CWindLayerListModel(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CWindLayerListModel() {}
|
||||
};
|
||||
} // namespace swift::gui::models
|
||||
#endif // SWIFT_GUI_MODELS_WINDLAYERLISTMODEL_H
|
||||
Reference in New Issue
Block a user