File indexing completed on 2024-05-12 13:29:44
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 SavedCommandsModel(QObject *parent = nullptr); 0014 virtual ~SavedCommandsModel(); 0015 0016 static SavedCommandsModel* self(){ 0017 static SavedCommandsModel *singleton = new SavedCommandsModel(); 0018 return singleton; 0019 }; 0020 0021 int rowCount(const QModelIndex &parent) const override 0022 { 0023 return parent.isValid() ? 0 : m_actions.size(); 0024 }; 0025 0026 QVariant data(const QModelIndex &index, int role) const override; 0027 void save(); 0028 0029 Q_INVOKABLE void addAction(QString action); 0030 Q_INVOKABLE bool removeRow(int row); 0031 0032 private: 0033 QStringList m_actions; 0034 };