• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kfile
kacleditwidget_p.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2005 by Sean Harmer <sh@rama.homelinux.org> *
3 * 2005 - 2007 Till Adam <adam@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * License, or (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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#ifndef KACLEDITWIDGET_P_H
21#define KACLEDITWIDGET_P_H
22
23#include <config-acl.h>
24
25#if defined(HAVE_POSIX_ACL) || defined(Q_MOC_RUN)
26#include <sys/acl.h>
27#include <kacl.h>
28
29#include <QPixmap>
30#include <QTreeWidget>
31#include <QtCore/QHash>
32
33#include <kcombobox.h>
34#include <kdialog.h>
35#include <kfileitem.h>
36
37class KACLListViewItem;
38class QButtonGroup;
39class KACLListView;
40class QStackedWidget;
41class QCheckBox;
42class QAbstractButton;
43class QColorGroup;
44
48class KACLListView : public QTreeWidget
49{
50Q_OBJECT
51 friend class KACLListViewItem;
52public:
53 enum Types
54 {
55 OWNER_IDX = 0,
56 GROUP_IDX,
57 OTHERS_IDX,
58 MASK_IDX,
59 NAMED_USER_IDX,
60 NAMED_GROUP_IDX,
61 LAST_IDX
62 };
63 enum EntryType { User = 1,
64 Group = 2,
65 Others = 4,
66 Mask = 8,
67 NamedUser = 16,
68 NamedGroup = 32,
69 AllTypes = 63 };
70
71 KACLListView( QWidget* parent = 0 );
72 ~KACLListView();
73
74 bool hasMaskEntry() const { return m_hasMask; }
75 bool hasDefaultEntries() const;
76 bool allowDefaults() const { return m_allowDefaults; }
77 void setAllowDefaults( bool v ) { m_allowDefaults = v; }
78 unsigned short maskPermissions() const;
79 void setMaskPermissions( unsigned short maskPerms );
80 acl_perm_t maskPartialPermissions() const;
81 void setMaskPartialPermissions( acl_perm_t maskPerms );
82
83 bool maskCanBeDeleted() const;
84 bool defaultMaskCanBeDeleted() const;
85
86 const KACLListViewItem* findDefaultItemByType( EntryType type ) const;
87 const KACLListViewItem* findItemByType( EntryType type,
88 bool defaults = false ) const;
89 unsigned short calculateMaskValue( bool defaults ) const;
90 void calculateEffectiveRights();
91
92 QStringList allowedUsers( bool defaults, KACLListViewItem *allowedItem = 0 );
93 QStringList allowedGroups( bool defaults, KACLListViewItem *allowedItem = 0 );
94
95 const KACL getACL() const { return getACL(); }
96 KACL getACL();
97
98 const KACL getDefaultACL() const { return getDefaultACL(); }
99 KACL getDefaultACL();
100
101 QPixmap getYesPixmap() const { return *m_yesPixmap; }
102 QPixmap getYesPartialPixmap() const { return *m_yesPartialPixmap; }
103
104public Q_SLOTS:
105 void slotAddEntry();
106 void slotEditEntry();
107 void slotRemoveEntry();
108 void setACL( const KACL &anACL );
109 void setDefaultACL( const KACL &anACL );
110
111protected Q_SLOTS:
112 void slotItemClicked( QTreeWidgetItem* pItem, int col );
113protected:
114 void contentsMousePressEvent( QMouseEvent * e );
115
116private:
117 void fillItemsFromACL( const KACL &pACL, bool defaults = false );
118 KACL itemsToACL( bool defaults ) const;
119
120 KACL m_ACL;
121 KACL m_defaultACL;
122 unsigned short m_mask;
123 bool m_hasMask;
124 bool m_allowDefaults;
125 QStringList m_allUsers;
126 QStringList m_allGroups;
127 QPixmap* m_yesPixmap;
128 QPixmap* m_yesPartialPixmap;
129};
130
131class EditACLEntryDialog : public KDialog
132{
133 Q_OBJECT
134public:
135 EditACLEntryDialog( KACLListView *listView, KACLListViewItem *item,
136 const QStringList &users,
137 const QStringList &groups,
138 const QStringList &defaultUsers,
139 const QStringList &defaultGroups,
140 int allowedTypes = KACLListView::AllTypes,
141 int allowedDefaultTypes = KACLListView::AllTypes,
142 bool allowDefault = false );
143 KACLListViewItem* item() const { return m_item; }
144public Q_SLOTS:
145 void slotOk();
146 void slotSelectionChanged( QAbstractButton* );
147private Q_SLOTS:
148 void slotUpdateAllowedUsersAndGroups();
149 void slotUpdateAllowedTypes();
150private:
151 KACLListView *m_listView;
152 KACLListViewItem *m_item;
153 QStringList m_users;
154 QStringList m_groups;
155 QStringList m_defaultUsers;
156 QStringList m_defaultGroups;
157 int m_allowedTypes;
158 int m_allowedDefaultTypes;
159 QButtonGroup *m_buttonGroup;
160 KComboBox *m_usersCombo;
161 KComboBox *m_groupsCombo;
162 QStackedWidget *m_widgetStack;
163 QCheckBox *m_defaultCB;
164 QHash<QAbstractButton*, int> m_buttonIds;
165};
166
167
168class KACLListViewItem : public QTreeWidgetItem
169{
170public:
171 KACLListViewItem( QTreeWidget* parent, KACLListView::EntryType type,
172 unsigned short value,
173 bool defaultEntry,
174 const QString& qualifier = QString() );
175 virtual ~KACLListViewItem();
176 QString key() const;
177 bool operator< ( const QTreeWidgetItem & other ) const;
178
179 void calcEffectiveRights();
180
181 bool isDeletable() const;
182 bool isAllowedToChangeType() const;
183
184 void togglePerm( acl_perm_t perm );
185
186#if 0
187 virtual void paintCell( QPainter *p, const QColorGroup &cg,
188 int column, int width, int alignment );
189#endif
190
191 void updatePermPixmaps();
192 void repaint();
193
194 KACLListView::EntryType type;
195 unsigned short value;
196 bool isDefault;
197 QString qualifier;
198 bool isPartial;
199
200private:
201 KACLListView* m_pACLListView;
202};
203
204
205#endif
206#endif
KACL
The KACL class encapsulates a POSIX Access Control List.
Definition: kacl.h:48
KComboBox
KDialog
QHash
QTreeWidget
QWidget
kacl.h
kcombobox.h
kdialog.h
kfileitem.h
Group
Group
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal