calamares/src/libcalamares/Job.h

73 lines
1.9 KiB
C
Raw Normal View History

2014-06-27 15:34:05 +02:00
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
2015-04-09 15:03:47 +02:00
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
2014-06-27 15:34:05 +02:00
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CALAMARES_JOB_H
#define CALAMARES_JOB_H
#include "DllMacro.h"
#include "Typedefs.h"
2014-06-27 15:34:05 +02:00
#include <QObject>
namespace Calamares {
2014-07-08 19:20:04 +02:00
class DLLEXPORT JobResult
{
public:
virtual ~JobResult() {}
2014-07-08 19:20:04 +02:00
virtual operator bool() const;
2014-07-08 19:20:04 +02:00
virtual QString message() const;
virtual void setMessage( const QString& message );
virtual QString details() const;
virtual void setDetails( const QString& details );
2014-07-08 19:20:04 +02:00
2014-07-09 19:08:53 +02:00
static JobResult ok();
2014-07-08 19:20:04 +02:00
2014-07-09 19:08:53 +02:00
static JobResult error( const QString& message, const QString& details = QString() );
2014-07-08 19:20:04 +02:00
protected:
explicit JobResult( bool ok, const QString& message, const QString& details );
2014-07-08 19:20:04 +02:00
private:
bool m_ok;
QString m_message;
QString m_details;
};
2014-06-27 15:34:05 +02:00
class DLLEXPORT Job : public QObject
{
Q_OBJECT
public:
explicit Job( QObject* parent = nullptr );
virtual ~Job();
2014-07-10 12:06:23 +02:00
virtual QString prettyName() const = 0;
2015-04-09 15:03:47 +02:00
virtual QString prettyDescription() const;
virtual QString prettyStatusMessage() const;
2014-07-08 19:20:04 +02:00
virtual JobResult exec() = 0;
signals:
2014-07-23 12:04:27 +02:00
void progress( qreal percent );
2014-06-27 15:34:05 +02:00
};
} // namespace Calamares
#endif // CALAMARES_JOB_H