File indexing completed on 2024-05-05 05:12:58

0001 /*
0002     This file is part of Akregator.
0003 
0004     SPDX-FileCopyrightText: 2008 Frank Osterfeld <osterfeld@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 
0009 #include "command.h"
0010 
0011 #include <QEventLoop>
0012 #include <QPointer>
0013 #include <QWidget>
0014 
0015 using namespace Akregator;
0016 
0017 class Akregator::CommandPrivate
0018 {
0019 public:
0020     CommandPrivate();
0021     QPointer<QWidget> parentWidget;
0022 };
0023 
0024 CommandPrivate::CommandPrivate()
0025     : parentWidget()
0026 {
0027 }
0028 
0029 Command::Command(QObject *parent)
0030     : QObject(parent)
0031     , d(new CommandPrivate)
0032 {
0033 }
0034 
0035 Command::~Command() = default;
0036 
0037 QWidget *Command::parentWidget() const
0038 {
0039     return d->parentWidget;
0040 }
0041 
0042 void Command::setParentWidget(QWidget *parentWidget)
0043 {
0044     d->parentWidget = parentWidget;
0045 }
0046 
0047 void Command::start()
0048 {
0049     doStart();
0050     Q_EMIT started();
0051 }
0052 
0053 void Command::abort()
0054 {
0055     doAbort();
0056 }
0057 
0058 void Command::done()
0059 {
0060     Q_EMIT finished();
0061     deleteLater();
0062 }
0063 
0064 void Command::waitForFinished()
0065 {
0066     QEventLoop loop;
0067     connect(this, &Command::finished, &loop, &QEventLoop::quit);
0068     loop.exec();
0069 }
0070 
0071 #include "moc_command.cpp"