Better wording
[kdepim.git] / libkdepim / recentaddresses.h
blob236abb631bc91c07fd735e1eeb14e34cae31d7b6
1 /* -*- mode: C++; c-file-style: "gnu" -*-
3 * Copyright (c) 2001-2003 Carsten Pfeiffer <pfeiffer@kde.org>
4 * Copyright (c) 2003 Zack Rusin <zack@kde.org>
6 * KMail is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * KMail is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * In addition, as a special exception, the copyright holders give
20 * permission to link the code of this program with any edition of
21 * the Qt library by Trolltech AS, Norway (or with modified versions
22 * of Qt that use the same license as Qt), and distribute linked
23 * combinations including the two. You must obey the GNU General
24 * Public License in all respects for all of the code used other than
25 * Qt. If you modify this file, you may extend this exception to
26 * your version of the file, but you are not obligated to do so. If
27 * you do not wish to do so, delete this exception statement from
28 * your version.
30 #ifndef KDEPIM_RECENTADDRESSES_H
31 #define KDEPIM_RECENTADDRESSES_H
33 #include "kdepim_export.h"
34 #include <kabc/addressee.h>
35 #include <KDialog>
36 #include <QStringList>
37 class KConfig;
38 class KEditListBox;
39 class KEditListWidget;
40 class KPushButton;
41 class QListWidget;
42 class KLineEdit;
44 namespace KPIM {
46 class KDEPIM_EXPORT RecentAddressDialog : public KDialog
48 Q_OBJECT
49 public:
50 RecentAddressDialog( QWidget *parent );
51 void setAddresses( const QStringList &addrs );
52 QStringList addresses() const;
53 void addAddresses(KConfig *config);
55 private slots:
56 void slotAddItem();
57 void slotRemoveItem();
58 void slotSelectionChanged();
59 void slotTypedSomething(const QString&);
60 protected:
61 void updateButtonState();
62 bool eventFilter( QObject* o, QEvent* e );
64 private:
65 KEditListWidget *mEditor;
66 KPushButton* mNewButton, *mRemoveButton;
67 QListWidget *mListView;
68 KLineEdit *mLineEdit;
71 /**
72 * Handles a list of "recent email-addresses". Simply set a max-count and
73 * call @ref add() to add entries.
75 * @author Carsten Pfeiffer <pfeiffer@kde.org>
78 class KDEPIM_EXPORT RecentAddresses
80 public:
81 ~RecentAddresses();
82 /**
83 * @returns the only possible instance of this class.
85 static RecentAddresses *self( KConfig *config = 0 );
88 * @return true if self() was called, i.e. a RecentAddresses instance exists
90 static bool exists();
92 /**
93 * @returns the list of recent addresses.
94 * Note: an entry doesn't have to be one email address, it can be multiple,
95 * like "Foo <foo@bar.org>, Bar Baz <bar@baz.org>".
97 QStringList addresses() const;
98 const KABC::Addressee::List &kabcAddresses() const
99 { return m_addresseeList; }
102 * Adds an entry to the list.
103 * Note: an entry doesn't have to be one email address, it can be multiple,
104 * like "Foo <foo@bar.org>, Bar Baz <bar@baz.org>".
106 void add( const QString &entry );
109 * Sets the maximum number, the list can hold. The list adjusts to this
110 * size if necessary. Default maximum is 40.
112 void setMaxCount( int count );
115 * @returns the current maximum number of entries.
117 uint maxCount() const { return m_maxCount; }
120 * Loads the list of recently used addresses from the configfile.
121 * Automatically done on startup.
123 void load( KConfig * );
126 * Saves the list of recently used addresses to the configfile.
127 * Make sure to call KGlobal::config()->sync() afterwards, to really save.
129 void save( KConfig * );
132 * Removes all entries from the history.
134 void clear();
136 private:
137 RecentAddresses( KConfig *config = 0 );
139 KABC::Addressee::List m_addresseeList;
141 void adjustSize();
143 int m_maxCount;
148 #endif