Changeset View
Changeset View
Standalone View
Standalone View
src/lib/accountmodel.cpp
Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Line(s) | 295 | { | |||
---|---|---|---|---|---|
304 | return QVariant(); | 304 | return QVariant(); | ||
305 | } | 305 | } | ||
306 | 306 | | |||
307 | bool AccountModel::newUserSetData(const QModelIndex &index, const QVariant& value, int roleInt) | 307 | bool AccountModel::newUserSetData(const QModelIndex &index, const QVariant& value, int roleInt) | ||
308 | { | 308 | { | ||
309 | AccountModel::Role role = static_cast<AccountModel::Role>(roleInt); | 309 | AccountModel::Role role = static_cast<AccountModel::Role>(roleInt); | ||
310 | m_newUserData[role] = value; | 310 | m_newUserData[role] = value; | ||
311 | QList<AccountModel::Role> roles = m_newUserData.keys(); | 311 | QList<AccountModel::Role> roles = m_newUserData.keys(); | ||
312 | if (!roles.contains(Username) || !roles.contains(RealName) || !roles.contains(Administrator)) { | 312 | if (!roles.contains(Username) || !roles.contains(RealName)) { | ||
313 | return true; | 313 | return true; | ||
314 | } | 314 | } | ||
315 | 315 | | |||
316 | // defaults to non-administrator | ||||
317 | int userType = 0; | ||||
318 | if (m_newUserData.contains(Administrator)) { | ||||
319 | userType = m_newUserData[Administrator].toBool(); | ||||
320 | } | ||||
316 | 321 | | |||
317 | int userType = m_newUserData[Administrator].toBool() ? 1 : 0; | | |||
318 | QDBusPendingReply <QDBusObjectPath > reply = m_dbus->CreateUser(m_newUserData[Username].toString(), m_newUserData[RealName].toString(), userType); | 322 | QDBusPendingReply <QDBusObjectPath > reply = m_dbus->CreateUser(m_newUserData[Username].toString(), m_newUserData[RealName].toString(), userType); | ||
319 | reply.waitForFinished(); | 323 | reply.waitForFinished(); | ||
320 | 324 | | |||
321 | if (reply.isError()) { | 325 | if (reply.isError()) { | ||
322 | qCDebug(USER_MANAGER_LOG) << reply.error().name(); | 326 | qCDebug(USER_MANAGER_LOG) << reply.error().name(); | ||
323 | qCDebug(USER_MANAGER_LOG) << reply.error().message(); | 327 | qCDebug(USER_MANAGER_LOG) << reply.error().message(); | ||
324 | m_newUserData.clear(); | 328 | m_newUserData.clear(); | ||
325 | return false; | 329 | return false; | ||
326 | } | 330 | } | ||
327 | 331 | | |||
328 | m_newUserData.remove(Username); | 332 | m_newUserData.remove(Username); | ||
329 | m_newUserData.remove(RealName); | 333 | m_newUserData.remove(RealName); | ||
330 | m_newUserData.remove(Administrator); | | |||
331 | 334 | | |||
332 | //If we don't have anything else to set just return | 335 | //If we don't have anything else to set just return | ||
333 | if (m_newUserData.isEmpty()) { | 336 | if (m_newUserData.isEmpty()) { | ||
334 | return true; | 337 | return true; | ||
335 | } | 338 | } | ||
336 | 339 | | |||
337 | UserAdded(reply.value()); | 340 | UserAdded(reply.value()); | ||
338 | 341 | | |||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |