1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/* This file is part of the KDE project
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef DATEVARIABLE_H
#define DATEVARIABLE_H
#include <KoVariable.h>
#include <QString>
#include <QDateTime>
/**
* Base class for in-text variables.
* A variable is a field inserted into the text and the content is set to a specific value that
* is used as text. This class is pretty boring in that it has just a setValue() to alter the
* text shown; we depend on plugin writers to create more exciting ways to update variables.
*/
class DateVariable : public KoVariable
{
public:
enum DateType {
Fixed,
AutoUpdate
};
enum DisplayType {
Date,
Time
};
enum ValueType {
DateOrTime,
DateTime
};
/**
* Constructor.
*/
explicit DateVariable(DateType type);
~DateVariable() override;
///reimplemented
void saveOdf(KoShapeSavingContext & context) override;
///reimplemented
bool loadOdf(const KoXmlElement & element, KoShapeLoadingContext & context) override;
void readProperties(const KoProperties *props);
QWidget *createOptionsWidget() override;
const QString & definition() const {
return m_definition;
}
void setDefinition(const QString &definition);
int daysOffset() const {
return m_daysOffset;
}
void setDaysOffset(int daysOffset);
int monthsOffset() const {
return m_monthsOffset;
}
void setMonthsOffset(int monthsOffset);
int yearsOffset() const {
return m_yearsOffset;
}
void setYearsOffset(int yearsOffset);
int secsOffset() const {
return m_secsOffset;
}
void setSecsOffset(int secsOffset);
private:
void update();
void adjustTime(const QString & adjustTime);
DateType m_type;
DisplayType m_displayType;
ValueType m_valueType;
QString m_definition;
QDateTime m_datetime;
int m_daysOffset;
int m_monthsOffset;
int m_yearsOffset;
int m_secsOffset;
};
#endif
|