// ----------------------------------------------------------------------------
// SatAppMenuProvider::loadMainView
// ----------------------------------------------------------------------------
//
void SatAppMenuProvider::loadMainView()
{
    qDebug("SATAPP: SatAppMenuProvider::loadMainView >");

    // create actions
    mSoftKeyQuitAction = new HbAction(Hb::QuitNaviAction,this);
    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction,this);

    bool docmlLoad = false;
    HbDocumentLoader loader;
    // ownership of the objects are transferred to caller
    mObjects = loader.load(SATAPP_DOCML,&docmlLoad);
    Q_ASSERT(docmlLoad);
    qDebug("SATAPP: SatAppMenuProvider main view found");
    // load setupmenu view
    mSetupMenuView = qobject_cast<HbView *>(loader.findWidget
            (SATAPP_SETUPMENU_VIEW));
    // find setupmenu view items
    mListWidget = qobject_cast<HbListWidget *>
        ( loader.findWidget(SATAPP_MENUITEM ));
    // connect setupmenu view menu
    HbAction *menuAction = mSetupMenuView->menu()->addAction(
        hbTrId("txt_common_menu_exit"));
    SAT_ASSERT(connect(menuAction, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    SAT_ASSERT(connect(mSoftKeyQuitAction, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    // set this view as current view
    mMainWindow->addView(mSetupMenuView);
    mMainWindow->setCurrentView(mSetupMenuView);

    // load selectitem view
    mSelectItemView = qobject_cast<HbView *>(loader.findWidget
            (SATAPP_SELECTITEM_VIEW));
    // find selectitem view items
    mSubTitle = qobject_cast<HbLabel *>
        ( loader.findWidget(SATAPP_SUBTITLE) );
    mSelectListWidget = qobject_cast<HbListWidget *>
        ( loader.findWidget(SATAPP_SELECTITEM ));
    // connect selectitem view menu
    HbAction *menuBack = mSelectItemView->menu()->addAction(
        hbTrId("txt_common_opt_back"));
    SAT_ASSERT(connect(menuBack, SIGNAL(triggered()),
        mSoftKeyBackAction, SIGNAL(triggered())));
    HbAction *menuQuit = mSelectItemView->menu()->addAction(
        hbTrId("txt_common_menu_exit"));

    SAT_ASSERT(connect(menuQuit, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    qDebug("SATAPP: SatAppMenuProvider::loadMainView <");

}
Esempio n. 2
0
/*!
    Prompts user for destination.
 */
void CpIapItem::queryDestination()
{
    OstTraceFunctionEntry0(CPIAPITEM_QUERYDESTINATION_ENTRY);
    bool readingSuccessful = true;
    QStringList destinations;
    try {
        mCmm->allDestinations(mDestinationList);
        
        for (int i = 0; i < mDestinationList.count(); i++) {
            CmDestinationShim *destination = mCmm->destination(mDestinationList[i]);
            if ((destination->id() != mDestId)
                && !destination->isHidden()) {

                QString dest = destination->name();
                destinations.append(dest);
            } else {
                // Remove this destination from list to sync both lists
                mDestinationList.removeAt(i);
                i--;
            }
            delete destination;
        }
    } catch (const std::exception&) {
        OstTrace0(TRACE_NORMAL, CPIAPITEM_QUERYDESTINATION, "CpIapItem::queryDestination: exception caught");
        readingSuccessful = false;
    }
    
    if (readingSuccessful) {
        // Load DocML 
        bool ok = false;
        HbDocumentLoader *loader = new HbDocumentLoader();
        loader->load(":/docml/cpdestinationplugindialogs.docml", &ok);
        mDialog = qobject_cast<HbDialog *>(loader->findWidget("dialog"));
        HbLabel *heading = qobject_cast<HbLabel *>(loader->findWidget("heading"));
        heading->setPlainText(hbTrId("txt_occ_dialog_select_network_destination_to_be_ac"));
        mList = qobject_cast<HbRadioButtonList *>(loader->findWidget("radioButtonList")); 
        mList->setItems(destinations);
        mList->setSelected(0);
        mOk = qobject_cast<HbAction *>(loader->findObject("okAction"));
        bool connected = connect(mOk, 
                                 SIGNAL(triggered()), 
                                 this, 
                                 SLOT(queryDialogClosed()));
        Q_ASSERT(connected);
        mDialog->show();
        delete loader;
    } else {
        OstTrace0(TRACE_NORMAL, DUP1_CPIAPITEM_QUERYDESTINATION, " CpIapItem::queryDestination: exception caught");
        showErrorNote(hbTrId("txt_occ_info_unable_to_read_settings"));
    }
    OstTraceFunctionExit0(CPIAPITEM_QUERYDESTINATION_EXIT);
}
/*!
 \fn bool NmHsWidget::loadDocML(HbDocumentLoader &loader)
 
 loads layout data and child items from docml file. Must be called after constructor.
 /return true if loading succeeded, otherwise false. False indicates that object is unusable
 */
bool NmHsWidget::loadDocML(HbDocumentLoader &loader)
{
    NM_FUNCTION;
    
    bool ok(false);
    loader.load(KNmHsWidgetDocML, &ok);
    
    if(ok) {
        mMainContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetMainContainer));  
        mWidgetContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContainer));
        mContentContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContentContainer));
        mEmptySpaceContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetEmptySpaceContainer));
        mNoMailsLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetNoMailsLabel));
        mListView = static_cast<HbListView*> (loader.findWidget(KNmHsWidgetMailListView));
        if (!mMainContainer || !mWidgetContainer || !mContentContainer 
                || !mEmptySpaceContainer || !mNoMailsLabel || !mListView) {
            //something failed in documentloader, no point to continue
            NM_ERROR(1,"NmHsWidget::loadDocML fail @ containers or label");
            ok = false;
        }
    }
    return ok;
}