void ProfileInner::reorderParticipants() { int32 was = _participants.size(), t = unixtime(), onlineCount = 0; if (_peerChat && !_peerChat->forbidden) { if (_peerChat->count <= 0 || !_peerChat->participants.isEmpty()) { _participants.clear(); for (ParticipantsData::iterator i = _participantsData.begin(), e = _participantsData.end(); i != e; ++i) { if (*i) { delete *i; *i = 0; } } _participants.reserve(_peerChat->participants.size()); _participantsData.resize(_peerChat->participants.size()); } UserData *self = App::self(); for (ChatData::Participants::const_iterator i = _peerChat->participants.cbegin(), e = _peerChat->participants.cend(); i != e; ++i) { UserData *user = i.key(); int32 until = user->onlineTill; Participants::iterator before = _participants.begin(); if (user != self) { if (before != _participants.end() && (*before) == self) { ++before; } while (before != _participants.end() && (*before)->onlineTill >= until) { ++before; } } _participants.insert(before, user); if (until > t) { ++onlineCount; } } if (_peerChat->count > 0 && _participants.isEmpty() && !_loadingId) { _loadingId = MTP::send(MTPmessages_GetFullChat(App::peerToMTP(_peerChat->id).c_peerChat().vchat_id), rpcDone(&ProfileInner::gotFullChat)); if (_onlineText.isEmpty()) _onlineText = lang(lng_chat_members).arg(_peerChat->count); } else if (onlineCount) { _onlineText = lang(lng_chat_members_online).arg(_participants.size()).arg(onlineCount); } else { _onlineText = lang(lng_chat_members).arg(_participants.size()); } loadProfilePhotos(_lastPreload); } else { _participants.clear(); if (_peerUser) { _onlineText = App::onlineText(_peerUser->onlineTill, t, true); } else { _onlineText = lang(lng_chat_no_members); } } if (was != _participants.size()) { resizeEvent(0); } }
void MembersBox::Inner::setVisibleTopBottom(int visibleTop, int visibleBottom) { _visibleTop = visibleTop; _visibleBottom = visibleBottom; loadProfilePhotos(); }
void ContactsInner::updateFilter(QString filter) { filter = textSearchKey(filter); QStringList f; if (!filter.isEmpty()) { QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts); int l = filterList.size(); f.reserve(l); for (int i = 0; i < l; ++i) { QString filterName = filterList[i].trimmed(); if (filterName.isEmpty()) continue; f.push_back(filterName); } filter = f.join(' '); } if (_filter != filter) { int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2); _filter = filter; if (_filter.isEmpty()) { if (_contacts->list.count) { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); resize(width(), _contacts->list.count * rh + st::contactsClose.height); _sel = _contacts->list.begin; } else { resize(width(), st::noContactsHeight); if (cContactsReceived()) { if (_addContactLnk.isHidden()) _addContactLnk.show(); } else { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); } } } else { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; _filtered.clear(); if (!f.isEmpty()) { DialogsList *dialogsToFilter = 0; if (_contacts->list.count) { for (fi = fb; fi != fe; ++fi) { DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0)); if (i == _contacts->index.cend()) { dialogsToFilter = 0; break; } if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) { dialogsToFilter = i.value(); } } } if (dialogsToFilter && dialogsToFilter->count) { _filtered.reserve(dialogsToFilter->count); for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) { const PeerData::Names &names(i->history->peer->names); PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni; for (fi = fb; fi != fe; ++fi) { QString filterName(*fi); for (ni = nb; ni != ne; ++ni) { if (ni->startsWith(*fi)) { break; } } if (ni == ne) { break; } } if (fi == fe) { i->attached = 0; _filtered.push_back(i); } } } } _filteredSel = _filtered.isEmpty() ? -1 : 0; if (!_filtered.isEmpty()) { resize(width(), _filtered.size() * rh + st::contactsClose.height); } else { resize(width(), st::noContactsHeight); } } if (parentWidget()) parentWidget()->update(); loadProfilePhotos(0); } }
void AddParticipantInner::updateFilter(QString filter) { _time = unixtime(); QStringList f; if (!filter.isEmpty()) { QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts); int l = filterList.size(); f.reserve(l); for (int i = 0; i < l; ++i) { QString filterName = filterList[i].trimmed(); if (filterName.isEmpty()) continue; f.push_back(filterName); } filter = f.join(' '); } if (_filter != filter) { int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2); _filter = filter; if (_filter.isEmpty()) { resize(width(), _contacts->list.count * rh); if (_contacts->list.count) { _sel = _contacts->list.begin; while (_sel->next->next &&& contactData(_sel)->inchat) { _sel = _sel->next; } } } else { QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; _filtered.clear(); if (!f.isEmpty()) { DialogsList *dialogsToFilter = 0; if (_contacts->list.count) { for (fi = fb; fi != fe; ++fi) { DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0)); if (i == _contacts->index.cend()) { dialogsToFilter = 0; break; } if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) { dialogsToFilter = i.value(); } } } if (dialogsToFilter && dialogsToFilter->count) { _filtered.reserve(dialogsToFilter->count); for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) { const PeerData::Names &names(i->history->peer->names); PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni; for (fi = fb; fi != fe; ++fi) { QString filterName(*fi); for (ni = nb; ni != ne; ++ni) { if (ni->startsWith(*fi)) { break; } } if (ni == ne) { break; } } if (fi == fe) { i->attached = 0; _filtered.push_back(i); } } } } _filteredSel = _filtered.isEmpty() ? -1 : 0; while (_filteredSel < _filtered.size() - 1 && contactData(_filtered[_filteredSel])->inchat) { ++_filteredSel; } resize(width(), _filtered.size() * rh); } if (parentWidget()) parentWidget()->update(); loadProfilePhotos(0); } }