KIdentityManagementCore::IdentityManager Class
class KIdentityManagementCore::IdentityManagerManages the list of identities. More...
| Header: | #include <KIdentityManagementCore/IdentityManager> |
| CMake: | find_package(KPim6IdentityManagementCore REQUIRED)target_link_libraries(mytarget PRIVATE KPim6::IdentityManagementCore) |
| Inherits: | QObject |
Public Types
Public Functions
| IdentityManager(bool readonly = false, QObject *parent = nullptr, const char *name = nullptr) | |
| virtual | ~IdentityManager() override |
| QStringList | allEmails() const |
| KIdentityManagementCore::IdentityManager::ConstIterator | begin() const |
| void | commit() |
| const KIdentityManagementCore::Identity & | defaultIdentity() const |
| KIdentityManagementCore::IdentityManager::ConstIterator | end() const |
| bool | hasPendingChanges() const |
| QStringList | identities() const |
| const KIdentityManagementCore::Identity & | identityForAddress(const QString &addresses) const |
| const KIdentityManagementCore::Identity & | identityForUoid(uint uoid) const |
| const KIdentityManagementCore::Identity & | identityForUoidOrDefault(uint uoid) const |
| bool | isUnique(const QString &name) const |
| QString | makeUnique(const QString &name) const |
| KIdentityManagementCore::IdentityManager::Iterator | modifyBegin() |
| KIdentityManagementCore::IdentityManager::Iterator | modifyEnd() |
| KIdentityManagementCore::Identity & | modifyIdentityForName(const QString &identityName) |
| KIdentityManagementCore::Identity & | modifyIdentityForUoid(uint uoid) |
| KIdentityManagementCore::Identity & | newFromControlCenter(const QString &name) |
| KIdentityManagementCore::Identity & | newFromExisting(const KIdentityManagementCore::Identity &other, const QString &name = QString()) |
| KIdentityManagementCore::Identity & | newFromScratch(const QString &name) |
| bool | removeIdentity(const QString &identityName) |
| bool | removeIdentityForced(const QString &identityName) |
| void | rollback() |
| void | saveIdentity(const KIdentityManagementCore::Identity &ident) |
| bool | setAsDefault(uint uoid) |
| QStringList | shadowIdentities() const |
| void | sort() |
| bool | thatIsMe(const QString &addressList) const |
Signals
| void | added(const KIdentityManagementCore::Identity &ident) |
| void | changed() |
| void | changed(const KIdentityManagementCore::Identity &ident) |
| void | changed(uint uoid) |
| void | deleted(uint uoid) |
| void | identitiesChanged(const QString &id) |
| void | identitiesWereChanged() |
| void | identityChanged(const KIdentityManagementCore::Identity &ident) |
| void | needToReloadIdentitySettings() |
Static Public Members
| KIdentityManagementCore::IdentityManager * | self() |
Protected Functions
| virtual void | createDefaultIdentity(QString &fullName, QString &emailAddress) |
Protected Slots
| void | slotRollback() |
Detailed Description
Author: Marc Mutz <mutz@kde.org>
Member Type Documentation
[alias] IdentityManager::const_iterator
Typedef for STL style iterator
[alias] IdentityManager::iterator
Typedef for STL style iterator
Member Function Documentation
[explicit] IdentityManager::IdentityManager(bool readonly = false, QObject *parent = nullptr, const char *name = nullptr)
Constructor readonly if true, no changes can be made to the identity manager This means in particular that if there is no identity configured, the default identity created here will not be saved. It is assumed that a minimum of one identity is always present. parent the parent object name the object name
[override virtual noexcept] IdentityManager::~IdentityManager()
Destroys the identity manager.
[signal] void IdentityManager::added(const KIdentityManagementCore::Identity &ident)
Emitted on commit() for each new identity ident the newly added identity
QStringList IdentityManager::allEmails() const
Returns the list of all email addresses (only name@host) from all identities Returns a list of all email addresses across all identities
KIdentityManagementCore::IdentityManager::ConstIterator IdentityManager::begin() const
Returns a const iterator pointing to the first identity in the list
[signal] void IdentityManager::changed()
Emitted whenever a commit changes any configuration option
Note: This signal is overloaded. To connect to this signal:
// Connect using qOverload:
connect(identityManager, qOverload<>(&IdentityManager::changed),
receiver, &ReceiverClass::slot);
// Or using a lambda:
connect(identityManager, qOverload<>(&IdentityManager::changed),
this, []() { /* handle changed */ });
For more examples and approaches, see connecting to overloaded signals.
[signal] void IdentityManager::changed(const KIdentityManagementCore::Identity &ident)
Emitted whenever the identity ident changed. Useful for more fine-grained change notifications than what is possible with the changed() signal. ident the identity that changed
Note: This signal is overloaded. To connect to this signal:
// Connect using qOverload:
connect(identityManager, qOverload(&IdentityManager::changed),
receiver, &ReceiverClass::slot);
// Or using a lambda:
connect(identityManager, qOverload(&IdentityManager::changed),
this, [](const KIdentityManagementCore::Identity &ident) { /* handle changed */ });
For more examples and approaches, see connecting to overloaded signals.
[signal] void IdentityManager::changed(uint uoid)
Emitted whenever the identity with Unique Object Identifier (UOID) uoid changed. Useful for more fine-grained change notifications than what is possible with the changed() signal. uoid the unique object identifier of the changed identity
Note: This signal is overloaded. To connect to this signal:
// Connect using qOverload:
connect(identityManager, qOverload(&IdentityManager::changed),
receiver, &ReceiverClass::slot);
// Or using a lambda:
connect(identityManager, qOverload(&IdentityManager::changed),
this, [](uint uoid) { /* handle changed */ });
For more examples and approaches, see connecting to overloaded signals.
void IdentityManager::commit()
Commit changes to disk and emit changed() if necessary
[virtual protected] void IdentityManager::createDefaultIdentity(QString &fullName, QString &emailAddress)
This is called when no identity has been defined, so we need to create a default one. The parameters are filled with some default values from KUser, but reimplementations of this method can give them another value. fullName out parameter for the full name emailAddress out parameter for the email address
const KIdentityManagementCore::Identity &IdentityManager::defaultIdentity() const
Returns the default identity Returns the default identity
[signal] void IdentityManager::deleted(uint uoid)
Emitted on commit() for each deleted identity. At the time this signal is emitted, the identity does still exist and can be retrieved by identityForUoid() if needed. uoid the unique object identifier of the deleted identity
KIdentityManagementCore::IdentityManager::ConstIterator IdentityManager::end() const
Returns a const iterator pointing past the last identity in the list
bool IdentityManager::hasPendingChanges() const
Check whether there are any unsaved changes Returns true if there are pending changes, false otherwise
QStringList IdentityManager::identities() const
Returns the list of identities Returns a list of identity names
[signal] void IdentityManager::identitiesChanged(const QString &id)
Emitted when identities change id the identity identifier
[signal] void IdentityManager::identitiesWereChanged()
Emitted whenever any identity changes
[signal] void IdentityManager::identityChanged(const KIdentityManagementCore::Identity &ident)
Emitted whenever an identity changes ident the identity that changed
const KIdentityManagementCore::Identity &IdentityManager::identityForAddress(const QString &addresses) const
Returns an identity whose address matches any in addresses or Identity::null if no such identity exists. addresses the string of addresses to scan for matches Returns the identity matching the addresses or Identity::null
const KIdentityManagementCore::Identity &IdentityManager::identityForUoid(uint uoid) const
Returns the identity with Unique Object Identifier (UOID) uoid or Identity::null if not found. uoid the Unique Object Identifier to find identity with Returns the identity with the given UOID or Identity::null
const KIdentityManagementCore::Identity &IdentityManager::identityForUoidOrDefault(uint uoid) const
Convenience method. Returns the identity with Unique Object Identifier (UOID) uoid or the default identity if not found. uoid the Unique Object Identifier to find identity with Returns the identity with the given UOID or the default identity
bool IdentityManager::isUnique(const QString &name) const
Returns whether the name is unique name the name to be examined Returns true if the name is unique, false otherwise
QString IdentityManager::makeUnique(const QString &name) const
Returns a unique name for a new identity based on name name the name of the base identity Returns a unique identity name
KIdentityManagementCore::IdentityManager::Iterator IdentityManager::modifyBegin()
Iterator used by the configuration dialog, which works on a separate list of identities, for modification. Changes are made effective by commit(). Returns a mutable iterator pointing to the first identity in the shadow list
KIdentityManagementCore::IdentityManager::Iterator IdentityManager::modifyEnd()
Returns a mutable iterator pointing past the last identity in the shadow list
KIdentityManagementCore::Identity &IdentityManager::modifyIdentityForName(const QString &identityName)
Returns the identity named identityName. This method returns a reference to the identity that can be modified. To let others see this change, use commit(). identityName the identity name to return modifiable reference for Returns a modifiable reference to the identity
KIdentityManagementCore::Identity &IdentityManager::modifyIdentityForUoid(uint uoid)
Returns the identity with Unique Object Identifier (UOID) uoid. This method returns a reference to the identity that can be modified. To let others see this change, use commit(). uoid the Unique Object Identifier to find identity with Returns a modifiable reference to the identity
[signal] void IdentityManager::needToReloadIdentitySettings()
Emitted when identity settings need to be reloaded
KIdentityManagementCore::Identity &IdentityManager::newFromControlCenter(const QString &name)
Creates a new identity with the given name, copying values from the Control Center defaults name the name for the new identity Returns a reference to the newly created identity
KIdentityManagementCore::Identity &IdentityManager::newFromExisting(const KIdentityManagementCore::Identity &other, const QString &name = QString())
Creates a new identity with the given name, copying all values from an existing identity other the identity to copy values from name the name for the new identity (if empty, uses other's name) Returns a reference to the newly created identity
KIdentityManagementCore::Identity &IdentityManager::newFromScratch(const QString &name)
Creates a new identity with the given name from scratch name the name for the new identity Returns a reference to the newly created identity
bool IdentityManager::removeIdentity(const QString &identityName)
Removes the identity with name identityName Will return false if the identity is not found, or when one tries to remove the last identity. identityName the identity to remove Returns true if the identity was removed, false otherwise
bool IdentityManager::removeIdentityForced(const QString &identityName)
Removes the identity with name identityName Will return false if the identity is not found, true otherwise.
Note: In opposite to removeIdentity(), this method allows to remove the last remaining identity.
identityName the identity to remove Returns true if the identity was removed, false if not found
void IdentityManager::rollback()
Re-read the config from disk and forget changes
void IdentityManager::saveIdentity(const KIdentityManagementCore::Identity &ident)
Store a new identity or modify an existing identity based on an independent identity object ident the identity to be saved
[static] KIdentityManagementCore::IdentityManager *IdentityManager::self()
Creates or reuses the identity manager instance for this process. It loads the emailidentities file to create identities. This sets readonly to false, so you should create a separate instance if you need it to be readonly.
bool IdentityManager::setAsDefault(uint uoid)
Sets the identity with Unique Object Identifier (UOID) uoid to be the new default identity. As usual, use commit() to make this permanent.
uoid the default identity to set Returns false if an identity with UOID uoid was not found, true otherwise
QStringList IdentityManager::shadowIdentities() const
Convenience method. Returns the list of (shadow) identities, i.e. the ones currently under configuration. Returns a list of shadow identity names
[protected slot] void IdentityManager::slotRollback()
Discards all changes made to the identities since the last commit.
See also rollback().
void IdentityManager::sort()
Sort the identities by name (the default is always first). This operates on the shadow list, so you need to call commit() for the changes to take effect.
bool IdentityManager::thatIsMe(const QString &addressList) const
Returns true if addressList contains any of our addresses, false otherwise. addressList the addressList to examine Returns true if one of our addresses is found in the list
See also identityForAddress().