brain.h 1.36 KB
Newer Older
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
#ifndef BRAIN_H
#define BRAIN_H

/* This deamon keeps on running while there are missing information about a track,
 *  it should have the option to turn it off, but the main idea is to here have the
 * brains of the app and collection. so this must be a very good a neat implementation */

#include <QObject>
#include <QThread>

#include "bae.h"
#include "../pulpo/pulpo.h"

class CollectionDB;
using namespace BAE;
using namespace PULPO;

class Brain : public QObject
{
    Q_OBJECT

public:
    explicit Brain();
    ~Brain();
    void start();
    void stop();
    bool isRunning() const;
    void setInterval(const uint &value);

    void setInfo(DB_LIST dataList, PULPO::ONTOLOGY ontology, QList<PULPO::SERVICES> services, PULPO::INFO info, PULPO::RECURSIVE recursive = PULPO::RECURSIVE::ON, void (*cb)(DB) = nullptr);

public slots:
    void synapse();
    void connectionParser(BAE::DB track, PULPO::RESPONSE response);
    void parseAlbumInfo(DB &track, const PULPO::INFO_K &response);
    void parseArtistInfo(DB &track, const PULPO::INFO_K &response);
    void parseTrackInfo(DB &track, const PULPO::INFO_K &response);
    void trackInfo();
    void artistInfo();
    void albumInfo();

private:
    QThread t;
    CollectionDB *con;
    Pulpo pulpo;
Camilo Higuita's avatar
fixes  
Camilo Higuita committed
46
    uint interval = 1500;
47 48 49 50 51 52 53 54
    bool go = false;

signals:
    void finished();
    void done(const TABLE &type);
};

#endif // BRAIN_H