Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Issue #1946 Fixed mangled text issue for FusionUI (#1947)
Browse files Browse the repository at this point in the history
  • Loading branch information
tst-ccamp authored Apr 19, 2021
1 parent 97bbe67 commit ff22053
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 41 deletions.
10 changes: 6 additions & 4 deletions earth_enterprise/src/fusion/fusionui/AssetChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class FolderItem : public QIconViewItem {

FolderItem::FolderItem(QIconView* parent, const gstAssetFolder& f)
: QIconViewItem(parent), folder(f) {
setText(shortAssetName(f.name()));
std::string san = shortAssetName(f.name());
setText(san.c_str());
AssetDisplayHelper a(AssetDefs::Invalid, std::string());
setPixmap(a.GetPixmap());
setKey(QString("0" + text()));
Expand All @@ -82,7 +83,7 @@ AssetItem::AssetItem(QIconView* parent, gstAssetHandle handle)
: QIconViewItem(parent), assetHandle(handle) {

auto saname = shortAssetName(handle->getName());
setText(saname);
setText(saname.c_str());

Asset asset = handle->getAsset();
AssetDisplayHelper a(asset->type, asset->subtype);
Expand Down Expand Up @@ -308,7 +309,7 @@ void AssetChooser::accept() {
AssetItem* assetItem = dynamic_cast<AssetItem*>(item);
if (assetItem != NULL) {
auto saname = shortAssetName(assetItem->getAssetHandle()->getName());
nameEdit->setText(saname);
nameEdit->setText(saname.c_str());
gstAssetHandle asset_handle = assetItem->getAssetHandle();
Asset asset = asset_handle->getAsset();
type_ = asset->type;
Expand Down Expand Up @@ -427,8 +428,9 @@ void AssetChooser::nameChanged(const QString& str) {
if (item != NULL) {
// If name doesn't match with current item, then clear selection.
AssetItem* assetItem = dynamic_cast<AssetItem*>(item);
std::string san = shortAssetName(assetItem->getAssetHandle()->getName().toStdString().c_str());
if (assetItem != NULL &&
getName() != shortAssetName(assetItem->getAssetHandle()->getName().toUtf8().constData())) {
getName() != san.c_str()) {
iconView->clearSelection();
}
}
Expand Down
4 changes: 2 additions & 2 deletions earth_enterprise/src/fusion/fusionui/AssetIconView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ AssetIcon::AssetIcon(QIconView* parent, gstAssetHandle handle, int initsz)
if (defaultImage == NULL)
defaultImage = new QImage(uic_load_pixmap("preview_default.png").
convertToImage());
auto name = shortAssetName(handle->getName());
setText(name);
std::string name = shortAssetName(handle->getName());
setText(name.c_str());

QImage img;
AssetVersion ver(handle->getAsset()->CurrVersionRef());
Expand Down
3 changes: 2 additions & 1 deletion earth_enterprise/src/fusion/fusionui/AssetProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ AssetProperties::AssetProperties( QWidget* parent, const gstAssetHandle &handle
versionsList->setSorting( 0, false );

Asset asset = handle->getAsset();
nameLabel->setText( shortAssetName( handle->getName()) );
std::string san = shortAssetName( handle->getName());
nameLabel->setText( san.c_str() );
typeLabel->setText( ToString( asset->type ).c_str() );
subTypeLabel->setText( asset->PrettySubtype().c_str() );

Expand Down
3 changes: 2 additions & 1 deletion earth_enterprise/src/fusion/fusionui/AssetTableView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ AssetTableItem::AssetTableItem(QTable* table, gstAssetHandle handle)
Asset asset = handle->getAsset();
AssetDisplayHelper a(asset->type, asset->PrettySubtype());
setPixmap(a.GetPixmap());
setText(shortAssetName(handle->getName()));
std::string san = shortAssetName(handle->getName());
setText(san.c_str());
}

AssetTableItem::~AssetTableItem() {
Expand Down
19 changes: 12 additions & 7 deletions earth_enterprise/src/fusion/fusionui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void DatabaseWidget::Prefill(const DatabaseEditRequest& request) {

if (request.config.vectorProject.size() != 0) {
projects.push_back(request.config.vectorProject);
vector_project_label->setText(shortAssetName(request.config.vectorProject));
std::string san = shortAssetName(request.config.vectorProject);
vector_project_label->setText(san.c_str());
} else {
vector_project_label->setText(empty_text);
}
Expand All @@ -49,14 +50,16 @@ void DatabaseWidget::Prefill(const DatabaseEditRequest& request) {
} else {
if (request.config.imageryProject.size() != 0) {
projects.push_back(request.config.imageryProject);
imagery_project_label->setText(shortAssetName(request.config.imageryProject));
std::string san = shortAssetName(request.config.imageryProject);
imagery_project_label->setText(san.c_str());
} else {
imagery_project_label->setText(empty_text);
}

if (request.config.terrainProject.size() != 0) {
projects.push_back(request.config.terrainProject);
terrain_project_label->setText(shortAssetName(request.config.terrainProject));
std::string san = shortAssetName(request.config.terrainProject);
terrain_project_label->setText(san.c_str());
} else {
terrain_project_label->setText(empty_text);
}
Expand Down Expand Up @@ -97,7 +100,8 @@ void DatabaseWidget::ChooseVectorProject() {
if (!chooser.getFullPath(newpath))
return;

vector_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
vector_project_label->setText(san.c_str());
}

void DatabaseWidget::ChooseImageryProject() {
Expand All @@ -110,7 +114,8 @@ void DatabaseWidget::ChooseImageryProject() {
if (!chooser.getFullPath(newpath))
return;

imagery_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
imagery_project_label->setText(san.c_str());
}

void DatabaseWidget::ChooseTerrainProject() {
Expand All @@ -122,8 +127,8 @@ void DatabaseWidget::ChooseTerrainProject() {
QString newpath;
if (!chooser.getFullPath(newpath))
return;

terrain_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
terrain_project_label->setText(san.c_str());
}

void DatabaseWidget::ClearVectorProject() {
Expand Down
3 changes: 2 additions & 1 deletion earth_enterprise/src/fusion/fusionui/LayerProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ LayerProperties::LayerProperties(QWidget* parent, const LayerConfig& config,
layer_config_.AssignUuidIfEmpty();

uuidEdit->setText(layer_config_.asset_uuid_.c_str());
assetNameLabel->setText(shortAssetName(layer_config_.assetRef));
std::string san = shortAssetName(layer_config_.assetRef);
assetNameLabel->setText(san.c_str());
preserveTextSpin->setValue(layer_config_.preserveTextLevel);
isVisibleCheck->setChecked(layer_config_.isVisible);

Expand Down
14 changes: 9 additions & 5 deletions earth_enterprise/src/fusion/fusionui/MapDatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ MapDatabaseWidget::MapDatabaseWidget(QWidget* parent, AssetBase* base)

void MapDatabaseWidget::Prefill(const MapDatabaseEditRequest& request) {
std::vector<std::string> projects;
std::string san;

if (request.config.mapProject.size() != 0) {
projects.push_back(request.config.mapProject);
map_project_label->setText(shortAssetName(request.config.mapProject));
san = shortAssetName(request.config.mapProject);
map_project_label->setText(san.c_str());
} else {
map_project_label->setText(empty_text);
}
Expand All @@ -52,8 +54,8 @@ void MapDatabaseWidget::Prefill(const MapDatabaseEditRequest& request) {
} else {
if (request.config.imageryProject.size() != 0) {
projects.push_back(request.config.imageryProject);
imagery_project_label->setText(
shortAssetName(request.config.imageryProject));
san = shortAssetName(request.config.imageryProject);
imagery_project_label->setText(san.c_str());
} else {
imagery_project_label->setText(empty_text);
}
Expand Down Expand Up @@ -107,7 +109,8 @@ void MapDatabaseWidget::ChooseMapProject() {
if (!chooser.getFullPath(newpath))
return;

map_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
map_project_label->setText(san.c_str());
}

void MapDatabaseWidget::ChooseImageryProject() {
Expand All @@ -120,7 +123,8 @@ void MapDatabaseWidget::ChooseImageryProject() {
if (!chooser.getFullPath(newpath))
return;

imagery_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
imagery_project_label->setText(san.c_str());
}

void MapDatabaseWidget::ClearMapProject() {
Expand Down
8 changes: 5 additions & 3 deletions earth_enterprise/src/fusion/fusionui/MapProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,21 @@ MapLayerItem::MapLayerItem(Q3ListView* parent,

void MapLayerItem::Init() {
MapLayerAsset layer_asset(layer_item_config_.assetRef);
std::string san;
if (layer_asset) {
if (layer_item_config_.legend.UseDefault()) {
setText(0, layer_asset->config.legend.defaultLocale.name + "<DEFAULT>");
} else {
setText(0, layer_item_config_.legend.GetValue().defaultLocale.name);
}

setText(1, shortAssetName(layer_item_config_.assetRef));
san = shortAssetName(layer_item_config_.assetRef);
setText(1, san.c_str());
AssetDisplayHelper a(layer_asset->type, layer_asset->subtype);
setPixmap(1, a.GetPixmap());
} else {
setText(0, "<INVALID>");
setText(1, shortAssetName(layer_item_config_.assetRef));
san = shortAssetName(layer_item_config_.assetRef);
setText(1, san.c_str());
setPixmap(1, AssetDisplayHelper::Pixmap(AssetDisplayHelper::Key_Unknown));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void MercatorMapDatabaseWidget::Prefill(const MapDatabaseEditRequest& request) {

if (request.config.mapProject.size() != 0) {
projects.push_back(request.config.mapProject);
map_project_label->setText(shortAssetName(request.config.mapProject));
std::string san = shortAssetName(request.config.mapProject);
map_project_label->setText(san.c_str());
} else {
map_project_label->setText(empty_text);
}
Expand Down Expand Up @@ -112,8 +113,8 @@ void MercatorMapDatabaseWidget::ChooseMapProject() {
QString newpath;
if (!chooser.getFullPath(newpath))
return;

map_project_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
map_project_label->setText(san.c_str());
}

void MercatorMapDatabaseWidget::ChooseImageryProject() {
Expand Down Expand Up @@ -153,6 +154,7 @@ void MercatorMapDatabaseWidget::SetImageryProject(const QString& path) {
ClearImageryProject();
} else {
imagery_project_path_ = path;
imagery_project_label->setText(shortAssetName(imagery_project_path_));
std::string san = shortAssetName(imagery_project_path_);
imagery_project_label->setText(san.c_str());
}
}
6 changes: 4 additions & 2 deletions earth_enterprise/src/fusion/fusionui/ProjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,8 @@ void ProjectManager::AddAssetLayer(const char* assetname) {
isasset);
if (newsource) {
std::string basename = khBasename(asset->GetRef().toString());
QString layername = shortAssetName(basename);
std::string san = shortAssetName(basename);
QString layername(san.c_str());
gstLayer* layer = CreateNewLayer(layername,
newsource, 0 /* src layer num */,
asset->GetRef());
Expand Down Expand Up @@ -2281,8 +2282,9 @@ void ProjectManager::contentsDropEvent(QDropEvent* e) {
if (ver) {
AddAssetLayer(it->latin1());
} else {
std::string san = shortAssetName(*it);
nogoodversions += QString(" " )
+ QString(shortAssetName(*it))
+ QString(san.c_str())
+ QString("\n");
}
}
Expand Down
3 changes: 2 additions & 1 deletion earth_enterprise/src/fusion/fusionui/RasterProjectWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ QString RasterLayerItem::text(int col) const {
config_.overridemax));
}

return QString(shortAssetName(config_.dataAsset)) + level;
std::string san = shortAssetName(config_.dataAsset);
return QString(san.c_str()) + level;
} else {
return QString();
}
Expand Down
6 changes: 4 additions & 2 deletions earth_enterprise/src/fusion/fusionui/VectorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void VectorLayerWidget::Prefill(const VectorLayerXEditRequest& req) {
if (req.config.vectorResource.empty()) {
vector_resource_label->setText(empty_text);
} else {
vector_resource_label->setText(shortAssetName(req.config.vectorResource));
std::string san = shortAssetName(req.config.vectorResource);
vector_resource_label->setText(san.c_str());
}
}

Expand All @@ -66,7 +67,8 @@ void VectorLayerWidget::chooseVectorResource() {
if (!chooser.getFullPath(newpath))
return;

vector_resource_label->setText(shortAssetName(newpath));
std::string san = shortAssetName(newpath);
vector_resource_label->setText(san.c_str());
}

// ****************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion earth_enterprise/src/fusion/fusionui/VectorProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void VectorLayerItem::Init() {

setText(0, layer_config_.defaultLocale.name_);

setText(1, shortAssetName(layer_config_.assetRef));
std::string san = shortAssetName(layer_config_.assetRef);
setText(1, san.c_str());

std::vector< unsigned int> fill_rgba, outline_rgba;
for (std::vector<DisplayRuleConfig>::iterator rule = layer_config_.displayRules.begin();
Expand Down
8 changes: 4 additions & 4 deletions earth_enterprise/src/fusion/gst/gstAssetGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "gstAssetGroup.h"


const char* shortAssetName(const char* n) {
std::string shortAssetName(const char* n) {

static const std::vector<std::string> suffixes =
{
Expand Down Expand Up @@ -53,15 +53,15 @@ const char* shortAssetName(const char* n) {
}
}

return saname.c_str();
return saname;
}

const char* shortAssetName(const std::string& str)
std::string shortAssetName(const std::string& str)
{
return shortAssetName(str.c_str());
}

const char* shortAssetName(const QString& str)
std::string shortAssetName(const QString& str)
{
return shortAssetName(str.toStdString().c_str());
}
Expand Down
6 changes: 3 additions & 3 deletions earth_enterprise/src/fusion/gst/gstAssetGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class gstAssetHandleImpl;

typedef khRefGuard<gstAssetHandleImpl> gstAssetHandle;

const char* shortAssetName(const char*);
const char* shortAssetName(const std::string&);
const char* shortAssetName(const QString&);
std::string shortAssetName(const char*);
std::string shortAssetName(const std::string&);
std::string shortAssetName(const QString&);
bool isAssetPath(const QString&);

// -----------------------------------------------------------------------------
Expand Down

0 comments on commit ff22053

Please sign in to comment.