File indexing completed on 2023-05-30 11:30:45

0001 /**
0002  * Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
0003  * Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.fr>
0004  *
0005  * This program is free software; you can redistribute it and/or modify it under
0006  * the terms of the GNU General Public License as published by the Free Software
0007  * Foundation; either version 2 of the License, or (at your option) any later
0008  * version.
0009  *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License along with
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #include "covericonview.h"
0019 #include "covermanager.h"
0020 
0021 using CoverUtility::CoverIconViewItem;
0022 
0023 CoverIconViewItem::CoverIconViewItem(coverKey id, QListWidget *parent) :
0024     QListWidgetItem(parent), m_id(id)
0025 {
0026     const auto &data = CoverManager::coverInfo(id);
0027     setText(QString("%1 - %2").arg(data.artist, data.album));
0028     setIcon(data.thumbnail());
0029     setSizeHint(QSize(140, 150));
0030 }
0031 
0032 CoverIconView::CoverIconView(QWidget *parent, const char *name) : QListWidget(parent)
0033 {
0034     setObjectName(QLatin1String(name));
0035     setResizeMode(QListWidget::Adjust);
0036     setViewMode(QListWidget::IconMode);
0037     setIconSize(QSize(130, 140)); // FIXME: HiDPI
0038     setMovement(QListWidget::Static);
0039     setContextMenuPolicy(Qt::CustomContextMenu);
0040 }
0041 
0042 CoverIconViewItem *CoverIconView::currentItem() const
0043 {
0044     return static_cast<CoverIconViewItem *>(QListWidget::currentItem());
0045 }
0046 
0047 // vim: set et sw=4 tw=0 sta: