• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

akonadi

selectionproxymodel.cpp
00001 /*
00002   Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
00003 
00004   This library is free software; you can redistribute it and/or modify it
00005   under the terms of the GNU Library General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or (at your
00007   option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful, but WITHOUT
00010   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012   License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public License
00015   along with this library; see the file COPYING.LIB.  If not, write to the
00016   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017   02110-1301, USA.
00018 */
00019 
00020 #include "selectionproxymodel.h"
00021 
00022 #include "entitytreemodel.h"
00023 
00024 using namespace Akonadi;
00025 
00026 namespace Akonadi
00027 {
00028 
00029 class SelectionProxyModelPrivate
00030 {
00031 public:
00032   SelectionProxyModelPrivate( SelectionProxyModel *selectionProxyModel )
00033     : q_ptr( selectionProxyModel )
00034   {
00035       Q_Q( SelectionProxyModel );
00036       foreach ( const QModelIndex &rootIndex, q->sourceRootIndexes() ) {
00037         rootIndexAdded( rootIndex );
00038         q->sourceModel()->fetchMore( rootIndex );
00039       }
00040   }
00041 
00045   void rootIndexAdded( const QModelIndex &newRootIndex )
00046   {
00047     Q_Q( SelectionProxyModel );
00048     // newRootIndex is already in the sourceModel.
00049     q->sourceModel()->setData( newRootIndex, QVariant(), EntityTreeModel::CollectionRefRole );
00050     q->sourceModel()->fetchMore( newRootIndex );
00051   }
00052 
00056   void rootIndexAboutToBeRemoved( const QModelIndex &removedRootIndex )
00057   {
00058     Q_Q( SelectionProxyModel );
00059     q->sourceModel()->setData( removedRootIndex, QVariant(), EntityTreeModel::CollectionDerefRole );
00060   }
00061 
00062   Q_DECLARE_PUBLIC( SelectionProxyModel )
00063   SelectionProxyModel *q_ptr;
00064 };
00065 
00066 }
00067 
00068 SelectionProxyModel::SelectionProxyModel( QItemSelectionModel *selectionModel, QObject *parent )
00069   : KSelectionProxyModel( selectionModel, parent ), d_ptr( new SelectionProxyModelPrivate( this ) )
00070 {
00071   connect( this, SIGNAL(rootIndexAdded(QModelIndex)), SLOT(rootIndexAdded(QModelIndex)) );
00072   connect( this, SIGNAL(rootIndexAboutToBeRemoved(QModelIndex)), SLOT(rootIndexAboutToBeRemoved(QModelIndex)) );
00073 }
00074 
00075 SelectionProxyModel::~SelectionProxyModel()
00076 {
00077   delete d_ptr;
00078 }
00079 
00080 #include "selectionproxymodel.moc"
00081 
00082 

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.6.1
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