LYN-4863: Item data not copied on drag-n-drop if column is hidden in Asset Browser Tree View. (#1616)
* Fixed: Item returning null in drag and drop when column is hidden * Added explanation about why this approach is needed Signed-off-by: John <jonawals@amazon.com>
This commit is contained in:
committed by
John
parent
1e8465f1cc
commit
b87e3eb1d6
+12
-3
@@ -185,10 +185,11 @@ namespace AzToolsFramework
|
||||
|
||||
void AssetBrowserTreeView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
|
||||
{
|
||||
// if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially marked for deletion
|
||||
if (selectionModel() && selectionModel()->selectedIndexes().size() == 1)
|
||||
// if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially
|
||||
// marked for deletion
|
||||
if (selectionModel() && selectedIndexes().size() == 1)
|
||||
{
|
||||
QModelIndex selectedIndex = selectionModel()->selectedIndexes().first();
|
||||
QModelIndex selectedIndex = selectedIndexes().first();
|
||||
QModelIndex parentSelectedIndex = selectedIndex.parent();
|
||||
if (parentSelectedIndex == parent && selectedIndex.row() >= start && selectedIndex.row() <= end)
|
||||
{
|
||||
@@ -198,6 +199,14 @@ namespace AzToolsFramework
|
||||
QTreeView::rowsAboutToBeRemoved(parent, start, end);
|
||||
}
|
||||
|
||||
// Item data for hidden columns normally isn't copied by Qt during drag-and-drop (see QTBUG-30242).
|
||||
// However, for the AssetBrowser, the hidden columns should get copied. By overriding selectedIndexes() to
|
||||
// include all selected indices, not just the visible ones, we can get the behavior we're looking for.
|
||||
QModelIndexList AssetBrowserTreeView::selectedIndexes() const
|
||||
{
|
||||
return selectionModel()->selectedIndexes();
|
||||
}
|
||||
|
||||
void AssetBrowserTreeView::SetThumbnailContext(const char* thumbnailContext) const
|
||||
{
|
||||
m_delegate->SetThumbnailContext(thumbnailContext);
|
||||
|
||||
+3
@@ -95,6 +95,9 @@ namespace AzToolsFramework
|
||||
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
|
||||
void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
|
||||
|
||||
protected:
|
||||
QModelIndexList selectedIndexes() const override;
|
||||
|
||||
private:
|
||||
QPointer<AssetBrowserModel> m_assetBrowserModel = nullptr;
|
||||
QPointer<AssetBrowserFilterModel> m_assetBrowserSortFilterProxyModel = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user