2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add support for pinned feeds management.

This commit is contained in:
John Preston
2018-01-04 22:54:35 +03:00
parent a2891807f8
commit 9d2239291d
22 changed files with 388 additions and 246 deletions

View File

@@ -8,15 +8,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/text/text.h"
#include "base/value_ordering.h"
#include "dialogs/dialogs_key.h"
class History;
class HistoryItem;
namespace Data {
class Feed;
} // namespace Data
namespace Ui {
class RippleAnimation;
} // namespace Ui
@@ -26,79 +22,6 @@ namespace Layout {
class RowPainter;
} // namespace Layout
struct Key {
Key() = default;
Key(History *history) : value(history) {
}
Key(not_null<History*> history) : value(history) {
}
Key(Data::Feed *feed) : value(feed) {
}
Key(not_null<Data::Feed*> feed) : value(feed) {
}
const QString &name() const {
if (const auto p = base::get_if<not_null<History*>>(&value)) {
return (*p)->peer->name;
}
// #TODO feeds name
static const auto empty = QString();
return empty;
}
const PeerData::NameFirstChars &nameFirstChars() const {
if (const auto p = base::get_if<not_null<History*>>(&value)) {
return (*p)->peer->nameFirstChars();
}
// #TODO feeds name
static const auto empty = PeerData::NameFirstChars();
return empty;
}
uint64 sortKey() const {
if (const auto p = base::get_if<not_null<History*>>(&value)) {
return (*p)->sortKeyInChatList();
}
// #TODO feeds sort in chats list
return 0ULL;
}
History *history() const {
if (const auto p = base::get_if<not_null<History*>>(&value)) {
return *p;
}
return nullptr;
}
Data::Feed *feed() const {
if (const auto p = base::get_if<not_null<Data::Feed*>>(&value)) {
return *p;
}
return nullptr;
}
inline bool operator<(const Key &other) const {
return value < other.value;
}
inline bool operator==(const Key &other) const {
return value == other.value;
}
// Not working :(
//friend inline auto value_ordering_helper(const Key &key) {
// return key.value;
//}
base::optional_variant<
not_null<History*>,
not_null<Data::Feed*>> value;
};
struct RowDescriptor {
RowDescriptor() = default;
RowDescriptor(Key key, MsgId msgId) : key(key), msgId(msgId) {
}
Key key;
MsgId msgId = 0;
};
class RippleRow {
public:
RippleRow();