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

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • plugins
  • planner
stdcalendar.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "stdcalendar.h"
23 
24 #include <K3StaticDeleter>
25 #include <KConfigGroup>
26 #include <KStandardDirs>
27 #include <KSystemTimeZone>
28 #include <KUrl>
29 
30 using namespace KOrg;
31 
32 static K3StaticDeleter<StdCalendar> selfDeleter;
33 
34 StdCalendar *StdCalendar::mSelf = 0;
35 
36 StdCalendar *StdCalendar::self()
37 {
38  if ( !mSelf ) {
39  selfDeleter.setObject( mSelf, new StdCalendar() );
40  }
41  return mSelf;
42 }
43 
44 StdCalendar::StdCalendar()
45  : CalendarResources( KSystemTimeZones::local() )
46 {
47  readConfig();
48 
49  KCal::CalendarResourceManager *manager = resourceManager();
50  if ( manager->isEmpty() ) {
51  KConfig _config( "korganizerrc" );
52  KConfigGroup config(&_config, "General" );
53  QString fileName = config.readPathEntry( "Active Calendar", QString() );
54 
55  QString resourceName;
56  QString resoruceType;
57  KCal::ResourceCalendar *defaultResource = 0;
58  if ( !fileName.isEmpty() ) {
59  KUrl url( fileName );
60  if ( url.isLocalFile() ) {
61  kDebug() << "Local resource at" << url;
62  defaultResource = manager->createResource( "file" );
63  if ( defaultResource ) {
64  defaultResource->setValue( "File", url.toLocalFile() );
65  }
66  } else {
67  kDebug() << "Remote Resource at" << url;
68  defaultResource = manager->createResource( "remote" );
69  if ( defaultResource ) {
70  defaultResource->setValue( "URL", url.url() );
71  }
72  }
73  resourceName = i18n( "Active Calendar" );
74  }
75  // No resource created, i.e. no path found in config => use default path
76  if ( !defaultResource ) {
77  fileName = KStandardDirs::locateLocal( "data", "korganizer/std.ics" );
78  kDebug() << "Creating new default local resource at" << fileName;
79  defaultResource = manager->createResource( "file" );
80  if ( defaultResource ) {
81  defaultResource->setValue( "File", fileName );
82  }
83  resourceName = i18n( "Default Calendar" );
84  }
85 
86  if ( defaultResource ) {
87  defaultResource->setTimeSpec( KSystemTimeZones::local() );
88  defaultResource->setResourceName( resourceName );
89  manager->add( defaultResource );
90  manager->setStandardResource( defaultResource );
91  }
92 
93  // By default, also create a birthday resource
94  KCal::ResourceCalendar *bdayResource = manager->createResource( "birthdays" );
95  if ( bdayResource ) {
96  kDebug() << "Adding Birthdays resource";
97  bdayResource->setTimeSpec( KSystemTimeZones::local() );
98  bdayResource->setResourceName( i18n( "Birthdays" ) );
99  manager->add( bdayResource );
100  } else {
101  kDebug() << "Unable to add a Birthdays calendar";
102  }
103  }
104 }
105 
106 StdCalendar::~StdCalendar()
107 {
108  mSelf = 0;
109 }
stdcalendar.h
KOrg::StdCalendar::~StdCalendar
~StdCalendar()
Definition: stdcalendar.cpp:106
QString::isEmpty
bool isEmpty() const
QString
KOrg::StdCalendar::self
static StdCalendar * self()
Definition: stdcalendar.cpp:36
selfDeleter
static K3StaticDeleter< StdCalendar > selfDeleter
Definition: stdcalendar.cpp:32
KOrg::StdCalendar
Definition: stdcalendar.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • 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
  • pimprint

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