Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / outputview / outputjob.cpp
blobf5c836a6b9130f6fa71651f0f93e70b6f88ee686
1 /* This file is part of KDevelop
2 Copyright 2007-2008 Hamish Rodda <rodda@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "outputjob.h"
22 #include <QStandardItemModel>
23 #include <QItemDelegate>
25 #include "interfaces/icore.h"
26 #include "interfaces/iplugincontroller.h"
27 #include "outputview/ioutputview.h"
29 using namespace KDevelop;
31 OutputJob::OutputJob(QObject* parent)
32 : KJob(parent)
33 , m_standardToolView(-1)
34 , m_type(IOutputView::OneView)
35 , m_behaviours(IOutputView::AllowUserClose)
36 , m_killJobOnOutputClose(true)
37 , m_raiseOnCreation(true)
38 , m_outputId(-1)
39 , m_outputModel(0)
40 , m_modelOwnership(IOutputView::KeepOwnership)
41 , m_outputDelegate(0)
42 , m_delegateOwnership(IOutputView::KeepOwnership)
46 void OutputJob::startOutput()
48 IPlugin* i = ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IOutputView");
49 if( i )
51 KDevelop::IOutputView* view = i->extension<KDevelop::IOutputView>();
52 if( view )
54 int tvid;
55 if (m_standardToolView != -1) {
56 tvid = view->standardToolView( static_cast<IOutputView::StandardToolView>(m_standardToolView) );
57 } else {
58 tvid = view->registerToolView(m_toolTitle, m_type, m_toolIcon);
61 if (m_title.isEmpty())
62 m_title = objectName();
64 m_outputId = view->registerOutputInToolView( tvid, m_title, m_behaviours );
66 if (!m_outputModel) {
67 m_outputModel = new QStandardItemModel(0);
68 m_modelOwnership = IOutputView::TakeOwnership;
71 // Keep the item model around after the job is gone
72 view->setModel(m_outputId, m_outputModel, m_modelOwnership);
74 if (!m_outputDelegate) {
75 m_outputDelegate = new QItemDelegate(0);
76 m_delegateOwnership = IOutputView::TakeOwnership;
79 view->setDelegate(m_outputId, m_outputDelegate, m_delegateOwnership);
81 if (m_killJobOnOutputClose)
82 connect(i, SIGNAL(outputRemoved(int, int)), this, SLOT(outputViewRemoved(int, int)));
84 if (m_raiseOnCreation)
85 view->raiseOutput(m_outputId);
90 void OutputJob::outputViewRemoved(int , int id)
92 if (id == m_outputId && m_killJobOnOutputClose)
93 kill();
96 void KDevelop::OutputJob::setTitle(const QString & title)
98 m_title = title;
101 void KDevelop::OutputJob::setViewType(IOutputView::ViewType type)
103 m_type = type;
106 void KDevelop::OutputJob::setBehaviours(IOutputView::Behaviours behaviours)
108 m_behaviours = behaviours;
111 void KDevelop::OutputJob::setKillJobOnOutputClose(bool killJobOnOutputClose)
113 m_killJobOnOutputClose = killJobOnOutputClose;
116 void KDevelop::OutputJob::setModel(QAbstractItemModel * model, IOutputView::Ownership takeOwnership)
118 m_modelOwnership = takeOwnership;
119 m_outputModel = model;
122 void KDevelop::OutputJob::setDelegate(QAbstractItemDelegate * delegate, IOutputView::Ownership takeOwnership)
124 m_delegateOwnership = takeOwnership;
125 m_outputDelegate = delegate;
128 QAbstractItemModel * KDevelop::OutputJob::model() const
130 return m_outputModel;
133 void KDevelop::OutputJob::setStandardToolView(IOutputView::StandardToolView standard)
135 m_standardToolView = standard;
138 void KDevelop::OutputJob::setRaiseOnCreation(bool raise)
140 m_raiseOnCreation = raise;
143 void OutputJob::setToolTitle(const QString& title)
145 m_toolTitle = title;
148 void OutputJob::setToolIcon(const KIcon& icon)
150 m_toolIcon = icon;
153 int OutputJob::outputId() const
155 return m_outputId;
158 #include "outputjob.moc"