1 /* This file is part of the KDE project
2 Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
3 Copyright (C) 2003, 2007 David Faure <faure@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 or at your option version 3 as published by
8 the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include "typeslistitem.h"
26 #include <kiconloader.h>
29 TypesListItem::TypesListItem(Q3ListView
*parent
, const QString
& major
)
30 : Q3ListViewItem(parent
),
36 TypesListItem::TypesListItem(TypesListItem
*parent
, KMimeType::Ptr mimetype
, bool newItem
)
37 : Q3ListViewItem(parent
),
38 m_mimetypeData(mimetype
, newItem
)
40 setText(0, m_mimetypeData
.minorType());
43 TypesListItem::~TypesListItem()
47 void TypesListItem::paintCell(QPainter
*painter
, const QColorGroup
& cg
, int column
, int width
, int align
)
49 if (parent() && !pixmap(0)) {
50 // Load icon here instead of loading it in the constructor. This way
51 // the user won't wait for icons he won't see.
52 setPixmap(0, KIconLoader::global()->loadMimeTypeIcon(m_mimetypeData
.icon(), KIconLoader::Small
));
54 Q3ListViewItem::paintCell(painter
, cg
, column
, width
, align
);
58 void TypesListItem::setIcon( const QString
& icon
)
60 m_mimetypeData
.setIcon(icon
);
61 setPixmap( 0, SmallIcon( icon
) );