iaupdate/IAD/ui/src/iaupdatedialogutil.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 13:45:18 +0300
changeset 42 d17dc5398051
child 44 329d304c1aa1
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   This module contains the implementation of IAUpdateDialogUtil class 
*                member functions.
*
*/
#include <hbtextitem.h>
#include <hbmessagebox.h>

#include "iaupdatedialogutil.h"
#include "iaupdatedialogobserver.h"
#include "iaupdatedebug.h"



IAUpdateDialogUtil::IAUpdateDialogUtil(QObject *parent, IAUpdateDialogObserver *observer)
: QObject(parent),
  mObserver(observer)
{
    IAUPDATE_TRACE("[IAUPDATE] IAUpdateDialogUtil::IAUpdateDialogUtil()");
}

IAUpdateDialogUtil::~IAUpdateDialogUtil()
{
    IAUPDATE_TRACE("[IAUPDATE] IAUpdateDialogUtil::~IAUpdateDialogUtil()");
}


void IAUpdateDialogUtil::showInformation(const QString &text, HbAction *primaryAction)
{    
    HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); 
    messageBox->setText(text);
    int actionCount = messageBox->actions().count();
    for (int i=actionCount-1; i >= 0; i--)
    { 
        messageBox->removeAction(messageBox->actions().at(i));
    }
    if (primaryAction)
    {    
        messageBox->addAction(primaryAction);
    }  
    messageBox->setTimeout(HbPopup::NoTimeout); 
    messageBox->setAttribute(Qt::WA_DeleteOnClose);
    messageBox->open(this,SLOT(finished(HbAction*)));
}


void IAUpdateDialogUtil::showQuestion(const QString &text, HbAction *primaryAction, HbAction *secondaryAction)
{
    HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); 
    messageBox->setIconVisible(false);
    messageBox->setText(text);
    int actionCount = messageBox->actions().count();
    for (int i=actionCount-1; i >= 0; i--)
    { 
        messageBox->removeAction(messageBox->actions().at(i));
    }
    if (primaryAction)
    {    
        messageBox->addAction(primaryAction);
    }
    if (secondaryAction)
    {    
        messageBox->addAction(secondaryAction);
    } 
    messageBox->setTimeout(HbPopup::NoTimeout); 
    messageBox->setAttribute(Qt::WA_DeleteOnClose);
    messageBox->open(this,SLOT(finished(HbAction*)));
}


void IAUpdateDialogUtil::showAgreement(HbAction *primaryAction, HbAction *secondaryAction)
{
    HbMessageBox *agreementDialog = new HbMessageBox(HbMessageBox::MessageTypeQuestion); 
    agreementDialog->setIconVisible(false);
    agreementDialog->setText("This application allows you to download and use applications and services provided by Nokia or third parties. Service Terms and Privacy Policy will apply. Nokia will not assume any liability or responsibility for the availability or third party applications or services. Before using the third party application or service, read the applicable terms of use.\n\nUse of this application involves transmission of data. Contact your network service provider for information about data transmission charges.\n\n(c) 2007-2010 Nokia. All rights reserved.");

    int actionCount = agreementDialog->actions().count();
    for (int i=actionCount-1; i >= 0; i--)
    { 
        agreementDialog->removeAction(agreementDialog->actions().at(i));
    }
    if (primaryAction)
    {    
        agreementDialog->addAction(primaryAction);
    }    
    if (secondaryAction)
    {
        agreementDialog->addAction(secondaryAction);
    }
    agreementDialog->setTimeout(HbPopup::NoTimeout);
    agreementDialog->setAttribute(Qt::WA_DeleteOnClose);
    agreementDialog->open(this,SLOT(finished(HbAction*)));
}



void IAUpdateDialogUtil::finished(HbAction *action)
{
    if (mObserver)
    {
        mObserver->dialogFinished(action);
    }
}