Implemented "find" button on resource selector widget
This commit is contained in:
parent
548fcb2f8e
commit
c53352c290
|
@ -72,6 +72,35 @@ CResourceBrowser::~CResourceBrowser()
|
||||||
delete mpUI;
|
delete mpUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CResourceBrowser::SelectResource(CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
ASSERT(pEntry);
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
mpUI->SearchBar->clear();
|
||||||
|
UpdateFilter();
|
||||||
|
|
||||||
|
// Select target directory
|
||||||
|
SelectDirectory(pEntry->Directory());
|
||||||
|
|
||||||
|
// Select resource
|
||||||
|
int Row = mpModel->GetIndexForEntry(pEntry).row();
|
||||||
|
mpUI->ResourceTableView->selectionModel()->clearSelection();
|
||||||
|
|
||||||
|
for (int iCol = 0; iCol < mpModel->columnCount(QModelIndex()); iCol++)
|
||||||
|
{
|
||||||
|
QModelIndex Index = mpModel->index(Row, iCol, QModelIndex());
|
||||||
|
QModelIndex ProxyIndex = mpProxyModel->mapFromSource(Index);
|
||||||
|
mpUI->ResourceTableView->selectionModel()->setCurrentIndex(ProxyIndex, QItemSelectionModel::Select);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CResourceBrowser::SelectDirectory(CVirtualDirectory *pDir)
|
||||||
|
{
|
||||||
|
QModelIndex Index = mpDirectoryModel->GetIndexForDirectory(pDir);
|
||||||
|
mpUI->DirectoryTreeView->selectionModel()->setCurrentIndex(Index, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
|
||||||
void CResourceBrowser::RefreshResources()
|
void CResourceBrowser::RefreshResources()
|
||||||
{
|
{
|
||||||
// Fill resource table
|
// Fill resource table
|
||||||
|
@ -157,8 +186,7 @@ void CResourceBrowser::OnDoubleClickTable(QModelIndex Index)
|
||||||
if (mpModel->IsIndexDirectory(SourceIndex))
|
if (mpModel->IsIndexDirectory(SourceIndex))
|
||||||
{
|
{
|
||||||
CVirtualDirectory *pDir = mpModel->IndexDirectory(SourceIndex);
|
CVirtualDirectory *pDir = mpModel->IndexDirectory(SourceIndex);
|
||||||
QModelIndex Index = mpDirectoryModel->GetIndexForDirectory(pDir);
|
SelectDirectory(pDir);
|
||||||
mpUI->DirectoryTreeView->selectionModel()->setCurrentIndex(Index, QItemSelectionModel::ClearAndSelect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resource - open resource for editing
|
// Resource - open resource for editing
|
||||||
|
|
|
@ -27,6 +27,8 @@ class CResourceBrowser : public QDialog
|
||||||
public:
|
public:
|
||||||
explicit CResourceBrowser(QWidget *pParent = 0);
|
explicit CResourceBrowser(QWidget *pParent = 0);
|
||||||
~CResourceBrowser();
|
~CResourceBrowser();
|
||||||
|
void SelectResource(CResourceEntry *pEntry);
|
||||||
|
void SelectDirectory(CVirtualDirectory *pDir);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CResourceEntry* SelectedEntry() const { return mpSelectedEntry; }
|
inline CResourceEntry* SelectedEntry() const { return mpSelectedEntry; }
|
||||||
|
|
|
@ -85,6 +85,21 @@ public:
|
||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QModelIndex GetIndexForEntry(CResourceEntry *pEntry) const
|
||||||
|
{
|
||||||
|
for (int iRes = 0; iRes < mEntries.size(); iRes++)
|
||||||
|
{
|
||||||
|
if (mEntries[iRes] == pEntry)
|
||||||
|
{
|
||||||
|
QModelIndex Out = index(mDirectories.size() + iRes, 0);
|
||||||
|
ASSERT(IndexEntry(Out) == pEntry);
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
CResourceEntry* IndexEntry(const QModelIndex& rkIndex) const
|
CResourceEntry* IndexEntry(const QModelIndex& rkIndex) const
|
||||||
{
|
{
|
||||||
int Index = rkIndex.row() - mDirectories.size();
|
int Index = rkIndex.row() - mDirectories.size();
|
||||||
|
@ -144,7 +159,12 @@ protected:
|
||||||
void RecursiveAddDirectoryContents(CVirtualDirectory *pDir)
|
void RecursiveAddDirectoryContents(CVirtualDirectory *pDir)
|
||||||
{
|
{
|
||||||
for (u32 iRes = 0; iRes < pDir->NumResources(); iRes++)
|
for (u32 iRes = 0; iRes < pDir->NumResources(); iRes++)
|
||||||
|
{
|
||||||
|
CResourceEntry *pEntry = pDir->ResourceByIndex(iRes);
|
||||||
|
|
||||||
|
if (pEntry->TypeInfo()->IsVisibleInBrowser() && !pEntry->IsHidden())
|
||||||
mEntries << pDir->ResourceByIndex(iRes);
|
mEntries << pDir->ResourceByIndex(iRes);
|
||||||
|
}
|
||||||
|
|
||||||
for (u32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++)
|
for (u32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++)
|
||||||
RecursiveAddDirectoryContents(pDir->SubdirectoryByIndex(iDir));
|
RecursiveAddDirectoryContents(pDir->SubdirectoryByIndex(iDir));
|
||||||
|
|
|
@ -47,6 +47,7 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
||||||
// UI Connections
|
// UI Connections
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
||||||
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
||||||
|
connect(mpFindButton, SIGNAL(clicked()), this, SLOT(Find()));
|
||||||
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
||||||
|
|
||||||
// Set up context menu
|
// Set up context menu
|
||||||
|
@ -144,6 +145,14 @@ void CResourceSelector::Set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CResourceSelector::Find()
|
||||||
|
{
|
||||||
|
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
||||||
|
pBrowser->SelectResource(mpResEntry);
|
||||||
|
pBrowser->show();
|
||||||
|
pBrowser->raise();
|
||||||
|
}
|
||||||
|
|
||||||
void CResourceSelector::Clear()
|
void CResourceSelector::Clear()
|
||||||
{
|
{
|
||||||
mpResEntry = nullptr;
|
mpResEntry = nullptr;
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void CreateContextMenu(const QPoint& rkPoint);
|
void CreateContextMenu(const QPoint& rkPoint);
|
||||||
void Set();
|
void Set();
|
||||||
|
void Find();
|
||||||
void Clear();
|
void Clear();
|
||||||
void EditAsset();
|
void EditAsset();
|
||||||
void CopyName();
|
void CopyName();
|
||||||
|
|
Loading…
Reference in New Issue