covericonview.cpp 1.9 KB
Newer Older
1 2
/**
 * Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
3
 * Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.com>
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 24
CoverIconViewItem::CoverIconViewItem(coverKey id, KListWidget *parent) :
    QListWidgetItem(parent), m_id(id)
Michael Pyne's avatar
Michael Pyne committed
25 26 27
{
    CoverDataPtr data = CoverManager::coverInfo(id);
    setText(QString("%1 - %2").arg(data->artist, data->album));
28 29
    setIcon(data->thumbnail());
    setSizeHint(QSize(140, 150));
Michael Pyne's avatar
Michael Pyne committed
30 31
}

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

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

47 48
// TODO: port to Qt4
#if 0
Laurent Montel's avatar
Laurent Montel committed
49
Q3DragObject *CoverIconView::dragObject()
Michael Pyne's avatar
Michael Pyne committed
50
{
Michael Pyne's avatar
Michael Pyne committed
51 52
    // Temporarily disabled pending conversion of the cover manager icon view
    // to Qt 4 ish stuff.
Michael Pyne's avatar
Michael Pyne committed
53 54
    CoverIconViewItem *item = currentItem();
    if(item)
55
        return new CoverDrag(item->id(), this);
Michael Pyne's avatar
Michael Pyne committed
56 57
    return 0;
}
58
#endif
Michael Pyne's avatar
Michael Pyne committed
59

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