1 | /* |
2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KABC_ADDRESSEEDIALOG_H |
22 | #define KABC_ADDRESSEEDIALOG_H |
23 | |
24 | #include "kabc_export.h" |
25 | #ifndef KDEPIM_NO_KRESOURCES |
26 | #include "addressbook.h" |
27 | #else |
28 | #include "addressee.h" |
29 | #endif |
30 | |
31 | #include <kdialog.h> |
32 | #include <klineedit.h> |
33 | |
34 | #include <QtCore/QHash> |
35 | #include <QtCore/QString> |
36 | #include <QTreeWidgetItem> |
37 | |
38 | namespace KABC { |
39 | |
40 | /** |
41 | @short Special ListViewItem, that is used by the AddresseeDialog. |
42 | */ |
43 | class KABC_EXPORT AddresseeItem : public QTreeWidgetItem |
44 | { |
45 | public: |
46 | |
47 | /** |
48 | Type of column |
49 | */ |
50 | enum Columns { |
51 | Name = 0, /**< Addressee name. */ |
52 | Email = 1 /**< Addressee email */ |
53 | }; |
54 | |
55 | /** |
56 | Constructor. |
57 | |
58 | @param parent The parent listview. |
59 | @param addressee The associated addressee. |
60 | */ |
61 | AddresseeItem( QTreeWidget *parent, const Addressee &addressee ); |
62 | |
63 | /** |
64 | Destroys the item. |
65 | */ |
66 | ~AddresseeItem(); |
67 | |
68 | /** |
69 | Returns the addressee. |
70 | */ |
71 | Addressee addressee() const; |
72 | |
73 | /** |
74 | Method used by QListView to sort the items. |
75 | */ |
76 | virtual QString key( int column, bool ascending ) const; |
77 | |
78 | private: |
79 | class Private; |
80 | Private *const d; |
81 | |
82 | Q_DISABLE_COPY( AddresseeItem ) |
83 | }; |
84 | |
85 | /** |
86 | @short Dialog for selecting address book entries. |
87 | |
88 | This class provides a dialog for selecting entries from the standard KDE |
89 | address book. Use the getAddressee() function to open a modal dialog, |
90 | returning an address book entry. |
91 | |
92 | In the dialog you can select an entry from the list with the mouse or type in |
93 | the first letters of the name or email address you are searching for. The |
94 | entry matching best is automatically selected. Use double click, pressing |
95 | return or pressing the ok button to return the selected addressee to the |
96 | application. |
97 | */ |
98 | class KABC_DEPRECATED_EXPORT AddresseeDialog : public KDialog |
99 | { |
100 | Q_OBJECT |
101 | |
102 | public: |
103 | /** |
104 | Construct addressbook entry select dialog. |
105 | |
106 | @param parent parent widget |
107 | @param multiple if true, indicates a multiple selection. |
108 | */ |
109 | explicit AddresseeDialog( QWidget *parent = 0, bool multiple = false ); |
110 | |
111 | /** |
112 | Destructor. |
113 | */ |
114 | virtual ~AddresseeDialog(); |
115 | |
116 | /** |
117 | Return the address chosen. |
118 | |
119 | If it is a multiple select, this will return only the first address chosen |
120 | */ |
121 | Addressee addressee() const; |
122 | |
123 | /** |
124 | Return the list of addresses chosen |
125 | */ |
126 | Addressee::List addressees() const; |
127 | |
128 | /** |
129 | Select a single address book entry. |
130 | |
131 | Open addressee select dialog and return the entry selected by the user. |
132 | If the user doesn't select an entry or presses cancel, the returned |
133 | addressee is empty. |
134 | |
135 | @param parent The QWidget parent for the dialog. |
136 | */ |
137 | static Addressee getAddressee( QWidget *parent ); |
138 | |
139 | /** |
140 | Select multiple address book entries. |
141 | |
142 | Open addressee select dialog and return the entries selected by the user. |
143 | If the user doesn't select an entry or presses cancel, the returned |
144 | addressee list is empty. |
145 | |
146 | @param parent The QWidget parent for the dialog. |
147 | */ |
148 | static Addressee::List getAddressees( QWidget *parent ); |
149 | |
150 | private: |
151 | class Private; |
152 | Private *const d; |
153 | |
154 | Q_PRIVATE_SLOT( d, void addressBookChanged() ) |
155 | Q_PRIVATE_SLOT( d, void selectItem( const QString & ) ) |
156 | Q_PRIVATE_SLOT( d, void updateEdit() ) |
157 | Q_PRIVATE_SLOT( d, void addSelected( QTreeWidgetItem * ) ) |
158 | Q_PRIVATE_SLOT( d, void removeSelected() ) |
159 | }; |
160 | |
161 | } |
162 | #endif |
163 | |