controlpanelui/src/tonefetcher/src/tonefetcherwidget.cpp
changeset 21 2883a5458389
parent 19 36aa4756ee82
child 22 a5692c68d772
equal deleted inserted replaced
20:22d3abee08da 21:2883a5458389
    32 #include <XQUtils>
    32 #include <XQUtils>
    33 #include <hblabel.h>
    33 #include <hblabel.h>
    34 #include "tonefetcherview.h"
    34 #include "tonefetcherview.h"
    35 #include "tonefetchermodel.h"
    35 #include "tonefetchermodel.h"
    36 #include <hbmessagebox.h>
    36 #include <hbmessagebox.h>
       
    37 #include <hbprogressdialog.h>
    37 
    38 
    38 ToneFetcherWidget::ToneFetcherWidget( ToneFetcherView *serviceView  ) 
    39 ToneFetcherWidget::ToneFetcherWidget( ToneFetcherView *serviceView  ) 
    39     : HbWidget(this),
    40     : HbWidget(this),
    40       mLabel(0),
    41       mLabel(0),
    41       mListView(0),
    42       mListView(0),
    42       mLayout(0),
    43       mLayout(0),
    43       mToneModel(0),
    44       mToneModel(0),
    44       mServiceView(serviceView),         
    45       mServiceView(serviceView),         
    45       mServiceEngine(0)
    46       mServiceEngine(0),
       
    47       mWaitNote(0)
    46       
    48       
    47 {
    49 {
    48     mSelected = false;
    50     mSelected = false;
    49     init();
    51     init();
    50     connect(mServiceEngine, SIGNAL(mdeSessionOpened()), 
    52     connect(mServiceEngine, SIGNAL(mdeSessionOpened()), 
    58     connect(mServiceEngine, 
    60     connect(mServiceEngine, 
    59            SIGNAL(notifyPreviewEvent(ToneServiceEngine::TPreviewEvent, int)), 
    61            SIGNAL(notifyPreviewEvent(ToneServiceEngine::TPreviewEvent, int)), 
    60            this, SLOT(previewEvent(ToneServiceEngine::TPreviewEvent, int)));
    62            this, SLOT(previewEvent(ToneServiceEngine::TPreviewEvent, int)));
    61     connect( mServiceEngine, SIGNAL(notifyObjectChanged()),
    63     connect( mServiceEngine, SIGNAL(notifyObjectChanged()),
    62             this, SLOT(onObjectChanged()));
    64             this, SLOT(onObjectChanged()));
       
    65     connect( mServiceEngine, SIGNAL(notifyRefreshStart()),
       
    66                 this, SLOT(refreshStart()));
       
    67     connect( mServiceEngine, SIGNAL(notifyRefreshFinish()),
       
    68                 this, SLOT(refreshFinish()));
    63 }
    69 }
    64 
    70 
    65 ToneFetcherWidget::~ToneFetcherWidget()
    71 ToneFetcherWidget::~ToneFetcherWidget()
    66 {
    72 {
    67     delete mToneModel;    
    73     delete mToneModel;
       
    74     mToneModel = 0;
       
    75     delete mWaitNote;
       
    76     mWaitNote = 0;
    68 }
    77 }
    69 
    78 
    70 void ToneFetcherWidget::on_list_activated(const QModelIndex &index)
    79 void ToneFetcherWidget::on_list_activated(const QModelIndex &index)
    71 {  
    80 {  
    72     QModelIndexList modelIndexList = mListView->selectionModel()->selectedIndexes();
    81     QModelIndexList modelIndexList = mListView->selectionModel()->selectedIndexes();
    73     
    82     
    74     //stop previewing when clicking another item.
    83     //stop previewing when clicking another item.
    75     if (mServiceEngine->IsPlaying()) {
    84     if (mServiceEngine->IsPlaying()) {
    76         mServiceEngine->preview(getCurrentItemPath());
    85         mServiceEngine->stop();
    77     }
    86     }
    78     /*
    87     /*
    79      * when one item is selected, reselecting it will deselect it. selecting another 
    88      * when one item is selected, reselecting it will deselect it. selecting another 
    80      * will also deselect it, while the other is selected.
    89      * will also deselect it, while the other is selected.
    81      */
    90      */
   123     mToneModel = new ToneFetcherModel(this);
   132     mToneModel = new ToneFetcherModel(this);
   124     addRomFiles();
   133     addRomFiles();
   125     
   134     
   126     connect(mListView, SIGNAL(activated(QModelIndex)),
   135     connect(mListView, SIGNAL(activated(QModelIndex)),
   127         this, SLOT(on_list_activated(QModelIndex )));
   136         this, SLOT(on_list_activated(QModelIndex )));
       
   137     if( !mWaitNote ){
       
   138         mWaitNote = new HbProgressDialog( HbProgressDialog::WaitDialog );
       
   139         mWaitNote->setText( hbTrId( "Refreshing..." ) );
       
   140         QAction *action = mWaitNote->actions().at(0);//disable Cancel buttion.
       
   141         action->setEnabled(false);
       
   142     }
   128 }
   143 }
   129 
   144 
   130 void ToneFetcherWidget::mdeSessionOpened()
   145 void ToneFetcherWidget::mdeSessionOpened()
   131 {
   146 {
   132     mServiceEngine->getTone();
   147     mServiceEngine->getTone();
   169     return QString();
   184     return QString();
   170 }
   185 }
   171 
   186 
   172 void ToneFetcherWidget::playOrPause() 
   187 void ToneFetcherWidget::playOrPause() 
   173 {
   188 {
       
   189     if(mServiceEngine->IsPlaying()) {
       
   190         mServiceEngine->stop();
       
   191     } else {    
   174     mServiceEngine->preview(getCurrentItemPath());
   192     mServiceEngine->preview(getCurrentItemPath());
       
   193     }
       
   194     
   175 }
   195 }
   176 
   196 
   177 void ToneFetcherWidget::previewEvent(ToneFetcherEngine::TPreviewEvent event, int errorId) 
   197 void ToneFetcherWidget::previewEvent(ToneFetcherEngine::TPreviewEvent event, int errorId) 
   178 {
   198 {
   179     Q_UNUSED(errorId);
   199     Q_UNUSED(errorId);
   184     }
   204     }
   185 }
   205 }
   186 
   206 
   187 void ToneFetcherWidget::onObjectChanged()
   207 void ToneFetcherWidget::onObjectChanged()
   188 {
   208 {
       
   209     if (mServiceEngine->IsPlaying()) {
       
   210         mServiceEngine->stop();      
       
   211     }
       
   212     emit triggerToolBar(false);
       
   213     mToneModel->toBeFreshed();
   189     mToneModel->clearAll();
   214     mToneModel->clearAll();
   190     mDigitalSoundList.clear();
   215     mDigitalSoundList.clear();
   191     mSimpleSoundList.clear();
   216     mSimpleSoundList.clear();
   192     addRomFiles();
   217     addRomFiles();
   193     mServiceEngine->getTone();    
   218     mServiceEngine->getTone();    
   215         fileName = new QStandardItem(fileInfo.fileName());
   240         fileName = new QStandardItem(fileInfo.fileName());
   216         filePath = new QStandardItem(fileInfo.absoluteFilePath());
   241         filePath = new QStandardItem(fileInfo.absoluteFilePath());
   217         mToneModel->insertInOrder(fileName, filePath);  
   242         mToneModel->insertInOrder(fileName, filePath);  
   218     }
   243     }
   219 }
   244 }
       
   245 
       
   246 void ToneFetcherWidget::refreshFinish()
       
   247 {
       
   248     if (mWaitNote) {
       
   249         mWaitNote->close();
       
   250     }
       
   251 }
       
   252 
       
   253 void ToneFetcherWidget::refreshStart()
       
   254 {
       
   255     if (mWaitNote) {
       
   256         mWaitNote->open();
       
   257     }
       
   258 }
   220 //End of File
   259 //End of File