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-2007 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/tableview/kexitextformatter.h>
00031 #include <widget/utils/kexidatetimeformatter.h>
00032 
00033 class KexiDBWidgetContextMenuExtender;
00034 
00037 void setLighterGrayBackgroundColor(QWidget* widget);
00038 
00040 
00043 class KEXIFORMUTILS_EXPORT KexiDBLineEdit :
00044     public KLineEdit,
00045     protected KexiDBTextWidgetInterface,
00046     public KexiFormDataItemInterface,
00047     public KexiSubwidgetInterface
00048 {
00049     Q_OBJECT
00050     Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00051     Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00052     Q_OVERRIDE(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true)
00053 
00054     public:
00055         KexiDBLineEdit(QWidget *parent, const char *name=0);
00056         virtual ~KexiDBLineEdit();
00057 
00058         inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00059         inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00060         virtual QVariant value();
00061         virtual void setInvalidState( const QString& displayText );
00062 
00065         virtual bool valueIsNull();
00066 
00071         virtual bool valueIsEmpty();
00072 
00074         virtual bool valueIsValid();
00075 
00077         virtual bool isReadOnly() const;
00078 
00083         virtual void setDisplayDefaultValue(QWidget* widget, bool displayDefaultValue);
00084 
00086         virtual QWidget* widget();
00087 
00088         virtual bool cursorAtStart();
00089         virtual bool cursorAtEnd();
00090         virtual void clear();
00091 
00092         virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
00093 
00097         virtual void handleAction(const QString& actionName);
00098 
00100         virtual bool keyPressed(QKeyEvent *ke);
00101 
00102     public slots:
00103         inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00104         inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00105         virtual void setReadOnly( bool readOnly );
00106 
00108         virtual void undo();
00109 
00111         virtual void moveCursorToEnd();
00112 
00114         virtual void moveCursorToStart();
00115 
00117         virtual void selectAll();
00118 
00119     protected slots:
00120         void slotTextChanged(const QString&);
00121 
00122     protected:
00123         virtual void paintEvent ( QPaintEvent * );
00124         virtual void setValueInternal(const QVariant& add, bool removeOld);
00125         virtual bool event ( QEvent * );
00126 
00127 #if 0
00128 //moved to KexiTextFormatter
00129         inline KexiDateFormatter* dateFormatter() {
00130             return m_dateFormatter ? m_dateFormatter : m_dateFormatter = new KexiDateFormatter();
00131         }
00132 
00133         inline KexiTimeFormatter* timeFormatter() {
00134             return m_timeFormatter ? m_timeFormatter : m_timeFormatter = new KexiTimeFormatter();
00135         }
00136 #endif
00137 
00138         virtual QPopupMenu * createPopupMenu();
00139 
00141         virtual bool appendStretchRequired(KexiDBAutoField* autoField) const;
00142 
00143 #if 0
00144 //moved to KexiTextFormatter
00146         KexiDateFormatter* m_dateFormatter;
00148         KexiTimeFormatter* m_timeFormatter;
00149 #endif
00151         KexiTextFormatter m_textFormatter;
00152 
00154         QGuardedPtr<const QValidator> m_readOnlyValidator;
00155 
00157         QGuardedPtr<const QValidator> m_readWriteValidator;
00158 
00160         KexiDBWidgetContextMenuExtender m_menuExtender;
00161 
00164         bool m_internalReadOnly : 1;
00165 
00167         bool m_slotTextChanged_enabled : 1;
00168 };
00169 
00170 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys