kaddressbook Library API Documentation

imagewidget.h

00001 /*                                                                      
00002     This file is part of KAddressBook.                                  
00003     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>                   
00004                                                                         
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or   
00008     (at your option) any later version.                                 
00009                                                                         
00010     This program is distributed in the hope that it will be useful,     
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of      
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the        
00013     GNU General Public License for more details.                        
00014                                                                         
00015     You should have received a copy of the GNU General Public License   
00016     along with this program; if not, write to the Free Software         
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           
00018                                                                         
00019     As a special exception, permission is given to link this program    
00020     with any edition of Qt, and distribute the resulting executable,    
00021     without including the source code for Qt in the source distribution.
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
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:42:47 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003