1 // Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
27 #include <qguardedptr.h>
29 #include <DDS_DicItem.h>
38 class Handle(DDS_Dictionary);
40 class QDS_EXPORT QDS_Datum : public QObject, public QDS
47 QDS_Datum( const QString&, QWidget* = 0, const int = All, const QString& = QString::null );
52 QString label() const;
53 QString units() const;
54 QString filter() const;
55 QString format() const;
56 QString longDescription() const;
57 QString shortDescription() const;
59 QString defaultValue() const;
60 QString minimumValue() const;
61 QString maximumValue() const;
63 virtual QVariant value() const;
65 virtual QString stringValue() const;
66 virtual double doubleValue() const;
67 virtual int integerValue() const;
71 virtual bool isEmpty() const;
76 virtual void setValue( const QVariant& );
78 virtual void setStringValue( const QString& );
79 virtual void setDoubleValue( const double );
80 virtual void setIntegerValue( const int );
82 virtual bool isEnabled( const int = Control ) const;
83 virtual void setEnabled( const bool, const int );
85 void show( const int = -1 );
86 void hide( const int = -1 );
87 void setShown( const bool, const int = -1 );
89 QWidget* widget( const int ) const;
92 virtual bool isValid( const bool = true,
93 const QString& = QString::null,
94 const QString& = QString::null ) const;
95 virtual QValidator* validator( const bool = false ) const;
97 void addTo( QVBoxLayout* );
98 void addTo( QHBoxLayout* );
99 void addTo( QGridLayout*, const int, const int, const bool = false );
101 virtual void setAlignment( const int, const int = Label );
103 static QString unitsToText( const QString& );
104 static QString textToUnits( const QString& );
106 static QString format( const QString&, const QString&, const bool = false );
107 static QString format( const int, const QString&, const bool = false );
108 static QString format( const double, const QString&, const bool = false );
109 static QString units( const QString& );
111 virtual bool eventFilter( QObject*, QEvent* );
113 operator QWidget*() const;
117 void paramChanged( QString& );
120 void setEnabled( bool );
123 virtual void onParamChanged();
127 void onDestroyed( QObject* );
130 QLabel* labelWidget() const;
131 QLabel* unitsWidget() const;
132 QWidget* controlWidget() const;
134 Handle(DDS_DicItem) dicItem() const;
135 void setDicItem( const Handle(DDS_DicItem)& );
139 void invalidateCache();
141 virtual QLabel* createLabel( QWidget* );
142 virtual QLabel* createUnits( QWidget* );
143 virtual QWidget* createControl( QWidget* ) = 0;
145 virtual QString getString() const = 0;
146 virtual void setString( const QString& ) = 0;
148 virtual bool validate( const QString& ) const;
150 QString prefix() const;
151 QString suffix() const;
152 virtual QString minValue() const;
153 virtual QString maxValue() const;
155 static QString format( const QString&, const int, const int );
156 static QString format( const QString&, const int, const double );
157 static QString format( const QString&, const int, const QString& );
159 static QString sprintf( const QString&, const int );
160 static QString sprintf( const QString&, const double );
161 static QString sprintf( const QString&, const QString& );
163 virtual void unitSystemChanged( const QString& );
165 void initDatum() const;
170 Wrapper* wrapper( QWidget* ) const;
171 Wrapper* wrapper( const int ) const;
172 int wrapperType( Wrapper* ) const;
174 static QString removeAccel( const QString& );
175 static bool isDoubleFormat( const QString& );
176 static QString canonicalFormat( const QString& );
177 static QString canonicalFormat( const QString&, QString& );
180 typedef QGuardedPtr<QLabel> GuardedLabel;
181 typedef QGuardedPtr<QWidget> GuardedWidget;
186 Handle(DDS_DicItem) myDicItem;
187 QMap<int, Wrapper*> myWrapper;
189 GuardedLabel myLabel;
190 GuardedLabel myUnits;
191 GuardedWidget myControl;
193 QString mySourceValue;
194 QString myTargetValue;