Don't reset the whole model
commit5a2b91d7c8d0060bd6bf443629869494408174d9
authorJosh Arenson <joshua.arenson@canonical.com>
dateWed 11 Jan 2017, 12:19 (10 years ago)
parent74b5e63af6073a
qml/Greeter/WideView.qml+2−2
@@ -153,9 +153,9 @@ FocusScope {
153153 // TODO when Qt 5.7
154154 //enabled: LightDM.Users.mock
155155 target: LightDMService.users
156− onModelReset: {
156+ onDataChanged: {
157157 loginList.currentSession = LightDMService.users.data(loginList.currentIndex, LightDMService.userRoles.SessionRole);
158− }
158+ }
159159 }
160160 }
161161
tests/mocks/liblightdm/MockUsersModel.cpp+3−3
@@ -81,16 +81,16 @@ void UsersModel::setCurrentSessionName(const QString &sessionName, const QString
8181{
8282 Q_D(UsersModel);
8383
84− beginResetModel();
85−
84+ int usersIndex = 0;
8685 for (auto &entry : d->entries) {
8786 if (username == entry.username) {
8887 entry.session = sessionName;
8988 break;
9089 }
90+ usersIndex++;
9191 }
9292
93− endResetModel();
93+ dataChanged(index(usersIndex, 0), index(usersIndex, 0), QVector<int>(SessionRole));
9494}
9595
9696int UsersModel::rowCount(const QModelIndex &parent) const