locationpickerservice/src/locationpickerproxymodel.cpp
changeset 20 cd10d5b85554
parent 17 0f22fb80ebba
child 31 8db05346071b
equal deleted inserted replaced
17:0f22fb80ebba 20:cd10d5b85554
    20 
    20 
    21 // ----------------------------------------------------
    21 // ----------------------------------------------------
    22 // LocationPickerProxyModel::LocationPickerProxyModel()
    22 // LocationPickerProxyModel::LocationPickerProxyModel()
    23 // ----------------------------------------------------
    23 // ----------------------------------------------------
    24 
    24 
    25 LocationPickerProxyModel::LocationPickerProxyModel(Qt::Orientations aOrientation , QObject *parent)
    25 LocationPickerProxyModel::LocationPickerProxyModel( Qt::Orientations aOrientation , QObject *parent )
    26      :QSortFilterProxyModel(parent),
    26      :QSortFilterProxyModel(parent),
    27      mOrientation( aOrientation )
    27      mOrientation( aOrientation )
    28 {
    28 {
    29 }
    29 }
    30 
    30 
    31 // ----------------------------------------------------
    31 // ----------------------------------------------------
    32 // LocationPickerProxyModel::lessThan()
    32 // LocationPickerProxyModel::lessThan()
    33 // ----------------------------------------------------
    33 // ----------------------------------------------------
    34  bool LocationPickerProxyModel::lessThan(const QModelIndex &left,
    34  bool LocationPickerProxyModel::lessThan( const QModelIndex &left,
    35                                       const QModelIndex &right) const
    35                                       const QModelIndex &right ) const
    36 {
    36 {
    37      // get left and right items data and implement sort logic
    37      // get left and right items data and implement sort logic
    38      // return true if left is less than right
    38      // return true if left is less than right
    39 	 QVariant leftData = sourceModel()->data(left);
    39 	 QVariant leftData = sourceModel()->data(left);
    40      QVariant rightData = sourceModel()->data(right);
    40      QVariant rightData = sourceModel()->data(right);
    60 
    60 
    61  // ----------------------------------------------------
    61  // ----------------------------------------------------
    62 // LocationPickerProxyModel::filterAcceptsRow()
    62 // LocationPickerProxyModel::filterAcceptsRow()
    63 // ----------------------------------------------------
    63 // ----------------------------------------------------
    64 
    64 
    65 bool LocationPickerProxyModel::filterAcceptsRow(int sourceRow,
    65 bool LocationPickerProxyModel::filterAcceptsRow( int sourceRow,
    66         const QModelIndex &sourceParent) const
    66         const QModelIndex &sourceParent ) const
    67 {
    67 {
    68     if( mOrientation == Qt::Vertical)
    68     if( mOrientation == Qt::Vertical)
    69     {
    69     {
    70     // implement logic for search.
    70     // implement logic for search.
    71     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
    71     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
    80 }
    80 }
    81 
    81 
    82  // ----------------------------------------------------
    82  // ----------------------------------------------------
    83 // LocationPickerProxyModel::filterParameterChanged()
    83 // LocationPickerProxyModel::filterParameterChanged()
    84 // ----------------------------------------------------
    84 // ----------------------------------------------------
    85 void LocationPickerProxyModel::filterParameterChanged(QString aSearchText)
    85 void LocationPickerProxyModel::filterParameterChanged( QString aSearchText )
    86 {
    86 {
    87     mSearchText = " " + aSearchText;
    87     mSearchText = " " + aSearchText;
    88 }
    88 }