You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
207 lines
6.5 KiB
207 lines
6.5 KiB
15 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2005 by Sean Harmer <sh@rama.homelinux.org> *
|
||
|
* Till Adam <adam@kde.org> *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU Library General Public License as *
|
||
|
* published by the Free Software Foundation; either version 2 of the *
|
||
|
* License, or (at your option) any later version. *
|
||
|
* *
|
||
|
* This program 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 General Public License for more details. *
|
||
|
* *
|
||
|
* You should have received a copy of the GNU General Public License *
|
||
|
* along with this program; if not, write to the *
|
||
|
* Free Software Foundation, Inc., *
|
||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||
|
***************************************************************************/
|
||
|
#ifndef KACLEDITWIDGET_P_H
|
||
|
#define KACLEDITWIDGET_P_H
|
||
|
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <config.h>
|
||
|
#endif
|
||
|
|
||
14 years ago
|
#ifdef Q_MOC_RUN
|
||
|
#define USE_POSIX_ACL
|
||
|
#endif // Q_MOC_RUN
|
||
|
|
||
15 years ago
|
#ifdef USE_POSIX_ACL
|
||
|
#include <klistview.h>
|
||
|
#include <sys/acl.h>
|
||
|
#include <kacl.h>
|
||
12 years ago
|
#include <tdefileitem.h>
|
||
15 years ago
|
#include <kdialogbase.h>
|
||
15 years ago
|
#include <tqpixmap.h>
|
||
|
#include <tqcombobox.h>
|
||
15 years ago
|
|
||
|
class KACLListViewItem;
|
||
15 years ago
|
class TQPushButton;
|
||
|
class TQVButtonGroup;
|
||
15 years ago
|
class KACLListView;
|
||
15 years ago
|
class TQWidgetStack;
|
||
|
class TQCheckBox;
|
||
15 years ago
|
|
||
|
/**
|
||
|
@author Sean Harmer
|
||
|
*/
|
||
|
class KACLListView : public KListView
|
||
|
{
|
||
14 years ago
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
friend class KACLListViewItem;
|
||
|
public:
|
||
|
enum Types
|
||
|
{
|
||
|
OWNER_IDX = 0,
|
||
|
GROUP_IDX,
|
||
|
OTHERS_IDX,
|
||
|
MASK_IDX,
|
||
|
NAMED_USER_IDX,
|
||
|
NAMED_GROUP_IDX,
|
||
|
LAST_IDX
|
||
|
};
|
||
|
enum EntryType { User = 1,
|
||
|
Group = 2,
|
||
|
Others = 4,
|
||
|
Mask = 8,
|
||
|
NamedUser = 16,
|
||
|
NamedGroup = 32,
|
||
|
AllTypes = 63 };
|
||
|
|
||
15 years ago
|
KACLListView( TQWidget* parent = 0, const char* name = 0 );
|
||
15 years ago
|
~KACLListView();
|
||
|
|
||
|
bool hasMaskEntry() const { return m_hasMask; }
|
||
|
bool hasDefaultEntries() const;
|
||
|
bool allowDefaults() const { return m_allowDefaults; }
|
||
|
void setAllowDefaults( bool v ) { m_allowDefaults = v; }
|
||
14 years ago
|
unsigned short maskPermissions() const;
|
||
|
void setMaskPermissions( unsigned short maskPerms );
|
||
|
acl_perm_t maskPartialPermissions() const;
|
||
|
void setMaskPartialPermissions( acl_perm_t maskPerms );
|
||
15 years ago
|
|
||
14 years ago
|
bool maskCanBeDeleted() const;
|
||
15 years ago
|
bool defaultMaskCanBeDeleted() const;
|
||
|
|
||
14 years ago
|
const KACLListViewItem* findDefaultItemByType( EntryType type ) const;
|
||
|
const KACLListViewItem* findItemByType( EntryType type,
|
||
15 years ago
|
bool defaults = false ) const;
|
||
|
unsigned short calculateMaskValue( bool defaults ) const;
|
||
|
void calculateEffectiveRights();
|
||
|
|
||
15 years ago
|
TQStringList allowedUsers( bool defaults, KACLListViewItem *allowedItem = 0 );
|
||
|
TQStringList allowedGroups( bool defaults, KACLListViewItem *allowedItem = 0 );
|
||
15 years ago
|
|
||
|
const KACL getACL() const { return getACL(); }
|
||
|
KACL getACL();
|
||
|
|
||
|
const KACL getDefaultACL() const { return getDefaultACL(); }
|
||
|
KACL getDefaultACL();
|
||
|
|
||
15 years ago
|
TQPixmap getYesPixmap() const { return *m_yesPixmap; }
|
||
|
TQPixmap getYesPartialPixmap() const { return *m_yesPartialPixmap; }
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
void slotAddEntry();
|
||
|
void slotEditEntry();
|
||
|
void slotRemoveEntry();
|
||
|
void setACL( const KACL &anACL );
|
||
|
void setDefaultACL( const KACL &anACL );
|
||
|
|
||
|
protected slots:
|
||
15 years ago
|
void entryClicked( TQListViewItem* pItem, const TQPoint& pt, int col );
|
||
15 years ago
|
protected:
|
||
15 years ago
|
void contentsMousePressEvent( TQMouseEvent * e );
|
||
15 years ago
|
|
||
|
private:
|
||
|
void fillItemsFromACL( const KACL &pACL, bool defaults = false );
|
||
|
KACL itemsToACL( bool defaults ) const;
|
||
|
|
||
|
KACL m_ACL;
|
||
|
KACL m_defaultACL;
|
||
14 years ago
|
unsigned short m_mask;
|
||
15 years ago
|
bool m_hasMask;
|
||
|
bool m_allowDefaults;
|
||
15 years ago
|
TQStringList m_allUsers;
|
||
|
TQStringList m_allGroups;
|
||
|
TQPixmap* m_yesPixmap;
|
||
|
TQPixmap* m_yesPartialPixmap;
|
||
15 years ago
|
};
|
||
|
|
||
|
class EditACLEntryDialog : public KDialogBase
|
||
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
|
EditACLEntryDialog( KACLListView *listView, KACLListViewItem *item,
|
||
15 years ago
|
const TQStringList &users,
|
||
|
const TQStringList &groups,
|
||
|
const TQStringList &defaultUsers,
|
||
|
const TQStringList &defaultGroups,
|
||
15 years ago
|
int allowedTypes = KACLListView::AllTypes,
|
||
|
int allowedDefaultTypes = KACLListView::AllTypes,
|
||
|
bool allowDefault = false );
|
||
|
KACLListViewItem* item() const { return m_item; }
|
||
|
public slots:
|
||
|
void slotOk();
|
||
|
void slotSelectionChanged( int id );
|
||
|
private slots:
|
||
|
void slotUpdateAllowedUsersAndGroups();
|
||
|
void slotUpdateAllowedTypes();
|
||
|
private:
|
||
|
KACLListView *m_listView;
|
||
|
KACLListViewItem *m_item;
|
||
15 years ago
|
TQStringList m_users;
|
||
|
TQStringList m_groups;
|
||
|
TQStringList m_defaultUsers;
|
||
|
TQStringList m_defaultGroups;
|
||
15 years ago
|
int m_allowedTypes;
|
||
|
int m_allowedDefaultTypes;
|
||
15 years ago
|
TQVButtonGroup *m_buttonGroup;
|
||
|
TQComboBox *m_usersCombo;
|
||
|
TQComboBox *m_groupsCombo;
|
||
|
TQWidgetStack *m_widgetStack;
|
||
|
TQCheckBox *m_defaultCB;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
class KACLListViewItem : public KListViewItem
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
KACLListViewItem( TQListView* parent, KACLListView::EntryType type,
|
||
15 years ago
|
unsigned short value,
|
||
|
bool defaultEntry,
|
||
15 years ago
|
const TQString& qualifier = TQString::null );
|
||
15 years ago
|
virtual ~KACLListViewItem();
|
||
15 years ago
|
virtual TQString key( int column, bool ascending ) const;
|
||
15 years ago
|
|
||
|
void calcEffectiveRights();
|
||
|
|
||
|
bool isDeletable() const;
|
||
|
bool isAllowedToChangeType() const;
|
||
|
|
||
|
void togglePerm( acl_perm_t perm );
|
||
|
|
||
15 years ago
|
virtual void paintCell( TQPainter *p, const TQColorGroup &cg,
|
||
13 years ago
|
int column, int width, int alignment );
|
||
15 years ago
|
|
||
|
void updatePermPixmaps();
|
||
13 years ago
|
void repaint();
|
||
15 years ago
|
|
||
|
KACLListView::EntryType type;
|
||
|
unsigned short value;
|
||
|
bool isDefault;
|
||
15 years ago
|
TQString qualifier;
|
||
15 years ago
|
bool isPartial;
|
||
|
|
||
|
private:
|
||
|
KACLListView* m_pACLListView;
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|
||
|
#endif
|