/****************************************************************************************
 * Copyright (c) 2008 Seb Ruiz <ruiz@kde.org>                                           *
 *                                                                                      *
 * This program 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 2 of the License, or (at your option) any later           *
 * version.                                                                             *
 *                                                                                      *
 * This program 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         *
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 ****************************************************************************************/

#ifndef COVERFETCHINGACTIONS_H
#define COVERFETCHINGACTIONS_H

#include "amarok_export.h"
#include "core/meta/forward_declarations.h"

#include <QAction>

/**
 * This collection of actions handles fetching, displaying and removing of album art
 *
 * @author Seb Ruiz
 */

class AMAROK_EXPORT BaseCoverAction : public QAction
{
    Q_OBJECT
    public:
        BaseCoverAction( QObject *parent, const Meta::AlbumPtr &album )
            : QAction( parent )
        {
            m_albums.append( album );
            connect( this, &QAction::triggered, this, &BaseCoverAction::slotTriggered );
        }
        BaseCoverAction( QObject *parent, const Meta::AlbumList &albums )
            : QAction( parent )
        {
            m_albums = albums;
            connect( this, &QAction::triggered, this, &BaseCoverAction::slotTriggered );
        }

    protected Q_SLOTS:
        virtual void slotTriggered() = 0;
    protected:
        Meta::AlbumList m_albums;
};

class AMAROK_EXPORT FetchCoverAction : public BaseCoverAction
{
    Q_OBJECT
    public:
        FetchCoverAction( QObject *parent, const Meta::AlbumPtr &album )
            : BaseCoverAction( parent, album ) { init(); }
        FetchCoverAction( QObject *parent, const Meta::AlbumList &albums )
            : BaseCoverAction( parent, albums ) { init(); }

    protected Q_SLOTS:
        void slotTriggered() override;
    protected:
        virtual void init();
};

class AMAROK_EXPORT DisplayCoverAction : public BaseCoverAction
{
    Q_OBJECT
    public:
        DisplayCoverAction( QObject *parent, const Meta::AlbumPtr &album )
            : BaseCoverAction( parent, album ) { init(); }
        DisplayCoverAction( QObject *parent, const Meta::AlbumList &albums )
            : BaseCoverAction( parent, albums ) { init(); }

    protected Q_SLOTS:
        void slotTriggered() override;
    protected:
        virtual void init();
};

class AMAROK_EXPORT UnsetCoverAction : public BaseCoverAction
{
    Q_OBJECT
    public:
        UnsetCoverAction( QObject *parent, const Meta::AlbumPtr &album )
            : BaseCoverAction( parent, album ) { init(); }
        UnsetCoverAction( QObject *parent, const Meta::AlbumList &albums )
            : BaseCoverAction( parent, albums ) { init(); }

    protected Q_SLOTS:
        void slotTriggered() override;
    protected:
        virtual void init();
};

class AMAROK_EXPORT SetCustomCoverAction : public BaseCoverAction
{
    Q_OBJECT
    public:
        SetCustomCoverAction( QObject *parent, const Meta::AlbumPtr &album )
            : BaseCoverAction( parent, album ) { init(); }
        SetCustomCoverAction( QObject *parent, const Meta::AlbumList &albums )
            : BaseCoverAction( parent, albums ) { init(); }

    protected Q_SLOTS:
        void slotTriggered() override;
    protected:
        virtual void init();
};

#endif
