1
/***************************************************************************
2
* Copyright (C) 2004 by Daniel Rocher *
3
* daniel.rocher@adella.org *
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. *
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. *
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
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
23
\brief Class of user items
27
\sa server machine service
29
'user' is parent of 'service' and child of 'machine'
36
extern void debugQt(const QString & message);
37
extern QList<QTreeWidgetItem *> QTreeWidgetItemList;
39
int user::compteur_objet=0;
41
user::user(QTreeWidgetItem * parent,const QString & PID,const QString & Username, const QString & Group) : QTreeWidgetItem(parent)
43
debugQt("Object user : "+QString::number(++compteur_objet));
44
QTreeWidgetItemList.append(this);
50
icon.addPixmap(QPixmap(":/icons/user.png"), QIcon::Normal, QIcon::Off);
51
this->setIcon( 0, icon ); //icon
52
this->setText ( 0, Username) ;
56
debugQt("Object user : "+QString::number(--compteur_objet));
57
QTreeWidgetItemList.removeAll (this);
61
add share if not exist
62
\retval true already exist
65
bool user::append_share(const QString & PID,const QString & Share,const QString & DateOpen)
68
for (int i=0; i < this->childCount (); ++i )
70
service * Child= dynamic_cast<service *>(this->child (i) );
73
if ((Child->pid==PID) && (Child->share==Share) )
78
return true; // exit loop
81
// if not exist add it
82
if (!exist) new service (this,PID,Share,DateOpen);
87
add lockedfile if not exist
88
\retval true already exist
91
bool user::append_lockedfile(const QString & PID,const QString & File,const QString & DenyMode,const QString & RW,const QString & Oplock,const QString & DateOpen)
94
for (int i=0; i < this->childCount (); ++i )
96
service * Child= dynamic_cast<service *>(this->child (i) );
99
if ((Child->pid==PID) && (Child->filename==File) && (Child->denymode==DenyMode) && (Child->rw==RW) && (Child->oplock==Oplock) && (Child->dateopen==DateOpen) )
104
return true; // exit loop
107
// if not exist add it
108
if (!exist) new service (this,PID,File,DenyMode,RW,Oplock,DateOpen);
113
Refresh view. Delete obsolete objects (mark = false).
116
void user::refresh_childs()
118
for (int i=0; i < this->childCount (); ++i )
120
service * Child= dynamic_cast<service *>(this->child (i) );
122
// if child doesn't exist any more
125
delete Child; // delete item and his children
135
- mark = true -> exist
136
- mark = false -> obsolete
139
void user::mark_childs()
141
for (int i=0; i < this->childCount (); ++i )
143
service * Child= dynamic_cast<service *>(this->child (i) );