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
|
/*
This file is part of Akregator.
SPDX-FileCopyrightText: 2008 Frank Osterfeld <osterfeld@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
*/
#include "command.h"
#include <QEventLoop>
#include <QPointer>
#include <QWidget>
using namespace Akregator;
class Akregator::CommandPrivate
{
public:
CommandPrivate();
QPointer<QWidget> parentWidget;
};
CommandPrivate::CommandPrivate()
: parentWidget()
{
}
Command::Command(QObject *parent)
: QObject(parent)
, d(new CommandPrivate)
{
}
Command::~Command() = default;
QWidget *Command::parentWidget() const
{
return d->parentWidget;
}
void Command::setParentWidget(QWidget *parentWidget)
{
d->parentWidget = parentWidget;
}
void Command::start()
{
doStart();
Q_EMIT started();
}
void Command::abort()
{
doAbort();
}
void Command::done()
{
Q_EMIT finished();
deleteLater();
}
void Command::waitForFinished()
{
QEventLoop loop;
connect(this, &Command::finished, &loop, &QEventLoop::quit);
loop.exec();
}
#include "moc_command.cpp"
|