-
Notifications
You must be signed in to change notification settings - Fork 7
/
packagelist.cpp
87 lines (71 loc) · 2 KB
/
packagelist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* This file is part of mg-package-manager
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2013 Timo Hannukkala <timo.hannukkala@nomovok.com>
*
* Contact: Kyösti Ranto <kyosti.ranto@digia.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include "packagelist.h"
#include "package.h"
#include <QDebug>
// #define PACKAGELIST_LOG
PackageList::PackageList(QObject *parent) :
QObject(parent)
{
qDebug() << Q_FUNC_INFO;
}
void PackageList::operator<<(QSharedPointer<PackageInfo> packagePtr)
{
#ifdef PACKAGELIST_LOG
qDebug() << Q_FUNC_INFO;
#endif
m_list << new Package(packagePtr, false, this);
emit changed();
}
Package* PackageList::get(PackageKit::Transaction::Info info, const QString &packageID, const QString &summary)
{
#ifdef PACKAGELIST_LOG
qDebug() << Q_FUNC_INFO;
#endif
int i;
for (i=0;i<m_list.size();i++) {
Package *packagePtr = m_list[i];
if (packagePtr->equals(info, packageID, summary)) {
return packagePtr;
}
}
return NULL;
}
QList<Package*> *PackageList::list()
{
#ifdef PACKAGELIST_LOG
qDebug() << Q_FUNC_INFO;
#endif
return &m_list;
}
void PackageList::clear()
{
#ifdef PACKAGELIST_LOG
qDebug() << Q_FUNC_INFO;
#endif
foreach(QObject *object, m_list)
object->deleteLater();
m_list.clear();
emit changed();
}