File indexing completed on 2024-05-05 04:40:57

0001 /*
0002     SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "toolviewdata.h"
0008 
0009 #include <QAbstractItemModel>
0010 #include <QAbstractItemDelegate>
0011 
0012 
0013 OutputData::OutputData( ToolViewData* tv )
0014 : QObject( tv )
0015 , delegate(nullptr)
0016 , model(nullptr)
0017 , toolView(tv)
0018 , id(-1)
0019 {
0020 }
0021 
0022 void OutputData::setModel( QAbstractItemModel* model_ )
0023 {
0024     model = model_;
0025 
0026     if (model) {
0027         model->setParent(this);
0028     }
0029 
0030     emit modelChanged( id );
0031 }
0032 
0033 void OutputData::setDelegate( QAbstractItemDelegate* del )
0034 {
0035     delegate = del;
0036 
0037     if (delegate) {
0038         delegate->setParent(this);
0039     }
0040 
0041     emit delegateChanged( id );
0042 }
0043 
0044 ToolViewData::ToolViewData( QObject* parent )
0045     : QObject( parent ), plugin(nullptr), toolViewId(-1)
0046 {
0047 }
0048 
0049 ToolViewData::~ToolViewData()
0050 {
0051 }
0052 
0053 OutputData* ToolViewData::addOutput( int id, const QString& title,
0054                                      KDevelop::IOutputView::Behaviours behave )
0055 {
0056     auto* d = new OutputData( this );
0057     d->id = id;
0058     d->title = title;
0059     d->behaviour = behave;
0060     d->toolView = this;
0061     outputdata.insert( id, d );
0062     emit outputAdded( id );
0063     return d;
0064 }
0065 
0066 #include "moc_toolviewdata.cpp"