mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: remove Core::getInstance from grouplist
This commit is contained in:
parent
365a452fb8
commit
82e0852f3c
|
@ -25,17 +25,15 @@
|
|||
|
||||
QHash<const GroupId, Group*> GroupList::groupList;
|
||||
QHash<uint32_t, GroupId> GroupList::id2key;
|
||||
Group* GroupList::addGroup(int groupNum, const GroupId& groupId, const QString& name, bool isAvGroupchat,
|
||||
Group* GroupList::addGroup(Core& core, int groupNum, const GroupId& groupId, const QString& name, bool isAvGroupchat,
|
||||
const QString& selfName)
|
||||
{
|
||||
auto checker = groupList.find(groupId);
|
||||
if (checker != groupList.end())
|
||||
if (checker != groupList.end()) {
|
||||
qWarning() << "addGroup: groupId already taken";
|
||||
}
|
||||
|
||||
// TODO: Core instance is bad but grouplist is also an instance so we can
|
||||
// deal with this later
|
||||
auto core = Core::getInstance();
|
||||
Group* newGroup = new Group(groupNum, groupId, name, isAvGroupchat, selfName, *core, *core);
|
||||
Group* newGroup = new Group(groupNum, groupId, name, isAvGroupchat, selfName, core, core);
|
||||
groupList[groupId] = newGroup;
|
||||
id2key[groupNum] = groupId;
|
||||
return newGroup;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "src/core/groupid.h"
|
||||
|
||||
class Core;
|
||||
template <class A, class B>
|
||||
class QHash;
|
||||
template <class T>
|
||||
|
@ -31,7 +32,7 @@ class QString;
|
|||
class GroupList
|
||||
{
|
||||
public:
|
||||
static Group* addGroup(int groupId, const GroupId& persistentGroupId, const QString& name, bool isAvGroupchat, const QString& selfName);
|
||||
static Group* addGroup(Core& core, int groupId, const GroupId& persistentGroupId, const QString& name, bool isAvGroupchat, const QString& selfName);
|
||||
static Group* findGroup(const GroupId& groupId);
|
||||
static const GroupId& id2Key(uint32_t groupNum);
|
||||
static void removeGroup(const GroupId& groupId, bool fake = false);
|
||||
|
|
|
@ -2078,7 +2078,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
|
|||
const auto groupName = tr("Groupchat #%1").arg(groupnumber);
|
||||
const bool enabled = core->getGroupAvEnabled(groupnumber);
|
||||
Group* newgroup =
|
||||
GroupList::addGroup(groupnumber, groupId, groupName, enabled, core->getUsername());
|
||||
GroupList::addGroup(*core, groupnumber, groupId, groupName, enabled, core->getUsername());
|
||||
auto dialogManager = ContentDialogManager::getInstance();
|
||||
auto rawChatroom = new GroupChatroom(newgroup, dialogManager);
|
||||
std::shared_ptr<GroupChatroom> chatroom(rawChatroom);
|
||||
|
|
Loading…
Reference in New Issue
Block a user