referencing seems to be working now

This commit is contained in:
Blue 2020-04-18 15:02:01 +03:00
parent 83a2e6af85
commit 9c855553c5
8 changed files with 77 additions and 41 deletions

View file

@ -30,9 +30,9 @@ Models::Group::~Group()
{
}
void Models::Group::appendChild(Models::Item* child)
void Models::Group::_appendChild(Models::Item* child)
{
Item::appendChild(child);
Item::_appendChild(child);
connect(child, &Item::childChanged, this, &Group::refresh);
changed(1);
refresh();
@ -83,9 +83,14 @@ void Models::Group::refresh()
{
unsigned int newAmount(0);
for (std::deque<Models::Item*>::const_iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) {
Models::Contact* cnt = static_cast<Models::Contact*>(*itr);
newAmount += cnt->getMessagesCount();
for (Models::Item* item : childItems) {
if (item->type == reference) {
item = static_cast<Reference*>(item)->dereference();
}
if (item->type == contact) {
Models::Contact* cnt = static_cast<Models::Contact*>(item);
newAmount += cnt->getMessagesCount();
}
}
setUnreadMessages(newAmount);
@ -95,10 +100,15 @@ unsigned int Models::Group::getOnlineContacts() const
{
unsigned int amount(0);
for (std::deque<Models::Item*>::const_iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) {
Models::Contact* cnt = static_cast<Models::Contact*>(*itr);
if (cnt->getAvailability() != Shared::Availability::offline) {
++amount;
for (Models::Item* item : childItems) {
if (item->type == reference) {
item = static_cast<Reference*>(item)->dereference();
}
if (item->type == contact) {
Models::Contact* cnt = static_cast<Models::Contact*>(item);
if (cnt->getAvailability() != Shared::Availability::offline) {
++amount;
}
}
}