1 /*
2 Copyright (C) 2014 Aseman
3 http://aseman.co
4
5 This project is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This project 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "asemanhashobject.h"
20
21 #include <QList>
22 #include <QPair>
23 #include <QDebug>
24 #include <QDebug>
25
26 class AsemanHashObjectPrivate
27 {
28 public:
29 QMultiHash<QString,QVariant> hash;
30 };
31
AsemanHashObject(QObject * parent)32 AsemanHashObject::AsemanHashObject(QObject *parent) :
33 QObject(parent)
34 {
35 p = new AsemanHashObjectPrivate;
36 }
37
insert(const QString & key,const QVariant & value)38 void AsemanHashObject::insert(const QString &key, const QVariant &value)
39 {
40 p->hash.insert(key,value);
41 emit countChanged();
42 }
43
insertMulti(const QString & key,const QVariant & value)44 void AsemanHashObject::insertMulti(const QString &key, const QVariant &value)
45 {
46 p->hash.insertMulti(key,value);
47 emit countChanged();
48 }
49
remove(const QString & key)50 void AsemanHashObject::remove(const QString &key)
51 {
52 p->hash.remove(key);
53 emit countChanged();
54 }
55
remove(const QString & key,const QVariant & value)56 void AsemanHashObject::remove(const QString &key, const QVariant &value)
57 {
58 p->hash.remove(key,value);
59 emit countChanged();
60 }
61
key(const QVariant & value)62 QVariant AsemanHashObject::key(const QVariant &value)
63 {
64 return p->hash.key(value);
65 }
66
keys(const QVariant & value)67 QStringList AsemanHashObject::keys(const QVariant &value)
68 {
69 return p->hash.keys(value);
70 }
71
keys()72 QStringList AsemanHashObject::keys()
73 {
74 return p->hash.keys();
75 }
76
value(const QString & key)77 QVariant AsemanHashObject::value(const QString &key)
78 {
79 return p->hash.value(key);
80 }
81
values(const QString & key)82 QVariantList AsemanHashObject::values(const QString &key)
83 {
84 return p->hash.values(key);
85 }
86
containt(const QString & key)87 QVariant AsemanHashObject::containt(const QString &key)
88 {
89 return p->hash.contains(key);
90 }
91
containt(const QString & key,const QVariant & value)92 QVariant AsemanHashObject::containt(const QString &key, const QVariant &value)
93 {
94 return p->hash.contains(key,value);
95 }
96
clear()97 void AsemanHashObject::clear()
98 {
99 p->hash.clear();
100 emit countChanged();
101 }
102
count()103 int AsemanHashObject::count()
104 {
105 return p->hash.count();
106 }
107
~AsemanHashObject()108 AsemanHashObject::~AsemanHashObject()
109 {
110 delete p;
111 }
112