MailCommon::SnippetsModel Class
class MailCommon::SnippetsModelThe SnippetsModel class. More...
| Header: | #include <MailCommon/SnippetsModel> |
| CMake: | find_package(KPim6MailCommon REQUIRED)target_link_libraries(mytarget PRIVATE KPim6::MailCommon) |
| Inherits: | QAbstractItemModel |
Public Functions
| SnippetsModel(QObject *parent = nullptr) | |
| virtual | ~SnippetsModel() override |
| void | load(const QString &filename = QString()) |
| void | save(const QString &filename = QString()) |
| QMap<QString, QString> | savedVariables() const |
| void | setSavedVariables(const QMap<QString, QString> &savedVariables) |
| QList<MailCommon::SnippetsInfo> | snippetsInfo() const |
Reimplemented Public Functions
| virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override |
| virtual QVariant | data(const QModelIndex &index, int role) const override |
| virtual bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
| virtual Qt::ItemFlags | flags(const QModelIndex &index) const override |
| virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override |
| virtual QMimeData * | mimeData(const QModelIndexList &indexes) const override |
| virtual QStringList | mimeTypes() const override |
| virtual QModelIndex | parent(const QModelIndex &index) const override |
| virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
| virtual bool | setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override |
| virtual Qt::DropActions | supportedDropActions() const override |
Signals
| void | addNewDndSnippset(const QString &text) |
| void | dndDone() |
| void | updateActionCollection(const QString &oldName, const QString &newName, const QKeySequence &keySequence, const QString &text, const QString &subject, const QString &to, const QString &cc, const QString &bcc, const QString &attachment) |
Static Public Members
| MailCommon::SnippetsModel * | instance() |
Reimplemented Protected Functions
| virtual bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
| virtual bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
Detailed Description
Author: Laurent Montel <montel@kde.org>
Member Function Documentation
[explicit] SnippetsModel::SnippetsModel(QObject *parent = nullptr)
Constructs a snippets model.
parent The parent object
[override virtual noexcept] SnippetsModel::~SnippetsModel()
Destroys the snippets model.
[signal] void SnippetsModel::addNewDndSnippset(const QString &text)
Emitted when a new snippet has been added via drag-and-drop.
text The text of the new snippet
[override virtual] int SnippetsModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::columnCount(const QModelIndex &parent) const.
Returns the number of columns in the model.
parent The parent model index Returns The column count
[override virtual] QVariant SnippetsModel::data(const QModelIndex &index, int role) const
Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.
Returns data for the given model index and role.
index The model index to retrieve data for role The model role Returns The data at the given index and role
See also setData().
[signal] void SnippetsModel::dndDone()
Emitted when a drag-and-drop operation has completed.
[override virtual] bool SnippetsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplements: QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).
Handles dropping of MIME data onto the model.
data The MIME data being dropped action The drop action row The destination row column The destination column parent The parent model index Returns True if the drop was successful, false otherwise
[override virtual] Qt::ItemFlags SnippetsModel::flags(const QModelIndex &index) const
Reimplements: QAbstractItemModel::flags(const QModelIndex &index) const.
Returns the item flags for the given index.
index The model index Returns The item flags
[override virtual] QModelIndex SnippetsModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::index(int row, int column, const QModelIndex &parent) const.
Returns the model index for the given row, column, and parent.
row The row number column The column number parent The parent model index Returns The model index
[override virtual protected] bool SnippetsModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplements: QAbstractItemModel::insertRows(int row, int count, const QModelIndex &parent).
Inserts new rows into the model.
row The row to insert at count The number of rows to insert parent The parent model index Returns True if the rows were successfully inserted, false otherwise
[static] MailCommon::SnippetsModel *SnippetsModel::instance()
Returns the singleton instance of the snippets model.
Returns A pointer to the SnippetsModel instance
void SnippetsModel::load(const QString &filename = QString())
Loads snippets from a file.
filename The filename to load from. If empty, uses the default location.
[override virtual] QMimeData *SnippetsModel::mimeData(const QModelIndexList &indexes) const
Reimplements: QAbstractItemModel::mimeData(const QModelIndexList &indexes) const.
Returns MIME data for the given indexes.
indexes The model indexes to encode Returns A pointer to the MIME data object
[override virtual] QStringList SnippetsModel::mimeTypes() const
Reimplements: QAbstractItemModel::mimeTypes() const.
Returns the list of supported MIME types.
Returns A string list of MIME types
[override virtual] QModelIndex SnippetsModel::parent(const QModelIndex &index) const
Reimplements: QAbstractItemModel::parent(const QModelIndex &index) const.
Returns the parent model index for the given index.
index The model index Returns The parent model index
[override virtual protected] bool SnippetsModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplements: QAbstractItemModel::removeRows(int row, int count, const QModelIndex &parent).
Removes rows from the model.
row The row to remove count The number of rows to remove parent The parent model index Returns True if the rows were successfully removed, false otherwise
[override virtual] int SnippetsModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplements: QAbstractItemModel::rowCount(const QModelIndex &parent) const.
Returns the number of rows in the model.
parent The parent model index Returns The row count
void SnippetsModel::save(const QString &filename = QString())
Saves the snippets to a file.
filename The filename to save to. If empty, uses the default location.
QMap<QString, QString> SnippetsModel::savedVariables() const
Returns the saved variables map.
Returns A map of variable names to values
See also setSavedVariables().
[override virtual] bool SnippetsModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
Reimplements: QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value, int role).
Sets data for the given model index and role.
index The model index to set data for value The value to set role The model role Returns True if the data was successfully set, false otherwise
See also data().
void SnippetsModel::setSavedVariables(const QMap<QString, QString> &savedVariables)
Sets the saved variables map.
savedVariables The map of variable names to values
See also savedVariables().
QList<MailCommon::SnippetsInfo> SnippetsModel::snippetsInfo() const
Returns information about all snippets in the model.
Returns A list of SnippetsInfo objects
[override virtual] Qt::DropActions SnippetsModel::supportedDropActions() const
Reimplements: QAbstractItemModel::supportedDropActions() const.
Returns the drop actions supported by the model.
Returns A combination of Qt::DropAction flags
[signal] void SnippetsModel::updateActionCollection(const QString &oldName, const QString &newName, const QKeySequence &keySequence, const QString &text, const QString &subject, const QString &to, const QString &cc, const QString &bcc, const QString &attachment)
Emitted when an action collection needs to be updated for a snippet.
oldName The old snippet name newName The new snippet name keySequence The keyboard shortcut text The snippet text subject The email subject to The To email address cc The CC email addresses bcc The BCC email addresses attachment The attachment path