23 #include "ircuserinfo.h" 25 #include "irc/entities/ircuserprefix.h" 26 #include "irc/ircglobal.h" 27 #include "irc/ircnetworkadapter.h" 32 this->parentNetwork =
nullptr;
39 this->parentNetwork = parentNetwork;
41 if (nickname.isEmpty() || parentNetwork ==
nullptr)
44 this->userName = parentNetwork->
userPrefixes().cleanNickname(nickname);
45 this->userModes << parentNetwork->
userPrefixes().modeFromNickname(nickname);
50 return prefixes().cleanNickname(userName);
58 QString IRCUserInfo::extractHostnameFromFullSignature()
const 64 hostName.remove(0, indexOfDelimiterChar + 1);
72 bool IRCUserInfo::isOp()
const 74 return modes().contains(
'o');
79 return (*
this) == otherUser;
88 bool IRCUserInfo::isValid()
const 90 return !userName.isEmpty() && parentNetwork !=
nullptr;
93 const QList<char> &IRCUserInfo::modes()
const 100 return parentNetwork;
103 void IRCUserInfo::setPrefixedNickname(
const QString &nickname)
105 this->userName = prefixes().cleanNickname(nickname);
106 if (prefixes().modeFromNickname(nickname) != 0)
107 setMode(prefixes().modeFromNickname(nickname));
110 bool IRCUserInfo::operator==(
const IRCUserInfo &otherUser)
const 115 return thisNickname.compare(otherNickname) == 0;
120 assert(parentNetwork !=
nullptr);
122 char mode2 = prefixes().
topMostMode(otherUser.modes());
123 if (prefixes().compare(mode1, mode2) != 0)
124 return prefixes().compare(mode1, mode2) < 0;
129 bool bIsThisAlphabeticallySmaller = (thisNickname.compare(otherNickname) <= 0);
130 return bIsThisAlphabeticallySmaller;
135 assert(parentNetwork !=
nullptr);
139 return QString(
"%1%2").arg(prefixes().prefixForMode(mode))
156 void IRCUserInfo::setModes(
const QList<char> &modes)
158 this->userModes = modes;
161 void IRCUserInfo::setMode(
char mode)
163 if (!userModes.contains(mode))
167 void IRCUserInfo::unsetMode(
char mode)
169 userModes.removeAll(mode);
QString fullSignature
Full user signature with nickname and hostname.
Interprets communication between the client and the IRC server.
char topMostMode(const QList< char > &candidates) const
Out of list of possible modes picks mode with highest priority.
QString cleanNickname() const
Returns nickname with no prefixes, contrary to the prefixedName() .
QString prefixedName() const
Will generate prefix based on the user flags.
bool isSameNickname(const IRCUserInfo &otherUser) const
Check if this user and user specified as parameter are the same user.
QString cleanNicknameLowerCase() const
Returns cleanNickname() with a call to IRCGlobal::toIrcLower() .
static QString toIrcLower(const QString &str)
RFC 1459 compliant toLower() method.
Holds information flags about given nickname.
const IRCUserPrefix & userPrefixes() const
All allowed modes with their nickname prefixes for this network.
QString prefixedNameLowerCase() const
Returns prefixedName() with a call to IRCGlobal::toIrcLower() .
One-to-one association of visible prefixes to user mode.
IRCUserInfo()
Creates invalid IRCUserInfo.
bool operator<=(const IRCUserInfo &otherUser) const
This operator can be used for sorting.