locationpickerservice/src/locationpickercollectioncontent.cpp
changeset 20 cd10d5b85554
parent 17 0f22fb80ebba
child 30 96df3ab41000
equal deleted inserted replaced
17:0f22fb80ebba 20:cd10d5b85554
    29 // -----------------------------------------------------------------
    29 // -----------------------------------------------------------------
    30 LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId )
    30 LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId )
    31     :mOrientation(aOrientation),
    31     :mOrientation(aOrientation),
    32 	 mProxyModel(NULL),
    32 	 mProxyModel(NULL),
    33     mModel(NULL),
    33     mModel(NULL),
    34     mDataManager(NULL)
    34     mDataManager(NULL),
       
    35 	mLocationFound(false)
    35 {
    36 {
    36     // Create a standard model for the view list
    37     // Create a standard model for the view list
    37     mModel = new QStandardItemModel( this );
    38     mModel = new QStandardItemModel( this );
    38     mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerCollectionContent );
    39     // create data manager to manage data in the model
    39     if( mDataManager->populateModel( mOrientation , aCollectionId ) )
    40     mDataManager = LocationPickerDataManager::getInstance();
       
    41     if( mDataManager->populateModel( *mModel, ELocationPickerCollectionContent, mOrientation , aCollectionId ) )
    40     {
    42     {
    41         // Create the proxy model.
    43         // Create the proxy model.
    42         mProxyModel = new LocationPickerProxyModel(mOrientation);
    44         mProxyModel = new LocationPickerProxyModel(mOrientation);
    43         mProxyModel->setSourceModel(mModel);
    45         mProxyModel->setSourceModel(mModel);
    44         mProxyModel->setDynamicSortFilter(TRUE);
    46         mProxyModel->setDynamicSortFilter(TRUE);
    45         mProxyModel->setSortRole(Qt::DisplayRole);
    47         mProxyModel->setSortRole(Qt::DisplayRole);
    46         mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    48         mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    47         // sort
    49         // sort
    48         mProxyModel->sort(0, Qt::AscendingOrder);
    50         mProxyModel->sort(0, Qt::AscendingOrder);
       
    51         mLocationFound = true;
    49     }
    52     }
    50     else
    53     else
    51     {
    54     {
    52         // no locations to display.
    55         // no locations to display.
    53         QStandardItem *modelItem = new QStandardItem();
    56         QStandardItem *modelItem = new QStandardItem();
    54         modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
    57         modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
    55         mModel->appendRow( modelItem );
    58         mModel->appendRow( modelItem );
       
    59         mLocationFound = false;
    56      }
    60      }
    57 }
    61 }
    58 
    62 
    59 // ----------------------------------------------------------------
    63 // ----------------------------------------------------------------
    60 // LocationPickerCollectionContent::~LocationPickerCollectionContent
    64 // LocationPickerCollectionContent::~LocationPickerCollectionContent
    61 // -----------------------------------------------------------------
    65 // -----------------------------------------------------------------
    62 LocationPickerCollectionContent::~LocationPickerCollectionContent()
    66 LocationPickerCollectionContent::~LocationPickerCollectionContent()
    63 {
    67 {
    64     delete mProxyModel;
    68     delete mProxyModel;
    65     delete mModel;
    69     delete mModel;
    66     delete mDataManager;
       
    67 }
    70 }
    68 
    71 
    69 // ----------------------------------------------------------------
    72 // ----------------------------------------------------------------
    70 // LocationPickerCollectionContent::getProxyModel
    73 // LocationPickerCollectionContent::getProxyModel
    71 // -----------------------------------------------------------------
    74 // -----------------------------------------------------------------
    72 LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
    75 LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
    73     {
    76 {
    74     return mProxyModel;
    77     return mProxyModel;
    75     }
    78 }
    76 
       
    77 
    79 
    78 // ----------------------------------------------------------------
    80 // ----------------------------------------------------------------
    79 // LocationPickerCollectionContent::getDataManager
    81 // LocationPickerCollectionContent::getStandardModel
    80 // -----------------------------------------------------------------
    82 // -----------------------------------------------------------------
    81 LocationPickerDataManager* LocationPickerCollectionContent::getDataManager()
    83 QStandardItemModel* LocationPickerCollectionContent::getStandardModel()
    82     {
    84 {
    83     return mDataManager;
    85     return mModel;
    84     }
    86 }
       
    87 
       
    88 // ----------------------------------------------------------------------------
       
    89 // LocationPickerCollectionContent::getData()
       
    90 // ----------------------------------------------------------------------------
       
    91 
       
    92 void LocationPickerCollectionContent::getData( QModelIndex aIndex, quint32& aValue )
       
    93 {
       
    94     QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() );
       
    95     QVariant var = item->data( Qt::UserRole );
       
    96     aValue = var.toUInt();
       
    97 }
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // LocationPickerCollectionContent::locationFound()
       
   101 // ----------------------------------------------------------------------------
       
   102 bool LocationPickerCollectionContent::locationFound()
       
   103 {
       
   104     return mLocationFound;
       
   105 }