game_list: fix folder reordering

This commit is contained in:
Vitor Kiguchi 2020-05-09 23:44:41 -03:00
parent 950c032837
commit fbf24e3ca4

View File

@ -580,6 +580,8 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) {
std::swap(UISettings::values.game_dirs[game_dir_index],
UISettings::values.game_dirs[selected.sibling(row - 1, 0)
.data(GameListDir::GameDirRole).toInt()]);
GetModel()->setData(selected, QVariant::fromValue(selected.sibling(row-1,0).data(GameListDir::GameDirRole).toInt()), GameListDir::GameDirRole);
GetModel()->setData(selected.sibling(row-1,0), QVariant::fromValue(game_dir_index), GameListDir::GameDirRole);
// move the treeview items
QList<QStandardItem*> item = item_model->takeRow(row);
item_model->invisibleRootItem()->insertRow(row - 1, item);
@ -591,6 +593,8 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) {
std::swap(UISettings::values.game_dirs[game_dir_index],
UISettings::values.game_dirs[selected.sibling(row + 1, 0)
.data(GameListDir::GameDirRole).toInt()]);
GetModel()->setData(selected, QVariant::fromValue(selected.sibling(row+1,0).data(GameListDir::GameDirRole).toInt()), GameListDir::GameDirRole);
GetModel()->setData(selected.sibling(row+1,0), QVariant::fromValue(game_dir_index), GameListDir::GameDirRole);
// move the treeview items
const QList<QStandardItem*> item = item_model->takeRow(row);
item_model->invisibleRootItem()->insertRow(row + 1, item);