Q_FOREACH(Tag tag, fetchAllByParentId(id)) { qDebug() << __func__ << " - 'tag': " << tag; if ((tag.getId() == tagId) || tag.hasChild(tagId)) { return true; } }
bool Tag::operator== (const Tag &other) { if ( this->getId() == other.getId() && this->getName() == other.getName() ) { return true; } return false; }
void TagCatalog::relateTagToKnowledge(Tag tag, KnowledgeItem knowledge) { if ( !exist(tag) ) add(tag); DB *db = DB::getInstance(); QString query = QString("INSERT INTO `KnowledgeTag` VALUES (NULL,'%1','%2')"). arg(knowledge.getId()). arg(tag.getId()); db->executeQuery(query); }
/** * Returns all linked tags */ QQmlListProperty<TagApi> NoteApi::tags() { _tags.clear(); Note note = Note::fetch(id); QList<Tag> tags = Tag::fetchAllOfNote(note); QListIterator<Tag> itr(tags); while (itr.hasNext()) { Tag tag = itr.next(); TagApi* tagApi = new TagApi(); tagApi->fetch(tag.getId()); _tags.append(tagApi); } return QQmlListProperty<TagApi>(this, _tags); }