kexi

kexidblineedit.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004-2006 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KexiDBLineEdit_H
00022 #define KexiDBLineEdit_H
00023 
00024 #include <klineedit.h>
00025 #include <qvalidator.h>
00026 
00027 #include "kexiformdataiteminterface.h"
00028 #include "kexidbtextwidgetinterface.h"
00029 #include "kexidbutils.h"
00030 #include <widget/utils/kexidatetimeformatter.h>
00031 
00032 class KexiDateFormatter;
00033 class KexiTimeFormatter;
00034 class KexiDBWidgetContextMenuExtender;
00035 
00038 void setLighterGrayBackgroundColor(QWidget* widget);
00039 
00041 
00044 class KEXIFORMUTILS_EXPORT KexiDBLineEdit :
00045     public KLineEdit,
00046     protected KexiDBTextWidgetInterface,
00047     public KexiFormDataItemInterface,
00048     public KexiSubwidgetInterface
00049 {
00050     Q_OBJECT
00051     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00052     Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00053     Q_OVERRIDE(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true)
00054 
00055     public:
00056         KexiDBLineEdit(QWidget *parent, const char *name=0);
00057         virtual ~KexiDBLineEdit();
00058 
00059         inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00060         inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00061         virtual QVariant value();
00062         virtual void setInvalidState( const QString& displayText );
00063 
00066         virtual bool valueIsNull();
00067 
00072         virtual bool valueIsEmpty();
00073 
00075         virtual bool valueIsValid();
00076 
00078         virtual bool isReadOnly() const;
00079 
00084         virtual void setDisplayDefaultValue(QWidget* widget, bool displayDefaultValue);
00085 
00087         virtual QWidget* widget();
00088 
00089         virtual bool cursorAtStart();
00090         virtual bool cursorAtEnd();
00091         virtual void clear();
00092 
00093         virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
00094 
00098         virtual void handleAction(const QString& actionName);
00099 
00101         virtual bool keyPressed(QKeyEvent *ke);
00102 
00103     public slots:
00104         inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00105         inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00106         virtual void setReadOnly( bool readOnly );
00107 
00109         virtual void undo();
00110 
00112         virtual void moveCursorToEnd();
00113 
00115         virtual void moveCursorToStart();
00116 
00118         virtual void selectAll();
00119 
00120     protected slots:
00121         void slotTextChanged(const QString&);
00122 
00123     protected:
00124         virtual void paintEvent ( QPaintEvent * );
00125         virtual void setValueInternal(const QVariant& add, bool removeOld);
00126         virtual bool event ( QEvent * );
00127 
00128         inline KexiDateFormatter* dateFormatter() {
00129             return m_dateFormatter ? m_dateFormatter : m_dateFormatter = new KexiDateFormatter();
00130         }
00131 
00132         inline KexiTimeFormatter* timeFormatter() {
00133             return m_timeFormatter ? m_timeFormatter : m_timeFormatter = new KexiTimeFormatter();
00134         }
00135 
00136         virtual QPopupMenu * createPopupMenu();
00137 
00139         virtual bool appendStretchRequired(KexiDBAutoField* autoField) const;
00140 
00142         KexiDateFormatter* m_dateFormatter;
00143 
00145         KexiTimeFormatter* m_timeFormatter;
00146 
00148         QGuardedPtr<const QValidator> m_readOnlyValidator;
00149 
00151         QGuardedPtr<const QValidator> m_readWriteValidator;
00152 
00154         KexiDBWidgetContextMenuExtender m_menuExtender;
00155 
00158         bool m_internalReadOnly : 1;
00159 
00161         bool m_slotTextChanged_enabled : 1;
00162 };
00163 
00164 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys