From f6aa593ee5355c7977a4c27aef8afe5f0c62c12f Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Fri, 20 Feb 2015 23:34:33 +0100 Subject: [PATCH] Don't add tags with no posts --- src/model/danboorutagmodel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/model/danboorutagmodel.cpp b/src/model/danboorutagmodel.cpp index df25e80..ed638f8 100644 --- a/src/model/danboorutagmodel.cpp +++ b/src/model/danboorutagmodel.cpp @@ -53,8 +53,7 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const DanbooruTag* tag = m_items.at(index.row()); if (role == Qt::DisplayRole) { - QString text("%1 (%2)"); - return text.arg(tag->name()).arg(tag->count()); + return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count()); } else if (role == Qt::ToolTipRole) { return i18n("Tag count: %1", tag->count()); } @@ -75,6 +74,10 @@ void DanbooruTagModel::addTag(DanbooruTag* tag) return; } + if(tag->count() == 0) { + return; + } + beginInsertRows(QModelIndex(), m_items.size(), m_items.size()); m_items.append(tag); endInsertRows();