messagingapp/msgui/conversationview/src/msgconversationbaseview.cpp
changeset 34 84197e66a4bd
parent 31 ebfee66fde93
child 43 35b64624a9e7
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
    48 //---------------------------------------------------------------
    48 //---------------------------------------------------------------
    49 // MsgConversationBaseView::MsgConversationBaseView
    49 // MsgConversationBaseView::MsgConversationBaseView
    50 // Constructor
    50 // Constructor
    51 //---------------------------------------------------------------
    51 //---------------------------------------------------------------
    52 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) :
    52 MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) :
    53 MsgBaseView(parent),
    53     MsgBaseView(parent), mConversationId(-1), mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe,
    54 mConversationId(-1),
    54         KMsgCVIdProperty, KMsgCVIdKey)
    55 mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe,KMsgCVIdProperty, 
    55 {
    56         KMsgCVIdKey)
    56     connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction()));
    57 { 
       
    58     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));   
       
    59     initView();
    57     initView();
    60 }
    58 }
    61 
    59 
    62 //---------------------------------------------------------------
    60 //---------------------------------------------------------------
    63 // MsgConversationBaseView::~MsgConversationBaseView
    61 // MsgConversationBaseView::~MsgConversationBaseView
    64 // Destructor
    62 // Destructor
    65 //---------------------------------------------------------------
    63 //---------------------------------------------------------------
    66 MsgConversationBaseView::~MsgConversationBaseView()
    64 MsgConversationBaseView::~MsgConversationBaseView()
    67 {   
    65 {
    68 }
    66 }
    69 
    67 
    70 //---------------------------------------------------------------
    68 //---------------------------------------------------------------
    71 // MsgConversationBaseView::openConversationView
    69 // MsgConversationBaseView::openConversationView
    72 // Launches conversation view for entry id and mode
    70 // Launches conversation view for entry id and mode
    73 //---------------------------------------------------------------
    71 //---------------------------------------------------------------
    74 void MsgConversationBaseView::openConversation(qint64 convId)
    72 void MsgConversationBaseView::openConversation(qint64 convId)
    75 {
    73 {
    76     ConversationsEngine::instance()->getConversations(convId);
    74     ConversationsEngine::instance()->getConversations(convId);
    77     mConversationId = convId;
    75     mConversationId = convId;
    78     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
    76     connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction()));
    79     
    77 
    80 	// publsih conversation id
    78     // publsih conversation id
    81     mSettingsManager->writeItemValue(mCVIdkey,(int)mConversationId);
    79     mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId);
    82     
    80 
    83     if(mConversationView)
    81     if (mConversationView) {
    84         {
       
    85         mConversationView->refreshView();
    82         mConversationView->refreshView();
    86         }
    83     }
    87 }
    84 }
    88 
    85 
    89 //---------------------------------------------------------------
    86 //---------------------------------------------------------------
    90 // MsgConversationBaseView::initView
    87 // MsgConversationBaseView::initView
    91 // create and initialise the conversationview
    88 // create and initialise the conversationview
    92 //---------------------------------------------------------------
    89 //---------------------------------------------------------------
    93 void MsgConversationBaseView::initView()
    90 void MsgConversationBaseView::initView()
    94     {
    91 {
    95     
    92 
    96     // Create header widget
    93     // Create header widget
    97     mContactCard = new MsgContactCardWidget(this);
    94     mContactCard = new MsgContactCardWidget(this);
    98 
    95 
    99     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    96     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
   100 
    97 
   101     qreal spacing = HbDeviceProfile::profile(this).unitValue();
    98     qreal spacing = HbDeviceProfile::profile(this).unitValue();
   102     mMainLayout->setSpacing(spacing);
    99     mMainLayout->setSpacing(spacing);
   103     mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN,
   100     mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN);
   104                                    CONTENT_MARGIN, CONTENT_MARGIN);
       
   105 
   101 
   106     mMainLayout->addItem(mContactCard);
   102     mMainLayout->addItem(mContactCard);
   107 
   103 
   108     /**
   104     /**
   109      * Create conversation view and connect to proper signals.
   105      * Create conversation view and connect to proper signals.
   112      */
   108      */
   113     mConversationView = new MsgConversationView(mContactCard);
   109     mConversationView = new MsgConversationView(mContactCard);
   114 
   110 
   115     mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   111     mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   116 
   112 
   117     connect(mConversationView, SIGNAL(closeConversationView()),
   113     connect(mConversationView, SIGNAL(closeConversationView()), this, SLOT(closeConversationView()));
   118             this, SLOT(closeConversationView()));
   114 
   119 
   115     connect(mConversationView, SIGNAL(replyStarted()), this, SLOT(markMessagesAsRead()));
   120     connect(mConversationView,SIGNAL(replyStarted()),
   116 
   121             this,SLOT(markMessagesAsRead()));
   117     connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this,
   122 
   118         SIGNAL(switchView(const QVariantList&)));
   123     connect(mConversationView, SIGNAL(switchView(const QVariantList&)),
   119 
   124             this, SIGNAL(switchView(const QVariantList&)));
   120     connect(mConversationView, SIGNAL(vkbOpened(bool)), this, SLOT(hideChrome(bool)));
   125     
   121     connect(mConversationView, SIGNAL(vkbOpened(bool)), mContactCard, SLOT(ignoreSignals(bool)));
   126     connect(mConversationView,SIGNAL(hideChrome(bool)),this,SLOT(hideChrome(bool)));
       
   127 
   122 
   128     this->setMenu(mConversationView->menu());
   123     this->setMenu(mConversationView->menu());
   129 
   124 
   130     mMainLayout->addItem(mConversationView);
   125     mMainLayout->addItem(mConversationView);
   131 
   126 
   132     this->setLayout(mMainLayout);
   127     this->setLayout(mMainLayout);
   133     
   128 
   134     mSettingsManager = new XQSettingsManager(this);
   129     mSettingsManager = new XQSettingsManager(this);
   135           
   130 
   136 }
   131 }
   137 
   132 
   138 //---------------------------------------------------------------
   133 //---------------------------------------------------------------
   139 // MsgConversationBaseView::closeConversationView
   134 // MsgConversationBaseView::closeConversationView
   140 // close conversation view
   135 // close conversation view
   141 //---------------------------------------------------------------
   136 //---------------------------------------------------------------
   142 void MsgConversationBaseView::closeConversationView()
   137 void MsgConversationBaseView::closeConversationView()
   143 {
   138 {
   144    markMessagesAsRead();
   139     markMessagesAsRead();
   145 }
   140 }
   146 
   141 
   147 //---------------------------------------------------------------
   142 //---------------------------------------------------------------
   148 // MsgConversationBaseView::markMessagesAsRead
   143 // MsgConversationBaseView::markMessagesAsRead
   149 // Mark unread msgs in cv as read
   144 // Mark unread msgs in cv as read
   150 //---------------------------------------------------------------
   145 //---------------------------------------------------------------
   151 void MsgConversationBaseView::markMessagesAsRead()
   146 void MsgConversationBaseView::markMessagesAsRead()
   152     {
   147 {
   153     if( mConversationId >= 0)
   148     if (mConversationId >= 0) {
   154         {
       
   155         ConversationsEngine::instance()->markConversationRead(mConversationId);
   149         ConversationsEngine::instance()->markConversationRead(mConversationId);
   156         }
   150     }
   157     }
   151 }
   158 
   152 
   159 //---------------------------------------------------------------
   153 //---------------------------------------------------------------
   160 // MsgConversationBaseView::saveContentToDrafts
   154 // MsgConversationBaseView::saveContentToDrafts
   161 // saves the editors content to drafts
   155 // saves the editors content to drafts
   162 //---------------------------------------------------------------
   156 //---------------------------------------------------------------
   163 void MsgConversationBaseView::saveContentToDrafts()
   157 void MsgConversationBaseView::saveContentToDrafts()
   164     {
   158 {
   165     bool result = false;
   159     bool result = false;
   166     if( mConversationId >= 0)
   160     if (mConversationId >= 0) {
   167         {
       
   168         result = mConversationView->saveContentToDrafts();
   161         result = mConversationView->saveContentToDrafts();
   169         }
   162     }
   170     
   163 
   171     if(result)
   164     if (result) {
   172         {
       
   173         HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
   165         HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
   174         }
   166     }
   175     }
   167 }
   176 
   168 
   177 //--------------------------------------------------------------- 
   169 //--------------------------------------------------------------- 
   178 // MsgConversationBaseView::conversationId 
   170 // MsgConversationBaseView::conversationId 
   179 // get the conversation ID 
   171 // get the conversation ID 
   180 //---------------------------------------------------------------     
   172 //---------------------------------------------------------------     
   181 qint64 MsgConversationBaseView::conversationId() 
   173 qint64 MsgConversationBaseView::conversationId()
   182     { 
   174 {
   183     return mConversationId; 
   175     return mConversationId;
   184     }
   176 }
   185 
   177 
   186 //---------------------------------------------------------------
   178 //---------------------------------------------------------------
   187 // MsgConversationBaseView::clearContent
   179 // MsgConversationBaseView::clearContent
   188 // clears conversation view content
   180 // clears conversation view content
   189 //---------------------------------------------------------------
   181 //---------------------------------------------------------------
   196 //---------------------------------------------------------------
   188 //---------------------------------------------------------------
   197 // MsgConversationBaseView::handleOk
   189 // MsgConversationBaseView::handleOk
   198 //
   190 //
   199 //---------------------------------------------------------------
   191 //---------------------------------------------------------------
   200 void MsgConversationBaseView::handleOk(const QVariant& result)
   192 void MsgConversationBaseView::handleOk(const QVariant& result)
   201     {
   193 {
   202     Q_UNUSED(result)
   194     Q_UNUSED(result)
   203     }
   195 }
   204 
   196 
   205 //---------------------------------------------------------------
   197 //---------------------------------------------------------------
   206 // MsgConversationBaseView::handleError
   198 // MsgConversationBaseView::handleError
   207 //
   199 //
   208 //---------------------------------------------------------------
   200 //---------------------------------------------------------------
   209 void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage)
   201 void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage)
   210     {
   202 {
   211     Q_UNUSED(errorMessage)
   203     Q_UNUSED(errorMessage)
   212     Q_UNUSED(errorCode)
   204     Q_UNUSED(errorCode)
   213     }
   205 }
   214 
   206 
   215 //---------------------------------------------------------------
   207 //---------------------------------------------------------------
   216 // MsgConversationBaseView::doDelayedConstruction
   208 // MsgConversationBaseView::doDelayedConstruction
   217 //
   209 //
   218 //---------------------------------------------------------------	
   210 //---------------------------------------------------------------	
   219 void MsgConversationBaseView::doDelayedConstruction()
   211 void MsgConversationBaseView::doDelayedConstruction()
   220 {
   212 {
   221     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
   213     disconnect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction()));
   222     QTimer::singleShot(50,this,SLOT(handleViewReady()));    
   214     QTimer::singleShot(50, this, SLOT(handleViewReady()));
   223 }
   215 }
   224 
       
   225 
   216 
   226 //---------------------------------------------------------------
   217 //---------------------------------------------------------------
   227 // MsgConversationBaseView::handleViewReady
   218 // MsgConversationBaseView::handleViewReady
   228 //
   219 //
   229 //---------------------------------------------------------------	
   220 //---------------------------------------------------------------	
   230 void MsgConversationBaseView::handleViewReady()
   221 void MsgConversationBaseView::handleViewReady()
   231     {
   222 {
   232     ConversationsEngine::instance()->fetchMoreConversations();
   223     ConversationsEngine::instance()->fetchMoreConversations();
   233     }
   224 }
   234 
   225 
   235 //---------------------------------------------------------------
   226 //---------------------------------------------------------------
   236 // MsgConversationBaseView::hideChrome
   227 // MsgConversationBaseView::hideChrome
   237 //
   228 //
   238 //---------------------------------------------------------------
   229 //---------------------------------------------------------------
   239 void MsgConversationBaseView::hideChrome(bool hide)
   230 void MsgConversationBaseView::hideChrome(bool hide)
   240     {
   231 {
   241     if(hide)
   232     if (hide) {
   242         {        
       
   243         this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem);
   233         this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem);
   244         this->setContentFullScreen(true);
   234         this->setContentFullScreen(true);
   245         
   235 
   246         if(this->mainWindow()->orientation() == Qt::Horizontal)
   236         if (this->mainWindow()->orientation() == Qt::Horizontal) {
   247             {
       
   248             mMainLayout->removeItem(mContactCard);
   237             mMainLayout->removeItem(mContactCard);
   249             mContactCard->hide();
   238             mContactCard->hide();
   250             }
       
   251         }
   239         }
   252     else
   240     }
   253         {
   241     else {
   254         this->showItems(Hb::StatusBarItem | Hb::TitleBarItem);
   242         this->showItems(Hb::StatusBarItem | Hb::TitleBarItem);
   255         this->setContentFullScreen(false);
   243         this->setContentFullScreen(false);
   256         
   244 
   257         if(!mContactCard->isVisible())
   245         if (!mContactCard->isVisible()) {
   258             {
   246             mMainLayout->insertItem(0, mContactCard);
   259             mMainLayout->insertItem(0,mContactCard);
       
   260             mContactCard->show();
   247             mContactCard->show();
   261             }
       
   262         }
   248         }
   263     }
   249     }
       
   250 }
   264 
   251 
   265 //---------------------------------------------------------------
   252 //---------------------------------------------------------------
   266 // MsgConversationBaseView::setPSCVId
   253 // MsgConversationBaseView::setPSCVId
   267 //
   254 //
   268 //---------------------------------------------------------------
   255 //---------------------------------------------------------------
   269 void MsgConversationBaseView::setPSCVId(bool setId)
   256 void MsgConversationBaseView::setPSCVId(bool setId)
   270 {
   257 {
   271     if(setId){
   258     if (setId) {
   272     mSettingsManager->writeItemValue(mCVIdkey,(int)mConversationId);
   259         mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId);
   273     }
   260     }
   274     else {
   261     else {
   275     mSettingsManager->writeItemValue(mCVIdkey,-1);
   262         mSettingsManager->writeItemValue(mCVIdkey, -1);
   276     }
   263     }
   277 }
   264 }
   278 // EOF
   265 // EOF