bluetoothengine/btui/inc/btuimodelsortfilter.h
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTUIMODELSORTFILTER_H
       
    19 #define BTUIMODELSORTFILTER_H
       
    20 
       
    21 #include <QSortFilterProxyModel>
       
    22 #include <btuimodeltypes.h>
       
    23 
       
    24 /*!
       
    25     \class BtuiModelSortFilter
       
    26     \brief the class handling sorting and filtering Bluetooth devices.
       
    27 
       
    28     BtuiModelSortFilter handles filtering/sorting a list of Bluetooth devices.
       
    29 
       
    30     \\sa bluetoothuimodel
       
    31  */
       
    32 class BTUIMODEL_IMEXPORT BtuiModelSortFilter : public QSortFilterProxyModel 
       
    33 {
       
    34     Q_OBJECT
       
    35 
       
    36 public:
       
    37     
       
    38     // matching mechanism applied for filters defined in Btuim::DeviceListFilter
       
    39     enum FilterMode {
       
    40         ExactMatch, // The filter value of the device must equal to the specified filters
       
    41         AtLeastMatch, // The filter value of the device must contains 
       
    42                       // all the specified filters at least.
       
    43         RoughMatch, // match at least one of the specified filters
       
    44         Exclusive,  // not match any of the specified filters
       
    45     };
       
    46     
       
    47     explicit BtuiModelSortFilter( QObject *parent = 0 );
       
    48     virtual ~BtuiModelSortFilter();
       
    49     
       
    50     void setDeviceMajorFilter( int filter, FilterMode mode );
       
    51     void addDeviceMajorFilter( int filter, FilterMode mode );
       
    52     void clearDeviceMajorFilter( int filter, FilterMode mode );
       
    53     void clearDeviceMajorFilters();
       
    54     
       
    55     bool hasFilter( int filter, FilterMode mode );
       
    56     
       
    57 signals:
       
    58     void deviceAcceptedByFilter(int sourceRow);
       
    59     
       
    60 protected:
       
    61     
       
    62     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
       
    63     bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
       
    64 
       
    65 private:
       
    66     class FilterItem {
       
    67     public:
       
    68         int mFilter;
       
    69         FilterMode mMode;
       
    70         FilterItem(int filter, FilterMode mode ) {
       
    71             mFilter = filter; mMode = mode;
       
    72         }
       
    73         bool operator== ( const FilterItem & other ) const { 
       
    74             return mFilter == other.mFilter && mMode == other.mMode;
       
    75         }
       
    76     };
       
    77     
       
    78 private:
       
    79     QList<FilterItem> mFilters;
       
    80 };
       
    81 
       
    82 #endif // BTUIMODELSORTFILTER_H