Browse Source

refactor: another small changes

Brief list of changes:
  - "resolveToxId" method's name replaced with "resolveToxPk";
  - updated comments for "resolveToxPk" and "needsToHideName";
  - changed "resolveToxPk" return value for fail case;
  - fixed typo.
reviewable/pr4343/r6
noavarice 8 years ago
parent
commit
4b3d86d172
  1. 2
      src/widget/form/chatform.cpp
  2. 15
      src/widget/form/genericchatform.cpp
  3. 2
      src/widget/form/genericchatform.h

2
src/widget/form/chatform.cpp

@ -723,7 +723,7 @@ void ChatForm::loadHistory(const QDateTime& since, bool processUndelivered) @@ -723,7 +723,7 @@ void ChatForm::loadHistory(const QDateTime& since, bool processUndelivered)
} else if (isSelf) {
authorStr = core->getUsername();
} else {
authorStr = resolveToxId(authorPk);
authorStr = resolveToxPk(authorPk);
}
bool isAction = it.message.startsWith(ACTION_PREFIX, Qt::CaseInsensitive);

15
src/widget/form/genericchatform.cpp

@ -89,9 +89,10 @@ static QString fontToCss(const QFont& font, const QString& name) @@ -89,9 +89,10 @@ static QString fontToCss(const QFont& font, const QString& name)
* @brief Searches for name (possibly alias) of someone with specified public key among all of your
* friends or groups you are participated
* @param pk Searched public key
* @return Name or alias of someone with such public key
* @return Name or alias of someone with such public key, or public key string representation if no
* one was found
*/
QString GenericChatForm::resolveToxId(const ToxPk& pk)
QString GenericChatForm::resolveToxPk(const ToxPk& pk)
{
Friend* f = FriendList::findFriend(pk);
if (f) {
@ -105,7 +106,7 @@ QString GenericChatForm::resolveToxId(const ToxPk& pk) @@ -105,7 +106,7 @@ QString GenericChatForm::resolveToxId(const ToxPk& pk)
}
}
return QString{};
return pk.toString();
}
GenericChatForm::GenericChatForm(QWidget* parent)
@ -375,9 +376,9 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos) @@ -375,9 +376,9 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
}
/**
* @brief Show, is it needed to repeat message author name or not
* @brief Show, is it needed to hide message author name or not
* @param messageAuthor Author of the sent message
* @return True if it's needed to repeat name, false otherwise
* @return True if it's needed to hide name, false otherwise
*/
bool GenericChatForm::needsToHideName(const ToxPk &messageAuthor) const
{
@ -399,7 +400,7 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri @@ -399,7 +400,7 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
{
const Core* core = Core::getInstance();
bool isSelf = author == core->getSelfId().getPublicKey();
QString authorStr = isSelf ? core->getUsername() : resolveToxId(author);
QString authorStr = isSelf ? core->getUsername() : resolveToxPk(author);
if (getLatestDate() != QDate::currentDate()) {
const Settings& s = Settings::getInstance();
QString dateText = QDate::currentDate().toString(s.getDateFormat());
@ -457,7 +458,7 @@ void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& da @@ -457,7 +458,7 @@ void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& da
void GenericChatForm::addAlertMessage(const ToxPk& author, const QString& msg, const QDateTime& dt)
{
QString authorStr = resolveToxId(author);
QString authorStr = resolveToxPk(author);
bool isSelf = author == Core::getInstance()->getSelfId().getPublicKey();
auto chatMsg = ChatMessage::createChatMessage(authorStr, msg, ChatMessage::ALERT, isSelf, dt);
if (needsToHideName(author)) {

2
src/widget/form/genericchatform.h

@ -70,7 +70,7 @@ public: @@ -70,7 +70,7 @@ public:
void addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
const QDateTime& datetime);
void addAlertMessage(const ToxPk& author, const QString& message, const QDateTime& datetime);
static QString resolveToxId(const ToxPk& id);
static QString resolveToxPk(const ToxPk& pk);
QDate getLatestDate() const;
signals:

Loading…
Cancel
Save