controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp
changeset 21 2883a5458389
parent 19 36aa4756ee82
child 22 a5692c68d772
--- a/controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp	Tue May 25 04:10:19 2010 +0800
+++ b/controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp	Thu Jun 10 16:07:41 2010 +0800
@@ -34,6 +34,7 @@
 #include "tonefetcherview.h"
 #include "tonefetchermodel.h"
 #include <hbmessagebox.h>
+#include <hbprogressdialog.h>
 
 ToneFetcherWidget::ToneFetcherWidget( ToneFetcherView *serviceView  ) 
     : HbWidget(this),
@@ -42,7 +43,8 @@
       mLayout(0),
       mToneModel(0),
       mServiceView(serviceView),         
-      mServiceEngine(0)
+      mServiceEngine(0),
+      mWaitNote(0)
       
 {
     mSelected = false;
@@ -60,11 +62,18 @@
            this, SLOT(previewEvent(ToneServiceEngine::TPreviewEvent, int)));
     connect( mServiceEngine, SIGNAL(notifyObjectChanged()),
             this, SLOT(onObjectChanged()));
+    connect( mServiceEngine, SIGNAL(notifyRefreshStart()),
+                this, SLOT(refreshStart()));
+    connect( mServiceEngine, SIGNAL(notifyRefreshFinish()),
+                this, SLOT(refreshFinish()));
 }
 
 ToneFetcherWidget::~ToneFetcherWidget()
 {
-    delete mToneModel;    
+    delete mToneModel;
+    mToneModel = 0;
+    delete mWaitNote;
+    mWaitNote = 0;
 }
 
 void ToneFetcherWidget::on_list_activated(const QModelIndex &index)
@@ -73,7 +82,7 @@
     
     //stop previewing when clicking another item.
     if (mServiceEngine->IsPlaying()) {
-        mServiceEngine->preview(getCurrentItemPath());
+        mServiceEngine->stop();
     }
     /*
      * when one item is selected, reselecting it will deselect it. selecting another 
@@ -125,6 +134,12 @@
     
     connect(mListView, SIGNAL(activated(QModelIndex)),
         this, SLOT(on_list_activated(QModelIndex )));
+    if( !mWaitNote ){
+        mWaitNote = new HbProgressDialog( HbProgressDialog::WaitDialog );
+        mWaitNote->setText( hbTrId( "Refreshing..." ) );
+        QAction *action = mWaitNote->actions().at(0);//disable Cancel buttion.
+        action->setEnabled(false);
+    }
 }
 
 void ToneFetcherWidget::mdeSessionOpened()
@@ -171,7 +186,12 @@
 
 void ToneFetcherWidget::playOrPause() 
 {
+    if(mServiceEngine->IsPlaying()) {
+        mServiceEngine->stop();
+    } else {    
     mServiceEngine->preview(getCurrentItemPath());
+    }
+    
 }
 
 void ToneFetcherWidget::previewEvent(ToneFetcherEngine::TPreviewEvent event, int errorId) 
@@ -186,6 +206,11 @@
 
 void ToneFetcherWidget::onObjectChanged()
 {
+    if (mServiceEngine->IsPlaying()) {
+        mServiceEngine->stop();      
+    }
+    emit triggerToolBar(false);
+    mToneModel->toBeFreshed();
     mToneModel->clearAll();
     mDigitalSoundList.clear();
     mSimpleSoundList.clear();
@@ -217,4 +242,18 @@
         mToneModel->insertInOrder(fileName, filePath);  
     }
 }
+
+void ToneFetcherWidget::refreshFinish()
+{
+    if (mWaitNote) {
+        mWaitNote->close();
+    }
+}
+
+void ToneFetcherWidget::refreshStart()
+{
+    if (mWaitNote) {
+        mWaitNote->open();
+    }
+}
 //End of File