// BEGIN TagManager::remove_tag () // <summary> // This will remove the tag from every note that is currently tagged // and from the main list of tags. // </summary> void TagManager::remove_tag (const Tag::Ptr & tag) { if (!tag){ std::cout << "TagManager.RemoveTag () called with a null tag"; return; } if(tag->is_property() || tag->is_system()){ m_internal_tags.erase(tag->normalized_name()); } // typedef std::map<std::string, Tag::Ptr> TagMap; bool tag_removed = false; TagMap::iterator map_iter; map_iter = m_tag_map.find(tag->normalized_name()); if (map_iter != m_tag_map.end()) { map_iter = m_tag_map.find(tag->normalized_name()); if (map_iter != m_tag_map.end()) { Tag::Ptr iter = map_iter->second; if (!m_tags->erase(iter)) { std::cout << "TagManager: Removed tag: %s", tag->normalized_name().c_str(); } else { // FIXME: For some really weird reason, this block actually gets called sometimes! std::cout << "TagManager: Call to remove tag from ListStore failed: %s", tag->normalized_name().c_str(); } m_tag_map.erase(map_iter); std::cout << "Removed TreeIter from tag_map: %s", tag->normalized_name().c_str(); tag_removed = true; std::list<Note*> notes; tag->get_notes(notes); for(std::list<Note*>::const_iterator note_iter = notes.begin(); note_iter != notes.end(); ++note_iter) { (*note_iter)->remove_tag(tag); } } } return; } // END TagManager::remove_tag ()
void NotebookApplicationAddin::on_tag_added(const Note & note, const Tag::Ptr& tag) { if (NotebookManager::instance().is_adding_notebook()) { return; } std::string megaPrefix(Tag::SYSTEM_TAG_PREFIX); megaPrefix += Notebook::NOTEBOOK_TAG_PREFIX; if (!tag->is_system() || !Glib::str_has_prefix(tag->name(), megaPrefix)) { return; } std::string notebookName = sharp::string_substring(tag->name(), megaPrefix.size()); Notebook::Ptr notebook = NotebookManager::instance().get_or_create_notebook (notebookName); NotebookManager::instance().signal_note_added_to_notebook() (note, notebook); }