messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
    22 #include <HbAction>
    22 #include <HbAction>
    23 #include <HbToolBar>
    23 #include <HbToolBar>
    24 #include <hbmessagebox.h>
    24 #include <hbmessagebox.h>
    25 #include <hbnotificationdialog.h>
    25 #include <hbnotificationdialog.h>
    26 #include <HbStyleLoader>
    26 #include <HbStyleLoader>
    27 #include <centralrepository.h>       
    27 #include <centralrepository.h>
    28 #include <MmsEngineDomainCRKeys.h>
    28 #include <MmsEngineDomainCRKeys.h>
    29 
    29 
    30 // USER INCLUDES
    30 // USER INCLUDES
    31 #include "uniscrollarea.h"
    31 #include "uniscrollarea.h"
    32 #include "unicontentswidget.h"
    32 #include "unicontentswidget.h"
    42 #include "UniEditorGenUtils.h" // This is needed for KDefaultMaxSize
    42 #include "UniEditorGenUtils.h" // This is needed for KDefaultMaxSize
    43 
    43 
    44 // LOCAL CONSTANTS
    44 // LOCAL CONSTANTS
    45 const QString REPLY_ICON("qtg_mono_reply");
    45 const QString REPLY_ICON("qtg_mono_reply");
    46 const QString REPLY_ALL_ICON("qtg_mono_reply_all");
    46 const QString REPLY_ALL_ICON("qtg_mono_reply_all");
    47 const QString FORWARD_ICON("qtg_mono_forward");
    47 const QString FORWARD_ICON("qtg_mono_forward_msg");
    48 const QString SEND_ICON("qtg_mono_send");
    48 const QString SEND_ICON("qtg_mono_send");
    49 const QString DELETE_ICON("qtg_mono_delete");
    49 const QString DELETE_ICON("qtg_mono_delete");
    50 
    50 
    51 //LOCALIZED CONSTANTS
    51 //LOCALIZED CONSTANTS
    52 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    52 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    68     }
    68     }
    69 
    69 
    70     mMessageId = messageId;
    70     mMessageId = messageId;
    71     mViewFeeder = new UniViewerFeeder(mMessageId, this);
    71     mViewFeeder = new UniViewerFeeder(mMessageId, this);
    72 
    72 
    73     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
       
    74 
       
    75     mScrollArea = new UniScrollArea(this);
    73     mScrollArea = new UniScrollArea(this);
       
    74     this->setWidget(mScrollArea);
    76 
    75 
    77     mContentsWidget = new UniContentsWidget(mViewFeeder,this);
    76     mContentsWidget = new UniContentsWidget(mViewFeeder,this);
    78 	
    77 
    79     connect(mContentsWidget,SIGNAL(sendMessage(const QString&)),
    78     connect(mContentsWidget,SIGNAL(sendMessage(const QString&,const QString&)),
    80             this, SLOT(sendMessage(const QString&)));
    79             this, SLOT(sendMessage(const QString&,const QString&)));
    81 
    80 
    82     connect(mScrollArea, SIGNAL(scrolledToNextSlide()),
    81     connect(mScrollArea, SIGNAL(scrolledToNextSlide()),
    83     mContentsWidget, SLOT(populateNextSlide()));
    82     mContentsWidget, SLOT(populateNextSlide()));
    84 
    83 
    85     mScrollArea->setContentWidget(mContentsWidget);
    84     mScrollArea->setContentWidget(mContentsWidget);
    86     mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    85     mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    87     mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide);
    86     mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide);
    88     mMainLayout->addItem(mScrollArea);
       
    89     mMainLayout->setSpacing(0);
       
    90     mMainLayout->setContentsMargins(0, 0, 0, 0);
       
    91 
       
    92     setLayout(mMainLayout);
       
    93 
    87 
    94     QDEBUG_WRITE("UnifiedViewer contruction End");
    88     QDEBUG_WRITE("UnifiedViewer contruction End");
    95 }
    89 }
    96 
    90 
    97 //----------------------------------------------------------------------------
    91 //----------------------------------------------------------------------------
   165     {
   159     {
   166         mViewFeeder->updateContent(messageId);
   160         mViewFeeder->updateContent(messageId);
   167     }
   161     }
   168     QDEBUG_WRITE("UnifiedViewer feeder->updateContent END");
   162     QDEBUG_WRITE("UnifiedViewer feeder->updateContent END");
   169 
   163 
       
   164     // Dont show the scroll bar.
       
   165     mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
       
   166 
   170     if ( (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) &&
   167     if ( (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) &&
   171          (mViewFeeder->slideCount() > 0) )
   168          (mViewFeeder->slideCount() > 0) )
   172     {
   169     {
   173         mScrollArea->setTotalSlides(mViewFeeder->slideCount());
   170         mScrollArea->setTotalSlides(mViewFeeder->slideCount());
   174     }
   171     }
   224 // @see header file
   221 // @see header file
   225 //---------------------------------------------------------------
   222 //---------------------------------------------------------------
   226 void UnifiedViewer::resizeEvent(QGraphicsSceneResizeEvent * event)
   223 void UnifiedViewer::resizeEvent(QGraphicsSceneResizeEvent * event)
   227 {
   224 {
   228     Q_UNUSED(event)
   225     Q_UNUSED(event)
   229     mContentsWidget->resize(this->rect().width(), -1);
   226     mContentsWidget->resize(this->rect().width(), this->rect().height()+1);
   230 }
   227 }
   231 
   228 
   232 //---------------------------------------------------------------
   229 //---------------------------------------------------------------
   233 // UnifiedViewer::handleDeleteAction
   230 // UnifiedViewer::handleDeleteAction
   234 // @see header file
   231 // @see header file
   235 //---------------------------------------------------------------
   232 //---------------------------------------------------------------
   236 void UnifiedViewer::handleDeleteAction()
   233 void UnifiedViewer::handleDeleteAction()
   237 {
   234 {
   238     bool result = HbMessageBox::question(LOC_DELETE_MESSAGE,
   235     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
   239                                          LOC_BUTTON_DELETE, 
   236                                          LOC_BUTTON_DELETE, 
   240                                          LOC_BUTTON_CANCEL);
   237                                          LOC_BUTTON_CANCEL);
   241     if (result)
       
   242     {
       
   243         QList<int> msgIdList;
       
   244         msgIdList << mMessageId;
       
   245 
       
   246         ConversationsEngine::instance()->deleteMessages(msgIdList);
       
   247 
       
   248         QVariantList param;
       
   249         if (mMsgCount > 1)
       
   250         {
       
   251             param << MsgBaseView::CV;
       
   252             param << MsgBaseView::UNIVIEWER;
       
   253         }
       
   254         else
       
   255         {
       
   256             param << MsgBaseView::CLV;
       
   257             param << MsgBaseView::UNIVIEWER;
       
   258         }
       
   259 
       
   260         QVariant dummy(QVariant::Invalid);
       
   261         param << dummy;
       
   262         emit switchView(param);
       
   263     }
       
   264 
       
   265 }
   238 }
   266 
   239 
   267 //---------------------------------------------------------------
   240 //---------------------------------------------------------------
   268 // UnifiedViewer::sendMessage
   241 // UnifiedViewer::sendMessage
   269 // @see header file
   242 // @see header file
   270 //---------------------------------------------------------------
   243 //---------------------------------------------------------------
   271 void UnifiedViewer::sendMessage(const QString& phoneNumber)
   244 void UnifiedViewer::sendMessage(const QString& phoneNumber,const QString& alias)
   272     {
   245     {
   273     ConvergedMessage message;
   246     ConvergedMessage message;
   274     message.setBodyText(QString());
   247     message.setBodyText(QString());
   275 
   248 
   276     ConvergedMessageAddress address;
   249     ConvergedMessageAddress address;
   277     address.setAlias(phoneNumber);
   250     address.setAlias(alias);
   278     address.setAddress(phoneNumber);
   251     address.setAddress(phoneNumber);
   279     message.addToRecipient(address);
   252     message.addToRecipient(address);
   280 
   253 
   281     QByteArray dataArray;
   254     QByteArray dataArray;
   282     QDataStream messageStream
   255     QDataStream messageStream
   310     }
   283     }
   311 
   284 
   312     return true;
   285     return true;
   313 }
   286 }
   314 
   287 
       
   288 //---------------------------------------------------------------
       
   289 // UnifiedViewer::onDialogDeleteMsg
       
   290 // @see header file
       
   291 //---------------------------------------------------------------
       
   292 void UnifiedViewer::onDialogDeleteMsg(HbAction* action)
       
   293 {
       
   294     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
   295     if (action == dlg->actions().at(0)) {
       
   296         QList<int> msgIdList;
       
   297         msgIdList << mMessageId;
       
   298 
       
   299         ConversationsEngine::instance()->deleteMessages(msgIdList);
       
   300 
       
   301         QVariantList param;
       
   302         if (mMsgCount > 1) {
       
   303             param << MsgBaseView::CV;
       
   304             param << MsgBaseView::UNIVIEWER;
       
   305         }
       
   306         else {
       
   307             param << MsgBaseView::CLV;
       
   308             param << MsgBaseView::UNIVIEWER;
       
   309         }
       
   310 
       
   311         QVariant dummy(QVariant::Invalid);
       
   312         param << dummy;
       
   313         emit switchView(param);
       
   314     }
       
   315 }
       
   316 
   315 // EOF
   317 // EOF