File indexing completed on 2024-04-28 04:41:58

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-2015 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 #ifndef KREPORTSECTION_H
0021 #define KREPORTSECTION_H
0022 
0023 #include <QCoreApplication>
0024 #include <QSet>
0025 #include <KReportElement>
0026 
0027 //! @brief The KReportSection class represents a section of a report design
0028 /*! A section has optional report header, report footer, page header, page footer,
0029     group header, group footer and detail.
0030     In the case of page header and page footer it is possible to define (firstpage, odd, even or lastpage). */
0031 class KREPORT_EXPORT KReportSection //SDC: explicit operator== virtual_dtor custom_clone
0032 {
0033     Q_DECLARE_TR_FUNCTIONS(KReportSection)
0034 public:
0035     enum class Type {
0036         Invalid,
0037         PageHeaderFirst,
0038         PageHeaderOdd,
0039         PageHeaderEven,
0040         PageHeaderLast,
0041         PageHeaderAny,
0042         ReportHeader,
0043         ReportFooter,
0044         PageFooterFirst,
0045         PageFooterOdd,
0046         PageFooterEven,
0047         PageFooterLast,
0048         PageFooterAny,
0049         GroupHeader,
0050         GroupFooter,
0051         Detail
0052     };
0053 
0054     /*!
0055     @getter
0056     @return section type
0057     Default section type is Invalid.
0058     @setter
0059     Sets section type.
0060     */
0061     KReportSection::Type type;  //SDC: default=KReportSection::Type::Invalid simple_type
0062 
0063     /*!
0064     @getter
0065     @return section height measured in points
0066     It is equal to KReportSection::defaultHeight() unless setHeight()
0067     is called with value > 0.
0068     @setter
0069     Sets section height measured in points.
0070     Set negative value to reset to the default height.
0071     */
0072     qreal height; //SDC: default=-1 custom_getter
0073 
0074     /*!
0075     @getter
0076     @return section background color
0077     It is equal to KReportSection::defaultBackgroundColor() unless setBackgroundColor()
0078     is called with a valid color.
0079     @setter
0080     Sets section background color.
0081     Set invalid color (QColor()) to reset to the default background color.
0082     */
0083     QColor backgroundColor;  //SDC: custom_getter
0084 
0085     /*!
0086     @getter
0087     @return all elements of this section
0088     */
0089     QList<KReportElement> elements;  //SDC: custom_getter no_setter
0090 
0091     /*!
0092     @internal A set that helps to quickly check if element is part of the section.
0093     */
0094     QSet<KReportElement> elementsSet; //SDC: internal
0095 
0096     //! Adds element @a element to this section.
0097     //! @return true on success.
0098     //! Adding fails if element is already added to this or other section.
0099     //! Use KReportElement::clone() to add a copy.
0100     bool addElement(const KReportElement &element);
0101 
0102     //! Adds element @a element to this section at index position @a i.
0103     //! @return true on success.
0104     //! Adding fails if element is already added to this or other section or if
0105     //! position @a i is out of bounds.
0106     //! Use KReportElement::clone() to add a copy.
0107     bool insertElement(int i, const KReportElement &element);
0108 
0109     //! Removes element @a element from this section.
0110     //! @return true on success.
0111     //! Removing fails if element @a element is not added in this section.
0112     bool removeElement(const KReportElement &element);
0113 
0114     //! Removes element from index position @a i from this section.
0115     //! @return true on success.
0116     //! Removing fails position @a i is out of bounds.
0117     bool removeElementAt(int i);
0118 
0119     //! @return default height for report sections. The standard is 2cm (converted to points).
0120     static qreal defaultHeight();
0121 
0122     //! Sets default height for report sections in points.
0123     static void setDefaultHeight(qreal height);
0124 
0125     //! @return default background color for report sections. The standard is white.
0126     static QColor defaultBackgroundColor();
0127 
0128     //! Sets default background color for report sections.
0129     static void setDefaultBackgroundColor(const QColor &color);
0130 };
0131 
0132 #endif // KREPORTSECTION_H