mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Updating radar site display fields to be more human-friendly
- Latitude/longitude in degrees N/S/E/W - Radar types with hyphens - Sort by raw decimal values
This commit is contained in:
parent
1bc6e714f5
commit
6e7a13494a
11 changed files with 186 additions and 5 deletions
|
|
@ -38,6 +38,7 @@ set(SRC_EXE_MAIN source/scwx/qt/main/main.cpp)
|
|||
set(HDR_MAIN source/scwx/qt/main/main_window.hpp)
|
||||
set(SRC_MAIN source/scwx/qt/main/main_window.cpp)
|
||||
set(UI_MAIN source/scwx/qt/main/main_window.ui)
|
||||
set(HDR_COMMON source/scwx/qt/common/types.hpp)
|
||||
set(HDR_CONFIG source/scwx/qt/config/radar_site.hpp)
|
||||
set(SRC_CONFIG source/scwx/qt/config/radar_site.cpp)
|
||||
set(SRC_EXTERNAL source/scwx/qt/external/stb_rect_pack.cpp)
|
||||
|
|
@ -153,6 +154,7 @@ set(TS_FILES ts/scwx_en_US.ts)
|
|||
|
||||
set(PROJECT_SOURCES ${HDR_MAIN}
|
||||
${SRC_MAIN}
|
||||
${HDR_COMMON}
|
||||
${HDR_CONFIG}
|
||||
${SRC_CONFIG}
|
||||
${SRC_EXTERNAL}
|
||||
|
|
@ -189,6 +191,7 @@ set(EXECUTABLE_SOURCES ${SRC_EXE_MAIN})
|
|||
|
||||
source_group("Header Files\\main" FILES ${HDR_MAIN})
|
||||
source_group("Source Files\\main" FILES ${SRC_MAIN})
|
||||
source_group("Header Files\\common" FILES ${HDR_COMMON})
|
||||
source_group("Header Files\\config" FILES ${HDR_CONFIG})
|
||||
source_group("Source Files\\config" FILES ${SRC_CONFIG})
|
||||
source_group("Source Files\\external" FILES ${SRC_EXTERNAL})
|
||||
|
|
|
|||
19
scwx-qt/source/scwx/qt/common/types.hpp
Normal file
19
scwx-qt/source/scwx/qt/common/types.hpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <Qt>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
enum ItemDataRole
|
||||
{
|
||||
SortRole = Qt::UserRole
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
@ -20,6 +20,9 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
|||
static const std::string defaultRadarSiteFile_ =
|
||||
":/res/config/radar_sites.json";
|
||||
|
||||
static const std::unordered_map<std::string, std::string> typeNameMap_ {
|
||||
{"wsr88d", "WSR-88D"}, {"tdwr", "TDWR"}, {"?", "?"}};
|
||||
|
||||
static std::unordered_map<std::string, std::shared_ptr<RadarSite>>
|
||||
radarSiteMap_;
|
||||
static std::unordered_map<std::string, std::string> siteIdMap_;
|
||||
|
|
@ -63,6 +66,19 @@ std::string RadarSite::type() const
|
|||
return p->type_;
|
||||
}
|
||||
|
||||
std::string RadarSite::type_name() const
|
||||
{
|
||||
auto it = typeNameMap_.find(p->type_);
|
||||
if (it != typeNameMap_.cend())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return typeNameMap_.at("?");
|
||||
}
|
||||
}
|
||||
|
||||
std::string RadarSite::id() const
|
||||
{
|
||||
return p->id_;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public:
|
|||
RadarSite& operator=(RadarSite&&) noexcept;
|
||||
|
||||
std::string type() const;
|
||||
std::string type_name() const;
|
||||
std::string id() const;
|
||||
double latitude() const;
|
||||
double longitude() const;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include <scwx/qt/model/radar_site_model.hpp>
|
||||
#include <scwx/qt/common/types.hpp>
|
||||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/common/geographic.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
namespace scwx
|
||||
|
|
@ -42,7 +44,8 @@ int RadarSiteModel::columnCount(const QModelIndex& parent) const
|
|||
QVariant RadarSiteModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (index.isValid() && index.row() >= 0 &&
|
||||
index.row() < p->radarSites_.size() && role == Qt::DisplayRole)
|
||||
index.row() < p->radarSites_.size() &&
|
||||
(role == Qt::DisplayRole || role == common::SortRole))
|
||||
{
|
||||
const auto& site = p->radarSites_.at(index.row());
|
||||
|
||||
|
|
@ -57,11 +60,27 @@ QVariant RadarSiteModel::data(const QModelIndex& index, int role) const
|
|||
case 3:
|
||||
return QString::fromStdString(site->country());
|
||||
case 4:
|
||||
return QString("%1").arg(site->latitude());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return QString::fromStdString(
|
||||
scwx::common::GetLatitudeString(site->latitude()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return site->latitude();
|
||||
}
|
||||
case 5:
|
||||
return QString("%1").arg(site->longitude());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return QString::fromStdString(
|
||||
scwx::common::GetLongitudeString(site->longitude()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return site->longitude();
|
||||
}
|
||||
case 6:
|
||||
return QString::fromStdString(site->type());
|
||||
return QString::fromStdString(site->type_name());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "radar_site_dialog.hpp"
|
||||
#include "./ui_radar_site_dialog.h"
|
||||
|
||||
#include <scwx/qt/common/types.hpp>
|
||||
#include <scwx/qt/model/radar_site_model.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ public:
|
|||
proxyModel_ {new QSortFilterProxyModel(self_)}
|
||||
{
|
||||
proxyModel_->setSourceModel(radarSiteModel_);
|
||||
proxyModel_->setSortRole(common::SortRole);
|
||||
proxyModel_->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
proxyModel_->setFilterKeyColumn(-1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue