|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ftuwizardloaderstate.h" |
|
20 #include "ftuwizardprovider.h" |
|
21 #include "ftucontentservice.h" |
|
22 #include <ftuwizardfactory.h> |
|
23 #include <ftuwizard.h> |
|
24 #include "ftutest_global.h" |
|
25 |
|
26 #include <QDebug> |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // FtuWizardLoaderState::FtuWizardLoaderState |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 FtuWizardLoaderState::FtuWizardLoaderState(QState *parent) : |
|
33 QState(parent), |
|
34 mWizardProvider(NULL) |
|
35 { |
|
36 mWizardProvider = new FtuWizardProvider(); |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // FtuWizardLoaderState::~FtuWizardLoaderState |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 FtuWizardLoaderState::~FtuWizardLoaderState() |
|
44 { |
|
45 delete mWizardProvider; |
|
46 } |
|
47 // --------------------------------------------------------------------------- |
|
48 // FtuWizardLoaderState::addWizard |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void FtuWizardLoaderState::addWizard(FtuWizard* wizard, bool success) |
|
52 { |
|
53 if(NULL!=wizard) { |
|
54 qDebug() << "Wizard " << wizard->objectName() << " initialized with " << success; |
|
55 } |
|
56 else { |
|
57 qFatal("void FtuWizardLoaderState::addWizard(FtuWizard* wizard, bool success): Null pointer argument wizard"); |
|
58 } |
|
59 |
|
60 if(wizard && success) |
|
61 { |
|
62 content()->appendWizard(wizard); |
|
63 |
|
64 // Disconnect the signal, for it is no longer needed. |
|
65 disconnect(wizard, SIGNAL(wizardInitialized(FtuWizard*, bool)), |
|
66 this, SLOT(addWizard(FtuWizard*, bool))); |
|
67 } |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // FtuWizardLoaderState::onEntry |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void FtuWizardLoaderState::onEntry(QEvent *event) |
|
75 { |
|
76 QState::onEntry(event); |
|
77 |
|
78 QList<FtuWizardFactory*> pluginList; |
|
79 mWizardProvider->loadFTUPlugins(pluginList); |
|
80 int size = pluginList.size(); |
|
81 |
|
82 if(size > 0) |
|
83 { |
|
84 for(int i = 0; i < size; i++) |
|
85 { |
|
86 FtuWizard* wizard = pluginList[i]->createWizard(); |
|
87 if(wizard) |
|
88 { |
|
89 |
|
90 connect(wizard, SIGNAL(wizardInitialized(FtuWizard*, bool)), |
|
91 this, SLOT(addWizard(FtuWizard*, bool))); |
|
92 wizard->initializeWizard(); |
|
93 } |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // FtuWizardLoaderState::onExit |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void FtuWizardLoaderState::onExit(QEvent *event) |
|
103 { |
|
104 QState::onExit(event); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 FtuContentService *FtuWizardLoaderState::content() const |
|
111 { |
|
112 return property(FTU_CONTENT_SERVICE_KEY).value<FtuContentService*>(); |
|
113 } |
|
114 |