kexi
kexidbimagebox.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KexiDBImageBox_H
00022 #define KexiDBImageBox_H
00023
00024 #include "kexiformdataiteminterface.h"
00025 #include "kexiframe.h"
00026 #include "kexidbutils.h"
00027 #include <kexiblobbuffer.h>
00028 #include <widget/utils/kexiimagecontextmenu.h>
00029
00030 class KexiDropDownButton;
00031
00033
00035 class KEXIFORMUTILS_EXPORT KexiDBImageBox :
00036 public KexiFrame,
00037 public KexiFormDataItemInterface,
00038 public KexiSubwidgetInterface
00039 {
00040 Q_OBJECT
00041 Q_PROPERTY( QString dataSource READ dataSource WRITE setDataSource )
00042 Q_PROPERTY( QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType )
00043 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00044
00045
00046 Q_PROPERTY( uint pixmapId READ pixmapId WRITE setPixmapId DESIGNABLE true STORED false )
00047 Q_PROPERTY( uint storedPixmapId READ storedPixmapId WRITE setStoredPixmapId DESIGNABLE false STORED true )
00048 Q_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents )
00049 Q_PROPERTY( bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio )
00050 Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
00051
00052
00053 Q_PROPERTY( bool dropDownButtonVisible READ dropDownButtonVisible WRITE setDropDownButtonVisible )
00054 Q_OVERRIDE( int lineWidth READ lineWidth WRITE setLineWidth )
00055 Q_OVERRIDE( FocusPolicy focusPolicy READ focusPolicyInternal WRITE setFocusPolicy )
00056
00057 public:
00058 KexiDBImageBox( bool designMode, QWidget *parent, const char *name = 0 );
00059 virtual ~KexiDBImageBox();
00060
00061 inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00062 inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00063
00064 virtual QVariant value();
00065
00066
00067
00068 QPixmap pixmap() const;
00069
00070 uint pixmapId() const;
00071
00072 uint storedPixmapId() const;
00073
00074 virtual void setInvalidState( const QString& displayText );
00075
00076 virtual bool valueIsNull();
00077
00078 virtual bool valueIsEmpty();
00079
00080 virtual QWidget* widget();
00081
00083 virtual bool cursorAtStart();
00084
00086 virtual bool cursorAtEnd();
00087
00088
00089
00090
00091 virtual bool isReadOnly() const;
00092
00093 bool hasScaledContents() const;
00094
00095
00096
00097 int alignment() const { return m_alignment; }
00098
00099 bool keepAspectRatio() const { return m_keepAspectRatio; }
00100
00101 virtual QSize sizeHint() const;
00102
00103 KexiImageContextMenu *contextMenu() const;
00104
00108
00109
00111 virtual void setLineWidth( int width );
00112
00114 virtual void setPaletteBackgroundColor( const QColor & color );
00115
00117 bool dropDownButtonVisible() const;
00118
00120 int lineWidth() const { return KexiFrame::lineWidth(); }
00121
00125 FocusPolicy focusPolicy() const;
00126
00128 FocusPolicy focusPolicyInternal() const;
00129
00132 virtual void setFocusPolicy( FocusPolicy policy );
00133
00134 public slots:
00135 void setPixmapId(uint id);
00136
00137 void setStoredPixmapId(uint id);
00138
00140 virtual void setDataSource( const QString &ds );
00141
00142 inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00143
00144 virtual void setReadOnly(bool set);
00145
00148
00149
00152
00153
00154 void setScaledContents(bool set);
00155
00156 void setAlignment(int alignment);
00157
00158 void setKeepAspectRatio(bool set);
00159
00160
00161
00163
00164
00166 void setDropDownButtonVisible( bool set );
00167
00169 void insertFromFile();
00170
00171 signals:
00174
00175
00176
00177 void idChanged(long id);
00178
00179 protected slots:
00180 void slotUpdateActionsAvailabilityRequested(bool& valueIsNull, bool& valueIsReadOnly);
00181
00182 void handleInsertFromFileAction(const KURL& url);
00183 void handleAboutToSaveAsAction(QString& origFilename, QString& fileExtension, bool& dataIsEmpty);
00184 void handleSaveAsAction(const QString& fileName);
00185 void handleCutAction();
00186 void handleCopyAction();
00187 void handlePasteAction();
00188 virtual void clear();
00189 void handleShowPropertiesAction();
00190
00191 protected:
00193 QByteArray data() const;
00194
00195 virtual void contextMenuEvent ( QContextMenuEvent * e );
00196
00197 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
00198 virtual void paintEvent( QPaintEvent* );
00199 virtual void resizeEvent( QResizeEvent* e );
00200 virtual bool eventFilter( QObject * watched, QEvent * e );
00201
00203 virtual void setValueInternal( const QVariant& add, bool removeOld ) {
00204 setValueInternal( add, removeOld, true );
00205 }
00206
00208 void setValueInternal( const QVariant& add, bool removeOld, bool loadPixmap );
00209
00211 void updateActionStrings();
00212 void updatePixmap();
00213
00215 void setData(const KexiBLOBBuffer::Handle& handle);
00216
00217 bool popupMenuAvailable();
00218
00222 virtual bool keyPressed(QKeyEvent *ke);
00223
00226 int realLineWidth() const;
00227
00229 virtual bool subwidgetStretchRequired(KexiDBAutoField* autoField) const;
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 QPixmap m_pixmap;
00245 QByteArray m_value;
00246 QString m_valueMimeType;
00247
00248 KexiBLOBBuffer::Handle m_data;
00249
00250 KexiDropDownButton *m_chooser;
00251 KexiImageContextMenu *m_popupMenu;
00252
00253
00254
00255
00256 int m_alignment;
00257 FocusPolicy m_focusPolicyInternal;
00258 bool m_designMode : 1;
00259 bool m_readOnly : 1;
00260 bool m_scaledContents : 1;
00261 bool m_keepAspectRatio : 1;
00262 bool m_insideSetData : 1;
00263 bool m_setFocusOnButtonAfterClosingPopup : 1;
00264 bool m_lineWidthChanged : 1;
00265 bool m_paletteBackgroundColorChanged : 1;
00266 bool m_paintEventEnabled : 1;
00267 bool m_dropDownButtonVisible : 1;
00268 };
00269
00270 #endif
|