~ubuntu-branches/ubuntu/wily/tupi/wily-proposed

« back to all changes in this revision

Viewing changes to src/store/ktprojectresponse.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-05-13 09:53:35 UTC
  • mfrom: (8.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130513095335-3iqdvt9ne07ia25v
Tags: 0.2+git01-1
* Upload to unstable.
* Removed unnecessary versioned Build-Depends.
* Removed obsolete "DM-Upload-Allowed".
* Added Vcs links to collab-maint.
* Standards updated to version 3.9.4.
* Corrected "libavutil51"-->"libavutil-dev" in Build-Depends.
* Updated debian/watch (corrected URL, removed comments).
* Updated get-orig-source (can work from any directory).
* Updated my email address; bumped copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Project TUPI: Magia 2D                                                *
3
 
 *   Project Contact: info@maefloresta.com                                 *
4
 
 *   Project Website: http://www.maefloresta.com                           *
5
 
 *   Project Leader: Gustav Gonzalez <info@maefloresta.com>                *
6
 
 *                                                                         *
7
 
 *   Developers:                                                           *
8
 
 *   2010:                                                                 *
9
 
 *    Gustavo Gonzalez / xtingray                                          *
10
 
 *                                                                         *
11
 
 *   KTooN's versions:                                                     * 
12
 
 *                                                                         *
13
 
 *   2006:                                                                 *
14
 
 *    David Cuadrado                                                       *
15
 
 *    Jorge Cuadrado                                                       *
16
 
 *   2003:                                                                 *
17
 
 *    Fernado Roldan                                                       *
18
 
 *    Simena Dinas                                                         *
19
 
 *                                                                         *
20
 
 *   Copyright (C) 2010 Gustav Gonzalez - http://www.maefloresta.com       *
21
 
 *   License:                                                              *
22
 
 *   This program is free software; you can redistribute it and/or modify  *
23
 
 *   it under the terms of the GNU General Public License as published by  *
24
 
 *   the Free Software Foundation; either version 3 of the License, or     *
25
 
 *   (at your option) any later version.                                   *
26
 
 *                                                                         *
27
 
 *   This program is distributed in the hope that it will be useful,       *
28
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
29
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
30
 
 *   GNU General Public License for more details.                          *
31
 
 *                                                                         *
32
 
 *   You should have received a copy of the GNU General Public License     *
33
 
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
34
 
 ***************************************************************************/
35
 
 
36
 
#include "ktprojectresponse.h"
37
 
#include "tdebug.h"
38
 
 
39
 
// This class returns information about data structure of a Tupi project 
40
 
// It is used from signals in the KTProject class to send data to anothers classes
41
 
 
42
 
class KTProjectResponse::Private
43
 
{
44
 
    public:
45
 
        Private(int part, int action) : part(part), action(action), isExternal(false) {}
46
 
 
47
 
        int part;
48
 
        int action;
49
 
        KTProjectRequestArgument arg;
50
 
        QByteArray data;
51
 
        Mode mode;
52
 
 
53
 
        bool isExternal;
54
 
};
55
 
 
56
 
KTProjectResponse::KTProjectResponse(int part, int action) : k(new Private(part, action))
57
 
{
58
 
}
59
 
 
60
 
KTProjectResponse::~KTProjectResponse()
61
 
{
62
 
    delete k;
63
 
}
64
 
 
65
 
int KTProjectResponse::part() const
66
 
{
67
 
    return k->part;
68
 
}
69
 
 
70
 
int KTProjectResponse::action() const
71
 
{
72
 
    if (k->mode == Undo) {
73
 
 
74
 
        switch (k->action) {
75
 
                case KTProjectRequest::Add:
76
 
                     {
77
 
                        return KTProjectRequest::Remove;
78
 
                     }
79
 
                break;
80
 
                case KTProjectRequest::AddSymbolToProject:
81
 
                     {
82
 
                        return KTProjectRequest::RemoveSymbolFromProject;
83
 
                     }
84
 
                break;
85
 
                case KTProjectRequest::EditNodes:
86
 
                     {
87
 
                     }
88
 
                break;
89
 
                case KTProjectRequest::View:
90
 
                     {
91
 
                     }
92
 
                break;
93
 
                case KTProjectRequest::Select:
94
 
                     {
95
 
                     }
96
 
                break;
97
 
                case KTProjectRequest::Transform:
98
 
                     {
99
 
                     }
100
 
                break;
101
 
                case KTProjectRequest::SetTween:
102
 
                     {
103
 
                     }
104
 
                break;
105
 
                case KTProjectRequest::Lock:
106
 
                     {
107
 
                     }
108
 
                break;
109
 
                case KTProjectRequest::Ungroup:
110
 
                     {
111
 
                        return KTProjectRequest::Group;
112
 
                     }
113
 
                break;
114
 
                case KTProjectRequest::Rename:
115
 
                     {
116
 
                     }
117
 
                break;
118
 
                case KTProjectRequest::Move:
119
 
                     {
120
 
                     }
121
 
                break;
122
 
                case KTProjectRequest::Convert:
123
 
                     {
124
 
                     }
125
 
                break;
126
 
                case KTProjectRequest::Remove:
127
 
                     {
128
 
                        return KTProjectRequest::Add;
129
 
                     }
130
 
                break;
131
 
                case KTProjectRequest::Group:
132
 
                     {
133
 
                        return KTProjectRequest::Ungroup;
134
 
                     }
135
 
                break;
136
 
                case KTProjectRequest::Paste:
137
 
                     {
138
 
                     }
139
 
                break;
140
 
                default:
141
 
                     {
142
 
                        tFatal() << "KTProjectResponse::action() : Unhandled action -> " << k->action;
143
 
                     }
144
 
                break;
145
 
        }
146
 
    }
147
 
 
148
 
    return k->action;
149
 
}
150
 
 
151
 
int KTProjectResponse::originalAction() const
152
 
{
153
 
    return k->action;
154
 
}
155
 
 
156
 
void KTProjectResponse::setMode(Mode mode)
157
 
{
158
 
    k->mode = mode;
159
 
}
160
 
 
161
 
void KTProjectResponse::setExternal(bool e)
162
 
{
163
 
    k->isExternal = e;
164
 
}
165
 
 
166
 
bool KTProjectResponse::external() const
167
 
{
168
 
    return k->isExternal;
169
 
}
170
 
 
171
 
KTProjectResponse::Mode KTProjectResponse::mode() const
172
 
{
173
 
    return k->mode;
174
 
}
175
 
 
176
 
void KTProjectResponse::setArg(const QString &value)
177
 
{
178
 
    k->arg = value;
179
 
}
180
 
 
181
 
void KTProjectResponse::setData(const QByteArray &data)
182
 
{
183
 
    k->data = data;
184
 
}
185
 
 
186
 
KTProjectRequestArgument KTProjectResponse::arg() const
187
 
{
188
 
    return k->arg;
189
 
}
190
 
 
191
 
QByteArray KTProjectResponse::data() const
192
 
{
193
 
    return k->data;
194
 
}
195
 
 
196
 
// SCENE
197
 
 
198
 
KTSceneResponse::KTSceneResponse(int part, int action) : KTProjectResponse(part, action), m_sceneIndex(-1)
199
 
{
200
 
}
201
 
 
202
 
KTSceneResponse::~KTSceneResponse()
203
 
{
204
 
}
205
 
 
206
 
int KTSceneResponse::sceneIndex() const
207
 
{
208
 
    return m_sceneIndex;
209
 
}
210
 
 
211
 
void KTSceneResponse::setSceneIndex(int index)
212
 
{
213
 
    m_sceneIndex = index;
214
 
}
215
 
 
216
 
void KTSceneResponse::setState(const QString &state)
217
 
{
218
 
    m_state = state;
219
 
}
220
 
 
221
 
QString KTSceneResponse::state() const
222
 
{
223
 
    return m_state;
224
 
}
225
 
 
226
 
void KTSceneResponse::setScenes(Scenes scenes) 
227
 
{
228
 
    m_scenes = scenes;
229
 
}
230
 
 
231
 
// LAYER
232
 
 
233
 
KTLayerResponse::KTLayerResponse(int part, int action) : KTSceneResponse(part, action), m_layerIndex(-1)
234
 
{
235
 
}
236
 
 
237
 
KTLayerResponse::~KTLayerResponse()
238
 
{
239
 
}
240
 
 
241
 
int KTLayerResponse::layerIndex() const
242
 
{
243
 
    return m_layerIndex;
244
 
}
245
 
 
246
 
void KTLayerResponse::setLayerIndex(int index)
247
 
{
248
 
    m_layerIndex = index;
249
 
}
250
 
 
251
 
// FRAME
252
 
 
253
 
KTFrameResponse::KTFrameResponse(int part, int action) : KTLayerResponse(part, action), m_frameIndex(-1)
254
 
{
255
 
}
256
 
 
257
 
KTFrameResponse::~KTFrameResponse()
258
 
{
259
 
}
260
 
 
261
 
int KTFrameResponse::frameIndex() const
262
 
{
263
 
    return m_frameIndex;
264
 
}
265
 
 
266
 
void KTFrameResponse::setFrameIndex(int index)
267
 
{
268
 
    m_frameIndex = index;
269
 
}
270
 
 
271
 
bool KTFrameResponse::frameIsEmpty()
272
 
{
273
 
    return empty;
274
 
}
275
 
 
276
 
void KTFrameResponse::setFrameState(bool state)
277
 
{
278
 
    empty = state;
279
 
}
280
 
 
281
 
// ITEM
282
 
 
283
 
KTItemResponse::KTItemResponse(int part, int action) : KTFrameResponse(part, action), m_itemIndex(-1)
284
 
{
285
 
}
286
 
 
287
 
KTItemResponse::~KTItemResponse()
288
 
{
289
 
}
290
 
 
291
 
int KTItemResponse::itemIndex() const
292
 
{
293
 
    return m_itemIndex;
294
 
}
295
 
 
296
 
void KTItemResponse::setItemIndex(int index)
297
 
{
298
 
    m_itemIndex = index;
299
 
}
300
 
 
301
 
KTLibraryObject::Type KTItemResponse::itemType() const
302
 
{
303
 
    return m_itemType;
304
 
}
305
 
 
306
 
void KTItemResponse::setItemType(KTLibraryObject::Type type)
307
 
{
308
 
    m_itemType = type;
309
 
}
310
 
 
311
 
QPointF KTItemResponse::position()
312
 
{
313
 
    return QPointF(m_x, m_y);
314
 
}
315
 
 
316
 
void KTItemResponse::setPosX(double coord)
317
 
{
318
 
    m_x = coord;
319
 
}
320
 
 
321
 
void KTItemResponse::setPosY(double coord)
322
 
{
323
 
    m_y = coord;
324
 
}
325
 
 
326
 
KTProject::Mode KTItemResponse::spaceMode()
327
 
{
328
 
    return m_mode;
329
 
}
330
 
 
331
 
void KTItemResponse::setSpaceMode(KTProject::Mode mode)
332
 
{
333
 
    m_mode = mode;
334
 
}
335
 
 
336
 
bool KTItemResponse::frameIsEmpty()
337
 
{
338
 
    return empty;
339
 
}
340
 
 
341
 
void KTItemResponse::setFrameState(bool state)
342
 
{
343
 
    empty = state;
344
 
}
345
 
 
346
 
KTLibraryResponse::KTLibraryResponse(int part, int action) : KTFrameResponse(part, action)
347
 
{
348
 
}
349
 
 
350
 
KTLibraryResponse::~KTLibraryResponse()
351
 
{
352
 
}
353
 
 
354
 
void KTLibraryResponse::setSymbolType(KTLibraryObject::Type symtype)
355
 
{
356
 
    m_symbolType = symtype;
357
 
}
358
 
 
359
 
KTLibraryObject::Type KTLibraryResponse::symbolType() const
360
 
{
361
 
    return m_symbolType;
362
 
}
363
 
 
364
 
void KTLibraryResponse::setParent(const QString top)
365
 
{
366
 
    parentNode = top;
367
 
}
368
 
 
369
 
QString KTLibraryResponse::parent() const
370
 
{
371
 
    return parentNode;
372
 
}
373
 
 
374
 
KTProject::Mode KTLibraryResponse::spaceMode()
375
 
{
376
 
    return m_mode;
377
 
}
378
 
 
379
 
void KTLibraryResponse::setSpaceMode(KTProject::Mode mode)
380
 
{
381
 
    m_mode = mode;
382
 
}
383
 
 
384
 
bool KTLibraryResponse::frameIsEmpty()
385
 
{
386
 
    return empty;
387
 
}
388
 
 
389
 
void KTLibraryResponse::setFrameState(bool state)
390
 
{
391
 
    tFatal() << "KTLibraryResponse::setFrameState() - Setting state: " << state;
392
 
    empty = state;
393
 
}
394
 
 
395
 
KTProjectResponseFactory::KTProjectResponseFactory()
396
 
{
397
 
}
398
 
 
399
 
KTProjectResponseFactory::~KTProjectResponseFactory()
400
 
{
401
 
}
402
 
 
403
 
KTProjectResponse *KTProjectResponseFactory::create(int part, int action)
404
 
{
405
 
    switch (part) {
406
 
            case KTProjectRequest::Scene:
407
 
             {
408
 
                 return new KTSceneResponse(part, action);
409
 
             }
410
 
            break;
411
 
            case KTProjectRequest::Layer:
412
 
             {
413
 
                 return new KTLayerResponse(part, action);
414
 
             }
415
 
            break;
416
 
            case KTProjectRequest::Frame:
417
 
             {
418
 
                 return new KTFrameResponse(part, action);
419
 
             }
420
 
            break;
421
 
            case KTProjectRequest::Item:
422
 
             {
423
 
                 return new KTItemResponse(part, action);
424
 
             }
425
 
            break;
426
 
            case KTProjectRequest::Library:
427
 
             {
428
 
                 return new KTLibraryResponse(part, action);
429
 
             }
430
 
            break;
431
 
            default:
432
 
             {
433
 
                qFatal("Unknown PART"); // TODO: REMOVE ME
434
 
             }
435
 
            break;
436
 
    }
437
 
    
438
 
    return new KTProjectResponse(part, action);
439
 
}