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

fix jumbled text in popups #1929

Merged
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
37 changes: 15 additions & 22 deletions earth_enterprise/src/fusion/fusionui/AssetChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@

#include "fusion/fusionui/AssetChooser.h"

#include <list>

#include <Qt/qstring.h>
#include <Qt/qlineedit.h>
#include <Qt/qpushbutton.h>
#include <Qt/qcombobox.h>
#include <Qt/qmessagebox.h>
#include <Qt/q3iconview.h>
//#include <qiconview.h>
#include <Qt/qinputdialog.h>
#include <Qt/qapplication.h>
#include <Qt/qcoreevent.h>
Expand Down Expand Up @@ -62,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 @@ -84,13 +81,8 @@ class AssetItem : public QIconViewItem {
AssetItem::AssetItem(QIconView* parent, gstAssetHandle handle)
: QIconViewItem(parent), assetHandle(handle) {

auto name = handle->getName().toStdString();
auto pos = name.rfind('.');
if (pos != std::string::npos)
{
name = name.substr(0,pos);
}
setText(name.c_str());
auto saname = shortAssetName(handle->getName());
setText(saname);

Asset asset = handle->getAsset();
AssetDisplayHelper a(asset->type, asset->subtype);
Expand Down Expand Up @@ -179,9 +171,8 @@ AssetChooser::AssetChooser(
}

// Insert compatible asset items in view filter combobox of OpenDialog.
for (size_t i = 0; i < compatible_asset_defs.size(); ++i) {
const AssetCategoryDef& asset_category_def = compatible_asset_defs[i];
AssetDisplayHelper adh(asset_category_def.type, asset_category_def.subtype);
for (const auto& i : compatible_asset_defs) {
AssetDisplayHelper adh(i.type, i.subtype);
compatible_asset_types_.push_back(adh);
filterCombo->insertItem(adh.GetPixmap(), adh.PrettyName());
}
Expand Down Expand Up @@ -249,8 +240,9 @@ bool AssetChooser::matchFilter(const gstAssetHandle handle) const {

if (match_string_ == all_compatible_assets_filter_text_) {
assert(!all_compatible_assets_filter_text_.empty());
for (size_t i = 0; i < compatible_asset_types_.size(); ++i) {
if (a.PrettyName() == compatible_asset_types_[i].PrettyName())

for (const auto& i : compatible_asset_types_) {
if (a.PrettyName() == i.PrettyName())
return true;
}
return false;
Expand Down Expand Up @@ -315,9 +307,10 @@ void AssetChooser::accept() {
// here
AssetItem* assetItem = dynamic_cast<AssetItem*>(item);
if (assetItem != NULL) {
std::string temp { shortAssetName(assetItem->getAssetHandle()->getName()
.toStdString().c_str()) };
nameEdit->setText(temp.c_str());
// std::string temp { shortAssetName(assetItem->getAssetHandle()->getName()
tst-basilhuffman marked this conversation as resolved.
Show resolved Hide resolved
// .toStdString().c_str()) };
auto saname = shortAssetName(assetItem->getAssetHandle()->getName());
nameEdit->setText(saname);
gstAssetHandle asset_handle = assetItem->getAssetHandle();
Asset asset = asset_handle->getAsset();
type_ = asset->type;
Expand Down Expand Up @@ -502,9 +495,9 @@ void AssetChooser::updateView(const gstAssetFolder& folder) {
// first add all folders
//
std::vector<gstAssetFolder> folders = folder.getAssetFolders();
for (std::vector<gstAssetFolder>::iterator it = folders.begin();
it != folders.end(); ++it) {
(void)new FolderItem(iconView, *it);

for (const auto& it : folders) {
(void)new FolderItem(iconView, it);
}

//
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
65 changes: 33 additions & 32 deletions earth_enterprise/src/fusion/fusionui/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ void AssetFolder::setOpen(bool o) {

void AssetFolder::populate() {
std::vector<gstAssetFolder> folders = folder.getAssetFolders();
std::vector<gstAssetFolder>::iterator it = folders.begin();
for (; it != folders.end(); ++it) {
(void)new AssetFolder(this, *it);

for (const auto& it : folders) {
(void)new AssetFolder(this, it);
}
}

Expand Down Expand Up @@ -267,9 +267,9 @@ static QPixmap uic_load_pixmap_AssetManager(const QString& name) {
}

bool DatabaseHasValidVersion(const Asset &asset) {
AssetStorage::VersionList::const_iterator version = asset->versions.begin();
for (; version != asset->versions.end(); ++version) {
AssetVersion asset_version(*version);

for (const auto& version : asset->versions) {
AssetVersion asset_version(version);
if (asset_version->state != AssetDefs::Succeeded)
continue;
if (asset_version->subtype == kMapDatabaseSubtype) {
Expand Down Expand Up @@ -519,8 +519,8 @@ AssetManager::AssetManager(QWidget* parent)
{
gstProviderSet providers;
if (providers.Load()) {
for (unsigned int i = 0; i < providers.items.size(); ++i) {
provider_map_[providers.items[i].id] = providers.items[i].key;
for (const auto& it : providers.items) {
provider_map_[it.id] = it.key;
}
}
}
Expand Down Expand Up @@ -1016,7 +1016,10 @@ void AssetManager::ShowAssetMenu(const gstAssetHandle& asset_handle,
// first item in menu should be the asset name since the table
// might get redrawn after the menu has popped-up
AssetDisplayHelper a(current_asset->type, current_asset->subtype);
menu.insertItem(a.GetPixmap(), shortAssetName(asset_handle->getName().toUtf8().constData()));

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

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

menu.insertSeparator();
menu.insertSeparator();
Expand Down Expand Up @@ -1194,10 +1197,9 @@ void AssetManager::PushDatabase(const gstAssetHandle& handle) {
}

std::vector<QString> nicknames;
std::vector<ServerCombination>::const_iterator it =
sc_set.combinations.begin();
for (; it != sc_set.combinations.end(); ++it) {
nicknames.push_back(it->nickname);

for (const auto& it : sc_set.combinations) {
nicknames.push_back(it.nickname);
}

PushDatabaseDialog push_db_dlg(this, asset, nicknames);
Expand Down Expand Up @@ -1235,14 +1237,14 @@ 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;
for (it = sc_set.combinations.begin();
it != sc_set.combinations.end(); ++it) {
if (nickname == it->nickname) {
stream_server = it->stream;

for (const auto& it : sc_set.combinations) {
if (nickname == it.nickname) {
stream_server = it.stream;
search_server = stream_server;
break;
}
Expand Down Expand Up @@ -1327,10 +1329,9 @@ void AssetManager::PublishDatabase(const gstAssetHandle& handle) {
}

std::vector<QString> nicknames;
std::vector<ServerCombination>::const_iterator it =
sc_set.combinations.begin();
for (; it != sc_set.combinations.end(); ++it) {
nicknames.push_back(it->nickname);

for (const auto& it : sc_set.combinations) {
nicknames.push_back(it.nickname);
}


Expand Down Expand Up @@ -1370,14 +1371,14 @@ 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;
for (it = sc_set.combinations.begin();
it != sc_set.combinations.end(); ++it) {
if (nickname == it->nickname) {
stream_server = it->stream;

for (const auto& it : sc_set.combinations) {
if (nickname == it.nickname) {
stream_server = it.stream;
search_server = stream_server;
break;
}
Expand Down Expand Up @@ -1621,10 +1622,10 @@ void AssetManager::assetsChanged(const AssetChanges& changes) {

// check to see if any of the changes are in this directory
std::set<std::string> changedHere;
for (AssetChanges::CIterator i = changes.items.begin();
i != changes.items.end(); ++i) {
if (khDirname(i->ref) == curr) {
changedHere.insert(AssetVersionRef(i->ref).AssetRef());

for(const auto& i : changes.items) {
if (khDirname(i.ref) == curr) {
changedHere.insert(AssetVersionRef(i.ref).AssetRef());
}
}

Expand Down Expand Up @@ -1810,7 +1811,7 @@ void AssetManager::UpdateTableItem(int row, gstAssetHandle handle,
int bpos = aname.rfind('/') + 1, epos = aname.rfind('.');
aname = aname.substr(bpos,epos-bpos);

if (aname != std::string(assetTableView->GetItem(i)->text().toUtf8().constData()))
if (aname != assetTableView->GetItem(i)->text().toStdString())
{
assetTableView->GetItem(i)->setText(aname.c_str());
}
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
Loading