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>
4 Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License version 2 or at your option version 3 as published by
9 the Free Software Foundation.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22// Own
23#include "typeslistitem.h"
24
25// KDE
26#include <kdebug.h>
27#include <kicon.h>
28
29
30TypesListItem::TypesListItem(QTreeWidget *parent, const QString & major)
31 : QTreeWidgetItem(parent),
32 m_mimetypeData(major)
33{
34 setText(0, major);
35}
36
37TypesListItem::TypesListItem(TypesListItem *parent, KMimeType::Ptr mimetype)
38 : QTreeWidgetItem(parent),
39 m_mimetypeData(mimetype)
40{
41 setText(0, m_mimetypeData.minorType());
42}
43
44TypesListItem::TypesListItem(TypesListItem *parent, const QString& newMimetype)
45 : QTreeWidgetItem(parent),
46 m_mimetypeData(newMimetype, true)
47{
48 setText(0, m_mimetypeData.minorType());
49}
50
51TypesListItem::~TypesListItem()
52{
53}
54
55void TypesListItem::setIcon( const QString& icon )
56{
57 m_mimetypeData.setUserSpecifiedIcon(icon);
58 loadIcon(true);
59}
60
61void TypesListItem::loadIcon(bool forceReload)
62{
63 if ((!m_mimetypeData.icon().isEmpty() && icon(0).isNull()) || forceReload) {
64 QTreeWidgetItem::setIcon(0, KIcon(m_mimetypeData.icon()));
65 }
66}
67
68