@@ -73,6 +73,8 @@ UsersModel::UsersModel(QObject *parent)
7373 this, &UsersModel::resetEntries);
7474 connect(MockController::instance(), &MockController::userModeChanged,
7575 this, &UsersModel::resetEntries);
76+ connect(MockController::instance(), &MockController::sessionNameChanged,
77+ this, &UsersModel::setCurrentSessionName);
7678 resetEntries();
7779}
7880
@@ -81,6 +83,22 @@ UsersModel::~UsersModel()
8183 delete d_ptr;
8284}
8385
86+void UsersModel::setCurrentSessionName(const QString &sessionName, const QString &username)
87+{
88+ Q_D(UsersModel);
89+
90+ int usersIndex = 0;
91+ for (auto &entry : d->entries) {
92+ if (username == entry.username) {
93+ entry.session = sessionName;
94+ break;
95+ }
96+ usersIndex++;
97+ }
98+
99+ dataChanged(index(usersIndex, 0), index(usersIndex, 0), QVector<int>(SessionRole));
100+}
101+
84102int UsersModel::rowCount(const QModelIndex &parent) const
85103{
86104 Q_D(const UsersModel);
@@ -144,28 +162,33 @@ void UsersModel::resetEntries()
144162 } else if (userMode == "single-pin") {
145163 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
146164 } else if (userMode == "full") {
165+ /*
166+ * Since the real model sorts these entries alphabetically, the model indices
167+ * don't line up correctly. The easiest way to fix this is to ensure that this
168+ * list of entries REMAINS IN ALPHABETICAL ORDER at all times.
169+ */
147170 d->entries = {
171+ { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
172+ { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
173+ { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
174+ { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
175+ { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
176+ { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
148177 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
149178 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
150− { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
151− { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
152− { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
153− { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
154− { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
155179 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
180+ { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
156181 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
157− { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
158− { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
159182 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
160− { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
161− // white and black are a bit redundant, but useful for manually testing if UI is still readable
162− { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
163− { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
183+ { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
164184 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
165− { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
185+ { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
166186 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
167− { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
168− { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
187+ { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
188+ { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
189+ // white and black are a bit redundant, but useful for manually testing if UI is still readable
190+ { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
191+ { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 }
169192 };
170193 }
171194