2 * Copyright (C) 2008 David Greaves <david@dgreaves.com>
4 * This software is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 2.1 of
7 * the License, or (at your option) any later version.
9 * This software is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this software; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 //#define DEBUG_SHOPPER 1
23 #include "shopper.h" // automake, i8n, gettext
28 GestureConnectionStore::GestureConnectionStore() : QObject() {};
30 struct Gesture::Private
32 // available via public API
33 QString shape
; // holds the string encoding of the shape.
35 // avialable via friend API, populated by 'connect'
36 GestureConnectionStore
* connectionStore
;
41 Gesture::Gesture(QString shape
)
45 p
->connectionStore
= 0;
48 Gesture::Gesture(Gesture
*g
)
51 p
->shape
= g
->p
->shape
;
52 p
->connectionStore
= 0;
55 Gesture::Gesture(const Gesture
&g
)
58 p
->shape
= g
.p
->shape
;
59 p
->connectionStore
= 0;
64 if (p
->connectionStore
)
65 delete p
->connectionStore
;
70 ////////////////////////////////////////////////////////////////
72 bool operator==(const Gesture
&A
, const Gesture
&B
)
74 return A
.p
->shape
== B
.p
->shape
;
77 uint
qHash(const Gesture
&A
)
84 ////////////////////////////////////////////////////////////////
86 void Gesture::addStroke(QString stroke
)
91 QString
Gesture::shape() const
97 ////////////////////////////////////////////////////////////////
98 // Protected interface
99 void Gesture::connect(QObject
* receiver
, const char* method
)
101 if (p
->connectionStore
== 0)
102 p
->connectionStore
= new GestureConnectionStore
;
104 p
->connectionStore
->connect(p
->connectionStore
, SIGNAL(activated()),
108 bool Gesture::disconnect(QObject
* receiver
, const char* method
)
110 Q_ASSERT(p
->connectionStore
!= 0);
111 if (p
->connectionStore
== 0)
114 return p
->connectionStore
->disconnect(p
->connectionStore
, SIGNAL(activated()),
118 void Gesture::invoke()
120 if (p
->connectionStore
)
121 p
->connectionStore
->activated();