1 /***************************************************************************
2 * This file is part of the Lime Report project *
3 * Copyright (C) 2015 by Alexander Arin *
4 * arin_a@bk.ru *
5 * *
6 ** GNU General Public License Usage **
7 * *
8 * This library is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation, either version 3 of the License, or *
11 * (at your option) any later version. *
12 * You should have received a copy of the GNU General Public License *
13 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14 * *
15 ** GNU Lesser General Public License **
16 * *
17 * This library is free software: you can redistribute it and/or modify *
18 * it under the terms of the GNU Lesser General Public License as *
19 * published by the Free Software Foundation, either version 3 of the *
20 * License, or (at your option) any later version. *
21 * You should have received a copy of the GNU Lesser General Public *
22 * License along with this library. *
23 * If not, see <http://www.gnu.org/licenses/>. *
24 * *
25 * This library is distributed in the hope that it will be useful, *
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28 * GNU General Public License for more details. *
29 ****************************************************************************/
30 #include "lrsubdetailband.h"
31 #include "lrdesignelementsfactory.h"
32 #include "lrglobal.h"
33
34
35 const QString xmlTagBand = QLatin1String("SubDetail");
36 const QString xmlTagHeader = QLatin1String("SubDetailHeader");
37 const QString xmlTagFooter = QLatin1String("SubDetailFooter");
38 const QColor BAND_COLOR = Qt::red;
39
40 namespace{
41
createBand(QObject * owner,LimeReport::BaseDesignIntf * parent)42 LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
43 return new LimeReport::SubDetailBand(owner,parent);
44 }
45
46 bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
47 xmlTagBand,
48 LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
49 createBand
50 );
51
createHeader(QObject * owner,LimeReport::BaseDesignIntf * parent)52 LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
53 return new LimeReport::SubDetailHeaderBand(owner,parent);
54 }
55
56 bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
57 xmlTagHeader,
58 LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG),
59 createHeader
60 );
61
createFooter(QObject * owner,LimeReport::BaseDesignIntf * parent)62 LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
63 return new LimeReport::SubDetailFooterBand(owner,parent);
64 }
65
66 bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
67 xmlTagFooter,
68 LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG),
69 createFooter
70 );
71
72 } // namespace
73
74 namespace LimeReport{
75
76 //SubDetailBand
77
SubDetailBand(QObject * owner,QGraphicsItem * parent)78 SubDetailBand::SubDetailBand(QObject *owner, QGraphicsItem *parent)
79 : DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner,parent)
80 {
81 setBandTypeText(tr("SubDetail"));
82 setFixedPos(false);
83 setMarkerColor(bandColor());
84 }
85
isHasHeader() const86 bool SubDetailBand::isHasHeader() const
87 {
88 return isConnectedToBand(BandDesignIntf::SubDetailHeader);
89 }
90
isHasFooter() const91 bool SubDetailBand::isHasFooter() const
92 {
93 return isConnectedToBand(BandDesignIntf::SubDetailFooter);
94 }
95
createSameTypeItem(QObject * owner,QGraphicsItem * parent)96 BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
97 {
98 return new SubDetailBand(owner,parent);
99 }
100
bandColor() const101 QColor SubDetailBand::bandColor() const
102 {
103 return BAND_COLOR;
104 }
105
106 //SubDetailHeaderBand
107
SubDetailHeaderBand(QObject * owner,QGraphicsItem * parent)108 SubDetailHeaderBand::SubDetailHeaderBand(QObject *owner, QGraphicsItem *parent)
109 :BandDesignIntf(BandDesignIntf::SubDetailHeader,xmlTagHeader,owner,parent)
110 {
111 setBandTypeText(tr("SubDetailHeader"));
112 setMarkerColor(bandColor());
113 }
114
isUnique() const115 bool SubDetailHeaderBand::isUnique() const
116 {
117 return false;
118 }
119
bandColor() const120 QColor SubDetailHeaderBand::bandColor() const
121 {
122 return BAND_COLOR;
123 }
124
createSameTypeItem(QObject * owner,QGraphicsItem * parent)125 BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
126 {
127 return new SubDetailHeaderBand(owner,parent);
128 }
129
130 //SubDetailFooterBand
131
SubDetailFooterBand(QObject * owner,QGraphicsItem * parent)132 SubDetailFooterBand::SubDetailFooterBand(QObject *owner, QGraphicsItem *parent)
133 : BandDesignIntf(BandDesignIntf::SubDetailFooter,xmlTagFooter,owner,parent)
134 {
135 setMarkerColor(bandColor());
136 }
137
isUnique() const138 bool SubDetailFooterBand::isUnique() const
139 {
140 return false;
141 }
142
bandColor() const143 QColor SubDetailFooterBand::bandColor() const
144 {
145 return BAND_COLOR;
146 }
147
createSameTypeItem(QObject * owner,QGraphicsItem * parent)148 BaseDesignIntf *SubDetailFooterBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
149 {
150 return new SubDetailFooterBand(owner,parent);
151 }
152
153
154 }
155