mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
Support filtered tables (mapToSource for indexes)
This commit is contained in:
parent
16e03c151a
commit
f2fc02cdff
1 changed files with 9 additions and 6 deletions
|
@ -573,14 +573,17 @@ void CSVWorld::Table::moveRecords(QDropEvent *event)
|
||||||
QModelIndex targedIndex = indexAt(event->pos());
|
QModelIndex targedIndex = indexAt(event->pos());
|
||||||
|
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
int targetRow = targedIndex.row();
|
int targetRowRaw = targedIndex.row();
|
||||||
int baseRow = targedIndex.row() - 1;
|
int targetRow = mProxyModel->mapToSource (mProxyModel->index (targetRowRaw, 0)).row();
|
||||||
|
int baseRowRaw = targedIndex.row() - 1;
|
||||||
|
int baseRow = mProxyModel->mapToSource (mProxyModel->index (baseRowRaw, 0)).row();
|
||||||
int highestDifference = 0;
|
int highestDifference = 0;
|
||||||
|
|
||||||
for (const auto& thisRowData : selectedRows)
|
for (const auto& thisRowData : selectedRows)
|
||||||
{
|
{
|
||||||
if (std::abs(targetRow - thisRowData.row()) > highestDifference) highestDifference = std::abs(targetRow - thisRowData.row());
|
int thisRow = mProxyModel->mapToSource (mProxyModel->index (thisRowData.row(), 0)).row();
|
||||||
if (thisRowData.row() - 1 < baseRow) baseRow = thisRowData.row() - 1;
|
if (std::abs(targetRow - thisRow) > highestDifference) highestDifference = std::abs(targetRow - thisRow);
|
||||||
|
if (thisRow - 1 < baseRow) baseRow = thisRow - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> newOrder (highestDifference + 1);
|
std::vector<int> newOrder (highestDifference + 1);
|
||||||
|
@ -607,8 +610,8 @@ void CSVWorld::Table::moveRecords(QDropEvent *event)
|
||||||
d_DEC) decrease all members after the ORIGIN by one, stop after hitting address TARGET
|
d_DEC) decrease all members after the ORIGIN by one, stop after hitting address TARGET
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int originRow = thisRowData.row();
|
int originRowRaw = thisRowData.row();
|
||||||
//int sourceMappedOriginRow = mProxyModel->mapToSource (mProxyModel->index (originRow, 0)).row();
|
int originRow = mProxyModel->mapToSource (mProxyModel->index (originRowRaw, 0)).row();
|
||||||
|
|
||||||
newOrder.erase(newOrder.begin() + originRow - baseRow - 1);
|
newOrder.erase(newOrder.begin() + originRow - baseRow - 1);
|
||||||
newOrder.emplace(newOrder.begin() + originRow - baseRow - 1, targetRow - baseRow - 1);
|
newOrder.emplace(newOrder.begin() + originRow - baseRow - 1, targetRow - baseRow - 1);
|
||||||
|
|
Loading…
Reference in a new issue