on xenial help sign in
fix beginmoverows calls
0a54e7bAlbert Astals
tests/mocks/Unity/fake_scopes.cpp+7−7
@@ -198,20 +198,20 @@ void Scopes::setFavorite(const QString& scopeId, bool favorite)
198 }
198 }
199}
199}
200
200
201−void Scopes::moveFavoriteTo(const QString& scopeId, int index)
201+void Scopes::moveFavoriteTo(const QString& scopeId, int to)
202{
202{
203− int origIndex = -1;
203+ int from = -1;
204 for (int i = 0; i < m_scopes.count(); ++i) {
204 for (int i = 0; i < m_scopes.count(); ++i) {
205 if (m_scopes[i]->id() == scopeId) {
205 if (m_scopes[i]->id() == scopeId) {
206− origIndex = i;
206+ from = i;
207 break;
207 break;
208 }
208 }
209 }
209 }
210− Q_ASSERT(origIndex != -1);
210+ Q_ASSERT(from != -1);
211− beginMoveRows(QModelIndex(), origIndex, origIndex, QModelIndex(), index);
211+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
212− m_scopes.move(origIndex, index);
212+ m_scopes.move(from, to);
213 endMoveRows();
213 endMoveRows();
214− m_scopesOverview->moveFavoriteTo(m_scopes[index], index);
214+ m_scopesOverview->moveFavoriteTo(m_scopes[to], to);
215}
215}
216
216
217QList<Scope*> Scopes::favScopes() const
217QList<Scope*> Scopes::favScopes() const
tests/mocks/Unity/fake_scopesoverview.cpp+5−5
@@ -333,11 +333,11 @@ void ScopesOverviewResultsModel::removeScope(Scope *scope)
333 Q_EMIT countChanged();
333 Q_EMIT countChanged();
334}
334}
335
335
336−void ScopesOverviewResultsModel::moveScopeTo(Scope *scope, int index)
336+void ScopesOverviewResultsModel::moveScopeTo(Scope *scope, int to)
337{
337{
338− const int origIndex = m_scopes.indexOf(scope);
338+ const int from = m_scopes.indexOf(scope);
339− Q_ASSERT(origIndex != -1);
339+ Q_ASSERT(from!= -1);
340− beginMoveRows(QModelIndex(), origIndex, origIndex, QModelIndex(), index);
340+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
341− m_scopes.move(origIndex, index);
341+ m_scopes.move(from, to);
342 endMoveRows();
342 endMoveRows();
343}
343}