File indexing completed on 2024-05-12 05:21:24
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 2005 Reinhold Kainhofer <reinhold@kainhofer.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 0009 #pragma once 0010 0011 #include "korganizerprivate_export.h" 0012 0013 #include <Akonadi/Collection> 0014 0015 #include <KCalendarCore/Incidence> 0016 0017 namespace Akonadi 0018 { 0019 class Collection; 0020 class Item; 0021 } 0022 0023 class QColor; 0024 class QDate; 0025 0026 // Provides static methods that are useful to all views. 0027 0028 namespace KOHelper 0029 { 0030 /** 0031 Returns a nice QColor for text, give the input color &c. 0032 */ 0033 KORGANIZERPRIVATE_EXPORT QColor getTextColor(const QColor &c); 0034 0035 /** 0036 This method returns the proper resource / subresource color for the view. 0037 @return The resource color for the incidence. If the incidence belongs 0038 to a subresource, the color for the subresource is returned (if set). 0039 @param calendar the calendar for which the resource color should be obtained 0040 @param incidence the incidence for which the color is needed (to 0041 determine which subresource needs to be used) 0042 */ 0043 [[nodiscard]] KORGANIZERPRIVATE_EXPORT QColor resourceColor(const Akonadi::Item &incidence); 0044 0045 [[nodiscard]] KORGANIZERPRIVATE_EXPORT QColor resourceColor(const Akonadi::Collection &collection); 0046 [[nodiscard]] KORGANIZERPRIVATE_EXPORT QColor resourceColorKnown(const Akonadi::Collection &collection); 0047 KORGANIZERPRIVATE_EXPORT void setResourceColor(const Akonadi::Collection &collection, const QColor &color); 0048 0049 /** 0050 Returns the number of years between the @p start QDate and the @p end QDate 0051 (i.e. the difference in the year number of both dates) 0052 */ 0053 [[nodiscard]] KORGANIZERPRIVATE_EXPORT int yearDiff(QDate start, QDate end); 0054 0055 /** 0056 Return true if it's the standard (that is, the current default) calendar. 0057 */ 0058 [[nodiscard]] KORGANIZERPRIVATE_EXPORT bool isStandardCalendar(Akonadi::Collection::Id id); 0059 0060 KORGANIZERPRIVATE_EXPORT void showSaveIncidenceErrorMsg(QWidget *parent, const KCalendarCore::Incidence::Ptr &incidence); 0061 }