2021-05-24 12:13:59 +02:00
|
|
|
#pragma once
|
|
|
|
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include "util/QStringHash.hpp"
|
|
|
|
|
|
|
|
#include <lrucache/lrucache.hpp>
|
2021-05-24 12:13:59 +02:00
|
|
|
#include <QString>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
|
2021-05-24 12:13:59 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <set>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
2023-05-07 15:18:07 +02:00
|
|
|
#include <vector>
|
2021-05-24 12:13:59 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
/// ChatterSet is a limited container that contains a list of recent chatters
|
|
|
|
/// that can be referenced by name.
|
|
|
|
class ChatterSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// The limit of how many chatters can be saved for a channel.
|
|
|
|
static constexpr size_t chatterLimit = 2000;
|
|
|
|
|
|
|
|
ChatterSet();
|
|
|
|
|
|
|
|
/// Inserts a user name if it isn't contained. Doesn't replace the original
|
|
|
|
/// if the casing hasn't changed.
|
|
|
|
void addRecentChatter(const QString &userName);
|
|
|
|
|
|
|
|
/// Removes chatters that aren't online anymore. Adds chatters that aren't
|
|
|
|
/// in the list yet.
|
|
|
|
void updateOnlineChatters(
|
|
|
|
const std::unordered_set<QString> &lowerCaseUsernames);
|
|
|
|
|
|
|
|
/// Checks if a username is in the list.
|
|
|
|
bool contains(const QString &userName) const;
|
|
|
|
|
|
|
|
/// Get filtered usernames by a prefix for autocompletion. Contained items
|
|
|
|
/// are in mixed case if available.
|
|
|
|
std::vector<QString> filterByPrefix(const QString &prefix) const;
|
|
|
|
|
2023-09-24 14:17:17 +02:00
|
|
|
/// Get all recent chatters. The first pair element contains the username
|
|
|
|
/// in lowercase, while the second pair element is the original case.
|
|
|
|
std::vector<std::pair<QString, QString>> all() const;
|
|
|
|
|
2021-05-24 12:13:59 +02:00
|
|
|
private:
|
|
|
|
// user name in lower case -> user name in normal case
|
|
|
|
cache::lru_cache<QString, QString> items;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ChatterSet = ChatterSet;
|
|
|
|
|
|
|
|
} // namespace chatterino
|