KLDAP Library
ldapstructureproxymodel.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "ldapstructureproxymodel.h"
00022 #include "ldapmodel.h"
00023 #include "ldapmodelnode_p.h"
00024
00025 #include <kdebug.h>
00026 #include <klocale.h>
00027
00028 using namespace KLDAP;
00029
00030 class LdapStructureProxyModel::LdapStructureProxyModelPrivate
00031 {
00032 public:
00033 LdapStructureProxyModelPrivate();
00034
00035 };
00036
00037 LdapStructureProxyModel::LdapStructureProxyModelPrivate::LdapStructureProxyModelPrivate()
00038 {
00039
00040 }
00041
00042 LdapStructureProxyModel::LdapStructureProxyModel( QObject *parent )
00043 : QSortFilterProxyModel( parent ),
00044 m_d( new LdapStructureProxyModelPrivate() )
00045 {
00046
00047 }
00048
00049 LdapStructureProxyModel::~LdapStructureProxyModel()
00050 {
00051 delete m_d;
00052 }
00053
00054 QVariant LdapStructureProxyModel::data( const QModelIndex &index,
00055 int role ) const
00056 {
00057
00058
00059 return sourceModel()->data( mapToSource( index ), role );
00060 }
00061
00062 bool LdapStructureProxyModel::setData( const QModelIndex &index,
00063 const QVariant &value,
00064 int role )
00065 {
00066 Q_UNUSED( index );
00067 Q_UNUSED( value );
00068 Q_UNUSED( role );
00069 return false;
00070 }
00071
00072 bool LdapStructureProxyModel::filterAcceptsRow( int sourceRow,
00073 const QModelIndex &sourceParent ) const
00074 {
00075 QModelIndex idx = sourceModel()->index( sourceRow, 0, sourceParent );
00076 LdapModelNode::NodeType nodeType =
00077 static_cast<LdapModelNode::NodeType>(
00078 sourceModel()->data( idx, LdapModel::NodeTypeRole ).toUInt() );
00079 return nodeType == LdapModelNode::DN;
00080 }
00081
00082 QVariant LdapStructureProxyModel::headerData( int section,
00083 Qt::Orientation orientation,
00084 int role ) const
00085 {
00086 Q_UNUSED( section );
00087 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
00088 return QString( i18n( "Distinguished Name" ) );
00089 }
00090
00091 return QVariant();
00092 }
00093
00094 int LdapStructureProxyModel::columnCount( const QModelIndex & ) const
00095 {
00096
00097 return 1;
00098 }
00099
00100 Qt::ItemFlags LdapStructureProxyModel::flags( const QModelIndex &index ) const
00101 {
00102
00103 return sourceModel()->flags( mapToSource( index ) );
00104 }
00105
00106 bool LdapStructureProxyModel::hasChildren( const QModelIndex &parent ) const
00107 {
00108
00109
00110 LdapModel *model = static_cast<LdapModel*>( sourceModel() );
00111 return model->hasChildrenOfType( mapToSource( parent ), LdapModel::DistinguishedName );
00112 }
00113
00114 QModelIndex LdapStructureProxyModel::mapFromSource( const QModelIndex &sourceIndex ) const
00115 {
00116 return QSortFilterProxyModel::mapFromSource( sourceIndex );
00117 }
00118
00119 QModelIndex LdapStructureProxyModel::mapToSource( const QModelIndex &proxyIndex ) const
00120 {
00121 return QSortFilterProxyModel::mapToSource( proxyIndex );
00122 }
00123
00124 bool LdapStructureProxyModel::insertRows( int row, int count,
00125 const QModelIndex &parent )
00126 {
00127 Q_UNUSED( row );
00128 Q_UNUSED( count );
00129 Q_UNUSED( parent );
00130 return false;
00131 }
00132
00133 bool LdapStructureProxyModel::removeRows( int row, int count,
00134 const QModelIndex &parent )
00135 {
00136 Q_UNUSED( row );
00137 Q_UNUSED( count );
00138 Q_UNUSED( parent );
00139 return false;
00140 }
00141
00142 void LdapStructureProxyModel::sort( int column, Qt::SortOrder order )
00143 {
00144 Q_UNUSED( column );
00145 Q_UNUSED( order );
00146 }
00147
00148 Qt::DropActions LdapStructureProxyModel::supportedDropActions() const
00149 {
00150 return Qt::MoveAction;
00151 }
00152
00153 QMimeData *LdapStructureProxyModel::mimeData( const QModelIndexList &indexes ) const
00154 {
00155 Q_UNUSED( indexes );
00156 return 0;
00157 }
00158
00159 bool LdapStructureProxyModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
00160 int row, int column, const QModelIndex &parent )
00161 {
00163 Q_UNUSED( data );
00164 Q_UNUSED( action );
00165 Q_UNUSED( row );
00166 Q_UNUSED( column );
00167 Q_UNUSED( parent );
00168 return false;
00169 }
00170
00171 #include "ldapstructureproxymodel.moc"