1 /****************************************************************************
2 Copyright (C) 2001-2009 Robby Stephenson <robby@periapsis.org>
3 ***************************************************************************/
4
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU General Public License as *
9 * published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) version 3 or any later version *
11 * accepted by the membership of KDE e.V. (or its successor approved *
12 * by the membership of KDE e.V.), which shall act as a proxy *
13 * defined in Section 14 of version 3 of the license. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
22 * *
23 ***************************************************************************/
24
25 #include "fetcherinfolistitem.h"
26 #include "fetchmanager.h"
27
28 using Tellico::FetcherInfoListItem;
29
FetcherInfoListItem(QListWidget * parent_,const Tellico::Fetch::FetcherInfo & info_)30 FetcherInfoListItem::FetcherInfoListItem(QListWidget* parent_, const Tellico::Fetch::FetcherInfo& info_)
31 : QListWidgetItem(parent_)
32 , m_info(info_)
33 , m_newSource(true)
34 , m_fetcher(nullptr) {
35 setData(Qt::DisplayRole, m_info.name);
36 QPixmap pix = Fetch::Manager::fetcherIcon(m_info.type);
37 if(!pix.isNull()) {
38 setData(Qt::DecorationRole, pix);
39 }
40 }
41
setConfigGroup(const KConfigGroup & group_)42 void FetcherInfoListItem::setConfigGroup(const KConfigGroup& group_) {
43 m_configGroup = group_;
44 if(m_fetcher) {
45 m_fetcher->setConfigGroup(m_configGroup);
46 }
47 }
48
fetchType() const49 Tellico::Fetch::Type FetcherInfoListItem::fetchType() const {
50 return m_info.type;
51 }
52
setUpdateOverwrite(bool b)53 void FetcherInfoListItem::setUpdateOverwrite(bool b) {
54 m_info.updateOverwrite = b;
55 }
56
updateOverwrite() const57 bool FetcherInfoListItem::updateOverwrite() const {
58 return m_info.updateOverwrite;
59 }
60
setNewSource(bool b)61 void FetcherInfoListItem::setNewSource(bool b) {
62 m_newSource = b;
63 }
64
isNewSource() const65 bool FetcherInfoListItem::isNewSource() const {
66 return m_newSource;
67 }
68
uuid() const69 QString FetcherInfoListItem::uuid() const {
70 return m_info.uuid;
71 }
72
setFetcher(Tellico::Fetch::Fetcher * fetcher_)73 void FetcherInfoListItem::setFetcher(Tellico::Fetch::Fetcher* fetcher_) {
74 Q_ASSERT(fetcher_);
75 m_fetcher = fetcher_;
76 QPixmap pix = Fetch::Manager::fetcherIcon(fetcher_);
77 if(!pix.isNull()) {
78 setData(Qt::DecorationRole, pix);
79 }
80 }
81
fetcher() const82 Tellico::Fetch::Fetcher* FetcherInfoListItem::fetcher() const {
83 return m_fetcher;
84 }
85