Remove for_const macro.

This commit is contained in:
John Preston
2021-09-03 14:09:57 +03:00
parent 2a2607d026
commit 23e9e7b9f0
20 changed files with 179 additions and 139 deletions

View File

@@ -233,7 +233,7 @@ void GroupMembersWidget::sortMembers() {
void GroupMembersWidget::updateOnlineCount() {
bool onlyMe = true;
int newOnlineCount = 0;
for_const (auto item, items()) {
for (const auto item : items()) {
auto member = getMember(item);
auto user = member->user();
auto isOnline = !user->isBot() && Data::OnlineTextActive(member->onlineTill, _now);
@@ -433,7 +433,7 @@ void GroupMembersWidget::updateOnlineDisplay() {
_now = base::unixtime::now();
bool changed = false;
for_const (auto item, items()) {
for (const auto item : items()) {
if (!item->statusHasOnlineColor) {
if (!item->peer->isSelf()) {
continue;

View File

@@ -63,8 +63,9 @@ void PeerListWidget::paintContents(Painter &p) {
auto left = getListLeft();
auto top = getListTop();
auto from = floorclamp(_visibleTop - top, _st.height, 0, _items.size());
auto to = ceilclamp(_visibleBottom - top, _st.height, 0, _items.size());
const auto count = int(_items.size());
auto from = floorclamp(_visibleTop - top, _st.height, 0, count);
auto to = ceilclamp(_visibleBottom - top, _st.height, 0, count);
for (auto i = from; i < to; ++i) {
auto y = top + i * _st.height;
auto selected = (_pressed >= 0) ? (i == _pressed) : (i == _selected);
@@ -147,7 +148,7 @@ void PeerListWidget::mousePressEvent(QMouseEvent *e) {
_pressed = _selected;
_pressedRemove = _selectedRemove;
if (_pressed >= 0 && !_pressedRemove) {
auto item = _items[_pressed];
const auto item = _items[_pressed];
if (!item->ripple) {
auto memberRowWidth = rowWidth();
auto mask = Ui::RippleAnimation::rectMask(QSize(memberRowWidth, _st.height));
@@ -170,7 +171,7 @@ void PeerListWidget::mousePressReleased(Qt::MouseButton button) {
auto pressed = std::exchange(_pressed, -1);
auto pressedRemove = base::take(_pressedRemove);
if (pressed >= 0 && pressed < _items.size()) {
if (auto &ripple = _items[pressed]->ripple) {
if (const auto &ripple = _items[pressed]->ripple) {
ripple->lastStop();
}
if (pressed == _selected && pressedRemove == _selectedRemove && button == Qt::LeftButton) {
@@ -274,7 +275,7 @@ void PeerListWidget::preloadPhotos() {
}
void PeerListWidget::refreshVisibility() {
setVisible(!_items.isEmpty());
setVisible(!_items.empty());
}
} // namespace Profile

View File

@@ -52,7 +52,7 @@ public:
int getListLeft() const;
const QList<Item*> &items() const {
const std::vector<Item*> &items() const {
return _items;
}
int itemsCount() const {
@@ -129,7 +129,7 @@ private:
Fn<void(PeerData*)> _removedCallback;
Fn<void(Item*)> _updateItemCallback;
QList<Item*> _items;
std::vector<Item*> _items;
int _visibleTop = 0;
int _visibleBottom = 0;