1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(model): Rename Contact and ContactId to Chat and ChatId

* Referring to groups generically as contacts is confusing.
* Friends are referred to as contacts in many places either as more
  neutral wording, or to avoid using the keyword friend as a variable
  name. Calling Contact Chat allows contact to be used for Friends.
This commit is contained in:
Anthony Bilinski 2022-03-07 04:18:16 -08:00
parent cf5be40511
commit 16aeb5f572
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
41 changed files with 245 additions and 244 deletions

View File

@ -242,8 +242,8 @@ set(${PROJECT_NAME}_SOURCES
src/core/toxoptions.h
src/core/toxpk.cpp
src/core/toxpk.h
src/core/contactid.cpp
src/core/contactid.h
src/core/chatid.cpp
src/core/chatid.h
src/core/toxstring.cpp
src/core/toxstring.h
src/friendlist.cpp
@ -266,8 +266,8 @@ set(${PROJECT_NAME}_SOURCES
src/model/chatroom/friendchatroom.h
src/model/chatroom/groupchatroom.cpp
src/model/chatroom/groupchatroom.h
src/model/contact.cpp
src/model/contact.h
src/model/chat.cpp
src/model/chat.h
src/model/dialogs/idialogs.cpp
src/model/dialogs/idialogs.h
src/model/dialogs/idialogsmanager.h

View File

@ -38,7 +38,7 @@ endfunction()
add_subdirectory(test/mock)
auto_test(core core "${${PROJECT_NAME}_RESOURCES}")
auto_test(core contactid "")
auto_test(core chatid "")
auto_test(core toxid "")
auto_test(core toxstring "")
auto_test(core fileprogress "")

View File

@ -21,71 +21,71 @@
#include <QString>
#include <cstdint>
#include <QHash>
#include "src/core/contactid.h"
#include "src/core/chatid.h"
/**
* @brief The default constructor. Creates an empty id.
*/
ContactId::ContactId()
ChatId::ChatId()
: id()
{
}
ContactId::~ContactId() = default;
ChatId::~ChatId() = default;
/**
* @brief Constructs a ContactId from bytes.
* @param rawId The bytes to construct the ContactId from.
* @brief Constructs a ChatId from bytes.
* @param rawId The bytes to construct the ChatId from.
*/
ContactId::ContactId(const QByteArray& rawId)
ChatId::ChatId(const QByteArray& rawId)
{
id = QByteArray(rawId);
}
/**
* @brief Compares the equality of the ContactId.
* @param other ContactId to compare.
* @return True if both ContactId are equal, false otherwise.
* @brief Compares the equality of the ChatId.
* @param other ChatId to compare.
* @return True if both ChatId are equal, false otherwise.
*/
bool ContactId::operator==(const ContactId& other) const
bool ChatId::operator==(const ChatId& other) const
{
return id == other.id;
}
/**
* @brief Compares the inequality of the ContactId.
* @param other ContactId to compare.
* @return True if both ContactIds are not equal, false otherwise.
* @brief Compares the inequality of the ChatId.
* @param other ChatId to compare.
* @return True if both ChatIds are not equal, false otherwise.
*/
bool ContactId::operator!=(const ContactId& other) const
bool ChatId::operator!=(const ChatId& other) const
{
return id != other.id;
}
/**
* @brief Compares two ContactIds
* @param other ContactId to compare.
* @return True if this ContactIds is less than the other ContactId, false otherwise.
* @brief Compares two ChatIds
* @param other ChatId to compare.
* @return True if this ChatIds is less than the other ChatId, false otherwise.
*/
bool ContactId::operator<(const ContactId& other) const
bool ChatId::operator<(const ChatId& other) const
{
return id < other.id;
}
/**
* @brief Converts the ContactId to a uppercase hex string.
* @brief Converts the ChatId to a uppercase hex string.
* @return QString containing the hex representation of the id
*/
QString ContactId::toString() const
QString ChatId::toString() const
{
return id.toHex().toUpper();
}
/**
* @brief Returns a pointer to the raw id data.
* @return Pointer to the raw id data, which is exactly `ContactId::getPkSize()`
* bytes long. Returns a nullptr if the ContactId is empty.
* @return Pointer to the raw id data, which is exactly `ChatId::getPkSize()`
* bytes long. Returns a nullptr if the ChatId is empty.
*/
const uint8_t* ContactId::getData() const
const uint8_t* ChatId::getData() const
{
if (id.isEmpty()) {
return nullptr;
@ -98,16 +98,16 @@ const uint8_t* ContactId::getData() const
* @brief Get a copy of the id
* @return Copied id bytes
*/
QByteArray ContactId::getByteArray() const
QByteArray ChatId::getByteArray() const
{
return QByteArray(id); // TODO: Is a copy really necessary?
}
/**
* @brief Checks if the ContactId contains a id.
* @brief Checks if the ChatId contains a id.
* @return True if there is a id, False otherwise.
*/
bool ContactId::isEmpty() const
bool ChatId::isEmpty() const
{
return id.isEmpty();
}

View File

@ -25,17 +25,17 @@
#include <QHash>
#include <memory>
class ContactId
class ChatId
{
public:
virtual ~ContactId();
ContactId(const ContactId&) = default;
ContactId& operator=(const ContactId&) = default;
ContactId(ContactId&&) = default;
ContactId& operator=(ContactId&&) = default;
bool operator==(const ContactId& other) const;
bool operator!=(const ContactId& other) const;
bool operator<(const ContactId& other) const;
virtual ~ChatId();
ChatId(const ChatId&) = default;
ChatId& operator=(const ChatId&) = default;
ChatId(ChatId&&) = default;
ChatId& operator=(ChatId&&) = default;
bool operator==(const ChatId& other) const;
bool operator!=(const ChatId& other) const;
bool operator<(const ChatId& other) const;
QString toString() const;
QByteArray getByteArray() const;
const uint8_t* getData() const;
@ -43,14 +43,14 @@ public:
virtual int getSize() const = 0;
protected:
ContactId();
explicit ContactId(const QByteArray& rawId);
ChatId();
explicit ChatId(const QByteArray& rawId);
QByteArray id;
};
inline uint qHash(const ContactId& id)
inline uint qHash(const ChatId& id)
{
return qHash(id.getByteArray());
}
using ContactIdPtr = std::shared_ptr<const ContactId>;
using ChatIdPtr = std::shared_ptr<const ChatId>;

View File

@ -33,7 +33,7 @@
* @brief The default constructor. Creates an empty Tox group ID.
*/
GroupId::GroupId()
: ContactId()
: ChatId()
{
}
@ -43,7 +43,7 @@ GroupId::GroupId()
* GroupId::size, else the GroupId will be empty.
*/
GroupId::GroupId(const QByteArray& rawId)
: ContactId([rawId](){
: ChatId([rawId](){
assert(rawId.length() == size);
return rawId;}())
{
@ -55,7 +55,7 @@ GroupId::GroupId(const QByteArray& rawId)
* GroupId::size from the specified buffer.
*/
GroupId::GroupId(const uint8_t* rawId)
: ContactId(QByteArray(reinterpret_cast<const char*>(rawId), size))
: ChatId(QByteArray(reinterpret_cast<const char*>(rawId), size))
{
}

View File

@ -19,11 +19,11 @@
#pragma once
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include <QByteArray>
#include <cstdint>
class GroupId : public ContactId
class GroupId : public ChatId
{
public:
static constexpr int size = 32;

View File

@ -18,7 +18,7 @@
*/
#include "contactid.h"
#include "chatid.h"
#include "toxid.h"
#include "toxpk.h"

View File

@ -17,7 +17,7 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contactid.h"
#include "chatid.h"
#include "toxpk.h"
#include <QByteArray>
@ -34,7 +34,7 @@
* @brief The default constructor. Creates an empty Tox key.
*/
ToxPk::ToxPk()
: ContactId()
: ChatId()
{
}
@ -44,7 +44,7 @@ ToxPk::ToxPk()
* ToxPk::size, else the ToxPk will be empty.
*/
ToxPk::ToxPk(const QByteArray& rawId)
: ContactId([&rawId](){
: ChatId([&rawId](){
assert(rawId.length() == size);
return rawId;}())
{
@ -56,7 +56,7 @@ ToxPk::ToxPk(const QByteArray& rawId)
* ToxPk::size from the specified buffer.
*/
ToxPk::ToxPk(const uint8_t* rawId)
: ContactId(QByteArray(reinterpret_cast<const char*>(rawId), size))
: ChatId(QByteArray(reinterpret_cast<const char*>(rawId), size))
{
}
@ -68,7 +68,7 @@ ToxPk::ToxPk(const uint8_t* rawId)
* @param pk Tox Pk string to convert to ToxPk object
*/
ToxPk::ToxPk(const QString& pk)
: ContactId([&pk](){
: ChatId([&pk](){
if (pk.length() == numHexChars) {
return QByteArray::fromHex(pk.toLatin1());
} else {

View File

@ -19,11 +19,11 @@
#pragma once
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include <QByteArray>
#include <cstdint>
class ToxPk : public ContactId
class ToxPk : public ChatId
{
public:
static constexpr int size = 32;

View File

@ -20,7 +20,7 @@
#include "friendlist.h"
#include "src/model/friend.h"
#include "src/persistence/settings.h"
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/core/toxpk.h"
#include <QDebug>
#include <QHash>

View File

@ -18,10 +18,10 @@
*/
#include "contact.h"
#include "chat.h"
#include <QVariant>
Contact::~Contact()
Chat::~Chat()
{
}

View File

@ -19,20 +19,20 @@
#pragma once
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include <QObject>
#include <QString>
class Contact : public QObject
class Chat : public QObject
{
Q_OBJECT
public:
virtual ~Contact() = 0;
virtual ~Chat() = 0;
virtual void setName(const QString& name) = 0;
virtual QString getDisplayedName() const = 0;
virtual uint32_t getId() const = 0;
virtual const ContactId& getPersistentId() const = 0;
virtual const ChatId& getPersistentId() const = 0;
virtual void setEventFlag(bool flag) = 0;
virtual bool getEventFlag() const = 0;

View File

@ -19,7 +19,7 @@
#pragma once
#include "src/model/contact.h"
#include "src/model/chat.h"
class Chatroom
{
@ -31,5 +31,5 @@ public:
Chatroom(Chatroom&&) = default;
Chatroom& operator=(Chatroom&&) = default;
virtual Contact* getContact() = 0;
virtual Chat* getChat() = 0;
};

View File

@ -55,7 +55,7 @@ Friend* FriendChatroom::getFriend()
return frnd;
}
Contact* FriendChatroom::getContact()
Chat* FriendChatroom::getChat()
{
return frnd;
}
@ -175,14 +175,14 @@ bool FriendChatroom::canBeRemovedFromWindow() const
{
const auto friendPk = frnd->getPublicKey();
const auto dialogs = dialogsManager->getFriendDialogs(friendPk);
return dialogs && dialogs->hasContact(friendPk);
return dialogs && dialogs->hasChat(friendPk);
}
bool FriendChatroom::friendCanBeRemoved() const
{
const auto friendPk = frnd->getPublicKey();
const auto dialogs = dialogsManager->getFriendDialogs(friendPk);
return !dialogs || !dialogs->hasContact(friendPk);
return !dialogs || !dialogs->hasChat(friendPk);
}
void FriendChatroom::removeFriendFromDialogs()

View File

@ -50,7 +50,7 @@ public:
FriendChatroom(Friend* frnd_, IDialogsManager* dialogsManager_, Core& core_,
Settings& settings_);
Contact* getContact() override;
Chat* getChat() override;
public slots:

View File

@ -35,7 +35,7 @@ GroupChatroom::GroupChatroom(Group* group_, IDialogsManager* dialogsManager_, Co
{
}
Contact* GroupChatroom::getContact()
Chat* GroupChatroom::getChat()
{
return group;
}
@ -84,7 +84,7 @@ bool GroupChatroom::canBeRemovedFromWindow() const
{
const auto groupId = group->getPersistentId();
const auto dialogs = dialogsManager->getGroupDialogs(groupId);
return dialogs && dialogs->hasContact(groupId);
return dialogs && dialogs->hasChat(groupId);
}
void GroupChatroom::removeGroupFromDialogs()

View File

@ -34,7 +34,7 @@ class GroupChatroom : public QObject, public Chatroom
public:
GroupChatroom(Group* group_, IDialogsManager* dialogsManager_, Core& core_);
Contact* getContact() override;
Chat* getChat() override;
Group* getGroup();

View File

@ -19,7 +19,7 @@
#pragma once
class ContactId;
class ChatId;
class GroupId;
class ToxPk;
@ -33,8 +33,8 @@ public:
IDialogs(IDialogs&&) = default;
IDialogs& operator=(IDialogs&&) = default;
virtual bool hasContact(const ContactId& contactId) const = 0;
virtual bool isContactActive(const ContactId& contactId) const = 0;
virtual bool hasChat(const ChatId& chatId) const = 0;
virtual bool isChatActive(const ChatId& chatId) const = 0;
virtual void removeFriend(const ToxPk& friendPk) = 0;
virtual void removeGroup(const GroupId& groupId) = 0;

View File

@ -138,7 +138,7 @@ uint32_t Friend::getId() const
return friendId;
}
const ContactId& Friend::getPersistentId() const
const ChatId& Friend::getPersistentId() const
{
return friendPk;
}

View File

@ -19,16 +19,16 @@
#pragma once
#include "contact.h"
#include "chat.h"
#include "src/core/core.h"
#include "src/core/extension.h"
#include "src/core/toxpk.h"
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/model/status.h"
#include <QObject>
#include <QString>
class Friend : public Contact
class Friend : public Chat
{
Q_OBJECT
public:
@ -49,7 +49,7 @@ public:
const ToxPk& getPublicKey() const;
uint32_t getId() const override;
const ContactId& getPersistentId() const override;
const ChatId& getPersistentId() const override;
void finishNegotiation();
void setStatus(Status::Status s);

View File

@ -19,7 +19,7 @@
#include "group.h"
#include "friend.h"
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/core/groupid.h"
#include "src/core/toxpk.h"
#include "src/friendlist.h"

View File

@ -19,9 +19,9 @@
#pragma once
#include "contact.h"
#include "chat.h"
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/core/groupid.h"
#include "src/core/icoregroupquery.h"
#include "src/core/icoreidhandler.h"
@ -31,7 +31,7 @@
#include <QObject>
#include <QStringList>
class Group : public Contact
class Group : public Chat
{
Q_OBJECT
public:

View File

@ -107,7 +107,7 @@ void Nexus::start()
qRegisterMetaType<ToxPk>("ToxPk");
qRegisterMetaType<ToxId>("ToxId");
qRegisterMetaType<ToxPk>("GroupId");
qRegisterMetaType<ToxPk>("ContactId");
qRegisterMetaType<ToxPk>("ChatId");
qRegisterMetaType<GroupInvite>("GroupInvite");
qRegisterMetaType<ReceiptNum>("ReceiptNum");
qRegisterMetaType<RowId>("RowId");

View File

@ -165,7 +165,7 @@ void CategoryWidget::search(const QString& searchString, bool updateAll, bool hi
setVisible(inCategory || listLayout->hasChatrooms());
}
bool CategoryWidget::cycleContacts(bool forward)
bool CategoryWidget::cycleChats(bool forward)
{
if (listLayout->friendTotalCount() == 0) {
return false;
@ -196,7 +196,7 @@ bool CategoryWidget::cycleContacts(bool forward)
return false;
}
bool CategoryWidget::cycleContacts(FriendWidget* activeChatroomWidget, bool forward)
bool CategoryWidget::cycleChats(FriendWidget* activeChatroomWidget, bool forward)
{
int index = -1;
QLayout* currentLayout = nullptr;

View File

@ -45,8 +45,8 @@ public:
void updateStatus();
bool hasChatrooms() const;
bool cycleContacts(bool forward);
bool cycleContacts(FriendWidget* activeChatroomWidget, bool forward);
bool cycleChats(bool forward);
bool cycleChats(FriendWidget* activeChatroomWidget, bool forward);
void search(const QString& searchString, bool updateAll = false, bool hideOnline = false,
bool hideOffline = false);

View File

@ -130,10 +130,10 @@ ContentDialog::ContentDialog(const Core &core, Settings& settings_, QWidget* par
reloadTheme();
new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousContact()));
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextContact()));
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousContact()));
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousChat()));
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextChat()));
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousChat()));
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextChat()));
connect(&settings, &Settings::groupchatPositionChanged, this, &ContentDialog::onGroupchatPositionChanged);
connect(splitter, &QSplitter::splitterMoved, this, &ContentDialog::saveSplitterState);
@ -159,9 +159,9 @@ FriendWidget* ContentDialog::addFriend(std::shared_ptr<FriendChatroom> chatroom,
const auto& friendPk = frnd->getPublicKey();
auto friendWidget = new FriendWidget(chatroom, compact, settings);
emit connectFriendWidget(*friendWidget);
contactWidgets[friendPk] = friendWidget;
chatWidgets[friendPk] = friendWidget;
friendLayout->addFriendWidget(friendWidget, frnd->getStatus());
contactChatForms[friendPk] = form;
chatForms[friendPk] = form;
// TODO(sudden6): move this connection to the Friend::displayedNameChanged signal
connect(frnd, &Friend::aliasChanged, this, &ContentDialog::updateFriendWidget);
@ -180,9 +180,9 @@ GroupWidget* ContentDialog::addGroup(std::shared_ptr<GroupChatroom> chatroom, Ge
const auto& groupId = g->getPersistentId();
const auto compact = settings.getCompactLayout();
auto groupWidget = new GroupWidget(chatroom, compact, settings);
contactWidgets[groupId] = groupWidget;
chatWidgets[groupId] = groupWidget;
groupLayout.addSortedWidget(groupWidget);
contactChatForms[groupId] = form;
chatForms[groupId] = form;
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
@ -194,13 +194,13 @@ GroupWidget* ContentDialog::addGroup(std::shared_ptr<GroupChatroom> chatroom, Ge
void ContentDialog::removeFriend(const ToxPk& friendPk)
{
auto chatroomWidget = qobject_cast<FriendWidget*>(contactWidgets[friendPk]);
auto chatroomWidget = qobject_cast<FriendWidget*>(chatWidgets[friendPk]);
disconnect(chatroomWidget->getFriend(), &Friend::aliasChanged, this,
&ContentDialog::updateFriendWidget);
// Need to find replacement to show here instead.
if (activeChatroomWidget == chatroomWidget) {
cycleContacts(/* forward = */ true, /* inverse = */ false);
cycleChats(/* forward = */ true, /* inverse = */ false);
}
friendLayout->removeFriendWidget(chatroomWidget, Status::Status::Offline);
@ -216,17 +216,17 @@ void ContentDialog::removeFriend(const ToxPk& friendPk)
update();
}
contactWidgets.remove(friendPk);
contactChatForms.remove(friendPk);
chatWidgets.remove(friendPk);
chatForms.remove(friendPk);
closeIfEmpty();
}
void ContentDialog::removeGroup(const GroupId& groupId)
{
auto chatroomWidget = qobject_cast<GroupWidget*>(contactWidgets[groupId]);
auto chatroomWidget = qobject_cast<GroupWidget*>(chatWidgets[groupId]);
// Need to find replacement to show here instead.
if (activeChatroomWidget == chatroomWidget) {
cycleContacts(true, false);
cycleChats(true, false);
}
groupLayout.removeSortedWidget(chatroomWidget);
@ -240,14 +240,14 @@ void ContentDialog::removeGroup(const GroupId& groupId)
update();
}
contactWidgets.remove(groupId);
contactChatForms.remove(groupId);
chatWidgets.remove(groupId);
chatForms.remove(groupId);
closeIfEmpty();
}
void ContentDialog::closeIfEmpty()
{
if (contactWidgets.isEmpty()) {
if (chatWidgets.isEmpty()) {
close();
}
}
@ -298,11 +298,11 @@ int ContentDialog::getCurrentLayout(QLayout*& layout)
}
/**
* @brief Activate next/previous contact.
* @brief Activate next/previous chat.
* @param forward If true, activate next contace, previous otherwise.
* @param inverse ??? TODO: Add docs.
*/
void ContentDialog::cycleContacts(bool forward, bool inverse)
void ContentDialog::cycleChats(bool forward, bool inverse)
{
QLayout* currentLayout;
int index = getCurrentLayout(currentLayout);
@ -413,17 +413,17 @@ void ContentDialog::reorderLayouts(bool newGroupOnTop)
}
}
void ContentDialog::previousContact()
void ContentDialog::previousChat()
{
cycleContacts(false);
cycleChats(false);
}
/**
* @brief Enable next contact.
* @brief Enable next chat.
*/
void ContentDialog::nextContact()
void ContentDialog::nextChat()
{
cycleContacts(true);
cycleChats(true);
}
/**
@ -486,7 +486,7 @@ void ContentDialog::dragEnterEvent(QDragEnterEvent* event)
ToxPk friendId = contact->getPublicKey();
// If friend is already in a dialog then you can't drop friend where it already is.
if (!hasContact(friendId)) {
if (!hasChat(friendId)) {
event->acceptProposedAction();
}
} else if (group) {
@ -497,7 +497,7 @@ void ContentDialog::dragEnterEvent(QDragEnterEvent* event)
return;
}
if (!hasContact(groupId)) {
if (!hasChat(groupId)) {
event->acceptProposedAction();
}
}
@ -561,12 +561,12 @@ void ContentDialog::keyPressEvent(QKeyEvent* event)
}
}
void ContentDialog::focusContact(const ContactId& contactId)
void ContentDialog::focusChat(const ChatId& chatId)
{
focusCommon(contactId, contactWidgets);
focusCommon(chatId, chatWidgets);
}
void ContentDialog::focusCommon(const ContactId& id, QHash<const ContactId&, GenericChatroomWidget*> list)
void ContentDialog::focusCommon(const ChatId& id, QHash<const ChatId&, GenericChatroomWidget*> list)
{
auto it = list.find(id);
if (it == list.end()) {
@ -594,8 +594,8 @@ void ContentDialog::activate(GenericChatroomWidget* widget)
}
activeChatroomWidget = widget;
const Contact* contact = widget->getContact();
contactChatForms[contact->getPersistentId()]->show(contentLayout);
const Chat* chat = widget->getChat();
chatForms[chat->getPersistentId()]->show(contentLayout);
widget->setAsActiveChatroom();
widget->resetEventFlags();
@ -605,21 +605,21 @@ void ContentDialog::activate(GenericChatroomWidget* widget)
void ContentDialog::updateFriendStatus(const ToxPk& friendPk, Status::Status status)
{
auto widget = qobject_cast<FriendWidget*>(contactWidgets.value(friendPk));
auto widget = qobject_cast<FriendWidget*>(chatWidgets.value(friendPk));
addFriendWidget(widget, status);
}
void ContentDialog::updateContactStatusLight(const ContactId& contactId)
void ContentDialog::updateChatStatusLight(const ChatId& chatId)
{
auto widget = contactWidgets.value(contactId);
auto widget = chatWidgets.value(chatId);
if (widget != nullptr) {
widget->updateStatusLight();
}
}
bool ContentDialog::isContactActive(const ContactId& contactId) const
bool ContentDialog::isChatActive(const ChatId& chatId) const
{
auto widget = contactWidgets.value(contactId);
auto widget = chatWidgets.value(chatId);
if (widget == nullptr) {
return false;
}
@ -630,7 +630,7 @@ bool ContentDialog::isContactActive(const ContactId& contactId) const
// TODO: Connect to widget directly
void ContentDialog::setStatusMessage(const ToxPk& friendPk, const QString& message)
{
auto widget = contactWidgets.value(friendPk);
auto widget = chatWidgets.value(friendPk);
if (widget != nullptr) {
widget->setStatusMsg(message);
}
@ -645,7 +645,7 @@ void ContentDialog::updateFriendWidget(const ToxPk& friendPk, QString alias)
{
std::ignore = alias;
Friend* f = FriendList::findFriend(friendPk);
FriendWidget* friendWidget = qobject_cast<FriendWidget*>(contactWidgets[friendPk]);
FriendWidget* friendWidget = qobject_cast<FriendWidget*>(chatWidgets[friendPk]);
Status::Status status = f->getStatus();
friendLayout->addFriendWidget(friendWidget, status);
@ -687,9 +687,9 @@ void ContentDialog::saveSplitterState()
settings.setDialogSplitterState(splitter->saveState());
}
bool ContentDialog::hasContact(const ContactId& contactId) const
bool ContentDialog::hasChat(const ChatId& chatId) const
{
return contactWidgets.contains(contactId);
return chatWidgets.contains(chatId);
}
/**

View File

@ -62,19 +62,19 @@ public:
void ensureSplitterVisible();
void updateTitleAndStatusIcon();
void cycleContacts(bool forward, bool loop = true);
void cycleChats(bool forward, bool loop = true);
void onVideoShow(QSize size);
void onVideoHide();
void addFriendWidget(FriendWidget* widget, Status::Status status);
bool isActiveWidget(GenericChatroomWidget* widget);
bool hasContact(const ContactId& contactId) const override;
bool isContactActive(const ContactId& contactId) const override;
bool hasChat(const ChatId& chatId) const override;
bool isChatActive(const ChatId& chatId) const override;
void focusContact(const ContactId& friendPk);
void focusChat(const ChatId& friendPk);
void updateFriendStatus(const ToxPk& friendPk, Status::Status status);
void updateContactStatusLight(const ContactId& contactId);
void updateChatStatusLight(const ChatId& chatId);
void setStatusMessage(const ToxPk& friendPk, const QString& message);
@ -89,8 +89,8 @@ signals:
public slots:
void reorderLayouts(bool newGroupOnTop);
void previousContact();
void nextContact();
void previousChat();
void nextChat();
void setUsername(const QString& newName);
void reloadTheme() override;
@ -119,7 +119,7 @@ private:
void saveSplitterState();
QLayout* nextLayout(QLayout* layout, bool forward) const;
int getCurrentLayout(QLayout*& layout);
void focusCommon(const ContactId& id, QHash<const ContactId&, GenericChatroomWidget*> list);
void focusCommon(const ChatId& id, QHash<const ChatId&, GenericChatroomWidget*> list);
private:
QList<QLayout*> layouts;
@ -132,8 +132,8 @@ private:
QSize videoSurfaceSize;
int videoCount;
QHash<const ContactId&, GenericChatroomWidget*> contactWidgets;
QHash<const ContactId&, GenericChatForm*> contactChatForms;
QHash<const ChatId&, GenericChatroomWidget*> chatWidgets;
QHash<const ChatId&, GenericChatForm*> chatForms;
QString username;
Settings& settings;

View File

@ -29,7 +29,7 @@
#include <tuple>
namespace {
void removeDialog(ContentDialog* dialog, QHash<const ContactId&, ContentDialog*>& dialogs)
void removeDialog(ContentDialog* dialog, QHash<const ChatId&, ContentDialog*>& dialogs)
{
for (auto it = dialogs.begin(); it != dialogs.end();) {
if (*it == dialog) {
@ -48,14 +48,14 @@ ContentDialog* ContentDialogManager::current()
return currentDialog;
}
bool ContentDialogManager::contactWidgetExists(const ContactId& contactId)
bool ContentDialogManager::chatWidgetExists(const ChatId& chatId)
{
const auto dialog = contactDialogs.value(contactId, nullptr);
const auto dialog = chatDialogs.value(chatId, nullptr);
if (dialog == nullptr) {
return false;
}
return dialog->hasContact(contactId);
return dialog->hasChat(chatId);
}
FriendWidget* ContentDialogManager::addFriendToDialog(ContentDialog* dialog,
@ -70,7 +70,7 @@ FriendWidget* ContentDialogManager::addFriendToDialog(ContentDialog* dialog,
lastDialog->removeFriend(friendPk);
}
contactDialogs[friendPk] = dialog;
chatDialogs[friendPk] = dialog;
return friendWidget;
}
@ -86,15 +86,15 @@ GroupWidget* ContentDialogManager::addGroupToDialog(ContentDialog* dialog,
lastDialog->removeGroup(groupId);
}
contactDialogs[groupId] = dialog;
chatDialogs[groupId] = dialog;
return groupWidget;
}
void ContentDialogManager::focusContact(const ContactId& contactId)
void ContentDialogManager::focusChat(const ChatId& chatId)
{
auto dialog = focusDialog(contactId, contactDialogs);
auto dialog = focusDialog(chatId, chatDialogs);
if (dialog != nullptr) {
dialog->focusContact(contactId);
dialog->focusChat(chatId);
}
}
@ -104,8 +104,8 @@ void ContentDialogManager::focusContact(const ContactId& contactId)
* @param list List with dialogs
* @return ContentDialog if found, nullptr otherwise
*/
ContentDialog* ContentDialogManager::focusDialog(const ContactId& id,
const QHash<const ContactId&, ContentDialog*>& list)
ContentDialog* ContentDialogManager::focusDialog(const ChatId& id,
const QHash<const ChatId&, ContentDialog*>& list)
{
auto iter = list.find(id);
if (iter == list.end()) {
@ -124,13 +124,13 @@ ContentDialog* ContentDialogManager::focusDialog(const ContactId& id,
void ContentDialogManager::updateFriendStatus(const ToxPk& friendPk)
{
auto dialog = contactDialogs.value(friendPk);
auto dialog = chatDialogs.value(friendPk);
if (dialog == nullptr) {
return;
}
dialog->updateContactStatusLight(friendPk);
if (dialog->isContactActive(friendPk)) {
dialog->updateChatStatusLight(friendPk);
if (dialog->isChatActive(friendPk)) {
dialog->updateTitleAndStatusIcon();
}
@ -140,35 +140,35 @@ void ContentDialogManager::updateFriendStatus(const ToxPk& friendPk)
void ContentDialogManager::updateGroupStatus(const GroupId& groupId)
{
auto dialog = contactDialogs.value(groupId);
auto dialog = chatDialogs.value(groupId);
if (dialog == nullptr) {
return;
}
dialog->updateContactStatusLight(groupId);
if (dialog->isContactActive(groupId)) {
dialog->updateChatStatusLight(groupId);
if (dialog->isChatActive(groupId)) {
dialog->updateTitleAndStatusIcon();
}
}
bool ContentDialogManager::isContactActive(const ContactId& contactId)
bool ContentDialogManager::isChatActive(const ChatId& chatId)
{
const auto dialog = contactDialogs.value(contactId);
const auto dialog = chatDialogs.value(chatId);
if (dialog == nullptr) {
return false;
}
return dialog->isContactActive(contactId);
return dialog->isChatActive(chatId);
}
ContentDialog* ContentDialogManager::getFriendDialog(const ToxPk& friendPk) const
{
return contactDialogs.value(friendPk);
return chatDialogs.value(friendPk);
}
ContentDialog* ContentDialogManager::getGroupDialog(const GroupId& groupId) const
{
return contactDialogs.value(groupId);
return chatDialogs.value(groupId);
}
ContentDialogManager* ContentDialogManager::getInstance()
@ -200,7 +200,7 @@ void ContentDialogManager::onDialogClose()
currentDialog = nullptr;
}
removeDialog(dialog, contactDialogs);
removeDialog(dialog, chatDialogs);
}
IDialogs* ContentDialogManager::getFriendDialogs(const ToxPk& friendPk) const

View File

@ -20,7 +20,7 @@
#pragma once
#include "contentdialog.h"
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/core/groupid.h"
#include "src/core/toxpk.h"
#include "src/model/dialogs/idialogsmanager.h"
@ -35,11 +35,11 @@ class ContentDialogManager : public QObject, public IDialogsManager
Q_OBJECT
public:
ContentDialog* current();
bool contactWidgetExists(const ContactId& groupId);
void focusContact(const ContactId& contactId);
bool chatWidgetExists(const ChatId& groupId);
void focusChat(const ChatId& chatId);
void updateFriendStatus(const ToxPk& friendPk);
void updateGroupStatus(const GroupId& friendPk);
bool isContactActive(const ContactId& contactId);
bool isChatActive(const ChatId& chatId);
ContentDialog* getFriendDialog(const ToxPk& friendPk) const;
ContentDialog* getGroupDialog(const GroupId& friendPk) const;
@ -60,12 +60,12 @@ private slots:
void onDialogActivate();
private:
ContentDialog* focusDialog(const ContactId& id,
const QHash<const ContactId&, ContentDialog*>& list);
ContentDialog* focusDialog(const ChatId& id,
const QHash<const ChatId&, ContentDialog*>& list);
ContentDialog* currentDialog = nullptr;
QHash<const ContactId&, ContentDialog*> contactDialogs;
QHash<const ChatId&, ContentDialog*> chatDialogs;
static ContentDialogManager* instance;
};

View File

@ -136,7 +136,7 @@ QPushButton* createButton(const QString& name, T* self, Fun onClickSlot, Setting
} // namespace
GenericChatForm::GenericChatForm(const Core& core_, const Contact* contact, IChatLog& chatLog_,
GenericChatForm::GenericChatForm(const Core& core_, const Chat* chat, IChatLog& chatLog_,
IMessageDispatcher& messageDispatcher_, DocumentCache& documentCache,
SmileyPack& smileyPack_, Settings& settings_, QWidget* parent_)
: QWidget(parent_, Qt::Window)
@ -273,7 +273,7 @@ GenericChatForm::GenericChatForm(const Core& core_, const Contact* contact, ICha
Translator::registerHandler(std::bind(&GenericChatForm::retranslateUi, this), this);
// update header on name/title change
connect(contact, &Contact::displayedNameChanged, this, &GenericChatForm::setName);
connect(chat, &Chat::displayedNameChanged, this, &GenericChatForm::setName);
}

View File

@ -36,7 +36,7 @@
class ChatFormHeader;
class ChatWidget;
class ChatTextEdit;
class Contact;
class Chat;
class ContentLayout;
class CroppingLabel;
class FlyoutOverlayWidget;
@ -71,7 +71,7 @@ class GenericChatForm : public QWidget
{
Q_OBJECT
public:
GenericChatForm(const Core& core_, const Contact* contact, IChatLog& chatLog_,
GenericChatForm(const Core& core_, const Chat* chat, IChatLog& chatLog_,
IMessageDispatcher& messageDispatcher_, DocumentCache&,
SmileyPack&, Settings&, QWidget* parent_ = nullptr);
~GenericChatForm() override;

View File

@ -442,7 +442,7 @@ void FriendListWidget::onGroupchatPositionChanged(bool top)
itemsChanged();
}
void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget, bool forward)
void FriendListWidget::cycleChats(GenericChatroomWidget* activeChatroomWidget, bool forward)
{
if (!activeChatroomWidget) {
return;
@ -461,7 +461,7 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
QWidget* widget_ = activityLayout->itemAt(index)->widget();
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(widget_);
if (categoryWidget == nullptr || categoryWidget->cycleContacts(friendWidget, forward)) {
if (categoryWidget == nullptr || categoryWidget->cycleChats(friendWidget, forward)) {
return;
}
@ -481,7 +481,7 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
categoryWidget = qobject_cast<CategoryWidget*>(widget);
if (categoryWidget != nullptr) {
if (!categoryWidget->cycleContacts(forward)) {
if (!categoryWidget->cycleChats(forward)) {
// Skip empty or finished categories.
index += forward ? 1 : -1;
continue;

View File

@ -60,7 +60,7 @@ public:
void searchChatrooms(const QString& searchString, bool hideOnline = false,
bool hideOffline = false, bool hideGroups = false);
void cycleContacts(GenericChatroomWidget* activeChatroomWidget, bool forward);
void cycleChats(GenericChatroomWidget* activeChatroomWidget, bool forward);
void updateActivityTime(const QDateTime& date);

View File

@ -351,7 +351,7 @@ const Friend* FriendWidget::getFriend() const
return chatroom->getFriend();
}
const Contact* FriendWidget::getContact() const
const Chat* FriendWidget::getChat() const
{
return getFriend();
}

View File

@ -44,7 +44,7 @@ public:
void resetEventFlags() final;
QString getStatusString() const final;
const Friend* getFriend() const final;
const Contact* getContact() const final;
const Chat* getChat() const final;
bool isFriend() const final;
bool isGroup() const final;

View File

@ -30,6 +30,7 @@ class Friend;
class Group;
class Contact;
class Settings;
class Chat;
class GenericChatroomWidget : public GenericChatItemWidget
{
@ -43,7 +44,7 @@ public slots:
virtual void updateStatusLight() = 0;
virtual void resetEventFlags() = 0;
virtual QString getStatusString() const = 0;
virtual const Contact* getContact() const = 0;
virtual const Chat* getChat() const = 0;
virtual const Friend* getFriend() const
{
return nullptr;

View File

@ -235,7 +235,7 @@ Group* GroupWidget::getGroup() const
return chatroom->getGroup();
}
const Contact* GroupWidget::getContact() const
const Chat* GroupWidget::getChat() const
{
return getGroup();
}

View File

@ -41,7 +41,7 @@ public:
void resetEventFlags() final;
QString getStatusString() const final;
Group* getGroup() const final;
const Contact* getContact() const final;
const Chat* getChat() const final;
void setName(const QString& name);
void editName();

View File

@ -262,11 +262,11 @@ void Widget::init()
sharedMessageProcessorParams.reset(new MessageProcessor::SharedParams(core->getMaxMessageSize(), coreExt->getMaxExtendedMessageSize()));
contactListWidget = new FriendListWidget(*core, this, settings, settings.getGroupchatPosition());
connect(contactListWidget, &FriendListWidget::searchCircle, this, &Widget::searchCircle);
connect(contactListWidget, &FriendListWidget::connectCircleWidget, this,
chatListWidget = new FriendListWidget(*core, this, settings, settings.getGroupchatPosition());
connect(chatListWidget, &FriendListWidget::searchCircle, this, &Widget::searchCircle);
connect(chatListWidget, &FriendListWidget::connectCircleWidget, this,
&Widget::connectCircleWidget);
ui->friendList->setWidget(contactListWidget);
ui->friendList->setWidget(chatListWidget);
ui->friendList->setLayoutDirection(Qt::RightToLeft);
ui->friendList->setContextMenuPolicy(Qt::CustomContextMenu);
@ -331,8 +331,8 @@ void Widget::init()
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
connect(ui->searchContactText, &QLineEdit::textChanged, this, &Widget::searchContacts);
connect(filterGroup, &QActionGroup::triggered, this, &Widget::searchContacts);
connect(ui->searchContactText, &QLineEdit::textChanged, this, &Widget::searchChats);
connect(filterGroup, &QActionGroup::triggered, this, &Widget::searchChats);
connect(filterDisplayGroup, &QActionGroup::triggered, this, &Widget::changeDisplayMode);
connect(ui->friendList, &QWidget::customContextMenuRequested, this, &Widget::friendListContextMenu);
@ -375,10 +375,10 @@ void Widget::init()
// keyboard shortcuts
auto* const quitShortcut = new QShortcut(Qt::CTRL + Qt::Key_Q, this);
connect(quitShortcut, &QShortcut::activated, qApp, &QApplication::quit);
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousContact()));
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextContact()));
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousContact()));
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousChat()));
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextChat()));
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousChat()));
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextChat()));
new QShortcut(Qt::Key_F11, this, SLOT(toggleFullscreen()));
#ifdef Q_OS_MAC
@ -420,9 +420,9 @@ void Widget::init()
nextConversationAction->setShortcut(QKeySequence::SelectNextPage);
connect(nextConversationAction, &QAction::triggered, [this]() {
if (ContentDialogManager::getInstance()->current() == QApplication::activeWindow())
ContentDialogManager::getInstance()->current()->cycleContacts(true);
ContentDialogManager::getInstance()->current()->cycleChats(true);
else if (QApplication::activeWindow() == this)
cycleContacts(true);
cycleChats(true);
});
previousConversationAction = new QAction(this);
@ -430,9 +430,9 @@ void Widget::init()
previousConversationAction->setShortcut(QKeySequence::SelectPreviousPage);
connect(previousConversationAction, &QAction::triggered, [this] {
if (ContentDialogManager::getInstance()->current() == QApplication::activeWindow())
ContentDialogManager::getInstance()->current()->cycleContacts(false);
ContentDialogManager::getInstance()->current()->cycleChats(false);
else if (QApplication::activeWindow() == this)
cycleContacts(false);
cycleChats(false);
});
windowMenu->menu()->insertSeparator(frontAction);
@ -491,9 +491,9 @@ void Widget::init()
// settings
connect(&settings, &Settings::showSystemTrayChanged, this, &Widget::onSetShowSystemTray);
connect(&settings, &Settings::separateWindowChanged, this, &Widget::onSeparateWindowClicked);
connect(&settings, &Settings::compactLayoutChanged, contactListWidget,
connect(&settings, &Settings::compactLayoutChanged, chatListWidget,
&FriendListWidget::onCompactChanged);
connect(&settings, &Settings::groupchatPositionChanged, contactListWidget,
connect(&settings, &Settings::groupchatPositionChanged, chatListWidget,
&FriendListWidget::onGroupchatPositionChanged);
connect(&GUI::getInstance(), &GUI::themeReload, this, &Widget::reloadTheme);
@ -1213,7 +1213,7 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
settings.setFriendActivity(friendPk, chatTime);
}
contactListWidget->addFriendWidget(widget);
chatListWidget->addFriendWidget(widget);
auto notifyReceivedCallback = [this, friendPk](const ToxPk& author, const Message& message) {
@ -1297,9 +1297,9 @@ void Widget::onFriendStatusChanged(const ToxPk& friendPk, Status::Status status)
FriendWidget* widget = friendWidgets[friendPk];
if (Status::isOnline(status)) {
contactListWidget->moveWidget(widget, Status::Status::Online);
chatListWidget->moveWidget(widget, Status::Status::Online);
} else {
contactListWidget->moveWidget(widget, Status::Status::Offline);
chatListWidget->moveWidget(widget, Status::Status::Offline);
}
widget->updateStatusLight();
@ -1341,7 +1341,7 @@ void Widget::onFriendDisplayedNameChanged(const QString& displayed)
GUI::setWindowTitle(displayed);
}
contactListWidget->itemsChanged();
chatListWidget->itemsChanged();
}
void Widget::onFriendUsernameChanged(int friendId, const QString& username)
@ -1389,8 +1389,8 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
form = groupChatForms[id].data();
}
bool chatFormIsSet;
ContentDialogManager::getInstance()->focusContact(id);
chatFormIsSet = ContentDialogManager::getInstance()->contactWidgetExists(id);
ContentDialogManager::getInstance()->focusChat(id);
chatFormIsSet = ContentDialogManager::getInstance()->chatWidgetExists(id);
if ((chatFormIsSet || form->isVisible()) && !newWindow) {
@ -1585,7 +1585,7 @@ bool Widget::newFriendMessageAlert(const ToxPk& friendId, const QString& text, b
if (contentDialog != nullptr) {
currentWindow = contentDialog->window();
hasActive = ContentDialogManager::getInstance()->isContactActive(friendId);
hasActive = ContentDialogManager::getInstance()->isChatActive(friendId);
} else {
if (settings.getSeparateWindow() && settings.getShowWindow()) {
if (settings.getDontGroupWindows()) {
@ -1599,7 +1599,7 @@ bool Widget::newFriendMessageAlert(const ToxPk& friendId, const QString& text, b
addFriendDialog(f, contentDialog);
currentWindow = contentDialog->window();
hasActive = ContentDialogManager::getInstance()->isContactActive(friendId);
hasActive = ContentDialogManager::getInstance()->isChatActive(friendId);
} else {
currentWindow = window();
FriendWidget* widget = friendWidgets[friendId];
@ -1647,7 +1647,7 @@ bool Widget::newGroupMessageAlert(const GroupId& groupId, const ToxPk& authorPk,
if (contentDialog != nullptr) {
currentWindow = contentDialog->window();
hasActive = ContentDialogManager::getInstance()->isContactActive(groupId);
hasActive = ContentDialogManager::getInstance()->isChatActive(groupId);
} else {
currentWindow = window();
hasActive = widget == activeChatroomWidget;
@ -1759,8 +1759,8 @@ void Widget::updateFriendActivity(const Friend& frnd)
const auto newTime = QDateTime::currentDateTime();
settings.setFriendActivity(pk, newTime);
FriendWidget* widget = friendWidgets[frnd.getPublicKey()];
contactListWidget->moveWidget(widget, frnd.getStatus());
contactListWidget->updateActivityTime(oldTime); // update old category widget
chatListWidget->moveWidget(widget, frnd.getStatus());
chatListWidget->updateActivityTime(oldTime); // update old category widget
}
void Widget::removeFriend(Friend* f, bool fake)
@ -1788,7 +1788,7 @@ void Widget::removeFriend(Friend* f, bool fake)
friendAlertConnections.remove(friendPk);
contactListWidget->removeFriendWidget(widget);
chatListWidget->removeFriendWidget(widget);
ContentDialog* lastDialog = ContentDialogManager::getInstance()->getFriendDialog(friendPk);
if (lastDialog != nullptr) {
@ -2057,7 +2057,7 @@ void Widget::onGroupTitleChanged(uint32_t groupnumber, const QString& author, co
}
g->setTitle(author, title);
contactListWidget->itemsChanged();
chatListWidget->itemsChanged();
}
void Widget::titleChangedByUser(const QString& title)
@ -2101,7 +2101,7 @@ void Widget::removeGroup(Group* g, bool fake)
if (!fake) {
core->removeGroup(groupnumber);
}
contactListWidget->removeGroupWidget(widget); // deletes widget
chatListWidget->removeGroupWidget(widget); // deletes widget
groupWidgets.remove(groupId);
auto groupChatFormIt = groupChatForms.find(groupId);
@ -2191,9 +2191,9 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
groupChatrooms[groupId] = chatroom;
groupChatForms[groupId] = QSharedPointer<GroupChatForm>(form);
contactListWidget->addGroupWidget(widget);
chatListWidget->addGroupWidget(widget);
widget->updateStatusLight();
contactListWidget->activateWindow();
chatListWidget->activateWindow();
connect(widget, &GroupWidget::chatroomWidgetClicked, this, &Widget::onChatroomWidgetClicked);
connect(widget, &GroupWidget::newWindowOpened, this, &Widget::openNewDialog);
@ -2426,9 +2426,9 @@ void Widget::onSplitterMoved(int pos, int index)
saveSplitterGeometry();
}
void Widget::cycleContacts(bool forward)
void Widget::cycleChats(bool forward)
{
contactListWidget->cycleContacts(activeChatroomWidget, forward);
chatListWidget->cycleChats(activeChatroomWidget, forward);
}
bool Widget::filterGroups(FilterCriteria index)
@ -2491,14 +2491,14 @@ void Widget::reloadTheme()
profilePicture->setStyleSheet(Style::getStylesheet("window/profile.css", settings));
}
void Widget::nextContact()
void Widget::nextChat()
{
cycleContacts(true);
cycleChats(true);
}
void Widget::previousContact()
void Widget::previousChat()
{
cycleContacts(false);
cycleChats(false);
}
// Preparing needed to set correct size of icons for GTK tray backend
@ -2531,12 +2531,12 @@ inline QIcon Widget::prepareIcon(QString path, int w, int h)
return QIcon(path);
}
void Widget::searchContacts()
void Widget::searchChats()
{
QString searchString = ui->searchContactText->text();
FilterCriteria filter = getFilterCriteria();
contactListWidget->searchChatrooms(searchString, filterOnline(filter), filterOffline(filter),
chatListWidget->searchChatrooms(searchString, filterOnline(filter), filterOffline(filter),
filterGroups(filter));
updateFilterText();
@ -2547,12 +2547,12 @@ void Widget::changeDisplayMode()
filterDisplayGroup->setEnabled(false);
if (filterDisplayGroup->checkedAction() == filterDisplayActivity) {
contactListWidget->setMode(FriendListWidget::SortingMode::Activity);
chatListWidget->setMode(FriendListWidget::SortingMode::Activity);
} else if (filterDisplayGroup->checkedAction() == filterDisplayName) {
contactListWidget->setMode(FriendListWidget::SortingMode::Name);
chatListWidget->setMode(FriendListWidget::SortingMode::Name);
}
searchContacts();
searchChats();
filterDisplayGroup->setEnabled(true);
updateFilterText();
@ -2584,7 +2584,7 @@ Widget::FilterCriteria Widget::getFilterCriteria() const
void Widget::searchCircle(CircleWidget& circleWidget)
{
if (contactListWidget->getMode() == FriendListWidget::SortingMode::Name) {
if (chatListWidget->getMode() == FriendListWidget::SortingMode::Name) {
FilterCriteria filter = getFilterCriteria();
QString text = ui->searchContactText->text();
circleWidget.search(text, true, filterOnline(filter), filterOffline(filter));
@ -2605,7 +2605,7 @@ void Widget::friendListContextMenu(const QPoint& pos)
QAction* chosenAction = menu.exec(ui->friendList->mapToGlobal(pos));
if (chosenAction == addCircleAction) {
contactListWidget->addCircleWidget();
chatListWidget->addCircleWidget();
} else if (chosenAction == createGroupAction) {
core->createGroup();
}

View File

@ -192,8 +192,8 @@ public slots:
void onGroupPeerAudioPlaying(int groupnumber, ToxPk peerPk);
void onGroupSendFailed(uint32_t groupnumber);
void onFriendTypingChanged(uint32_t friendnumber, bool isTyping);
void nextContact();
void previousContact();
void nextChat();
void previousChat();
void onFriendDialogShown(const Friend* f);
void onGroupDialogShown(Group* g);
void toggleFullscreen();
@ -268,8 +268,8 @@ private:
void removeGroup(Group* g, bool fake = false);
void saveWindowGeometry();
void saveSplitterGeometry();
void cycleContacts(bool forward);
void searchContacts();
void cycleChats(bool forward);
void searchChats();
void changeDisplayMode();
void updateFilterText();
FilterCriteria getFilterCriteria() const;
@ -322,7 +322,7 @@ private:
FilesForm* filesForm;
static Widget* instance;
GenericChatroomWidget* activeChatroomWidget;
FriendListWidget* contactListWidget;
FriendListWidget* chatListWidget;
MaskablePixmapWidget* profilePicture;
bool notify(QObject* receiver, QEvent* event);
bool autoAwayActive = false;

View File

@ -17,7 +17,7 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#include "src/core/contactid.h"
#include "src/core/chatid.h"
#include "src/core/toxpk.h"
#include "src/core/toxid.h"
#include "src/core/groupid.h"
@ -38,7 +38,7 @@ const QString echoStr =
QStringLiteral("76518406F6A9F2217E8DC487CC783C25CC16A15EB36FF32E335A235342C48A39");
const QByteArray echoPk = QByteArray::fromHex(echoStr.toLatin1());
class TestContactId : public QObject
class TestChatId : public QObject
{
Q_OBJECT
private slots:
@ -51,13 +51,13 @@ private slots:
void hashableTest();
};
void TestContactId::toStringTest()
void TestChatId::toStringTest()
{
ToxPk pk(testPk);
QVERIFY(testStr == pk.toString());
}
void TestContactId::equalTest()
void TestChatId::equalTest()
{
ToxPk pk1(testPk);
ToxPk pk2(testPk);
@ -67,7 +67,7 @@ void TestContactId::equalTest()
QVERIFY(!(pk1 != pk2));
}
void TestContactId::clearTest()
void TestChatId::clearTest()
{
ToxPk empty;
ToxPk pk(testPk);
@ -75,14 +75,14 @@ void TestContactId::clearTest()
QVERIFY(!pk.isEmpty());
}
void TestContactId::copyTest()
void TestChatId::copyTest()
{
ToxPk src(testPk);
ToxPk copy = src;
QVERIFY(copy == src);
}
void TestContactId::dataTest()
void TestChatId::dataTest()
{
ToxPk pk(testPk);
QVERIFY(testPk == pk.getByteArray());
@ -91,7 +91,7 @@ void TestContactId::dataTest()
}
}
void TestContactId::sizeTest()
void TestChatId::sizeTest()
{
ToxPk pk;
GroupId id;
@ -99,7 +99,7 @@ void TestContactId::sizeTest()
QVERIFY(id.getSize() == GroupId::size);
}
void TestContactId::hashableTest()
void TestChatId::hashableTest()
{
ToxPk pk1{testPkArray};
ToxPk pk2{testPk};
@ -108,5 +108,5 @@ void TestContactId::hashableTest()
QVERIFY(qHash(pk1) != qHash(pk3));
}
QTEST_GUILESS_MAIN(TestContactId)
#include "contactid_test.moc"
QTEST_GUILESS_MAIN(TestChatId)
#include "chatid_test.moc"