File: vcsjob.h

package info (click to toggle)
kdevelop 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 73,508 kB
  • sloc: cpp: 291,803; python: 4,322; javascript: 3,518; sh: 1,316; ansic: 703; xml: 414; php: 95; lisp: 66; makefile: 31; sed: 12
file content (137 lines) | stat: -rw-r--r-- 3,909 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
    SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
    SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef KDEVPLATFORM_VCSJOB_H
#define KDEVPLATFORM_VCSJOB_H

#include <outputview/outputjob.h>

#include "vcsexport.h"

class QVariant;

namespace KDevelop
{

class IPlugin;
class VcsJobPrivate;

/**
 * This class provides an extension of KJob to get various VCS-specific
 * information about the job. This includes the type, the state
 * and the results provided by the job.
 *
 */
class KDEVPLATFORMVCS_EXPORT VcsJob : public OutputJob
{
    Q_OBJECT
public:
    explicit VcsJob( QObject* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose);
    ~VcsJob() override;
    /**
     * To easily check which type of job this is.
     *
     * @todo Check how this can be extended via plugins, maybe use QFlag? (not
     * QFlags!)
     */
    enum JobType
    {
        Unknown = -1    /**< Unknown job type (default)*/,
        Add = 0         /**< An add job */,
        Remove = 1      /**< A remove job */,
        Copy = 2        /**< A copy job */,
        Move = 3        /**< A move job */,
        Diff = 4        /**< A diff job */,
        Commit = 5      /**< A commit job */,
        Update = 6      /**< An update job */,
        Merge = 7       /**< A merge job */,
        Resolve = 8     /**< A resolve job */,
        Import = 9      /**< An import job */,
        Checkout = 10   /**< A checkout job */,
        Log = 11        /**< A log job */,
        Push = 12       /**< A push job */,
        Pull = 13       /**< A pull job */,
        Annotate = 14   /**< An annotate job */,
        Clone = 15      /**< A clone job */,
        Status = 16     /**< A status job */,
        Revert = 17     /**< A revert job */,
        Cat = 18        /**< A cat job */,
        Reset = 19      /**< A reset job */,
        Apply = 20      /**< An apply job */,
        UserType = 1000 /**< A custom job */
    };

    /**
     * Simple enum to define how the job finished.
     */
    enum JobStatus
    {
        JobRunning = 0    /**< The job is running */,
        JobSucceeded = 1  /**< The job succeeded */,
        JobCanceled = 2   /**< The job was cancelled */,
        JobFailed = 3     /**< The job failed */,
        JobNotStarted = 4 /**< The job is not yet started */
    };

    /**
     * This method will return all new results of the job. The actual data
     * type that is wrapped in the QVariant depends on the type of job.
     *
     * @note Results returned by a previous call to fetchResults are not
     * returned.
     */
    virtual QVariant fetchResults() = 0;

    /**
     * Find out in which state the job is. It can be running, canceled,
     * failed or finished
     *
     * @return the status of the job
     * @see JobStatus
     */
    virtual JobStatus status() const = 0;

    /**
     * Used to find out about the type of job.
     *
     * @return the type of job
     */
    JobType type() const;

    /**
     * Used to get at the version control plugin. The plugin
     * can be used to get one of the interfaces to execute
     * more vcs actions, depending on this job's results
     * (like getting a diff for an entry in a log)
     */
    virtual KDevelop::IPlugin* vcsPlugin() const = 0;

    /**
     * This can be used to set the type of the vcs job in subclasses.
     */
    void setType( JobType );

Q_SIGNALS:
    /**
     * This signal is emitted when new results are available. Depending on
     * the plugin and the operation, it may be emitted only once when all
     * results are ready, or several times.
     */
    void resultsReady( KDevelop::VcsJob* );

private Q_SLOTS:
    void delayedModelInitialize();

private:
    const QScopedPointer<class VcsJobPrivate> d_ptr;
    Q_DECLARE_PRIVATE(VcsJob)
};

}

#endif