kexidblineedit.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004-2007 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KexiDBLineEdit_H
22#define KexiDBLineEdit_H
23
24#include <klineedit.h>
25#include <tqvalidator.h>
26
27#include "kexiformdataiteminterface.h"
28#include "kexidbtextwidgetinterface.h"
29#include "kexidbutils.h"
30#include <widget/tableview/kexitextformatter.h>
31#include <widget/utils/kexidatetimeformatter.h>
32
34
37void setLighterGrayBackgroundColor(TQWidget* widget);
38
40
43class KEXIFORMUTILS_EXPORT KexiDBLineEdit :
44 public KLineEdit,
48{
49 TQ_OBJECT
50
51 TQ_PROPERTY(TQString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
52 TQ_PROPERTY(TQCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
53 TQ_OVERRIDE(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true)
54
55 public:
56 KexiDBLineEdit(TQWidget *parent, const char *name=0);
57 virtual ~KexiDBLineEdit();
58
59 inline TQString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
60 inline TQCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
61 virtual TQVariant value();
62 virtual void setInvalidState( const TQString& displayText );
63
66 virtual bool valueIsNull();
67
72 virtual bool valueIsEmpty();
73
75 virtual bool valueIsValid();
76
78 virtual bool isReadOnly() const;
79
84 virtual void setDisplayDefaultValue(TQWidget* widget, bool displayDefaultValue);
85
87 virtual TQWidget* widget();
88
89 virtual bool cursorAtStart();
90 virtual bool cursorAtEnd();
91 virtual void clear();
92
93 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
94
98 virtual void handleAction(const TQString& actionName);
99
101 virtual bool keyPressed(TQKeyEvent *ke);
102
103 public slots:
104 inline void setDataSource(const TQString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
105 inline void setDataSourceMimeType(const TQCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
106 virtual void setReadOnly( bool readOnly );
107
109 virtual void undo();
110
112 virtual void moveCursorToEnd();
113
115 virtual void moveCursorToStart();
116
118 virtual void selectAll();
119
120 protected slots:
121 void slotTextChanged(const TQString&);
122
123 protected:
124 virtual void paintEvent ( TQPaintEvent * );
125 virtual void setValueInternal(const TQVariant& add, bool removeOld);
126 virtual bool event ( TQEvent * );
127
128#if 0
129//moved to KexiTextFormatter
130 inline KexiDateFormatter* dateFormatter() {
131 return m_dateFormatter ? m_dateFormatter : m_dateFormatter = new KexiDateFormatter();
132 }
133
134 inline KexiTimeFormatter* timeFormatter() {
135 return m_timeFormatter ? m_timeFormatter : m_timeFormatter = new KexiTimeFormatter();
136 }
137#endif
138
139 virtual TQPopupMenu * createPopupMenu();
140
142 virtual bool appendStretchRequired(KexiDBAutoField* autoField) const;
143
144#if 0
145//moved to KexiTextFormatter
147 KexiDateFormatter* m_dateFormatter;
149 KexiTimeFormatter* m_timeFormatter;
150#endif
153
155 TQGuardedPtr<const TQValidator> m_readOnlyValidator;
156
158 TQGuardedPtr<const TQValidator> m_readWriteValidator;
159
162
166
169};
170
171#endif
Universal "Auto Field" widget for Kexi forms.
Line edit widget for Kexi forms.
TQGuardedPtr< const TQValidator > m_readOnlyValidator
Used for read only flag to disable editing.
bool m_slotTextChanged_enabled
Used in slotTextChanged()
TQGuardedPtr< const TQValidator > m_readWriteValidator
Used to remember the previous validator used forf r/w mode, after setting the read only flag.
KexiDBWidgetContextMenuExtender m_menuExtender
Used for extending context menu.
bool m_internalReadOnly
Used in isReadOnly, as sometimes we want to have the flag set tot true when KLineEdit::isReadOnly is ...
KexiTextFormatter m_textFormatter
Used to format text.
An interface providing common text editor's functionality.
void setColumnInfo(KexiDB::QueryColumnInfo *cinfo, TQWidget *w)
Called from KexiFormDataItemInterface::setColumnInfo(KexiDB::QueryColumnInfo* cinfo) implementation.
void event(TQEvent *e, TQWidget *w, bool textIsEmpty)
Called from event( TQEvent * e ) method of the data aware widget.
Used for extending editor widgets' context menu.
Definition kexidbutils.h:32
Helper class that assigns additional information for the column in a query.
Definition queryschema.h:49
virtual bool cursorAtEnd()=0
virtual bool cursorAtStart()=0
virtual bool isReadOnly() const
virtual TQVariant value()=0
virtual bool valueIsNull()=0
virtual bool valueIsEmpty()=0
virtual void handleAction(const TQString &actionName)
virtual void setValueInternal(const TQVariant &add, bool removeOld)=0
virtual void clear()=0
clears item's data, so the data will contain NULL data
Date formatter used by KexiDateTableEdit and KexiDateTimeTableEdit.
An interface for declaring form widgets to be data-aware.
void setDataSourceMimeType(const TQCString &ds)
virtual void setDisplayDefaultValue(TQWidget *widget, bool displayDefaultValue)
void setDataSource(const TQString &ds)
Sets the name of the data source for this widget.
virtual void setInvalidState(const TQString &displayText)=0
virtual void setReadOnly(bool readOnly)=0
An interface allowing to define custom behaviour for subwidget of the KexiDBAutoField.
Definition kexidbutils.h:60
Text formatter used to format TQVariant values to text for displaying and back to TQVariant.
Time formatter used by KexiTimeTableEdit and KexiDateTimeTableEdit Following time formats are allowed...