kexi
kexidbautofield.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KEXIDBAUTOFIELD_H
00023 #define KEXIDBAUTOFIELD_H
00024
00025 #include <qwidget.h>
00026 #include <kexidb/field.h>
00027 #include <formeditor/container.h>
00028 #include <formeditor/widgetwithsubpropertiesinterface.h>
00029 #include "kexiformdataiteminterface.h"
00030
00031 class QBoxLayout;
00032 class QLabel;
00033
00035
00036 class KEXIFORMUTILS_EXPORT KexiDBAutoField :
00037 public QWidget,
00038 public KexiFormDataItemInterface,
00039 public KFormDesigner::DesignTimeDynamicChildWidgetHandler,
00040 public KFormDesigner::WidgetWithSubpropertiesInterface
00041 {
00042 Q_OBJECT
00043
00044 Q_OVERRIDE(QString caption READ caption WRITE setCaption DESIGNABLE true)
00045 Q_OVERRIDE(QColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor DESIGNABLE true RESET unsetPalette)
00046 Q_OVERRIDE(QColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor DESIGNABLE true RESET unsetPalette)
00047 Q_PROPERTY(QColor foregroundLabelColor READ foregroundLabelColor WRITE setForegroundLabelColor DESIGNABLE true RESET unsetPalette)
00048 Q_PROPERTY(QColor backgroundLabelColor READ backgroundLabelColor WRITE setBackgroundLabelColor DESIGNABLE true RESET unsetPalette)
00049 Q_PROPERTY(bool autoCaption READ hasAutoCaption WRITE setAutoCaption DESIGNABLE true)
00050 Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00051 Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00052 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00053 Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition DESIGNABLE true)
00054 Q_PROPERTY(WidgetType widgetType READ widgetType WRITE setWidgetType DESIGNABLE true)
00055
00056 Q_PROPERTY(int fieldTypeInternal READ fieldTypeInternal WRITE setFieldTypeInternal DESIGNABLE true STORED false)
00057 Q_PROPERTY(QString fieldCaptionInternal READ fieldCaptionInternal WRITE setFieldCaptionInternal DESIGNABLE true STORED false)
00058 Q_ENUMS( WidgetType LabelPosition )
00059
00060 public:
00061 enum WidgetType { Auto = 100, Text, Integer, Double, Boolean, Date, Time, DateTime,
00062 MultiLineText, ComboBox, Image };
00063 enum LabelPosition { Left = 300, Top, NoLabel };
00064
00065 KexiDBAutoField(const QString &text, WidgetType type, LabelPosition pos,
00066 QWidget *parent = 0, const char *name = 0, bool designMode = true);
00067 KexiDBAutoField(QWidget *parent = 0, const char *name = 0, bool designMode = true,
00068 LabelPosition pos = Left);
00069
00070 virtual ~KexiDBAutoField();
00071
00072 inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00073 inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00074 virtual void setDataSource( const QString &ds );
00075 virtual void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00076 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
00077
00078 virtual void setInvalidState(const QString& text);
00079 virtual bool isReadOnly() const;
00080 virtual void setReadOnly( bool readOnly );
00081
00082 virtual QVariant value();
00083 virtual bool valueIsNull();
00084 virtual bool valueIsEmpty();
00085 virtual bool valueIsValid();
00086 virtual bool valueChanged();
00087 virtual void clear();
00088
00090 virtual void installListener(KexiDataItemChangesListener* listener);
00091
00092 WidgetType widgetType() const;
00093 void setWidgetType(WidgetType type);
00094
00095 LabelPosition labelPosition() const;
00096 virtual void setLabelPosition(LabelPosition position);
00097
00098 QString caption() const;
00099 void setCaption(const QString &caption);
00100
00101 bool hasAutoCaption() const;
00102 void setAutoCaption(bool autoCaption);
00103
00108 virtual void setDisplayDefaultValue(QWidget* widget, bool displayDefaultValue);
00109
00110 QWidget* editor() const;
00111 QLabel* label() const;
00112
00113 virtual bool cursorAtStart();
00114 virtual bool cursorAtEnd();
00115
00116 static WidgetType widgetTypeForFieldType(KexiDB::Field::Type type);
00117
00121 void setFieldTypeInternal(int kexiDBFieldType);
00122
00126 void setFieldCaptionInternal(const QString& text);
00127
00129 int fieldTypeInternal() const;
00130
00132 QString fieldCaptionInternal() const;
00133
00134 virtual QSize sizeHint() const;
00135 virtual void setFocusPolicy ( FocusPolicy policy );
00136
00138 const QColor & paletteForegroundColor() const;
00139
00141 void setPaletteForegroundColor( const QColor & color );
00142
00144 const QColor & paletteBackgroundColor() const;
00145
00147 virtual void setPaletteBackgroundColor( const QColor & color );
00148
00150 const QColor & foregroundLabelColor() const;
00151
00153 virtual void setForegroundLabelColor( const QColor & color );
00154
00156 const QColor & backgroundLabelColor() const;
00157
00159 virtual void setBackgroundLabelColor( const QColor & color );
00160
00162 virtual QVariant property( const char * name ) const;
00163
00165 virtual bool setProperty( const char * name, const QVariant & value );
00166
00168 virtual bool keyPressed(QKeyEvent *ke);
00169
00170 public slots:
00171 virtual void unsetPalette();
00172
00173 protected slots:
00174
00175 virtual void paletteChange( const QPalette& oldPal );
00176
00178 virtual void moveCursorToEnd();
00179
00181 virtual void moveCursorToStart();
00182
00184 virtual void selectAll();
00185
00186 protected:
00187 virtual void setValueInternal(const QVariant&add, bool removeOld);
00188 void init(const QString &text, WidgetType type, LabelPosition pos);
00189 virtual void createEditor();
00190 void changeText(const QString &text, bool beautify = true);
00191
00192 void updateInformationAboutUnboundField();
00193
00195 void copyPropertiesToEditor();
00196
00197 virtual bool eventFilter( QObject *o, QEvent *e );
00198
00200 void setLabelPositionInternal(LabelPosition position, bool noLabel);
00201
00203 void setColumnInfoInternal(KexiDB::QueryColumnInfo* cinfo, KexiDB::QueryColumnInfo* visibleColumnInfo);
00204
00205 private:
00206 class Private;
00207 Private *d;
00208 };
00209
00210 #endif
|