VcsCommand: Simplify ProgressParser

Get rid of abstract base ProgressParser and replace
it with ProgressParser function. The only one former
subclass GitProgressParser is now functor object.
Pass future interface directly to the ProgressParser
function, along with input text to be parsed.

Change-Id: Icbcf0b6e55097f8b38eb8a32ceaa4414723116d0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-10-07 16:16:35 +02:00
parent 8eb4d52342
commit 93dfa93b7d
3 changed files with 16 additions and 75 deletions

View File

@@ -12,7 +12,6 @@
#include <QObject>
QT_BEGIN_NAMESPACE
class QMutex;
class QVariant;
template <typename T>
class QFuture;
@@ -31,23 +30,7 @@ namespace VcsBase {
namespace Internal { class VcsCommandPrivate; }
class VCSBASE_EXPORT ProgressParser
{
public:
ProgressParser();
virtual ~ProgressParser();
protected:
virtual void parseProgress(const QString &text) = 0;
void setProgressAndMaximum(int value, int maximum);
private:
void setFuture(QFutureInterface<void> *future);
QFutureInterface<void> *m_future;
QMutex *m_futureMutex = nullptr;
friend class Internal::VcsCommandPrivate;
};
using ProgressParser = std::function<void(QFutureInterface<void> &, const QString &)>;
class VCSBASE_EXPORT CommandResult
{
@@ -96,7 +79,7 @@ public:
void setCodec(QTextCodec *codec);
void setProgressParser(ProgressParser *parser);
void setProgressParser(const ProgressParser &parser);
static CommandResult runBlocking(const Utils::FilePath &workingDirectory,
const Utils::Environment &environmentconst,