File indexing completed on 2024-04-28 05:50:45

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PROFILE_MODEL_H
0008 #define PROFILE_MODEL_H
0009 
0010 #include "konsoleprivate_export.h"
0011 
0012 #include <QAbstractTableModel>
0013 #include <QExplicitlySharedDataPointer>
0014 #include <QList>
0015 
0016 namespace Konsole
0017 {
0018 class Profile;
0019 
0020 class KONSOLEPRIVATE_EXPORT ProfileModel : public QAbstractTableModel
0021 {
0022     Q_OBJECT
0023 public:
0024     static ProfileModel *instance();
0025 
0026     enum Roles {
0027         ProfilePtrRole = Qt::UserRole + 1,
0028     };
0029 
0030     enum Column {
0031         NAME,
0032         SHORTCUT,
0033         PROFILE,
0034         COLUMNS,
0035     };
0036 
0037     void populate();
0038     void add(QExplicitlySharedDataPointer<Profile> profile);
0039     void remove(QExplicitlySharedDataPointer<Profile> profile);
0040     void update(QExplicitlySharedDataPointer<Profile> profile);
0041     void setDefault(QExplicitlySharedDataPointer<Profile> profile);
0042 
0043     int rowCount(const QModelIndex &parent) const override;
0044     int columnCount(const QModelIndex &parent) const override;
0045     QVariant data(const QModelIndex &idx, int role) const override;
0046     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0047     Qt::ItemFlags flags(const QModelIndex &index) const override;
0048     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0049 
0050 private:
0051     QList<QExplicitlySharedDataPointer<Profile>> m_profiles;
0052     ProfileModel();
0053 };
0054 
0055 }
0056 
0057 #endif