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
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
2016-04-09 18:45:55 +00:00
|
|
|
#include "dialogs/dialogs_list.h"
|
|
|
|
|
|
|
|
class History;
|
|
|
|
|
|
|
|
namespace Dialogs {
|
|
|
|
|
|
|
|
class IndexedList {
|
|
|
|
public:
|
|
|
|
IndexedList(SortMode sortMode);
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
RowsByLetter addToEnd(Key key);
|
|
|
|
Row *addByName(Key key);
|
2019-04-16 11:37:50 +00:00
|
|
|
void adjustByDate(const RowsByLetter &links);
|
2018-01-04 17:15:04 +00:00
|
|
|
void moveToTop(Key key);
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2017-01-30 15:27:13 +00:00
|
|
|
// row must belong to this indexed list all().
|
|
|
|
void movePinned(Row *row, int deltaSign);
|
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
// For sortMode != SortMode::Date
|
2018-01-04 17:15:04 +00:00
|
|
|
void peerNameChanged(
|
|
|
|
not_null<PeerData*> peer,
|
2018-01-22 09:33:09 +00:00
|
|
|
const base::flat_set<QChar> &oldChars);
|
2016-04-11 10:59:01 +00:00
|
|
|
|
|
|
|
//For sortMode == SortMode::Date
|
2018-01-04 17:15:04 +00:00
|
|
|
void peerNameChanged(
|
|
|
|
Mode list,
|
|
|
|
not_null<PeerData*> peer,
|
2018-01-22 09:33:09 +00:00
|
|
|
const base::flat_set<QChar> &oldChars);
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
void del(Key key, Row *replacedBy = nullptr);
|
2016-04-09 18:45:55 +00:00
|
|
|
void clear();
|
|
|
|
|
|
|
|
const List &all() const {
|
|
|
|
return _list;
|
|
|
|
}
|
|
|
|
const List *filtered(QChar ch) const {
|
2019-04-16 14:05:56 +00:00
|
|
|
const auto i = _index.find(ch);
|
|
|
|
return (i != _index.end()) ? &i->second : nullptr;
|
2016-04-09 18:45:55 +00:00
|
|
|
}
|
2019-04-22 18:18:57 +00:00
|
|
|
std::vector<not_null<Row*>> filtered(const QStringList &words) const;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
~IndexedList();
|
|
|
|
|
|
|
|
// Part of List interface is duplicated here for all() list.
|
|
|
|
int size() const { return all().size(); }
|
2019-04-16 14:05:56 +00:00
|
|
|
bool empty() const { return all().empty(); }
|
2018-01-04 17:15:04 +00:00
|
|
|
bool contains(Key key) const { return all().contains(key); }
|
|
|
|
Row *getRow(Key key) const { return all().getRow(key); }
|
2016-04-09 18:45:55 +00:00
|
|
|
Row *rowAtY(int32 y, int32 h) const { return all().rowAtY(y, h); }
|
|
|
|
|
|
|
|
using iterator = List::iterator;
|
|
|
|
using const_iterator = List::const_iterator;
|
|
|
|
const_iterator cbegin() const { return all().cbegin(); }
|
|
|
|
const_iterator cend() const { return all().cend(); }
|
|
|
|
const_iterator begin() const { return all().cbegin(); }
|
|
|
|
const_iterator end() const { return all().cend(); }
|
|
|
|
iterator begin() { return all().begin(); }
|
|
|
|
iterator end() { return all().end(); }
|
|
|
|
const_iterator cfind(Row *value) const { return all().cfind(value); }
|
|
|
|
const_iterator find(Row *value) const { return all().cfind(value); }
|
|
|
|
iterator find(Row *value) { return all().find(value); }
|
|
|
|
const_iterator cfind(int y, int h) const { return all().cfind(y, h); }
|
|
|
|
const_iterator find(int y, int h) const { return all().cfind(y, h); }
|
|
|
|
iterator find(int y, int h) { return all().find(y, h); }
|
|
|
|
|
|
|
|
private:
|
2018-01-04 17:15:04 +00:00
|
|
|
void adjustByName(
|
|
|
|
Key key,
|
2018-01-22 09:33:09 +00:00
|
|
|
const base::flat_set<QChar> &oldChars);
|
2018-01-04 17:15:04 +00:00
|
|
|
void adjustNames(
|
|
|
|
Mode list,
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<History*> history,
|
2018-01-22 09:33:09 +00:00
|
|
|
const base::flat_set<QChar> &oldChars);
|
2016-04-11 10:59:01 +00:00
|
|
|
|
2019-04-16 14:05:56 +00:00
|
|
|
SortMode _sortMode = SortMode();
|
2017-10-24 17:11:35 +00:00
|
|
|
List _list, _empty;
|
2019-04-16 14:05:56 +00:00
|
|
|
base::flat_map<QChar, List> _index;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Dialogs
|