2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Author: Michael Terry <michael.terry@canonical.com>
19// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
20// To use the same method of setting role name that it does, we
21// set our compatibility to Qt4 here too.
22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
24#include "UsersModel.h"
25#include "UsersModelPrivate.h"
27#include <QtCore/QString>
33UsersModel::UsersModel(QObject *parent) :
34 QAbstractListModel(parent),
35 d_ptr(new UsersModelPrivate(this))
39 // Extend roleNames (we want to keep the "display" role)
40 QHash<int, QByteArray> roles = roleNames();
41 roles[NameRole] = "name";
42 roles[RealNameRole] = "realName";
43 roles[LoggedInRole] = "loggedIn";
44 roles[BackgroundRole] = "background";
45 roles[BackgroundPathRole] = "backgroundPath";
46 roles[SessionRole] = "session";
47 roles[HasMessagesRole] = "hasMessages";
48 roles[ImagePathRole] = "imagePath";
52UsersModel::~UsersModel()
57int UsersModel::rowCount(const QModelIndex &parent) const
59 Q_D(const UsersModel);
61 if (parent.isValid()) {
63 } else { // parent is root
64 return d->entries.size();
68QVariant UsersModel::data(const QModelIndex &index, int role) const
70 Q_D(const UsersModel);
72 if (!index.isValid()) {
76 int row = index.row();
79 return d->entries[row].real_name;
80 case Qt::DecorationRole:
82 case UsersModel::NameRole:
83 return d->entries[row].username;
84 case UsersModel::RealNameRole:
85 return d->entries[row].real_name;
86 case UsersModel::SessionRole:
87 return d->entries[row].session;
88 case UsersModel::LoggedInRole:
89 return d->entries[row].is_active;
90 case UsersModel::BackgroundRole:
91 return QPixmap(d->entries[row].background);
92 case UsersModel::BackgroundPathRole:
93 return d->entries[row].background;
94 case UsersModel::HasMessagesRole:
95 return d->entries[row].has_messages;
96 case UsersModel::ImagePathRole:
103QString UsersModel::mockMode() const
105 Q_D(const UsersModel);
109void UsersModel::setMockMode(QString mockMode)
113 if (d->mockMode != mockMode) {
114 d->mockMode = mockMode;
115 Q_EMIT mockModeChanged(mockMode);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list