phoneuis/bubblemanager2/bubblecore/src/bubbleconferencehandler.cpp
changeset 30 ebdbd102c78a
parent 22 6bb1b21d2484
child 51 f39ed5e045e0
equal deleted inserted replaced
27:2f8f8080a020 30:ebdbd102c78a
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <QtGui>
    18 #include <QtGui>
    19 #include <hbaction.h>
    19 #include <hbaction.h>
    20 #include <hbpushbutton.h>
       
    21 #include <hbtextitem.h>
    20 #include <hbtextitem.h>
    22 #include <hblabel.h>
    21 #include <hblabel.h>
    23 #include <hblistview.h>
    22 #include <hblistview.h>
    24 #include <hbcolorscheme.h>
    23 #include <hbcolorscheme.h>
    25 
    24 
    26 #include "bubblemanager2.h"
    25 #include "bubblemanager2.h"
    27 #include "bubbleconferencehandler.h"
    26 #include "bubbleconferencehandler.h"
    28 #include "bubbleconferenceheader.h"
    27 #include "bubbleconferenceheader.h"
    29 #include "bubbleutils.h"
    28 #include "bubbleutils.h"
    30 #include "bubblebuttonstyle.h"
       
    31 #include "bubbleparticipantlistitem.h"
    29 #include "bubbleparticipantlistitem.h"
    32 #include "bubbleparticipantlistmodel.h"
    30 #include "bubbleparticipantlistmodel.h"
       
    31 #include "bubblebutton.h"
    33 
    32 
    34 static const int BUBBLE_SELECTION_TIMEOUT = 3000;
    33 static const int BUBBLE_SELECTION_TIMEOUT = 3000;
    35 
    34 
    36 BubbleConferenceHandler::BubbleConferenceHandler(
    35 BubbleConferenceHandler::BubbleConferenceHandler(
    37     BubbleWidgetManager& widgetManager,
    36     BubbleWidgetManager& widgetManager,
    48     spec.setTextHeight(4*HbDeviceProfile::current().unitValue());
    47     spec.setTextHeight(4*HbDeviceProfile::current().unitValue());
    49     mTimerLabel->setFontSpec(spec);
    48     mTimerLabel->setFontSpec(spec);
    50     mTimerLabel->setAlignment(Qt::AlignLeft);
    49     mTimerLabel->setAlignment(Qt::AlignLeft);
    51 
    50 
    52     mButtonCenter =
    51     mButtonCenter =
    53         qobject_cast<HbPushButton*>(widget(BubbleWidgetManager::CenterButton));
    52         qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::CenterButton));
    54     Q_ASSERT(mButtonCenter);
    53     Q_ASSERT(mButtonCenter);
    55     mButtonLeft =
    54     mButtonLeft =
    56         qobject_cast<HbPushButton*>(widget(BubbleWidgetManager::LeftButton));
    55         qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::LeftButton));
    57     Q_ASSERT(mButtonLeft);
    56     Q_ASSERT(mButtonLeft);
    58     mButtonRight =
    57     mButtonRight =
    59         qobject_cast<HbPushButton*>(widget(BubbleWidgetManager::RightButton));
    58         qobject_cast<BubbleButton*>(widget(BubbleWidgetManager::RightButton));
    60     Q_ASSERT(mButtonRight);
    59     Q_ASSERT(mButtonRight);
    61 
    60 
    62     mList =
    61     mList =
    63         qobject_cast<HbListView*>(widget(BubbleWidgetManager::ParticipantList));
    62         qobject_cast<HbListView*>(widget(BubbleWidgetManager::ParticipantList));
    64     Q_ASSERT(mList);
    63     Q_ASSERT(mList);
    68     mPrototype =
    67     mPrototype =
    69         qobject_cast<BubbleParticipantListItem*>(
    68         qobject_cast<BubbleParticipantListItem*>(
    70             widgetManager.createParticipantListItem());
    69             widgetManager.createParticipantListItem());
    71     Q_ASSERT(mPrototype);
    70     Q_ASSERT(mPrototype);
    72     mList->setItemPrototype(mPrototype);
    71     mList->setItemPrototype(mPrototype);
    73     connect(mPrototype,SIGNAL(selectionChanged(int)),
    72     connect(mList->selectionModel(),
    74             SLOT(handleItemSelected(int)));
    73             SIGNAL(currentChanged(QModelIndex,QModelIndex)),
       
    74             this,
       
    75             SLOT(handleItemSelected(QModelIndex,QModelIndex)));
    75 
    76 
    76     mSelectionTimer = new QTimer(this);
    77     mSelectionTimer = new QTimer(this);
    77     connect(mSelectionTimer,SIGNAL(timeout()),SLOT(clearSelection()));
    78     connect(mSelectionTimer,SIGNAL(timeout()),SLOT(clearSelection()));
    78     mSelectionTimer->setSingleShot(true);
    79     mSelectionTimer->setSingleShot(true);
    79 
    80 
   105 void BubbleConferenceHandler::readBubbleHeader( const BubbleHeader& header )
   106 void BubbleConferenceHandler::readBubbleHeader( const BubbleHeader& header )
   106 {
   107 {
   107     Q_ASSERT(header.isConference());
   108     Q_ASSERT(header.isConference());
   108     mHeader = static_cast<const BubbleConferenceHeader*>(&header);
   109     mHeader = static_cast<const BubbleConferenceHeader*>(&header);
   109 
   110 
       
   111     // set actions to item prototype
       
   112     QList<HbAbstractViewItem*> prototypes = mList->itemPrototypes();
       
   113     QList<HbAction*> actions = mHeader->participantListActions();
       
   114     foreach (HbAction* action, actions ) {
       
   115         mPrototype->addAction(action);
       
   116     }
       
   117 
   110     // populate participant list model
   118     // populate participant list model
   111     QList<BubbleHeader*> participants = mHeader->headers();
   119     QList<BubbleHeader*> participants = mHeader->headers();
   112     foreach(BubbleHeader* participant, participants) {
   120     foreach(BubbleHeader* participant, participants) {
   113          mModel->addParticipant(
   121          mModel->addParticipant(
   114             participant->bubbleId(),
   122             participant->bubbleId(),
   115             participant->cli(),
   123             participant->cli(),
   116             (int)participant->callState(),
   124             (int)participant->callState(),
   117             !(mHeader->callFlags()&BubbleManagerIF::NoCiphering));
   125             !(mHeader->callFlags()&BubbleManagerIF::NoCiphering));
   118     }
       
   119 
       
   120     // set actions to item prototype
       
   121     QList<HbAbstractViewItem*> prototypes = mList->itemPrototypes();
       
   122     QList<HbAction*> actions = mHeader->participantListActions();
       
   123     foreach (HbAction* action, actions ) {
       
   124         mPrototype->addAction(action);
       
   125     }
   126     }
   126 
   127 
   127     if (header.timerCost().length()) {
   128     if (header.timerCost().length()) {
   128         QColor color;
   129         QColor color;
   129         color = HbColorScheme::color("list_item_title_normal");
   130         color = HbColorScheme::color("list_item_title_normal");
   186 
   187 
   187     mTimerLabel->setPlainText(mHeader->timerCost());
   188     mTimerLabel->setPlainText(mHeader->timerCost());
   188     mTimerLabel->update();
   189     mTimerLabel->update();
   189 }
   190 }
   190 
   191 
   191 void BubbleConferenceHandler::handleItemSelected(int row)
   192 void BubbleConferenceHandler::handleItemSelected(
   192 {
   193     const QModelIndex & current,
   193     Q_ASSERT( mHeader != 0 );
   194     const QModelIndex & previous )
   194     // need to cast constness away
   195 {
   195     BubbleConferenceHeader& mutableHeader =
   196     Q_UNUSED(previous);
   196         const_cast<BubbleConferenceHeader&>(*mHeader);
   197 
   197     mutableHeader.setSelectedHeader(mModel->bubbleId(row));
   198     if (current.isValid()) {
   198     mSelectionTimer->stop();
   199         Q_ASSERT( mHeader != 0 );
   199     mSelectionTimer->start(BUBBLE_SELECTION_TIMEOUT);
   200         // need to cast constness away
       
   201         BubbleConferenceHeader& mutableHeader =
       
   202             const_cast<BubbleConferenceHeader&>(*mHeader);
       
   203         mutableHeader.setSelectedHeader(mModel->bubbleId(current.row()));
       
   204         mSelectionTimer->stop();
       
   205         mSelectionTimer->start(BUBBLE_SELECTION_TIMEOUT);
       
   206     }
   200 }
   207 }
   201 
   208 
   202 void BubbleConferenceHandler::clearSelection()
   209 void BubbleConferenceHandler::clearSelection()
   203 {
   210 {
   204     mList->selectionModel()->clear();
   211     mList->selectionModel()->clear();