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 );
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 
00099     KABC::Addressee::List toAddresses()  const;
00103     KABC::Addressee::List ccAddresses()  const;
00107     KABC::Addressee::List bccAddresses() const;
00108 
00109   public slots:
00114     void setShowCC( bool b );
00119     void setShowBCC( bool b );
00124     void setRecentAddresses( const KABC::Addressee::List& addr );
00128     void setSelectedTo( const QStringList& l );
00132     void setSelectedCC( const QStringList& l );
00136     void setSelectedBCC( const QStringList& l );
00137 
00138   protected slots:
00139     void addSelectedTo();
00140     void addSelectedCC();
00141     void addSelectedBCC();
00142 
00143     void removeEntry();
00144     void saveAs();
00145     void launchAddressBook();
00146 
00147     void filterChanged( const QString & );
00148 
00149     void updateAvailableAddressees();
00150     void availableSelectionChanged();
00151     void selectedSelectionChanged();
00152     void availableAddressSelected( AddresseeViewItem* item, bool selected );
00153     void selectedAddressSelected( AddresseeViewItem* item, bool selected );
00154 
00155   protected:
00156     AddresseeViewItem* selectedToItem();
00157     AddresseeViewItem* selectedCcItem();
00158     AddresseeViewItem* selectedBccItem();
00159 
00160     void initConnections();
00161     void addDistributionLists();
00162     void addAddresseeToAvailable( const KABC::Addressee& addr,
00163                                   AddresseeViewItem* defaultParent=0 );
00164     void addAddresseeToSelected( const KABC::Addressee& addr,
00165                                  AddresseeViewItem* defaultParent=0 );
00166     void addAddresseesToSelected( AddresseeViewItem *parent,
00167                                   const QPtrList<AddresseeViewItem>& addresses );
00168     QStringList entryToString( const KABC::Addressee::List& l ) const;
00169     KABC::Addressee::List allAddressee( AddresseeViewItem* parent ) const;
00170     KABC::Addressee::List allAddressee( KListView* view, bool onlySelected = true ) const;
00171     QStringList allDistributionLists( AddresseeViewItem* parent ) const;
00172 
00173   private:
00174     // if there's only one group in the available list, open it
00175     void checkForSingleAvailableGroup();
00176 
00177     // used to re-show items in the available list
00178     // it is recursive, but should only ever recurse once so should be fine
00179     void unmapSelectedAddress(AddresseeViewItem* item);
00180     void updateRecentAddresses();
00181 
00182     struct AddressesDialogPrivate;
00183     AddressesDialogPrivate *d;
00184 
00185     QPtrList<AddresseeViewItem> selectedAvailableAddresses;
00186     QPtrList<AddresseeViewItem> selectedSelectedAddresses;
00187     QPtrDict<AddresseeViewItem> selectedToAvailableMapping;
00188   };
00189 
00190 }
00191 
00192 #endif /* ADDRESSESDIALOG_H */
KDE Logo
This file is part of the documentation for libkdepim Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:31 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003