• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KLDAP Library

ldapstructureproxymodel.cpp

00001 /*
00002   This file is part of libkldap.
00003   Copyright (c) 2006 Sean Harmer <sh@theharmers.co.uk>
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General  Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public License
00016   along with this library; see the file COPYING.LIB.  If not, write to
00017   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018   Boston, MA 02110-1301, USA.
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   // Included just in case we decide to do any special presentation of the data
00058   // at some other point throughout the 4.x series.
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   if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
00087     return QString( i18n( "Distinguished Name" ) );
00088   }
00089 
00090   return QVariant();
00091 }
00092 
00093 int LdapStructureProxyModel::columnCount( const QModelIndex &/*parent*/ ) const
00094 {
00095   // No need for more than one column just to show the structure
00096   return 1;
00097 }
00098 
00099 Qt::ItemFlags LdapStructureProxyModel::flags( const QModelIndex &index ) const
00100 {
00101   // Included so as not to break BC in case we wish to use this later in 4.x
00102   return sourceModel()->flags( mapToSource( index ) );
00103 }
00104 
00105 bool LdapStructureProxyModel::hasChildren( const QModelIndex &parent ) const
00106 {
00107   // We need to handle this carefully bacause of the filtering out of attributes
00108   // and the lazy population approach.
00109   LdapModel *model = static_cast<LdapModel*>( sourceModel() );
00110   return model->hasChildrenOfType( mapToSource( parent ), LdapModel::DistinguishedName );
00111 }
00112 
00113 QModelIndex LdapStructureProxyModel::mapFromSource( const QModelIndex &sourceIndex ) const
00114 {
00115   return QSortFilterProxyModel::mapFromSource( sourceIndex );
00116 }
00117 
00118 QModelIndex LdapStructureProxyModel::mapToSource( const QModelIndex &proxyIndex ) const
00119 {
00120   return QSortFilterProxyModel::mapToSource( proxyIndex );
00121 }
00122 
00123 bool LdapStructureProxyModel::insertRows( int row, int count,
00124                                           const QModelIndex &parent )
00125 {
00126   Q_UNUSED( row );
00127   Q_UNUSED( count );
00128   Q_UNUSED( parent );
00129   return false;
00130 }
00131 
00132 bool LdapStructureProxyModel::removeRows( int row, int count,
00133                                           const QModelIndex &parent )
00134 {
00135   Q_UNUSED( row );
00136   Q_UNUSED( count );
00137   Q_UNUSED( parent );
00138   return false;
00139 }
00140 
00141 void LdapStructureProxyModel::sort( int column, Qt::SortOrder order )
00142 {
00143   Q_UNUSED( column );
00144   Q_UNUSED( order );
00145 }
00146 
00147 Qt::DropActions LdapStructureProxyModel::supportedDropActions() const
00148 {
00149   return Qt::MoveAction;
00150 }
00151 
00152 QMimeData *LdapStructureProxyModel::mimeData( const QModelIndexList &indexes ) const
00153 {
00154   Q_UNUSED( indexes );
00155   return 0;
00156 }
00157 
00158 bool LdapStructureProxyModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
00159                                             int row, int column, const QModelIndex &parent )
00160 {
00162   Q_UNUSED( data );
00163   Q_UNUSED( action );
00164   Q_UNUSED( row );
00165   Q_UNUSED( column );
00166   Q_UNUSED( parent );
00167   return false;
00168 }
00169 
00170 #include "ldapstructureproxymodel.moc"

KLDAP Library

Skip menu "KLDAP Library"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal