diff options
Diffstat (limited to 'liblightdm-qt/QLightDM/user.h')
-rw-r--r-- | liblightdm-qt/QLightDM/user.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/liblightdm-qt/QLightDM/user.h b/liblightdm-qt/QLightDM/user.h new file mode 100644 index 00000000..08841fc1 --- /dev/null +++ b/liblightdm-qt/QLightDM/user.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2010-2011 David Edmundson. + * Author: David Edmundson <kde@davidedmundson.co.uk> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. See http://www.gnu.org/copyleft/lgpl.html the full text of the + * license. + */ + +#ifndef QLIGHTDM_USER_H +#define QLIGHTDM_USER_H + +#include <QtCore/QString> +#include <QtCore/QSharedDataPointer> +#include <QAbstractListModel> + +class UserPrivate; +class UsersModelPrivate; + +namespace QLightDM +{ + //public facing User class + /** Class storing user information. + This is an implicitly shared class. */ + + class Q_DECL_EXPORT User + { + public: + explicit User(); + User(const QString &name, const QString &realName, const QString &homeDirectory, const QString &image, bool isLoggedIn); + User(const User& other); + ~User(); + User &operator=(const User& other); + + bool update(const QString &realName, const QString &homeDirectory, const QString &image, bool isLoggedIn); + + /** The name to display (the real name if available, otherwise use the username */ + QString displayName() const; + + /** The username of the user*/ + QString name() const; + /** The user's real name, use this for displaying*/ + QString realName() const; + + /** Returns the home directory of this user*/ + QString homeDirectory() const; + + /** Returns the path to an avatar of this user*/ + QString image() const; + + /** Returns true if this user is already logged in on another session*/ + bool isLoggedIn() const; + + // LdmUser &operator=(const LdmUser user); + private: + QSharedDataPointer<UserPrivate> d; + }; + + class Q_DECL_EXPORT UsersModel : public QAbstractListModel + { + Q_OBJECT + public: + explicit UsersModel(QObject *parent = 0); + ~UsersModel(); + + enum UserModelRoles {NameRole = Qt::UserRole, + RealNameRole, + LoggedInRole}; + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + + signals: + + public slots: + + private slots: + /** Updates the model with new changes in the password file*/ + void loadUsers(); + + private: + /** Returns a list of all users in the password file*/ + QList<User> getUsers(); + UsersModelPrivate *d; + }; + + UsersModel *users(); +} + +#endif // QLIGHTDM_USER_H |