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

kalarm

  • sources
  • kde-4.14
  • kdepim
  • kalarm
calendarcompat.cpp
Go to the documentation of this file.
1 /*
2  * calendarcompat.cpp - compatibility for old calendar file formats
3  * Program: kalarm
4  * Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #include "calendarcompat.h"
22 #include "functions.h"
23 #include "mainwindow.h"
24 #include "messagebox.h"
25 
26 #include <kcal/calendarlocal.h>
27 
28 #include <kdebug.h>
29 
30 namespace CalendarCompat
31 {
32 
33 /******************************************************************************
34 * Find the version of KAlarm which wrote the calendar file, and do any
35 * necessary conversions to the current format. If it is a resource calendar,
36 * the user is prompted whether to save the conversions. For a local calendar
37 * file, any conversions will only be saved if changes are made later.
38 * If the calendar only contains the wrong alarm types, 'wrongType' is set true.
39 * Reply = true if the calendar file is now in the current format.
40 */
41 KACalendar::Compat fix(KCal::CalendarLocal& calendar, const QString& localFile, AlarmResource* resource,
42  AlarmResource::FixFunc conv, bool* wrongType)
43 {
44  if (wrongType)
45  *wrongType = false;
46  QString versionString;
47  int version = KACalendar::updateVersion(calendar, localFile, versionString);
48  if (version == KACalendar::IncompatibleFormat)
49  return KACalendar::Incompatible; // calendar was created by another program, or an unknown version of KAlarm
50  if (!resource)
51  return KACalendar::Current; // update non-shared calendars regardless
52 
53  // Check whether the alarm types in the calendar correspond with the resource's alarm type
54  if (wrongType)
55  *wrongType = !resource->checkAlarmTypes(calendar);
56 
57  if (version == KACalendar::CurrentFormat)
58  return KACalendar::Current; // calendar is in current KAlarm format
59  if (resource->ResourceCached::readOnly() || conv == AlarmResource::NO_CONVERT)
60  return KACalendar::Convertible;
61  // Update the calendar file now if the user wants it to be read-write
62  if (conv == AlarmResource::PROMPT || conv == AlarmResource::PROMPT_PART)
63  {
64  QString msg = KAlarm::conversionPrompt(resource->resourceName(), versionString, (conv == AlarmResource::PROMPT));
65  if (KAMessageBox::warningYesNo(MainWindow::mainMainWindow(), msg) != KMessageBox::Yes)
66  return KACalendar::Convertible;
67  }
68  KACalendar::setKAlarmVersion(calendar);
69  return KACalendar::Converted;
70 }
71 
72 } // namespace CalendarCompat
73 
74 // vim: et sw=4:
CalendarCompat::fix
KACalendar::Compat fix(KCal::CalendarLocal &calendar, const QString &localFile, AlarmResource *resource, AlarmResource::FixFunc conv, bool *wrongType)
Definition: calendarcompat.cpp:41
mainwindow.h
main application window
messagebox.h
QString
KAMessageBox::warningYesNo
static int warningYesNo(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonYes=KStandardGuiItem::yes(), const KGuiItem &buttonNo=KStandardGuiItem::no(), const QString &dontAskAgainName=QString(), Options options=Options(Notify|Dangerous|WindowModal))
functions.h
miscellaneous functions
MainWindow::mainMainWindow
static MainWindow * mainMainWindow()
Definition: mainwindow.cpp:286
calendarcompat.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm

Skip menu "kalarm"
  • 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
  • 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