• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

outputview

outputjob.cpp

00001 /* This file is part of KDevelop
00002 Copyright 2007-2008 Hamish Rodda <rodda@kde.org>
00003 
00004 This library is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU Library General Public
00006 License as published by the Free Software Foundation; either
00007 version 2 of the License, or (at your option) any later version.
00008 
00009 This library is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 Library General Public License for more details.
00013 
00014 You should have received a copy of the GNU Library General Public License
00015 along with this library; see the file COPYING.LIB.  If not, write to
00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017 Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "outputjob.h"
00021 
00022 #include <QStandardItemModel>
00023 #include <QItemDelegate>
00024 
00025 #include "interfaces/icore.h"
00026 #include "interfaces/iplugincontroller.h"
00027 #include "outputview/ioutputview.h"
00028 
00029 using namespace KDevelop;
00030 
00031 OutputJob::OutputJob(QObject* parent)
00032     : KJob(parent)
00033     , m_standardToolView(-1)
00034     , m_type(IOutputView::OneView)
00035     , m_behaviours(IOutputView::AllowUserClose)
00036     , m_killJobOnOutputClose(true)
00037     , m_raiseOnCreation(true)
00038     , m_outputId(-1)
00039     , m_outputModel(0)
00040     , m_modelOwnership(IOutputView::KeepOwnership)
00041     , m_outputDelegate(0)
00042     , m_delegateOwnership(IOutputView::KeepOwnership)
00043 {
00044 }
00045 
00046 void OutputJob::startOutput()
00047 {
00048     IPlugin* i = ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IOutputView");
00049     if( i )
00050     {
00051         KDevelop::IOutputView* view = i->extension<KDevelop::IOutputView>();
00052         if( view )
00053         {
00054             int tvid;
00055             if (m_standardToolView != -1) {
00056                 tvid = view->standardToolView( static_cast<IOutputView::StandardToolView>(m_standardToolView) );
00057             } else {
00058                 tvid = view->registerToolView(m_toolTitle, m_type, m_toolIcon);
00059             }
00060 
00061             if (m_title.isEmpty())
00062                 m_title = objectName();
00063                 
00064             m_outputId = view->registerOutputInToolView( tvid, m_title, m_behaviours );
00065 
00066             if (!m_outputModel) {
00067                 m_outputModel = new QStandardItemModel(0);
00068                 m_modelOwnership = IOutputView::TakeOwnership;
00069             }
00070 
00071             // Keep the item model around after the job is gone
00072             view->setModel(m_outputId, m_outputModel, m_modelOwnership);
00073 
00074             if (!m_outputDelegate) {
00075                 m_outputDelegate = new QItemDelegate(0);
00076                 m_delegateOwnership = IOutputView::TakeOwnership;
00077             }
00078 
00079             view->setDelegate(m_outputId, m_outputDelegate, m_delegateOwnership);
00080 
00081             if (m_killJobOnOutputClose)
00082                 connect(i, SIGNAL(outputRemoved(int, int)), this, SLOT(outputViewRemoved(int, int)));
00083 
00084             if (m_raiseOnCreation)
00085                 view->raiseOutput(m_outputId);
00086         }
00087     }
00088 }
00089 
00090 void OutputJob::outputViewRemoved(int , int id)
00091 {
00092     if (id == m_outputId && m_killJobOnOutputClose)
00093         kill();
00094 }
00095 
00096 void KDevelop::OutputJob::setTitle(const QString & title)
00097 {
00098     m_title = title;
00099 }
00100 
00101 void KDevelop::OutputJob::setViewType(IOutputView::ViewType type)
00102 {
00103     m_type = type;
00104 }
00105 
00106 void KDevelop::OutputJob::setBehaviours(IOutputView::Behaviours behaviours)
00107 {
00108     m_behaviours = behaviours;
00109 }
00110 
00111 void KDevelop::OutputJob::setKillJobOnOutputClose(bool killJobOnOutputClose)
00112 {
00113     m_killJobOnOutputClose = killJobOnOutputClose;
00114 }
00115 
00116 void KDevelop::OutputJob::setModel(QAbstractItemModel * model, IOutputView::Ownership takeOwnership)
00117 {
00118     m_modelOwnership = takeOwnership;
00119     m_outputModel = model;
00120 }
00121 
00122 void KDevelop::OutputJob::setDelegate(QAbstractItemDelegate * delegate, IOutputView::Ownership takeOwnership)
00123 {
00124     m_delegateOwnership = takeOwnership;
00125     m_outputDelegate = delegate;
00126 }
00127 
00128 QAbstractItemModel * KDevelop::OutputJob::model() const
00129 {
00130     return m_outputModel;
00131 }
00132 
00133 void KDevelop::OutputJob::setStandardToolView(IOutputView::StandardToolView standard)
00134 {
00135     m_standardToolView = standard;
00136 }
00137 
00138 void KDevelop::OutputJob::setRaiseOnCreation(bool raise)
00139 {
00140     m_raiseOnCreation = raise;
00141 }
00142 
00143 void OutputJob::setToolTitle(const QString& title)
00144 {
00145     m_toolTitle = title;
00146 }
00147 
00148 void OutputJob::setToolIcon(const KIcon& icon)
00149 {   
00150     m_toolIcon = icon;
00151 }
00152 
00153 int OutputJob::outputId() const
00154 {
00155     return m_outputId;
00156 }
00157 
00158 #include "outputjob.moc"

outputview

Skip menu "outputview"
  • Main Page
  • Namespace List
  • File List
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  •     interfaces
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal