File indexing completed on 2024-04-28 04:37:01
0001 /* 0002 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0003 SPDX-FileCopyrightText: 2012 Morten Danielsen Volden <mvolden2@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_OUTPUTMODEL_H 0009 #define KDEVPLATFORM_OUTPUTMODEL_H 0010 0011 #include "outputviewexport.h" 0012 #include "ioutputviewmodel.h" 0013 #include "ifilterstrategy.h" 0014 0015 #include <QAbstractListModel> 0016 0017 class QUrl; 0018 0019 namespace KDevelop 0020 { 0021 class OutputModelPrivate; 0022 0023 class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputModel : public QAbstractListModel, public KDevelop::IOutputViewModel 0024 { 0025 Q_OBJECT 0026 Q_INTERFACES(KDevelop::IOutputViewModel) 0027 0028 public: 0029 0030 enum CustomRoles { 0031 OutputItemTypeRole = Qt::UserRole + 1 0032 }; 0033 0034 enum OutputFilterStrategy 0035 { 0036 NoFilter, 0037 CompilerFilter, 0038 ScriptErrorFilter, 0039 NativeAppErrorFilter, 0040 StaticAnalysisFilter 0041 }; 0042 Q_ENUM(OutputFilterStrategy) 0043 0044 explicit OutputModel( const QUrl& builddir , QObject* parent = nullptr ); 0045 explicit OutputModel( QObject* parent = nullptr ); 0046 ~OutputModel() override; 0047 0048 /// IOutputViewModel interfaces 0049 void activate( const QModelIndex& index ) override; 0050 QModelIndex firstHighlightIndex() override; 0051 QModelIndex nextHighlightIndex( const QModelIndex ¤t ) override; 0052 QModelIndex previousHighlightIndex( const QModelIndex ¤t ) override; 0053 QModelIndex lastHighlightIndex() override; 0054 0055 /// QAbstractItemModel interfaces 0056 QVariant data( const QModelIndex&, int = Qt::DisplayRole ) const override; 0057 int rowCount( const QModelIndex& = QModelIndex() ) const override; 0058 QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const override; 0059 0060 void setFilteringStrategy(const OutputFilterStrategy& currentStrategy); 0061 void setFilteringStrategy(IFilterStrategy* filterStrategy); 0062 0063 public Q_SLOTS: 0064 void appendLine( const QString& ); 0065 void appendLines( const QStringList& ); 0066 void ensureAllDone(); 0067 void clear(); 0068 0069 Q_SIGNALS: 0070 /// If the current filter strategy supports it, reports progress information 0071 void progress(const KDevelop::IFilterStrategy::Progress& progress); 0072 void allDone(); 0073 0074 private: 0075 const QScopedPointer<class OutputModelPrivate> d_ptr; 0076 Q_DECLARE_PRIVATE(OutputModel) 0077 friend class OutputModelPrivate; 0078 }; 0079 0080 } 0081 0082 #endif