kexidbimagebox.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 KexiDBImageBox_H
22#define KexiDBImageBox_H
23
24#include "kexiformdataiteminterface.h"
25#include "kexiframe.h"
26#include "kexidbutils.h"
27#include <kexiblobbuffer.h>
28
31
33
35class KEXIFORMUTILS_EXPORT KexiDBImageBox :
36 public KexiFrame,
39{
40 TQ_OBJECT
41
42 TQ_PROPERTY( TQString dataSource READ dataSource WRITE setDataSource )
43 TQ_PROPERTY( TQCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType )
44 TQ_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
45// TQ_PROPERTY( TQPixmap pixmap READ pixmap WRITE setPixmap )
46// TQ_PROPERTY( TQByteArray pixmapData READ pixmapData WRITE setPixmapData )
47 TQ_PROPERTY( uint pixmapId READ pixmapId WRITE setPixmapId DESIGNABLE true STORED false )
48 TQ_PROPERTY( uint storedPixmapId READ storedPixmapId WRITE setStoredPixmapId DESIGNABLE false STORED true )
49 TQ_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents )
50 TQ_PROPERTY( bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio )
51 TQ_PROPERTY( int alignment READ alignment WRITE setAlignment )
52// TQ_PROPERTY( TQString originalFileName READ originalFileName WRITE setOriginalFileName DESIGNABLE false )
53// TQ_OVERRIDE( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy )
54 TQ_PROPERTY( bool dropDownButtonVisible READ dropDownButtonVisible WRITE setDropDownButtonVisible )
55 TQ_OVERRIDE( int lineWidth READ lineWidth WRITE setLineWidth )
56 TQ_OVERRIDE( FocusPolicy focusPolicy READ focusPolicyInternal WRITE setFocusPolicy )
57
58 public:
59 KexiDBImageBox( bool designMode, TQWidget *parent, const char *name = 0 );
60 virtual ~KexiDBImageBox();
61
62 inline TQString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
63 inline TQCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
64
65 virtual TQVariant value(); // { return m_value.data(); }
66
67// TQByteArray pixmapData() const { return m_value.data(); }
68
69 TQPixmap pixmap() const;
70
71 uint pixmapId() const;
72
73 uint storedPixmapId() const;
74//
75 virtual void setInvalidState( const TQString& displayText );
76
77 virtual bool valueIsNull();
78
79 virtual bool valueIsEmpty();
80
81 virtual TQWidget* widget();
82
84 virtual bool cursorAtStart();
85
87 virtual bool cursorAtEnd();
88
89// //! used to catch setIndent(), etc.
90// virtual bool setProperty ( const char * name, const TQVariant & value );
91
92 virtual bool isReadOnly() const;
93
94 bool hasScaledContents() const;
95
96// bool designMode() const { return m_designMode; }
97
98 int alignment() const { return m_alignment; }
99
100 bool keepAspectRatio() const { return m_keepAspectRatio; }
101
102 virtual TQSize sizeHint() const;
103
104 KexiImageContextMenu *contextMenu() const;
105
109//todo TQString originalFileName() const { return m_value.originalFileName(); }
110
112 virtual void setLineWidth( int width );
113
116 virtual void setPalette( const TQPalette &pal );
117
119 virtual void setPaletteBackgroundColor( const TQColor & color );
120
122 bool dropDownButtonVisible() const;
123
125 int lineWidth() const { return KexiFrame::lineWidth(); }
126
130 TQWidget::FocusPolicy focusPolicy() const;
131
133 TQWidget::FocusPolicy focusPolicyInternal() const;
134
137 virtual void setFocusPolicy( TQWidget::FocusPolicy policy );
138
139 public slots:
140 void setPixmapId(uint id);
141
142 void setStoredPixmapId(uint id);
143
145 virtual void setDataSource( const TQString &ds );
146
147 inline void setDataSourceMimeType(const TQCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
148
149 virtual void setReadOnly(bool set);
150
153//todo void setPixmapData(const TQByteArray& pixmapData) { m_value.setData(pixmapData); }
154
157//todo void setOriginalFileName(const TQString& name) { m_value.setOriginalFileName(name); }
158
159 void setScaledContents(bool set);
160
161 void setAlignment(int alignment);
162
163 void setKeepAspectRatio(bool set);
164
165// void updateActionsAvailability();
166
168// void slotToggled( bool on );
169
171 void setDropDownButtonVisible( bool set );
172
174 void insertFromFile();
175
176 signals:
179// virtual void pixmapChanged();
180// virtual void valueChanged(const TQByteArray& data);
181
182 void idChanged(long id);
183
184 protected slots:
185 void slotUpdateActionsAvailabilityRequested(bool& valueIsNull, bool& valueIsReadOnly);
186
187 void handleInsertFromFileAction(const KURL& url);
188 void handleAboutToSaveAsAction(TQString& origFilename, TQString& fileExtension, bool& dataIsEmpty);
189 void handleSaveAsAction(const TQString& fileName);
190 void handleCutAction();
191 void handleCopyAction();
192 void handlePasteAction();
193 virtual void clear();
194 void handleShowPropertiesAction();
195
196 protected:
198 TQByteArray data() const;
199
200 virtual void contextMenuEvent ( TQContextMenuEvent * e );
201// virtual void mousePressEvent( TQMouseEvent *e );
202 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
203 virtual void paintEvent( TQPaintEvent* );
204 virtual void resizeEvent( TQResizeEvent* e );
205 virtual bool eventFilter( TQObject * watched, TQEvent * e );
206
208 virtual void setValueInternal( const TQVariant& add, bool removeOld ) {
209 setValueInternal( add, removeOld, true /*loadPixmap*/ );
210 }
211
213 void setValueInternal( const TQVariant& add, bool removeOld, bool loadPixmap );
214
216 void updateActionStrings();
217 void updatePixmap();
218
220 void setData(const KexiBLOBBuffer::Handle& handle);
221
222 bool popupMenuAvailable();
223
227 virtual bool keyPressed(TQKeyEvent *ke);
228
231 int realLineWidth() const;
232
234 virtual bool subwidgetStretchRequired(KexiDBAutoField* autoField) const;
235
236// virtual void drawContents ( TQPainter *p );
237
238// virtual void fontChange( const TQFont& font );
239// virtual void styleChange( TQStyle& style );
240// virtual void enabledChange( bool enabled );
241
242// virtual void paletteChange( const TQPalette& pal );
243// virtual void frameChanged();
244// virtual void showEvent( TQShowEvent* e );
245
246// void updatePixmapLater();
247// class ImageLabel;
248// ImageLabel *m_pixmapLabel;
249 TQPixmap m_pixmap;
250 TQByteArray m_value;
252// PixmapData m_value;
254// TQString m_originalFileName;
255 KexiDropDownButton *m_chooser;
256 KexiImageContextMenu *m_popupMenu;
257//moved TDEActionCollection m_actionCollection;
258//moved TDEAction *m_insertFromFileAction, *m_saveAsAction, *m_cutAction, *m_copyAction, *m_pasteAction,
259// *m_deleteAction, *m_propertiesAction;
260// TQTimer m_clickTimer;
261 int m_alignment;
262 TQWidget::FocusPolicy m_focusPolicyInternal;
263 bool m_designMode : 1;
264 bool m_readOnly : 1;
265 bool m_scaledContents : 1;
266 bool m_keepAspectRatio : 1;
267 bool m_insideSetData : 1;
268 bool m_setFocusOnButtonAfterClosingPopup : 1;
269 bool m_lineWidthChanged : 1;
270 bool m_paletteBackgroundColorChanged : 1;
272 bool m_dropDownButtonVisible : 1;
273 bool m_insideSetPalette : 1;
274};
275
276#endif
Object handle used by KexiBLOBBuffer.
Universal "Auto Field" widget for Kexi forms.
A data-aware, editable image box.
void idChanged(long id)
Used for db-aware mode.
TQByteArray m_value
for db-aware mode
int lineWidth() const
For overridden property.
TQString m_valueMimeType
for db-aware mode
virtual void setValueInternal(const TQVariant &add, bool removeOld)
Sets value value for a widget.
bool m_paintEventEnabled
used to disable paintEvent()
TQWidget::FocusPolicy m_focusPolicyInternal
Used for focusPolicyInternal()
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 setValueInternal(const TQVariant &add, bool removeOld)=0
virtual void clear()=0
clears item's data, so the data will contain NULL data
A button for drop-down "Image" menu.
An interface for declaring form widgets to be data-aware.
void setDataSourceMimeType(const TQCString &ds)
virtual void setColumnInfo(KexiDB::QueryColumnInfo *cinfo)
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
Frame widget for Kexi forms.
Definition kexiframe.h:27
A context menu used for images within form and table views.
An interface allowing to define custom behaviour for subwidget of the KexiDBAutoField.
Definition kexidbutils.h:60