2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
28 #include <qpushbutton.h>
30 #include <kabc/picture.h>
31 #include <kdialogbase.h>
33 #include "contacteditorwidget.h"
38 class ImageLoader
: public QObject
43 ImageLoader( QWidget
*parent
);
45 KABC::Picture
loadPicture( const KURL
&url
, bool *ok
);
48 KABC::Picture mPicture
;
55 class ImageButton
: public QPushButton
60 ImageButton( const QString
&title
, QWidget
*parent
);
62 void setReadOnly( bool readOnly
);
64 void setPicture( const KABC::Picture
&picture
);
65 KABC::Picture
picture() const;
67 void setImageLoader( ImageLoader
*loader
);
71 void urlDropped( const KURL
& );
74 virtual void dragEnterEvent( QDragEnterEvent
*event
);
75 virtual void dropEvent( QDropEvent
*event
);
76 virtual void mouseMoveEvent( QMouseEvent
*event
);
77 virtual void mousePressEvent( QMouseEvent
*event
);
78 virtual void contextMenuEvent( QContextMenuEvent
*event
);
90 KABC::Picture mPicture
;
92 ImageLoader
*mImageLoader
;
96 class ImageBaseWidget
: public QWidget
101 ImageBaseWidget( const QString
&title
, QWidget
*parent
, const char *name
= 0 );
105 Sets the photo object.
107 void setImage( const KABC::Picture
&photo
);
110 Returns a photo object.
112 KABC::Picture
image() const;
114 void setReadOnly( bool readOnly
);
120 ImageButton
*mImageButton
;
121 ImageLoader
*mImageLoader
;
126 class ImageWidget
: public KAB::ContactEditorWidget
129 ImageWidget( KABC::AddressBook
*ab
, QWidget
*parent
, const char *name
= 0 );
131 void loadContact( KABC::Addressee
*addr
);
132 void storeContact( KABC::Addressee
*addr
);
133 void setReadOnly( bool readOnly
);
135 int logicalWidth() const { return 2; }
138 ImageBaseWidget
*mPhotoWidget
;
139 ImageBaseWidget
*mLogoWidget
;
142 class ImageWidgetFactory
: public KAB::ContactEditorWidgetFactory
145 KAB::ContactEditorWidget
*createWidget( KABC::AddressBook
*ab
, QWidget
*parent
, const char *name
)
147 return new ImageWidget( ab
, parent
, name
);
150 QString
pageIdentifier() const { return "misc"; }