videocollection/tsrc/stubs/src/hbmenu.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: stub hbmessagebox
       
    15 * 
       
    16 */
       
    17 
       
    18 #include "hbmenu.h"
       
    19 #include "hbmenudata.h"
       
    20 
       
    21 HbAction *HbMenuData::mMenuAction = 0;
       
    22 HbAction *HbMenuData::mActiveAction = 0;
       
    23 bool HbMenuData::mEnabledSetted = false;
       
    24 bool HbMenuData::mReturnEmptyActionList = false;
       
    25 QPointF HbMenuData::mExecPoint = QPointF();
       
    26 
       
    27 
       
    28 HbMenu::HbMenu(QGraphicsItem *parent):
       
    29     HbWidget(parent)
       
    30 {
       
    31 }
       
    32 
       
    33 HbMenu::~HbMenu()
       
    34 {
       
    35     HbMenuData::reset();
       
    36     
       
    37     QMap<QString, HbAction*>::const_iterator iter = mActions.constBegin();
       
    38     while(iter != mActions.constEnd())
       
    39     {
       
    40         delete *iter;           
       
    41         iter++;
       
    42     }
       
    43     mActions.clear();
       
    44 }
       
    45 
       
    46 HbAction* HbMenu::exec(const QPointF &pos, HbAction *action)
       
    47 {
       
    48     Q_UNUSED(action);
       
    49     
       
    50     HbMenuData::mExecPoint = pos;
       
    51     
       
    52     return 0;
       
    53 }
       
    54 
       
    55 HbAction* HbMenu::menuAction()
       
    56 {
       
    57     return HbMenuData::mMenuAction;
       
    58 }
       
    59 
       
    60 HbAction* HbMenu::activeAction()
       
    61 {
       
    62     return HbMenuData::mActiveAction;
       
    63 }
       
    64 
       
    65 void HbMenu::setActiveAction(HbAction *action)
       
    66 {
       
    67     if (HbMenuData::mActiveAction)
       
    68     {
       
    69         delete HbMenuData::mActiveAction;
       
    70         HbMenuData::mActiveAction = 0;
       
    71     }
       
    72     HbMenuData::mActiveAction = action;
       
    73 }
       
    74 
       
    75 void HbMenu::setEnabled(bool enabled)
       
    76 {
       
    77     HbMenuData::mEnabledSetted = enabled;
       
    78 }
       
    79 
       
    80 HbAction* HbMenu::addAction(const QString &text,
       
    81     const QObject *receiver,
       
    82     const char *member)
       
    83 {
       
    84     Q_UNUSED(receiver);
       
    85     Q_UNUSED(member);
       
    86     
       
    87     if(mActions.contains(text))
       
    88     {
       
    89         delete mActions[text];
       
    90     }
       
    91     HbAction *action = new HbAction(text); 
       
    92     mActions[text] = action;
       
    93     
       
    94     return action;
       
    95 }
       
    96 
       
    97 QList<HbAction*> HbMenu::actions()
       
    98 {
       
    99     if(HbMenuData::mReturnEmptyActionList)
       
   100     {
       
   101         return QList<HbAction*>();
       
   102     }
       
   103     return mActions.values();
       
   104 }
       
   105 
       
   106 void HbMenu::setPreferredPos(const QPointF &position,
       
   107     HbPopup::Placement placement)
       
   108 {
       
   109     Q_UNUSED(placement);
       
   110 
       
   111     HbMenuData::mExecPoint = position;
       
   112 }
       
   113 
       
   114 void HbMenu::setDismissPolicy(HbPopup::DismissPolicy dismissPolicy)
       
   115 {
       
   116     Q_UNUSED(dismissPolicy);
       
   117 }
       
   118 
       
   119 // end of file