controlpanelui/src/cpringtoneview/src/cpringtoneview.cpp
changeset 31 e79ce701c376
parent 25 19394c261aa5
child 42 3487b2ea501a
equal deleted inserted replaced
25:19394c261aa5 31:e79ce701c376
    32 #include <cpsettingformentryitemdata.h>
    32 #include <cpsettingformentryitemdata.h>
    33 
    33 
    34 CpRingToneView::CpRingToneView( QGraphicsItem *parent ):
    34 CpRingToneView::CpRingToneView( QGraphicsItem *parent ):
    35                               CpBaseSettingView(0, parent),
    35                               CpBaseSettingView(0, parent),
    36                               mToneTypeList( new HbListWidget(this) ),
    36                               mToneTypeList( new HbListWidget(this) ),
    37                               mReq(0)
    37                               mReq(0), mProcessing(false)
    38 {
    38 {
    39     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem.css");
    39     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem.css");
    40     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem_color.css");
    40     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem_color.css");
    41     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem.widgetml");
    41     HbStyleLoader::registerFilePath(":/widgetml/cpdataformlistentryviewitem.widgetml");
    42     
    42     
    43     HbDataForm *form = qobject_cast<HbDataForm*> ( widget() );
    43     HbDataForm *form = qobject_cast<HbDataForm*> ( widget() );
    44     form->setHeading("txt_cp_subhead_select_tone_type");   
    44     form->setHeading(hbTrId("txt_cp_subhead_select_tone_type"));   
    45     
    45     
    46     HbDataFormModel *model = new HbDataFormModel();  
    46     HbDataFormModel *model = new HbDataFormModel();  
    47     QList< QPair<QString,QString> > tonesTypeList;
    47     QList< QPair<QString,QString> > tonesTypeList;
    48     tonesTypeList << qMakePair( QString("qtg_large_tone_off"), hbTrId("txt_cp_list_no_tone") )
    48     tonesTypeList << qMakePair( QString("qtg_large_tone_off"), hbTrId("txt_cp_list_no_tone") )
    49                  << qMakePair( QString("qtg_large_tone"), hbTrId("txt_cp_list_tone") )
    49                  << qMakePair( QString("qtg_large_tone"), hbTrId("txt_cp_list_tone") )
    60     connect(form, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
    60     connect(form, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
    61     form->setModel(model);
    61     form->setModel(model);
    62 }
    62 }
    63 CpRingToneView::~CpRingToneView()
    63 CpRingToneView::~CpRingToneView()
    64 {
    64 {
    65     if(mReq)    delete mReq;
    65     if (mReq) {
       
    66         delete mReq;
       
    67     }    
    66 }
    68 }
       
    69 
    67 void CpRingToneView::itemActivated( const QModelIndex &index )
    70 void CpRingToneView::itemActivated( const QModelIndex &index )
    68 {
    71 {
       
    72     //avoid responding to the second or later consecutive click
       
    73 	if (mProcessing) {
       
    74 		return;
       
    75 	}
       
    76 	mProcessing = true;
    69     int nRow = index.row();
    77     int nRow = index.row();
    70 
    78 
    71     switch(nRow) {
    79     switch(nRow) {
    72         case 0:         //no tone, set default no sound
    80         case 0:         //no tone, set default no sound
    73                 emit selOK(QString(""));
    81                 emit selOK(QString(""));
    84 		        break;
    92 		        break;
    85 	 }
    93 	 }
    86 }
    94 }
    87 void CpRingToneView::handleOk(const QVariant &result)
    95 void CpRingToneView::handleOk(const QVariant &result)
    88 {
    96 {
    89     CPFW_LOG( "CpPersonalizationEntryItemData::handleOk" );
    97     mProcessing = false;
       
    98     CPFW_LOG( "CpRingToneView::handleOk" );
    90     if (!result.canConvert<QString>() || result.toString().length() == 0 )  //error result
    99     if (!result.canConvert<QString>() || result.toString().length() == 0 )  //error result
    91     {
   100     {
    92         return;
   101         return;
    93     }
   102     }
    94     hide();
   103     hide();
    97 }
   106 }
    98 
   107 
    99 
   108 
   100 void CpRingToneView::handleError(int errorCode, const QString& errorMessage)
   109 void CpRingToneView::handleError(int errorCode, const QString& errorMessage)
   101 {
   110 {
       
   111     mProcessing = false;
   102     emit(selError( errorCode, errorMessage ));
   112     emit(selError( errorCode, errorMessage ));
   103 }
   113 }
   104 
   114 
   105 void CpRingToneView::launchMediaFetcher( const QString &strService, const QString &strItface )
   115 void CpRingToneView::launchMediaFetcher( const QString &strService, const QString &strItface )
   106 {
   116 {
   110         delete mReq;
   120         delete mReq;
   111         mReq = 0;
   121         mReq = 0;
   112     }
   122     }
   113         //launch media fetcher
   123         //launch media fetcher
   114     mReq = mAppMgr.create(strService, strItface, true);
   124     mReq = mAppMgr.create(strService, strItface, true);
       
   125     mReq->setSynchronous(false);
   115     if (!mReq)
   126     if (!mReq)
   116     {
   127     {
   117       CPFW_LOG("CpRingToneView::launchMediaFetcher, Mediafetcher start failed");
   128       CPFW_LOG("CpRingToneView::launchMediaFetcher, Mediafetcher start failed");
   118       return;
   129       return;
   119     }
   130     }
   120     else
   131     else
   121     {
   132     {   //use QueuedConnection so that requestError will not be emitted when selecting one tone
   122         connect(mReq, SIGNAL( requestOk( const QVariant&)), SLOT( handleOk(const QVariant&)) );
   133         connect(mReq, SIGNAL(requestOk(QVariant)), SLOT( handleOk(QVariant)), Qt::QueuedConnection);
   123         connect(mReq, SIGNAL( requestError( int,const QString&)), SLOT(handleError(int,const QString&)) );
   134         connect(mReq, SIGNAL(requestError(int, QString)), SLOT(handleError(int, QString)));
   124     }
   135     }
   125     
   136     
   126     QList<QVariant> args;
   137     QList<QVariant> args;
   127     args << QVariant(QString("<app_name>"));
   138     args << QVariant(QString("<app_name>"));
   128     mReq->setArguments(args);
   139     mReq->setArguments(args);