Bug 300956 - Group counts are wrong when set to "show only blocked contacts"
Summary: Group counts are wrong when set to "show only blocked contacts"
Status: RESOLVED FIXED
Alias: None
Product: telepathy
Classification: Frameworks and Libraries
Component: contactlist (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: 0.4.0
Assignee: Telepathy Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-31 18:08 UTC by David Edmundson
Modified: 2012-07-06 12:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.5


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Edmundson 2012-05-31 18:08:43 UTC
Set to "show only blocked contacts" 
(TBH, this seems an odd option to have anyway)

The numbers on the side of the group are just wrong.
Comment 1 Dominik Cermak 2012-06-01 10:57:23 UTC
I think the numbers are wrong because AccountsFilterModel uses the online/total count directly from telepathy but doesn't respect filter settings (the wrong numbers aren't only here, it's the case for all filters). I will look into the internals of AccountsFilterModel to see how we can solve this.

PS: What's so odd with that option, I actually implemented it because of http://bugs.kde.org/show_bug.cgi?id=294679 and in the review nobody told me that it's odd.
Comment 2 Dominik Cermak 2012-06-01 11:48:12 UTC
The counts come from GroupsModelItem. And because AccountsFilterModel only decides what items to show (in case of filtering) but all the data that is displayed comes from inside the items (which don't know about the filtering), I have no idea how to solve this ATM.

But maybe I just have a wrong understanding of QSortFilterProxyModel...
Any hints appreciated.
Comment 3 Martin Klapetek 2012-06-01 11:55:34 UTC
For the available users count you'd probably want to modify GroupsModelItem::countOnlineContacts() and check for the filter setting being used. Then just extend the "if" in the forloop and count only the relevant contacts. As for the total users count, see GroupsModelItem::data(int role) - case AccountsModel::TotalUsersCountRole - you'd need to again implement checking for the filter setting and count it from there.

Or implement it on the filter model level completely (which would make most sense).
Comment 4 Dominik Cermak 2012-06-01 12:25:42 UTC
Thanks, I will try and see if I get it working on filter model level.
Comment 5 Dominik Cermak 2012-06-27 15:37:39 UTC
Git commit 3737f85af335b0634d31c7d82a0e222f3475581c by Dominik Cermak.
Committed on 27/06/2012 at 17:30.
Pushed by cermak into branch 'master'.

Respect filters for counters

The counting is done in the AccountsFilterModel now.
So to have those counters one will have to use the AccountsFilterModel.
FIXED-IN: 0.5
REVIEW: 105130

M  +190  -3    KTp/Models/accounts-filter-model.cpp
M  +10   -4    KTp/Models/accounts-filter-model.h
M  +3    -24   KTp/Models/accounts-model-item.cpp
M  +0    -2    KTp/Models/accounts-model-item.h
M  +2    -4    KTp/Models/accounts-model.cpp
M  +1    -22   KTp/Models/groups-model-item.cpp
M  +0    -2    KTp/Models/groups-model-item.h
M  +1    -8    KTp/Models/groups-model.cpp

http://commits.kde.org/telepathy-common-internals/3737f85af335b0634d31c7d82a0e222f3475581c