mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(group): Store title name in Group
This commit is contained in:
parent
aaf1029667
commit
7429614188
|
@ -28,8 +28,11 @@
|
|||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
Group::Group(int groupId, QString name, bool isAvGroupchat)
|
||||
: groupId(groupId)
|
||||
static const int MAX_GROUP_TITLE_LENGTH = 128;
|
||||
|
||||
Group::Group(int groupId, const QString& name, bool isAvGroupchat)
|
||||
: title{name}
|
||||
, groupId(groupId)
|
||||
, nPeers{0}
|
||||
, avGroupchat{isAvGroupchat}
|
||||
{
|
||||
|
@ -70,12 +73,15 @@ void Group::updatePeer(int peerId, QString name)
|
|||
|
||||
void Group::setName(const QString& name)
|
||||
{
|
||||
emit titleChanged(groupId, name);
|
||||
if (!name.isEmpty() && title != name) {
|
||||
title = name.left(MAX_GROUP_TITLE_LENGTH);
|
||||
emit titleChanged(groupId, title);
|
||||
}
|
||||
}
|
||||
|
||||
QString Group::getName() const
|
||||
{
|
||||
return widget->getName();
|
||||
return title;
|
||||
}
|
||||
|
||||
QString Group::getDisplayedName() const
|
||||
|
|
|
@ -36,7 +36,7 @@ class Group : public Contact
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Group(int GroupId, QString Name, bool IsAvGroupchat);
|
||||
Group(int groupId, const QString& name, bool isAvGroupchat);
|
||||
~Group() override;
|
||||
|
||||
bool isAvGroupchat() const;
|
||||
|
@ -67,6 +67,7 @@ signals:
|
|||
void userListChanged(uint32_t groupId, const QMap<QByteArray, QString>& toxids);
|
||||
|
||||
private:
|
||||
QString title;
|
||||
GroupWidget* widget;
|
||||
GroupChatForm* chatForm;
|
||||
QStringList peers;
|
||||
|
|
|
@ -63,10 +63,8 @@ GroupWidget::~GroupWidget()
|
|||
|
||||
void GroupWidget::setTitle(const QString& newName)
|
||||
{
|
||||
if (!newName.isEmpty()) {
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->setName(newName);
|
||||
}
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->setName(newName);
|
||||
}
|
||||
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
|
Loading…
Reference in New Issue
Block a user