~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kugar/kudesigner_lib/cfield.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          cfield.cpp  -  description
 
3
                             -------------------
 
4
    begin                : 07.06.2002
 
5
    copyright            : (C) 2002 by Alexander Dymo
 
6
    email                : cloudtemple@mksat.net
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
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.                       *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#ifndef PURE_QT
 
19
#include <klocale.h>
 
20
#include <klineeditdlg.h>
 
21
#else
 
22
#include "qlocale.h"
 
23
#include <qinputdialog.h>
 
24
#endif
 
25
 
 
26
#include "cfield.h"
 
27
#include "property.h"
 
28
 
 
29
CanvasField::CanvasField(int x, int y, int width, int height, QCanvas * canvas,bool reg):
 
30
    CanvasLabel(x, y, width, height, canvas)
 
31
{
 
32
    std::map<QString, QString> m;
 
33
 
 
34
    props["Field"] = *(new PropPtr(new Property(FieldName, "Field", i18n("Field to display"), i18n("Field Name"))));
 
35
 
 
36
    m["String"] = "0";
 
37
    m["Integer"] = "1";
 
38
    m["Float"] = "2";
 
39
    m["Date"] = "3";
 
40
    m["Currency"] = "4";
 
41
    props["DataType"] = *(new PropPtr(new Property("DataType", m, i18n("Data type"), "0")));
 
42
    m.clear();
 
43
 
 
44
    m["m/d/y"] = "0";
 
45
    m["m-d-y"] = "1";
 
46
    m["mm/dd/y"] = "2";
 
47
    m["mm-dd-y"] = "3";
 
48
    m["m/d/yyyy"] = "4";
 
49
    m["m-d-yyyy"] = "5";
 
50
    m["mm/dd/yyyy"] = "6";
 
51
    m["mm-dd-yyyy"] = "7";
 
52
    m["yyyy/m/d"] = "8";
 
53
    m["yyyy-m-d"] = "9";
 
54
    m["dd.mm.yy"] = "10";
 
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")));
 
58
    m.clear();
 
59
 
 
60
    props["Precision"] = *(new PropPtr(new Property(IntegerValue, "Precision", i18n("Number of digits after comma"), "2")));
 
61
 
 
62
    //TODO: make currency locale-aware
 
63
    props["Currency"] = *(new PropPtr(new Property(Symbol, "Currency", i18n("Currency symbol"), "32")));
 
64
 
 
65
    props["NegValueColor"] = *(new PropPtr(new Property(Color, "NegValueColor", i18n("Negative value color"), "0,0,0")));
 
66
 
 
67
    props["CommaSeparator"] = *(new PropPtr(new Property(Symbol, "CommaSeparator", i18n("Comma separator"), "44")));
 
68
 
 
69
    if (reg) registerAs(KuDesignerRttiCanvasField);
 
70
}
 
71
 
 
72
void CanvasField::draw(QPainter &painter)
 
73
{
 
74
    props["Text"]->setValue("[" + props["Field"]->value() + "]");
 
75
    CanvasLabel::draw(painter);
 
76
}
 
77
 
 
78
QString CanvasField::getXml()
 
79
{
 
80
    return "\t\t<Field" + CanvasReportItem::getXml() + " />\n";
 
81
}
 
82
 
 
83
void CanvasField::fastProperty()
 
84
{
 
85
    bool accepted;
 
86
    QString sValue = props["Field"]->value();
 
87
 
 
88
#ifndef PURE_QT
 
89
    QString sText = KLineEditDlg::getText( i18n( "Change Field" ),
 
90
            "Enter field name:", sValue , &accepted );
 
91
#else
 
92
    QString sText = QInputDialog::getText( i18n( "Change Field" ),
 
93
            "Enter field name:", QLineEdit::Normal, sValue , &accepted );
 
94
#endif
 
95
 
 
96
    if ( accepted )
 
97
        props["Field"]->setValue( sText );
 
98
 
 
99
}
 
100