2016-04-09 18:45:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-09 18:45:55 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-14 11:00:23 +00:00
|
|
|
#include "ui/text/text.h"
|
2018-01-04 19:54:35 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
class History;
|
|
|
|
class HistoryItem;
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
namespace Layout {
|
|
|
|
class RowPainter;
|
|
|
|
} // namespace Layout
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
class RippleRow {
|
|
|
|
public:
|
|
|
|
RippleRow();
|
|
|
|
~RippleRow();
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
|
2016-12-05 11:01:08 +00:00
|
|
|
void stopLastRipple();
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
void paintRipple(Painter &p, int x, int y, int outerWidth, const QColor *colorOverride = nullptr) const;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
|
|
|
private:
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<Ui::RippleAnimation> _ripple;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
class List;
|
2016-12-05 11:01:08 +00:00
|
|
|
class Row : public RippleRow {
|
2016-04-09 18:45:55 +00:00
|
|
|
public:
|
2018-01-04 17:15:04 +00:00
|
|
|
explicit Row(std::nullptr_t) {
|
|
|
|
}
|
2019-04-16 11:37:50 +00:00
|
|
|
Row(Key key, int pos) : _id(key), _pos(pos) {
|
2016-04-09 18:45:55 +00:00
|
|
|
}
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
Key key() const {
|
|
|
|
return _id;
|
|
|
|
}
|
2016-04-09 18:45:55 +00:00
|
|
|
History *history() const {
|
2018-01-04 17:15:04 +00:00
|
|
|
return _id.history();
|
|
|
|
}
|
2019-04-15 11:54:03 +00:00
|
|
|
Data::Folder *folder() const {
|
|
|
|
return _id.folder();
|
2018-01-04 17:15:04 +00:00
|
|
|
}
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> entry() const {
|
|
|
|
return _id.entry();
|
|
|
|
}
|
2016-04-09 18:45:55 +00:00
|
|
|
int pos() const {
|
|
|
|
return _pos;
|
|
|
|
}
|
2018-01-13 12:45:11 +00:00
|
|
|
uint64 sortKey() const;
|
2018-01-04 17:15:04 +00:00
|
|
|
|
2019-04-23 12:29:23 +00:00
|
|
|
void validateListEntryCache() const;
|
|
|
|
const Text &listEntryCache() const {
|
|
|
|
return _listEntryCache;
|
|
|
|
}
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
// for any attached data, for example View in contacts list
|
|
|
|
void *attached = nullptr;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class List;
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
Key _id;
|
|
|
|
int _pos = 0;
|
2019-04-23 12:29:23 +00:00
|
|
|
mutable uint32 _listEntryCacheVersion = 0;
|
|
|
|
mutable Text _listEntryCache;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
class FakeRow : public RippleRow {
|
2016-04-09 18:45:55 +00:00
|
|
|
public:
|
2018-02-14 19:38:01 +00:00
|
|
|
FakeRow(Key searchInChat, not_null<HistoryItem*> item);
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
Key searchInChat() const {
|
|
|
|
return _searchInChat;
|
2017-09-05 17:21:56 +00:00
|
|
|
}
|
|
|
|
not_null<HistoryItem*> item() const {
|
2016-04-09 18:45:55 +00:00
|
|
|
return _item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Layout::RowPainter;
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
Key _searchInChat;
|
2017-09-05 17:21:56 +00:00
|
|
|
not_null<HistoryItem*> _item;
|
2016-04-09 18:45:55 +00:00
|
|
|
mutable const HistoryItem *_cacheFor = nullptr;
|
2016-06-07 19:59:39 +00:00
|
|
|
mutable Text _cache;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Dialogs
|