qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
group.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "contact.h"
23 
24 #include "src/core/contactid.h"
25 #include "src/core/groupid.h"
28 #include "src/core/toxpk.h"
29 
30 #include <QMap>
31 #include <QObject>
32 #include <QStringList>
33 
34 class Group : public Contact
35 {
36  Q_OBJECT
37 public:
38  Group(int groupId, const GroupId persistentGroupId, const QString& name, bool isAvGroupchat,
40  bool isAvGroupchat() const;
41  uint32_t getId() const override;
42  const GroupId& getPersistentId() const override;
43  int getPeersCount() const;
44  void regeneratePeerList();
45  const QMap<ToxPk, QString>& getPeerList() const;
46  bool peerHasNickname(ToxPk pk);
47 
48  void setEventFlag(bool f) override;
49  bool getEventFlag() const override;
50 
51  void setMentionedFlag(bool f);
52  bool getMentionedFlag() const;
53 
54  void updateUsername(ToxPk pk, const QString newName);
55  void setName(const QString& newTitle) override;
56  void setTitle(const QString& author, const QString& newTitle);
57  QString getName() const;
58  QString getDisplayedName() const override;
59  QString resolveToxPk(const ToxPk& id) const;
60  void setSelfName(const QString& name);
61  QString getSelfName() const;
62 
63 signals:
64  void titleChangedByUser(const QString& title);
65  void titleChanged(const QString& author, const QString& title);
66  void userJoined(const ToxPk& user, const QString& name);
67  void userLeft(const ToxPk& user, const QString& name);
68  void numPeersChanged(int numPeers);
69  void peerNameChanged(const ToxPk& peer, const QString& oldName, const QString& newName);
70 
71 private:
74  QString selfName;
75  QString title;
76  QMap<ToxPk, QString> peerDisplayNames;
82 };
Group::peerHasNickname
bool peerHasNickname(ToxPk pk)
Group::getName
QString getName() const
Definition: group.cpp:72
Group::resolveToxPk
QString resolveToxPk(const ToxPk &id) const
Definition: group.cpp:184
Group::getPeerList
const QMap< ToxPk, QString > & getPeerList() const
Gets the PKs and names of all peers.
Definition: group.cpp:159
Group::isAvGroupchat
bool isAvGroupchat() const
Definition: group.cpp:135
Group::avGroupchat
bool avGroupchat
Definition: group.h:81
Group::Group
Group(int groupId, const GroupId persistentGroupId, const QString &name, bool isAvGroupchat, const QString &selfName, ICoreGroupQuery &groupQuery, ICoreIdHandler &idHandler)
Definition: group.cpp:33
Group::titleChanged
void titleChanged(const QString &author, const QString &title)
Group::getPeersCount
int getPeersCount() const
Definition: group.cpp:150
Group::regeneratePeerList
void regeneratePeerList()
Definition: group.cpp:82
Group::hasNewMessages
bool hasNewMessages
Definition: group.h:77
toxpk.h
Group::numPeersChanged
void numPeersChanged(int numPeers)
Group::setEventFlag
void setEventFlag(bool f) override
Definition: group.cpp:164
Group::getId
uint32_t getId() const override
Definition: group.cpp:140
Group::userJoined
void userJoined(const ToxPk &user, const QString &name)
contactid.h
Group::idHandler
ICoreIdHandler & idHandler
Definition: group.h:73
Group::selfName
QString selfName
Definition: group.h:74
Group::setSelfName
void setSelfName(const QString &name)
Definition: group.cpp:195
ToxPk
This class represents a Tox Public Key, which is a part of Tox ID.
Definition: toxpk.h:26
Group::peerDisplayNames
QMap< ToxPk, QString > peerDisplayNames
Definition: group.h:76
Contact
Definition: contact.h:26
Group::peerNameChanged
void peerNameChanged(const ToxPk &peer, const QString &oldName, const QString &newName)
Group::getMentionedFlag
bool getMentionedFlag() const
Definition: group.cpp:179
Group::getEventFlag
bool getEventFlag() const override
Definition: group.cpp:169
Group::setTitle
void setTitle(const QString &author, const QString &newTitle)
Definition: group.cpp:62
ICoreGroupQuery
Definition: icoregroupquery.h:31
Group::getDisplayedName
QString getDisplayedName() const override
Definition: group.cpp:77
Group::getPersistentId
const GroupId & getPersistentId() const override
Definition: group.cpp:145
icoregroupquery.h
groupid.h
GroupId
This class represents a long term persistent group identifier.
Definition: groupid.h:26
Group
Definition: group.h:34
contact.h
ICoreIdHandler
Definition: icoreidhandler.h:25
Group::setName
void setName(const QString &newTitle) override
Definition: group.cpp:51
Group::setMentionedFlag
void setMentionedFlag(bool f)
Definition: group.cpp:174
Group::userWasMentioned
bool userWasMentioned
Definition: group.h:78
Group::updateUsername
void updateUsername(ToxPk pk, const QString newName)
Definition: group.cpp:123
icoreidhandler.h
Group::toxGroupNum
int toxGroupNum
Definition: group.h:79
Group::groupId
const GroupId groupId
Definition: group.h:80
Group::titleChangedByUser
void titleChangedByUser(const QString &title)
Group::getSelfName
QString getSelfName() const
Definition: group.cpp:200
Group::groupQuery
ICoreGroupQuery & groupQuery
Definition: group.h:72
Group::title
QString title
Definition: group.h:75
Group::userLeft
void userLeft(const ToxPk &user, const QString &name)