bool FeRomList::set_fav( FeRomInfo &r, FeDisplayInfo &display, bool fav ) { r.set_info( FeRomInfo::Favourite, fav ? "1" : "" ); m_fav_changed=true; return fix_filters( display, FeRomInfo::Favourite ); }
bool FeRomList::set_fav( int filter_index, int rom_index, FeDisplayInfo &display, bool fav ) { if (( rom_index < 0 ) || ( rom_index >= filter_size( filter_index ) )) return false; (m_filtered_list[filter_index][rom_index])->set_info( FeRomInfo::Favourite, fav ? "1" : "" ); m_fav_changed=true; return fix_filters( display, FeRomInfo::Favourite ); }
bool FeRomList::set_tag( int filter_index, int rom_index, FeDisplayInfo &display, const std::string &tag, bool flag ) { if (( rom_index < 0 ) || ( rom_index >= filter_size( filter_index ) )) return false; std::string curr_tags = (m_filtered_list[filter_index][rom_index])->get_info(FeRomInfo::Tags); size_t pos = curr_tags.find( FE_TAGS_SEP + tag + FE_TAGS_SEP ); std::map<std::string, bool>::iterator itt = m_tags.begin(); if ( flag == true ) { if ( pos == std::string::npos ) { (m_filtered_list[filter_index][rom_index])->append_tag( tag ); m_tags_changed = true; itt = m_tags.find( tag ); if ( itt != m_tags.end() ) (*itt).second = true; else itt = m_tags.insert( itt, std::pair<std::string,bool>( tag, true ) ); } } else if ( pos != std::string::npos ) { pos++; // because we searched for the preceeding FE_TAGS_SEP as well int len = tag.size(); if (( ( pos + len ) < curr_tags.size() ) && ( curr_tags.at( pos + len ) == FE_TAGS_SEP )) len++; curr_tags.erase( pos, len ); // // Clean up our leading FE_TAGS_SEP if there are no tags left // if (( curr_tags.size() == 1 ) && (curr_tags[0] == FE_TAGS_SEP )) curr_tags.clear(); (m_filtered_list[filter_index][rom_index])->set_info( FeRomInfo::Tags, curr_tags ); m_tags_changed = true; itt = m_tags.find( tag ); if ( itt != m_tags.end() ) (*itt).second = true; else itt = m_tags.insert( itt, std::pair<std::string,bool>( tag, true ) ); } return fix_filters( display, FeRomInfo::Tags ); }