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