agendainterface/inc/agendautil.h
changeset 55 2c54b51f39c4
parent 51 0b38fc5b94c6
child 57 bb2d3e476f29
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Header file for AgendaUtil class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef AGENDAUTIL_H
       
    19 #define AGENDAUTIL_H
       
    20 
       
    21 // System includes
       
    22 #include <QObject>
       
    23 #include <QList>
       
    24 
       
    25 // User includes
       
    26 #include "agendaentry.h"
       
    27 #include "agendainterfacedefines.h"
       
    28 
       
    29 // Forward declarations
       
    30 class QDateTime;
       
    31 class AgendaUtilPrivate;
       
    32 
       
    33 class XQCALENDAR_EXPORT AgendaUtil : public QObject
       
    34 {
       
    35 	Q_OBJECT
       
    36 
       
    37 public:
       
    38 
       
    39 	enum Error {
       
    40 		NoError = 0,
       
    41 		OutOfMemoryError,
       
    42 		AlreadyInUse,
       
    43 		UnknownError = -1
       
    44 	};
       
    45 
       
    46 	enum FilterFlags {
       
    47 		IncludeAppointments = 0x01,
       
    48 		IncludeReminders = 0x02,
       
    49 		IncludeEvents = 0x04,
       
    50 		IncludeAnniversaries = 0x08,
       
    51 		IncludeCompletedTodos = 0x10,
       
    52 		IncludeIncompletedTodos = 0x20,
       
    53 		IncludeAlarmedOnly = 0x40,
       
    54 		IncludeRptsNextInstanceOnly = 0x80,
       
    55 		IncludeNotes=0x300,
       
    56 		IncludeAll=IncludeAppointments
       
    57 		| IncludeReminders
       
    58 		| IncludeEvents
       
    59 		| IncludeAnniversaries
       
    60 		| IncludeCompletedTodos
       
    61 		| IncludeIncompletedTodos
       
    62 		| IncludeNotes
       
    63 	};
       
    64 
       
    65 	enum RecurrenceRange {
       
    66 		ThisOnly,
       
    67 		ThisAndAll,
       
    68 		ThisAndFuture,
       
    69 		ThisAndPrior
       
    70 	};
       
    71 
       
    72 	AgendaUtil(QObject* parent = 0);
       
    73 	~AgendaUtil();
       
    74 
       
    75 	ulong addEntry(const AgendaEntry& entry);
       
    76 	ulong cloneEntry(const AgendaEntry& entry, AgendaEntry::Type type);
       
    77 	bool deleteEntry(ulong id);
       
    78 	void deleteRepeatedEntry(
       
    79 			AgendaEntry& entry, AgendaUtil::RecurrenceRange range);
       
    80 	bool updateEntry(const AgendaEntry& entry, bool isChild = false);
       
    81 	bool storeRepeatingEntry(const AgendaEntry& entry, bool copyToChildren);
       
    82 	bool createException(const AgendaEntry& entry);
       
    83 	QList<ulong> entryIds(
       
    84 			AgendaUtil::FilterFlags filter = AgendaUtil::IncludeAll);
       
    85 	QList<AgendaEntry> fetchAllEntries(
       
    86 			AgendaUtil::FilterFlags filter = AgendaUtil::IncludeAll);
       
    87 	QList<AgendaEntry> fetchEntriesInRange(
       
    88 			QDateTime rangeStart, QDateTime rangeEnd,
       
    89 			AgendaUtil::FilterFlags filter = AgendaUtil::IncludeAll);
       
    90 	QList<AgendaEntry> createEntryIdListForDay(
       
    91 			QDateTime day,
       
    92 			AgendaUtil::FilterFlags filter = AgendaUtil::IncludeAll);
       
    93 	AgendaEntry fetchById(ulong id);
       
    94 
       
    95 	int importvCalendar(const QString& fileName, AgendaEntry& entry);
       
    96 	bool exportAsvCalendar(const QString& fileName, long int calendarEntryId);
       
    97 
       
    98 	AgendaUtil::Error error() const;
       
    99 	void setCompleted(AgendaEntry& entry, bool complete, QDateTime& dateTime);
       
   100 	void deleteEntries(
       
   101 			QDateTime& start, QDateTime& end,
       
   102 			AgendaUtil::FilterFlags filter = AgendaUtil::IncludeAll);
       
   103 	AgendaEntry parentEntry(AgendaEntry& entry);
       
   104 	void clearRepeatingProperties(AgendaEntry& entry);
       
   105 	void getPreviousInstanceTimes(AgendaEntry& entry, QDateTime& startTime, 
       
   106 	                              QDateTime& endTime);
       
   107 	void getNextInstanceTimes(AgendaEntry& entry, QDateTime& startTime, 
       
   108 	                          QDateTime& endTime);
       
   109 	void markDatesWithEvents(QDateTime rangeStart, QDateTime rangeEnd,
       
   110 						 AgendaUtil::FilterFlags filter, QList<QDate>& dates);
       
   111 	bool areNoEntriesInCalendar();
       
   112 	static QDateTime minTime();
       
   113 	static QDateTime maxTime();
       
   114 
       
   115 	static bool isWorkdaysRepeatingEntry(const AgendaRepeatRule& repeatRule);
       
   116 	
       
   117 Q_SIGNALS:
       
   118 	void entriesChanged(QList<ulong> ids);
       
   119 	void entryAdded(ulong id);
       
   120 	void entryDeleted(ulong id);
       
   121 	void entryUpdated(ulong id);
       
   122 	void entriesDeleted(int status);
       
   123 	void entryViewCreationCompleted(int status);
       
   124 	void instanceViewCreationCompleted(int status);
       
   125 
       
   126 private:
       
   127 	friend class AgendaUtilPrivate;
       
   128 	AgendaUtilPrivate* d;
       
   129 };
       
   130 
       
   131 #endif // AGENDAUTIL_H
       
   132 
       
   133 // End of file	--Don't remove this.