mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:00:05 +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
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