KLDAP Library
ldapattributeproxymodel.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "ldapattributeproxymodel.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 LdapAttributeProxyModel::LdapAttributeProxyModelPrivate
00031 {
00032 public:
00033 LdapAttributeProxyModelPrivate();
00034
00035 };
00036
00037 LdapAttributeProxyModel::LdapAttributeProxyModelPrivate::LdapAttributeProxyModelPrivate()
00038 {
00039
00040 }
00041
00042 LdapAttributeProxyModel::LdapAttributeProxyModel( QObject *parent )
00043 : QSortFilterProxyModel( parent ),
00044 m_d( new LdapAttributeProxyModelPrivate() )
00045 {
00046
00047 }
00048
00049 LdapAttributeProxyModel::~LdapAttributeProxyModel()
00050 {
00051 delete m_d;
00052 }
00053
00054 QVariant LdapAttributeProxyModel::data( const QModelIndex &index,
00055 int role ) const
00056 {
00057
00058
00059 return sourceModel()->data( mapToSource( index ), role );
00060 }
00061
00062 bool LdapAttributeProxyModel::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 LdapAttributeProxyModel::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::Attr;
00080 }
00081
00082 QVariant LdapAttributeProxyModel::headerData( int section,
00083 Qt::Orientation orientation,
00084 int role ) const
00085 {
00086 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
00087 if ( section == 0 ) {
00088 return QVariant( QString( i18n( "Attribute" ) ) );
00089 } else if ( section == 1 ) {
00090 return QVariant( QString( i18n( "Value" ) ) );
00091 }
00092 }
00093
00094 return QVariant();
00095 }
00096
00097 int LdapAttributeProxyModel::columnCount( const QModelIndex & ) const
00098 {
00099 return 2;
00100 }
00101
00102 Qt::ItemFlags LdapAttributeProxyModel::flags( const QModelIndex &index ) const
00103 {
00104
00105 return sourceModel()->flags( mapToSource( index ) );
00106 }
00107
00108 bool LdapAttributeProxyModel::hasChildren( const QModelIndex &parent ) const
00109 {
00110
00111
00112 LdapModel *model = static_cast<LdapModel*>( sourceModel() );
00113 return model->hasChildrenOfType( mapToSource( parent ), LdapModel::Attribute );
00114 }
00115
00116 QModelIndex LdapAttributeProxyModel::mapFromSource( const QModelIndex &sourceIndex ) const
00117 {
00118 return QSortFilterProxyModel::mapFromSource( sourceIndex );
00119 }
00120
00121 QModelIndex LdapAttributeProxyModel::mapToSource( const QModelIndex &proxyIndex ) const
00122 {
00123 return QSortFilterProxyModel::mapToSource( proxyIndex );
00124 }
00125
00126 bool LdapAttributeProxyModel::insertRows( int row, int count,
00127 const QModelIndex &parent )
00128 {
00129 Q_UNUSED( row );
00130 Q_UNUSED( count );
00131 Q_UNUSED( parent );
00132 return false;
00133 }
00134
00135 bool LdapAttributeProxyModel::removeRows( int row, int count,
00136 const QModelIndex &parent )
00137 {
00138 Q_UNUSED( row );
00139 Q_UNUSED( count );
00140 Q_UNUSED( parent );
00141 return false;
00142 }
00143
00144 void LdapAttributeProxyModel::sort( int column, Qt::SortOrder order )
00145 {
00146 Q_UNUSED( column );
00147 Q_UNUSED( order );
00148 }
00149
00150 Qt::DropActions LdapAttributeProxyModel::supportedDropActions() const
00151 {
00152 return Qt::MoveAction;
00153 }
00154
00155 QMimeData *LdapAttributeProxyModel::mimeData( const QModelIndexList &indexes ) const
00156 {
00157 Q_UNUSED( indexes );
00158 return 0;
00159 }
00160
00161 bool LdapAttributeProxyModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
00162 int row, int column, const QModelIndex &parent )
00163 {
00165 Q_UNUSED( data );
00166 Q_UNUSED( action );
00167 Q_UNUSED( row );
00168 Q_UNUSED( column );
00169 Q_UNUSED( parent );
00170 return false;
00171 }
00172
00173 #include "ldapattributeproxymodel.moc"