kaddressbook

distributionlistwidget.h

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 DISTRIBUTIONLISTWIDGET_H
00025 #define DISTRIBUTIONLISTWIDGET_H
00026 
00027 #include <config.h> // for KDEPIM_NEW_DISTRLISTS
00028 #include <kdialogbase.h>
00029 #include <klistview.h>
00030 
00031 #include "extensionwidget.h"
00032 
00033 class QButtonGroup;
00034 class QComboBox;
00035 class QListView;
00036 
00037 class DistributionListView;
00038 
00039 namespace KAB {
00040 class Core;
00041 }
00042 
00043 namespace KABC {
00044 class AddressBook;
00045 class DistributionListManager;
00046 }
00047 
00048 class DistributionListWidget : public KAB::ExtensionWidget
00049 {
00050     Q_OBJECT
00051 
00052   public:
00053     DistributionListWidget( KAB::Core*, QWidget *parent, const char *name = 0 );
00054     virtual ~DistributionListWidget();
00055 
00056     void contactsSelectionChanged();
00057 
00058     QString title() const;
00059     QString identifier() const;
00060 
00061   public slots:
00062     void save();
00063     void dropped( QDropEvent*, QListViewItem* );
00064 
00065     void removeContact();
00066 
00067   private slots:
00068     void createList();
00069     void editList();
00070     void removeList();
00071     void addContact();
00072     void changeEmail();
00073     void updateNameCombo();
00074     void updateContactView();
00075     void selectionContactViewChanged();
00076 
00077   private:
00078 #ifdef KDEPIM_NEW_DISTRLISTS
00079     void changed( const KABC::Addressee& dist );
00080 #else
00081     void changed();
00082 #endif
00083     bool alreadyExists( const QString& distrListName ) const;
00084 
00085   protected:
00086     void dropEvent( QDropEvent* );
00087 
00088   private:
00089     QComboBox *mNameCombo;
00090     QLabel *mEntryCountLabel;
00091     DistributionListView *mContactView;
00092 
00093 #ifndef KDEPIM_NEW_DISTRLISTS
00094     KABC::DistributionListManager *mManager;
00095 #endif
00096     QPushButton *mCreateListButton;
00097     QPushButton *mEditListButton;
00098     QPushButton *mRemoveListButton;
00099     QPushButton *mChangeEmailButton;
00100     QPushButton *mAddContactButton;
00101     QPushButton *mRemoveContactButton;
00102 };
00103 
00107 class DistributionListView : public KListView
00108 {
00109   Q_OBJECT
00110 
00111   public:
00112     DistributionListView( QWidget *parent, const char* name = 0 );
00113 
00114   protected:
00115     void dragEnterEvent( QDragEnterEvent *e );
00116     void dropEvent( QDropEvent *e );
00117     void viewportDragMoveEvent( QDragMoveEvent *e );
00118     void viewportDropEvent( QDropEvent *e );
00119 };
00120 
00124 class EmailSelector : public KDialogBase
00125 {
00126   public:
00127     EmailSelector( const QStringList &emails, const QString &current,
00128                    QWidget *parent );
00129 
00130     QString selected() const;
00131 
00132     static QString getEmail( const QStringList &emails, const QString &current,
00133                              QWidget *parent );
00134 
00135   private:
00136     QButtonGroup *mButtonGroup;
00137     QMap<int, QString> mEmailMap;
00138 };
00139 
00140 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys