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/Tree_24px.png</file>
|
||||||
<file>icons/Gear_16px.png</file>
|
<file>icons/Gear_16px.png</file>
|
||||||
<file>icons/Gear_24px.png</file>
|
<file>icons/Gear_24px.png</file>
|
||||||
|
<file>icons/ToParentFolder_16px.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
@ -110,9 +111,10 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
|
||||||
|
|
||||||
QAction *pDisplayAssetIDsAction = new QAction("Display Asset IDs", this);
|
QAction *pDisplayAssetIDsAction = new QAction("Display Asset IDs", this);
|
||||||
pDisplayAssetIDsAction->setCheckable(true);
|
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(pDisplayAssetIDsAction);
|
||||||
|
|
||||||
|
pOptionsMenu->addAction("Find Asset by ID", this, SLOT(FindAssetByID()));
|
||||||
pOptionsMenu->addAction("Rebuild Database", this, SLOT(RebuildResourceDB()));
|
pOptionsMenu->addAction("Rebuild Database", this, SLOT(RebuildResourceDB()));
|
||||||
mpUI->OptionsToolButton->setMenu(pOptionsMenu);
|
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);
|
ASSERT(pEntry);
|
||||||
|
|
||||||
|
@ -191,6 +193,12 @@ void CResourceBrowser::SelectResource(CResourceEntry *pEntry)
|
||||||
UpdateFilter();
|
UpdateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change filter
|
||||||
|
if (ClearFiltersIfNecessary && !mpProxyModel->IsTypeAccepted(pEntry->TypeInfo()))
|
||||||
|
{
|
||||||
|
ResetTypeFilter();
|
||||||
|
}
|
||||||
|
|
||||||
// Select resource
|
// Select resource
|
||||||
QModelIndex SourceIndex = mpModel->GetIndexForEntry(pEntry);
|
QModelIndex SourceIndex = mpModel->GetIndexForEntry(pEntry);
|
||||||
QModelIndex ProxyIndex = mpProxyModel->mapFromSource(SourceIndex);
|
QModelIndex ProxyIndex = mpProxyModel->mapFromSource(SourceIndex);
|
||||||
|
@ -416,8 +424,10 @@ void CResourceBrowser::UpdateDescriptionLabel()
|
||||||
mpUI->TableDescriptionLabel->setText(Desc);
|
mpUI->TableDescriptionLabel->setText(Desc);
|
||||||
|
|
||||||
// Update clear button status
|
// Update clear button status
|
||||||
bool EnableClearButton = (!mpUI->SearchBar->text().isEmpty() || mpModel->IsDisplayingUserEntryList() || (mpSelectedDir && !mpSelectedDir->IsRoot()));
|
bool CanGoUp = (mpSelectedDir && !mpSelectedDir->IsRoot());
|
||||||
mpUI->ClearButton->setEnabled(EnableClearButton);
|
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()
|
void CResourceBrowser::SetResourceTreeView()
|
||||||
|
@ -581,10 +591,48 @@ void CResourceBrowser::OnResourceSelectionChanged(const QModelIndex& rkNewIndex)
|
||||||
emit SelectedResourceChanged(mpSelectedEntry);
|
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);
|
mpDelegate->SetDisplayAssetIDs(Enable);
|
||||||
mpUI->ResourceTableView->repaint();
|
mpModel->RefreshAllIndices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::UpdateStore()
|
void CResourceBrowser::UpdateStore()
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
~CResourceBrowser();
|
~CResourceBrowser();
|
||||||
|
|
||||||
void SetActiveDirectory(CVirtualDirectory *pDir);
|
void SetActiveDirectory(CVirtualDirectory *pDir);
|
||||||
void SelectResource(CResourceEntry *pEntry);
|
void SelectResource(CResourceEntry *pEntry, bool ClearFiltersIfNecessary = false);
|
||||||
void SelectDirectory(CVirtualDirectory *pDir);
|
void SelectDirectory(CVirtualDirectory *pDir);
|
||||||
void CreateFilterCheckboxes();
|
void CreateFilterCheckboxes();
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ public slots:
|
||||||
void OnDirectorySelectionChanged(const QModelIndex& rkNewIndex);
|
void OnDirectorySelectionChanged(const QModelIndex& rkNewIndex);
|
||||||
void OnDoubleClickTable(QModelIndex Index);
|
void OnDoubleClickTable(QModelIndex Index);
|
||||||
void OnResourceSelectionChanged(const QModelIndex& rkNewIndex);
|
void OnResourceSelectionChanged(const QModelIndex& rkNewIndex);
|
||||||
void SetAssetIdDisplayEnabled(bool Enable);
|
void FindAssetByID();
|
||||||
|
void SetAssetIDDisplayEnabled(bool Enable);
|
||||||
|
|
||||||
void UpdateStore();
|
void UpdateStore();
|
||||||
void SetProjectStore();
|
void SetProjectStore();
|
||||||
|
|
|
@ -212,7 +212,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../Icons.qrc">
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
CVirtualDirectory *pDir = mpModel->IndexDirectory(Index);
|
CVirtualDirectory *pDir = mpModel->IndexDirectory(Index);
|
||||||
CResourceEntry *pEntry = mpModel->IndexEntry(Index);
|
CResourceEntry *pEntry = mpModel->IndexEntry(Index);
|
||||||
|
|
||||||
if (pEntry && HasTypeFilter() && !mTypeFilter.contains(pEntry->TypeInfo()))
|
if (pEntry && !IsTypeAccepted(pEntry->TypeInfo()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!mSearchString.IsEmpty())
|
if (!mSearchString.IsEmpty())
|
||||||
|
@ -109,6 +109,11 @@ public:
|
||||||
return !mTypeFilter.isEmpty();
|
return !mTypeFilter.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsTypeAccepted(CResTypeInfo *pTypeInfo) const
|
||||||
|
{
|
||||||
|
return mTypeFilter.isEmpty() || mTypeFilter.contains(pTypeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
inline void SetSortMode(ESortMode Mode)
|
inline void SetSortMode(ESortMode Mode)
|
||||||
{
|
{
|
||||||
if (mSortMode != Mode)
|
if (mSortMode != Mode)
|
||||||
|
|
|
@ -274,6 +274,17 @@ int CResourceTableModel::EntryListIndex(CResourceEntry *pEntry)
|
||||||
return qLowerBound(mEntries, pEntry) - mEntries.constBegin();
|
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)
|
void CResourceTableModel::CheckAddDirectory(CVirtualDirectory *pDir)
|
||||||
{
|
{
|
||||||
if (pDir->Parent() == mpCurrentDir)
|
if (pDir->Parent() == mpCurrentDir)
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
inline QString ModelDescription() const { return mModelDescription; }
|
inline QString ModelDescription() const { return mModelDescription; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void RefreshAllIndices();
|
||||||
void CheckAddDirectory(CVirtualDirectory *pDir);
|
void CheckAddDirectory(CVirtualDirectory *pDir);
|
||||||
void CheckRemoveDirectory(CVirtualDirectory *pDir);
|
void CheckRemoveDirectory(CVirtualDirectory *pDir);
|
||||||
void OnResourceMoved(CResourceEntry *pEntry, CVirtualDirectory *pOldDir, TString OldName);
|
void OnResourceMoved(CResourceEntry *pEntry, CVirtualDirectory *pOldDir, TString OldName);
|
||||||
|
|
|
@ -276,7 +276,7 @@ void CResourceSelector::Find()
|
||||||
if (mpResEntry)
|
if (mpResEntry)
|
||||||
{
|
{
|
||||||
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
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