~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/koreport/items/field/krscriptfield.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Kexi Report Plugin
 
3
 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
#include "krscriptfield.h"
 
19
 
 
20
namespace Scripting
 
21
{
 
22
Field::Field(KoReportItemField *f)
 
23
{
 
24
    m_field = f;
 
25
}
 
26
 
 
27
 
 
28
Field::~Field()
 
29
{
 
30
}
 
31
 
 
32
QString Field::source()
 
33
{
 
34
    return m_field->itemDataSource();
 
35
}
 
36
 
 
37
void Field::setSource(const QString& s)
 
38
{
 
39
    m_field->setItemDataSource(s);
 
40
}
 
41
 
 
42
int Field::horizontalAlignment()
 
43
{
 
44
    QString a = m_field->m_horizontalAlignment->value().toString();
 
45
 
 
46
    if (a.toLower() == "left") {
 
47
        return -1;
 
48
    } else if (a.toLower() == "center") {
 
49
        return 0;
 
50
    } else if (a.toLower() == "right") {
 
51
        return 1;
 
52
    }
 
53
    return -1;
 
54
}
 
55
void Field::setHorizonalAlignment(int a)
 
56
{
 
57
    switch (a) {
 
58
    case -1:
 
59
        m_field->m_horizontalAlignment->setValue("left");
 
60
        break;
 
61
    case 0:
 
62
        m_field->m_horizontalAlignment->setValue("center");
 
63
        break;
 
64
    case 1:
 
65
        m_field->m_horizontalAlignment->setValue("right");
 
66
        break;
 
67
    default:
 
68
        m_field->m_horizontalAlignment->setValue("left");
 
69
        break;
 
70
    }
 
71
}
 
72
 
 
73
int Field::verticalAlignment()
 
74
{
 
75
    QString a = m_field->m_horizontalAlignment->value().toString();
 
76
 
 
77
    if (a.toLower() == "top") {
 
78
        return -1;
 
79
    } else if (a.toLower() == "middle") {
 
80
        return 0;
 
81
    } else if (a.toLower() == "bottom") {
 
82
        return 1;
 
83
    }
 
84
    return -1;
 
85
}
 
86
void Field::setVerticalAlignment(int a)
 
87
{
 
88
    switch (a) {
 
89
    case -1:
 
90
        m_field->m_verticalAlignment->setValue("top");
 
91
        break;
 
92
    case 0:
 
93
        m_field->m_verticalAlignment->setValue("middle");
 
94
        break;
 
95
    case 1:
 
96
        m_field->m_verticalAlignment->setValue("bottom");
 
97
        break;
 
98
    default:
 
99
        m_field->m_verticalAlignment->setValue("middle");
 
100
        break;
 
101
    }
 
102
}
 
103
 
 
104
QColor Field::backgroundColor()
 
105
{
 
106
    return m_field->m_backgroundColor->value().value<QColor>();
 
107
}
 
108
void Field::setBackgroundColor(const QColor& c)
 
109
{
 
110
    m_field->m_backgroundColor->setValue(c);
 
111
}
 
112
 
 
113
QColor Field::foregroundColor()
 
114
{
 
115
    return m_field->m_foregroundColor->value().value<QColor>();
 
116
}
 
117
void Field::setForegroundColor(const QColor& c)
 
118
{
 
119
    m_field->m_foregroundColor->setValue(c);
 
120
}
 
121
 
 
122
int Field::backgroundOpacity()
 
123
{
 
124
    return m_field->m_backgroundOpacity->value().toInt();
 
125
}
 
126
void Field::setBackgroundOpacity(int o)
 
127
{
 
128
    m_field->m_backgroundOpacity->setValue(o);
 
129
}
 
130
 
 
131
QColor Field::lineColor()
 
132
{
 
133
    return m_field->m_lineColor->value().value<QColor>();
 
134
}
 
135
void Field::setLineColor(const QColor& c)
 
136
{
 
137
    m_field->m_lineColor->setValue(c);
 
138
}
 
139
 
 
140
int Field::lineWeight()
 
141
{
 
142
    return m_field->m_lineWeight->value().toInt();
 
143
}
 
144
void Field::setLineWeight(int w)
 
145
{
 
146
    m_field->m_lineWeight->setValue(w);
 
147
}
 
148
 
 
149
int Field::lineStyle()
 
150
{
 
151
    return m_field->m_lineStyle->value().toInt();
 
152
}
 
153
void Field::setLineStyle(int s)
 
154
{
 
155
    if (s < 0 || s > 5) {
 
156
        s = 1;
 
157
    }
 
158
    m_field->m_lineStyle->setValue(s);
 
159
}
 
160
 
 
161
QPointF Field::position()
 
162
{
 
163
    return m_field->m_pos.toPoint();
 
164
}
 
165
void Field::setPosition(const QPointF &p)
 
166
{
 
167
    m_field->m_pos.setPointPos(p);
 
168
}
 
169
 
 
170
QSizeF Field::size()
 
171
{
 
172
    return m_field->m_size.toPoint();
 
173
}
 
174
void Field::setSize(const QSizeF &s)
 
175
{
 
176
    m_field->m_size.setPointSize(s);
 
177
}
 
178
}