locationpickerservice/src/locationpickercollectioncontent.cpp
changeset 31 8db05346071b
parent 30 96df3ab41000
equal deleted inserted replaced
30:96df3ab41000 31:8db05346071b
    25 // ======== MEMBER FUNCTIONS ========
    25 // ======== MEMBER FUNCTIONS ========
    26 
    26 
    27 // ----------------------------------------------------------------
    27 // ----------------------------------------------------------------
    28 // LocationPickerCollectionContent::LocationPickerCollectionContent()
    28 // LocationPickerCollectionContent::LocationPickerCollectionContent()
    29 // -----------------------------------------------------------------
    29 // -----------------------------------------------------------------
    30 LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId )
    30 LocationPickerCollectionContent::LocationPickerCollectionContent( quint32 aCollectionId )
    31     :mOrientation(aOrientation),
    31     :mProxyModel(NULL),
    32 	 mProxyModel(NULL),
       
    33     mModel(NULL),
    32     mModel(NULL),
    34     mDataManager(NULL),
    33     mDataManager(NULL),
    35 	mLocationFound(false)
    34 	mLocationFound(false)
    36 {
    35 {
    37     // Create a standard model for the view list
    36     // Create a standard model for the view list
    38     mModel = new QStandardItemModel( this );
    37     mModel = new QStandardItemModel( this );
    39     if(mModel)
    38     // create data manager to manage data in the model
       
    39     mDataManager = LocationPickerDataManager::getInstance();
       
    40     if( mDataManager->populateModel( *mModel, ELocationPickerCollectionContent, aCollectionId ) )
    40     {
    41     {
    41         // create data manager to manage data in the model
    42         // Create the proxy model.
    42         mDataManager = LocationPickerDataManager::getInstance();
    43         mProxyModel = new LocationPickerProxyModel();
    43         if( mDataManager->populateModel( *mModel, ELocationPickerCollectionContent, mOrientation , aCollectionId ) )
    44         mProxyModel->setSourceModel(mModel);
    44         {
    45         mProxyModel->setDynamicSortFilter(TRUE);
    45             // Create the proxy model.
    46         mProxyModel->setSortRole(Qt::DisplayRole);
    46             mProxyModel = new LocationPickerProxyModel(mOrientation);
    47         mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    47             mProxyModel->setSourceModel(mModel);
    48         // sort
    48             mProxyModel->setDynamicSortFilter(TRUE);
    49         mProxyModel->sort(0, Qt::AscendingOrder);
    49             mProxyModel->setSortRole(Qt::DisplayRole);
    50         mLocationFound = true;
    50             mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
       
    51             // sort
       
    52             mProxyModel->sort(0, Qt::AscendingOrder);
       
    53             mLocationFound = true;
       
    54         }
       
    55         else
       
    56         {
       
    57             // no locations to display.
       
    58             QStandardItem *modelItem = new QStandardItem();
       
    59             modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
       
    60             mModel->appendRow( modelItem );
       
    61             mLocationFound = false;
       
    62         }
       
    63     }
    51     }
       
    52     else
       
    53     {
       
    54         // no locations to display.
       
    55         QStandardItem *modelItem = new QStandardItem();
       
    56         modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
       
    57         mModel->appendRow( modelItem );
       
    58         mLocationFound = false;
       
    59      }
    64 }
    60 }
    65 
    61 
    66 // ----------------------------------------------------------------
    62 // ----------------------------------------------------------------
    67 // LocationPickerCollectionContent::~LocationPickerCollectionContent
    63 // LocationPickerCollectionContent::~LocationPickerCollectionContent
    68 // -----------------------------------------------------------------
    64 // -----------------------------------------------------------------
    76 // LocationPickerCollectionContent::getProxyModel
    72 // LocationPickerCollectionContent::getProxyModel
    77 // -----------------------------------------------------------------
    73 // -----------------------------------------------------------------
    78 LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
    74 LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
    79 {
    75 {
    80     return mProxyModel;
    76     return mProxyModel;
    81 }
       
    82 
       
    83 // ----------------------------------------------------------------
       
    84 // LocationPickerCollectionContent::getStandardModel
       
    85 // -----------------------------------------------------------------
       
    86 QStandardItemModel* LocationPickerCollectionContent::getStandardModel()
       
    87 {
       
    88     return mModel;
       
    89 }
    77 }
    90 
    78 
    91 // ----------------------------------------------------------------------------
    79 // ----------------------------------------------------------------------------
    92 // LocationPickerCollectionContent::getData()
    80 // LocationPickerCollectionContent::getData()
    93 // ----------------------------------------------------------------------------
    81 // ----------------------------------------------------------------------------