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

Commit

Permalink
overloaded shortAssetName
Browse files Browse the repository at this point in the history
  • Loading branch information
tst-basilhuffman committed Apr 5, 2021
1 parent f9cd854 commit 5933db3
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion earth_enterprise/src/fusion/fusionui/AssetBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void AssetBase::InstallMainWidget() {
void AssetBase::SetName(const QString& text) {
asset_path_ = text;
std::string pretty_name { AssetPrettyName().toStdString() };
std::string short_name { shortAssetName(text.toUtf8().constData()) };
std::string short_name { shortAssetName(text) };

setCaption(QString(pretty_name.c_str()) + " : " + short_name.c_str());
emit NameChanged(text);
Expand Down
4 changes: 2 additions & 2 deletions earth_enterprise/src/fusion/fusionui/AssetChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FolderItem : public QIconViewItem {

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

auto name = handle->getName().toStdString();
auto pos = name.rfind('.');
auto test = shortAssetName(name.c_str());
auto test = shortAssetName(name);
if (pos != std::string::npos)
{
name = name.substr(0,pos);
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());

setText(shortAssetName(handle->getName().toUtf8().constData()));
auto name = shortAssetName(handle->getName());
setText(name);

QImage img;
AssetVersion ver(handle->getAsset()->CurrVersionRef());
Expand Down
6 changes: 3 additions & 3 deletions earth_enterprise/src/fusion/fusionui/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ void AssetManager::ShowAssetMenu(const gstAssetHandle& asset_handle,
// might get redrawn after the menu has popped-up
AssetDisplayHelper a(current_asset->type, current_asset->subtype);

std::string shortName = shortAssetName(asset_handle->getName().toStdString().c_str());
std::string shortName = shortAssetName(asset_handle->getName());

menu.insertItem(a.GetPixmap(), shortName.c_str());

Expand Down Expand Up @@ -1237,7 +1237,7 @@ void AssetManager::PushDatabase(const gstAssetHandle& handle) {
// Update the preferences with the user's choice. We want to remember these
// choices so that we can automatically select this server next time they
// push/publish.
std::string database_name = shortAssetName(asset->GetRef().toString().c_str());
std::string database_name = shortAssetName(asset->GetRef().toString());
Preferences::UpdatePublishServerDbMap(database_name, nickname.toUtf8().constData());

ServerConfig stream_server, search_server;
Expand Down Expand Up @@ -1371,7 +1371,7 @@ void AssetManager::PublishDatabase(const gstAssetHandle& handle) {
// Update the preferences with the user's choice. We want to remember these
// choices so that we can automatically select this server next time they
// push/publish.
std::string database_name = shortAssetName(asset->GetRef().toString().c_str());
std::string database_name = shortAssetName(asset->GetRef().toString());
Preferences::UpdatePublishServerDbMap(database_name, nickname.toUtf8().constData());

ServerConfig stream_server, search_server;
Expand Down
2 changes: 1 addition & 1 deletion earth_enterprise/src/fusion/fusionui/AssetProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ AssetProperties::AssetProperties( QWidget* parent, const gstAssetHandle &handle
versionsList->setSorting( 0, false );

Asset asset = handle->getAsset();
nameLabel->setText( shortAssetName( handle->getName().toUtf8().constData() ) );
nameLabel->setText( shortAssetName( handle->getName()) );
typeLabel->setText( ToString( asset->type ).c_str() );
subTypeLabel->setText( asset->PrettySubtype().c_str() );

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

AssetTableItem::~AssetTableItem() {
Expand Down
12 changes: 6 additions & 6 deletions earth_enterprise/src/fusion/fusionui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ 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.c_str()));
vector_project_label->setText(shortAssetName(request.config.vectorProject));
} else {
vector_project_label->setText(empty_text);
}
Expand All @@ -49,14 +49,14 @@ 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.c_str()));
imagery_project_label->setText(shortAssetName(request.config.imageryProject));
} 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.c_str()));
terrain_project_label->setText(shortAssetName(request.config.terrainProject));
} else {
terrain_project_label->setText(empty_text);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ void DatabaseWidget::ChooseVectorProject() {
if (!chooser.getFullPath(newpath))
return;

vector_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
vector_project_label->setText(shortAssetName(newpath));
}

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

imagery_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
imagery_project_label->setText(shortAssetName(newpath));
}

void DatabaseWidget::ChooseTerrainProject() {
Expand All @@ -123,7 +123,7 @@ void DatabaseWidget::ChooseTerrainProject() {
if (!chooser.getFullPath(newpath))
return;

terrain_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
terrain_project_label->setText(shortAssetName(newpath));
}

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

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

Expand Down
8 changes: 4 additions & 4 deletions earth_enterprise/src/fusion/fusionui/MapDatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void MapDatabaseWidget::Prefill(const MapDatabaseEditRequest& request) {

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

map_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
map_project_label->setText(shortAssetName(newpath));
}

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

imagery_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
imagery_project_label->setText(shortAssetName(newpath));
}

void MapDatabaseWidget::ClearMapProject() {
Expand Down
4 changes: 2 additions & 2 deletions earth_enterprise/src/fusion/fusionui/MapProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ void MapLayerItem::Init() {
setText(0, layer_item_config_.legend.GetValue().defaultLocale.name);
}

setText(1, shortAssetName(layer_item_config_.assetRef.c_str()));
setText(1, shortAssetName(layer_item_config_.assetRef));
AssetDisplayHelper a(layer_asset->type, layer_asset->subtype);
setPixmap(1, a.GetPixmap());
} else {
setText(0, "<INVALID>");
setText(1, shortAssetName(layer_item_config_.assetRef.c_str()));
setText(1, shortAssetName(layer_item_config_.assetRef));
setPixmap(1, AssetDisplayHelper::Pixmap(AssetDisplayHelper::Key_Unknown));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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.c_str()));
map_project_label->setText(shortAssetName(request.config.mapProject));
} else {
map_project_label->setText(empty_text);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ void MercatorMapDatabaseWidget::ChooseMapProject() {
if (!chooser.getFullPath(newpath))
return;

map_project_label->setText(shortAssetName(newpath.toUtf8().constData()));
map_project_label->setText(shortAssetName(newpath));
}

void MercatorMapDatabaseWidget::ChooseImageryProject() {
Expand Down Expand Up @@ -153,6 +153,6 @@ void MercatorMapDatabaseWidget::SetImageryProject(const QString& path) {
ClearImageryProject();
} else {
imagery_project_path_ = path;
imagery_project_label->setText(shortAssetName(imagery_project_path_.toUtf8().constData()));
imagery_project_label->setText(shortAssetName(imagery_project_path_));
}
}
6 changes: 3 additions & 3 deletions earth_enterprise/src/fusion/fusionui/ProjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ void ProjectManager::AddAssetLayer(const char* assetname) {
isasset);
if (newsource) {
std::string basename = khBasename(asset->GetRef().toString());
QString layername = shortAssetName(basename.c_str());
QString layername = shortAssetName(basename);
gstLayer* layer = CreateNewLayer(layername,
newsource, 0 /* src layer num */,
asset->GetRef());
Expand Down Expand Up @@ -2279,10 +2279,10 @@ void ProjectManager::contentsDropEvent(QDropEvent* e) {
Asset asset(AssetDefs::FilenameToAssetPath(it->toUtf8().constData()));
AssetVersion ver(asset->GetLastGoodVersionRef());
if (ver) {
AddAssetLayer((*it).latin1());
AddAssetLayer(it->latin1());
} else {
nogoodversions += QString(" " )
+ QString(shortAssetName(it->toUtf8().constData()))
+ QString(shortAssetName(*it))
+ QString("\n");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PushDatabaseDialog::PushDatabaseDialog(
const std::vector<QString>& nicknames)
: PushDatabaseDialogBase(parent, 0, false, 0) {

std::string database_name = shortAssetName(asset->GetRef().toString().c_str());
std::string database_name = shortAssetName(asset->GetRef());
db_name_label->setText(database_name.c_str());

std::vector<QString>::const_iterator nickname = nicknames.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ QString RasterLayerItem::text(int col) const {
config_.overridemax));
}

return QString(shortAssetName(config_.dataAsset.c_str())) + level;
return QString(shortAssetName(config_.dataAsset)) + level;
} else {
return QString();
}
Expand Down
4 changes: 2 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,7 @@ 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.c_str()));
vector_resource_label->setText(shortAssetName(req.config.vectorResource));
}
}

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

vector_resource_label->setText(shortAssetName(newpath.toUtf8().constData()));
vector_resource_label->setText(shortAssetName(newpath));
}

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

setText(0, layer_config_.defaultLocale.name_);

setText(1, shortAssetName(layer_config_.assetRef.c_str()));
setText(1, shortAssetName(layer_config_.assetRef));

std::vector< unsigned int> fill_rgba, outline_rgba;
for (std::vector<DisplayRuleConfig>::iterator rule = layer_config_.displayRules.begin();
Expand Down
10 changes: 10 additions & 0 deletions earth_enterprise/src/fusion/gst/gstAssetGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ const char* shortAssetName(const char* n) {
return saname.c_str();
}

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

const char* shortAssetName(const QString& str)
{
return shortAssetName(str.toStdString().c_str());
}

bool isAssetPath(const QString& str) {
static QRegExp rx(".*\\.k[vit](asset|project)$|"
".*\\.k[i](masset|mproject)$|"
Expand Down
2 changes: 2 additions & 0 deletions earth_enterprise/src/fusion/gst/gstAssetGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class gstAssetHandleImpl;
typedef khRefGuard<gstAssetHandleImpl> gstAssetHandle;

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

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

0 comments on commit 5933db3

Please sign in to comment.