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
00115 virtual void setPalette( const QPalette &pal );
00116
00118 virtual void setPaletteBackgroundColor( const QColor & color );
00119
00121 bool dropDownButtonVisible() const;
00122
00124 int lineWidth() const { return KexiFrame::lineWidth(); }
00125
00129 FocusPolicy focusPolicy() const;
00130
00132 FocusPolicy focusPolicyInternal() const;
00133
00136 virtual void setFocusPolicy( FocusPolicy policy );
00137
00138 public slots:
00139 void setPixmapId(uint id);
00140
00141 void setStoredPixmapId(uint id);
00142
00144 virtual void setDataSource( const QString &ds );
00145
00146 inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00147
00148 virtual void setReadOnly(bool set);
00149
00152
00153
00156
00157
00158 void setScaledContents(bool set);
00159
00160 void setAlignment(int alignment);
00161
00162 void setKeepAspectRatio(bool set);
00163
00164
00165
00167
00168
00170 void setDropDownButtonVisible( bool set );
00171
00173 void insertFromFile();
00174
00175 signals:
00178
00179
00180
00181 void idChanged(long id);
00182
00183 protected slots:
00184 void slotUpdateActionsAvailabilityRequested(bool& valueIsNull, bool& valueIsReadOnly);
00185
00186 void handleInsertFromFileAction(const KURL& url);
00187 void handleAboutToSaveAsAction(QString& origFilename, QString& fileExtension, bool& dataIsEmpty);
00188 void handleSaveAsAction(const QString& fileName);
00189 void handleCutAction();
00190 void handleCopyAction();
00191 void handlePasteAction();
00192 virtual void clear();
00193 void handleShowPropertiesAction();
00194
00195 protected:
00197 QByteArray data() const;
00198
00199 virtual void contextMenuEvent ( QContextMenuEvent * e );
00200
00201 virtual void setColumnInfo(KexiDB::QueryColumnInfo* cinfo);
00202 virtual void paintEvent( QPaintEvent* );
00203 virtual void resizeEvent( QResizeEvent* e );
00204 virtual bool eventFilter( QObject * watched, QEvent * e );
00205
00207 virtual void setValueInternal( const QVariant& add, bool removeOld ) {
00208 setValueInternal( add, removeOld, true );
00209 }
00210
00212 void setValueInternal( const QVariant& add, bool removeOld, bool loadPixmap );
00213
00215 void updateActionStrings();
00216 void updatePixmap();
00217
00219 void setData(const KexiBLOBBuffer::Handle& handle);
00220
00221 bool popupMenuAvailable();
00222
00226 virtual bool keyPressed(QKeyEvent *ke);
00227
00230 int realLineWidth() const;
00231
00233 virtual bool subwidgetStretchRequired(KexiDBAutoField* autoField) const;
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 QPixmap m_pixmap;
00249 QByteArray m_value;
00250 QString m_valueMimeType;
00251
00252 KexiBLOBBuffer::Handle m_data;
00253
00254 KexiDropDownButton *m_chooser;
00255 KexiImageContextMenu *m_popupMenu;
00256
00257
00258
00259
00260 int m_alignment;
00261 FocusPolicy m_focusPolicyInternal;
00262 bool m_designMode : 1;
00263 bool m_readOnly : 1;
00264 bool m_scaledContents : 1;
00265 bool m_keepAspectRatio : 1;
00266 bool m_insideSetData : 1;
00267 bool m_setFocusOnButtonAfterClosingPopup : 1;
00268 bool m_lineWidthChanged : 1;
00269 bool m_paletteBackgroundColorChanged : 1;
00270 bool m_paintEventEnabled : 1;
00271 bool m_dropDownButtonVisible : 1;
00272 bool m_insideSetPalette : 1;
00273 };
00274
00275 #endif
|