outputmodel.h 3.61 KB
Newer Older
1
/***************************************************************************
2
 *   This file is part of KDevelop                                         *
3
4
 *   Copyright 2007 Andreas Pakulat <apaku@gmx.de>                         *
 *   Copyright (C) 2012  Morten Danielsen Volden mvolden2@gmail.com        *
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

22
23
#ifndef KDEVPLATFORM_OUTPUTMODEL_H
#define KDEVPLATFORM_OUTPUTMODEL_H
24

25
#include "outputviewexport.h"
26
#include "ioutputviewmodel.h"
27
#include "ifilterstrategy.h"
28

29
#include <QAbstractListModel>
30

31
class QUrl;
32

33
namespace KDevelop
34
{
35
class OutputModelPrivate;
36

37
class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputModel : public QAbstractListModel, public KDevelop::IOutputViewModel
38
{
39
    Q_OBJECT
40
41
    Q_INTERFACES(KDevelop::IOutputViewModel)

42
43
public:

44
45
46
    enum CustomRoles {
        OutputItemTypeRole = Qt::UserRole + 1
    };
47

48
49
50
51
    enum OutputFilterStrategy
    {
        NoFilter,
        CompilerFilter,
52
        ScriptErrorFilter,
53
        NativeAppErrorFilter,
54
        StaticAnalysisFilter
55
56
    };

57
58
    explicit OutputModel( const QUrl& builddir , QObject* parent = nullptr );
    explicit OutputModel( QObject* parent = nullptr );
59
    ~OutputModel() override;
60
61

    /// IOutputViewModel interfaces
Kevin Funk's avatar
Kevin Funk committed
62
    void activate( const QModelIndex& index ) override;
63
    QModelIndex firstHighlightIndex() override;
Kevin Funk's avatar
Kevin Funk committed
64
65
    QModelIndex nextHighlightIndex( const QModelIndex &current ) override;
    QModelIndex previousHighlightIndex( const QModelIndex &current ) override;
66
    QModelIndex lastHighlightIndex() override;
67
68

    /// QAbstractItemModel interfaces
Kevin Funk's avatar
Kevin Funk committed
69
70
71
    QVariant data( const QModelIndex&, int = Qt::DisplayRole ) const override;
    int rowCount( const QModelIndex& = QModelIndex() ) const override;
    QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const override;
72

73
    void setFilteringStrategy(const OutputFilterStrategy& currentStrategy);
74
    void setFilteringStrategy(IFilterStrategy* filterStrategy);
75

76
77
78
public Q_SLOTS:
    void appendLine( const QString& );
    void appendLines( const QStringList& );
79
    void ensureAllDone();
80
    void clear();
81

82
Q_SIGNALS:
83
84
    /// If the current filter strategy supports it, reports progress information
    void progress(const KDevelop::IFilterStrategy::Progress& progress);
85
    void allDone();
86
87

private:
88
89
    const QScopedPointer<class OutputModelPrivate> d_ptr;
    Q_DECLARE_PRIVATE(OutputModel)
90
    friend class OutputModelPrivate;
91
};
92

93
}
94
95
96

Q_DECLARE_METATYPE( KDevelop::OutputModel::OutputFilterStrategy )

97
#endif
98