Browse Source

Renamed function isMine to isActiveProfile.

As an user can have multiple profiles where each profile has its own
Tox ID the name isMine is not very accurate.
pull/1675/head
marcel 10 years ago
parent
commit
2ffabb19ec
  1. 2
      src/core/corestructs.cpp
  2. 2
      src/core/corestructs.h
  3. 2
      src/group.cpp
  4. 2
      src/widget/form/addfriendform.cpp
  5. 8
      src/widget/form/chatform.cpp
  6. 6
      src/widget/form/genericchatform.cpp
  7. 2
      src/widget/widget.cpp

2
src/core/corestructs.cpp

@ -66,7 +66,7 @@ bool ToxID::operator!=(const ToxID& other) const
return publicKey != other.publicKey; return publicKey != other.publicKey;
} }
bool ToxID::isMine() const bool ToxID::isActiveProfile() const
{ {
return *this == Core::getInstance()->getSelfId(); return *this == Core::getInstance()->getSelfId();
} }

2
src/core/corestructs.h

@ -30,7 +30,7 @@ struct ToxID
bool operator==(const ToxID& other) const; bool operator==(const ToxID& other) const;
bool operator!=(const ToxID& other) const; bool operator!=(const ToxID& other) const;
bool isMine() const; bool isActiveProfile() const;
void clear(); void clear();
}; };

2
src/group.cpp

@ -98,7 +98,7 @@ void Group::regeneratePeerList()
for (int i = 0; i < nPeers; i++) for (int i = 0; i < nPeers; i++)
{ {
ToxID id = Core::getInstance()->getGroupPeerToxID(groupId, i); ToxID id = Core::getInstance()->getGroupPeerToxID(groupId, i);
if (id.isMine()) if (id.isActiveProfile())
selfPeerNum = i; selfPeerNum = i;
QString toxid = id.publicKey; QString toxid = id.publicKey;

2
src/widget/form/addfriendform.cpp

@ -129,7 +129,7 @@ void AddFriendForm::setIdFromClipboard()
QString id = clipboard->text().trimmed(); QString id = clipboard->text().trimmed();
if (Core::getInstance()->isReady() && !id.isEmpty() && ToxID::isToxId(id)) if (Core::getInstance()->isReady() && !id.isEmpty() && ToxID::isToxId(id))
{ {
if (!ToxID::fromString(id).isMine()) if (!ToxID::fromString(id).isActiveProfile())
toxId.setText(id); toxId.setText(id);
} }
} }

8
src/widget/form/chatform.cpp

@ -179,7 +179,7 @@ void ChatForm::startFileSend(ToxFile file)
return; return;
QString name; QString name;
if (!previousId.isMine()) if (!previousId.isActiveProfile())
{ {
Core* core = Core::getInstance(); Core* core = Core::getInstance();
name = core->getUsername(); name = core->getUsername();
@ -814,13 +814,13 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
// Show each messages // Show each messages
ToxID authorId = ToxID::fromString(it.sender); ToxID authorId = ToxID::fromString(it.sender);
QString authorStr = authorId.isMine() ? Core::getInstance()->getUsername() : resolveToxID(authorId); QString authorStr = authorId.isActiveProfile() ? Core::getInstance()->getUsername() : resolveToxID(authorId);
bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive); bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive);
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr,
isAction ? it.message.right(it.message.length() - 4) : it.message, isAction ? it.message.right(it.message.length() - 4) : it.message,
isAction ? ChatMessage::ACTION : ChatMessage::NORMAL, isAction ? ChatMessage::ACTION : ChatMessage::NORMAL,
authorId.isMine(), authorId.isActiveProfile(),
QDateTime()); QDateTime());
if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) ) if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
@ -829,7 +829,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
prevId = authorId; prevId = authorId;
prevMsgDateTime = msgDateTime; prevMsgDateTime = msgDateTime;
if (it.isSent || !authorId.isMine()) if (it.isSent || !authorId.isActiveProfile())
{ {
msg->markAsSent(msgDateTime); msg->markAsSent(msgDateTime);
} }

6
src/widget/form/genericchatform.cpp

@ -248,7 +248,7 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString &message, bool isAction, ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString &message, bool isAction,
const QDateTime &datetime, bool isSent) const QDateTime &datetime, bool isSent)
{ {
QString authorStr = author.isMine() ? Core::getInstance()->getUsername() : resolveToxID(author); QString authorStr = author.isActiveProfile() ? Core::getInstance()->getUsername() : resolveToxID(author);
ChatMessage::Ptr msg; ChatMessage::Ptr msg;
if (isAction) if (isAction)
@ -258,7 +258,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString
} }
else else
{ {
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, author.isMine()); msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, author.isActiveProfile());
if ( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) ) if ( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) )
msg->hideSender(); msg->hideSender();
@ -282,7 +282,7 @@ ChatMessage::Ptr GenericChatForm::addSelfMessage(const QString &message, bool is
void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDateTime datetime) void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDateTime datetime)
{ {
QString authorStr = resolveToxID(author); QString authorStr = resolveToxID(author);
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ALERT, author.isMine(), datetime); ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ALERT, author.isActiveProfile(), datetime);
insertChatMessage(msg); insertChatMessage(msg);
if ((author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter)) if ((author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter))

2
src/widget/widget.cpp

@ -951,7 +951,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QStri
return; return;
ToxID author = Core::getInstance()->getGroupPeerToxID(groupnumber, peernumber); ToxID author = Core::getInstance()->getGroupPeerToxID(groupnumber, peernumber);
bool targeted = !author.isMine() && (message.contains(nameMention) || message.contains(sanitizedNameMention)); bool targeted = !author.isActiveProfile() && (message.contains(nameMention) || message.contains(sanitizedNameMention));
if (targeted && !isAction) if (targeted && !isAction)
g->getChatForm()->addAlertMessage(author, message, QDateTime::currentDateTime()); g->getChatForm()->addAlertMessage(author, message, QDateTime::currentDateTime());
else else

Loading…
Cancel
Save