contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp
changeset 75 4ecbe3571b5a
parent 71 7cc7d74059f9
--- a/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp	Fri Sep 17 08:27:32 2010 +0300
+++ b/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp	Mon Oct 04 00:06:02 2010 +0300
@@ -92,7 +92,6 @@
   mThumbnailPixmap(QPixmap()),
   mThumbnailInProgress(false),
   mTranslator(new HbTranslator(translationsPath, translationsFile)),
-  mAvatarIcon(0),
   mPendingExit(false)
 {
     // Localization file loading   		
@@ -601,6 +600,12 @@
             this, SLOT(onContactsChanged(QList<QContactLocalId>)));
         connect(mContactManager, SIGNAL(contactsRemoved(QList<QContactLocalId>)),
             this, SLOT(onContactsRemoved(QList<QContactLocalId>)));
+        connect(mContactManager,
+        		SIGNAL(selfContactIdChanged(const QContactLocalId &,
+        				const QContactLocalId &)),
+        		this,
+        		SLOT(onSelfContactIdChanged(const QContactLocalId &,
+        				const QContactLocalId &)));
     }
 }
 
@@ -663,6 +668,7 @@
     if (mLauncher->isVisible()) {
         mLauncher->hide();
     }
+    loadNormalLayout();
 }    
 
 /*!
@@ -811,21 +817,7 @@
     for(i=0; i<contactIds.count(); i++) {
         if (contactIds.at(i) == mContactLocalId) {
             qDebug() << "-deleting widget with removed contact " << mContactLocalId;
-
-            mAvatarIconItem->deleteLater();
-            mContactNameLabel->deleteLater();
-            
-            mContactLocalId = unUsedContactId;
-            
-            mContactHasAvatarDetail = false;
-            
-            
-            if (!mLauncher->isPendingRequest()){
-            	emit finished();
-            }
-            else {
-            	mPendingExit = true;
-            }
+            finishWidget();
             break;
         }
     }
@@ -890,5 +882,26 @@
     update();
 }
 
+void ContactWidgetHs::onSelfContactIdChanged(const QContactLocalId &theOldId,
+        const QContactLocalId &theNewId) {
+    if (0 != theNewId && mContactLocalId == theNewId) {
+        qDebug() << "-deleting widget after selfcontact change"
+                 << mContactLocalId;
+        finishWidget();
+    }
+}
+
+void ContactWidgetHs::finishWidget() {
+    mAvatarIconItem->deleteLater();
+    mContactNameLabel->deleteLater();
+    mContactLocalId = unUsedContactId;
+    mContactHasAvatarDetail = false;
+    
+    if (!mLauncher->isPendingRequest()) {
+        emit finished();
+    } else {
+    	mPendingExit = true;
+    }
+}
 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)