on xenial help sign in
fix beginmoverows calls
commit0a54e7b3cb1898da32f0c6c47d66a99891427183 authorAlbert Astals <albert.astals@canonical.com> dateFri 26 Sep 2014, 13:33 (12 years ago) parent00297d2
2 files changed+12−12
tests/mocks/Unity/fake_scopes.cpp+7−7 tests/mocks/Unity/fake_scopesoverview.cpp+5−5
tests/mocks/Unity/fake_scopes.cpp+7−7
@@ -198,20 +198,20 @@ void Scopes::setFavorite(const QString& scopeId, bool favorite)
198198 }
199199}
200200
201−void Scopes::moveFavoriteTo(const QString& scopeId, int index)
201+void Scopes::moveFavoriteTo(const QString& scopeId, int to)
202202{
203− int origIndex = -1;
203+ int from = -1;
204204 for (int i = 0; i < m_scopes.count(); ++i) {
205205 if (m_scopes[i]->id() == scopeId) {
206− origIndex = i;
206+ from = i;
207207 break;
208208 }
209209 }
210− Q_ASSERT(origIndex != -1);
211− beginMoveRows(QModelIndex(), origIndex, origIndex, QModelIndex(), index);
212− m_scopes.move(origIndex, index);
210+ Q_ASSERT(from != -1);
211+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
212+ m_scopes.move(from, to);
213213 endMoveRows();
214− m_scopesOverview->moveFavoriteTo(m_scopes[index], index);
214+ m_scopesOverview->moveFavoriteTo(m_scopes[to], to);
215215}
216216
217217QList<Scope*> Scopes::favScopes() const
tests/mocks/Unity/fake_scopesoverview.cpp+5−5
@@ -333,11 +333,11 @@ void ScopesOverviewResultsModel::removeScope(Scope *scope)
333333 Q_EMIT countChanged();
334334}
335335
336−void ScopesOverviewResultsModel::moveScopeTo(Scope *scope, int index)
336+void ScopesOverviewResultsModel::moveScopeTo(Scope *scope, int to)
337337{
338− const int origIndex = m_scopes.indexOf(scope);
339− Q_ASSERT(origIndex != -1);
340− beginMoveRows(QModelIndex(), origIndex, origIndex, QModelIndex(), index);
341− m_scopes.move(origIndex, index);
338+ const int from = m_scopes.indexOf(scope);
339+ Q_ASSERT(from!= -1);
340+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
341+ m_scopes.move(from, to);
342342 endMoveRows();
343343}