~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/widget/tableview/kexitableedit.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
   You should have received a copy of the GNU Library General Public License
16
16
   along with this program; see the file COPYING.  If not, write to
17
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 
   Boston, MA 02111-1307, USA.
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
19
19
 */
20
20
 
21
21
#ifndef _KEXITABLEEDIT_H_
30
30
 
31
31
namespace KexiDB {
32
32
        class Field;
 
33
        class QueryColumnInfo;
33
34
}
34
35
 
35
36
/*! @short Abstract class for a cell editor.
40
41
 
41
42
        public:
42
43
                KexiTableEdit(KexiTableViewColumn &column, QScrollView* parent = 0, const char* name = 0);
43
 
//              KexiTableEdit(KexiDB::Field &f, QScrollView* parent = 0, const char* name = 0);
44
44
 
45
45
                virtual ~KexiTableEdit();
46
46
 
47
 
/* moved to KexiDataItemInterface*/
48
 
                /*! Just initializes \a value, and calls init(const QString& add, bool removeOld). 
49
 
                 If \a removeOld is true, current value is set up as \a add.
50
 
                 If \a removeOld if false, current value is set up as \a value + \a add.
51
 
                 \a value is stored as 'old value' -it'd be usable in the future
52
 
                 (e.g. Combo Box editor can use old value if current value does not 
53
 
                 match any item on the list).
54
 
                 Called by KexiTableView and others. */
55
 
/*              void init(const QVariant& value, const QString& add, bool removeOld = false);
56
 
 
57
 
                //! \return true if editor's value is changed (compared to original value)
58
 
                virtual bool valueChanged();
59
 
 
60
 
                //! \return true if editor's value is null (not empty)
61
 
                virtual bool valueIsNull() = 0;
62
 
 
63
 
                //! \return true if editor's value is empty (not null). 
64
 
                //! Only few field types can accept "EMPTY" property 
65
 
                //! (check this with KexiDB::Field::hasEmptyProperty()), 
66
 
                virtual bool valueIsEmpty() = 0;
67
 
*/
68
 
 
69
 
/* moved to KexiDataItemInterface
70
 
                virtual QVariant value(bool &ok) = 0;
71
 
*/
72
 
 
73
47
                //! Implemented for KexiDataItemInterface.
74
48
                //! \return field information for this item
75
49
                virtual KexiDB::Field *field() const { return m_column->field(); }
76
50
 
 
51
                /*! A rich field information for db-aware data. 
 
52
                 For not-db-aware data it is always 0 (use field() instead. */
 
53
                virtual KexiDB::QueryColumnInfo *columnInfo() const { return m_column->fieldinfo; }
 
54
 
77
55
                //! Implemented for KexiDataItemInterface.
78
56
                //! Does nothing because instead KexiTableViewColumn is used to get field's schema.
79
 
                virtual void setField(KexiDB::Field *field) { }
 
57
                virtual void setColumnInfo(KexiDB::QueryColumnInfo *) { }
80
58
 
81
59
                //! \return column information for this item 
82
60
                //! (extended information, comparing to field()).
83
61
                inline KexiTableViewColumn *column() const { return m_column; }
84
62
 
85
 
//moved to KexiDataItemInterface
86
 
                /*! \return true if internal editor's cursor (whatever that means, eg. line edit cursor)
87
 
                 is at the beginning of editor's contents. This can inform table view that 
88
 
                 after pressing "left arrow" key should stop editing and move to cell at the left 
89
 
                 hand of the current cell. */
90
 
//              virtual bool cursorAtStart() = 0;
91
 
 
92
 
//moved to KexiDataItemInterface
93
 
                /*! \return true if internal editor's cursor (whatever that means, eg. line edit cursor)
94
 
                 is at the end of editor's contents. This can inform table view that 
95
 
                 after pressing "right arrow" key should stop editing and move to cell at the right 
96
 
                 hand of the current cell. */
97
 
//              virtual bool cursorAtEnd() = 0;
98
 
 
99
63
                /*! Reimplemented: resizes a view(). */
100
64
                virtual void resize(int w, int h);
101
65
 
108
72
                /*! Shows item's widget, if available. */
109
73
                inline virtual void showWidget() { show(); }
110
74
 
111
 
//moved to KexiDataItemInterface
112
 
                //! clears editor's data, so the data will contain NULL data
113
 
//              virtual void clear() = 0;
114
 
 
115
 
//moved to KexiDataItemInterface
116
 
#if 0
117
 
                /*! Displays additional elements that are needed for indicating that the current cell
118
 
                 is selected. For example, combobox editor (KexiComboBoxTableEdit) moves and shows
119
 
                 dropdown button. \a r is the rectangle for the cell. 
120
 
                 For reimplementation. By default does nothing. */
121
 
                virtual void showFocus( const QRect& r );
122
 
 
123
 
                /*! Hides additional elements that are needed for indicating that the current cell
124
 
                 is selected. 
125
 
                 For reimplementation. By default does nothing. */
126
 
                virtual void hideFocus();
127
 
#endif
128
 
 
129
75
                /*! Paints a border for the cell described by \a x, \a y, \a w, \a h on \a p painter.
130
76
                 The cell's value is \a val (may be usefull if you want to reimplement this method).
131
77
                */
153
99
                        bool readOnly, bool fullRowSelection );
154
100
 
155
101
                /*! Sometimes, editor can contain non-standard margin, for example combobox editor contains
156
 
                 dropdown button at the right side. \returns left margin's size; 
 
102
                 dropdown button at the right side. \return left margin's size; 
157
103
                 0 by default. For reimplementation.  */
158
104
                int leftMargin() const { return m_leftMargin; }
159
105
 
160
106
                /*! Sometimes, editor can contain non-standard margin, for example combobox editor contains
161
 
                 dropdown button at the right side. \returns right margin;s size; 
 
107
                 dropdown button at the right side. \return right margin;s size; 
162
108
                 0 by default. For reimplementation.  */
163
109
                int rightMargin() const { return m_rightMargin; }
164
110
 
177
123
                 returns QWidget::size(). */
178
124
                virtual QSize totalSize() { return QWidget::size(); }
179
125
 
180
 
//moved to KexiDataItemInterface
181
 
                /*! \return true if this editor offers a widget (e.g. line edit) that we can move focus to.
182
 
                 Editor for boolean values has this set to false (see KexiBoolTableEdit). 
183
 
                 You can override this flag by changing m_hasFocusableWidget in your subclass' constructor. */
184
 
//              inline bool hasFocusableWidget() const { return m_hasFocusableWidget; }
185
 
 
186
 
//moved to KexiDataItemInterface
187
 
                /*! Allows to define reaction for clicking on cell's contents. 
188
 
                 Currently it's used for editor of type boolean, where we want to toggle true/false
189
 
                 on single mouse click. \sa hasFocusableWidget(), KexiBoolTableEdit. 
190
 
                 Default implementation does nothing. */
191
 
//              virtual void clickedOnContents() {};
192
 
 
193
 
//moved to KexiDataItemInterface
194
 
                /*! \return true if editing should be accepted immediately after
195
 
                 deleting contents for the cell (usually using Delete key).
196
 
                 This flag is false by default, and is true e.g. for date, time and datetime types. */
197
 
//              bool acceptEditorAfterDeleteContents() const { return m_acceptEditorAfterDeleteContents; }
198
 
 
199
126
        signals:
200
127
                void editRequested();
201
128
                void cancelRequested();
202
129
                void acceptRequested();
203
130
 
204
131
        protected:
205
 
#if 0
206
 
//moved to KexiDataItemInterface
207
 
                /*! Initializes this editor with \a add value, which should be somewhat added to the current
208
 
                 value (already storted in m_origValue). 
209
 
                 If \a removeOld is true, a value should be set to \a add, otherwise 
210
 
                 -it should be set to current \a m_origValue + \a add, if possible.
211
 
                 Implement this. */
212
 
                virtual void init(const QVariant& add, bool removeOld) = 0;
213
 
#endif
214
132
                virtual bool eventFilter(QObject* watched, QEvent* e);
215
133
 
216
134
                /*! Sets \a v as view widget for this editor. The view will be assigned as focus proxy
222
140
                void moveChild( QWidget * child, int x, int y ) {
223
141
                        m_scrollView->moveChild(child, x, y); }
224
142
 
225
 
        //              virtual void paintEvent( QPaintEvent *pe );
226
 
//moved to KexiDataItemInterface: QVariant m_origValue;
227
143
                KexiTableViewColumn *m_column;
228
 
//              KexiDB::Field *m_field;
229
 
//              int m_type; //! one of KexiDB::Field
230
144
                int m_leftMargin;
231
145
                int m_rightMargin;
232
 
 
233
146
                QScrollView* m_scrollView;
234
147
 
235
 
//moved to KexiDataItemInterface:               bool m_hasFocusableWidget : 1;
236
 
//moved to KexiDataItemInterface:               bool m_acceptEditorAfterDeleteContents : 1;
237
148
        private:
238
149
                QWidget* m_view;
239
150
};
240
151
 
 
152
//! Declaration of cell editor factory
 
153
#define KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(factoryclassname) \
 
154
        class factoryclassname : public KexiCellEditorFactoryItem \
 
155
        { \
 
156
                public: \
 
157
                        factoryclassname(); \
 
158
                        virtual ~factoryclassname(); \
 
159
        \
 
160
                protected: \
 
161
                        virtual KexiTableEdit* createEditor(KexiTableViewColumn &column, QScrollView* parent = 0); \
 
162
        };
 
163
 
 
164
//! Implementation of cell editor factory
 
165
#define KEXI_CELLEDITOR_FACTORY_ITEM_IMPL(factoryclassname, itemclassname) \
 
166
factoryclassname::factoryclassname() \
 
167
 : KexiCellEditorFactoryItem() \
 
168
{} \
 
169
\
 
170
factoryclassname::~factoryclassname() \
 
171
{} \
 
172
\
 
173
KexiTableEdit* factoryclassname::createEditor( \
 
174
        KexiTableViewColumn &column, QScrollView* parent) \
 
175
{ \
 
176
        return new itemclassname(column, parent); \
 
177
}
 
178
 
241
179
#endif