Skip to content
Snippets Groups Projects
Commit abab0c29 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

account: fix reordering

- use correct variable names
- change currentIndex in dropMimeData

Refs #68848
parent a7f86938
No related branches found
No related tags found
No related merge requests found
......@@ -417,7 +417,6 @@ bool AccountModel::moveUp()
if (d_ptr->m_pSelectionModel) {
const QModelIndex& idx = d_ptr->m_pSelectionModel->currentIndex();
if (dropMimeData(mimeData({idx}), Qt::MoveAction, idx.row()-1, idx.column(),idx.parent())) {
d_ptr->m_pSelectionModel->setCurrentIndex(index(idx.row()-1,idx.column()), QItemSelectionModel::ClearAndSelect);
return true;
}
}
......@@ -430,7 +429,6 @@ bool AccountModel::moveDown()
if (d_ptr->m_pSelectionModel) {
const QModelIndex& idx = d_ptr->m_pSelectionModel->currentIndex();
if (dropMimeData(mimeData({idx}), Qt::MoveAction, idx.row()+1, idx.column(),idx.parent())) {
d_ptr->m_pSelectionModel->setCurrentIndex(index(idx.row()+1,idx.column()), QItemSelectionModel::ClearAndSelect);
return true;
}
}
......@@ -720,9 +718,6 @@ bool AccountModel::dropMimeData(const QMimeData* data, Qt::DropAction action, in
else if(row >= d_ptr->m_lAccounts.size()) {
destinationRow = 0;
}
else if(data->hasFormat(RingMimes::VIDEO_CODEC) && row >= rowCount()) {
destinationRow = 0;
}
else {
destinationRow = row;
}
......@@ -731,17 +726,19 @@ bool AccountModel::dropMimeData(const QMimeData* data, Qt::DropAction action, in
if (!dest)
return false;
const QModelIndex codecIdx = dest->index();
const QModelIndex accIdx = dest->index();
beginRemoveRows(QModelIndex(), codecIdx.row(), codecIdx.row());
Account* codecInfo = d_ptr->m_lAccounts[codecIdx.row()];
d_ptr->m_lAccounts.removeAt(codecIdx.row());
beginRemoveRows(QModelIndex(), accIdx.row(), accIdx.row());
Account* acc = d_ptr->m_lAccounts[accIdx.row()];
d_ptr->m_lAccounts.removeAt(accIdx.row());
endRemoveRows();
beginInsertRows(QModelIndex(), destinationRow, destinationRow);
d_ptr->m_lAccounts.insert(destinationRow,codecInfo);
d_ptr->m_lAccounts.insert(destinationRow,acc);
endInsertRows();
d_ptr->m_pSelectionModel->setCurrentIndex(index(destinationRow), QItemSelectionModel::ClearAndSelect);
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment