fturuntimeservices/src/ftucontentservice.cpp
changeset 0 c464cd7e2753
equal deleted inserted replaced
-1:000000000000 0:c464cd7e2753
       
     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:  First Time Use runtime content service.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ftucontentservice.h"
       
    20 #include "ftucontentservice_p.h"
       
    21 #include <ftuwizard.h>
       
    22 
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // FtuContentServicePrivate::FtuContentServicePrivate()
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 FtuContentServicePrivate::FtuContentServicePrivate(FtuContentService *ftuContentService)
       
    29     : QObject(ftuContentService),
       
    30       mFtuContentService(ftuContentService),
       
    31       mActiveWizardIndex(-1)
       
    32 {
       
    33 
       
    34 }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // FtuContentServicePrivate::~FtuContentServicePrivate()
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 FtuContentServicePrivate::~FtuContentServicePrivate()
       
    41 {
       
    42     qDeleteAll(mWizardList);
       
    43 }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // FtuContentServicePrivate::appendWizard()
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void FtuContentServicePrivate::appendWizard(FtuWizard *wizard)
       
    50 {
       
    51     if (wizard && mWizardList.contains(wizard)) {
       
    52         return;
       
    53     }
       
    54 
       
    55     mWizardList.append(wizard);
       
    56 
       
    57     if (wizard) {
       
    58         int index = mWizardList.size() - 1;
       
    59         emit mFtuContentService->wizardAdded(index);
       
    60     }
       
    61 }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // FtuContentServicePrivate::insertWizard()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void FtuContentServicePrivate::insertWizard(int index, FtuWizard *wizard)
       
    68 {
       
    69     if (wizard && mWizardList.contains(wizard)) {
       
    70         return;
       
    71     }
       
    72 
       
    73     if (index < 0 || mWizardList.count() < index) {
       
    74         return;
       
    75     }
       
    76 
       
    77     mWizardList.insert(index, wizard);
       
    78 
       
    79     if (wizard) {
       
    80         emit mFtuContentService->wizardAdded(index);
       
    81     }
       
    82 }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // FtuContentServicePrivate::setActiveWizard()
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void FtuContentServicePrivate::setActiveWizard(int index)
       
    89 {
       
    90     if (index < 0 || mWizardList.count() <= index) {
       
    91         index = -1;
       
    92     }
       
    93 
       
    94     mActiveWizardIndex = index;
       
    95 }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // FtuContentServicePrivate::activeWizard()
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 int FtuContentServicePrivate::activeWizard() const
       
   102 {
       
   103     return mActiveWizardIndex;
       
   104 }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // FtuContentServicePrivate::wizard()
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 FtuWizard* FtuContentServicePrivate::wizard(int index) const
       
   111 {
       
   112     if (index < 0 || mWizardList.count() <= index) {
       
   113         return 0;
       
   114     }
       
   115 
       
   116     return mWizardList[index];
       
   117 }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // FtuContentServicePrivate::wizards()
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 QList<FtuWizard*> FtuContentServicePrivate::wizards() const
       
   124 {
       
   125     return mWizardList;
       
   126 }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // FtuContentService::FtuContentService()
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 FtuContentService::FtuContentService(QObject *parent)
       
   133     : QObject(parent),
       
   134 	  mFtuContentServicePrivate(NULL)
       
   135 {
       
   136     mFtuContentServicePrivate = new FtuContentServicePrivate(this);    
       
   137 }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // FtuContentService::~FtuContentService()
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 FtuContentService::~FtuContentService()
       
   144 {
       
   145     if(mFtuContentServicePrivate)
       
   146 	{
       
   147 		delete mFtuContentServicePrivate;
       
   148 	}
       
   149 }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // FtuContentService::appendWizard()
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void FtuContentService::appendWizard(FtuWizard *wizard)
       
   156 {
       
   157     mFtuContentServicePrivate->appendWizard(wizard);
       
   158 }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // FtuContentService::insertWizard()
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void FtuContentService::insertWizard(int index, FtuWizard *wizard)
       
   165 {
       
   166     mFtuContentServicePrivate->insertWizard(index, wizard);
       
   167 }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // FtuContentService::setActiveWizard()
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 void FtuContentService::setActiveWizard(int index)
       
   174 {
       
   175     mFtuContentServicePrivate->setActiveWizard(index);
       
   176 }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // FtuContentService::activeWizard()
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 int FtuContentService::activeWizard() const
       
   183 {
       
   184     return mFtuContentServicePrivate->activeWizard();
       
   185 }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // FtuContentService::wizard()
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 FtuWizard *FtuContentService::wizard(int index) const
       
   192 {
       
   193     return mFtuContentServicePrivate->wizard(index);
       
   194 }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // FtuContentService::wizards()
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 QList<FtuWizard*> FtuContentService::wizards() const
       
   201 {
       
   202     return mFtuContentServicePrivate->wizards();
       
   203 }