[LYN-3419] Removed now unused viewportSearch from ViewportTitleDlg and all related code.
This commit is contained in:
@@ -63,33 +63,9 @@ inline namespace Helpers
|
||||
}
|
||||
}
|
||||
|
||||
const int SEARCH_BY_NAME = 1;
|
||||
const int SEARCH_BY_TYPE = 2;
|
||||
const int SEARCH_BY_ASSET = 3;
|
||||
const int HIDE_OTHERS = 4;
|
||||
const int FREEZE_OTHERS = 5;
|
||||
const int JUST_SELLECT = 6;
|
||||
const int LOGICAL_AND = 7;
|
||||
const int LOGICAL_OR = 8;
|
||||
const int INPUT_NAMES_FROM_SELECTION = 9;
|
||||
|
||||
CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
|
||||
: QWidget(pParent)
|
||||
, m_searchMode(ESM_BY_NAME)
|
||||
, m_searchResultHandling(ESRH_HIDE_OTHERS)
|
||||
, m_bOR(false)
|
||||
, m_ui(new Ui::ViewportTitleDlg)
|
||||
, m_searchModeActionGroup(nullptr)
|
||||
, m_searchByNameAction(nullptr)
|
||||
, m_searchByTypeAction(nullptr)
|
||||
, m_searchByAssetAction(nullptr)
|
||||
, m_searchResultHandlingActionGroup(nullptr)
|
||||
, m_searchHideOthersAction(nullptr)
|
||||
, m_searchFreezeOthersAction(nullptr)
|
||||
, m_searchJustSelectAction(nullptr)
|
||||
, m_searchMatchTypeActionGroup(nullptr)
|
||||
, m_searchAndAction(nullptr)
|
||||
, m_searchOrAction(nullptr)
|
||||
{
|
||||
auto container = new QWidget(this);
|
||||
m_ui->setupUi(container);
|
||||
@@ -106,9 +82,6 @@ CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent)
|
||||
LoadCustomPresets("AspectRatioPresets", "AspectRatioPreset", m_customAspectRatioPresets);
|
||||
LoadCustomPresets("ResPresets", "ResPreset", m_customResPresets);
|
||||
|
||||
m_ui->m_viewportSearch->setEnabled(false);
|
||||
m_ui->m_viewportSearch->setVisible(false);
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(m_ui->m_fovLabel, &QWidget::customContextMenuRequested, this, &CViewportTitleDlg::PopUpFOVMenu);
|
||||
@@ -142,8 +115,6 @@ void CViewportTitleDlg::OnInitDialog()
|
||||
m_ui->m_titleBtn->setText(m_title);
|
||||
m_ui->m_sizeStaticCtrl->setText(QString());
|
||||
|
||||
UpdateSearchOptionsText();
|
||||
|
||||
m_ui->m_toggleHelpersBtn->setChecked(GetIEditor()->GetDisplaySettings()->IsDisplayHelpers());
|
||||
|
||||
ICVar* pDisplayInfo(gEnv->pConsole->GetCVar("r_displayInfo"));
|
||||
@@ -160,77 +131,6 @@ void CViewportTitleDlg::OnInitDialog()
|
||||
|
||||
m_ui->m_toggleHelpersBtn->setProperty("class", "big");
|
||||
m_ui->m_toggleDisplayInfoBtn->setProperty("class", "big");
|
||||
|
||||
// ON_EN_CHANGE(IDC_VIEWPORT_SEARCH, OnSearchTermChange)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QMenu * CViewportTitleDlg::InitializeViewportSearchMenu()
|
||||
{
|
||||
QMenu* menu = new QMenu(this);
|
||||
|
||||
m_searchByNameAction = menu->addAction(tr("By Name"));
|
||||
m_searchByNameAction->setData(SEARCH_BY_NAME);
|
||||
m_searchByNameAction->setCheckable(true);
|
||||
m_searchByNameAction->setChecked(m_searchMode == ESM_BY_NAME);
|
||||
m_searchByTypeAction = menu->addAction(tr("By Type"));
|
||||
m_searchByTypeAction->setData(SEARCH_BY_TYPE);
|
||||
m_searchByTypeAction->setCheckable(true);
|
||||
m_searchByTypeAction->setChecked(m_searchMode == ESM_BY_TYPE);
|
||||
m_searchByAssetAction = menu->addAction(tr("By Asset"));
|
||||
m_searchByAssetAction->setData(SEARCH_BY_ASSET);
|
||||
m_searchByAssetAction->setCheckable(true);
|
||||
m_searchByAssetAction->setChecked(m_searchMode == ESM_BY_ASSET);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
m_searchHideOthersAction = menu->addAction(tr("Hide others"));
|
||||
m_searchHideOthersAction->setData(HIDE_OTHERS);
|
||||
m_searchHideOthersAction->setCheckable(true);
|
||||
m_searchHideOthersAction->setChecked(m_searchResultHandling == ESRH_HIDE_OTHERS);
|
||||
m_searchFreezeOthersAction = menu->addAction(tr("Freeze others"));
|
||||
m_searchFreezeOthersAction->setData(FREEZE_OTHERS);
|
||||
m_searchFreezeOthersAction->setCheckable(true);
|
||||
m_searchFreezeOthersAction->setChecked(m_searchResultHandling == ESRH_FREEZE_OTHERS);
|
||||
m_searchJustSelectAction = menu->addAction(tr("Just Select"));
|
||||
m_searchJustSelectAction->setData(JUST_SELLECT);
|
||||
m_searchJustSelectAction->setCheckable(true);
|
||||
m_searchJustSelectAction->setChecked(m_searchResultHandling == ESRH_JUST_SELECT);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
m_searchAndAction = menu->addAction(tr("AND"));
|
||||
m_searchAndAction->setData(LOGICAL_AND);
|
||||
m_searchAndAction->setCheckable(true);
|
||||
m_searchAndAction->setChecked(!m_bOR);
|
||||
m_searchOrAction = menu->addAction(tr("OR"));
|
||||
m_searchOrAction->setData(LOGICAL_OR);
|
||||
m_searchOrAction->setCheckable(true);
|
||||
m_searchOrAction->setChecked(m_bOR);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(tr("Input names from selection"))->setData(INPUT_NAMES_FROM_SELECTION);
|
||||
|
||||
// Add the search mode, search result handling, and match type actions to
|
||||
// exclusive action groups so that only one can be checked at a time, and
|
||||
// you can't un-check the active action
|
||||
m_searchModeActionGroup = new QActionGroup(this);
|
||||
m_searchModeActionGroup->setExclusive(true);
|
||||
m_searchModeActionGroup->addAction(m_searchByNameAction);
|
||||
m_searchModeActionGroup->addAction(m_searchByTypeAction);
|
||||
m_searchModeActionGroup->addAction(m_searchByAssetAction);
|
||||
m_searchResultHandlingActionGroup = new QActionGroup(this);
|
||||
m_searchResultHandlingActionGroup->setExclusive(true);
|
||||
m_searchResultHandlingActionGroup->addAction(m_searchHideOthersAction);
|
||||
m_searchResultHandlingActionGroup->addAction(m_searchFreezeOthersAction);
|
||||
m_searchResultHandlingActionGroup->addAction(m_searchJustSelectAction);
|
||||
m_searchMatchTypeActionGroup = new QActionGroup(this);
|
||||
m_searchMatchTypeActionGroup->setExclusive(true);
|
||||
m_searchMatchTypeActionGroup->addAction(m_searchAndAction);
|
||||
m_searchMatchTypeActionGroup->addAction(m_searchOrAction);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -238,8 +138,6 @@ void CViewportTitleDlg::SetTitle(const QString& title)
|
||||
{
|
||||
m_title = title;
|
||||
m_ui->m_titleBtn->setText(m_title);
|
||||
|
||||
m_ui->m_viewportSearch->setVisible(false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -624,339 +522,6 @@ void CViewportTitleDlg::OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::InputNamesToSearchFromSelection()
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
CSelectionGroup* pSelected = pObjMgr->GetSelection();
|
||||
QString names;
|
||||
for (int i = 0; i < pSelected->GetCount(); ++i)
|
||||
{
|
||||
names += pSelected->GetObject(i)->GetName();
|
||||
names += QStringLiteral(" ");
|
||||
}
|
||||
m_ui->m_viewportSearch->setText(names);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::OnViewportSearchButtonClicked(const QAction* clickedAction)
|
||||
{
|
||||
int cmd = clickedAction ? clickedAction->data().toInt() : 0;
|
||||
|
||||
#define ASSIGN(dst, src) do { if ((dst) != (src)) { (dst) = (src); OnSearchTermChange(); } \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
if (cmd == SEARCH_BY_NAME)
|
||||
{
|
||||
ASSIGN(m_searchMode, ESM_BY_NAME);
|
||||
}
|
||||
else if (cmd == SEARCH_BY_TYPE)
|
||||
{
|
||||
ASSIGN(m_searchMode, ESM_BY_TYPE);
|
||||
}
|
||||
else if (cmd == SEARCH_BY_ASSET)
|
||||
{
|
||||
ASSIGN(m_searchMode, ESM_BY_ASSET);
|
||||
}
|
||||
else if (cmd == HIDE_OTHERS)
|
||||
{
|
||||
ASSIGN(m_searchResultHandling, ESRH_HIDE_OTHERS);
|
||||
}
|
||||
else if (cmd == FREEZE_OTHERS)
|
||||
{
|
||||
ASSIGN(m_searchResultHandling, ESRH_FREEZE_OTHERS);
|
||||
}
|
||||
else if (cmd == JUST_SELLECT)
|
||||
{
|
||||
ASSIGN(m_searchResultHandling, ESRH_JUST_SELECT);
|
||||
}
|
||||
else if (cmd == LOGICAL_AND)
|
||||
{
|
||||
ASSIGN(m_bOR, false);
|
||||
}
|
||||
else if (cmd == LOGICAL_OR)
|
||||
{
|
||||
ASSIGN(m_bOR, true);
|
||||
}
|
||||
else if (cmd == INPUT_NAMES_FROM_SELECTION)
|
||||
{
|
||||
InputNamesToSearchFromSelection();
|
||||
m_bOR = true;
|
||||
m_searchOrAction->setChecked(true);
|
||||
OnSearchTermChange();
|
||||
}
|
||||
|
||||
UpdateSearchOptionsText();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::OnViewportSearchClear()
|
||||
{
|
||||
UnhideUnfreezeAll();
|
||||
//clear edit control
|
||||
gSettings.bIsSearchFilterActive = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SetFocusToSearchField()
|
||||
{
|
||||
if (m_ui->m_viewportSearch->isVisible())
|
||||
{
|
||||
m_ui->m_viewportSearch->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::OnSearchTermChange()
|
||||
{
|
||||
// Get individual search terms.
|
||||
const QString searchTerm = m_ui->m_viewportSearch->text();
|
||||
|
||||
if (!searchTerm.isEmpty())
|
||||
{
|
||||
gSettings.bIsSearchFilterActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSettings.bIsSearchFilterActive = false;
|
||||
}
|
||||
|
||||
const int MIN_CHARS_AS_A_SEARCH_TERM = 3;
|
||||
QStringList terms;
|
||||
|
||||
QStringList splitTerms = searchTerm.split(QStringLiteral(" "));
|
||||
for (const QString& term : splitTerms)
|
||||
{
|
||||
if (term.length() >= MIN_CHARS_AS_A_SEARCH_TERM)
|
||||
{
|
||||
terms.append(term);
|
||||
}
|
||||
}
|
||||
|
||||
if (terms.isEmpty())
|
||||
{
|
||||
UnhideUnfreezeAll();
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure to lower case all terms because later we lower case all inputs to compare against
|
||||
for (QString& term : terms)
|
||||
{
|
||||
term = term.toLower();
|
||||
}
|
||||
|
||||
// Perform a search.
|
||||
if (m_searchMode == ESM_BY_NAME)
|
||||
{
|
||||
SearchByName(terms);
|
||||
}
|
||||
else if (m_searchMode == ESM_BY_TYPE)
|
||||
{
|
||||
SearchByType(terms);
|
||||
}
|
||||
else if (m_searchMode == ESM_BY_ASSET)
|
||||
{
|
||||
SearchByAsset(terms);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::UnhideUnfreezeAll()
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
int objCount = pObjMgr->GetObjectCount();
|
||||
CBaseObjectsArray objects;
|
||||
pObjMgr->GetObjects(objects);
|
||||
for (int i = 0; i < objCount; ++i)
|
||||
{
|
||||
CBaseObject* pObject = objects[i];
|
||||
pObjMgr->FreezeObject(pObject, false);
|
||||
pObjMgr->HideObject(pObject, false);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static bool DoesTextSatisfyTerms(const QString& text, const QStringList& terms, bool bOR)
|
||||
{
|
||||
if (bOR) // OR
|
||||
{
|
||||
for (const QString& term : terms)
|
||||
{
|
||||
if (text.contains(term))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else // AND
|
||||
{
|
||||
for (const QString& term : terms)
|
||||
{
|
||||
if (!text.contains(term))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static void HandleMatched(CBaseObject* pObject)
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
|
||||
pObjMgr->FreezeObject(pObject, false);
|
||||
pObjMgr->HideObject(pObject, false);
|
||||
pObjMgr->SelectObject(pObject);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static void HandleFiltered(CBaseObject* pObject, CViewportTitleDlg::ESearchResultHandling searchResultHandling)
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
pObjMgr->UnselectObject(pObject);
|
||||
if (searchResultHandling == CViewportTitleDlg::ESRH_HIDE_OTHERS)
|
||||
{
|
||||
pObjMgr->FreezeObject(pObject, false);
|
||||
pObjMgr->HideObject(pObject, true);
|
||||
}
|
||||
else if (searchResultHandling == CViewportTitleDlg::ESRH_FREEZE_OTHERS)
|
||||
{
|
||||
pObjMgr->HideObject(pObject, false);
|
||||
pObjMgr->FreezeObject(pObject, true);
|
||||
}
|
||||
else if (searchResultHandling == CViewportTitleDlg::ESRH_JUST_SELECT)
|
||||
{
|
||||
pObjMgr->FreezeObject(pObject, false);
|
||||
pObjMgr->HideObject(pObject, false);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SearchByType(const QStringList& terms)
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
int objCount = pObjMgr->GetObjectCount();
|
||||
CBaseObjectsArray objects;
|
||||
pObjMgr->GetObjects(objects);
|
||||
for (int i = 0; i < objCount; ++i)
|
||||
{
|
||||
CBaseObject* pObject = objects[i];
|
||||
QString type = pObject->GetTypeDescription();
|
||||
if (DoesTextSatisfyTerms(type.toLower(), terms, m_bOR))
|
||||
{
|
||||
HandleMatched(pObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleFiltered(pObject, m_searchResultHandling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SearchByName(const QStringList& terms)
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
int objCount = pObjMgr->GetObjectCount();
|
||||
CBaseObjectsArray objects;
|
||||
pObjMgr->GetObjects(objects);
|
||||
for (int i = 0; i < objCount; ++i)
|
||||
{
|
||||
CBaseObject* pObject = objects[i];
|
||||
QString name = pObject->GetName();
|
||||
if (DoesTextSatisfyTerms(name.toLower(), terms, m_bOR))
|
||||
{
|
||||
HandleMatched(pObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleFiltered(pObject, m_searchResultHandling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::SearchByAsset(const QStringList& terms)
|
||||
{
|
||||
IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
|
||||
int objCount = pObjMgr->GetObjectCount();
|
||||
CBaseObjectsArray objects;
|
||||
pObjMgr->GetObjects(objects);
|
||||
for (int i = 0; i < objCount; ++i)
|
||||
{
|
||||
CBaseObject* pObject = objects[i];
|
||||
CUsedResources usedAssets;
|
||||
pObject->GatherUsedResources(usedAssets);
|
||||
CUsedResources::TResourceFiles::const_iterator itr = usedAssets.files.begin(),
|
||||
end = usedAssets.files.end();
|
||||
bool bMatch = false;
|
||||
for (; itr != end; ++itr)
|
||||
{
|
||||
QString filename = *itr;
|
||||
if (DoesTextSatisfyTerms(filename.toLower(), terms, m_bOR))
|
||||
{
|
||||
bMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bMatch)
|
||||
{
|
||||
HandleMatched(pObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleFiltered(pObject, m_searchResultHandling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CViewportTitleDlg::UpdateSearchOptionsText()
|
||||
{
|
||||
QString str = "";
|
||||
|
||||
if (m_searchMode == ESM_BY_NAME)
|
||||
{
|
||||
str += tr("By Name");
|
||||
}
|
||||
else if (m_searchMode == ESM_BY_TYPE)
|
||||
{
|
||||
str += tr("By Type");
|
||||
}
|
||||
else //if(m_searchMode == ESM_BY_ASSET)
|
||||
{
|
||||
str += tr("By Asset");
|
||||
}
|
||||
|
||||
if (m_searchResultHandling == ESRH_HIDE_OTHERS)
|
||||
{
|
||||
str += tr(", Hide filtered");
|
||||
}
|
||||
else if (m_searchResultHandling == ESRH_FREEZE_OTHERS)
|
||||
{
|
||||
str += tr(", Freeze filtered");
|
||||
}
|
||||
else if (m_searchResultHandling == ESRH_JUST_SELECT)
|
||||
{
|
||||
str += tr(", Just Select");
|
||||
}
|
||||
|
||||
if (m_bOR)
|
||||
{
|
||||
str += tr(", OR");
|
||||
}
|
||||
else
|
||||
{
|
||||
str += tr(", AND");
|
||||
}
|
||||
|
||||
m_ui->m_viewportSearch->setPlaceholderText(str);
|
||||
}
|
||||
|
||||
void CViewportTitleDlg::LoadCustomPresets(const QString& section, const QString& keyName, QStringList& outCustompresets)
|
||||
{
|
||||
QSettings settings("Amazon", "O3DE"); // Temporary solution until we have the global Settings class.
|
||||
|
||||
Reference in New Issue
Block a user