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 searchLdap();
00171     void ldapSearchResult();
00172     void launchAddressBook();
00173 
00174     void filterChanged( const QString & );
00175 
00176     void updateAvailableAddressees();
00177     void availableSelectionChanged();
00178     void selectedSelectionChanged();
00179     void availableAddressSelected( AddresseeViewItem* item, bool selected );
00180     void selectedAddressSelected( AddresseeViewItem* item, bool selected );
00181 
00182   protected:
00183     AddresseeViewItem* selectedToItem();
00184     AddresseeViewItem* selectedCcItem();
00185     AddresseeViewItem* selectedBccItem();
00186 
00187     void initConnections();
00188     void addDistributionLists();
00189     void addAddresseeToAvailable( const KABC::Addressee& addr,
00190                                   AddresseeViewItem* defaultParent=0, bool useCategory=true );
00191     void addAddresseeToSelected( const KABC::Addressee& addr,
00192                                  AddresseeViewItem* defaultParent=0 );
00193     void addAddresseesToSelected( AddresseeViewItem *parent,
00194                                   const QPtrList<AddresseeViewItem>& addresses );
00195     QStringList entryToString( const KABC::Addressee::List& l ) const;
00196     KABC::Addressee::List allAddressee( AddresseeViewItem* parent ) const;
00197     KABC::Addressee::List allAddressee( KListView* view, bool onlySelected = true ) const;
00198     QStringList allDistributionLists( AddresseeViewItem* parent ) const;
00199 
00200   private:
00201     // if there's only one group in the available list, open it
00202     void checkForSingleAvailableGroup();
00203 
00204     // used to re-show items in the available list
00205     // it is recursive, but should only ever recurse once so should be fine
00206     void unmapSelectedAddress(AddresseeViewItem* item);
00207     void updateRecentAddresses();
00208 
00209     struct AddressesDialogPrivate;
00210     AddressesDialogPrivate *d;
00211 
00212     QPtrList<AddresseeViewItem> selectedAvailableAddresses;
00213     QPtrList<AddresseeViewItem> selectedSelectedAddresses;
00214     QPtrDict<AddresseeViewItem> selectedToAvailableMapping;
00215   };
00216 
00217 }
00218 
00219 #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 Jan 31 15:53:22 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003