00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KLDAP_LDAPMODEL_H
00022 #define KLDAP_LDAPMODEL_H
00023
00024 #include <QtCore/QAbstractItemModel>
00025
00026 #include "ldapconnection.h"
00027 #include "ldapobject.h"
00028 #include "kldap_export.h"
00029
00030 namespace KLDAP {
00031
00042 class KLDAP_EXPORT LdapModel : public QAbstractItemModel
00043 {
00044 Q_OBJECT
00045 public:
00046 enum Roles {
00047 NodeTypeRole = Qt::UserRole + 1
00048 };
00049
00050 enum LdapDataType {
00051 DistinguishedName = 0,
00052 Attribute
00053 };
00054
00063 explicit LdapModel( QObject *parent = 0 );
00071 explicit LdapModel( LdapConnection &connection, QObject *parent = 0 );
00072 virtual ~LdapModel();
00073
00080 void setConnection( LdapConnection &connection );
00081
00082
00083
00084
00088 virtual QModelIndex index( int row, int col, const QModelIndex &parent ) const;
00092 virtual QModelIndex parent( const QModelIndex &child ) const;
00096 virtual QVariant data( const QModelIndex &index, int role ) const;
00101 virtual bool setData( const QModelIndex &index,
00102 const QVariant &value,
00103 int role = Qt::EditRole );
00107 virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
00111 virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00115 virtual int columnCount( const QModelIndex &parent ) const;
00119 virtual int rowCount( const QModelIndex &parent ) const;
00123 virtual bool hasChildren( const QModelIndex &parent ) const;
00127 virtual bool canFetchMore( const QModelIndex &parent ) const;
00131 virtual void fetchMore( const QModelIndex &parent );
00136 virtual bool insertRows( int row, int count,
00137 const QModelIndex &parent = QModelIndex() );
00142 virtual bool removeRows( int row, int count,
00143 const QModelIndex &parent = QModelIndex() );
00148 virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
00149
00150
00151
00152
00157 virtual Qt::DropActions supportedDropActions() const;
00162 virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
00167 virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action,
00168 int row, int column, const QModelIndex &parent );
00169
00170
00171
00172
00182 bool hasChildrenOfType( const QModelIndex &parent, LdapDataType type ) const;
00183
00184 public Q_SLOTS:
00189 virtual void revert();
00194 virtual bool submit();
00195
00196 Q_SIGNALS:
00204 void ready();
00205
00206 private:
00207 class LdapModelPrivate;
00208 LdapModelPrivate *const m_d;
00209
00210 Q_PRIVATE_SLOT( m_d, void gotSearchResult( KLDAP::LdapSearch* ) )
00211 Q_PRIVATE_SLOT( m_d, void gotSearchData( KLDAP::LdapSearch*, const KLDAP::LdapObject& ) )
00212 };
00213
00214 }
00215 #endif