2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Support dialog rows with variable height.

This commit is contained in:
John Preston
2022-11-11 10:23:23 +04:00
parent 248337daf5
commit 37308cde21
26 changed files with 600 additions and 401 deletions

View File

@@ -795,7 +795,9 @@ ShareBox::Inner::Chat *ShareBox::Inner::getChatAtIndex(int index) {
}
const auto row = [=] {
if (_filter.isEmpty()) {
return _chatsIndexed->rowAtY(index, 1);
return (index < _chatsIndexed->size())
? (_chatsIndexed->begin() + index)->get()
: nullptr;
}
return (index < _filtered.size())
? _filtered[index].get()
@@ -865,9 +867,11 @@ void ShareBox::Inner::loadProfilePhotos(int yFrom) {
if (_filter.isEmpty()) {
if (!_chatsIndexed->empty()) {
auto i = _chatsIndexed->cfind(yFrom, _rowHeight);
const auto index = yFrom / _rowHeight;
auto i = _chatsIndexed->begin()
+ std::min(index, _chatsIndexed->size());;
for (auto end = _chatsIndexed->cend(); i != end; ++i) {
if (((*i)->pos() * _rowHeight) >= yTo) {
if (((*i)->index() * _rowHeight) >= yTo) {
break;
}
(*i)->entry()->loadUserpic();
@@ -973,7 +977,8 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
auto indexTo = rowTo * _columnCount;
if (_filter.isEmpty()) {
if (!_chatsIndexed->empty()) {
auto i = _chatsIndexed->cfind(indexFrom, 1);
auto i = _chatsIndexed->begin()
+ std::min(indexFrom, _chatsIndexed->size());
for (auto end = _chatsIndexed->cend(); i != end; ++i) {
if (indexFrom >= indexTo) {
break;