- New class: Parser::ProjectQuery
[dashstudio.git] / src / dash / network / userprofile.cpp
blobe731c87fbc35ff84648d77db6d540ba99544760b
1 /***************************************************************************
2 * Copyright (C) 2007 by Jorge Cuadrado *
3 * kuadrosxx@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "userprofile.h"
22 #include <dash/network/permission.h>
24 namespace Dash {
25 namespace Network {
27 struct UserProfile::Private
29 QList<Dash::Network::Permission> permissions;
30 QString name;
33 UserProfile::UserProfile(): d(new Private)
37 UserProfile::UserProfile(const UserProfile & copy): d(new Private)
39 d->name = copy.d->name;
40 d->permissions = copy.d->permissions;
43 UserProfile::UserProfile(const QString & name, const QList<Dash::Network::Permission> & permissions) : d(new Private)
45 d->permissions = permissions;
46 d->name = name;
50 UserProfile::~UserProfile()
52 delete d;
55 bool UserProfile::isThisProfile(const QList<Dash::Network::Permission> & permissions) const
57 foreach(Dash::Network::Permission perm, permissions)
59 bool ok = false;
60 foreach(Dash::Network::Permission perm1, d->permissions)
62 if(perm.name() == perm1.name())
64 if(perm.write() != perm1.write() && perm.write() != perm1.write())
66 return false;
68 break;
69 ok = true;
72 if(!ok)
74 return false;
77 return true;
80 QString UserProfile::name() const
82 return d->name;
85 void UserProfile::setName( const QString& name)
87 d->name = name;
90 QList<Dash::Network::Permission> UserProfile::permissions() const
92 return d->permissions;
95 void UserProfile::setPermission(const QList<Dash::Network::Permission>& permissions)
97 d->permissions = permissions;
100 UserProfile *UserProfile::operator=(const UserProfile& copy)
102 d->name = copy.d->name;
103 d->permissions = copy.d->permissions;
104 return this;