File indexing completed on 2024-05-12 04:38:18

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003     SPDX-FileCopyrightText: 2017 Friedrich W. H. Kossebau <kossebau@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KDEVPLATFORM_ENVIRONMENTPROFILELISTMODEL_H
0009 #define KDEVPLATFORM_ENVIRONMENTPROFILELISTMODEL_H
0010 
0011 #include <QAbstractItemModel>
0012 #include "util/environmentprofilelist.h"
0013 
0014 namespace KDevelop
0015 {
0016 
0017 // Subclassing EnvironmentProfileList instead of having as a member, to have access to protected API
0018 class EnvironmentProfileListModel : public QAbstractItemModel, protected EnvironmentProfileList
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit EnvironmentProfileListModel(QObject* parent = nullptr);
0024 
0025     int rowCount(const QModelIndex& parent = {}) const override;
0026     int columnCount(const QModelIndex& parent = {}) const override;
0027     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0028     QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
0029     QModelIndex parent(const QModelIndex& index) const override;
0030 
0031     int profileIndex(const QString& profileName) const;
0032     int defaultProfileIndex() const;
0033     QString profileName(int profileIndex) const;
0034     bool hasProfile(const QString& profileName) const;
0035     QMap<QString, QString>& variables(const QString& profileName);
0036 
0037     int addProfile(const QString& newProfileName);
0038     int cloneProfile(const QString& newProfileName, const QString& sourceProfileName);
0039     void removeProfile(int profileIndex);
0040     void setDefaultProfile(int profileIndex);
0041 
0042     void loadFromConfig(KConfig* config);
0043     void saveToConfig(KConfig* config);
0044 
0045 Q_SIGNALS:
0046     void profileAboutToBeRemoved(const QString& profileName);
0047     void defaultProfileChanged(int defaultProfileIndex);
0048 };
0049 
0050 }
0051 
0052 #endif