Skip to content
Snippets Groups Projects
Commit 471c7245 authored by Edric Milaret's avatar Edric Milaret
Browse files

fix move in codecmodel

We were removing and inserting an item instead of just moving it
That confused the selection in the UI.

This fix is only applied for windows because the gnome and osx clients
don't yet support the layoutChanged signals which are emitted when move
operations are performed on the source models of proxy models.

Change-Id: I6a62164231e44f3894d300b3445c781ed8062cbd
Tuleap: #933
parent ad49fc70
No related branches found
No related tags found
No related merge requests found
......@@ -573,6 +573,14 @@ bool CodecModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
const QModelIndex codecIdx = d_ptr->getIndexofCodecByID(codecId);
#ifdef Q_OS_WIN
/* To understand why qtDestinationRow is needed
http://doc.qt.io/qt-5/qabstractitemmodel.html#beginMoveRows */
auto qtDestinationRow = destinationRow > codecIdx.row() ? destinationRow+1 : destinationRow;
beginMoveRows(parent, codecIdx.row(), codecIdx.row(), parent, qtDestinationRow);
d_ptr->m_lCodecs.move(codecIdx.row(), destinationRow);
endMoveRows();
#else
beginRemoveRows(QModelIndex(), codecIdx.row(), codecIdx.row());
CodecModelPrivate::CodecData* codecInfo = d_ptr->m_lCodecs[codecIdx.row()];
d_ptr->m_lCodecs.removeAt(codecIdx.row());
......@@ -581,6 +589,7 @@ bool CodecModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
beginInsertRows(QModelIndex(), destinationRow, destinationRow);
d_ptr->m_lCodecs.insert(destinationRow,codecInfo);
endInsertRows();
#endif
this << EditAction::MODIFY;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment