imagewidget.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef IMAGEWIDGET_H
00025 #define IMAGEWIDGET_H
00026
00027 #include <qlabel.h>
00028
00029 #include <kabc/picture.h>
00030 #include <kdialogbase.h>
00031
00032 #include "contacteditorwidget.h"
00033
00034 class KURLRequester;
00035 class QCheckBox;
00036
00040 class ImageLabel : public QLabel
00041 {
00042 Q_OBJECT
00043
00044 public:
00045 ImageLabel( const QString &title, QWidget *parent );
00046
00047 void setReadOnly( bool readOnly );
00048
00049 signals:
00050 void changed();
00051
00052 protected:
00053 virtual void dragEnterEvent( QDragEnterEvent *event );
00054 virtual void dropEvent( QDropEvent *event );
00055 virtual void mouseMoveEvent( QMouseEvent *event );
00056 virtual void mousePressEvent( QMouseEvent *event );
00057
00058 private:
00059 void startDrag();
00060
00061 bool mReadOnly;
00062 QPoint mDragStartPos;
00063 };
00064
00065 class ImageBaseWidget : public QWidget
00066 {
00067 Q_OBJECT
00068
00069 public:
00070 ImageBaseWidget( const QString &title, QWidget *parent, const char *name = 0 );
00071 ~ImageBaseWidget();
00072
00076 void setImage( const KABC::Picture &photo );
00077
00081 KABC::Picture image() const;
00082
00083 void setReadOnly( bool readOnly );
00084
00085 signals:
00086 void changed();
00087
00088 private slots:
00089 void loadImage();
00090 void updateGUI();
00091 void clear();
00092 void imageChanged();
00093
00094 private:
00095 QPixmap loadPixmap( const KURL &url );
00096
00097 ImageLabel *mImageLabel;
00098 KURLRequester *mImageUrl;
00099
00100 QCheckBox *mUseImageUrl;
00101 QPushButton *mClearButton;
00102
00103 bool mReadOnly;
00104 };
00105
00106 class ImageWidget : public KAB::ContactEditorWidget
00107 {
00108 public:
00109 ImageWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
00110
00111 void loadContact( KABC::Addressee *addr );
00112 void storeContact( KABC::Addressee *addr );
00113 void setReadOnly( bool readOnly );
00114
00115 int logicalWidth() const { return 2; }
00116
00117 private:
00118 ImageBaseWidget *mPhotoWidget;
00119 ImageBaseWidget *mLogoWidget;
00120 };
00121
00122 class ImageWidgetFactory : public KAB::ContactEditorWidgetFactory
00123 {
00124 public:
00125 KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
00126 {
00127 return new ImageWidget( ab, parent, name );
00128 }
00129
00130 QString pageIdentifier() const { return "misc"; }
00131 };
00132
00133 #endif
This file is part of the documentation for kaddressbook Library Version 3.3.2.