]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-qt/user.cpp
Rearrange liblightdm-qt to be the same a liblightdm-gobject
[sojka/lightdm.git] / liblightdm-qt / user.cpp
1 /*
2  * Copyright (C) 2010-2011 David Edmundson.
3  * Author: David Edmundson <kde@davidedmundson.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License as published by the Free
7  * Software Foundation; either version 3 of the License, or (at your option) any
8  * later version. See http://www.gnu.org/copyleft/lgpl.html the full text of the
9  * license.
10  */
11
12 #include "QLightDM/User"
13
14 #include <QtCore/QSharedData>
15
16 using namespace QLightDM;
17
18 class UserPrivate : public QSharedData
19 {
20 public:
21     QString name;
22     QString realName;
23     QString homeDirectory;
24     QString image;
25     bool isLoggedIn;
26 };
27
28 User::User():
29     d(new UserPrivate)
30 {
31 }
32
33 User::User(const QString& name, const QString& realName, const QString& homeDirectory, const QString& image, bool isLoggedIn) :
34     d(new UserPrivate)
35 {
36     d->name = name;
37     d->realName = realName;
38     d->homeDirectory = homeDirectory;
39     d->image = image;
40     d->isLoggedIn = isLoggedIn;
41 }
42
43 User::User(const User &other)
44     : d(other.d)
45 {
46 }
47
48 User::~User()
49 {
50 }
51
52
53 User& User::operator=(const User& other)
54 {
55     d = other.d;
56     return *this;
57 }
58
59 bool User::update(const QString& realName, const QString& homeDirectory, const QString& image, bool isLoggedIn)
60 {
61     if (d->realName == realName && d->homeDirectory == homeDirectory && d->image == image && d->isLoggedIn == isLoggedIn) {
62         return false;
63     }
64
65     d->realName = realName;
66     d->homeDirectory = homeDirectory;
67     d->image = image;
68     d->isLoggedIn = isLoggedIn;
69
70     return true;
71 }
72
73 QString User::displayName() const
74 {
75     if (!d->realName.isEmpty()) {
76         return d->realName;
77     }
78     else {
79         return d->name;
80     }
81 }
82
83 QString User::name() const
84 {
85     return d->name;
86 }
87
88 QString User::realName() const
89 {
90     return d->realName;
91 }
92
93 QString User::homeDirectory() const
94 {
95     return d->homeDirectory;
96 }
97
98 QString User::image() const
99 {
100     return d->image;
101 }
102
103 bool User::isLoggedIn() const
104 {
105     return d->isLoggedIn;
106 }