File indexing completed on 2024-05-19 05:54:12
0001 // This file was part of the KDE libraries 0002 // SPDX-FileCopyrightText: 2022 Tao Guo <guotao945@gmail.com> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #ifndef QUICKCOMMANDSMODEL_H 0006 #define QUICKCOMMANDSMODEL_H 0007 0008 #include <QStandardItemModel> 0009 0010 class QuickCommandData; 0011 0012 class QuickCommandsModel : public QStandardItemModel 0013 { 0014 Q_OBJECT 0015 public: 0016 enum Roles { QuickCommandRole = Qt::UserRole + 1 }; 0017 explicit QuickCommandsModel(QObject *parent = nullptr); 0018 ~QuickCommandsModel() override; 0019 0020 QStringList groups() const; 0021 bool addChildItem(const QuickCommandData &data, const QString &groupName); 0022 bool editChildItem(const QuickCommandData &data, const QModelIndex &idx, const QString &groupName); 0023 0024 private: 0025 void load(); 0026 void save(); 0027 void updateItem(QStandardItem *item, const QuickCommandData &data); 0028 QStandardItem *addTopLevelItem(const QString &groupName); 0029 }; 0030 0031 #endif // QUICKCOMMANDSMODEL_H