File indexing completed on 2024-04-21 04:41:51

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
0003  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0004  * Copyright (C) 2010-2018 Jarosław Staniek <staniek@kde.org>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 
0021 #ifndef KREPORTSECTIONDATA_H
0022 #define KREPORTSECTIONDATA_H
0023 
0024 #include "KReportUnit.h"
0025 
0026 #include <KPropertySet>
0027 
0028 #include <QColor>
0029 
0030 class KReportItemBase;
0031 class KReportDocument;
0032 class QDomElement;
0033 
0034 namespace Scripting
0035 {
0036 class Section;
0037 }
0038 
0039 /**
0040  * KReportSectionData is used to store the information about a specific report section
0041  *
0042  * A section has a name, type, unit and optionally extra data.
0043  */
0044 class KREPORT_EXPORT KReportSectionData : public QObject
0045 {
0046     Q_OBJECT
0047 public:
0048     enum class Type {
0049         None,
0050         PageHeaderFirst,
0051         PageHeaderOdd,
0052         PageHeaderEven,
0053         PageHeaderLast,
0054         PageHeaderAny,
0055         ReportHeader,
0056         ReportFooter,
0057         PageFooterFirst,
0058         PageFooterOdd,
0059         PageFooterEven,
0060         PageFooterLast,
0061         PageFooterAny,
0062         GroupHeader,
0063         GroupFooter,
0064         Detail
0065     };
0066 
0067     explicit KReportSectionData(QObject* parent = nullptr);
0068 
0069     explicit KReportSectionData(const QDomElement &elemSource, QObject *parent = nullptr);
0070 
0071     ~KReportSectionData() override;
0072 
0073     KReportUnit unit() const;
0074 
0075     void setUnit(const KReportUnit &u);
0076 
0077     /**
0078      * Returns property set for this section
0079      *
0080      * @since 3.1
0081      */
0082     KPropertySet* propertySet();
0083 
0084     /**
0085      * @overload
0086      */
0087     const KPropertySet* propertySet() const;
0088 
0089     bool isValid() const;
0090 
0091     qreal height() const;
0092 
0093     void setHeight(qreal ptHeight);
0094 
0095     QList<KReportItemBase*> objects() const;
0096 
0097     QString name() const;
0098 
0099     QColor backgroundColor() const;
0100 
0101     Type type() const;
0102 
0103     static KReportSectionData::Type sectionTypeFromString(const QString& s);
0104     static QString sectionTypeString(KReportSectionData::Type type);
0105 
0106 private:
0107     void setBackgroundColor(const QColor &color);
0108     void setHeight(qreal ptHeight, KProperty::ValueOptions options);
0109     KReportItemBase* object(int index);
0110 
0111     Q_DISABLE_COPY(KReportSectionData)
0112     class Private;
0113     Private * const d;
0114 
0115     friend class Scripting::Section;
0116     friend class KReportDesignerSection;
0117 };
0118 
0119 #endif