Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.cpp
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Line(s) | |||||
161 | void ButtonsModel::move(int sourceIndex, int targetIndex) | 161 | void ButtonsModel::move(int sourceIndex, int targetIndex) | ||
162 | { | 162 | { | ||
163 | if (sourceIndex == qMax(0, targetIndex)) { | 163 | if (sourceIndex == qMax(0, targetIndex)) { | ||
164 | return; | 164 | return; | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | /* When moving an item down, the destination index needs to be incremented | 167 | /* When moving an item down, the destination index needs to be incremented | ||
168 | by one, as explained in the documentation: | 168 | by one, as explained in the documentation: | ||
169 | http://doc.qt.nokia.com/qabstractitemmodel.html#beginMoveRows */ | 169 | https://doc.qt.io/qt-5/qabstractitemmodel.html#beginMoveRows */ | ||
170 | if (targetIndex > sourceIndex) { | 170 | if (targetIndex > sourceIndex) { | ||
171 | // Row will be moved down | 171 | // Row will be moved down | ||
172 | beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), targetIndex + 1); | 172 | beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), targetIndex + 1); | ||
173 | } else { | 173 | } else { | ||
174 | beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), qMax(0, targetIndex)); | 174 | beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), qMax(0, targetIndex)); | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | m_buttons.move(sourceIndex, qMax(0, targetIndex)); | 177 | m_buttons.move(sourceIndex, qMax(0, targetIndex)); | ||
Show All 24 Lines |