QTfrontend/model/ThemeFilterProxyModel.cpp
changeset 13283 f816b9e73fcb
parent 13257 7d7eb27dab31
child 14849 8ed0c3761640
equal deleted inserted replaced
13282:b13071610c07 13283:f816b9e73fcb
    31     isFilteringHidden = false;
    31     isFilteringHidden = false;
    32 }
    32 }
    33 
    33 
    34 bool ThemeFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
    34 bool ThemeFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
    35 {
    35 {
       
    36     QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
       
    37     bool searchOkay = true;
       
    38     if(!filterRegExp().isEmpty())
       
    39     {
       
    40         // Check regular expression set by the theme chooser search
       
    41         QString name = index.data(ThemeModel::ActualNameRole).toString();
       
    42         int in = filterRegExp().indexIn(name);
       
    43         searchOkay = in != -1;
       
    44     }
       
    45 
    36     if(isFilteringDLC || isFilteringHidden)
    46     if(isFilteringDLC || isFilteringHidden)
    37     {
    47     {
    38         QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
       
    39         bool isDLC = index.data(ThemeModel::IsDlcRole).toBool();
    48         bool isDLC = index.data(ThemeModel::IsDlcRole).toBool();
    40         bool isHidden = index.data(ThemeModel::IsHiddenRole).toBool();
    49         bool isHidden = index.data(ThemeModel::IsHiddenRole).toBool();
    41         if(
    50 
    42             ((isFilteringDLC && !isDLC) || !isFilteringDLC) &&
    51         return ( ((isFilteringDLC && !isDLC) || !isFilteringDLC) &&
    43             ((isFilteringHidden && !isHidden) || !isFilteringHidden))
    52                  ((isFilteringHidden && !isHidden) || !isFilteringHidden) ) &&
    44         {
    53                searchOkay;
    45             if(!filterRegExp().isEmpty())
       
    46             {
       
    47                 // Also check regular expression set by the theme chooser search
       
    48                 QString name = index.data(ThemeModel::ActualNameRole).toString();
       
    49                 int index = filterRegExp().indexIn(name);
       
    50                 return index != -1;
       
    51             }
       
    52             else
       
    53                 return true;
       
    54         }
       
    55     }
    54     }
    56     else
    55     else
    57     {
    56     {
    58         return true;
    57         return searchOkay;
    59     }
    58     }
    60 }
    59 }
    61 
    60 
    62 void ThemeFilterProxyModel::setFilterDLC(bool enable)
    61 void ThemeFilterProxyModel::setFilterDLC(bool enable)
    63 {
    62 {