From 13f504b1af2766d007efdb815ca9c8d658251811 Mon Sep 17 00:00:00 2001 From: tst-basilhuffman Date: Mon, 5 Apr 2021 05:42:12 +0000 Subject: [PATCH] refactored --- .../src/fusion/fusionui/AssetBase.cpp | 6 ++-- .../src/fusion/fusionui/AssetChooser.cpp | 35 +++++-------------- .../src/fusion/gst/gstAssetGroup.cpp | 4 +-- .../src/fusion/gst/gstAssetGroup.h | 2 +- 4 files changed, 14 insertions(+), 33 deletions(-) diff --git a/earth_enterprise/src/fusion/fusionui/AssetBase.cpp b/earth_enterprise/src/fusion/fusionui/AssetBase.cpp index f9bf760093..e53d45ec93 100644 --- a/earth_enterprise/src/fusion/fusionui/AssetBase.cpp +++ b/earth_enterprise/src/fusion/fusionui/AssetBase.cpp @@ -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); } diff --git a/earth_enterprise/src/fusion/fusionui/AssetChooser.cpp b/earth_enterprise/src/fusion/fusionui/AssetChooser.cpp index 1497ea64de..c96a648d3a 100644 --- a/earth_enterprise/src/fusion/fusionui/AssetChooser.cpp +++ b/earth_enterprise/src/fusion/fusionui/AssetChooser.cpp @@ -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); @@ -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; } } @@ -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(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; @@ -420,9 +404,8 @@ const gstAssetFolder& AssetChooser::getFolder() const { void AssetChooser::selectItem(QIconViewItem* item) { AssetItem* assetItem = dynamic_cast(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); } } diff --git a/earth_enterprise/src/fusion/gst/gstAssetGroup.cpp b/earth_enterprise/src/fusion/gst/gstAssetGroup.cpp index d24cef3c10..07116bbd3c 100644 --- a/earth_enterprise/src/fusion/gst/gstAssetGroup.cpp +++ b/earth_enterprise/src/fusion/gst/gstAssetGroup.cpp @@ -53,6 +53,7 @@ bool isAssetPath(const QString& str) { ".*\\.kdatabase$|" ".*\\.km(layer|project|database|mdatabase)|" ".*\\.kvlayer", true, false); + return rx.exactMatch(str); } @@ -63,9 +64,6 @@ gstAssetHandleImpl::gstAssetHandleImpl(const gstAssetFolder& f, : parent_folder_(f), name_(n) { } -gstAssetHandleImpl::~gstAssetHandleImpl() { -} - const gstAssetFolder &gstAssetHandleImpl::getParentFolder() const { return parent_folder_; } diff --git a/earth_enterprise/src/fusion/gst/gstAssetGroup.h b/earth_enterprise/src/fusion/gst/gstAssetGroup.h index cb852b822f..fa38652fae 100644 --- a/earth_enterprise/src/fusion/gst/gstAssetGroup.h +++ b/earth_enterprise/src/fusion/gst/gstAssetGroup.h @@ -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;