mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:30:05 +00:00
Location markers part2 clang-format fixes
This commit is contained in:
parent
e62ef3a7f3
commit
cac89129af
9 changed files with 79 additions and 76 deletions
|
|
@ -903,7 +903,7 @@ bool GeoIcons::RunMousePicking(
|
|||
const QPointF& mouseGlobalPos,
|
||||
const glm::vec2& mouseCoords,
|
||||
const common::Coordinate& /* mouseGeoCoords */,
|
||||
std::shared_ptr<types::EventHandler>& eventHandler )
|
||||
std::shared_ptr<types::EventHandler>& eventHandler)
|
||||
{
|
||||
std::unique_lock lock {p->iconMutex_};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ namespace manager
|
|||
static const std::string logPrefix_ = "scwx::qt::manager::marker_manager";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
static const std::string kNameName_ = "name";
|
||||
static const std::string kLatitudeName_ = "latitude";
|
||||
static const std::string kLongitudeName_ = "longitude";
|
||||
static const std::string kIconName_ = "icon";
|
||||
static const std::string kIconColorName_ = "icon-color";
|
||||
static const std::string kNameName_ = "name";
|
||||
static const std::string kLatitudeName_ = "latitude";
|
||||
static const std::string kLongitudeName_ = "longitude";
|
||||
static const std::string kIconName_ = "icon";
|
||||
static const std::string kIconColorName_ = "icon-color";
|
||||
|
||||
static const std::string defaultIconName = "images/location-marker";
|
||||
|
||||
|
|
@ -68,7 +68,6 @@ public:
|
|||
class MarkerManager::Impl::MarkerRecord
|
||||
{
|
||||
public:
|
||||
|
||||
MarkerRecord(const types::MarkerInfo& info) :
|
||||
markerInfo_ {info}
|
||||
{
|
||||
|
|
@ -93,7 +92,6 @@ public:
|
|||
util::color::ToArgbString(record->markerInfo_.iconColor)}};
|
||||
}
|
||||
|
||||
|
||||
friend MarkerRecord tag_invoke(boost::json::value_to_tag<MarkerRecord>,
|
||||
const boost::json::value& jv)
|
||||
{
|
||||
|
|
@ -102,7 +100,7 @@ public:
|
|||
|
||||
const boost::json::object& jo = jv.as_object();
|
||||
|
||||
std::string iconName = defaultIconName;
|
||||
std::string iconName = defaultIconName;
|
||||
boost::gil::rgba8_pixel_t iconColor = defaultIconColor;
|
||||
|
||||
if (jo.contains(kIconName_) && jo.at(kIconName_).is_string())
|
||||
|
|
@ -112,7 +110,8 @@ public:
|
|||
|
||||
if (jo.contains(kIconColorName_) && jo.at(kIconName_).is_string())
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
iconColor = util::color::ToRgba8PixelT(
|
||||
boost::json::value_to<std::string>(jv.at(kIconColorName_)));
|
||||
}
|
||||
|
|
@ -181,7 +180,6 @@ void MarkerManager::Impl::ReadMarkerSettings()
|
|||
{
|
||||
// For each marker entry
|
||||
auto& markerArray = markerJson.as_array();
|
||||
//std::vector<std::string> fileNames {};
|
||||
markerRecords_.reserve(markerArray.size());
|
||||
idToIndex_.reserve(markerArray.size());
|
||||
for (auto& markerEntry : markerArray)
|
||||
|
|
@ -206,13 +204,13 @@ void MarkerManager::Impl::ReadMarkerSettings()
|
|||
}
|
||||
|
||||
util::TextureAtlas& textureAtlas = util::TextureAtlas::Instance();
|
||||
textureAtlas.BuildAtlas(2048, 2048); // Should this code be moved to ResourceManager?
|
||||
textureAtlas.BuildAtlas(
|
||||
2048, 2048); // Should this code be moved to ResourceManager?
|
||||
|
||||
logger_->debug("{} location marker entries", markerRecords_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Q_EMIT self_->MarkersUpdated();
|
||||
}
|
||||
|
||||
|
|
@ -457,7 +455,8 @@ void MarkerManager::add_icon(const std::string& name, bool startup)
|
|||
if (!startup)
|
||||
{
|
||||
util::TextureAtlas& textureAtlas = util::TextureAtlas::Instance();
|
||||
textureAtlas.BuildAtlas(2048, 2048); // Should this code be moved to ResourceManager?
|
||||
textureAtlas.BuildAtlas(
|
||||
2048, 2048); // Should this code be moved to ResourceManager?
|
||||
Q_EMIT IconAdded(name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ public:
|
|||
|
||||
size_t marker_count();
|
||||
std::optional<types::MarkerInfo> get_marker(types::MarkerId id);
|
||||
std::optional<size_t> get_index(types::MarkerId id);
|
||||
std::optional<size_t> get_index(types::MarkerId id);
|
||||
void set_marker(types::MarkerId id, const types::MarkerInfo& marker);
|
||||
types::MarkerId add_marker(const types::MarkerInfo& marker);
|
||||
void remove_marker(types::MarkerId id);
|
||||
void move_marker(size_t from, size_t to);
|
||||
void remove_marker(types::MarkerId id);
|
||||
void move_marker(size_t from, size_t to);
|
||||
|
||||
void add_icon(const std::string& name, bool startup = false);
|
||||
std::optional<types::MarkerIconInfo> get_icon(const std::string& name);
|
||||
|
|
@ -39,7 +39,7 @@ public:
|
|||
void set_marker_settings_path(const std::string& path);
|
||||
|
||||
static std::shared_ptr<MarkerManager> Instance();
|
||||
static const std::string& getDefaultIconName();
|
||||
static const std::string& getDefaultIconName();
|
||||
|
||||
signals:
|
||||
void MarkersInitialized(size_t count);
|
||||
|
|
@ -51,7 +51,6 @@ signals:
|
|||
void IconsReady();
|
||||
void IconAdded(std::string name);
|
||||
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ QVariant MarkerModel::data(const QModelIndex& index, int role) const
|
|||
{
|
||||
std::optional<types::MarkerIconInfo> icon =
|
||||
p->markerManager_->get_icon(markerInfo->iconName);
|
||||
if (icon) {
|
||||
if (icon)
|
||||
{
|
||||
return util::modulateColors(icon->qIcon,
|
||||
QSize(iconSize_, iconSize_),
|
||||
QColor(markerInfo->iconColor[0],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ struct MarkerInfo
|
|||
{
|
||||
}
|
||||
|
||||
MarkerId id{0};
|
||||
MarkerId id {0};
|
||||
std::string name;
|
||||
double latitude;
|
||||
double longitude;
|
||||
|
|
@ -39,37 +39,38 @@ struct MarkerInfo
|
|||
boost::gil::rgba8_pixel_t iconColor;
|
||||
};
|
||||
|
||||
struct MarkerIconInfo {
|
||||
struct MarkerIconInfo
|
||||
{
|
||||
explicit MarkerIconInfo(types::ImageTexture texture,
|
||||
std::int32_t hotX,
|
||||
std::int32_t hotY) :
|
||||
name{types::GetTextureName(texture)},
|
||||
path{types::GetTexturePath(texture)},
|
||||
hotX{hotX},
|
||||
hotY{hotY},
|
||||
qIcon{QIcon(QString::fromStdString(path))},
|
||||
image{}
|
||||
name {types::GetTextureName(texture)},
|
||||
path {types::GetTexturePath(texture)},
|
||||
hotX {hotX},
|
||||
hotY {hotY},
|
||||
qIcon {QIcon(QString::fromStdString(path))},
|
||||
image {}
|
||||
{
|
||||
}
|
||||
|
||||
explicit MarkerIconInfo(const std::string& path,
|
||||
std::int32_t hotX,
|
||||
std::int32_t hotY,
|
||||
explicit MarkerIconInfo(const std::string& path,
|
||||
std::int32_t hotX,
|
||||
std::int32_t hotY,
|
||||
std::shared_ptr<boost::gil::rgba8_image_t> image) :
|
||||
name{path},
|
||||
path{path},
|
||||
hotX{hotX},
|
||||
hotY{hotY},
|
||||
qIcon{QIcon(QString::fromStdString(path))},
|
||||
image{image}
|
||||
name {path},
|
||||
path {path},
|
||||
hotX {hotX},
|
||||
hotY {hotY},
|
||||
qIcon {QIcon(QString::fromStdString(path))},
|
||||
image {image}
|
||||
{
|
||||
}
|
||||
|
||||
std::string name;
|
||||
std::string path;
|
||||
std::int32_t hotX;
|
||||
std::int32_t hotY;
|
||||
QIcon qIcon;
|
||||
std::string name;
|
||||
std::string path;
|
||||
std::int32_t hotX;
|
||||
std::int32_t hotY;
|
||||
QIcon qIcon;
|
||||
std::optional<std::shared_ptr<boost::gil::rgba8_image_t>> image;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -46,14 +46,12 @@ static const std::unordered_map<ImageTexture, TextureInfo> imageTextureInfo_ {
|
|||
{ImageTexture::LocationMarker,
|
||||
{"images/location-marker", ":/res/textures/images/location-marker.svg"}},
|
||||
{ImageTexture::LocationPin,
|
||||
{"images/location-pin",
|
||||
":/res/icons/font-awesome-6/location-pin.svg"}},
|
||||
{"images/location-pin", ":/res/icons/font-awesome-6/location-pin.svg"}},
|
||||
{ImageTexture::LocationStar,
|
||||
{"images/location-star",
|
||||
":/res/icons/font-awesome-6/star-solid-white.svg"}},
|
||||
{ImageTexture::LocationTent,
|
||||
{"images/location-tent",
|
||||
":/res/icons/font-awesome-6/tent-solid.svg"}},
|
||||
{"images/location-tent", ":/res/icons/font-awesome-6/tent-solid.svg"}},
|
||||
{ImageTexture::MapboxLogo,
|
||||
{"images/mapbox-logo", ":/res/textures/images/mapbox-logo.svg"}},
|
||||
{ImageTexture::MapTilerLogo,
|
||||
|
|
|
|||
|
|
@ -30,10 +30,7 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
|||
class EditMarkerDialog::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl(EditMarkerDialog* self) :
|
||||
self_{self}
|
||||
{
|
||||
}
|
||||
explicit Impl(EditMarkerDialog* self) : self_ {self} {}
|
||||
|
||||
void show_color_dialog();
|
||||
void show_icon_file_dialog();
|
||||
|
|
@ -46,15 +43,15 @@ public:
|
|||
void handle_rejected();
|
||||
|
||||
EditMarkerDialog* self_;
|
||||
QPushButton* deleteButton_;
|
||||
QPushButton* deleteButton_;
|
||||
QIcon get_colored_icon(const types::MarkerIconInfo& marker,
|
||||
const std::string& color);
|
||||
|
||||
std::shared_ptr<manager::MarkerManager> markerManager_ =
|
||||
manager::MarkerManager::Instance();
|
||||
types::MarkerId editId_;
|
||||
bool adding_;
|
||||
std::string setIconOnAdded_{""};
|
||||
bool adding_;
|
||||
std::string setIconOnAdded_ {""};
|
||||
};
|
||||
|
||||
QIcon EditMarkerDialog::Impl::get_colored_icon(
|
||||
|
|
@ -66,9 +63,9 @@ QIcon EditMarkerDialog::Impl::get_colored_icon(
|
|||
}
|
||||
|
||||
EditMarkerDialog::EditMarkerDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
p {std::make_unique<Impl>(this)},
|
||||
ui(new Ui::EditMarkerDialog)
|
||||
QDialog(parent),
|
||||
p {std::make_unique<Impl>(this)},
|
||||
ui(new Ui::EditMarkerDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
|
@ -98,7 +95,7 @@ void EditMarkerDialog::setup(double latitude, double longitude)
|
|||
// By default use foreground color as marker color, mainly so the icons
|
||||
// are vissable in the dropdown menu.
|
||||
QColor color = QWidget::palette().color(QWidget::foregroundRole());
|
||||
p->editId_ = p->markerManager_->add_marker(types::MarkerInfo(
|
||||
p->editId_ = p->markerManager_->add_marker(types::MarkerInfo(
|
||||
"",
|
||||
latitude,
|
||||
longitude,
|
||||
|
|
@ -114,8 +111,7 @@ void EditMarkerDialog::setup(double latitude, double longitude)
|
|||
|
||||
void EditMarkerDialog::setup(types::MarkerId id)
|
||||
{
|
||||
std::optional<types::MarkerInfo> marker =
|
||||
p->markerManager_->get_marker(id);
|
||||
std::optional<types::MarkerInfo> marker = p->markerManager_->get_marker(id);
|
||||
if (!marker)
|
||||
{
|
||||
return;
|
||||
|
|
@ -143,7 +139,7 @@ void EditMarkerDialog::setup(types::MarkerId id)
|
|||
|
||||
types::MarkerInfo EditMarkerDialog::get_marker_info() const
|
||||
{
|
||||
QString colorName = ui->iconColorLineEdit->text();
|
||||
QString colorName = ui->iconColorLineEdit->text();
|
||||
boost::gil::rgba8_pixel_t color =
|
||||
util::color::ToRgba8PixelT(colorName.toStdString());
|
||||
|
||||
|
|
@ -270,7 +266,6 @@ void EditMarkerDialog::Impl::set_icon_color(const std::string& color)
|
|||
|
||||
auto* iconComboBox = self_->ui->iconComboBox;
|
||||
|
||||
|
||||
self_->ui->iconComboBox->clear();
|
||||
for (auto& markerIcon : markerManager_->get_icons())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,10 +32,9 @@ public:
|
|||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
Ui::EditMarkerDialog* ui;
|
||||
Ui::EditMarkerDialog* ui;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue