/***************************************************************************
 *   Copyright (c) 2009  Peter Mylemans <peter.mylemans@gmail.com>         *
 *                                                                         *
 *   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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include "LocalCollection.h"
#include "database/DummyDatabase.h"

LocalCollection::LocalCollection()
{
    m_database = new DummyDatabase;
}

LocalCollection::~LocalCollection()
{
    delete m_database;
}

const QPixmap LocalCollection::icon() const
{
    return m_icon;
}

const QString LocalCollection::title() const
{
    return "Local Collection";
}

void LocalCollection::query(const QString &query)
{
    Q_UNUSED(query);

    QList<ContextModel*> list = m_database->listLocalCollection();
    foreach (ContextModel* model, list)
    {
        if (model->modelId() == "falkor-movie")
            addMovie(static_cast<const Movie*>(model));
    }
}

void LocalCollection::addMovie(const Movie *movie)
{
    addModel(movie);
    emit movieAdded(movie);
}
