mpx/mpxviewframeworkqt/example_vf_pluginresolving/plugins/welcomeviewplugin/src/welcomeview.cpp
changeset 64 92dbd2a406d9
equal deleted inserted replaced
61:3b098142db83 64:92dbd2a406d9
       
     1 /*
       
     2 * Copyright (c) 2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "welcomeview.h"
       
    19 
       
    20 #include <hbview.h>
       
    21 #include <hblabel.h>
       
    22 #include <hbmenu.h>
       
    23 #include <hbaction.h>
       
    24 #include <hbpusHbutton.h>
       
    25 
       
    26 #include <QSizePolicy>
       
    27 #include <QSignalMapper>
       
    28 #include <QGraphicsGridLayout>
       
    29 
       
    30 WelcomeView::WelcomeView(const QString &name) 
       
    31 : 
       
    32 HbView()
       
    33     {
       
    34     setObjectName(name);
       
    35     setTitle(name);
       
    36     mapper = new QSignalMapper(this);
       
    37     mapper->setParent(this);
       
    38     
       
    39     setTitle(title());
       
    40     QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::Fixed);
       
    41     
       
    42     QGraphicsGridLayout *layout = new QGraphicsGridLayout();
       
    43     
       
    44     label = new HbLabel();
       
    45     label->setSizePolicy(policy);
       
    46 //    label->setAlignment(Qt::AlignCenter);
       
    47     layout->addItem(label, 7, 1, 3, 1);
       
    48     
       
    49     connect(mapper, SIGNAL(mapped(int)), this, SLOT(setLabelText(int)));
       
    50     
       
    51     bool result = false;
       
    52 
       
    53 /*
       
    54     HbPushButton *buttonNextSib = new HbPushButton("Right", this);
       
    55     buttonNextSib->setSizePolicy(policy);
       
    56     layout->addItem(buttonNextSib, 1, 1, 1, 1);
       
    57 //    connectButton(buttonNextSib, HbViewCommandGoNextSibiling);
       
    58 
       
    59     HbPushButton *buttonPreviousSib = new HbPushButton("Left", this);
       
    60     buttonPreviousSib->setSizePolicy(policy);
       
    61     layout->addItem(buttonPreviousSib, 2, 1, 1, 1);
       
    62 //    connectButton(buttonPreviousSib, HbViewCommandGoPreviousSibiling);
       
    63 
       
    64     
       
    65     HbPushButton *buttonParent = new HbPushButton("Parent", this);
       
    66     buttonParent->setSizePolicy(policy);
       
    67     layout->addItem(buttonParent, 3, 1, 1, 1);
       
    68 //    connectButton(buttonParent, HbViewCommandGoParent);
       
    69     
       
    70     HbPushButton *buttonChild = new HbPushButton("Child", this);
       
    71     buttonChild->setSizePolicy(policy);
       
    72     layout->addItem(buttonChild, 4, 1, 1, 1);
       
    73 //    connectButton(buttonChild, HbViewCommandGoDefaultChild);
       
    74     
       
    75     HbPushButton *buttonForward = new HbPushButton("Forward", this);
       
    76     buttonForward->setSizePolicy(policy);
       
    77     layout->addItem(buttonForward, 5, 1, 1, 1);
       
    78 //    connectButton(buttonForward, HbViewCommandGoForward);
       
    79 
       
    80     HbPushButton *buttonBack = new HbPushButton("Back", this);
       
    81     buttonBack->setSizePolicy(policy);
       
    82     layout->addItem(buttonBack, 6, 1, 1, 1);
       
    83 //    connectButton(buttonBack, HbViewCommandGoBack);
       
    84     
       
    85     this->setLayout(layout);
       
    86 */
       
    87     }
       
    88 
       
    89 WelcomeView::~WelcomeView()
       
    90     {
       
    91     }
       
    92 
       
    93 bool WelcomeView::connectButton(HbPushButton *button, int commandId)
       
    94     {
       
    95     bool result = connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
       
    96     if (result) {
       
    97         mapper->setMapping(button, commandId);
       
    98     }
       
    99     return result;
       
   100     }
       
   101 
       
   102 void WelcomeView::setLabelText(int commandId) 
       
   103     {
       
   104     QString ltext("command id: %1");
       
   105     label->setText(ltext.arg(commandId));
       
   106     }
       
   107