-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlistobject.cpp
156 lines (123 loc) · 2.81 KB
/
listobject.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
Copyright (C) 2014 Sialan Labs
http://labs.sialan.org
Meikade 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 3 of the License, or
(at your option) any later version.
Meikade 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/>.
*/
#include "listobject.h"
#include <QVariantList>
#include <QDebug>
class ListObjectPrivate
{
public:
QVariantList list;
};
ListObject::ListObject(QObject *parent) :
QObject(parent)
{
p = new ListObjectPrivate;
}
void ListObject::removeAll(const QVariant &v)
{
p->list.removeAll( v );
emit countChanged();
}
void ListObject::removeOne(const QVariant &v)
{
p->list.removeOne( v );
emit countChanged();
}
void ListObject::removeAt(int index)
{
p->list.removeAt( index );
emit countChanged();
}
QVariant ListObject::takeLast()
{
if( p->list.isEmpty() )
return QVariant();
const QVariant & res = p->list.takeLast();
emit countChanged();
return res;
}
QVariant ListObject::takeFirst()
{
if( p->list.isEmpty() )
return QVariant();
const QVariant & res = p->list.takeFirst();
emit countChanged();
return res;
}
QVariant ListObject::takeAt(int index)
{
const QVariant & res = p->list.takeAt( index );
emit countChanged();
return res;
}
QVariant ListObject::last() const
{
if( p->list.isEmpty() )
return QVariant();
return p->list.last();
}
QVariant ListObject::first() const
{
if( p->list.isEmpty() )
return QVariant();
return p->list.first();
}
void ListObject::insert(int index, const QVariant &v)
{
p->list.insert( index, v );
emit countChanged();
}
void ListObject::append(const QVariant &v)
{
p->list.append( v );
emit countChanged();
}
void ListObject::prepend(const QVariant &v)
{
p->list.prepend( v );
emit countChanged();
}
int ListObject::count() const
{
return p->list.count();
}
bool ListObject::isEmpty() const
{
return p->list.isEmpty();
}
QVariant ListObject::at(int index) const
{
return p->list.at(index);
}
int ListObject::indexOf(const QVariant &v) const
{
return p->list.indexOf(v);
}
void ListObject::fromList(const QVariantList &list)
{
p->list = list;
}
QVariantList ListObject::toList() const
{
return p->list;
}
bool ListObject::contains(const QVariant &v) const
{
return p->list.contains(v);
}
ListObject::~ListObject()
{
delete p;
}