Selecting assets from tableview
This commit is contained in:
+1
-12
@@ -27,15 +27,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
return m_indexMap[proxyIndex.row()];
|
||||
}
|
||||
QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const
|
||||
{
|
||||
Q_ASSERT(!sourceIndex.isValid() || sourceIndex.model() == sourceModel());
|
||||
if (!sourceIndex.isValid())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer());
|
||||
}
|
||||
|
||||
QVariant AssetBrowserTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
@@ -94,7 +85,7 @@ namespace AzToolsFramework
|
||||
|
||||
int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return !parent.isValid() ? m_rowMap.size() : 0;
|
||||
return !parent.isValid() ? m_indexMap.size() : 0;
|
||||
}
|
||||
|
||||
int AssetBrowserTableModel::BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/)
|
||||
@@ -106,7 +97,6 @@ namespace AzToolsFramework
|
||||
if (model->hasChildren(index) == false)
|
||||
{
|
||||
beginInsertRows(parent, row, row);
|
||||
m_rowMap[index] = row;
|
||||
m_indexMap[row] = index;
|
||||
endInsertRows();
|
||||
|
||||
@@ -139,7 +129,6 @@ namespace AzToolsFramework
|
||||
if (m_indexMap.size() > 0)
|
||||
{
|
||||
beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row());
|
||||
m_rowMap.clear();
|
||||
m_indexMap.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace AzToolsFramework
|
||||
// QSortFilterProxyModel
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
|
||||
QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
|
||||
QModelIndex parent(const QModelIndex& child) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
@@ -42,7 +41,6 @@ namespace AzToolsFramework
|
||||
private:
|
||||
QPointer<AssetBrowserFilterModel> m_filterModel;
|
||||
QMap<int, QModelIndex> m_indexMap;
|
||||
QMap<QModelIndex, int> m_rowMap;
|
||||
};
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+8
-4
@@ -41,6 +41,7 @@ namespace AzToolsFramework
|
||||
|
||||
setMouseTracking(true);
|
||||
setSortingEnabled(false);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu);
|
||||
|
||||
@@ -61,7 +62,7 @@ namespace AzToolsFramework
|
||||
connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot);
|
||||
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
|
||||
horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeMode::Stretch);
|
||||
horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
|
||||
}
|
||||
void AssetBrowserTableView::SetName(const QString& name)
|
||||
{
|
||||
@@ -78,7 +79,10 @@ namespace AzToolsFramework
|
||||
QModelIndexList sourceIndexes;
|
||||
for (const auto& index : selectedIndexes())
|
||||
{
|
||||
sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index)));
|
||||
if (index.column() == 0)
|
||||
{
|
||||
sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index)));
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector<AssetBrowserEntry*> entries;
|
||||
@@ -87,8 +91,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||
{
|
||||
AZ_UNUSED(selected);
|
||||
AZ_UNUSED(deselected);
|
||||
QTableView::selectionChanged(selected, deselected);
|
||||
Q_EMIT selectionChangedSignal(selected, deselected);
|
||||
}
|
||||
void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
|
||||
{
|
||||
|
||||
+4
-1
@@ -101,7 +101,10 @@ namespace AzToolsFramework
|
||||
QModelIndexList sourceIndexes;
|
||||
for (const auto& index : selectedIndexes())
|
||||
{
|
||||
sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index));
|
||||
if (index.column() == 0)
|
||||
{
|
||||
sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index));
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector<AssetBrowserEntry*> entries;
|
||||
|
||||
Reference in New Issue
Block a user