covericonview.cpp 1.63 KB
Newer Older
1 2
/**
 * Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
Arnold Dumas's avatar
Arnold Dumas committed
3
 * Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.fr>
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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/>.
 */
Michael Pyne's avatar
Michael Pyne committed
17 18 19 20 21 22

#include "covericonview.h"
#include "covermanager.h"

using CoverUtility::CoverIconViewItem;

23
CoverIconViewItem::CoverIconViewItem(coverKey id, QListWidget *parent) :
24
    QListWidgetItem(parent), m_id(id)
Michael Pyne's avatar
Michael Pyne committed
25
{
Michael Pyne's avatar
Michael Pyne committed
26 27 28
    const auto &data = CoverManager::coverInfo(id);
    setText(QString("%1 - %2").arg(data.artist, data.album));
    setIcon(data.thumbnail());
29
    setSizeHint(QSize(140, 150));
Michael Pyne's avatar
Michael Pyne committed
30 31
}

32
CoverIconView::CoverIconView(QWidget *parent, const char *name) : QListWidget(parent)
Michael Pyne's avatar
Michael Pyne committed
33
{
Arnold Dumas's avatar
Arnold Dumas committed
34
    setObjectName(QLatin1String(name));
35 36 37 38
    setResizeMode(QListWidget::Adjust);
    setViewMode(QListWidget::IconMode);
    setIconSize(QSize(130, 140)); // FIXME: HiDPI
    setMovement(QListWidget::Static);
39
    setContextMenuPolicy(Qt::CustomContextMenu);
Michael Pyne's avatar
Michael Pyne committed
40 41 42 43
}

CoverIconViewItem *CoverIconView::currentItem() const
{
44
    return static_cast<CoverIconViewItem *>(QListWidget::currentItem());
Michael Pyne's avatar
Michael Pyne committed
45 46
}

47
// vim: set et sw=4 tw=0 sta: