File indexing completed on 2024-10-06 13:17:45

0001 // SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QAbstractListModel>
0007 #include <QObject>
0008 
0009 class TerminalTabModel : public QAbstractListModel
0010 {
0011     Q_OBJECT
0012     
0013 public:
0014     TerminalTabModel(QObject *parent = nullptr);
0015     
0016     static TerminalTabModel *self()
0017     {
0018         static TerminalTabModel *singleton = new TerminalTabModel();
0019         return singleton;
0020     }
0021     
0022     enum {
0023         NameRole = Qt::DisplayRole
0024     };
0025 
0026     int rowCount(const QModelIndex &parent) const override;
0027     QVariant data(const QModelIndex &index, int role) const override;
0028     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0029     Qt::ItemFlags flags(const QModelIndex &index) const override;
0030     QHash<int, QByteArray> roleNames() const override;
0031 
0032     Q_INVOKABLE void newTab();
0033     Q_INVOKABLE void removeTab(int index);
0034 
0035 private:
0036     int m_indexCounter;
0037     QList<QString> m_tabNames;
0038 };