2018-01-04 19:54:35 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "base/value_ordering.h"
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
class History;
|
2020-06-12 14:09:04 +00:00
|
|
|
class PeerData;
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
namespace Data {
|
2019-04-15 11:54:03 +00:00
|
|
|
class Folder;
|
2018-01-04 19:54:35 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Dialogs {
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
class Entry;
|
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
class Key {
|
|
|
|
public:
|
|
|
|
Key() = default;
|
2020-06-12 14:09:04 +00:00
|
|
|
Key(Entry *entry) : _value(entry) {
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
2020-06-12 14:09:04 +00:00
|
|
|
Key(History *history);
|
|
|
|
Key(Data::Folder *folder);
|
|
|
|
Key(not_null<Entry*> entry) : _value(entry) {
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
2020-06-12 14:09:04 +00:00
|
|
|
Key(not_null<History*> history);
|
|
|
|
Key(not_null<Data::Folder*> folder);
|
2018-01-04 19:54:35 +00:00
|
|
|
|
|
|
|
explicit operator bool() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
return (_value != nullptr);
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> entry() const;
|
2018-01-04 19:54:35 +00:00
|
|
|
History *history() const;
|
2019-04-15 11:54:03 +00:00
|
|
|
Data::Folder *folder() const;
|
2018-01-22 16:42:25 +00:00
|
|
|
PeerData *peer() const;
|
2018-01-04 19:54:35 +00:00
|
|
|
|
|
|
|
inline bool operator<(const Key &other) const {
|
|
|
|
return _value < other._value;
|
|
|
|
}
|
|
|
|
inline bool operator>(const Key &other) const {
|
|
|
|
return (other < *this);
|
|
|
|
}
|
|
|
|
inline bool operator<=(const Key &other) const {
|
|
|
|
return !(other < *this);
|
|
|
|
}
|
|
|
|
inline bool operator>=(const Key &other) const {
|
|
|
|
return !(*this < other);
|
|
|
|
}
|
|
|
|
inline bool operator==(const Key &other) const {
|
|
|
|
return _value == other._value;
|
|
|
|
}
|
|
|
|
inline bool operator!=(const Key &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not working :(
|
|
|
|
//friend inline auto value_ordering_helper(const Key &key) {
|
|
|
|
// return key.value;
|
|
|
|
//}
|
|
|
|
|
|
|
|
private:
|
2020-06-12 14:09:04 +00:00
|
|
|
Entry *_value = nullptr;
|
2018-01-04 19:54:35 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RowDescriptor {
|
|
|
|
RowDescriptor() = default;
|
2018-02-16 15:46:24 +00:00
|
|
|
RowDescriptor(Key key, FullMsgId fullId) : key(key), fullId(fullId) {
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Key key;
|
2018-02-16 15:46:24 +00:00
|
|
|
FullMsgId fullId;
|
2018-01-22 16:42:25 +00:00
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
};
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
inline bool operator==(const RowDescriptor &a, const RowDescriptor &b) {
|
2018-12-29 13:09:45 +00:00
|
|
|
return (a.key == b.key)
|
|
|
|
&& ((a.fullId == b.fullId) || (!a.fullId.msg && !b.fullId.msg));
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const RowDescriptor &a, const RowDescriptor &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator<(const RowDescriptor &a, const RowDescriptor &b) {
|
|
|
|
if (a.key < b.key) {
|
|
|
|
return true;
|
|
|
|
} else if (a.key > b.key) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-16 15:46:24 +00:00
|
|
|
return a.fullId < b.fullId;
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator>(const RowDescriptor &a, const RowDescriptor &b) {
|
|
|
|
return (b < a);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator<=(const RowDescriptor &a, const RowDescriptor &b) {
|
|
|
|
return !(b < a);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator>=(const RowDescriptor &a, const RowDescriptor &b) {
|
|
|
|
return !(a < b);
|
|
|
|
}
|
|
|
|
|
2020-11-12 15:46:17 +00:00
|
|
|
struct EntryState {
|
|
|
|
enum class Section {
|
|
|
|
History,
|
|
|
|
Profile,
|
|
|
|
ChatsList,
|
|
|
|
Scheduled,
|
|
|
|
Pinned,
|
|
|
|
Replies,
|
|
|
|
};
|
|
|
|
|
|
|
|
Key key;
|
|
|
|
Section section = Section::History;
|
|
|
|
FilterId filterId = 0;
|
|
|
|
MsgId rootId = 0;
|
|
|
|
MsgId currentReplyToId = 0;
|
|
|
|
};
|
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
} // namespace Dialogs
|