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

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
tst-basilhuffman committed Apr 5, 2021
1 parent f9cd854 commit 13f504b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
6 changes: 3 additions & 3 deletions earth_enterprise/src/fusion/fusionui/AssetBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ 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()) };
auto pretty_name = AssetPrettyName().toStdString().c_str();
auto short_name = shortAssetName(text.toStdString().c_str());

setCaption(QString(pretty_name.c_str()) + " : " + short_name.c_str());
setCaption(QString(pretty_name) + " : " + short_name);
emit NameChanged(text);
}

Expand Down
35 changes: 9 additions & 26 deletions earth_enterprise/src/fusion/fusionui/AssetChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +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('.');
auto test = shortAssetName(name.c_str());
if (pos != std::string::npos)
{
name = name.substr(0,pos);
}
setText(test);
auto saname = shortAssetName(handle->getName().toStdString().c_str());
setText(saname);

Asset asset = handle->getAsset();
AssetDisplayHelper a(asset->type, asset->subtype);
Expand Down Expand Up @@ -290,18 +284,9 @@ void AssetChooser::accept() {
// If name doesn't match with current item name, then reset item
// pointer to initiate searching of item by name below.
auto gname = getName();
std::string san1 { shortAssetName(assetItem->getAssetHandle()
->getName().toUtf8().constData()) } ,
san2 { shortAssetName(assetItem->getAssetHandle()
->getName().toStdString().c_str()) };

if (san1 == san2)
{
gname.clear();
gname = QString(san2.c_str());
}
if (assetItem != NULL && gname != san2.c_str()) {
auto saname = shortAssetName(assetItem->getAssetHandle()->getName().toStdString().c_str());

if (assetItem != NULL && gname != saname) {
item = NULL;
}
}
Expand All @@ -310,12 +295,11 @@ void AssetChooser::accept() {
// Note: means that name have been edited and we try to find item by name.
item = iconView->findItem(getName(), QKeySequence::ExactMatch);
}
// 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());
auto saname = shortAssetName(assetItem->getAssetHandle()->getName().toStdString().c_str());
nameEdit->setText(saname);
gstAssetHandle asset_handle = assetItem->getAssetHandle();
Asset asset = asset_handle->getAsset();
type_ = asset->type;
Expand Down Expand Up @@ -420,9 +404,8 @@ const gstAssetFolder& AssetChooser::getFolder() const {
void AssetChooser::selectItem(QIconViewItem* item) {
AssetItem* assetItem = dynamic_cast<AssetItem*>(item);
if (assetItem != NULL) {
std::string aname { assetItem->getAssetHandle()->getName().toStdString() },
sname { shortAssetName(aname.c_str()) };
nameEdit->setText(sname.c_str());
auto saname = shortAssetName(assetItem->getAssetHandle()->getName().toStdString().c_str());
nameEdit->setText(saname);
}
}

Expand Down
4 changes: 1 addition & 3 deletions earth_enterprise/src/fusion/gst/gstAssetGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bool isAssetPath(const QString& str) {
".*\\.kdatabase$|"
".*\\.km(layer|project|database|mdatabase)|"
".*\\.kvlayer", true, false);

return rx.exactMatch(str);
}

Expand All @@ -63,9 +64,6 @@ gstAssetHandleImpl::gstAssetHandleImpl(const gstAssetFolder& f,
: parent_folder_(f), name_(n) {
}

gstAssetHandleImpl::~gstAssetHandleImpl() {
}

const gstAssetFolder &gstAssetHandleImpl::getParentFolder() const {
return parent_folder_;
}
Expand Down
2 changes: 1 addition & 1 deletion earth_enterprise/src/fusion/gst/gstAssetGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class gstAssetHandleImpl : public khRefCounter {
static inline gstAssetHandle Create(const gstAssetFolder& p,const QString& n) {
return khRefGuardFromNew(new gstAssetHandleImpl(p, n));
}
virtual ~gstAssetHandleImpl();
virtual ~gstAssetHandleImpl() = default;

QString getName() const;
QString fullPath() const;
Expand Down

0 comments on commit 13f504b

Please sign in to comment.