1
/***************************************************************************
2
cfield.cpp - description
5
copyright : (C) 2002 by Alexander Dymo
6
email : cloudtemple@mksat.net
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU Library General Public License as *
13
* published by the Free Software Foundation; either version 2 of the *
14
* License, or (at your option) any later version. *
16
***************************************************************************/
20
#include <klineeditdlg.h>
23
#include <qinputdialog.h>
29
CanvasField::CanvasField(int x, int y, int width, int height, QCanvas * canvas,bool reg):
30
CanvasLabel(x, y, width, height, canvas)
32
std::map<QString, QString> m;
34
props["Field"] = *(new PropPtr(new Property(FieldName, "Field", i18n("Field to display"), i18n("Field Name"))));
41
props["DataType"] = *(new PropPtr(new Property("DataType", m, i18n("Data type"), "0")));
50
m["mm/dd/yyyy"] = "6";
51
m["mm-dd-yyyy"] = "7";
55
m["dd.mm.yyyy"] = "11";
56
//TODO: make date format not hard-coded, use locale settings
57
props["DateFormat"] = *(new PropPtr(new Property("DateFormat", m, i18n("Date format"), "11")));
60
props["Precision"] = *(new PropPtr(new Property(IntegerValue, "Precision", i18n("Number of digits after comma"), "2")));
62
//TODO: make currency locale-aware
63
props["Currency"] = *(new PropPtr(new Property(Symbol, "Currency", i18n("Currency symbol"), "32")));
65
props["NegValueColor"] = *(new PropPtr(new Property(Color, "NegValueColor", i18n("Negative value color"), "0,0,0")));
67
props["CommaSeparator"] = *(new PropPtr(new Property(Symbol, "CommaSeparator", i18n("Comma separator"), "44")));
69
if (reg) registerAs(KuDesignerRttiCanvasField);
72
void CanvasField::draw(QPainter &painter)
74
props["Text"]->setValue("[" + props["Field"]->value() + "]");
75
CanvasLabel::draw(painter);
78
QString CanvasField::getXml()
80
return "\t\t<Field" + CanvasReportItem::getXml() + " />\n";
83
void CanvasField::fastProperty()
86
QString sValue = props["Field"]->value();
89
QString sText = KLineEditDlg::getText( i18n( "Change Field" ),
90
"Enter field name:", sValue , &accepted );
92
QString sText = QInputDialog::getText( i18n( "Change Field" ),
93
"Enter field name:", QLineEdit::Normal, sValue , &accepted );
97
props["Field"]->setValue( sText );