libkdepim

distributionlist.h

00001 /*
00002     This file is part of libkdepim.
00003     Copyright (c) 2004-2005 David Faure <faure@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library 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 GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef DISTRIBUTIONLIST_H
00022 #define DISTRIBUTIONLIST_H
00023 
00024 #include <kabc/addressee.h>
00025 
00026 namespace KABC {
00027 class AddressBook;
00028 }
00029 
00030 namespace KPIM {
00031 
00043 class DistributionList : public KABC::Addressee
00044 {
00045   public:
00053     struct Entry
00054     {
00055       typedef QValueList<Entry> List;
00056 
00057       Entry() {}
00058       Entry( const Addressee &_addressee, const QString &_email ) :
00059           addressee( _addressee ), email( _email ) {}
00060 
00061       Addressee addressee;
00062       QString email;
00063     };
00064 
00065     typedef QValueList<DistributionList> List;
00066 
00070     DistributionList();
00075     DistributionList( const KABC::Addressee& addr );
00076 
00080     ~DistributionList() {}
00081 
00083     void setName( const QString &name );
00084 
00086     QString name() const { return formattedName(); }
00087 
00092     void insertEntry( const Addressee &, const QString &email=QString::null );
00093 
00098     void removeEntry( const Addressee &, const QString &email=QString::null );
00099 
00101     void insertEntry( const QString& uid, const QString& email=QString::null );
00103     void removeEntry( const QString& uid, const QString& email=QString::null );
00104 
00105 
00111     QStringList emails( KABC::AddressBook* book ) const;
00112 
00118     Entry::List entries( KABC::AddressBook* book ) const;
00119 
00120     // KDE4: should be a method of Addressee
00121     static bool isDistributionList( const KABC::Addressee& addr );
00122 
00123     // KDE4: should be a method of AddressBook
00124     static DistributionList findByName( KABC::AddressBook* book,
00125                                         const QString& name,
00126                                         bool caseSensitive = true );
00127     // KDE4: should be a method of AddressBook
00128     // A bit slow (but no more than findByName).
00129     // From KAddressbook, use Core::distributionLists() instead.
00130     static QValueList<DistributionList> allDistributionLists( KABC::AddressBook* book );
00131 
00132 
00133   private:
00134     // can't have any data here, use Addressee's methods instead
00135 };
00136 
00137 }
00138 
00139 #endif /* DISTRIBUTIONLIST_H */
00140 
KDE Home | KDE Accessibility Home | Description of Access Keys