Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/barcode/KReportItemBarcode.cpp
Show All 33 Lines | |||||
34 | KReportItemBarcode::KReportItemBarcode(const QDomNode & element) | 34 | KReportItemBarcode::KReportItemBarcode(const QDomNode & element) | ||
35 | : m_minWidthData(0), m_minWidthTotal(0), m_minHeight(0) | 35 | : m_minWidthData(0), m_minWidthTotal(0), m_minHeight(0) | ||
36 | { | 36 | { | ||
37 | createProperties(); | 37 | createProperties(); | ||
38 | QDomNodeList nl = element.childNodes(); | 38 | QDomNodeList nl = element.childNodes(); | ||
39 | QString n; | 39 | QString n; | ||
40 | QDomNode node; | 40 | QDomNode node; | ||
41 | 41 | | |||
42 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 42 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
43 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 43 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
44 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | 44 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | ||
45 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 45 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
46 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | 46 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | ||
47 | m_maxLength->setValue(element.toElement().attribute(QLatin1String("report:barcode-max-length"))); | 47 | m_maxLength->setValue(element.toElement().attribute(QLatin1String("report:barcode-max-length"))); | ||
48 | m_format->setValue(element.toElement().attribute(QLatin1String("report:barcode-format"))); | 48 | m_format->setValue(element.toElement().attribute(QLatin1String("report:barcode-format"))); | ||
49 | parseReportRect(element.toElement(), &m_pos, &m_size); | 49 | parseReportRect(element.toElement()); | ||
50 | 50 | | |||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | void KReportItemBarcode::setMaxLength(int i) | 53 | void KReportItemBarcode::setMaxLength(int i) | ||
54 | { | 54 | { | ||
55 | if (i > 0) { | 55 | if (i > 0) { | ||
56 | if (m_maxLength->value().toInt() != i) { | 56 | if (m_maxLength->value().toInt() != i) { | ||
57 | m_maxLength->setValue(i); | 57 | m_maxLength->setValue(i); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
113 | } else { | 113 | } else { | ||
114 | kreportpluginWarning() << "Unknown format encountered: " << m_format->value().toString(); | 114 | kreportpluginWarning() << "Unknown format encountered: " << m_format->value().toString(); | ||
115 | } | 115 | } | ||
116 | } | 116 | } | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | void KReportItemBarcode::createProperties() | 119 | void KReportItemBarcode::createProperties() | ||
120 | { | 120 | { | ||
121 | m_set = new KPropertySet; | | |||
122 | | ||||
123 | QStringList keys, strings; | 121 | QStringList keys, strings; | ||
124 | 122 | | |||
125 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), | 123 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), | ||
126 | QString(), tr("Data Source")); | 124 | QString(), tr("Data Source")); | ||
127 | 125 | | |||
128 | m_itemValue = new KProperty("value", QString(), tr("Value"), | 126 | m_itemValue = new KProperty("value", QString(), tr("Value"), | ||
129 | tr("Value used if not bound to a field")); | 127 | tr("Value used if not bound to a field")); | ||
130 | 128 | | |||
Show All 16 Lines | 139 | strings << tr("Code 3 of 9", "Barcode symbology, keep short") | |||
147 | << tr("UPC-A", "Barcode symbology, keep short") | 145 | << tr("UPC-A", "Barcode symbology, keep short") | ||
148 | << tr("UPC-E", "Barcode symbology, keep short"); | 146 | << tr("UPC-E", "Barcode symbology, keep short"); | ||
149 | m_format = new KProperty("barcode-format", keys, strings, QLatin1String("3of9"), | 147 | m_format = new KProperty("barcode-format", keys, strings, QLatin1String("3of9"), | ||
150 | tr("Barcode Format")); | 148 | tr("Barcode Format")); | ||
151 | 149 | | |||
152 | m_maxLength = new KProperty("barcode-max-length", 5, tr("Max Length"), | 150 | m_maxLength = new KProperty("barcode-max-length", 5, tr("Max Length"), | ||
153 | tr("Maximum Barcode Length")); | 151 | tr("Maximum Barcode Length")); | ||
154 | 152 | | |||
155 | addDefaultProperties(); | 153 | propertySet()->addProperty(m_controlSource); | ||
156 | m_set->addProperty(m_controlSource); | 154 | propertySet()->addProperty(m_itemValue); | ||
157 | m_set->addProperty(m_itemValue); | 155 | propertySet()->addProperty(m_format); | ||
158 | m_set->addProperty(m_format); | 156 | propertySet()->addProperty(m_horizontalAlignment); | ||
159 | m_set->addProperty(m_horizontalAlignment); | 157 | propertySet()->addProperty(m_maxLength); | ||
160 | m_set->addProperty(m_maxLength); | | |||
161 | } | 158 | } | ||
162 | 159 | | |||
163 | KReportItemBarcode::~KReportItemBarcode() | 160 | KReportItemBarcode::~KReportItemBarcode() | ||
164 | { | 161 | { | ||
165 | delete m_set; | | |||
166 | } | 162 | } | ||
167 | 163 | | |||
168 | int KReportItemBarcode::alignment() | 164 | int KReportItemBarcode::alignment() | ||
169 | { | 165 | { | ||
170 | QByteArray a = m_horizontalAlignment->value().toByteArray(); | 166 | QByteArray a = m_horizontalAlignment->value().toByteArray(); | ||
171 | 167 | | |||
172 | if (a == "left") | 168 | if (a == "left") | ||
173 | return 0; | 169 | return 0; | ||
Show All 37 Lines | |||||
211 | } | 207 | } | ||
212 | 208 | | |||
213 | int KReportItemBarcode::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 209 | int KReportItemBarcode::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
214 | const QVariant &data, KReportScriptHandler *script) | 210 | const QVariant &data, KReportScriptHandler *script) | ||
215 | { | 211 | { | ||
216 | Q_UNUSED(section); | 212 | Q_UNUSED(section); | ||
217 | Q_UNUSED(script); | 213 | Q_UNUSED(script); | ||
218 | 214 | | |||
219 | QPointF pos = m_pos.toScene(); | 215 | QPointF pos = scenePosition(position()); | ||
220 | QSizeF size = m_size.toScene(); | 216 | QSizeF siz = sceneSize(size()); | ||
221 | pos += offset; | 217 | pos += offset; | ||
222 | 218 | | |||
223 | QRectF rect = QRectF(pos, size); | 219 | QRectF rect = QRectF(pos, siz); | ||
224 | 220 | | |||
225 | QString val; | 221 | QString val; | ||
226 | 222 | | |||
227 | if (m_controlSource->value().toString().isEmpty()) { | 223 | if (m_controlSource->value().toString().isEmpty()) { | ||
228 | val = m_itemValue->value().toString(); | 224 | val = m_itemValue->value().toString(); | ||
229 | } else { | 225 | } else { | ||
230 | val = data.toString(); | 226 | val = data.toString(); | ||
231 | } | 227 | } | ||
Show All 26 Lines |