File indexing completed on 2024-05-05 04:38:04

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Hamish Rodda <rodda@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_OUTPUTJOB_H
0008 #define KDEVPLATFORM_OUTPUTJOB_H
0009 
0010 #include <outputview/ioutputview.h>
0011 #include <outputview/outputviewexport.h>
0012 
0013 #include <KJob>
0014 
0015 class QIcon;
0016 
0017 namespace KDevelop
0018 {
0019 class OutputJobPrivate;
0020 
0021 class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputJob : public KJob
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     enum
0027     {
0028         FailedShownError = UserDefinedError + 100 //job failed and failure is shown in OutputView
0029     };
0030     enum OutputJobVerbosity { Silent, Verbose };
0031 
0032     explicit OutputJob(QObject* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose);
0033     ~OutputJob() override;
0034 
0035     void startOutput();
0036 
0037     OutputJobVerbosity verbosity() const;
0038 
0039     void setVerbosity(OutputJobVerbosity verbosity);
0040 
0041     QAbstractItemModel* model() const;
0042 
0043     /// Set the \a title for this job's output tab.  If not set, will default to the job's objectName().
0044     void setTitle(const QString& title);
0045 
0046 protected:
0047     /// NOTE: if a standard tool view is not set, a new unshared and unconfigurable tool view is created for the job.
0048     void setStandardToolView(IOutputView::StandardToolView standard);
0049     void setToolTitle(const QString& title);
0050     void setToolIcon(const QIcon& icon);
0051     void setViewType(IOutputView::ViewType type);
0052     void setBehaviours(IOutputView::Behaviours behaviours);
0053     void setKillJobOnOutputClose(bool killJobOnOutputClose);
0054 
0055     /**
0056      * Sets the model for the view that shows this jobs output.
0057      *
0058      * The view takes ownership of the model, but it is safe to
0059      * use the model while the job is running.
0060      *
0061      * NOTE: Do not reuse the same model for different jobs.
0062      */
0063     void setModel(QAbstractItemModel* model);
0064 
0065     /**
0066      * Sets the delegate for the view that shows this jobs output.
0067      *
0068      * The view takes ownership of the delegate, but it is safe to
0069      * use the delegate while the job is running.
0070      *
0071      * NOTE: Do not reuse the same delegate for different jobs.
0072      */
0073     void setDelegate(QAbstractItemDelegate* delegate);
0074 
0075     int outputId() const;
0076 
0077 private Q_SLOTS:
0078     void outputViewRemoved(int , int id);
0079 
0080 private:
0081     const QScopedPointer<class OutputJobPrivate> d_ptr;
0082     Q_DECLARE_PRIVATE(OutputJob)
0083 };
0084 
0085 }
0086 
0087 #endif