locationpickerservice/src/locationpickerappwindow.cpp
changeset 15 13ae750350c9
child 17 0f22fb80ebba
equal deleted inserted replaced
0:522cd55cc3d7 15:13ae750350c9
       
     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: LocationPickerAppWindow implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "locationpickerappwindow.h"
       
    19 #include "locationpickertoolbar.h"
       
    20 #include "locationpickerallview.h"
       
    21 #include "locationpickersearchview.h"
       
    22 #include "locationpickercollectionlistview.h"
       
    23 #include "locationpickerservice.h"
       
    24 #include "locationpickertypes.h"
       
    25 #include "locationpickertypes.h"
       
    26 #include "locationpickerdatamanager.h"
       
    27  
       
    28 // ----------------------------------------------------------------------------
       
    29 // LocationPickerAppWindow::LocationPickerAppWindow()
       
    30 // ----------------------------------------------------------------------------
       
    31 LocationPickerAppWindow::LocationPickerAppWindow(
       
    32         QWidget* aParent ):
       
    33         HbMainWindow( aParent )
       
    34 {
       
    35     // create the service object;
       
    36     mService = new LocationPickerService( this );
       
    37   
       
    38     LocationPickerToolBar *toolBar = new LocationPickerToolBar( this );
       
    39 
       
    40     // Create 'all' view, set the tool bar and add the view to main window
       
    41     mLocationPickerAllView = new LocationPickerAllView( this ); 
       
    42     if( !mLocationPickerAllView->locationsFound() )
       
    43     {
       
    44         toolBar->disableTabs();
       
    45     }
       
    46     mLocationPickerAllView->setToolBar(toolBar);
       
    47     addView(mLocationPickerAllView);
       
    48     setCurrentView(mLocationPickerAllView);
       
    49 
       
    50     // Create 'search' view, set the tool bar and add the view to main window
       
    51     mLocationPickerSearchView = new LocationPickerSearchView( this );
       
    52     mLocationPickerSearchView->setToolBar(toolBar);
       
    53     addView(mLocationPickerSearchView);
       
    54 
       
    55     // Create 'collection' view, set the tool bar and add the view to main window
       
    56     mLocationPickerCollectionListView = new LocationPickerCollectionListView( this );
       
    57     mLocationPickerCollectionListView->setToolBar(toolBar);
       
    58     addView(mLocationPickerCollectionListView);
       
    59     
       
    60 }
       
    61 
       
    62 
       
    63 // ----------------------------------------------------------------------------
       
    64 // LocationPickerAppWindow::~LocationPickerAppWindow()
       
    65 // ----------------------------------------------------------------------------
       
    66 LocationPickerAppWindow::~LocationPickerAppWindow()
       
    67 {
       
    68     delete mService;
       
    69 }
       
    70 
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // LocationPickerAppWindow::backButtonTriggered()
       
    74 // ----------------------------------------------------------------------------
       
    75 void LocationPickerAppWindow::backButtonTriggered()
       
    76 {
       
    77     if( currentViewIndex() > KNumberOfMainViews-1 )
       
    78     {
       
    79         //the current view is collection content view.
       
    80         //so come back to collection list view
       
    81         setCurrentView(mLocationPickerCollectionListView);
       
    82         deleteCollectionContentView();
       
    83     }
       
    84     else
       
    85     {
       
    86 		// Other views request complete with a invalid location picker item
       
    87 		QLocationPickerItem item;
       
    88 		item.mIsValid = false;
       
    89         mService->complete(item);
       
    90     }
       
    91 }
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // LocationPickerAppWindow::deleteCollectionContentView()
       
    95 // ----------------------------------------------------------------------------
       
    96 void LocationPickerAppWindow::deleteCollectionContentView()
       
    97 {
       
    98 	// call collection view's deleteCollectionContentView()
       
    99     mLocationPickerCollectionListView->deleteCollectionContentView();
       
   100 }
       
   101 
       
   102 // ----------------------------------------------------------------------------
       
   103 // LocationPickerAppWindow::itemSelected()
       
   104 // ----------------------------------------------------------------------------
       
   105 void LocationPickerAppWindow::itemSelected( quint32 aLmid )
       
   106 {
       
   107     QLocationPickerItem item;
       
   108     
       
   109     LocationPickerDataManager dataManager;
       
   110     dataManager.getLocationItem( aLmid, item );
       
   111 
       
   112     // complete the request
       
   113     mService->complete(item);
       
   114    
       
   115 }
       
   116 
       
   117 
       
   118 Q_IMPLEMENT_USER_METATYPE(QLocationPickerItem)