Pimcommon

recentaddresses.h
1/*
2 *
3 * SPDX-FileCopyrightText: 2001-2003 Carsten Pfeiffer <pfeiffer@kde.org>
4 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org>
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>
13class KConfig;
14
15namespace 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 <pfeiffer@kde.org>
22 */
23
24class PIMCOMMONAKONADI_EXPORT RecentAddresses
25{
26public:
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 <foo@bar.org>, Bar Baz <bar@baz.org>".
42 */
43 [[nodiscard]] 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 <foo@bar.org>, Bar Baz <bar@baz.org>".
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 [[nodiscard]] 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
80private:
81 PIMCOMMONAKONADI_NO_EXPORT explicit RecentAddresses(KConfig *config = nullptr);
82 PIMCOMMONAKONADI_NO_EXPORT void adjustSize();
83
84 KContacts::Addressee::List m_addresseeList;
85
86 int m_maxCount;
87};
88}
AddresseeList List
Handles a list of "recent email-addresses".
folderdialogacltab.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 12:00:34 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.