Don't add tags with no posts

This commit is contained in:
Luca Beltrame 2015-02-20 23:34:33 +01:00
parent 7ccd845eba
commit f6aa593ee5

View file

@ -53,8 +53,7 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const
DanbooruTag* tag = m_items.at(index.row()); DanbooruTag* tag = m_items.at(index.row());
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
QString text("%1 (%2)"); return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count());
return text.arg(tag->name()).arg(tag->count());
} else if (role == Qt::ToolTipRole) { } else if (role == Qt::ToolTipRole) {
return i18n("Tag count: %1", tag->count()); return i18n("Tag count: %1", tag->count());
} }
@ -75,6 +74,10 @@ void DanbooruTagModel::addTag(DanbooruTag* tag)
return; return;
} }
if(tag->count() == 0) {
return;
}
beginInsertRows(QModelIndex(), m_items.size(), m_items.size()); beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
m_items.append(tag); m_items.append(tag);
endInsertRows(); endInsertRows();