src/hbwidgets/popups/hbprogressdialog.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
--- a/src/hbwidgets/popups/hbprogressdialog.cpp	Mon Apr 19 14:02:13 2010 +0300
+++ b/src/hbwidgets/popups/hbprogressdialog.cpp	Mon May 03 12:48:33 2010 +0300
@@ -23,147 +23,207 @@
 **
 ****************************************************************************/
 
-#include <hbnamespace_p.h>
-#include <hbiconitem.h>
-#include <hbaction.h>
 #include <hbprogressdialog.h>
 #include <hbprogressdialog_p.h>
 #include <hbstyleoptionprogressdialog.h>
-#include <hbstyleoptionprogressbar.h>
-#include <hbinstance.h>
+
+#include <hbnamespace_p.h>
+#include <hbaction.h>
+#include <hbpopup.h>
 #include <hbtextitem.h>
 #include <QGraphicsItem>
-#include <QDebug>
+
+/*
+    internal
+    HbProgressDialogContentWidget class
 
+    HbProgressDialogContentWidget is internal to HbProgressDialog and is the content widget to progressDialog
+
+    HbProgressDialogContentWidget holds the text, icon and progressbar.
+
+*/
 class HbProgressDialogContentWidget : public HbWidget
 {
     Q_OBJECT
-	public:
-	QGraphicsItem* mIconItem;
-	HbProgressBar* mPb;
-	QGraphicsItem *mText;// This will be HbTextItem and creation will delegate to style when it fixes the layout issue...
-	HbProgressDialogPrivate *d;
+    
+    public:
+    
+    QGraphicsItem *mIconItem;
+    HbProgressBar *mProgressBar;
+    QGraphicsItem *mTextItem;
+    HbProgressDialogPrivate *d;
+    
     enum { Type = HbPrivate::ItemType_ProgressDialogContentWidget };
     int type() const { return Type; }
-	HbProgressDialogContentWidget(HbProgressDialogPrivate *priv,QGraphicsItem* parent =0 ):HbWidget(parent),
-		mIconItem(0),mPb(0),mText(0),d(priv)
-	{
-       
-	    if( !mPb ){
-		    mPb = new HbProgressBar(HbProgressBar::SimpleProgressBar,this);
-	    }
-        
-		mText = style()->createPrimitive(HbStyle::P_ProgressDialog_text,this);
-        mIconItem = style()->createPrimitive(HbStyle::P_ProgressDialog_icon, this);
-		mIconItem->hide();
-        HbStyle::setItemName(mText, "text");
-        HbStyle::setItemName(mIconItem, "icon");
-        HbStyle::setItemName(mPb, "pbar");
     
-		setProperty("hasText",true);
-        setProperty("hasIcon",false);
-	    
-	}
-
-	void repolishContent()
-	{
-		repolish();
-	}
+    HbProgressDialogContentWidget(HbProgressDialogPrivate *priv,QGraphicsItem* parent =0 ):HbWidget(parent),
+        mIconItem(0),mProgressBar(0),mTextItem(0),d(priv)
+    {
+        setProperty("text",QVariant(true));
+        setProperty("icon",QVariant(false));
+    }
+  
+    void repolishContent()
+    {
+        repolish();
+    }
 };
 
-
+/*!
+    internal
 
-HbProgressDialogPrivate::HbProgressDialogPrivate() :
-mAction(0),mTimer(0),mContentWidget(0),mTextWrapping(true),mMinDuration(0),mDelayTime(0),mTextString(QString()),mAlign(Qt::AlignTop|Qt::AlignLeft)
+    HbProgressDialogPrivate class constructor
+*/
+HbProgressDialogPrivate::HbProgressDialogPrivate() :mAction(0),mTimer(0),mIcon(0),mContentWidget(0),
+                                                    mMinDuration(0),mDelayTime(0),mTextString(QString()),
+                                                    mAlign(Qt::AlignTop|Qt::AlignLeft)
 {
-	
 }
 
+/*!
+    internal
+
+    HbProgressDialogPrivate class destructor
+*/
 HbProgressDialogPrivate::~HbProgressDialogPrivate()
-{
-    
+{  
 }
 
+/*!
+    internal
 
+    initialises HbProgressDialogPrivate class 
+*/
 void HbProgressDialogPrivate::init(HbProgressDialog::ProgressDialogType type)
 {
     Q_Q(HbProgressDialog);
-   	mContentWidget = new HbProgressDialogContentWidget(this);
+    
+    mContentWidget = new HbProgressDialogContentWidget(this);
     q->setContentWidget(mContentWidget);
-	mNoteType = type ;
-   	
-	if(mNoteType == HbProgressDialog::WaitDialog){
-		mContentWidget->mPb->setRange(0,0);
-	}
-	else{
-		mContentWidget->mPb->setRange(0,100);
-	}
-	mAction = new HbAction(q->tr("Cancel"),q);
+    mNoteType = type ;
+        
+    createPrimitives();
+
+    if(mNoteType == HbProgressDialog::WaitDialog){
+        mContentWidget->mProgressBar->setRange(0,0);
+    }
+    else{
+        mContentWidget->mProgressBar->setRange(0,100);
+    }
+    
+    mAction = new HbAction(q->tr("Cancel"));
     QObject::connect(mAction, SIGNAL(triggered()), q, SLOT(_q_userCancel()));
     q->setPrimaryAction(mAction);
-	mMinDuration = 1500;
-	mDelayTime = 1000;
+    
+    mMinDuration = 1500;
+    mDelayTime = 1000;
 
     mTimer = new QTimeLine(mDelayTime, q);
-    mTimer->setFrameRange(0, 100);
-   
-	
+    mTimer->setFrameRange(0, 100);  
     QObject::connect(mTimer, SIGNAL(finished()), q, SLOT(_q_finished()));
+
     q->setTimeout(HbPopup::NoTimeout);
     q->setDismissPolicy(HbPopup::NoDismiss);
     q->setModal(false);
-    q->setBackgroundFaded(false);
     q->hide();
-	
-
-    
 }
 
+/*
+    internal
+
+    createPrimitives.
+ */
+void HbProgressDialogPrivate::createPrimitives()
+{
+    Q_Q(HbProgressDialog);
+
+    if( !mContentWidget->mProgressBar ){
+            mContentWidget->mProgressBar = new HbProgressBar(HbProgressBar::SimpleProgressBar,mContentWidget);
+            HbStyle::setItemName(mContentWidget->mProgressBar, "pbar");
+    }
+
+    if ( !mContentWidget->mTextItem ) {
+        mContentWidget->mTextItem = q->style()->createPrimitive(HbStyle::P_ProgressDialog_text,mContentWidget);
+        HbStyle::setItemName(mContentWidget->mTextItem, "text");
+    }
+
+    if ( !mIcon.isNull() ) {
+        if ( !mContentWidget->mIconItem ) {
+            mContentWidget->mIconItem = q->style()->createPrimitive(HbStyle::P_ProgressDialog_icon, mContentWidget); 
+            HbStyle::setItemName(mContentWidget->mIconItem, "icon");
+        }
+    } else {
+        if( mContentWidget->mIconItem ){
+            delete mContentWidget->mIconItem;
+        }
+        mContentWidget->mIconItem = 0;
+    }
+}
+
+/*!
+    internal
+
+    private slot which stops the timer and 
+    dismisses the dialog
+*/
 void HbProgressDialogPrivate::_q_userCancel()
 {
     Q_Q(HbProgressDialog);
-	flags &= ~HbProgressDialogPrivate::Closetimer;
-	mTimer->stop();
+    
+    flags &= ~HbProgressDialogPrivate::Closetimer;
+    mTimer->stop();
     q->cancel();
-	
 }
 
+/*!
+    internal
+
+    private slot which stops the timer and 
+    dismisses the dialog
+*/
 void HbProgressDialogPrivate::_q_finished()
 {
     Q_Q(HbProgressDialog);
 
-	if(flags.testFlag(HbProgressDialogPrivate::Showtimer)){
-            mTimer->stop();
-                        q->HbDialog::show();
-			mTimer->setDuration(mMinDuration);
-            mTimer->setCurrentTime(0);
-			mTimer->start();
-			flags &= ~HbProgressDialogPrivate::Showtimer;
-			flags |= HbProgressDialogPrivate::Closetimer;
-	}
-	else if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){
-		flags &= ~HbProgressDialogPrivate::Closetimer;
-		if(flags.testFlag(HbProgressDialogPrivate::Closepending)){
-			q->close();
-		}
-	}
+    if(flags.testFlag(HbProgressDialogPrivate::Showtimer)){
+        mTimer->stop();
+        q->HbDialog::show();
+        mTimer->setDuration(mMinDuration);
+        mTimer->setCurrentTime(0);
+        mTimer->start();
+        flags &= ~HbProgressDialogPrivate::Showtimer;
+        flags |= HbProgressDialogPrivate::Closetimer;
+    }
+    else if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){
+        flags &= ~HbProgressDialogPrivate::Closetimer;
+        if(flags.testFlag(HbProgressDialogPrivate::Closepending)){
+            q->close();
+        }
+    }
 }
 
+/*!
+    internal
+
+    private slot which stops the timer and 
+    dismisses the dialog
+*/
 void HbProgressDialogPrivate::_q_progressValueChanged(int value)
 {
-	 Q_Q(HbProgressDialog);
-	 if(value >= mContentWidget->mPb->maximum() && q->autoClose()){
-		 if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){
-			flags |= HbProgressDialogPrivate::Closepending;
-			flags &= ~HbProgressDialogPrivate::Showtimer;
-		 }
-		 else if(!flags.testFlag(HbProgressDialogPrivate::Showtimer)){
-			 q->close();
-		 }
-		 else{
-			 flags &= ~HbProgressDialogPrivate::Showtimer;
-		 }		 
-	 }
+    Q_Q(HbProgressDialog);
+    
+    if(value >= mContentWidget->mProgressBar->maximum() && q->autoClose()){
+        if(flags.testFlag(HbProgressDialogPrivate::Closetimer)){
+            flags |= HbProgressDialogPrivate::Closepending;
+            flags &= ~HbProgressDialogPrivate::Showtimer;
+        }
+        else if(!flags.testFlag(HbProgressDialogPrivate::Showtimer)){
+            q->close();
+        }
+        else{
+            flags &= ~HbProgressDialogPrivate::Showtimer;
+        }
+    }
 }
 
 
@@ -171,87 +231,143 @@
     @beta
     @hbwidgets
     \class HbProgressDialog
-    \brief HbProgressDialog is a notification widget that combines test, icon, and a progress bar.
-    
-    \image html hbprogressdialog.png A progress note.
+    \brief HbProgressDialog provides feedback on the progress of a slow operation.
+
+    \image html hbprogressnote.png  A progress dialog.
 
-    HbProgressDialog provides several types of notifications. The supported  types are:
+    ProgressDialog widget displays that a process is active and also the completion level of the process to the user.
+
+    A progress dialog is used to give the user an indication of how long an operation is going to take, and 
+    to demonstrate that the application has not frozen. It can also give the user an opportunity to abort the operation.
+
+    Progress dialog provides several types of notifications. The supported  types are:
     
     \code
     enum ProgressDialogType { ProgressDialog, WaitDialog };
     \endcode
 
-    \sa HbDialog
+    Progress dialog has the following mandatory elements:
+    \li Progress bar (Determinate type) 
+    \li Description
+    \li Cancel button (for canceling the process) 
 
-    Progress dialog has a number of use cases. Depending on the use case, either the value of the progress bar
-    is updated  manually or waiting progress bar will be shown. The former case is used when displaying a download note.
-    The latter case is used when connecting to network or opening a web page. The examples below demonstrate the use
-    cases.
+    Optionally, progress dialog may also includes:
+    \li  Icon
+    \li  Heading
+    \li  Close button (same as ‘Cancel’ button during active process, closes the dialog after successful process)
+
+    Progress dialog is modal and requires user intervention to dismiss it. 
+    \sa HbDialog
 
     The first example is a dialog  displayed when the application is connecting
     to network. As the delay is unknown the waiting progressbar will be shown indefinitely. 
-    The note disappears if the user clicks Cancel button or
-    after the connection is established in which case the application closes the progress note.
+    The dialog disappears if the user clicks Cancel button or
+    after the connection is established in which case the application closes the progress dialog.
 
-    Here is an example of using the infinite progress note:
+    Here is an example of using the infinite progress dialog(wait dialog):
     
     \code
-    HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::WaitDialog);
-    note->show();
+    HbProgressDialog *pDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
+    pDialog->show();
     \endcode
 
-    The progress note is closed explicitly when the user clicks Cancel button or the application calls cancel().
+    The progress note is closed explicitly when the user clicks Cancel button or the application 
+    calls cancel().
 
     Another use case is an application downloading a file. 
     \code
-    HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog);
-    note->setMinimum(0);
-    note->setMaximum(1000);
-    note->show();
+    HbProgressDialog *pDialog = new HbProgressDialog(HbProgressDialog::ProgressDialog);
+    pDialog->setMinimum(0);
+    pDialog->setMaximum(1000);
+    pDialog->show();
     for (int i=0;i<1000;i+=100) 
     {
-      note->setProgressValue(i);
-      note->setText(QString("Downloaded %1/1000 KB").arg(i));
+      pDialog->setProgressValue(i);
+      pDialog->setText(QString("Downloaded %1/1000 KB").arg(i));
     }
 
     \endcode
 */
 
 /*!
-    @beta
-    Constructor.
+    \fn void HbProgressDialog::cancelled()
+
+    This signal is emitted when the user clicks the cancel action.
+ */
+
+/*!
+    \enum HbProgressDialog::ProgressDialogType
+
+    This enum defines available progress dialog type values.
+
+ */
+
+/*!
+    \var HbProgressDialog::ProgressDialog
+
+    This enum describes the type value as ProgressDialog.
+ */
 
-    \param type Must be one of the defined ProgressDialogType enumerations.
-    \param parent An optional parameter.
+/*!
+    \var HbProgressDialog::WaitDialog
+
+    TThis enum describes the type value as WaitDialog.
+ */
+
 
+/*!
+    @beta
+    Constructs a new HbProgressDialog with \a type and \a parent.
+
+    \param type ProgressDialogType.
+    \param parent  progress dialog's parent.
+    
+    Default settings:
+    \li The text is empty.
+    \li The icon is null.
+    \li The cancel button text is (translated) "Cancel".
 */
-
 HbProgressDialog::HbProgressDialog(ProgressDialogType type, QGraphicsItem *parent) :
     HbDialog(*new HbProgressDialogPrivate, parent)
 {
     Q_D(HbProgressDialog);
+
     d->init(type);
-	setAutoClose(true);
+    setAutoClose(true);
 }
 
 /*!
     @beta
-    Constructor.
-
-    \param parent An optional parameter.
-
+    Constructs a new HbProgressDialog with \a parent.
+    
+    Default settings:
+    \li The text is empty.
+    \li The icon is null.
+    \li The cancel button text is (translated) "Cancel".
+    \li minimum is 0;
+    \li maximum is 100
+    
+    The parent argument is dialog's parent widget.
 */
 HbProgressDialog::HbProgressDialog(QGraphicsItem *parent) :
     HbDialog(*new HbProgressDialogPrivate, parent)
 {
     Q_D(HbProgressDialog);
+
     d->init(ProgressDialog);
     setAutoClose(true);
 }
 
 /*!
+    Destructs the progressDialog.
+*/
+HbProgressDialog::~HbProgressDialog()
+{
+}
+
+/*!
     @beta
-    Returns the maximum value of the progressbar within the note.
+    Returns the maximum value of the progressbar within the progressdialog.
 
     The default value is \c 100.
 
@@ -261,13 +377,12 @@
 {
     Q_D(const HbProgressDialog);
 
-    return d->mContentWidget->mPb->maximum();
+    return d->mContentWidget->mProgressBar->maximum();
 }
 
-
 /*!
     @beta
-    Sets the maximum value of the progressbar within the note.
+    Sets the maximum value of the progressbar within the progressdialog.
 
     \sa maximum()
 */
@@ -275,12 +390,12 @@
 {
     Q_D(HbProgressDialog);
 
-    d->mContentWidget->mPb->setMaximum(max);
+    d->mContentWidget->mProgressBar->setMaximum(max);
 }
 
 /*!
     @beta
-    Returns the minimum value of the progressbar within the note.
+    Returns the minimum value of the progressbar within the progressdialog.
 
     The default value is \c 0.
 
@@ -289,12 +404,15 @@
 int HbProgressDialog::minimum() const
 {
     Q_D(const HbProgressDialog);
-    return d->mContentWidget->mPb->minimum();
+
+    return d->mContentWidget->mProgressBar->minimum();
 }
 
 /*!
     @beta
-    Sets the minimum value of the progressbar within the note.
+    Sets the minimum value of the progressbar within the progressdialog.
+
+    \param min minimum value of the progressbar.
 
     \sa minimum()
 */
@@ -302,12 +420,17 @@
 {
     Q_D(HbProgressDialog);
 
-    d->mContentWidget->mPb->setMinimum(min);
+    d->mContentWidget->mProgressBar->setMinimum(min);
 }
 
 /*!
     @beta
-    Sets the minimum and maximum value of the progressbar within the note.
+    Sets the progress dialog's minimum and maximum values to minimum and maximum, respectively.
+
+    If maximum is smaller than minimum, minimum becomes the only legal value.
+
+    \param min minimum value of the progressbar within the progressdialog
+    \param max maximum value of the progressbar within the progressdialog
 
     \sa minimum()
     \sa maximum()
@@ -315,51 +438,51 @@
 void HbProgressDialog::setRange(int min,int max)
 {
     Q_D(HbProgressDialog);
-    d->mContentWidget->mPb->setRange(min,max);
+    
+    d->mContentWidget->mProgressBar->setRange(min,max);
 }
 
 /*!
     @beta
-  Returns the value of the progressbar within the note.
+    Returns the value of the progressbar within the note.
 
-  This value is constrained as follows:
-  \b minimum <= \c value <= \b maximum.
+    This value is constrained as follows:
+    \b minimum <= \c value <= \b maximum.
 
-  \sa setValue()
-
+    \sa setValue()
  */
 int HbProgressDialog::progressValue() const
 {
     Q_D(const HbProgressDialog);
 
-    return d->mContentWidget->mPb->progressValue();
+    return d->mContentWidget->mProgressBar->progressValue();
 }
 
 /*!
     @beta
-  Sets the value of the progressbar within the note.
-  After the timeline has been started the value is updated automatically.
-  Use this function only if the timer is not used.
+    Sets the value of the progressbar within the progress dialog.
+    After the timeline has been started the value is updated automatically.
+    Use this function only if the timer is not used.
 
-  This value is constrained as follows:
-  \b minimum <= \c value <= \b maximum.
+    This value is constrained as follows:
+    \b minimum <= \c value <= \b maximum.
 
- \sa value()
+    \param value progressbar value
 
+    \sa value()
 */
 void HbProgressDialog::setProgressValue(int value)
 {
     Q_D(HbProgressDialog);
 
-    d->mContentWidget->mPb->setProgressValue(value);
-	d->_q_progressValueChanged(value);
+    d->mContentWidget->mProgressBar->setProgressValue(value);
+    d->_q_progressValueChanged(value);
 }
 
 /*!
     @beta
-  Closes the popup while emitting the cancelled() signal. This function is called when 
-  user presses the Cancel button or then the timer expires.
-
+    Closes the dialog while emitting the cancelled() signal. This function is called when 
+    user presses the Cancel button or then the timer expires.
  */
 void HbProgressDialog::cancel() 
 {
@@ -367,110 +490,140 @@
     close();
 }
 
+/*!
+
+    \deprecated HbProgressDialog::primitive(HbStyle::Primitive)
+        is deprecated.
+
+    Returns the pointer for \a primitive passed.
+    Will return NULL if \a primitive passed is invalid
+*/
 QGraphicsItem* HbProgressDialog::primitive(HbStyle::Primitive primitive) const
 {
     Q_D(const HbProgressDialog);
+
     switch (primitive) {
-        case HbStyle::P_Popup_background:
-            return HbDialog::primitive(primitive);
         case HbStyle::P_ProgressDialog_icon:
             return d->mContentWidget->mIconItem;
+        case HbStyle::P_ProgressDialog_text:
+            return d->mContentWidget->mTextItem;
         default:
             return 0;
-        }    
+        }
 }
 
 /*!
     @beta
-  Sets the progressdialog type. 
-  \sa progressDialogType()
+    Sets the progressdialog type. 
+
+    The type of the progress dialog can be specified with one of the values:
+    \li HbProgressDialog::ProgressDialog
+    \li HbProgressDialog::WaitDialog
+    \sa progressDialogType()
  */
 void HbProgressDialog::setProgressDialogType(HbProgressDialog::ProgressDialogType type)
 {
     Q_D(HbProgressDialog);
-	if(d->mNoteType != type) {
-		d->mNoteType = type;
-		if(type == WaitDialog){
-			d->mContentWidget->mPb->setRange(0,0);
-		}
-		else {
-			d->mContentWidget->mPb->setRange(0,100);
-		}
-	}
+    
+    if(d->mNoteType != type) {
+        d->mNoteType = type;
+        if(type == WaitDialog){
+            d->mContentWidget->mProgressBar->setRange(0,0);
+        }
+        else {
+            d->mContentWidget->mProgressBar->setRange(0,100);
+        }
+    }
 }
 
 /*!
     @beta
-  returns progressDialog type;
-   \sa setProgressDialogType()
+    Returns progressDialog type.
+    \sa setProgressDialogType()
  */
 HbProgressDialog::ProgressDialogType HbProgressDialog::progressDialogType() const
 {
     Q_D(const HbProgressDialog);
+    
     return d->mNoteType;
 }
-  
-
-void HbProgressDialog::showEvent(QShowEvent *event)
-{
-    Q_D(HbProgressDialog);
-	d->mContentWidget->mPb->show();
-        HbDialog::showEvent(event);
-}
 
 /*!
     @beta
-  Shows the Note after a delay(say 1sec). This is a convenient slot
-  if user cancels note before delay expired note wont be shown at all 
+    Shows the progress dialog after a delay(say 1sec). This is a convenient slot.
+    if user cancels progress dialog before delay getting expired, then progress dialog wont be shown at all 
  */
 void HbProgressDialog::delayedShow()
 {
-		Q_D(HbProgressDialog);
-		d->flags |= HbProgressDialogPrivate::Showtimer;
-		d->mTimer->setDuration(d->mDelayTime);
-		d->mTimer->start();		
+    Q_D(HbProgressDialog);
+    
+    d->flags |= HbProgressDialogPrivate::Showtimer;
+    d->mTimer->setDuration(d->mDelayTime);
+    d->mTimer->start();     
+}
+
+/*!
+    @beta
+    Returns the auto close flag.
+    \sa setAutoClose()
+ */
+bool HbProgressDialog::autoClose () const 
+{
+    Q_D(const HbProgressDialog);
+    
+    return d->flags.testFlag(HbProgressDialogPrivate::Autoclose);
 }
 
 /*!
     @beta
-  Returns the auto close flag.
+    Sets the auto close flag.
+    \sa autoClose()
  */
-bool HbProgressDialog::autoClose () const 
+void HbProgressDialog::setAutoClose ( bool close )
 {
-	Q_D(const HbProgressDialog);	
-	return d->flags.testFlag(HbProgressDialogPrivate::Autoclose);
+    Q_D(HbProgressDialog);
+    
+    close?d->flags 
+        |= HbProgressDialogPrivate::Autoclose : d->flags &= ~HbProgressDialogPrivate::Autoclose;
 }
 
 /*!
-    @beta
-  Sets the auto close flag.
+    Initializes \a option with the values from this HbProgressDialog. 
+    This method is useful for subclasses when they need a HbStyleOptionProgressDialog,
+    but don't want to fill in all the information themselves.
  */
-void HbProgressDialog::setAutoClose ( bool b )
+void HbProgressDialog::initStyleOption(HbStyleOptionProgressDialog *option) const
 {
-    Q_D(HbProgressDialog);
-	b?d->flags 
-		|= HbProgressDialogPrivate::Autoclose : d->flags &= ~HbProgressDialogPrivate::Autoclose;
+    Q_D(const HbProgressDialog);
+
+    HbDialog::initStyleOption(option);
+
+    option->progressBarSize = d->mContentWidget->mProgressBar->minimumSize();
+    option->icon = d->mIcon;
+    option->iconAlignment = d->mIconAlignment;
+    option->text = d->mTextString;
+    option->textAlignment = d->mAlign;
 }
 
-void HbProgressDialog::initStyleOption(HbStyleOption *option) const
+/*!
+    \reimp
+ */
+void HbProgressDialog::showEvent(QShowEvent *event)
 {
-	Q_D(const HbProgressDialog);
-	HbStyleOptionProgressDialog* progressDialogOption 
-		= qstyleoption_cast< HbStyleOptionProgressDialog *>(option);
-	
-    HbDialog::initStyleOption(progressDialogOption);
-	progressDialogOption->progressBarSize = d->mContentWidget->mPb->minimumSize();
-    progressDialogOption->icon = d->mIcon;
-    progressDialogOption->iconAlignment = d->mIconAlignment;
-	progressDialogOption->text = d->mTextString;
-	progressDialogOption->wrap = d->mTextWrapping;
-	progressDialogOption->textAlignment = d->mAlign;
+    Q_D(HbProgressDialog);
+    
+    d->mContentWidget->mProgressBar->show();
+    HbDialog::showEvent(event);   
+}
 
-}
+/*!
+    \reimp
+ */
 void HbProgressDialog::closeEvent ( QCloseEvent * event )
 {
     Q_D(HbProgressDialog);
-	d->mAction->setToolTip("");
+    
+    d->mAction->setToolTip("");
     if(d->flags.testFlag(HbProgressDialogPrivate::Closetimer)){
         d->flags |= HbProgressDialogPrivate::Closepending;
         event->setAccepted(false);
@@ -480,76 +633,98 @@
         d->mTimer->stop();
         d->flags &= ~HbProgressDialogPrivate::Showtimer;
     }
-    d->mContentWidget->mPb->close();
-    HbDialog::closeEvent(event);
-	
+    d->mContentWidget->mProgressBar->close();
+    HbDialog::closeEvent(event);    
 }
 
 /*!
     @beta
-    Sets text of the note.
+    Sets the text to be shown on progress dialog.
+    
+    \param text user defined text.
+
     \sa text()
 */
 void HbProgressDialog::setText(const QString &text)
 {
     Q_D(HbProgressDialog);
-	if ( text != d->mTextString) {
-		d->mTextString = text;
-		HbStyleOptionProgressDialog progressDialogOption;
-        initStyleOption(&progressDialogOption);
-		style()->updatePrimitive(d->mContentWidget->mText, HbStyle::P_ProgressDialog_text, &progressDialogOption);
-	}
+    
+    if ( text != d->mTextString) {
+        d->mTextString = text;
+        d->createPrimitives();
+
+        if(d->mContentWidget->mTextItem)
+        {
+            HbStyleOptionProgressDialog progressDialogOption;
+            initStyleOption(&progressDialogOption);
+            style()->updatePrimitive(d->mContentWidget->mTextItem, HbStyle::P_ProgressDialog_text, &progressDialogOption);
+        }
+    }
 }
+
 /*!
     @beta
-    Returns text of the note.
+    Returns the  text shown on progress dialog.
+
+    The default text is an empty string.
     \sa setText()
 */
 QString HbProgressDialog::text() const
 {
     Q_D(const HbProgressDialog);
-	return d->mTextString;
+
+    return d->mTextString;
 }
 
-
 /*!
     @beta
-    Sets icon for the note.
+    Sets  the icon to be shown on progress dialog.
+
+    \param icon user defined icon.
     \sa icon()
 */
 void HbProgressDialog::setIcon(const HbIcon &icon)
 {
     Q_D(HbProgressDialog);
+    
     if (icon != d->mIcon){
         d->mIcon = icon;
+        d->createPrimitives();
+
         if (d->mContentWidget->mIconItem) {
-			d->mContentWidget->mIconItem->show();
-			d->mContentWidget->setProperty("hasIcon",true);
+            d->mContentWidget->setProperty("icon",true);
+
             HbStyleOptionProgressDialog progressDialogOption;
             initStyleOption(&progressDialogOption);
             style()->updatePrimitive(d->mContentWidget->mIconItem, HbStyle::P_ProgressDialog_icon, &progressDialogOption);
-			d->mContentWidget->repolishContent();
         }
-
-		
-	}
+        else
+        {
+            d->mContentWidget->setProperty("icon",false);
+        }
+        d->mContentWidget->repolishContent();
+    }
 }
 
-
 /*!
     @beta
-    Returns icon of the note.
+    Returns the  icon shown on progress dialog.
+
+    The default icon is a null icon.
     \sa setIcon()
 */
 HbIcon HbProgressDialog::icon() const
 {
     Q_D(const HbProgressDialog);
+
     return d->mIcon;
 }
 
 
 /*!
-    @deprecated
+    \deprecated HbProgressDialog::setTextAlignment( Qt::Alignment )
+        is deprecated.
+
     Sets the text alignment.
     \param align Qt defined alignment options can used.
 
@@ -559,32 +734,38 @@
 */
 void HbProgressDialog::setTextAlignment( Qt::Alignment align )
 {
-	
     Q_D(HbProgressDialog);
-	if (align != d->mAlign ) {
-		d->mAlign = align;
-	    HbStyleOptionProgressDialog progressDialogOption;
-        initStyleOption(&progressDialogOption);
-		style()->updatePrimitive(d->mContentWidget->mText, HbStyle::P_ProgressDialog_text, &progressDialogOption);
-       
-   }
+    
+    if (align != d->mAlign ){
+        d->mAlign = align;
+        if(d->mContentWidget->mTextItem)
+        {
+            HbStyleOptionProgressDialog progressDialogOption;
+            initStyleOption(&progressDialogOption);
+            style()->updatePrimitive(d->mContentWidget->mTextItem, HbStyle::P_ProgressDialog_text, &progressDialogOption); 
+        }
+    }
 }
 
 /*!
-    @deprecated
+    \deprecated HbProgressDialog::textAlignment() const
+        is deprecated.
+
     Returns the text alignment.
 
     \sa setTextAlignment()
 */
 Qt::Alignment HbProgressDialog::textAlignment() const
 {
-	Q_D(const HbProgressDialog);
-	return d->mAlign;
+    Q_D(const HbProgressDialog);
+    
+    return d->mAlign;
 }
 
+/*!
+   \deprecated HbProgressDialog::setIconAlignment( Qt::Alignment )
+        is deprecated.
 
-/*!
-    @deprecated
     Sets the icon alignment.
 
     \param align Qt defined alignment options can used.
@@ -596,6 +777,7 @@
 void HbProgressDialog::setIconAlignment( Qt::Alignment align )
 {
     Q_D(HbProgressDialog);
+    
     if (align != d->mIconAlignment){
         d->mIconAlignment = align;
         if (d->mContentWidget->mIconItem) {
@@ -608,7 +790,9 @@
 
 
 /*!
-    @deprecated
+    \deprecated HbProgressDialog::iconAlignment() const
+        is deprecated.
+
     Returns the icon alignment.
 
     \sa setIconAlignment()
@@ -616,6 +800,7 @@
 Qt::Alignment HbProgressDialog::iconAlignment() const
 {
     Q_D(const HbProgressDialog);
+
     return d->mIconAlignment;
 }