Added asset lookup by ID, fixed a bug with asset ID display, added "go to parent directory" icon
This commit is contained in:
parent
89d668a810
commit
4f2828e0f8
|
@ -77,5 +77,6 @@
|
|||
<file>icons/Tree_24px.png</file>
|
||||
<file>icons/Gear_16px.png</file>
|
||||
<file>icons/Gear_24px.png</file>
|
||||
<file>icons/ToParentFolder_16px.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
@ -110,9 +111,10 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
|
|||
|
||||
QAction *pDisplayAssetIDsAction = new QAction("Display Asset IDs", this);
|
||||
pDisplayAssetIDsAction->setCheckable(true);
|
||||
connect(pDisplayAssetIDsAction, SIGNAL(toggled(bool)), this, SLOT(SetAssetIdDisplayEnabled(bool)));
|
||||
connect(pDisplayAssetIDsAction, SIGNAL(toggled(bool)), this, SLOT(SetAssetIDDisplayEnabled(bool)));
|
||||
pOptionsMenu->addAction(pDisplayAssetIDsAction);
|
||||
|
||||
pOptionsMenu->addAction("Find Asset by ID", this, SLOT(FindAssetByID()));
|
||||
pOptionsMenu->addAction("Rebuild Database", this, SLOT(RebuildResourceDB()));
|
||||
mpUI->OptionsToolButton->setMenu(pOptionsMenu);
|
||||
|
||||
|
@ -177,7 +179,7 @@ void CResourceBrowser::SetActiveDirectory(CVirtualDirectory *pDir)
|
|||
}
|
||||
}
|
||||
|
||||
void CResourceBrowser::SelectResource(CResourceEntry *pEntry)
|
||||
void CResourceBrowser::SelectResource(CResourceEntry *pEntry, bool ClearFiltersIfNecessary /*= false*/)
|
||||
{
|
||||
ASSERT(pEntry);
|
||||
|
||||
|
@ -191,6 +193,12 @@ void CResourceBrowser::SelectResource(CResourceEntry *pEntry)
|
|||
UpdateFilter();
|
||||
}
|
||||
|
||||
// Change filter
|
||||
if (ClearFiltersIfNecessary && !mpProxyModel->IsTypeAccepted(pEntry->TypeInfo()))
|
||||
{
|
||||
ResetTypeFilter();
|
||||
}
|
||||
|
||||
// Select resource
|
||||
QModelIndex SourceIndex = mpModel->GetIndexForEntry(pEntry);
|
||||
QModelIndex ProxyIndex = mpProxyModel->mapFromSource(SourceIndex);
|
||||
|
@ -416,8 +424,10 @@ void CResourceBrowser::UpdateDescriptionLabel()
|
|||
mpUI->TableDescriptionLabel->setText(Desc);
|
||||
|
||||
// Update clear button status
|
||||
bool EnableClearButton = (!mpUI->SearchBar->text().isEmpty() || mpModel->IsDisplayingUserEntryList() || (mpSelectedDir && !mpSelectedDir->IsRoot()));
|
||||
mpUI->ClearButton->setEnabled(EnableClearButton);
|
||||
bool CanGoUp = (mpSelectedDir && !mpSelectedDir->IsRoot());
|
||||
bool CanClear = (!mpUI->SearchBar->text().isEmpty() || mpModel->IsDisplayingUserEntryList());
|
||||
mpUI->ClearButton->setEnabled(CanGoUp || CanClear);
|
||||
mpUI->ClearButton->setIcon( CanClear ? QIcon(":/icons/X_16px.png") : QIcon(":/icons/ToParentFolder_16px.png") );
|
||||
}
|
||||
|
||||
void CResourceBrowser::SetResourceTreeView()
|
||||
|
@ -581,10 +591,48 @@ void CResourceBrowser::OnResourceSelectionChanged(const QModelIndex& rkNewIndex)
|
|||
emit SelectedResourceChanged(mpSelectedEntry);
|
||||
}
|
||||
|
||||
void CResourceBrowser::SetAssetIdDisplayEnabled(bool Enable)
|
||||
void CResourceBrowser::FindAssetByID()
|
||||
{
|
||||
if (!mpStore)
|
||||
return;
|
||||
|
||||
QString QStringAssetID = QInputDialog::getText(this, "Enter Asset ID", "Enter asset ID:");
|
||||
TString StringAssetID = TO_TSTRING(QStringAssetID);
|
||||
|
||||
if (!StringAssetID.IsEmpty())
|
||||
{
|
||||
EGame Game = mpStore->Game();
|
||||
EIDLength IDLength = CAssetID::GameIDLength(Game);
|
||||
|
||||
if (StringAssetID.IsHexString(false, IDLength * 2))
|
||||
{
|
||||
if (StringAssetID.StartsWith("0x", false))
|
||||
StringAssetID = StringAssetID.ChopFront(2);
|
||||
|
||||
// Find the resource entry
|
||||
CAssetID ID = (IDLength == e32Bit ? StringAssetID.ToInt32(16) : StringAssetID.ToInt64(16));
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(ID);
|
||||
|
||||
if (pEntry)
|
||||
SelectResource(pEntry, true);
|
||||
|
||||
// User entered unrecognized ID
|
||||
else
|
||||
UICommon::ErrorMsg(this, QString("Couldn't find any asset with ID %1").arg(QStringAssetID));
|
||||
}
|
||||
|
||||
// User entered invalid string
|
||||
else
|
||||
UICommon::ErrorMsg(this, "The entered string is not a valid asset ID!");
|
||||
}
|
||||
|
||||
// User entered nothing, don't do anything
|
||||
}
|
||||
|
||||
void CResourceBrowser::SetAssetIDDisplayEnabled(bool Enable)
|
||||
{
|
||||
mpDelegate->SetDisplayAssetIDs(Enable);
|
||||
mpUI->ResourceTableView->repaint();
|
||||
mpModel->RefreshAllIndices();
|
||||
}
|
||||
|
||||
void CResourceBrowser::UpdateStore()
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
~CResourceBrowser();
|
||||
|
||||
void SetActiveDirectory(CVirtualDirectory *pDir);
|
||||
void SelectResource(CResourceEntry *pEntry);
|
||||
void SelectResource(CResourceEntry *pEntry, bool ClearFiltersIfNecessary = false);
|
||||
void SelectDirectory(CVirtualDirectory *pDir);
|
||||
void CreateFilterCheckboxes();
|
||||
|
||||
|
@ -88,7 +88,8 @@ public slots:
|
|||
void OnDirectorySelectionChanged(const QModelIndex& rkNewIndex);
|
||||
void OnDoubleClickTable(QModelIndex Index);
|
||||
void OnResourceSelectionChanged(const QModelIndex& rkNewIndex);
|
||||
void SetAssetIdDisplayEnabled(bool Enable);
|
||||
void FindAssetByID();
|
||||
void SetAssetIDDisplayEnabled(bool Enable);
|
||||
|
||||
void UpdateStore();
|
||||
void SetProjectStore();
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/X_16px.png</normaloff>:/icons/X_16px.png</iconset>
|
||||
<normaloff>:/icons/ToParentFolder_16px.png</normaloff>:/icons/ToParentFolder_16px.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
CVirtualDirectory *pDir = mpModel->IndexDirectory(Index);
|
||||
CResourceEntry *pEntry = mpModel->IndexEntry(Index);
|
||||
|
||||
if (pEntry && HasTypeFilter() && !mTypeFilter.contains(pEntry->TypeInfo()))
|
||||
if (pEntry && !IsTypeAccepted(pEntry->TypeInfo()))
|
||||
return false;
|
||||
|
||||
if (!mSearchString.IsEmpty())
|
||||
|
@ -109,6 +109,11 @@ public:
|
|||
return !mTypeFilter.isEmpty();
|
||||
}
|
||||
|
||||
inline bool IsTypeAccepted(CResTypeInfo *pTypeInfo) const
|
||||
{
|
||||
return mTypeFilter.isEmpty() || mTypeFilter.contains(pTypeInfo);
|
||||
}
|
||||
|
||||
inline void SetSortMode(ESortMode Mode)
|
||||
{
|
||||
if (mSortMode != Mode)
|
||||
|
|
|
@ -274,6 +274,17 @@ int CResourceTableModel::EntryListIndex(CResourceEntry *pEntry)
|
|||
return qLowerBound(mEntries, pEntry) - mEntries.constBegin();
|
||||
}
|
||||
|
||||
void CResourceTableModel::RefreshAllIndices()
|
||||
{
|
||||
int NumRows = rowCount(QModelIndex());
|
||||
int NumCols = columnCount(QModelIndex());
|
||||
|
||||
if (NumRows > 0 && NumCols > 0)
|
||||
{
|
||||
emit dataChanged( index(0,0), index(NumRows-1, NumCols-1) );
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceTableModel::CheckAddDirectory(CVirtualDirectory *pDir)
|
||||
{
|
||||
if (pDir->Parent() == mpCurrentDir)
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
inline QString ModelDescription() const { return mModelDescription; }
|
||||
|
||||
public slots:
|
||||
void RefreshAllIndices();
|
||||
void CheckAddDirectory(CVirtualDirectory *pDir);
|
||||
void CheckRemoveDirectory(CVirtualDirectory *pDir);
|
||||
void OnResourceMoved(CResourceEntry *pEntry, CVirtualDirectory *pOldDir, TString OldName);
|
||||
|
|
|
@ -276,7 +276,7 @@ void CResourceSelector::Find()
|
|||
if (mpResEntry)
|
||||
{
|
||||
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
||||
pBrowser->SelectResource(mpResEntry);
|
||||
pBrowser->SelectResource(mpResEntry, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 248 B |
Loading…
Reference in New Issue