Pimcommon

recentaddresses.h
1 /*
2  *
3  * SPDX-FileCopyrightText: 2001-2003 Carsten Pfeiffer <[email protected]>
4  * SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 #pragma once
9 
10 #include "pimcommonakonadi_export.h"
11 #include <KContacts/Addressee>
12 #include <QStringList>
13 class KConfig;
14 
15 namespace PimCommon
16 {
17 /**
18  * Handles a list of "recent email-addresses". Simply set a max-count and
19  * call @ref add() to add entries.
20  *
21  * @author Carsten Pfeiffer <[email protected]>
22  */
23 
24 class PIMCOMMONAKONADI_EXPORT RecentAddresses
25 {
26 public:
27  ~RecentAddresses();
28  /**
29  * @returns the only possible instance of this class.
30  */
31  static RecentAddresses *self(KConfig *config = nullptr);
32 
33  /*
34  * @return true if self() was called, i.e. a RecentAddresses instance exists
35  */
36  static bool exists();
37 
38  /**
39  * @returns the list of recent addresses.
40  * Note: an entry doesn't have to be one email address, it can be multiple,
41  * like "Foo <[email protected]>, Bar Baz <[email protected]>".
42  */
43  Q_REQUIRED_RESULT QStringList addresses() const;
44 
45  /**
46  * Adds an entry to the list.
47  * Note: an entry doesn't have to be one email address, it can be multiple,
48  * like "Foo <[email protected]>, Bar Baz <[email protected]>".
49  */
50  void add(const QString &entry);
51 
52  /**
53  * Sets the maximum number, the list can hold. The list adjusts to this
54  * size if necessary. Default maximum is 40.
55  */
56  void setMaxCount(int count);
57 
58  /**
59  * @returns the current maximum number of entries.
60  */
61  Q_REQUIRED_RESULT int maxCount() const;
62 
63  /**
64  * Loads the list of recently used addresses from the configfile.
65  * Automatically done on startup.
66  */
67  void load(KConfig *);
68 
69  /**
70  * Saves the list of recently used addresses to the configfile.
71  * Make sure to call KSharedConfig::openConfig()->sync() afterwards, to really save.
72  */
73  void save(KConfig *);
74 
75  /**
76  * Removes all entries from the history.
77  */
78  void clear();
79 
80 private:
81  explicit RecentAddresses(KConfig *config = nullptr);
82  void adjustSize();
83 
84  KContacts::Addressee::List m_addresseeList;
85 
86  int m_maxCount;
87 };
88 }
folderdialogacltab.h
Handles a list of "recent email-addresses".
AddresseeList List
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 03:52:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.