From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14427 invoked by alias); 5 Aug 2018 22:10:34 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 14330 invoked by uid 89); 5 Aug 2018 22:10:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: rgout03.bt.lon5.cpcloud.co.uk Received: from rgout0301.bt.lon5.cpcloud.co.uk (HELO rgout03.bt.lon5.cpcloud.co.uk) (65.20.0.207) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Aug 2018 22:10:32 +0000 X-OWM-Source-IP: 86.151.121.200 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-SNCR-VADESECURE: CLEAN Received: from localhost.localdomain (86.151.121.200) by rgout03.bt.lon5.cpcloud.co.uk (9.0.019.26-1) (authenticated as jonturney@btinternet.com) id 5B4CE16C01FB5C92; Sun, 5 Aug 2018 23:10:31 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 08/13] Show the count of packages in a category Date: Sun, 05 Aug 2018 22:10:00 -0000 Message-Id: <20180805220851.270212-9-jon.turney@dronecode.org.uk> In-Reply-To: <20180805220851.270212-1-jon.turney@dronecode.org.uk> References: <20180805220851.270212-1-jon.turney@dronecode.org.uk> X-SW-Source: 2018-08/txt/msg00014.txt.bz2 --- PickCategoryLine.cc | 8 ++++++-- PickCategoryLine.h | 4 +++- PickView.cc | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/PickCategoryLine.cc b/PickCategoryLine.cc index ec15b4a..736e3c6 100644 --- a/PickCategoryLine.cc +++ b/PickCategoryLine.cc @@ -18,14 +18,18 @@ #include "PickView.h" #include "window.h" #include "package_meta.h" +#include const std::string PickCategoryLine::get_text (int col_num) const { if (col_num == pkgname_col) { - std::string s = (cat_tree->collapsed() ? "[+] " : "[-] ") + cat_tree->category().first; - return s; + std::ostringstream s; + s << (cat_tree->collapsed() ? "[+] " : "[-] ") << cat_tree->category().first; + if (pkgcount) + s << " (" << pkgcount << ")"; + return s.str(); } else if (col_num == new_col) { diff --git a/PickCategoryLine.h b/PickCategoryLine.h index 6c18018..ec160f9 100644 --- a/PickCategoryLine.h +++ b/PickCategoryLine.h @@ -23,8 +23,9 @@ class PickCategoryLine: public ListViewLine { public: - PickCategoryLine (PickView & aView, CategoryTree * _tree) : + PickCategoryLine (PickView & aView, CategoryTree * _tree, int _pkgcount) : cat_tree (_tree), + pkgcount(_pkgcount), theView (aView) { }; @@ -38,6 +39,7 @@ public: private: CategoryTree * cat_tree; + int pkgcount; PickView & theView; }; diff --git a/PickView.cc b/PickView.cc index 967d53b..6e1af0c 100644 --- a/PickView.cc +++ b/PickView.cc @@ -169,12 +169,12 @@ PickView::insert_category (CategoryTree *cat_tree) return; // if it's not the "All" category + int packageCount = 0; bool hasContents = false; bool isAll = casecompare(cat->first, "All") == 0; if (!isAll) { // count the number of packages in this category - int packageCount = 0; for (std::vector ::const_iterator i = cat->second.begin (); i != cat->second.end () ; ++i) { @@ -197,7 +197,7 @@ PickView::insert_category (CategoryTree *cat_tree) return; // insert line for the category - contents.push_back(new PickCategoryLine(*this, cat_tree)); + contents.push_back(new PickCategoryLine(*this, cat_tree, packageCount)); // if not collapsed if (!cat_tree->collapsed()) -- 2.17.0