Fix wrong connect
[kdepim.git] / calendarsupport / calendarsingleton.cpp
blobdba54069ca4762a3245e2d90c00c1aaad2d85c26
1 /*
2 Copyright (c) 2013 Sérgio Martins <iamsergio@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 As a special exception, permission is given to link this program
19 with any edition of Qt, and distribute the resulting executable,
20 without including the source code for Qt in the source distribution.
23 #include "calendarsingleton.h"
24 #include "kcalprefs.h"
26 #include <Akonadi/Calendar/ETMCalendar>
27 #include <KCalCore/Person>
29 /**
30 * Singleton is implemented through qApp parenting because we can't rely on K_GLOBAL_STATIC.
32 * QWidgets and QAbstractItemModels can't be global because their dtor depends on other globals
33 * and the order of global destruction is undefined.
35 Akonadi::ETMCalendar::Ptr CalendarSupport::calendarSingleton(bool createIfNull)
37 static Akonadi::ETMCalendar::Ptr calendar;
39 if (!calendar && createIfNull) {
40 calendar = Akonadi::ETMCalendar::Ptr(new Akonadi::ETMCalendar());
41 calendar->setCollectionFilteringEnabled(false);
42 calendar->setOwner(KCalCore::Person::Ptr(new KCalCore::Person(KCalPrefs::instance()->fullName(),
43 KCalPrefs::instance()->email())));
46 return calendar;