contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp
changeset 67 59984e68247d
parent 66 554fe4dbbb59
child 72 6abfb1094884
equal deleted inserted replaced
66:554fe4dbbb59 67:59984e68247d
    90   mMainWindow(0),
    90   mMainWindow(0),
    91   mThumbnailManager(new ThumbnailManager(this)),
    91   mThumbnailManager(new ThumbnailManager(this)),
    92   mThumbnailPixmap(QPixmap()),
    92   mThumbnailPixmap(QPixmap()),
    93   mThumbnailInProgress(false),
    93   mThumbnailInProgress(false),
    94   mTranslator(new HbTranslator(translationsPath, translationsFile)),
    94   mTranslator(new HbTranslator(translationsPath, translationsFile)),
    95   mAvatarIcon(0),
       
    96   mPendingExit(false)
    95   mPendingExit(false)
    97 {
    96 {
    98     // Localization file loading   		
    97     // Localization file loading   		
    99 	mTranslator->loadCommon();    
    98 	mTranslator->loadCommon();    
   100     
    99     
   599     } else { // connect contact change observation
   598     } else { // connect contact change observation
   600         connect(mContactManager, SIGNAL(contactsChanged(QList<QContactLocalId>)),
   599         connect(mContactManager, SIGNAL(contactsChanged(QList<QContactLocalId>)),
   601             this, SLOT(onContactsChanged(QList<QContactLocalId>)));
   600             this, SLOT(onContactsChanged(QList<QContactLocalId>)));
   602         connect(mContactManager, SIGNAL(contactsRemoved(QList<QContactLocalId>)),
   601         connect(mContactManager, SIGNAL(contactsRemoved(QList<QContactLocalId>)),
   603             this, SLOT(onContactsRemoved(QList<QContactLocalId>)));
   602             this, SLOT(onContactsRemoved(QList<QContactLocalId>)));
       
   603         connect(mContactManager,
       
   604         		SIGNAL(selfContactIdChanged(const QContactLocalId &,
       
   605         				const QContactLocalId &)),
       
   606         		this,
       
   607         		SLOT(onSelfContactIdChanged(const QContactLocalId &,
       
   608         				const QContactLocalId &)));
   604     }
   609     }
   605 }
   610 }
   606 
   611 
   607 /*!
   612 /*!
   608     Initializes the widget.
   613     Initializes the widget.
   809     qDebug() << "ContactWidgetHs::onContactsRemoved, removed count " << contactIds.count();
   814     qDebug() << "ContactWidgetHs::onContactsRemoved, removed count " << contactIds.count();
   810     int i;
   815     int i;
   811     for(i=0; i<contactIds.count(); i++) {
   816     for(i=0; i<contactIds.count(); i++) {
   812         if (contactIds.at(i) == mContactLocalId) {
   817         if (contactIds.at(i) == mContactLocalId) {
   813             qDebug() << "-deleting widget with removed contact " << mContactLocalId;
   818             qDebug() << "-deleting widget with removed contact " << mContactLocalId;
   814 
   819             finishWidget();
   815             mAvatarIconItem->deleteLater();
       
   816             mContactNameLabel->deleteLater();
       
   817             
       
   818             mContactLocalId = unUsedContactId;
       
   819             
       
   820             mContactHasAvatarDetail = false;
       
   821             
       
   822             
       
   823             if (!mLauncher->isPendingRequest()){
       
   824             	emit finished();
       
   825             }
       
   826             else {
       
   827             	mPendingExit = true;
       
   828             }
       
   829             break;
   820             break;
   830         }
   821         }
   831     }
   822     }
   832 }
   823 }
   833 
   824 
   888     mContactNameLabel->setTextColor(color);
   879     mContactNameLabel->setTextColor(color);
   889 
   880 
   890     update();
   881     update();
   891 }
   882 }
   892 
   883 
       
   884 void ContactWidgetHs::onSelfContactIdChanged(const QContactLocalId &theOldId,
       
   885         const QContactLocalId &theNewId) {
       
   886     if (0 != theNewId && mContactLocalId == theNewId) {
       
   887         qDebug() << "-deleting widget after selfcontact change"
       
   888                  << mContactLocalId;
       
   889         finishWidget();
       
   890     }
       
   891 }
       
   892 
       
   893 void ContactWidgetHs::finishWidget() {
       
   894     mAvatarIconItem->deleteLater();
       
   895     mContactNameLabel->deleteLater();
       
   896     mContactLocalId = unUsedContactId;
       
   897     mContactHasAvatarDetail = false;
       
   898     
       
   899     if (!mLauncher->isPendingRequest()) {
       
   900         emit finished();
       
   901     } else {
       
   902     	mPendingExit = true;
       
   903     }
       
   904 }
   893 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
   905 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
   894 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)
   906 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)