Pimcommon

templatelistwidget.h
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "pimcommon_export.h"
10#include <QListWidget>
11
12namespace PimCommon
13{
14class TemplateListWidgetPrivate;
15
16struct defaultTemplate {
17 QString name;
18 QString text;
19};
20
21/**
22 * @brief The TemplateListWidget class
23 * @author Laurent Montel <montel@kde.org>
24 */
25class PIMCOMMON_EXPORT TemplateListWidget : public QListWidget
26{
27 Q_OBJECT
28public:
29 explicit TemplateListWidget(const QString &configName, QWidget *parent = nullptr);
30 ~TemplateListWidget() override;
31
32 // Need to load template in specific class to allow to use correct defaultTemplates function
33 void loadTemplates();
34
35 [[nodiscard]] virtual QList<PimCommon::defaultTemplate> defaultTemplates();
36 [[nodiscard]] virtual bool addNewTemplate(QString &templateName, QString &templateScript);
37 [[nodiscard]] virtual bool modifyTemplate(QString &templateName, QString &templateScript, bool defaultTemplate);
38
39 void setKNewStuffConfigFile(const QString &configName);
40
41 void addDefaultTemplate(const QString &templateName, const QString &templateScript);
42
43protected:
44 [[nodiscard]] QStringList mimeTypes() const override;
45 [[nodiscard]] QMimeData *mimeData(const QList<QListWidgetItem *> &items) const override;
46 void dropEvent(QDropEvent *event) override;
47 enum TemplateData {
48 Text = Qt::UserRole + 1,
49 DefaultTemplate = Qt::UserRole + 2,
50 };
51
52Q_SIGNALS:
53 void insertTemplate(const QString &);
54 void insertNewTemplate(const QString &);
55
56private:
57 friend class TemplateListWidgetPrivate;
58 std::unique_ptr<TemplateListWidgetPrivate> const d;
59};
60}
61Q_DECLARE_TYPEINFO(PimCommon::defaultTemplate, Q_RELOCATABLE_TYPE);
The TemplateListWidget class.
folderdialogacltab.h
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.