File indexing completed on 2024-12-08 07:55:46
0001 // SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include <QAbstractListModel> 0007 0008 class SavedCommandsModel : public QAbstractListModel 0009 { 0010 Q_OBJECT 0011 0012 public: 0013 explicit SavedCommandsModel(QObject *parent = nullptr); 0014 ~SavedCommandsModel() override; 0015 0016 static SavedCommandsModel *self() 0017 { 0018 static SavedCommandsModel *singleton = new SavedCommandsModel(); 0019 return singleton; 0020 }; 0021 0022 int rowCount(const QModelIndex &parent) const override 0023 { 0024 return parent.isValid() ? 0 : m_actions.size(); 0025 }; 0026 0027 QVariant data(const QModelIndex &index, int role) const override; 0028 void save(); 0029 0030 Q_INVOKABLE void addAction(const QString &action); 0031 Q_INVOKABLE bool removeRow(int row); 0032 0033 private: 0034 QStringList m_actions; 0035 };