1 /* -*- mode: C++; c-file-style: "gnu" -*-
3 * This file is part of libkdepim.
5 * Copyright (c) 2003 Zack Rusin <zack@kde.org>
6 * Copyright (c) 2003 Aaron J. Seigo <aseigo@kde.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
25 #ifndef KDEPIM_ADDRESSESDIALOG_H
26 #define KDEPIM_ADDRESSESDIALOG_H
28 #include "kdepim_export.h"
29 #include "ui_addresspicker.h"
31 #include <kabc/addressee.h>
37 #include <QStringList>
38 #include <QTreeWidget>
40 class AddressPickerUI
: public QWidget
, public Ui::AddressPickerUI
43 AddressPickerUI( QWidget
*parent
) : QWidget( parent
) {
52 class AddresseeViewItem
: public QObject
, public QTreeWidgetItem
66 AddresseeViewItem( AddresseeViewItem
*parent
, const KABC::Addressee
& addr
, int emailIndex
= 0 );
67 AddresseeViewItem( QTreeWidget
*lv
, const QString
& name
, Category cat
=Group
);
68 AddresseeViewItem( AddresseeViewItem
*parent
, const QString
& name
, const KABC::Addressee::List
&lst
);
69 AddresseeViewItem( AddresseeViewItem
*parent
, const QString
& name
);
72 KABC::Addressee
addressee() const;
73 KABC::Addressee::List
addresses() const;
74 Category
category() const;
77 QString
email() const;
79 bool matches( const QString
& ) const;
81 virtual bool operator < ( const QTreeWidgetItem
& other
) const;
84 struct AddresseeViewItemPrivate
;
85 AddresseeViewItemPrivate
*d
;
88 class KDEPIM_EXPORT AddressesDialog
: public KDialog
92 AddressesDialog( QWidget
*widget
=0 );
96 * Returns the list of picked "To" addresses as a QStringList.
98 QStringList
to() const;
100 * Returns the list of picked "CC" addresses as a QStringList.
102 QStringList
cc() const;
104 * Returns the list of picked "BCC" addresses as a QStringList.
106 QStringList
bcc() const;
109 * Returns the list of picked "To" addresses as KABC::Addressee::List.
110 * Note that this doesn't include the distribution lists
112 KABC::Addressee::List
toAddresses() const;
114 * Returns the list of picked "To" addresses as KABC::Addressee::List.
115 * Note that this does include the distribution lists
116 * Multiple Addressees are removed
118 KABC::Addressee::List
allToAddressesNoDuplicates() const;
120 * Returns the list of picked "CC" addresses as KABC::Addressee::List.
121 * Note that this doesn't include the distribution lists
123 KABC::Addressee::List
ccAddresses() const;
125 * Returns the list of picked "BCC" addresses as KABC::Addressee::List.
126 * Note that this doesn't include the distribution lists
128 KABC::Addressee::List
bccAddresses() const;
131 * Returns the list of picked "To" distribution lists.
132 * This complements @ref toAddresses.
134 QStringList
toDistributionLists() const;
136 * Returns the list of picked "CC" distribution lists.
137 * This complements @ref ccAddresses.
139 QStringList
ccDistributionLists() const;
141 * Returns the list of picked "BCC" distribution lists.
142 * This complements @ref bccAddresses.
144 QStringList
bccDistributionLists() const;
148 * Displays the CC field if @p b is true, else
149 * hides it. By default displays it.
151 void setShowCC( bool b
);
153 * Displays the BCC field if @p b is true, else
154 * hides it. By default displays it.
156 void setShowBCC( bool b
);
158 * If called adds "Recent Addresses" item to the picker list view,
159 * with the addresses given in @p addr.
161 void setRecentAddresses( const KABC::Addressee::List
& addr
);
163 * Adds addresses in @p l to the selected "To" group.
165 void setSelectedTo( const QStringList
& l
);
167 * Adds addresses in @p l to the selected "CC" group.
169 void setSelectedCC( const QStringList
& l
);
171 * Adds addresses in @p l to the selected "BCC" group.
173 void setSelectedBCC( const QStringList
& l
);
176 void addSelectedTo();
177 void addSelectedCC();
178 void addSelectedBCC();
183 void ldapSearchResult();
185 void filterChanged( const QString
& );
187 void updateAvailableAddressees();
188 void availableSelectionChanged();
189 void selectedSelectionChanged();
192 AddresseeViewItem
* selectedToItem();
193 AddresseeViewItem
* selectedCcItem();
194 AddresseeViewItem
* selectedBccItem();
196 QList
<AddresseeViewItem
*> selectedAvailableAddresses() const;
197 QList
<AddresseeViewItem
*> selectedSelectedAddresses() const;
199 void initConnections();
200 void addDistributionLists();
201 void addAddresseeToAvailable( const KABC::Addressee
& addr
,
202 AddresseeViewItem
* defaultParent
=0, bool useCategory
=true );
203 void addAddresseeToSelected( const KABC::Addressee
& addr
,
204 AddresseeViewItem
* defaultParent
=0 );
205 void addAddresseesToSelected( AddresseeViewItem
*parent
,
206 const QList
<AddresseeViewItem
*> addresses
);
207 QStringList
entryToString( const KABC::Addressee::List
& l
) const;
208 KABC::Addressee::List
allAddressee( AddresseeViewItem
* parent
) const;
209 KABC::Addressee::List
allAddressee( QTreeWidget
* view
, bool onlySelected
= true ) const;
210 QStringList
allDistributionLists( AddresseeViewItem
* parent
) const;
213 // if there's only one group in the available list, open it
214 void checkForSingleAvailableGroup();
216 // used to re-show items in the available list
217 // it is recursive, but should only ever recurse once so should be fine
218 void unmapSelectedAddress(AddresseeViewItem
* item
);
219 void updateRecentAddresses();
221 struct AddressesDialogPrivate
;
222 AddressesDialogPrivate
*d
;
224 QMap
<AddresseeViewItem
*,AddresseeViewItem
*> selectedToAvailableMapping
;
229 #endif /* ADDRESSESDIALOG_H */