~ubuntu-sdk-team/qtcreator-plugin-remotelinux/trunk

« back to all changes in this revision

Viewing changes to src/qnx/bardescriptordocumentnodehandlers.cpp

  • Committer: CI bot
  • Author(s): Benjamin Zeller
  • Date: 2014-06-16 10:28:43 UTC
  • mfrom: (4.2.4 remotelinux)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616102843-8juvmjvzwlzsboyw
Migrating to Qt5.3 and QtC 3.1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
**
3
 
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
4
 
**
5
 
** Contact: BlackBerry (qt@blackberry.com)
6
 
** Contact: KDAB (info@kdab.com)
7
 
**
8
 
** This file is part of Qt Creator.
9
 
**
10
 
** Commercial License Usage
11
 
** Licensees holding valid commercial Qt licenses may use this file in
12
 
** accordance with the commercial license agreement provided with the
13
 
** Software or, alternatively, in accordance with the terms contained in
14
 
** a written agreement between you and Digia.  For licensing terms and
15
 
** conditions see http://qt.digia.com/licensing.  For further information
16
 
** use the contact form at http://qt.digia.com/contact-us.
17
 
**
18
 
** GNU Lesser General Public License Usage
19
 
** Alternatively, this file may be used under the terms of the GNU Lesser
20
 
** General Public License version 2.1 as published by the Free Software
21
 
** Foundation and appearing in the file LICENSE.LGPL included in the
22
 
** packaging of this file.  Please review the following information to
23
 
** ensure the GNU Lesser General Public License version 2.1 requirements
24
 
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
 
**
26
 
** In addition, as a special exception, Digia gives you certain additional
27
 
** rights.  These rights are described in the Digia Qt LGPL Exception
28
 
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
 
**
30
 
****************************************************************************/
31
 
 
32
 
#include "bardescriptordocumentnodehandlers.h"
33
 
#include "bardescriptoreditorwidget.h"
34
 
#include "bardescriptoreditorassetswidget.h"
35
 
#include "bardescriptoreditorauthorinformationwidget.h"
36
 
#include "bardescriptoreditorentrypointwidget.h"
37
 
#include "bardescriptoreditorenvironmentwidget.h"
38
 
#include "bardescriptoreditorgeneralwidget.h"
39
 
#include "bardescriptoreditorpackageinformationwidget.h"
40
 
#include "bardescriptoreditorpermissionswidget.h"
41
 
 
42
 
#include <utils/environment.h>
43
 
#include <utils/qtcassert.h>
44
 
 
45
 
#include <QDomNode>
46
 
 
47
 
using namespace Qnx;
48
 
using namespace Qnx::Internal;
49
 
 
50
 
BarDescriptorDocumentAbstractNodeHandler::BarDescriptorDocumentAbstractNodeHandler(BarDescriptorEditorWidget *editorWidget)
51
 
    : m_editorWidget(editorWidget)
52
 
    , m_order(0xFFFF)
53
 
{
54
 
}
55
 
 
56
 
BarDescriptorDocumentAbstractNodeHandler::~BarDescriptorDocumentAbstractNodeHandler()
57
 
{
58
 
}
59
 
 
60
 
bool BarDescriptorDocumentAbstractNodeHandler::handle(const QDomNode &node)
61
 
{
62
 
    if (m_order == 0xFFFF)
63
 
        m_order = node.lineNumber();
64
 
 
65
 
    return fromNode(node);
66
 
}
67
 
 
68
 
void BarDescriptorDocumentAbstractNodeHandler::clear()
69
 
{
70
 
    m_order = 0xFFFF;
71
 
}
72
 
 
73
 
int BarDescriptorDocumentAbstractNodeHandler::order() const
74
 
{
75
 
    return m_order;
76
 
}
77
 
 
78
 
BarDescriptorEditorPackageInformationWidget *BarDescriptorDocumentAbstractNodeHandler::packageInformationWidget() const
79
 
{
80
 
    return m_editorWidget->packageInformationWidget();
81
 
}
82
 
 
83
 
BarDescriptorEditorAuthorInformationWidget *BarDescriptorDocumentAbstractNodeHandler::authorInformationWidget() const
84
 
{
85
 
    return m_editorWidget->authorInformationWidget();
86
 
}
87
 
 
88
 
BarDescriptorEditorEntryPointWidget *BarDescriptorDocumentAbstractNodeHandler::entryPointWidget() const
89
 
{
90
 
    return m_editorWidget->entryPointWidget();
91
 
}
92
 
 
93
 
BarDescriptorEditorGeneralWidget *BarDescriptorDocumentAbstractNodeHandler::generalWidget() const
94
 
{
95
 
    return m_editorWidget->generalWidget();
96
 
}
97
 
 
98
 
BarDescriptorEditorPermissionsWidget *BarDescriptorDocumentAbstractNodeHandler::permissionsWidget() const
99
 
{
100
 
    return m_editorWidget->permissionsWidget();
101
 
}
102
 
 
103
 
BarDescriptorEditorEnvironmentWidget *BarDescriptorDocumentAbstractNodeHandler::environmentWidget() const
104
 
{
105
 
    return m_editorWidget->environmentWidget();
106
 
}
107
 
 
108
 
BarDescriptorEditorAssetsWidget *BarDescriptorDocumentAbstractNodeHandler::assetsWidget() const
109
 
{
110
 
    return m_editorWidget->assetsWidget();
111
 
}
112
 
 
113
 
bool BarDescriptorDocumentAbstractNodeHandler::canHandleSimpleTextElement(const QDomNode &node, const QString &tagName) const
114
 
{
115
 
    QDomElement element = node.toElement();
116
 
    if (element.isNull())
117
 
        return false;
118
 
 
119
 
    if (element.tagName().toLower() != tagName.toLower())
120
 
        return false;
121
 
 
122
 
    QDomText textNode = element.firstChild().toText();
123
 
    if (textNode.isNull())
124
 
        return false;
125
 
 
126
 
    return true;
127
 
}
128
 
 
129
 
QString BarDescriptorDocumentAbstractNodeHandler::loadSimpleTextElement(const QDomNode &node)
130
 
{
131
 
    QDomElement element = node.toElement();
132
 
    QDomText textNode = element.firstChild().toText();
133
 
    return textNode.data();
134
 
}
135
 
 
136
 
QDomElement BarDescriptorDocumentAbstractNodeHandler::createSimpleTextElement(QDomDocument &doc, const QString &tagName, const QString &textValue) const
137
 
{
138
 
    if (textValue.isEmpty())
139
 
        return QDomElement();
140
 
 
141
 
    QDomElement elem = doc.createElement(tagName);
142
 
    elem.appendChild(doc.createTextNode(textValue));
143
 
    return elem;
144
 
}
145
 
 
146
 
// ----------------------------------------------------------------------------
147
 
 
148
 
BarDescriptorDocumentIdNodeHandler::BarDescriptorDocumentIdNodeHandler(BarDescriptorEditorWidget *editorWidget)
149
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
150
 
{
151
 
}
152
 
 
153
 
bool BarDescriptorDocumentIdNodeHandler::canHandle(const QDomNode &node) const
154
 
{
155
 
    return canHandleSimpleTextElement(node, QLatin1String("id"));
156
 
}
157
 
 
158
 
bool BarDescriptorDocumentIdNodeHandler::fromNode(const QDomNode &node)
159
 
{
160
 
    if (!canHandle(node))
161
 
        return false;
162
 
 
163
 
    packageInformationWidget()->setPackageId(loadSimpleTextElement(node));
164
 
    return true;
165
 
}
166
 
 
167
 
QDomNode BarDescriptorDocumentIdNodeHandler::toNode(QDomDocument &doc) const
168
 
{
169
 
    return createSimpleTextElement(doc, QLatin1String("id"), packageInformationWidget()->packageId());
170
 
}
171
 
 
172
 
// ----------------------------------------------------------------------------
173
 
 
174
 
BarDescriptorDocumentVersionNumberNodeHandler::BarDescriptorDocumentVersionNumberNodeHandler(BarDescriptorEditorWidget *editorWidget)
175
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
176
 
{
177
 
}
178
 
 
179
 
bool BarDescriptorDocumentVersionNumberNodeHandler::canHandle(const QDomNode &node) const
180
 
{
181
 
    return canHandleSimpleTextElement(node, QLatin1String("versionNumber"));
182
 
}
183
 
 
184
 
bool BarDescriptorDocumentVersionNumberNodeHandler::fromNode(const QDomNode &node)
185
 
{
186
 
    if (!canHandle(node))
187
 
        return false;
188
 
 
189
 
    packageInformationWidget()->setPackageVersion(loadSimpleTextElement(node));
190
 
    return true;
191
 
}
192
 
 
193
 
QDomNode BarDescriptorDocumentVersionNumberNodeHandler::toNode(QDomDocument &doc) const
194
 
{
195
 
    return createSimpleTextElement(doc, QLatin1String("versionNumber"), packageInformationWidget()->packageVersion());
196
 
}
197
 
 
198
 
// ----------------------------------------------------------------------------
199
 
 
200
 
BarDescriptorDocumentBuildIdNodeHandler::BarDescriptorDocumentBuildIdNodeHandler(BarDescriptorEditorWidget *editorWidget)
201
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
202
 
{
203
 
}
204
 
 
205
 
bool BarDescriptorDocumentBuildIdNodeHandler::canHandle(const QDomNode &node) const
206
 
{
207
 
    return canHandleSimpleTextElement(node, QLatin1String("buildId"));
208
 
}
209
 
 
210
 
bool BarDescriptorDocumentBuildIdNodeHandler::fromNode(const QDomNode &node)
211
 
{
212
 
    if (!canHandle(node))
213
 
        return false;
214
 
 
215
 
    packageInformationWidget()->setPackageBuildId(loadSimpleTextElement(node));
216
 
    return true;
217
 
}
218
 
 
219
 
QDomNode BarDescriptorDocumentBuildIdNodeHandler::toNode(QDomDocument &doc) const
220
 
{
221
 
    return createSimpleTextElement(doc, QLatin1String("buildId"), packageInformationWidget()->packageBuildId());
222
 
}
223
 
 
224
 
// ----------------------------------------------------------------------------
225
 
 
226
 
BarDescriptorDocumentApplicationNameNodeHandler::BarDescriptorDocumentApplicationNameNodeHandler(BarDescriptorEditorWidget *editorWidget)
227
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
228
 
{
229
 
}
230
 
 
231
 
bool BarDescriptorDocumentApplicationNameNodeHandler::canHandle(const QDomNode &node) const
232
 
{
233
 
    return canHandleSimpleTextElement(node, QLatin1String("name"));
234
 
}
235
 
 
236
 
bool BarDescriptorDocumentApplicationNameNodeHandler::fromNode(const QDomNode &node)
237
 
{
238
 
    // TODO: Add support for localization
239
 
 
240
 
    if (!canHandle(node))
241
 
        return false;
242
 
 
243
 
    entryPointWidget()->setApplicationName(loadSimpleTextElement(node));
244
 
    return true;
245
 
}
246
 
 
247
 
QDomNode BarDescriptorDocumentApplicationNameNodeHandler::toNode(QDomDocument &doc) const
248
 
{
249
 
    // TODO: Add support for localization
250
 
 
251
 
    return createSimpleTextElement(doc, QLatin1String("name"), entryPointWidget()->applicationName());
252
 
}
253
 
 
254
 
// ----------------------------------------------------------------------------
255
 
 
256
 
BarDescriptorDocumentApplicationDescriptionNodeHandler::BarDescriptorDocumentApplicationDescriptionNodeHandler(BarDescriptorEditorWidget *editorWidget)
257
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
258
 
{
259
 
}
260
 
 
261
 
bool BarDescriptorDocumentApplicationDescriptionNodeHandler::canHandle(const QDomNode &node) const
262
 
{
263
 
    return canHandleSimpleTextElement(node, QLatin1String("description"));
264
 
}
265
 
 
266
 
bool BarDescriptorDocumentApplicationDescriptionNodeHandler::fromNode(const QDomNode &node)
267
 
{
268
 
    // TODO: Add support for localization
269
 
 
270
 
    if (!canHandle(node))
271
 
        return false;
272
 
 
273
 
    entryPointWidget()->setApplicationDescription(loadSimpleTextElement(node));
274
 
    return true;
275
 
}
276
 
 
277
 
QDomNode BarDescriptorDocumentApplicationDescriptionNodeHandler::toNode(QDomDocument &doc) const
278
 
{
279
 
    return createSimpleTextElement(doc, QLatin1String("description"), entryPointWidget()->applicationDescription());
280
 
}
281
 
 
282
 
// ----------------------------------------------------------------------------
283
 
 
284
 
BarDescriptorDocumentApplicationIconNodeHandler::BarDescriptorDocumentApplicationIconNodeHandler(BarDescriptorEditorWidget *editorWidget)
285
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
286
 
{
287
 
}
288
 
 
289
 
bool BarDescriptorDocumentApplicationIconNodeHandler::canHandle(const QDomNode &node) const
290
 
{
291
 
    QDomElement element = node.toElement();
292
 
    if (element.isNull())
293
 
        return false;
294
 
 
295
 
    if (element.tagName() != QLatin1String("icon"))
296
 
        return false;
297
 
 
298
 
    QDomElement imageElement = element.firstChild().toElement();
299
 
    if (imageElement.isNull())
300
 
        return false;
301
 
 
302
 
    if (imageElement.tagName() != QLatin1String("image"))
303
 
        return false;
304
 
 
305
 
    QDomText imageTextNode = imageElement.firstChild().toText();
306
 
    if (imageTextNode.isNull())
307
 
        return false;
308
 
 
309
 
    return true;
310
 
}
311
 
 
312
 
bool BarDescriptorDocumentApplicationIconNodeHandler::fromNode(const QDomNode &node)
313
 
{
314
 
    // TODO: Add support for localization
315
 
 
316
 
    if (!canHandle(node))
317
 
        return false;
318
 
 
319
 
    QDomNode imageNode = node.firstChild();
320
 
    QDomText imageTextNode = imageNode.firstChild().toText();
321
 
    entryPointWidget()->setApplicationIcon(imageTextNode.data());
322
 
    return true;
323
 
}
324
 
 
325
 
QDomNode BarDescriptorDocumentApplicationIconNodeHandler::toNode(QDomDocument &doc) const
326
 
{
327
 
    // TODO: Add support for localization
328
 
    const QString iconFileName = entryPointWidget()->applicationIconFileName();
329
 
    if (iconFileName.isEmpty())
330
 
        return QDomElement();
331
 
 
332
 
    QDomElement iconElement = doc.createElement(QLatin1String("icon"));
333
 
    iconElement.appendChild(createSimpleTextElement(doc, QLatin1String("image"), iconFileName));
334
 
    return iconElement;
335
 
}
336
 
 
337
 
// ----------------------------------------------------------------------------
338
 
 
339
 
BarDescriptorDocumentSplashScreenNodeHandler::BarDescriptorDocumentSplashScreenNodeHandler(BarDescriptorEditorWidget *editorWidget)
340
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
341
 
{
342
 
}
343
 
 
344
 
bool BarDescriptorDocumentSplashScreenNodeHandler::canHandle(const QDomNode &node) const
345
 
{
346
 
    QDomElement element = node.toElement();
347
 
    if (element.isNull())
348
 
        return false;
349
 
 
350
 
    if (element.tagName().toLower() != QLatin1String("splashscreens"))
351
 
        return false;
352
 
 
353
 
    QDomElement imageElement = element.firstChild().toElement();
354
 
    if (imageElement.isNull())
355
 
        return false;
356
 
 
357
 
    if (imageElement.tagName().toLower() != QLatin1String("image"))
358
 
        return false;
359
 
 
360
 
    QDomText imageTextNode = imageElement.firstChild().toText();
361
 
    if (imageTextNode.isNull())
362
 
        return false;
363
 
 
364
 
    return true;
365
 
}
366
 
 
367
 
bool BarDescriptorDocumentSplashScreenNodeHandler::fromNode(const QDomNode &node)
368
 
{
369
 
    if (!canHandle(node))
370
 
        return false;
371
 
 
372
 
    QDomElement imageNode = node.firstChildElement();
373
 
    while (!imageNode.isNull()) {
374
 
        if (imageNode.tagName().toLower() == QLatin1String("image")) {
375
 
            QDomText imageTextNode = imageNode.firstChild().toText();
376
 
            entryPointWidget()->appendSplashScreen(imageTextNode.data());
377
 
        }
378
 
        imageNode = imageNode.nextSiblingElement();
379
 
    }
380
 
    return true;
381
 
}
382
 
 
383
 
QDomNode BarDescriptorDocumentSplashScreenNodeHandler::toNode(QDomDocument &doc) const
384
 
{
385
 
    QStringList splashScreens = entryPointWidget()->splashScreens();
386
 
    if (splashScreens.isEmpty())
387
 
        return QDomElement();
388
 
 
389
 
    QDomElement splashScreenElement = doc.createElement(QLatin1String("splashScreens"));
390
 
    foreach (const QString &splashScreen, splashScreens)
391
 
        splashScreenElement.appendChild(createSimpleTextElement(doc, QLatin1String("image"), splashScreen));
392
 
 
393
 
    return splashScreenElement;
394
 
}
395
 
 
396
 
// ----------------------------------------------------------------------------
397
 
 
398
 
BarDescriptorDocumentAssetNodeHandler::BarDescriptorDocumentAssetNodeHandler(BarDescriptorEditorWidget *editorWidget)
399
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
400
 
{
401
 
}
402
 
 
403
 
bool BarDescriptorDocumentAssetNodeHandler::canHandle(const QDomNode &node) const
404
 
{
405
 
    return canHandleSimpleTextElement(node, QLatin1String("asset"));
406
 
}
407
 
 
408
 
bool BarDescriptorDocumentAssetNodeHandler::fromNode(const QDomNode &node)
409
 
{
410
 
    if (!canHandle(node))
411
 
        return false;
412
 
 
413
 
    QDomElement element = node.toElement();
414
 
 
415
 
    QString path = element.attribute(QLatin1String("path"));
416
 
    QString entry = element.attribute(QLatin1String("entry"));
417
 
    QDomText destNode = element.firstChild().toText();
418
 
    QString dest = destNode.data();
419
 
 
420
 
    BarDescriptorAsset asset;
421
 
    asset.source = path;
422
 
    asset.destination = dest;
423
 
    asset.entry = entry == QLatin1String("true");
424
 
 
425
 
    assetsWidget()->addAsset(asset);
426
 
    return true;
427
 
}
428
 
 
429
 
QDomNode BarDescriptorDocumentAssetNodeHandler::toNode(QDomDocument &doc) const
430
 
{
431
 
    QDomDocumentFragment fragment = doc.createDocumentFragment();
432
 
 
433
 
    QList<BarDescriptorAsset> assets = assetsWidget()->assets();
434
 
    foreach (const BarDescriptorAsset &asset, assets) {
435
 
        QDomElement assetElem = doc.createElement(QLatin1String("asset"));
436
 
        assetElem.setAttribute(QLatin1String("path"), asset.source);
437
 
        if (asset.entry) {
438
 
            assetElem.setAttribute(QLatin1String("type"), QLatin1String("Qnx/Elf"));
439
 
            assetElem.setAttribute(QLatin1String("entry"), QLatin1String("true"));
440
 
        }
441
 
        assetElem.appendChild(doc.createTextNode(asset.destination));
442
 
        fragment.appendChild(assetElem);
443
 
    }
444
 
 
445
 
    return fragment;
446
 
}
447
 
 
448
 
// ----------------------------------------------------------------------------
449
 
 
450
 
BarDescriptorDocumentInitialWindowNodeHandler::BarDescriptorDocumentInitialWindowNodeHandler(BarDescriptorEditorWidget *editorWidget)
451
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
452
 
{
453
 
}
454
 
 
455
 
bool BarDescriptorDocumentInitialWindowNodeHandler::canHandle(const QDomNode &node) const
456
 
{
457
 
    QDomElement element = node.toElement();
458
 
    if (element.isNull())
459
 
        return false;
460
 
 
461
 
    if (element.tagName() != QLatin1String("initialWindow"))
462
 
        return false;
463
 
 
464
 
    return true;
465
 
}
466
 
 
467
 
bool BarDescriptorDocumentInitialWindowNodeHandler::fromNode(const QDomNode &node)
468
 
{
469
 
    if (!canHandle(node))
470
 
        return false;
471
 
 
472
 
    QDomElement child = node.firstChildElement();
473
 
    while (!child.isNull()) {
474
 
        if (child.tagName() == QLatin1String("aspectRatio")) {
475
 
            generalWidget()->setOrientation(loadSimpleTextElement(child));
476
 
        } else if (child.tagName() == QLatin1String("autoOrients")) {
477
 
            if (loadSimpleTextElement(child) == QLatin1String("true"))
478
 
                generalWidget()->setOrientation(QLatin1String("auto-orient"));
479
 
        } else if (child.tagName() == QLatin1String("systemChrome")) {
480
 
            generalWidget()->setChrome(loadSimpleTextElement(child));
481
 
        } else if (child.tagName() == QLatin1String("transparent")) {
482
 
            const QString transparent = loadSimpleTextElement(child);
483
 
            generalWidget()->setTransparent(transparent == QLatin1String("true"));
484
 
        }
485
 
        child = child.nextSiblingElement();
486
 
    }
487
 
 
488
 
    return true;
489
 
}
490
 
 
491
 
QDomNode BarDescriptorDocumentInitialWindowNodeHandler::toNode(QDomDocument &doc) const
492
 
{
493
 
    QDomElement element = doc.createElement(QLatin1String("initialWindow"));
494
 
 
495
 
    if (generalWidget()->orientation() == QLatin1String("auto-orient")) {
496
 
        element.appendChild(createSimpleTextElement(doc, QLatin1String("autoOrients"), QLatin1String("true")));
497
 
    } else if (!generalWidget()->orientation().isEmpty()) {
498
 
        element.appendChild(createSimpleTextElement(doc, QLatin1String("aspectRatio"), generalWidget()->orientation()));
499
 
        element.appendChild(createSimpleTextElement(doc, QLatin1String("autoOrients"), QLatin1String("false")));
500
 
    }
501
 
    element.appendChild(createSimpleTextElement(doc, QLatin1String("systemChrome"), generalWidget()->chrome()));
502
 
    element.appendChild(createSimpleTextElement(doc, QLatin1String("transparent"), generalWidget()->transparent() ? QLatin1String("true") : QLatin1String("false")));
503
 
 
504
 
    return element;
505
 
}
506
 
 
507
 
// ----------------------------------------------------------------------------
508
 
 
509
 
 
510
 
BarDescriptorDocumentActionNodeHandler::BarDescriptorDocumentActionNodeHandler(BarDescriptorEditorWidget *editorWidget)
511
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
512
 
{
513
 
}
514
 
 
515
 
bool BarDescriptorDocumentActionNodeHandler::canHandle(const QDomNode &node) const
516
 
{
517
 
    return canHandleSimpleTextElement(node, QLatin1String("action"));
518
 
}
519
 
 
520
 
bool BarDescriptorDocumentActionNodeHandler::fromNode(const QDomNode &node)
521
 
{
522
 
    if (!canHandle(node))
523
 
        return false;
524
 
 
525
 
    QString value = loadSimpleTextElement(node);
526
 
    if (value != QLatin1String("run_native")) // This has no representation in the GUI, and is always added
527
 
        permissionsWidget()->checkPermission(value);
528
 
 
529
 
    return true;
530
 
}
531
 
 
532
 
QDomNode BarDescriptorDocumentActionNodeHandler::toNode(QDomDocument &doc) const
533
 
{
534
 
    QDomDocumentFragment frag = doc.createDocumentFragment();
535
 
 
536
 
    QDomElement runNativeElement = doc.createElement(QLatin1String("action"));
537
 
    runNativeElement.setAttribute(QLatin1String("system"), QLatin1String("true"));
538
 
    runNativeElement.appendChild(doc.createTextNode(QLatin1String("run_native")));
539
 
    frag.appendChild(runNativeElement);
540
 
 
541
 
    QStringList checkedIdentifiers = permissionsWidget()->checkedPermissions();
542
 
    foreach (const QString &identifier, checkedIdentifiers)
543
 
        frag.appendChild(createSimpleTextElement(doc, QLatin1String("action"), identifier));
544
 
 
545
 
    return frag;
546
 
}
547
 
 
548
 
// ----------------------------------------------------------------------------
549
 
 
550
 
BarDescriptorDocumentArgNodeHandler::BarDescriptorDocumentArgNodeHandler(BarDescriptorEditorWidget *editorWidget)
551
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
552
 
{
553
 
}
554
 
 
555
 
bool BarDescriptorDocumentArgNodeHandler::canHandle(const QDomNode &node) const
556
 
{
557
 
    return canHandleSimpleTextElement(node, QLatin1String("arg"));
558
 
}
559
 
 
560
 
bool BarDescriptorDocumentArgNodeHandler::fromNode(const QDomNode &node)
561
 
{
562
 
    if (!canHandle(node))
563
 
        return false;
564
 
 
565
 
    generalWidget()->appendApplicationArgument(loadSimpleTextElement(node));
566
 
    return true;
567
 
}
568
 
 
569
 
QDomNode BarDescriptorDocumentArgNodeHandler::toNode(QDomDocument &doc) const
570
 
{
571
 
    QDomDocumentFragment frag = doc.createDocumentFragment();
572
 
 
573
 
    QStringList arguments = generalWidget()->applicationArguments();
574
 
    foreach (const QString &argument, arguments)
575
 
        frag.appendChild(createSimpleTextElement(doc, QLatin1String("arg"), argument));
576
 
 
577
 
    return frag;
578
 
}
579
 
 
580
 
// ----------------------------------------------------------------------------
581
 
 
582
 
BarDescriptorDocumentEnvNodeHandler::BarDescriptorDocumentEnvNodeHandler(BarDescriptorEditorWidget *editorWidget)
583
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
584
 
{
585
 
}
586
 
 
587
 
bool BarDescriptorDocumentEnvNodeHandler::canHandle(const QDomNode &node) const
588
 
{
589
 
    QDomElement element = node.toElement();
590
 
    if (element.isNull())
591
 
        return false;
592
 
 
593
 
    if (element.tagName() != QLatin1String("env"))
594
 
        return false;
595
 
 
596
 
    if (!element.hasAttribute(QLatin1String("var")) || !element.hasAttribute(QLatin1String("value")))
597
 
        return false;
598
 
 
599
 
    return true;
600
 
}
601
 
 
602
 
bool BarDescriptorDocumentEnvNodeHandler::fromNode(const QDomNode &node)
603
 
{
604
 
    if (!canHandle(node))
605
 
        return false;
606
 
 
607
 
    QDomElement element = node.toElement();
608
 
 
609
 
    QString var = element.attribute(QLatin1String("var"));
610
 
    QString value = element.attribute(QLatin1String("value"));
611
 
 
612
 
    Utils::EnvironmentItem item(var, value);
613
 
    environmentWidget()->appendEnvironmentItem(item);
614
 
    return true;
615
 
}
616
 
 
617
 
QDomNode BarDescriptorDocumentEnvNodeHandler::toNode(QDomDocument &doc) const
618
 
{
619
 
    QDomDocumentFragment frag = doc.createDocumentFragment();
620
 
    QList<Utils::EnvironmentItem> environmentItems = environmentWidget()->environment();
621
 
 
622
 
    foreach (const Utils::EnvironmentItem &item, environmentItems) {
623
 
        QDomElement element = doc.createElement(QLatin1String("env"));
624
 
        element.setAttribute(QLatin1String("var"), item.name);
625
 
        element.setAttribute(QLatin1String("value"), item.value);
626
 
        frag.appendChild(element);
627
 
    }
628
 
 
629
 
    return frag;
630
 
}
631
 
 
632
 
// ----------------------------------------------------------------------------
633
 
 
634
 
BarDescriptorDocumentAuthorNodeHandler::BarDescriptorDocumentAuthorNodeHandler(BarDescriptorEditorWidget *editorWidget)
635
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
636
 
{
637
 
}
638
 
 
639
 
bool BarDescriptorDocumentAuthorNodeHandler::canHandle(const QDomNode &node) const
640
 
{
641
 
    return canHandleSimpleTextElement(node, QLatin1String("author"))
642
 
            || canHandleSimpleTextElement(node, QLatin1String("publisher"));
643
 
}
644
 
 
645
 
bool BarDescriptorDocumentAuthorNodeHandler::fromNode(const QDomNode &node)
646
 
{
647
 
    if (!canHandle(node))
648
 
        return false;
649
 
 
650
 
    authorInformationWidget()->setAuthor(loadSimpleTextElement(node));
651
 
    return true;
652
 
}
653
 
 
654
 
QDomNode BarDescriptorDocumentAuthorNodeHandler::toNode(QDomDocument &doc) const
655
 
{
656
 
    return createSimpleTextElement(doc, QLatin1String("author"), authorInformationWidget()->author());
657
 
}
658
 
 
659
 
// ----------------------------------------------------------------------------
660
 
 
661
 
BarDescriptorDocumentAuthorIdNodeHandler::BarDescriptorDocumentAuthorIdNodeHandler(BarDescriptorEditorWidget *editorWidget)
662
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
663
 
{
664
 
}
665
 
 
666
 
bool BarDescriptorDocumentAuthorIdNodeHandler::canHandle(const QDomNode &node) const
667
 
{
668
 
    return canHandleSimpleTextElement(node, QLatin1String("authorId"));
669
 
}
670
 
 
671
 
bool BarDescriptorDocumentAuthorIdNodeHandler::fromNode(const QDomNode &node)
672
 
{
673
 
    if (!canHandle(node))
674
 
        return false;
675
 
 
676
 
    authorInformationWidget()->setAuthorId(loadSimpleTextElement(node));
677
 
    return true;
678
 
}
679
 
 
680
 
QDomNode BarDescriptorDocumentAuthorIdNodeHandler::toNode(QDomDocument &doc) const
681
 
{
682
 
    return createSimpleTextElement(doc, QLatin1String("authorId"), authorInformationWidget()->authorId());
683
 
}
684
 
 
685
 
// ----------------------------------------------------------------------------
686
 
 
687
 
BarDescriptorDocumentUnknownNodeHandler::BarDescriptorDocumentUnknownNodeHandler(BarDescriptorEditorWidget *editorWidget)
688
 
    : BarDescriptorDocumentAbstractNodeHandler(editorWidget)
689
 
{
690
 
}
691
 
 
692
 
bool BarDescriptorDocumentUnknownNodeHandler::canHandle(const QDomNode &node) const
693
 
{
694
 
    Q_UNUSED(node);
695
 
    return true;
696
 
}
697
 
 
698
 
bool BarDescriptorDocumentUnknownNodeHandler::fromNode(const QDomNode &node)
699
 
{
700
 
    m_node = node.cloneNode();
701
 
    return true;
702
 
}
703
 
 
704
 
QDomNode BarDescriptorDocumentUnknownNodeHandler::toNode(QDomDocument &doc) const
705
 
{
706
 
    Q_UNUSED(doc);
707
 
    return m_node;
708
 
}