phoneapp/phoneuiview2/src/phoneuiqtview.cpp
changeset 22 6bb1b21d2484
parent 21 92ab7f8d0eab
child 27 2f8f8080a020
equal deleted inserted replaced
21:92ab7f8d0eab 22:6bb1b21d2484
     1 /*!
     1 /*!
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  Phone UI's Qt view.
    14 * Description:  Phone UI's Qt view.
    15 *
    15 *
    16 */
    16 */
    17 #include <hbinstance.h>
    17 #include <hbinstance.h>
    18 #include <QSignalMapper>
    18 #include <qsignalmapper>
       
    19 #include <qtimer>
    19 #include <hbaction.h>
    20 #include <hbaction.h>
    20 #include <hbtoolbar.h>
    21 #include <hbtoolbar.h>
    21 #include <hbvolumesliderpopup.h>
    22 #include <hbvolumesliderpopup.h>
    22 #include <hbnamespace.h>
    23 #include <hbnamespace.h>
    23 #include <bubblemanager2.h>
    24 #include <bubblemanager2.h>
    27 #include <xqserviceutil.h>
    28 #include <xqserviceutil.h>
    28 #include <dialpad.h>
    29 #include <dialpad.h>
    29 
    30 
    30 #include "phoneuiqtview.h"
    31 #include "phoneuiqtview.h"
    31 #include "phoneaction.h"
    32 #include "phoneaction.h"
       
    33 #include "qtphonelog.h"
       
    34 const int LongKeyPressTimeOut(600);
    32 
    35 
    33 PhoneUIQtView::PhoneUIQtView (HbMainWindow &window, QGraphicsItem *parent) :
    36 PhoneUIQtView::PhoneUIQtView (HbMainWindow &window, QGraphicsItem *parent) :
    34     HbView (parent),
    37     HbView (parent),
    35     m_window(window),
    38     m_window(window),
    36     m_volumeSlider (0), 
    39     m_volumeSlider (0),
    37     m_expandSignalMapper(0), 
    40     m_expandSignalMapper(0),
    38     m_participantListSignalMapper(0),
    41     m_participantListSignalMapper(0),
    39     m_volumeCommandId(0)
    42     m_volumeCommandId(0),
       
    43     m_longPressTimer(0)
    40 {
    44 {
    41     setTitle(hbTrId("txt_phone_title_telephone"));
    45     setTitle(hbTrId("txt_phone_title_telephone"));
    42 
    46 
    43     // call handling widget
    47     // Call handling widget
    44     m_bubbleManager = new BubbleManager (this);
    48     m_bubbleManager = new BubbleManager (this);
    45 
       
    46     setWidget(m_bubbleManager);
    49     setWidget(m_bubbleManager);
    47 
    50 
       
    51     // Long press timer
       
    52     m_longPressTimer = new QTimer(this);
       
    53     m_longPressTimer->setSingleShot(true);
       
    54     connect(m_longPressTimer, SIGNAL(timeout()), this, SLOT(longEndKeyPressEvent()));
       
    55 
    48     // Dialpad
    56     // Dialpad
    49     m_dialpad = new Dialpad();
    57     m_dialpad = new Dialpad(m_window);
    50     m_dialpad->setCallButtonEnabled(false);
    58     m_dialpad->setCallButtonEnabled(false);
       
    59     m_dialpad->setTapOutsideDismiss(true);
    51     connect(&m_dialpad->editor(),SIGNAL(contentsChanged()),
    60     connect(&m_dialpad->editor(),SIGNAL(contentsChanged()),
    52             SLOT(onEditorContentChanged()));
    61             SLOT(onEditorContentChanged()));
    53     connect(m_dialpad,SIGNAL(aboutToClose()),this,
    62     connect(m_dialpad,SIGNAL(aboutToClose()),this,
    54                 SLOT(dialpadClosed()));
    63                 SLOT(dialpadClosed()));
    55             
    64 
    56     // Set event filter         
    65     // Set event filter
    57     m_window.installEventFilter(this);
    66     m_window.installEventFilter(this);
    58     
    67 
    59     
       
    60     m_signalMapper = new QSignalMapper (this);
    68     m_signalMapper = new QSignalMapper (this);
    61     connect(m_signalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
    69     connect(m_signalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
    62     connect(&m_window,SIGNAL(orientationChanged(Qt::Orientation)),
    70     connect(&m_window,SIGNAL(orientationChanged(Qt::Orientation)),
    63             this,SLOT(handleOrientationChange(Qt::Orientation)));
    71             this,SLOT(handleOrientationChange(Qt::Orientation)));
    64     
    72 
    65     m_menuSignalMapper = new QSignalMapper(this);
    73     m_menuSignalMapper = new QSignalMapper(this);
    66     connect(m_menuSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(command(int)));
    74     connect(m_menuSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(command(int)));
    67     
    75 
    68     m_bubbleManager->handleOrientationChange(m_window.orientation());
    76     m_bubbleManager->handleOrientationChange(m_window.orientation());
    69     
    77 
    70     // changed exit softkey to back button
    78     // change exit softkey to back button
    71     m_backAction = new HbAction(Hb::BackAction,this);
    79     m_backAction = new HbAction(Hb::BackAction, this);
    72     connect(m_backAction, SIGNAL(triggered()), this, SLOT(backButtonClicked()));
    80     connect(m_backAction, SIGNAL(triggered()), this, SLOT(backButtonClicked()));
    73     HbAction *action = m_window.softKeyAction(Hb::SecondarySoftKey);
    81     setNavigationAction(m_backAction);
    74     m_window.removeSoftKeyAction(Hb::SecondarySoftKey,action);
    82 
    75     m_window.addSoftKeyAction(Hb::SecondarySoftKey,m_backAction);
       
    76     
       
    77     m_emptyAction = new HbAction(this);
       
    78     
       
    79     createToolBarActions();
    83     createToolBarActions();
    80 }
    84 }
    81 
    85 
    82 PhoneUIQtView::~PhoneUIQtView ()
    86 PhoneUIQtView::~PhoneUIQtView ()
    83 {
    87 {
   100     const PhoneAction& action )
   104     const PhoneAction& action )
   101 {
   105 {
   102     HbAction* bubbleAction = new HbAction ();
   106     HbAction* bubbleAction = new HbAction ();
   103     bubbleAction->setText (action.text());
   107     bubbleAction->setText (action.text());
   104     bubbleAction->setIcon (action.icon());
   108     bubbleAction->setIcon (action.icon());
   105     setActionRole(action,*bubbleAction);                    
   109     setActionRole(action,*bubbleAction);
   106     m_bubbleManager->addAction (bubbleId, bubbleAction);
   110     m_bubbleManager->addAction (bubbleId, bubbleAction);
   107     
   111 
   108     QList<int> bubbles = m_bubbleMap.keys();
   112     QList<int> bubbles = m_bubbleMap.keys();
   109     bool found(false);
   113     bool found(false);
   110     
   114 
   111     for ( int i=0; i<bubbles.size(); ++i ) {
   115     for ( int i=0; i<bubbles.size(); ++i ) {
   112         if (bubbleId==bubbles[i]){
   116         if (bubbleId==bubbles[i]){
   113             connect(bubbleAction, SIGNAL (triggered ()), m_bubbleMap.value(bubbleId), SLOT (map ()));
   117             connect(bubbleAction, SIGNAL (triggered ()), m_bubbleMap.value(bubbleId), SLOT (map ()));
   114             m_bubbleMap.value(bubbleId)->setMapping(bubbleAction, action.command());
   118             m_bubbleMap.value(bubbleId)->setMapping(bubbleAction, action.command());
   115             m_bubbleActionMap.value(bubbleId)->append(bubbleAction);
   119             m_bubbleActionMap.value(bubbleId)->append(bubbleAction);
   116             found = true;
   120             found = true;
   117         }
   121         }
   118     }
   122     }
   119     
   123 
   120     if (!found) {
   124     if (!found) {
   121         QSignalMapper *mapper = new QSignalMapper();
   125         QSignalMapper *mapper = new QSignalMapper();
   122         connect(mapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
   126         connect(mapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
   123         connect(bubbleAction, SIGNAL (triggered ()), mapper, SLOT (map ()));
   127         connect(bubbleAction, SIGNAL (triggered ()), mapper, SLOT (map ()));
   124         mapper->setMapping (bubbleAction, action.command());
   128         mapper->setMapping (bubbleAction, action.command());
   129     }
   133     }
   130 }
   134 }
   131 
   135 
   132 void PhoneUIQtView::addParticipantListAction(
   136 void PhoneUIQtView::addParticipantListAction(
   133     int commandId,
   137     int commandId,
   134     const QString& text, 
   138     const QString& text,
   135     const HbIcon& icon)
   139     const HbIcon& icon)
   136 {
   140 {
   137     HbAction* action = new HbAction ();
   141     HbAction* action = new HbAction ();
   138     action->setText (text);
   142     action->setText (text);
   139     action->setIcon (icon);
   143     action->setIcon (icon);
   140     m_bubbleManager->addParticipantListAction(action);
   144     m_bubbleManager->addParticipantListAction(action);
   141     
   145 
   142     if (!m_participantListSignalMapper) {
   146     if (!m_participantListSignalMapper) {
   143         m_participantListSignalMapper = new QSignalMapper();
   147         m_participantListSignalMapper = new QSignalMapper();
   144         connect(m_participantListSignalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
   148         connect(m_participantListSignalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int)));
   145     }
   149     }
   146     
   150 
   147     connect(action, SIGNAL (triggered ()), m_participantListSignalMapper, SLOT (map ()));
   151     connect(action, SIGNAL (triggered ()), m_participantListSignalMapper, SLOT (map ()));
   148     m_participantListSignalMapper->setMapping (action, commandId);
   152     m_participantListSignalMapper->setMapping (action, commandId);
   149     m_participantListActions.append( action );
   153     m_participantListActions.append( action );
   150 }
   154 }
   151 
   155 
   152 void PhoneUIQtView::clearParticipantListActions()
   156 void PhoneUIQtView::clearParticipantListActions()
   153 {
   157 {
   154    
   158 
   155     if (m_participantListSignalMapper) {
   159     if (m_participantListSignalMapper) {
   156         m_bubbleManager->clearParticipantListActions();
   160         m_bubbleManager->clearParticipantListActions();
   157         
   161 
   158         foreach (HbAction *action, m_participantListActions ) {
   162         foreach (HbAction *action, m_participantListActions ) {
   159             m_participantListSignalMapper->removeMappings(action);
   163             m_participantListSignalMapper->removeMappings(action);
   160             delete action;
   164             delete action;
   161         }
   165         }
   162             
   166 
   163         m_participantListActions.clear();
   167         m_participantListActions.clear();
   164         delete m_participantListSignalMapper;
   168         delete m_participantListSignalMapper;
   165         m_participantListSignalMapper = 0;
   169         m_participantListSignalMapper = 0;
   166     }
   170     }
   167 
   171 
   168 }
   172 }
   169 
   173 
   170 void PhoneUIQtView::clearBubbleCommands (int bubbleId)
   174 void PhoneUIQtView::clearBubbleCommands (int bubbleId)
   171 {
   175 {
   172     m_bubbleManager->clearActions (bubbleId);   
   176     m_bubbleManager->clearActions (bubbleId);
   173     QSignalMapper *mapper = m_bubbleMap.value(bubbleId);
   177     QSignalMapper *mapper = m_bubbleMap.value(bubbleId);
   174     
   178 
   175     if (mapper) {
   179     if (mapper) {
   176         QList<HbAction *> *actions = m_bubbleActionMap.value(bubbleId);
   180         QList<HbAction *> *actions = m_bubbleActionMap.value(bubbleId);
   177         
   181 
   178         foreach (HbAction *action, *actions ) {
   182         foreach (HbAction *action, *actions ) {
   179             mapper->removeMappings(action);
   183             mapper->removeMappings(action);
   180             delete action;
   184             delete action;
   181         }
   185         }
   182             
   186 
   183         actions->clear();
   187         actions->clear();
   184         m_bubbleMap.remove(bubbleId);
   188         m_bubbleMap.remove(bubbleId);
   185         m_bubbleActionMap.remove(bubbleId);
   189         m_bubbleActionMap.remove(bubbleId);
   186         delete mapper;
   190         delete mapper;
   187         delete actions;      
   191         delete actions;
   188     }
   192     }
   189 
   193 
   190 }
   194 }
   191 
   195 
   192 void PhoneUIQtView::setToolbarActions(const QList<PhoneAction*>& actions)
   196 void PhoneUIQtView::setToolbarActions(const QList<PhoneAction*>& actions)
   194     // clear current toolbar actions
   198     // clear current toolbar actions
   195     for (int i=0;i<toolBar()->actions().count();++i) {
   199     for (int i=0;i<toolBar()->actions().count();++i) {
   196         m_signalMapper->removeMappings(
   200         m_signalMapper->removeMappings(
   197                 static_cast<HbAction*>(toolBar()->actions().at(i)));
   201                 static_cast<HbAction*>(toolBar()->actions().at(i)));
   198     }
   202     }
   199     
   203 
   200     QList<QAction*> toolBarActions = toolBar()->actions();
   204     QList<QAction*> toolBarActions = toolBar()->actions();
   201     
   205 
   202     if (toolBarActions.size()<actions.size()) {
   206     if (toolBarActions.size()<actions.size()) {
   203         for (int i=toolBarActions.size(); i<actions.size(); ++i) {
   207         for (int i=toolBarActions.size(); i<actions.size(); ++i) {
   204             toolBar()->addAction(m_toolbarActions.at(i));
   208             toolBar()->addAction(m_toolbarActions.at(i));
   205         }
   209         }
   206     } else if (toolBarActions.size()>actions.size()) {
   210     } else if (toolBarActions.size()>actions.size()) {
   209                 HbAction* action = static_cast<HbAction*>(toolBarActions.at(i-1));
   213                 HbAction* action = static_cast<HbAction*>(toolBarActions.at(i-1));
   210                 toolBar()->removeAction(action);
   214                 toolBar()->removeAction(action);
   211             }
   215             }
   212         }
   216         }
   213     }
   217     }
   214     
   218 
   215     for (int i=0; i<toolBar()->actions().size(); ++i) {    
   219     for (int i=0; i<toolBar()->actions().size(); ++i) {
   216     
   220 
   217         if (i<actions.count()) {
   221         if (i<actions.count()) {
   218             HbAction* action = static_cast<HbAction*>(toolBar()->actions().at(i));
   222             HbAction* action = static_cast<HbAction*>(toolBar()->actions().at(i));
   219             action->setText(actions.at(i)->text());
   223             action->setText(actions.at(i)->text());
   220             action->setIcon(actions.at(i)->icon());            
   224             action->setIcon(actions.at(i)->icon());
   221             action->setDisabled(actions.at(i)->isDisabled());
   225             action->setDisabled(actions.at(i)->isDisabled());
   222             
   226 
   223             m_signalMapper->setMapping(action, actions.at(i)->command());
   227             m_signalMapper->setMapping(action, actions.at(i)->command());
   224         }
   228         }
   225     }
   229     }
   226     
   230 
   227     if ( m_window.orientation() == Qt::Horizontal ) {
   231     if ( m_window.orientation() == Qt::Horizontal ) {
   228         toolBar()->setOrientation(Qt::Horizontal);
   232         toolBar()->setOrientation(Qt::Horizontal);
   229     }
   233     }
   230     // update toolbar
   234     // update toolbar
   231     toolBar()->update();
   235     toolBar()->update();
   236     toolBar()->hide ();
   240     toolBar()->hide ();
   237 }
   241 }
   238 
   242 
   239 void PhoneUIQtView::showToolbar ()
   243 void PhoneUIQtView::showToolbar ()
   240 {
   244 {
   241     setFocus();       
   245     setFocus();
   242     toolBar()->show();
   246     toolBar()->show();
   243 }
   247 }
   244 
   248 
   245 int PhoneUIQtView::volumeSliderValue ()
   249 int PhoneUIQtView::volumeSliderValue ()
   246 {
   250 {
   253 
   257 
   254 void PhoneUIQtView::removeVolumeSlider ()
   258 void PhoneUIQtView::removeVolumeSlider ()
   255 {
   259 {
   256     if (m_volumeSlider) {
   260     if (m_volumeSlider) {
   257         if (m_volumeSlider->isVisible()) {
   261         if (m_volumeSlider->isVisible()) {
   258             m_volumeSlider->hide();   
   262             m_volumeSlider->hide();
   259         }
   263         }
   260         m_volumeSlider->deleteLater();
   264         m_volumeSlider->deleteLater();
   261         m_volumeSlider = 0;
   265         m_volumeSlider = 0;
   262     }
   266     }
   263 }
   267 }
   269 
   273 
   270 void PhoneUIQtView::setVolumeSliderValue (
   274 void PhoneUIQtView::setVolumeSliderValue (
   271         int value, int commandId, int maxVolumeValue, int minVolumeValue)
   275         int value, int commandId, int maxVolumeValue, int minVolumeValue)
   272 {
   276 {
   273     m_volumeCommandId = commandId;
   277     m_volumeCommandId = commandId;
   274     
   278 
   275     if (!m_volumeSlider) {
   279     if (!m_volumeSlider) {
   276         m_volumeSlider = new HbVolumeSliderPopup ();
   280         m_volumeSlider = new HbVolumeSliderPopup ();
   277         m_volumeSlider->setDismissPolicy(HbDialog::TapOutside);
   281         m_volumeSlider->setDismissPolicy(HbDialog::TapOutside);
   278         m_volumeSlider->setTimeout (10000); // TODO: 10 seconds for now, replace with correct value when spec is ready and says what it is
   282         m_volumeSlider->setTimeout (10000); // TODO: 10 seconds for now, replace with correct value when spec is ready and says what it is
   279         connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeSliderChanged(int)));
   283         connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeSliderChanged(int)));
   280         connect(m_volumeSlider, SIGNAL(aboutToClose()), this, SLOT(volumeSliderClosed()));
   284         connect(m_volumeSlider, SIGNAL(aboutToClose()), this, SLOT(volumeSliderClosed()));
   281     }
   285     }
   282         
   286 
   283 
   287 
   284     if (m_volumeSlider->minimum() != minVolumeValue ||
   288     if (m_volumeSlider->minimum() != minVolumeValue ||
   285             m_volumeSlider->maximum() !=  maxVolumeValue  ) {
   289             m_volumeSlider->maximum() !=  maxVolumeValue  ) {
   286         m_volumeSlider->setRange (minVolumeValue, maxVolumeValue);
   290         m_volumeSlider->setRange (minVolumeValue, maxVolumeValue);
   287     }
   291     }
   288     
   292 
   289     if (value != m_volumeSlider->value())
   293     if (value != m_volumeSlider->value())
   290         m_volumeSlider->setValue (value);
   294         m_volumeSlider->setValue (value);
   291     
   295 
   292     if (false == m_volumeSlider->isVisible()) {
   296     if (false == m_volumeSlider->isVisible()) {
   293         m_volumeSlider->show();
   297         m_volumeSlider->show();
   294     }
   298     }
   295 }
   299 }
   296 
   300 
   297 void PhoneUIQtView::volumeSliderChanged(int value)
   301 void PhoneUIQtView::volumeSliderChanged(int value)
   298 {
   302 {
   299     Q_UNUSED (value);
   303     Q_UNUSED (value);
   300     emit command (m_volumeCommandId);   
   304     emit command (m_volumeCommandId);
   301 }
   305 }
   302 
   306 
   303 void PhoneUIQtView::setExpandAction(int bubbleId, int commandId)
   307 void PhoneUIQtView::setExpandAction(int bubbleId, int commandId)
   304 {
   308 {
   305     removeExpandAction(bubbleId);
   309     removeExpandAction(bubbleId);
   306     
   310 
   307     HbAction* action = new HbAction();
   311     HbAction* action = new HbAction();
   308     m_bubbleManager->setExpandAction(bubbleId, action);
   312     m_bubbleManager->setExpandAction(bubbleId, action);
   309     
   313 
   310     if (!m_expandSignalMapper) {
   314     if (!m_expandSignalMapper) {
   311         m_expandSignalMapper = new QSignalMapper(this);
   315         m_expandSignalMapper = new QSignalMapper(this);
   312         connect(m_expandSignalMapper, SIGNAL (mapped (int)), 
   316         connect(m_expandSignalMapper, SIGNAL (mapped (int)),
   313                 this, SIGNAL (command (int)));
   317                 this, SIGNAL (command (int)));
   314     }
   318     }
   315     
   319 
   316     connect(action, SIGNAL (triggered ()), m_expandSignalMapper, SLOT (map ()));
   320     connect(action, SIGNAL (triggered ()), m_expandSignalMapper, SLOT (map ()));
   317     m_expandSignalMapper->setMapping(action, commandId);
   321     m_expandSignalMapper->setMapping(action, commandId);
   318     
   322 
   319     m_expandActionMap.insert(bubbleId,action);
   323     m_expandActionMap.insert(bubbleId,action);
   320 }
   324 }
   321 
   325 
   322 void PhoneUIQtView::removeExpandAction(int bubbleId)
   326 void PhoneUIQtView::removeExpandAction(int bubbleId)
   323 {
   327 {
   325         m_bubbleManager->setExpandAction(bubbleId, 0);
   329         m_bubbleManager->setExpandAction(bubbleId, 0);
   326         HbAction* action = m_expandActionMap.value(bubbleId);
   330         HbAction* action = m_expandActionMap.value(bubbleId);
   327         m_expandSignalMapper->removeMappings(action);
   331         m_expandSignalMapper->removeMappings(action);
   328         m_expandActionMap.remove(bubbleId);
   332         m_expandActionMap.remove(bubbleId);
   329         delete action;
   333         delete action;
   330     }   
   334     }
   331 }
   335 }
   332 
   336 
   333 void PhoneUIQtView::showDialpad()
   337 void PhoneUIQtView::showDialpad()
   334 {
   338 {
   335     if (false == m_dialpad->isVisible()) {
   339     if (false == m_dialpad->isVisible()) {
   342 {
   346 {
   343     if (true == m_dialpad->isVisible())
   347     if (true == m_dialpad->isVisible())
   344         m_dialpad->closeDialpad();
   348         m_dialpad->closeDialpad();
   345 }
   349 }
   346 
   350 
   347 bool PhoneUIQtView::isDialpadVisible()   
   351 bool PhoneUIQtView::isDialpadVisible()
   348 {
   352 {
   349     return m_dialpad->isVisible();
   353     return m_dialpad->isVisible();
   350 }
   354 }
   351 
   355 
   352 QString PhoneUIQtView::dialpadText()   
   356 QString PhoneUIQtView::dialpadText()
   353 {
   357 {
   354     return m_dialpad->editor().text();
   358     return m_dialpad->editor().text();
   355 }
   359 }
   356 
   360 
   357 void PhoneUIQtView::clearAndHideDialpad()   
   361 void PhoneUIQtView::clearAndHideDialpad()
   358 {
   362 {
   359     m_dialpad->editor().setText(QString(""));
   363     m_dialpad->editor().setText(QString(""));
   360     hideDialpad();
   364     hideDialpad();
   361 }
   365 }
   362 
   366 
   373         HbAction* action = static_cast<HbAction*>(menu()->actions().at(i-1));
   377         HbAction* action = static_cast<HbAction*>(menu()->actions().at(i-1));
   374         m_menuSignalMapper->removeMappings(action);
   378         m_menuSignalMapper->removeMappings(action);
   375         menu()->removeAction(action);
   379         menu()->removeAction(action);
   376         delete action;
   380         delete action;
   377     }
   381     }
   378     
   382 
   379     for (int i=0; i<actions.count(); ++i) {
   383     for (int i=0; i<actions.count(); ++i) {
   380         HbAction* action = new HbAction();
   384         HbAction* action = new HbAction();
   381         action->setText(actions.at(i)->text());
   385         action->setText(actions.at(i)->text());
   382         menu()->addAction(action);
   386         menu()->addAction(action);
   383         connect(action, SIGNAL(triggered()), m_menuSignalMapper, SLOT(map()));
   387         connect(action, SIGNAL(triggered()), m_menuSignalMapper, SLOT(map()));
   396     if (orientation==Qt::Horizontal) {
   400     if (orientation==Qt::Horizontal) {
   397         toolBar()->setOrientation(Qt::Horizontal);
   401         toolBar()->setOrientation(Qt::Horizontal);
   398     }
   402     }
   399 
   403 
   400     m_bubbleManager->handleOrientationChange(orientation);
   404     m_bubbleManager->handleOrientationChange(orientation);
   401     
   405 
   402     setDialpadPosition();
   406     setDialpadPosition();
   403 }
   407 }
   404 
   408 
   405 void PhoneUIQtView::backButtonClicked()
   409 void PhoneUIQtView::backButtonClicked()
   406 {
   410 {
   420 
   424 
   421 bool PhoneUIQtView::eventFilter(QObject * /*watched*/, QEvent * event)
   425 bool PhoneUIQtView::eventFilter(QObject * /*watched*/, QEvent * event)
   422 {
   426 {
   423     if (event->type() == QEvent::KeyPress) {
   427     if (event->type() == QEvent::KeyPress) {
   424         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
   428         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
   425         qDebug() << "PhoneUIQtView::eventFilter: pressed key " << keyEvent->key();
   429         PHONE_DEBUG2("PhoneUIQtView::eventFilter pressed key:", keyEvent->key());
       
   430         if(keyEvent->key() == Qt::Key_No) {
       
   431             m_longPressTimer->stop();
       
   432             m_longPressTimer->start(LongKeyPressTimeOut);
       
   433         }
   426         emit keyPressed(keyEvent);
   434         emit keyPressed(keyEvent);
   427         return false;
   435         return false;
   428     } else if (event->type() == QEvent::KeyRelease) {
   436     } else if (event->type() == QEvent::KeyRelease) {
       
   437         m_longPressTimer->stop();
   429         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
   438         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
   430         qDebug() << "PhoneUIQtView::eventFilter: released key " << keyEvent->key();
   439         PHONE_DEBUG2("PhoneUIQtView::eventFilter released key:", keyEvent->key());
   431         emit keyReleased(keyEvent);
   440         emit keyReleased(keyEvent);
   432         return false;
   441         return false;
   433     } else {
   442     } else {
   434         return false;
   443         return false;
   435     }
   444     }
   442     if (m_window.orientation() == Qt::Horizontal) {
   451     if (m_window.orientation() == Qt::Horizontal) {
   443             // dialpad takes half of the screen
   452             // dialpad takes half of the screen
   444         m_dialpad->setPos(QPointF(screenRect.width()/2,
   453         m_dialpad->setPos(QPointF(screenRect.width()/2,
   445                                   this->scenePos().y()));
   454                                   this->scenePos().y()));
   446         m_dialpad->setPreferredSize(screenRect.width()/2,
   455         m_dialpad->setPreferredSize(screenRect.width()/2,
   447                                            (screenRect.height()-scenePos().y()));                                  
   456                                            (screenRect.height()-scenePos().y()));
   448     } else {
   457     } else {
   449         // dialpad takes 65% of the screen height
   458         // dialpad takes 65% of the screen height
   450         qreal screenHeight = screenRect.height();
   459         qreal screenHeight = screenRect.height();
   451         m_dialpad->setPos(QPointF(0,
   460         m_dialpad->setPos(QPointF(0,
   452                                   screenHeight/2.25));
   461                                   screenHeight/2.25));
   453         m_dialpad->setPreferredSize(screenRect.width(),
   462         m_dialpad->setPreferredSize(screenRect.width(),
   454                                     screenHeight-screenHeight/2.25);        
   463                                     screenHeight-screenHeight/2.25);
   455     }
   464     }
   456 }
   465 }
   457 
   466 
   458 void PhoneUIQtView::setActionRole(const PhoneAction& pa, HbAction& action)
   467 void PhoneUIQtView::setActionRole(const PhoneAction& pa, HbAction& action)
   459 {
   468 {
   473     }
   482     }
   474 }
   483 }
   475 
   484 
   476 void PhoneUIQtView::shutdownPhoneApp()
   485 void PhoneUIQtView::shutdownPhoneApp()
   477 {
   486 {
   478     qDebug() << "PhoneUIQtView::shutdownPhoneApp ";
   487     PHONE_DEBUG("PhoneUIQtView::shutdownPhoneApp");
   479     QCoreApplication::quit();
   488     QCoreApplication::quit();
   480 }
   489 }
   481 
   490 
   482 void PhoneUIQtView::setBackButtonVisible(bool visible)
   491 void PhoneUIQtView::setBackButtonVisible(bool visible)
   483 {
   492 {
   484     HbAction *oldAction = m_window.softKeyAction(Hb::SecondarySoftKey);
       
   485     m_window.removeSoftKeyAction(Hb::SecondarySoftKey, oldAction);
       
   486     if (visible) {
   493     if (visible) {
   487         m_window.addSoftKeyAction(Hb::SecondarySoftKey, m_backAction);
   494         setNavigationAction(m_backAction);
   488         }
   495         }
   489     else {
   496     else {
   490         m_window.addSoftKeyAction(Hb::SecondarySoftKey, m_emptyAction);
   497         setNavigationAction(0);
   491     }
   498     }
   492 }
   499 }
   493 
   500 
       
   501 void PhoneUIQtView::longEndKeyPressEvent()
       
   502 {
       
   503     Q_ASSERT(m_longPressTimer);
       
   504     m_longPressTimer->stop();
       
   505     emit endKeyLongPress();
       
   506 }