bool VideoFilterSettings::matches_filter(const VideoMetadata &mdata) const { bool matches = true; //textfilter if (!textfilter.isEmpty()) { matches = false; matches = matches || mdata.GetTitle().contains(textfilter, Qt::CaseInsensitive); matches = matches || mdata.GetSubtitle().contains(textfilter, Qt::CaseInsensitive); matches = matches || mdata.GetPlot().contains(textfilter, Qt::CaseInsensitive); } //search for season with optionally episode nr. if (matches && season != -1) { matches = season == mdata.GetSeason(); matches = matches && (episode == -1 || episode == mdata.GetEpisode()); } if (matches && insertdate.isValid()) { matches = mdata.GetInsertdate().isValid() && mdata.GetInsertdate() >= insertdate; } if (matches && genre != kGenreFilterAll) { matches = false; const VideoMetadata::genre_list &gl = mdata.GetGenres(); for (VideoMetadata::genre_list::const_iterator p = gl.begin(); p != gl.end(); ++p) { if ((matches = p->first == genre)) { break; } } } if (matches && country != kCountryFilterAll) { matches = false; const VideoMetadata::country_list &cl = mdata.GetCountries(); for (VideoMetadata::country_list::const_iterator p = cl.begin(); p != cl.end(); ++p) { if ((matches = p->first == country)) { break; } } } if (matches && cast != kCastFilterAll) { const VideoMetadata::cast_list &cl = mdata.GetCast(); if (cast == kCastFilterUnknown && cl.size() == 0) { matches = true; } else { matches = false; for (VideoMetadata::cast_list::const_iterator p = cl.begin(); p != cl.end(); ++p) { if ((matches = p->first == cast)) { break; } } } } if (matches && category != kCategoryFilterAll) { matches = category == mdata.GetCategoryID(); } if (matches && year != kYearFilterAll) { if (year == kYearFilterUnknown) { matches = (mdata.GetYear() == 0) || (mdata.GetYear() == VIDEO_YEAR_DEFAULT); } else { matches = year == mdata.GetYear(); } } if (matches && runtime != kRuntimeFilterAll) { if (runtime == kRuntimeFilterUnknown) { matches = mdata.GetLength() == 0; } else { matches = runtime == (mdata.GetLength() / 30); } } if (matches && userrating != kUserRatingFilterAll) { matches = mdata.GetUserRating() >= userrating; } if (matches && browse != kBrowseFilterAll) { matches = mdata.GetBrowse() == browse; } if (matches && watched != kWatchedFilterAll) { matches = mdata.GetWatched() == watched; } if (matches && m_inetref != kInetRefFilterAll) { matches = mdata.GetInetRef() == VIDEO_INETREF_DEFAULT; } if (matches && m_coverfile != kCoverFileFilterAll) { matches = IsDefaultCoverFile(mdata.GetCoverFile()); } if (matches && m_parental_level) { matches = (mdata.GetShowLevel() != ParentalLevel::plNone) && (mdata.GetShowLevel() <= m_parental_level); } return matches; }
void VideoListImp::buildGroupList(metadata_list_type whence) { metadata_list ml; VideoMetadataListManager::loadAllFromDatabase(ml); m_metadata.setList(ml); metadata_view_list mlist; mlist.reserve(m_metadata.getList().size()); back_insert_iterator<metadata_view_list> mli(mlist); transform(m_metadata.getList().begin(), m_metadata.getList().end(), mli, to_metadata_ptr()); metadata_path_sort mps(true); sort(mlist.begin(), mlist.end(), mps); typedef map<QString, meta_dir_node *> group_to_node_map; group_to_node_map gtnm; meta_dir_node *video_root = &m_metadata_tree; smart_dir_node sdn = video_root->addSubDir("All"); meta_dir_node* all_group_node = sdn.get(); for (metadata_view_list::iterator p = mlist.begin(); p != mlist.end(); ++p) { VideoMetadata *data = *p; all_group_node->addEntry(smart_meta_node(new meta_data_node(data))); vector<QString> groups; switch (whence) { case ltDBGenreGroup: { vector<pair <int, QString> > genres = data->GetGenres(); for (vector<pair <int, QString> >::iterator i = genres.begin(); i != genres.end(); ++i) { pair<int, QString> item = *i; groups.push_back(item.second); } break; } case ltDBCategoryGroup: { groups.push_back(data->GetCategory()); break; } case ltDBYearGroup: { groups.push_back(QString::number(data->GetYear())); break; } case ltDBDirectorGroup: { groups.push_back(data->GetDirector()); break; } case ltDBStudioGroup: { groups.push_back(data->GetStudio()); break; } case ltDBCastGroup: { vector<pair<int, QString> > cast = data->GetCast(); for (vector<pair<int, QString> >::iterator i = cast.begin(); i != cast.end(); ++i) { pair<int, QString> item = *i; groups.push_back(item.second); } break; } case ltDBUserRatingGroup: { int i = data->GetUserRating(); groups.push_back(QString::number(i)); break; } case ltDBInsertDateGroup: { QDate date = data->GetInsertdate(); QString tmp = MythDate::toString( date, MythDate::kDateFull | MythDate::kSimplify); groups.push_back(tmp); break; } default: { LOG(VB_GENERAL, LOG_ERR, "Invalid type of grouping"); break; } } if (groups.empty()) { meta_dir_node *group_node = gtnm["Unknown"]; if (group_node == NULL) { smart_dir_node sdn = video_root->addSubDir("Unknown"); group_node = sdn.get(); gtnm["Unknown"] = group_node; } group_node->addEntry(smart_meta_node(new meta_data_node(data))); } for (vector<QString>::iterator i = groups.begin(); i != groups.end(); ++i) { QString item = *i; meta_dir_node *group_node = gtnm[item]; if (group_node == NULL) { smart_dir_node sdn = video_root->addSubDir(item); group_node = sdn.get(); gtnm[item] = group_node; } group_node->addEntry(smart_meta_node(new meta_data_node(data))); } } }
QStringList GetDisplayCast(const VideoMetadata &item) { QStringList ret; CopySecond(item.GetCast(), ret); return ret; }