File indexing completed on 2024-05-19 05:11:08
0001 /******************************************************************************* 0002 * konsolekalendarexports.h * 0003 * * 0004 * KonsoleKalendar is a command line interface to KDE calendars * 0005 * SPDX-FileCopyrightText: 2002-2004 Tuukka Pasanen <illuusio@mailcity.com> * 0006 * SPDX-FileCopyrightText: 2003-2005 Allen Winter <winter@kde.org> * 0007 * * 0008 * SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 * 0009 * * 0010 ******************************************************************************/ 0011 0012 #pragma once 0013 0014 #include <QTextStream> 0015 0016 #include "konsolekalendarvariables.h" 0017 0018 /** 0019 * @file konsolekalendarexports.h 0020 * Provides the KonsoleKalendarExports class definition. 0021 */ 0022 0023 /** 0024 * @brief 0025 * Class to manage the Export functionality. 0026 * @author Tuukka Pasanen 0027 * @author Allen Winter 0028 */ 0029 class KonsoleKalendarExports 0030 { 0031 public: 0032 /** 0033 * Constructs a KonsoleKalendarChange object from command line arguments. 0034 * @param vars is a KonsoleKalendarVariable object with Event information. 0035 */ 0036 explicit KonsoleKalendarExports(KonsoleKalendarVariables *vars = nullptr); 0037 0038 /** 0039 * Destructor 0040 */ 0041 ~KonsoleKalendarExports(); 0042 0043 /** 0044 * Export the Event in Text Mode. 0045 * @param ts pointer to the output QTextStream. 0046 * @param event pointer to the Event to export. 0047 * @param date is the QDate to be exported for. 0048 */ 0049 bool exportAsTxt(QTextStream *ts, const KCalendarCore::Event::Ptr &event, const QDate &date); 0050 0051 /** 0052 * Export the Event in Short Text Mode. 0053 * @param ts pointer to the output QTextStream. 0054 * @param event pointer to the Event to export. 0055 * @param date is the QDate to be exported for. 0056 * @param sameday flags that this Event is on the same date as the 0057 * previously exported Event. 0058 */ 0059 bool exportAsTxtShort(QTextStream *ts, const KCalendarCore::Event::Ptr &event, const QDate &date, bool sameday); 0060 0061 /** 0062 * Export the Event in Comma-Separated Values (CSV) Mode. 0063 * @param ts pointer to the output QTextStream. 0064 * @param event pointer to the Event to export. 0065 * @param date is the QDate to be exported for. 0066 */ 0067 bool exportAsCSV(QTextStream *ts, const KCalendarCore::Event::Ptr &event, const QDate &date); 0068 0069 private: 0070 //@cond PRIVATE 0071 KonsoleKalendarVariables *m_variables = nullptr; 0072 bool m_firstEntry; 0073 //@endcond 0074 0075 /** 0076 * Processes a field for Comma-Separated Value (CSV) compliance: 0077 * 1. Replaces double quotes by a pair of consecutive double quotes 0078 * 2. Surrounds field with double quotes 0079 * @param field is the field value to be processed. 0080 * @param dquote is a QString containing the double quote character. 0081 */ 0082 QString processField(const QString &field, const QString &dquote); 0083 };