qtinternetradio/ui/src/irplsview.cpp
changeset 0 09774dfdd46b
child 3 ee64f059b8e1
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     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 <hblistview.h>
       
    19 
       
    20 #include "irplsview.h"
       
    21 #include "irapplication.h"
       
    22 #include "irabstractviewmanager.h"
       
    23 #include "irqnetworkcontroller.h"
       
    24 #include "irplsmodel.h"
       
    25 #include "irqisdsdatastructure.h"
       
    26 #include "irplaycontroller.h"
       
    27 
       
    28 IRPlsView::IRPlsView(IRApplication* aApplication, TIRViewId aViewId) : 
       
    29                      IrAbstractListViewBase(aApplication, aViewId), iPlsModel(NULL)
       
    30 {
       
    31     connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
       
    32             this, SLOT(networkRequestNotified(IRQNetworkEvent)));
       
    33     setHeadingText(hbTrId("txt_irad_subtitle_stations_from_play_list"));
       
    34         
       
    35     iPlsModel = new IRPlsModel(this);
       
    36     iListView->setModel(iPlsModel);
       
    37     iListView->setCurrentIndex(iPlsModel->index(0));
       
    38 }
       
    39 
       
    40 IRPlsView::~IRPlsView()
       
    41 {
       
    42 }
       
    43 
       
    44 void IRPlsView::networkRequestNotified(IRQNetworkEvent aEvent)
       
    45 {
       
    46     if (getViewManager()->currentView() != this)
       
    47     {
       
    48         return;
       
    49     }
       
    50         
       
    51     switch (aEvent)
       
    52     {
       
    53         case EIRQNetworkConnectionEstablished:
       
    54             iApplication->closeConnectingDialog();
       
    55             
       
    56             if (EIR_UseNetwork_SelectItem == getUseNetworkReason())
       
    57             {
       
    58                 handleItemSelected();
       
    59             }
       
    60             setUseNetworkReason(EIR_UseNetwork_NoReason);
       
    61             
       
    62             break;
       
    63             
       
    64         default:
       
    65             break;
       
    66     }
       
    67 }
       
    68 
       
    69 void IRPlsView::handleItemSelected()
       
    70 {
       
    71     int currentRow = iListView->currentIndex().row();
       
    72     IRQChannelServerURL server;
       
    73     server.bitrate = 0;
       
    74     server.url = iPlsModel->getFile(currentRow);
       
    75     server.serverName = iPlsModel->getTitle(currentRow);
       
    76     IRQPreset preset;
       
    77     preset.insertChannelServer(server);
       
    78     preset.name = iPlsModel->getTitle(currentRow);
       
    79     preset.description = iPlsModel->getFile(currentRow);
       
    80     preset.shortDesc = iPlsModel->getFile(currentRow);
       
    81     preset.type = 0;
       
    82     preset.uniqID = 0;
       
    83     preset.presetId = 0;
       
    84 
       
    85     iPlayController->connectToChannel(&preset, EIRQAdhocExternal);
       
    86 }
       
    87 
       
    88 void IRPlsView::updateView()
       
    89 {
       
    90     iListView->reset();
       
    91     iListView->setCurrentIndex(iPlsModel->index(0));
       
    92 }