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

akonadi

subscriptionchangeproxymodel.cpp

00001 /*
00002     Copyright (c) 2008 Volker Krause <vkrause@kde.org>
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 "subscriptionchangeproxymodel_p.h"
00021 #include "subscriptionmodel_p.h"
00022 
00023 #include <kdebug.h>
00024 #include <klocale.h>
00025 
00026 using namespace Akonadi;
00027 
00031 class SubscriptionChangeProxyModel::Private
00032 {
00033   public:
00034     Qt::CheckState subscribed;
00035 };
00036 
00037 SubscriptionChangeProxyModel::SubscriptionChangeProxyModel(bool subscribed, QObject * parent) :
00038     QSortFilterProxyModel( parent ),
00039     d( new Private )
00040 {
00041   d->subscribed = subscribed ? Qt::Checked : Qt::Unchecked;
00042   setDynamicSortFilter( true );
00043 }
00044 
00045 SubscriptionChangeProxyModel::~ SubscriptionChangeProxyModel()
00046 {
00047   delete d;
00048 }
00049 
00050 bool SubscriptionChangeProxyModel::filterAcceptsRow(int row, const QModelIndex & parent) const
00051 {
00052   QModelIndex index = sourceModel()->index( row, 0, parent );
00053   if ( !index.data( SubscriptionModel::SubscriptionChangedRole ).toBool() )
00054     return false;
00055   if ( index.data( Qt::CheckStateRole ) != d->subscribed )
00056     return false;
00057   return true;
00058 }
00059 
00060 QVariant SubscriptionChangeProxyModel::data(const QModelIndex & index, int role) const
00061 {
00062   if ( role == Qt::CheckStateRole )
00063     return QVariant();
00064   return QSortFilterProxyModel::data( index, role );
00065 }
00066 
00067 QVariant SubscriptionChangeProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
00068 {
00069   if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
00070     if ( d->subscribed == Qt::Checked )
00071       return i18nc( "@title:column", "Subscribe To" );
00072     else
00073       return i18nc( "@title:column", "Unsubscribe From" );
00074   }
00075   return QSortFilterProxyModel::headerData( section, orientation, role );
00076 }
00077 
00078 #include "subscriptionchangeproxymodel_p.moc"

akonadi

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

KDE-PIM Libraries

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