Added Typedefs.h and Job/JobQueue interfaces.

This commit is contained in:
Teo Mrnjavac 2014-06-27 16:21:45 +02:00
parent 1d0dfa5215
commit f1da3373a8
5 changed files with 71 additions and 0 deletions

View File

@ -26,4 +26,7 @@ Job::Job( QObject* parent )
{
}
Job::~Job()
{}
} // namespace Calamares

View File

@ -20,6 +20,7 @@
#define CALAMARES_JOB_H
#include "DllMacro.h"
#include "Typedefs.h"
#include <QObject>
@ -29,7 +30,21 @@ class DLLEXPORT Job : public QObject
{
Q_OBJECT
public:
enum State
{
Pending = 0,
Running,
Finished
};
explicit Job( QObject* parent = nullptr );
virtual ~Job();
virtual QString prettyName() = 0;
virtual void exec() = 0;
signals:
void running( const Calamares::job_ptr& );
void finished( const Calamares::job_ptr& );
};
} // namespace Calamares

View File

@ -20,6 +20,14 @@
namespace Calamares
{
JobQueue* JobQueue::s_instance = nullptr;
JobQueue*
JobQueue::instance()
{
return s_instance;
}
JobQueue::JobQueue( QObject* parent )
: QObject( parent )
{

View File

@ -20,6 +20,7 @@
#define CALAMARES_JOBQUEUE_H
#include "DllMacro.h"
#include "Typedefs.h"
#include <QObject>
@ -31,6 +32,18 @@ class DLLEXPORT JobQueue : public QObject
Q_OBJECT
public:
explicit JobQueue( QObject* parent = nullptr );
static JobQueue* instance();
void enqueue( const Calamares::job_ptr& job );
void enqueue( const QList< Calamares::job_ptr >& jobs );
signals:
void jobRunning( const Calamares::job_ptr& );
void jobFinished( const Calamares::job_ptr& );
private:
static JobQueue* s_instance;
};
}

View File

@ -0,0 +1,32 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* 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 TYPEDEFS_H
#define TYPEDEFS_H
#include <QSharedPointer>
namespace Calamares
{
class Job;
typedef QSharedPointer< Job > job_ptr;
} //ns
#endif // TYPEDEFS_H