libkdepim Library API Documentation

addressesdialog.h

00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002  *
00003  *  This file is part of libkdepim.
00004  *  Copyright (c) 2003 Zack Rusin <zack@kde.org>
00005  *  Copyright (c) 2003 Aaron J. Seigo <aseigo@kde.org>
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Library General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Library General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Library General Public License
00018  *  along with this library; see the file COPYING.LIB.  If not, write to
00019  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  *  Boston, MA 02111-1307, USA.
00021  *
00022  */
00023 
00024 #ifndef ADDRESSESDIALOG_H
00025 #define ADDRESSESDIALOG_H
00026 
00027 #include <kabc/addressee.h>
00028 #include <kdialogbase.h>
00029 #include <klistview.h>
00030 #include <qstringlist.h>
00031 #include <qptrlist.h>
00032 #include <qptrdict.h>
00033 
00034 namespace KPIM {
00035 
00036   class AddresseeViewItem : public QObject, public KListViewItem
00037   {
00038   Q_OBJECT
00039 
00040   public:
00041     enum Category {
00042       To          =0,
00043       CC          =1,
00044       BCC         =2,
00045       Group       =3,
00046       Entry       =4,
00047       FilledGroup =5,
00048       DistList    =6
00049     };
00050     AddresseeViewItem( AddresseeViewItem *parent, const KABC::Addressee& addr, int emailIndex = 0 );
00051     AddresseeViewItem( KListView *lv, const QString& name, Category cat=Group );
00052     AddresseeViewItem( AddresseeViewItem *parent, const QString& name, const KABC::Addressee::List &lst );
00053     AddresseeViewItem( AddresseeViewItem *parent, const QString& name );
00054     ~AddresseeViewItem();
00055 
00056     KABC::Addressee       addressee() const;
00057     KABC::Addressee::List addresses() const;
00058     Category              category() const;
00059 
00060     QString name()  const;
00061     QString email() const;
00062 
00063     bool matches( const QString& ) const;
00064 
00065     virtual int compare( QListViewItem * i, int col, bool ascending ) const;
00066     virtual void setSelected( bool );
00067 
00068   signals:
00069     void addressSelected( AddresseeViewItem*, bool );
00070 
00071   private:
00072     struct AddresseeViewItemPrivate;
00073     AddresseeViewItemPrivate *d;
00074   };
00075 
00076   class AddressesDialog : public KDialogBase
00077   {
00078     Q_OBJECT
00079   public:
00080     AddressesDialog( QWidget *widget=0, const char *name=0 );
00081     ~AddressesDialog();
00082 
00086     QStringList to()  const;
00090     QStringList cc()  const;
00094     QStringList bcc() const;
00095 
00100     KABC::Addressee::List toAddresses()  const;
00106     KABC::Addressee::List allToAddressesNoDuplicates()  const;
00111     KABC::Addressee::List ccAddresses()  const;
00116     KABC::Addressee::List bccAddresses() const;
00117 
00122     QStringList toDistributionLists() const;
00127     QStringList ccDistributionLists() const;
00132     QStringList bccDistributionLists() const;
00133 
00134   public slots:
00139     void setShowCC( bool b );
00144     void setShowBCC( bool b );
00149     void setRecentAddresses( const KABC::Addressee::List& addr );
00153     void setSelectedTo( const QStringList& l );
00157     void setSelectedCC( const QStringList& l );
00161     void setSelectedBCC( const QStringList& l );
00162 
00163   protected slots:
00164     void addSelectedTo();
00165     void addSelectedCC();
00166     void addSelectedBCC();
00167 
00168     void removeEntry();
00169     void saveAs();
00170     void launchAddressBook();
00171 
00172     void filterChanged( const QString & );
00173 
00174     void updateAvailableAddressees();
00175     void availableSelectionChanged();
00176     void selectedSelectionChanged();
00177     void availableAddressSelected( AddresseeViewItem* item, bool selected );
00178     void selectedAddressSelected( AddresseeViewItem* item, bool selected );
00179 
00180   protected:
00181     AddresseeViewItem* selectedToItem();
00182     AddresseeViewItem* selectedCcItem();
00183     AddresseeViewItem* selectedBccItem();
00184 
00185     void initConnections();
00186     void addDistributionLists();
00187     void addAddresseeToAvailable( const KABC::Addressee& addr,
00188                                   AddresseeViewItem* defaultParent=0, bool useCategory=true );
00189     void addAddresseeToSelected( const KABC::Addressee& addr,
00190                                  AddresseeViewItem* defaultParent=0 );
00191     void addAddresseesToSelected( AddresseeViewItem *parent,
00192                                   const QPtrList<AddresseeViewItem>& addresses );
00193     QStringList entryToString( const KABC::Addressee::List& l ) const;
00194     KABC::Addressee::List allAddressee( AddresseeViewItem* parent ) const;
00195     KABC::Addressee::List allAddressee( KListView* view, bool onlySelected = true ) const;
00196     QStringList allDistributionLists( AddresseeViewItem* parent ) const;
00197 
00198   private:
00199     // if there's only one group in the available list, open it
00200     void checkForSingleAvailableGroup();
00201 
00202     // used to re-show items in the available list
00203     // it is recursive, but should only ever recurse once so should be fine
00204     void unmapSelectedAddress(AddresseeViewItem* item);
00205     void updateRecentAddresses();
00206 
00207     struct AddressesDialogPrivate;
00208     AddressesDialogPrivate *d;
00209 
00210     QPtrList<AddresseeViewItem> selectedAvailableAddresses;
00211     QPtrList<AddresseeViewItem> selectedSelectedAddresses;
00212     QPtrDict<AddresseeViewItem> selectedToAvailableMapping;
00213   };
00214 
00215 }
00216 
00217 #endif /* ADDRESSESDIALOG_H */
KDE Logo
This file is part of the documentation for libkdepim Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:40:51 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003