KReport

KReportScriptField.cpp
1/* This file is part of the KDE project
2 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "KReportScriptField.h"
19
20#include <QSizeF>
21#include <QPointF>
22
23
24namespace Scripting
25{
26Field::Field(KReportItemField *f)
27{
28 m_field = f;
29}
30
31
32Field::~Field()
33{
34}
35
37{
38 return m_field->itemDataSource();
39}
40
42{
43 m_field->setItemDataSource(s);
44}
45
47{
48 const QString a = m_field->m_horizontalAlignment->value().toString().toLower();
49
50 if (a == QLatin1String("left")) {
51 return -1;
52 }
53 if (a == QLatin1String("center")) {
54 return 0;
55 }
56 if (a == QLatin1String("right")) {
57 return 1;
58 }
59 return -1;
60}
62{
63 switch (a) {
64 case -1:
65 m_field->m_horizontalAlignment->setValue(QLatin1String("left"));
66 break;
67 case 0:
68 m_field->m_horizontalAlignment->setValue(QLatin1String("center"));
69 break;
70 case 1:
71 m_field->m_horizontalAlignment->setValue(QLatin1String("right"));
72 break;
73 default:
74 m_field->m_horizontalAlignment->setValue(QLatin1String("left"));
75 break;
76 }
77}
78
80{
81 const QString a = m_field->m_horizontalAlignment->value().toString().toLower();
82
83 if (a == QLatin1String("top")) {
84 return -1;
85 }
86 if (a == QLatin1String("middle")) {
87 return 0;
88 }
89 if (a == QLatin1String("bottom")) {
90 return 1;
91 }
92 return -1;
93}
95{
96 switch (a) {
97 case -1:
98 m_field->m_verticalAlignment->setValue(QLatin1String("top"));
99 break;
100 case 0:
101 m_field->m_verticalAlignment->setValue(QLatin1String("middle"));
102 break;
103 case 1:
104 m_field->m_verticalAlignment->setValue(QLatin1String("bottom"));
105 break;
106 default:
107 m_field->m_verticalAlignment->setValue(QLatin1String("middle"));
108 break;
109 }
110}
111
113{
114 return m_field->m_backgroundColor->value().value<QColor>();
115}
117{
118 m_field->m_backgroundColor->setValue(c);
119}
120
122{
123 return m_field->m_foregroundColor->value().value<QColor>();
124}
126{
127 m_field->m_foregroundColor->setValue(c);
128}
129
131{
132 return m_field->m_backgroundOpacity->value().toInt();
133}
135{
136 m_field->m_backgroundOpacity->setValue(o);
137}
138
140{
141 return m_field->m_lineColor->value().value<QColor>();
142}
144{
145 m_field->m_lineColor->setValue(c);
146}
147
149{
150 return m_field->m_lineWeight->value().toInt();
151}
153{
154 m_field->m_lineWeight->setValue(w);
155}
156
158{
159 return m_field->m_lineStyle->value().toInt();
160}
162{
163 if (s < 0 || s > 5) {
164 s = 1;
165 }
166 m_field->m_lineStyle->setValue(s);
167}
168
170{
171 return m_field->position();
172}
174{
175 m_field->setPosition(p);
176}
177
179{
180 return m_field->size();
181}
182void Field::setSize(const QSizeF &s)
183{
184 m_field->setSize(s);
185}
186
187}
QVariant value() const
bool setValue(const QVariant &value, ValueOptions options=ValueOptions())
void setSize(const QSizeF &ptSize)
Sets size for the element.
QPointF position() const
Return the position in points.
void setPosition(const QPointF &ptPos)
Sets position for the element.
QSizeF size() const
Return the size in points.
QString itemDataSource() const
int horizontalAlignment() const
void setSize(const QSizeF &)
Sets the size of the field to the given size in points.
void setPosition(const QPointF &)
Sets the position of the field to the given point coordinates.
void setBackgroundOpacity(int)
Sets the background opacity of the field Valid values are in the range 0-100.
void setLineWeight(int)
Sets the border line weight (thickness) of the field.
void setVerticalAlignment(int)
Sets the vertical alignment Valid values for aligmnt are top: -1, middle: 0, bottom: 1.
QColor backgroundColor() const
void setLineColor(const QColor &)
Sets the border line color of the field to the given color.
void setBackgroundColor(const QColor &)
Set the background color of the field to the given color.
void setHorizonalAlignment(int)
Sets the horizontal alignment Valid values for alignment are left: -1, center: 0, right; 1.
int verticalAlignment() const
QString source() const
void setLineStyle(int)
Sets the border line style of the field to the given style in the range 0-5.
void setForegroundColor(const QColor &)
Sets the foreground (text) color of the field to the given color.
QColor foregroundColor() const
void setSource(const QString &s)
Sets the data source for the field element.
QPointF position() const
Field item script interface.
QString toLower() const const
int toInt(bool *ok) const const
QString toString() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:48:09 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.