File indexing completed on 2024-05-12 04:39:40
0001 /* 0002 SPDX-FileCopyrightText: 2010 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later 0005 */ 0006 0007 #ifndef PROJECTPATHSMODEL_H 0008 #define PROJECTPATHSMODEL_H 0009 0010 #include <QAbstractListModel> 0011 #include <QVector> 0012 #include <QUrl> 0013 0014 #include "../compilerprovider/settingsmanager.h" 0015 0016 namespace KDevelop 0017 { 0018 class IProject; 0019 } 0020 0021 class ProjectPathsModel : public QAbstractListModel 0022 { 0023 Q_OBJECT 0024 public: 0025 enum SpecialRoles { 0026 IncludesDataRole = Qt::UserRole + 1, 0027 DefinesDataRole = Qt::UserRole + 2, 0028 FullUrlDataRole = Qt::UserRole + 3, 0029 CompilerDataRole = Qt::UserRole + 4, 0030 ParserArgumentsRole = Qt::UserRole + 5 0031 }; 0032 explicit ProjectPathsModel( QObject* parent = nullptr ); 0033 void setProject( KDevelop::IProject* w_project ); 0034 void setPaths( const QVector< ConfigEntry >& paths ); 0035 void addPath( const QUrl &url ); 0036 QVector<ConfigEntry> paths() const; 0037 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 0038 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 0039 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; 0040 Qt::ItemFlags flags(const QModelIndex& index) const override; 0041 bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ) override; 0042 private: 0043 QVector<ConfigEntry> projectPaths; 0044 KDevelop::IProject* project = nullptr; 0045 0046 void addPathInternal( const ConfigEntry& config, bool prepend ); 0047 QString sanitizePath( const QString& path, bool expectRelative = true, bool needRelative = true ) const; 0048 QString sanitizeUrl( const QUrl& url, bool needRelative = true ) const; 0049 }; 0050 0051 #endif // PROJECTPATHSMODEL_H