• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

calendarsupport

  • sources
  • kde-4.12
  • kdepim
  • calendarsupport
collectionselection.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009 KDAB
3  Author: Frank Osterfeld <frank@kdab.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19  As a special exception, permission is given to link this program
20  with any edition of Qt, and distribute the resulting executable,
21  without including the source code for Qt in the source distribution.
22 */
23 
24 #include "collectionselection.h"
25 #include "utils.h"
26 
27 #include <QItemSelectionModel>
28 
29 using namespace CalendarSupport;
30 
31 class CollectionSelection::Private
32 {
33  public:
34  explicit Private( QItemSelectionModel *model_ ) : model( model_ )
35  {
36  }
37 
38  QItemSelectionModel *model;
39 };
40 
41 CollectionSelection::CollectionSelection( QItemSelectionModel *selectionModel, QObject *parent )
42  : QObject( parent ), d( new Private ( selectionModel ) )
43 {
44  connect( selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
45  this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)) );
46 }
47 
48 CollectionSelection::~CollectionSelection()
49 {
50  delete d;
51 }
52 
53 QItemSelectionModel *CollectionSelection::model() const
54 {
55  return d->model;
56 }
57 
58 bool CollectionSelection::hasSelection() const
59 {
60  return d->model->hasSelection();
61 }
62 
63 bool CollectionSelection::contains( const Akonadi::Collection &c ) const
64 {
65  return selectedCollectionIds().contains( c.id() );
66 }
67 
68 bool CollectionSelection::contains( const Akonadi::Collection::Id &id ) const
69 {
70  return selectedCollectionIds().contains( id );
71 }
72 
73 Akonadi::Collection::List CollectionSelection::selectedCollections() const
74 {
75  Akonadi::Collection::List selected;
76  Q_FOREACH ( const QModelIndex &idx, d->model->selectedIndexes() ) {
77  selected.append( collectionFromIndex( idx ) );
78  }
79  return selected;
80 }
81 
82 QList<Akonadi::Collection::Id> CollectionSelection::selectedCollectionIds() const
83 {
84  QList<Akonadi::Collection::Id> selected;
85  Q_FOREACH ( const QModelIndex &idx, d->model->selectedIndexes() ) {
86  selected.append( collectionIdFromIndex( idx ) );
87  }
88  return selected;
89 }
90 
91 void CollectionSelection::slotSelectionChanged( const QItemSelection &selectedIndexes,
92  const QItemSelection &deselIndexes )
93 {
94  const Akonadi::Collection::List selected = collectionsFromIndexes( selectedIndexes.indexes() );
95  const Akonadi::Collection::List deselected = collectionsFromIndexes( deselIndexes.indexes() );
96 
97  emit selectionChanged( selected, deselected );
98  Q_FOREACH ( const Akonadi::Collection &c, deselected ) {
99  emit collectionDeselected( c );
100  }
101  Q_FOREACH ( const Akonadi::Collection &c, selected ) {
102  emit collectionSelected( c );
103  }
104 }
CalendarSupport::CollectionSelection::hasSelection
bool hasSelection() const
Definition: collectionselection.cpp:58
CalendarSupport::CollectionSelection::collectionDeselected
void collectionDeselected(const Akonadi::Collection &)
collectionselection.h
CalendarSupport::CollectionSelection::CollectionSelection
CollectionSelection(QItemSelectionModel *selectionModel, QObject *parent=0)
Definition: collectionselection.cpp:41
CalendarSupport::CollectionSelection::selectionChanged
void selectionChanged(const Akonadi::Collection::List &selected, const Akonadi::Collection::List &deselected)
QObject
utils.h
CalendarSupport::CollectionSelection::selectedCollectionIds
QList< Akonadi::Collection::Id > selectedCollectionIds() const
Definition: collectionselection.cpp:82
CalendarSupport::CollectionSelection::contains
bool contains(const Akonadi::Collection &c) const
Definition: collectionselection.cpp:63
CalendarSupport::CollectionSelection::collectionSelected
void collectionSelected(const Akonadi::Collection &)
CalendarSupport::CollectionSelection::model
QItemSelectionModel * model() const
Definition: collectionselection.cpp:53
CalendarSupport::collectionsFromIndexes
CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromIndexes(const QModelIndexList &indexes)
Definition: utils.cpp:488
CalendarSupport::collectionFromIndex
CALENDARSUPPORT_EXPORT Akonadi::Collection collectionFromIndex(const QModelIndex &index)
Definition: utils.cpp:478
CalendarSupport::collectionIdFromIndex
CALENDARSUPPORT_EXPORT Akonadi::Collection::Id collectionIdFromIndex(const QModelIndex &index)
Definition: utils.cpp:483
CalendarSupport::CollectionSelection::~CollectionSelection
~CollectionSelection()
Definition: collectionselection.cpp:48
CalendarSupport::CollectionSelection::selectedCollections
Akonadi::Collection::List selectedCollections() const
Definition: collectionselection.cpp:73
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

calendarsupport

Skip menu "calendarsupport"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal