messagingapp/msgui/unifiededitor/src/msgunieditorbody.cpp
changeset 76 60a8a215b0ec
parent 67 fc91263aee62
equal deleted inserted replaced
73:ecf6a73a9186 76:60a8a215b0ec
    14  * Description:
    14  * Description:
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 // INCLUDES
    18 // INCLUDES
    19 #include <HbTextEdit>
       
    20 #include <HbTextItem>
    19 #include <HbTextItem>
    21 #include <HbFrameItem>
       
    22 #include <HbFrameDrawer>
       
    23 #include <HbIconItem>
    20 #include <HbIconItem>
    24 #include <HbAction>
       
    25 #include <HbMainWindow>
    21 #include <HbMainWindow>
    26 #include <HbDeviceProfile>
    22 #include <HbDeviceProfile>
    27 #include <QImageReader>
    23 #include <QImageReader>
    28 #include <QFileInfo>
    24 #include <QFileInfo>
    29 #include <MsgMediaResolver.h>
    25 #include <MsgMediaResolver.h>
    30 #include <MsgImageInfo.h>
    26 #include <MsgImageInfo.h>
    31 #include <HbIconAnimationManager>
    27 #include <HbIconAnimationManager>
    32 #include <HbIconAnimator>
    28 #include <HbIconAnimator>
    33 #include <HbIcon>
       
    34 #include <QGraphicsLinearLayout>
    29 #include <QGraphicsLinearLayout>
    35 #include <HbNotificationDialog>
    30 #include <HbNotificationDialog>
    36 
    31 
    37 #include <csmsaccount.h>
       
    38 #include <smutset.h>
       
    39 #include <xqaiwrequest.h>
    32 #include <xqaiwrequest.h>
    40 #include <xqrequestinfo.h>
    33 #include <xqrequestinfo.h>
    41 #include <xqsharablefile.h>
    34 #include <xqsharablefile.h>
    42 #include <xqappmgr.h>
    35 #include <xqappmgr.h>
    43 #include <xqconversions.h>
    36 #include <xqconversions.h>
    44 #include <hbmessagebox.h>
    37 #include <hbmessagebox.h>
    45 #include <hbcolorscheme.h>
    38 
    46 #include <QColor>
       
    47 // USER INCLUDES
    39 // USER INCLUDES
    48 #include "msgunieditorbody.h"
    40 #include "msgunieditorbody.h"
    49 #include "UniEditorGenUtils.h"
    41 #include "UniEditorGenUtils.h"
    50 #include "UniSendingSettings.h"
       
    51 #include "msgunieditormonitor.h"
    42 #include "msgunieditormonitor.h"
    52 
    43 
    53 #include "mmsconformancecheck.h"
    44 #include "mmsconformancecheck.h"
    54 #include "unieditorpluginloader.h"
       
    55 #include "unieditorplugininterface.h"
       
    56 #include "convergedmessage.h"
       
    57 #include "msgmediautil.h"
       
    58 #include "msgunieditorpixmapwidget.h"
    45 #include "msgunieditorpixmapwidget.h"
    59 #include "msgunieditoraudiowidget.h"
    46 #include "msgunieditoraudiowidget.h"
       
    47 #include "msgunieditorview.h"
    60 
    48 
    61 // Constants
    49 // Constants
    62 const QString BACKGROUND_FRAME("qtg_fr_messaging_char_count");
       
    63 const QString CHAR_COUNTER_COLOR("qtc_messaging_char_count");
       
    64 
       
    65 const int KShowCounterLimit = 10;
       
    66 const int BYTES_TO_KBYTES_FACTOR = 1024; 
    50 const int BYTES_TO_KBYTES_FACTOR = 1024; 
    67 
    51 
    68 //Localized Constants for item specific menu
    52 //Localized Constants for item specific menu
    69 #define LOC_TITLE   hbTrId("txt_messaging_title_messaging")
       
    70 #define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content")
       
    71 #define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai")
    53 #define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai")
    72 #define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading")
    54 #define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading")
    73 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here")
       
    74 #define LOC_ATTACHED_PHOTO_SIZE hbTrId("txt_messaging_dpopinfo_attached_photo_size_is_l1")
    55 #define LOC_ATTACHED_PHOTO_SIZE hbTrId("txt_messaging_dpopinfo_attached_photo_size_is_l1")
    75 
    56 
    76 const QString ANIMATION_ICON("qtg_anim_loading");
    57 const QString ANIMATION_ICON("qtg_anim_loading");
    77 const QString ANIMATION_FILE(":/qtg_anim_loading.axml");
    58 const QString ANIMATION_FILE("qtg_anim_loading.axml");
    78 // LOCAL FUNCTIONS
    59 // LOCAL FUNCTIONS
    79 
    60 
    80 //---------------------------------------------------------------
    61 //---------------------------------------------------------------
    81 // showInsertFailureNote
    62 // showInsertFailureNote
    82 // @return fullPath of unified editor's temporary dir
    63 // @return fullPath of unified editor's temporary dir
    83 //---------------------------------------------------------------
    64 //---------------------------------------------------------------
    84 void showInsertFailureNote()
    65 void showInsertFailureNote()
    85 {
    66 {
    86     int availableSize =
    67     int availableSize =
    87             (MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize())
    68         (MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize())
    88             /BYTES_TO_KBYTES_FACTOR;
    69         /BYTES_TO_KBYTES_FACTOR;
    89     QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM)
    70     QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM)
    90             .arg(availableSize);
    71                 .arg(availableSize);
    91 
    72 
    92     HbMessageBox::information(displayStr, 0, 0, HbMessageBox::Ok);
    73     HbMessageBox::information(displayStr, 0, 0, HbMessageBox::Ok);
    93 }
    74 }
    94 
    75 
    95 
    76 
    96 MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) :
    77 MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) :
    97 MsgUnifiedEditorBaseWidget(parent),
    78 MsgUnifiedEditorBaseWidget(parent),
    98 mHasImage(false),
    79 mHasImage(false),
    99 mHasAudio(false),
    80 mHasAudio(false),
   100 mTextEdit(0),
       
   101 mPixmapItem(0),
    81 mPixmapItem(0),
   102 mAudioItem(0),
    82 mAudioItem(0),
   103 mImageSize(0),
    83 mImageSize(0),
   104 mAudioSize(0),
    84 mAudioSize(0),
   105 mVideoSize(0),
       
   106 mProcessImageOperation(0),
    85 mProcessImageOperation(0),
   107 mMediaResolver(0),
    86 mMediaResolver(0),
   108 mImageInfo(0),
    87 mImageInfo(0),
   109 mProcessingWidget(0),
    88 mProcessingWidget(0),
   110 mDraftMessage(false),
    89 mDraftMessage(false)
   111 mIsImageResizing(false)
    90 {
   112 {
    91     this->setObjectName("body");
   113     mTextEdit = new HbTextEdit(this);
    92     mMmsConformanceCheck = new MmsConformanceCheck;    
   114     mTextEdit->setPlaceholderText(LOC_HINT_TEXT);
       
   115     mTextEdit->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
       
   116     HbStyle::setItemName(mTextEdit,"textEdit");
       
   117     connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged()));
       
   118 
       
   119     mMmsConformanceCheck = new MmsConformanceCheck;
       
   120     
       
   121     mCharCounter = new HbTextItem(this);
       
   122     HbStyle::setItemName(mCharCounter, "charCounter");
       
   123     mCharCounter->setZValue(1.5);
       
   124 
       
   125     QColor color = HbColorScheme::color(CHAR_COUNTER_COLOR);
       
   126     mCharCounter->setTextColor(color);
       
   127 
       
   128     mBackgroundItem = new HbFrameItem(this);
       
   129     HbStyle::setItemName(mBackgroundItem, "charCounterFrame");
       
   130 
       
   131     mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
   132     mBackgroundItem->frameDrawer().setFillWholeRect(true);
       
   133     
       
   134     mBackgroundItem->frameDrawer().setFrameGraphicsName(BACKGROUND_FRAME);
       
   135     
       
   136     mPluginLoader = new UniEditorPluginLoader(this);
       
   137 
       
   138     mPluginInterface =
       
   139                         mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms);    
       
   140     
       
   141     TRAP_IGNORE(
       
   142     CSmsSettings* settings = CSmsSettings::NewLC();
       
   143     CSmsAccount* account = CSmsAccount::NewLC();
       
   144     account->LoadSettingsL( *settings );
       
   145 
       
   146     if( settings->CharacterSet() == TSmsDataCodingScheme::ESmsAlphabetUCS2)
       
   147     {
       
   148     mCharSupportType = TUniSendingSettings::EUniCharSupportFull;
       
   149     }
       
   150     else
       
   151     {
       
   152     mCharSupportType = TUniSendingSettings::EUniCharSupportReduced;
       
   153     }
       
   154     
       
   155     CleanupStack::PopAndDestroy( account );
       
   156     CleanupStack::PopAndDestroy( settings );                
       
   157     );
       
   158 
       
   159     mCharCounter->setVisible(false);
       
   160     mBackgroundItem->setVisible(false);
       
   161 }
    93 }
   162 
    94 
   163 MsgUnifiedEditorBody::~MsgUnifiedEditorBody()
    95 MsgUnifiedEditorBody::~MsgUnifiedEditorBody()
   164 {
    96 {
   165     delete mMmsConformanceCheck;
    97     delete mMmsConformanceCheck;
   166     delete mProcessImageOperation;
    98     delete mProcessImageOperation;
   167     delete mMediaResolver;
    99     delete mMediaResolver;
   168     delete mImageInfo;
   100     delete mImageInfo;
   169 }
   101 }
   170 
   102 
   171 QString MsgUnifiedEditorBody::text()
   103 void MsgUnifiedEditorBody::setImage(const QString& imagefile, bool draftMessage)
   172 {
   104     {
   173     return mTextEdit->toPlainText();
   105     
   174 }
   106    // do nothing if filepath is empty
   175 
       
   176 void MsgUnifiedEditorBody::setImage(QString& imagefile, bool draftMessage)
       
   177     {
       
   178     // do nothing if filepath is empty
       
   179     if (imagefile.isEmpty())
   107     if (imagefile.isEmpty())
   180         {
   108         {
   181         return;
   109         return;
   182         }
   110         }
       
   111     
       
   112     //disable image option in menu.
       
   113     emit enableMenuAction(PHOTO,false);
   183 
   114 
   184     mDraftMessage = draftMessage;
   115     mDraftMessage = draftMessage;
   185     if (!mImageInfo)
   116     if (!mImageInfo)
   186         {
   117         {
   187         setImage(true);
   118         setImage(true);
   231             }
   162             }
   232         if (error == KErrNone && !mDraftMessage)
   163         if (error == KErrNone && !mDraftMessage)
   233             {
   164             {
   234             mSavedImageFile = imagefile;
   165             mSavedImageFile = imagefile;
   235             startResizeAnimation();
   166             startResizeAnimation();
   236             mIsImageResizing = true;
   167             
       
   168             // image resize is started. set the image resize flag.
       
   169             emit contentsChanged(true);
       
   170             
   237             mProcessImageOperation->Process(mImageInfo);
   171             mProcessImageOperation->Process(mImageInfo);
   238             }
   172             }
   239         else
   173         else
   240             {
   174             {
   241             if (mImageInfo)
   175             if (mImageInfo)
   252 
   186 
   253 void MsgUnifiedEditorBody::handleSetImage()
   187 void MsgUnifiedEditorBody::handleSetImage()
   254 {   
   188 {   
   255     //check for insert conformance
   189     //check for insert conformance
   256     if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile))
   190     if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile))
       
   191     {
       
   192         //enable image option in menu as insertion failed.
       
   193         emit enableMenuAction(PHOTO,true);
   257         return;
   194         return;
   258     
   195     }
   259     int msgSize = messageSize();
   196     
       
   197     int msgSize = MsgUnifiedEditorMonitor::messageSize();
   260     QFileInfo fileinfo(mImageFile);
   198     QFileInfo fileinfo(mImageFile);
   261     int imageSize = fileinfo.size() + KEstimatedMimeHeaderSize;
   199     int imageSize = fileinfo.size() + KEstimatedMimeHeaderSize;
   262     if ( (imageSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize())
   200     if ( (imageSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize())
   263     {
   201     {
   264         mImageSize = imageSize;
   202         mImageSize = imageSize;
   267     {
   205     {
   268         mImageFile.clear();
   206         mImageFile.clear();
   269         setImage(false);
   207         setImage(false);
   270         //Show appropriate note and leave
   208         //Show appropriate note and leave
   271         showInsertFailureNote();
   209         showInsertFailureNote();
       
   210         
       
   211         //enable image option in menu as insertion failed.
       
   212         emit enableMenuAction(PHOTO,true);
       
   213         
   272         return;
   214         return;
   273     }
   215     }
   274 
   216 
   275     mPixmapItem = new MsgUnifiedEditorPixmapWidget(this);
   217     mPixmapItem = new MsgUnifiedEditorPixmapWidget(this);
   276     mPixmapItem->hide();
   218     mPixmapItem->hide();
   281     
   223     
   282     // repolish the body widget
   224     // repolish the body widget
   283     this->repolish();
   225     this->repolish();
   284 
   226 
   285     // emit signal to indicate addition of image
   227     // emit signal to indicate addition of image
   286     emit contentChanged();
   228     emit contentsChanged(bodySize());    
   287 }
   229 }
   288 
   230 
   289 void MsgUnifiedEditorBody::setAudio(QString& audiofile)
   231 void MsgUnifiedEditorBody::setAudio(const QString& audiofile)
   290 {
   232 {
   291     // do nothing if filepath is empty
   233     // do nothing if filepath is empty
   292     if(audiofile.isEmpty())
   234     if(audiofile.isEmpty())
   293     {
   235     {
   294         return;
   236         return;
   306         delete mAudioItem;
   248         delete mAudioItem;
   307         mAudioItem = NULL;
   249         mAudioItem = NULL;
   308         mAudioSize = 0;
   250         mAudioSize = 0;
   309     }
   251     }
   310 
   252 
   311     int msgSize = messageSize();
   253     int msgSize = MsgUnifiedEditorMonitor::messageSize();
   312     QFileInfo fileinfo(mAudioFile);
   254     QFileInfo fileinfo(mAudioFile);
   313     int audioSize = fileinfo.size() + KEstimatedMimeHeaderSize;
   255     int audioSize = fileinfo.size() + KEstimatedMimeHeaderSize;
   314     if((audioSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize() )
   256     if((audioSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize() )
   315     {
   257     {
   316     	mAudioSize = audioSize;
   258     	mAudioSize = audioSize;
   332 
   274 
   333     // repolish the body widget
   275     // repolish the body widget
   334     this->repolish();
   276     this->repolish();
   335 
   277 
   336     // emit signal to indicate addition of audio
   278     // emit signal to indicate addition of audio
   337     emit contentChanged();
   279     emit contentsChanged(bodySize());
   338 }
   280     
   339 
   281     //disable sound option in menu.
   340 void MsgUnifiedEditorBody::setText(QString& text)
   282     emit enableMenuAction(SOUND,false);
   341 {
       
   342     if(!text.isEmpty())
       
   343     {    
       
   344         mTextEdit->setPlainText(text);
       
   345     }
       
   346 }
   283 }
   347 
   284 
   348 const QStringList MsgUnifiedEditorBody::mediaContent()
   285 const QStringList MsgUnifiedEditorBody::mediaContent()
   349 {
   286 {
   350     QStringList mediaFiles;
   287     QStringList mediaFiles;
   381     style()->parameter("hb-param-margin-gene-middle-vertical",bodyItemSpacing);
   318     style()->parameter("hb-param-margin-gene-middle-vertical",bodyItemSpacing);
   382 
   319 
   383     HbDeviceProfile prf = HbDeviceProfile::profile(mMainWindow);
   320     HbDeviceProfile prf = HbDeviceProfile::profile(mMainWindow);
   384     qreal unt = prf.unitValue();
   321     qreal unt = prf.unitValue();
   385 
   322 
   386     // Note: With NGA, the orientation change does not cause HW to switch orientation.
   323     qreal maxWidth = mMainWindow->width()-leftMargin-rightMargin;
   387     // So, the HW resolution also remains unchanged. We need to swap values of width &
   324     qreal maxHeight = mMainWindow->height()-chromeHeight-toolbarHeight;
   388     // height to map portrait resolution to landscape resolution.
   325 
   389     qreal maxWidth = 0.0, maxHeight = 0.0;
   326     szHint.setHeight(0);
   390     
       
   391     // Landscape
       
   392     if(mMainWindow->orientation() == Qt::Horizontal)
       
   393         {
       
   394         maxHeight = mMainWindow->width()-chromeHeight-toolbarHeight;
       
   395         maxWidth = (mMainWindow->height()-leftMargin-rightMargin-(2*unt))/2;
       
   396         }
       
   397     else
       
   398     {
       
   399         maxWidth = mMainWindow->width()-leftMargin-rightMargin;
       
   400         maxHeight = mMainWindow->height()-chromeHeight-toolbarHeight;
       
   401     }
       
   402     szHint.setHeight(maxHeight);
       
   403     
   327     
   404     // add space for audio
   328     // add space for audio
   405     if(mAudioItem)
   329     if(mAudioItem)
   406     {
   330     {
   407 		if(mMainWindow->orientation() == Qt::Horizontal)
   331 		if(mMainWindow->orientation() == Qt::Horizontal)
   453 
   377 
   454             if(mPixmapItem)
   378             if(mPixmapItem)
   455             {
   379             {
   456             mPixmapItem->setPreferredSize(imageSize);
   380             mPixmapItem->setPreferredSize(imageSize);
   457             mPixmapItem->setSize(imageSize);
   381             mPixmapItem->setSize(imageSize);
   458             if(mMainWindow->orientation() == Qt::Horizontal)
       
   459             {
       
   460                 QPointF currPos = mPixmapItem->pos();
       
   461                 currPos.setX(leftMargin+((maxWidth-imageSize.width())/2));
       
   462                 mPixmapItem->setPos(currPos);
       
   463             }
       
   464             mPixmapItem->show();
   382             mPixmapItem->show();
   465             }
   383             }
   466             
   384             
   467             if(mProcessingWidget)
   385             if(mProcessingWidget)
   468             {
   386             {
   472             }
   390             }
   473             szHint.rheight() += imageSize.height();
   391             szHint.rheight() += imageSize.height();
   474         }
   392         }
   475     }
   393     }
   476     
   394     
   477 
       
   478     mTextEdit->setMinimumHeight(maxHeight);
       
   479     szHint.rheight() += bodyItemSpacing;
   395     szHint.rheight() += bodyItemSpacing;
   480     return szHint;
   396     return szHint;
   481 }
   397 }
   482 
   398 
   483 void MsgUnifiedEditorBody::removeMedia()
   399 void MsgUnifiedEditorBody::removeMedia()
   499             delete mPixmapItem;
   415             delete mPixmapItem;
   500             mPixmapItem = NULL;
   416             mPixmapItem = NULL;
   501         }
   417         }
   502         setImage(false);
   418         setImage(false);
   503         mImageSize = 0;
   419         mImageSize = 0;
       
   420         
       
   421         //enable photo option in menu.
       
   422         emit enableMenuAction(PHOTO,true);
       
   423         
   504     }
   424     }
   505     else if(audio)//remove audio item
   425     else if(audio)//remove audio item
   506         {
   426         {
   507             mAudioFile.clear();
   427             mAudioFile.clear();
   508             if(mAudioItem)
   428             if(mAudioItem)
   511                 delete mAudioItem;
   431                 delete mAudioItem;
   512                 mAudioItem = NULL;
   432                 mAudioItem = NULL;
   513             }
   433             }
   514             setAudio(false);
   434             setAudio(false);
   515             mAudioSize = 0;
   435             mAudioSize = 0;
       
   436             
       
   437             //enable sound option in menu.
       
   438             emit enableMenuAction(SOUND,true);
   516         }
   439         }
   517 
   440 
   518     this->repolish();
   441     this->repolish();
   519 
   442 
   520 	emit contentChanged();
   443 	emit contentsChanged(bodySize());
   521 }
   444 }
   522 
   445 
   523 bool MsgUnifiedEditorBody::hasImage()
   446 bool MsgUnifiedEditorBody::hasImage()
   524 {
   447 {
   525     return mHasImage;
   448     return mHasImage;
   540     mHasAudio = audio;
   463     mHasAudio = audio;
   541 }
   464 }
   542 
   465 
   543 int MsgUnifiedEditorBody::bodySize()
   466 int MsgUnifiedEditorBody::bodySize()
   544 {
   467 {
   545 	int bodysize = 0;
   468     return mImageSize + mAudioSize;
   546 	
       
   547 	if( mImageSize || mTextEdit->toPlainText().size() || 
       
   548 	    mAudioSize || mVideoSize )
       
   549 	{
       
   550 	     
       
   551 	    UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
       
   552 	    
       
   553         bodysize +=  mImageSize + mAudioSize + mVideoSize +
       
   554             genUtils->UTF8Size(mTextEdit->toPlainText()) +
       
   555             KEstimatedMimeHeaderSize + KEstimatedMmsSmilHeaderSize;
       
   556         delete genUtils;
       
   557 	}
       
   558 	return bodysize;
       
   559 }
       
   560 
       
   561 int MsgUnifiedEditorBody::messageSize()
       
   562 {
       
   563     int estimatedMediaSize = bodySize();
       
   564     if(!estimatedMediaSize)
       
   565     {
       
   566         // This is the first media content to be inserted
       
   567         estimatedMediaSize = KEstimatedMmsSmilHeaderSize;
       
   568     }
       
   569     
       
   570     return estimatedMediaSize + MsgUnifiedEditorMonitor::subjectSize() + MsgUnifiedEditorMonitor::containerSize();
       
   571 }
       
   572 
       
   573 void MsgUnifiedEditorBody::onTextChanged()
       
   574 {   
       
   575     QString string = text();
       
   576 
       
   577     if( string.size() > mPrevBuffer.size() &&
       
   578         MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms )
       
   579     {
       
   580         // reject any text input if mms size limit is reached
       
   581         int futureSize = bodySize() +
       
   582                 MsgUnifiedEditorMonitor::containerSize() + MsgUnifiedEditorMonitor::subjectSize();
       
   583         if(futureSize > MsgUnifiedEditorMonitor::maxMmsSize())
       
   584         {
       
   585             mTextEdit->setPlainText(mPrevBuffer);
       
   586             HbMessageBox::information(LOC_UNABLE_TO_ADD_CONTENT, 0, 0, HbMessageBox::Ok);
       
   587             mTextEdit->setCursorPosition(mPrevBuffer.length());
       
   588             return;
       
   589         }
       
   590         else if(!mPrevBuffer.isEmpty())
       
   591         {
       
   592             //Save the previous buffer
       
   593             mPrevBuffer = string;
       
   594             // emit signal to indicate change in content
       
   595             emit contentChanged();
       
   596             return;
       
   597         }
       
   598     }
       
   599 
       
   600     //Check done for optimization
       
   601     //Only if content is deleted we need to call encodingsettings again
       
   602     if (mPrevBuffer.isEmpty() || string.size() <= mPrevBuffer.size())
       
   603     {
       
   604         mPluginInterface->setEncodingSettings(EFalse, ESmsEncodingNone,
       
   605             mCharSupportType);
       
   606     }
       
   607 
       
   608     TInt numOfRemainingChars;
       
   609     TInt numOfPDUs;
       
   610     TBool unicodeMode;
       
   611     TSmsEncoding alternativeEncodingType;
       
   612     mPluginInterface->getNumPDUs(string, numOfRemainingChars, numOfPDUs,
       
   613         unicodeMode, alternativeEncodingType);
       
   614 
       
   615     //Save the unicode value returned
       
   616     mUnicode = unicodeMode;
       
   617     //Save the old buffer
       
   618     mPrevBuffer = string;
       
   619     
       
   620     // emit signal to indicate change in content
       
   621     emit contentChanged();
       
   622     
       
   623     if(MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Sms)
       
   624     {
       
   625         //Set char counter value
       
   626         QString display = QString("%1(%2)").arg(numOfRemainingChars).arg(
       
   627             numOfPDUs);
       
   628         mCharCounter->setText(display);
       
   629         
       
   630         if (numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit)
       
   631         {
       
   632             mCharCounter->setVisible(true);
       
   633             mBackgroundItem->setVisible(true);
       
   634         }
       
   635         else
       
   636         {
       
   637             mCharCounter->setVisible(false);
       
   638             mBackgroundItem->setVisible(false);
       
   639         }
       
   640     }
       
   641 }
   469 }
   642 
   470 
   643 void MsgUnifiedEditorBody::EditorOperationEvent(
   471 void MsgUnifiedEditorBody::EditorOperationEvent(
   644     TUniEditorProcessImageOperationEvent aEvent, TFileName& aFileName)
   472     TUniEditorProcessImageOperationEvent aEvent, TFileName& aFileName)
   645 {
   473 {
   646     delete mImageInfo;
   474     delete mImageInfo;
   647     mImageInfo = NULL; 
   475     mImageInfo = NULL;
   648 
   476 
   649     if (aEvent == EUniEditorProcessImageOperationComplete && 
   477     if (aEvent == EUniEditorProcessImageOperationComplete && 
   650             aFileName.Length() > 0)
   478             aFileName.Length() > 0)
   651     {
   479     {
   652         mImageFile = XQConversions::s60DescToQString(aFileName);
   480         mImageFile = XQConversions::s60DescToQString(aFileName);
   660         mImageFile = mSavedImageFile;
   488         mImageFile = mSavedImageFile;
   661     }
   489     }
   662     mSavedImageFile.clear();
   490     mSavedImageFile.clear();
   663 
   491 
   664    // image resize is complete. reset the image resize flag
   492    // image resize is complete. reset the image resize flag
   665     mIsImageResizing = false;
   493     emit contentsChanged(false);
       
   494     
   666     //handle the processed image from ProcessImage Operation
   495     //handle the processed image from ProcessImage Operation
   667     handleSetImage();
   496     handleSetImage();
   668     
   497     
   669     stopResizeAnimation();
   498     stopResizeAnimation();
   670 }
   499 }
   671 
   500 
   672 void MsgUnifiedEditorBody::startResizeAnimation()
   501 void MsgUnifiedEditorBody::startResizeAnimation()
   673 {
   502 {
   674     // emit signal to indicate disable the send tool button.
       
   675     emit enableSendButton(false);
       
   676     
       
   677 	
       
   678     QGraphicsLinearLayout* processingLayout = new QGraphicsLinearLayout(Qt::Vertical);
   503     QGraphicsLinearLayout* processingLayout = new QGraphicsLinearLayout(Qt::Vertical);
   679     
   504     
   680     mProcessingWidget = new HbWidget(this);
   505     mProcessingWidget = new HbWidget(this);
   681     HbStyle::setItemName(mProcessingWidget,"pixmap"); 
   506     HbStyle::setItemName(mProcessingWidget,"pixmap"); 
   682     mProcessingWidget->hide();
   507     mProcessingWidget->hide();
   706     {
   531     {
   707         delete mProcessingWidget;
   532         delete mProcessingWidget;
   708         mProcessingWidget = NULL;
   533         mProcessingWidget = NULL;
   709     }
   534     }
   710 	
   535 	
   711 }
       
   712 
       
   713 // ---------------------------------------------------------
       
   714 // MsgUnifiedEditorBody::isUnicode
       
   715 // ---------------------------------------------------------
       
   716 //
       
   717 bool MsgUnifiedEditorBody::isUnicode()
       
   718 {
       
   719     return mUnicode;
       
   720 }
       
   721 
       
   722 // ---------------------------------------------------------
       
   723 // MsgUnifiedEditorBody::disableCharCounter
       
   724 // ---------------------------------------------------------
       
   725 //
       
   726 void MsgUnifiedEditorBody::disableCharCounter()
       
   727 {
       
   728     mCharCounter->setVisible(false);
       
   729     mBackgroundItem->setVisible(false);
       
   730 }
       
   731 
       
   732 // ---------------------------------------------------------
       
   733 // MsgUnifiedEditorBody::enableCharCounter
       
   734 // ---------------------------------------------------------
       
   735 //
       
   736 void MsgUnifiedEditorBody::enableCharCounter()
       
   737     {
       
   738     mPluginInterface->setEncodingSettings(EFalse, ESmsEncodingNone,
       
   739             mCharSupportType);
       
   740 
       
   741     TInt numOfRemainingChars;
       
   742     TInt numOfPDUs;
       
   743     TBool unicodeMode;
       
   744     TSmsEncoding alternativeEncodingType;
       
   745     QString string = mTextEdit->toPlainText();
       
   746     mPluginInterface->getNumPDUs(string,
       
   747             numOfRemainingChars, numOfPDUs, unicodeMode,
       
   748             alternativeEncodingType);
       
   749 
       
   750     //Save the unicode value returned
       
   751     mUnicode = unicodeMode;
       
   752 
       
   753     //Set char counter value
       
   754     QString display = QString("%1(%2)").arg(numOfRemainingChars).arg(
       
   755             numOfPDUs);
       
   756     mCharCounter->setText(display);
       
   757 
       
   758     if (numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit)
       
   759         {
       
   760         mCharCounter->setVisible(true);
       
   761         mBackgroundItem->setVisible(true);
       
   762         }
       
   763     else
       
   764         {
       
   765         mCharCounter->setVisible(false);
       
   766         mBackgroundItem->setVisible(false);
       
   767         }
       
   768 
       
   769     }
       
   770 
       
   771 //---------------------------------------------------------------
       
   772 // MsgUnifiedEditorBody :: setFocus
       
   773 // @see header file
       
   774 //---------------------------------------------------------------
       
   775 void MsgUnifiedEditorBody::setFocus()
       
   776 {
       
   777     mTextEdit->setFocus(Qt::MouseFocusReason);
       
   778 }
   536 }
   779 
   537 
   780 //---------------------------------------------------------------
   538 //---------------------------------------------------------------
   781 // MsgUnifiedEditorBody :: removeMediaContent
   539 // MsgUnifiedEditorBody :: removeMediaContent
   782 // @see header file
   540 // @see header file
   808         mAudioSize = 0;
   566         mAudioSize = 0;
   809     }
   567     }
   810 
   568 
   811     this->repolish();
   569     this->repolish();
   812 
   570 
   813     emit contentChanged();
   571     emit contentsChanged(bodySize());
   814 }
   572 }
   815 // EOF
   573 // EOF