1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
* Copyright (c) 1998 Denis Perchine <dyp@perchine.com>
* Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
* Former maintainer: Adriaan de Groot <groot@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#include "kglobal_.h"
#include "misc.h"
#include "kgroupvw.h"
KGroupViewItem::KGroupViewItem(KListView *parent, KU::KGroup *aku)
: KListViewItem(parent), mGroup(aku)
{
}
int KGroupViewItem::compare( TQListViewItem *i, int col, bool ascending ) const
{
switch ( col ) {
case 0: {
gid_t gid1, gid2;
gid1 = mGroup->getGID();
gid2 = ((KGroupViewItem*) i)->mGroup->getGID();
if ( gid1 == gid2 ) return 0;
return ( gid1 < gid2) ? -1: 1;
}
case 2: {
uint rid1,rid2;
rid1 = mGroup->getSID().getRID();
rid2 = ((KGroupViewItem*) i)->mGroup->getSID().getRID();
if ( rid1 == rid2 ) return 0;
return ( rid1 < rid2) ? -1: 1;
}
default:
return TQListViewItem::compare( i, col, ascending );
}
}
TQString KGroupViewItem::text(int num) const
{
switch(num)
{
case 0: return TQString::number(mGroup->getGID());
case 1: return mGroup->getName();
case 2: return ( mGroup->getCaps() & KU::KGroup::Cap_Samba ) ?
mGroup->getSID().getDOM() : TQString();
case 3: return ( mGroup->getCaps() & KU::KGroup::Cap_Samba ) ?
TQString::number( mGroup->getSID().getRID() ) : TQString();
case 4: {
if ( mGroup->getCaps() & KU::KGroup::Cap_Samba ) {
switch ( mGroup->getType() ) {
case 2: return i18n("Domain");
case 4: return i18n("Local");
case 5: return i18n("Builtin");
default: return i18n("Unknown");
}
} else {
return TQString();
}
}
case 5: return mGroup->getDisplayName();
case 6: return mGroup->getDesc();
}
return TQString();
}
KGroupView::KGroupView(TQWidget *parent, const char *name)
: KListView( parent, name )
{
setSelectionMode( TQListView::Extended );
}
KGroupView::~KGroupView()
{
}
void KGroupView::insertItem(KU::KGroup *aku)
{
KGroupViewItem *groupItem = new KGroupViewItem(this, aku);
KListView::insertItem(groupItem);
}
void KGroupView::removeItem(KU::KGroup *aku)
{
KGroupViewItem *groupItem = (KGroupViewItem *)firstChild();
while(groupItem)
{
if (groupItem->group() == aku)
{
delete groupItem;
return;
}
groupItem = (KGroupViewItem*) groupItem->nextSibling();
}
}
void KGroupView::init()
{
while ( columns() > 2 ) {
removeColumn( 2 );
}
setAllColumnsShowFocus(true);
if ( columns() < 2 ) {
addColumn(i18n("GID"));
setColumnAlignment(0, AlignRight);
addColumn(i18n("Group Name"));
}
if ( kug->getGroups().getCaps() & KU::KGroups::Cap_Samba ) {
addColumn(i18n("Domain SID"));
addColumn(i18n("RID"));
addColumn(i18n("Type"));
addColumn(i18n("Display Name"));
addColumn(i18n("Description"));
}
}
KU::KGroup *KGroupView::getCurrentGroup()
{
KGroupViewItem *groupItem = (KGroupViewItem *)currentItem();
if (!groupItem) return 0;
return groupItem->group();
}
#include "kgroupvw.moc"
|