KCalUtils

datetimefilters.cpp
1/*
2 * SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7
8#include "datetimefilters.h"
10#include <KTextTemplate/SafeString>
11
12KDateFilter::KDateFilter()
14{
15}
16
17KDateFilter::~KDateFilter()
18{
19}
20
21QVariant KDateFilter::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
22{
23 Q_UNUSED(autoescape)
24
25 QDate date;
26 if (input.userType() == QMetaType::QDate) {
27 date = input.toDate();
28 } else if (input.userType() == QMetaType::QDateTime) {
29 date = input.toDateTime().date();
30 } else {
31 return QString();
32 }
33 const bool shortFmt = (argument.value<KTextTemplate::SafeString>().get().compare(QLatin1StringView("short"), Qt::CaseInsensitive) == 0);
35}
36
37bool KDateFilter::isSafe() const
38{
39 return true;
40}
41
42KTimeFilter::KTimeFilter()
44{
45}
46
47KTimeFilter::~KTimeFilter()
48{
49}
50
51QVariant KTimeFilter::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
52{
53 Q_UNUSED(autoescape)
54
55 QTime time;
56 if (input.userType() == QMetaType::QTime) {
57 time = input.toTime();
58 } else if (input.userType() == QMetaType::QDateTime) {
59 time = input.toDateTime().time();
60 } else {
61 return QString();
62 }
63
64 const bool shortFmt = (argument.value<KTextTemplate::SafeString>().get().compare(QLatin1StringView("short"), Qt::CaseInsensitive) == 0);
66}
67
68bool KTimeFilter::isSafe() const
69{
70 return true;
71}
72
73KDateTimeFilter::KDateTimeFilter()
75{
76}
77
78KDateTimeFilter::~KDateTimeFilter()
79{
80}
81
82QVariant KDateTimeFilter::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
83{
84 Q_UNUSED(autoescape)
85 if (input.userType() != QMetaType::QDateTime) {
86 return QString();
87 }
88 const QDateTime dt = input.toDateTime();
89 const QStringList arguments = argument.value<KTextTemplate::SafeString>().get().split(QLatin1Char(','));
90 const bool shortFmt = arguments.contains(QLatin1StringView("short"), Qt::CaseInsensitive);
91 const bool dateOnly = arguments.contains(QLatin1StringView("dateonly"), Qt::CaseInsensitive);
93}
94
95bool KDateTimeFilter::isSafe() const
96{
97 return true;
98}
This file is part of the API for handling calendar data and provides static functions for formatting ...
KCALUTILS_EXPORT QString timeToString(QTime time, bool shortfmt=true)
Build a QString time representation of a QTime object.
KCALUTILS_EXPORT QString dateToString(QDate date, bool shortfmt=true)
Build a QString date representation of a QDate object.
KCALUTILS_EXPORT QString dateTimeToString(const QDateTime &date, bool dateOnly=false, bool shortfmt=true)
Build a QString date/time representation of a QDateTime object.
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
QDate date() const const
QTime time() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
CaseInsensitive
QDate toDate() const const
QDateTime toDateTime() const const
QTime toTime() const const
int userType() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.