File indexing completed on 2024-12-08 09:38:10

0001 /*
0002     This file is part of the kholidays library.
0003 
0004     SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
0005     SPDX-FileCopyrightText: 2004 Allen Winter <winter@kde.org>
0006     SPDX-FileCopyrightText: 2008 David Jarvie <djarvie@kde.org>
0007     SPDX-FileCopyrightText: 2010 John Layt <john@layt.net>
0008 
0009     SPDX-License-Identifier: LGPL-2.0-or-later
0010 */
0011 
0012 #ifndef KHOLIDAYS_HOLIDAY_H
0013 #define KHOLIDAYS_HOLIDAY_H
0014 
0015 #include "kholidays_export.h"
0016 
0017 #include <QList>
0018 #include <QSharedDataPointer>
0019 
0020 class QDate;
0021 class QString;
0022 
0023 namespace KHolidays
0024 {
0025 class HolidayPrivate;
0026 class HolidayRegion;
0027 
0028 /** Represents a holiday event. */
0029 class KHOLIDAYS_EXPORT Holiday
0030 {
0031     friend class HolidayRegion;
0032     friend class HolidayParserDriver;
0033     friend class HolidayParserDriverPlan;
0034     friend class HolidayParserDriverPlanOld;
0035 
0036 public:
0037     /**
0038      * A list of holiday descriptions.
0039      */
0040     typedef QList<Holiday> List;
0041 
0042     /**
0043      * Describes the date type of the holiday.
0044      * If any of the holidays on a date are non-workdays types, then the entire day is non-working.
0045      */
0046     enum DayType {
0047         Workday, ///< The holiday is a workday
0048         NonWorkday, ///< The holiday is a real holiday
0049     };
0050 
0051     /**
0052      * Creates an empty holiday.
0053      */
0054     Holiday();
0055 
0056     /**
0057      * Creates a holiday from an @p other holiday.
0058      */
0059     Holiday(const Holiday &other);
0060 
0061     /**
0062      * Destroys the holiday object.
0063      */
0064     ~Holiday();
0065 
0066     /**
0067      *
0068      */
0069     Holiday &operator=(const Holiday &other);
0070 
0071     /**
0072      *
0073      */
0074     bool operator<(const Holiday &rhs) const;
0075 
0076     /**
0077      *
0078      */
0079     bool operator>(const Holiday &rhs) const;
0080 
0081     /**
0082      * @since 4.6
0083      *
0084      * Returns the observed start date of the holiday.
0085      */
0086     QDate observedStartDate() const;
0087 
0088     /**
0089      * @since 4.6
0090      *
0091      * Returns the observed end date of the holiday.
0092      */
0093     QDate observedEndDate() const;
0094 
0095     /**
0096      * @since 4.6
0097      *
0098      * Returns the duration of the holiday in days.
0099      */
0100     int duration() const;
0101 
0102     /**
0103      * @since 5.0
0104      *
0105      * Returns the name of the Holiday.
0106      *
0107      * @return the name of the Holiday
0108      */
0109     QString name() const;
0110 
0111     /**
0112      * @since 5.0
0113      *
0114      * Returns the description of the Holiday if available
0115      *
0116      * @return the description of the Holiday
0117      */
0118     QString description() const;
0119 
0120     /**
0121      * Returns the day type of the holiday.
0122      */
0123     DayType dayType() const;
0124 
0125     /**
0126      * @since 5.8
0127      *
0128      * Returns a QStringList of categories for the Holiday.
0129      * If the Holiday has no categories then an empty list is returned.
0130      */
0131     QStringList categoryList() const;
0132 
0133 private:
0134     QSharedDataPointer<HolidayPrivate> d;
0135 };
0136 
0137 }
0138 
0139 #endif // KHOLIDAYS_HOLIDAY_H