#include "ircuser.h"
#include "util.h"
-#include "network.h"
#include "signalproxy.h"
#include "ircchannel.h"
#include <QTextCodec>
#include <QDebug>
-IrcUser::IrcUser(const QString &hostmask, Network *network) : SyncableObject(network),
+IrcUser::IrcUser(const QString &hostmask, Network *network)
+ : SyncableObject(network),
_initialized(false),
- _nick(nickFromMask(hostmask)),
- _user(userFromMask(hostmask)),
- _host(hostFromMask(hostmask)),
+ _nick(network->encodeServerString(nickFromMask(hostmask))),
+ _user(network->encodeServerString(userFromMask(hostmask))),
+ _host(network->encodeServerString(hostFromMask(hostmask))),
_realName(),
_awayMessage(),
_away(false),
// PUBLIC SLOTS:
// ====================
void IrcUser::setUser(const QString &user) {
- if(!user.isEmpty() && _user != user) {
- _user = user;
- emit userSet(user);
+ if(!user.isEmpty()) {
+ QByteArray newUser = network()->encodeServerString(user);
+ if(newUser != _user) {
+ _user = newUser;
+ emit userSet(user);
+ }
}
}
void IrcUser::setRealName(const QString &realName) {
- if (!realName.isEmpty() && _realName != realName) {
- _realName = realName;
- emit realNameSet(realName);
+ if(!realName.isEmpty()) {
+ QByteArray newRealName = network()->encodeServerString(realName);
+ if(newRealName != _realName) {
+ _realName = newRealName;
+ emit realNameSet(realName);
+ }
}
}
}
void IrcUser::setAwayMessage(const QString &awayMessage) {
- if(!awayMessage.isEmpty() && _awayMessage != awayMessage) {
- _awayMessage = awayMessage;
- emit awayMessageSet(awayMessage);
+ if(!awayMessage.isEmpty()) {
+ QByteArray newAwayMessage = network()->encodeServerString(awayMessage);
+ if(newAwayMessage != _awayMessage) {
+ _awayMessage = newAwayMessage;
+ emit awayMessageSet(awayMessage);
+ }
}
}
}
void IrcUser::setHost(const QString &host) {
- if(!host.isEmpty() && _host != host) {
- _host = host;
- emit hostSet(host);
+ if(!host.isEmpty()) {
+ QByteArray newHost = network()->encodeServerString(host);
+ if(newHost != _host) {
+ _host = newHost;
+ emit hostSet(host);
+ }
}
}
void IrcUser::setNick(const QString &nick) {
- if(!nick.isEmpty() && nick != _nick) {
- _nick = nick;
- updateObjectName();
- emit nickSet(nick);
+ if(!nick.isEmpty()) {
+ QByteArray newNick = network()->encodeServerString(nick);
+ if(newNick != _nick) {
+ _nick = newNick;
+ updateObjectName();
+ emit nickSet(nick);
+ }
}
}
}
void IrcUser::updateObjectName() {
- renameObject(QString::number(network()->networkId().toInt()) + "/" + _nick);
+ renameObject(QString::number(network()->networkId().toInt()) + "/" + nick());
}
void IrcUser::updateHostmask(const QString &mask) {
#include <QDateTime>
#include "syncableobject.h"
+#include "network.h"
class SignalProxy;
-class Network;
class IrcChannel;
class IrcUser : public SyncableObject {
IrcUser(const QString &hostmask, Network *network);
virtual ~IrcUser();
- inline QString user() const { return _user; }
- inline QString host() const { return _host; }
- inline QString nick() const { return _nick; }
- inline QString realName() const { return _realName; }
+ inline QString user() const { return network()->decodeServerString(_user); }
+ inline QString host() const { return network()->decodeServerString(_host); }
+ inline QString nick() const { return network()->decodeServerString(_nick); }
+ inline QString realName() const { return network()->decodeServerString(_realName); }
QString hostmask() const;
inline bool isAway() const { return _away; }
- inline QString awayMessage() const { return _awayMessage; }
+ inline QString awayMessage() const { return network()->decodeServerString(_awayMessage); }
QDateTime idleTime();
inline QDateTime loginTime() const { return _loginTime; }
inline QString server() const { return _server; }
bool _initialized;
- QString _nick;
- QString _user;
- QString _host;
- QString _realName;
- QString _awayMessage;
+ QByteArray _nick;
+ QByteArray _user;
+ QByteArray _host;
+ QByteArray _realName;
+ QByteArray _awayMessage;
bool _away;
QString _server;
QDateTime _idleTime;
#include <QDebug>
#include <QTextCodec>
+#include "ircuser.h"
#include "util.h"
QTextCodec *Network::_defaultCodecForServer = 0;
#include "syncableobject.h"
#include "signalproxy.h"
-#include "ircuser.h"
#include "ircchannel.h"
+class IrcUser;
+
// defined below!
struct NetworkInfo;
inline void setProxy(SignalProxy *proxy) { _proxy = proxy; }
inline bool isMyNick(const QString &nick) const { return (myNick().toLower() == nick.toLower()); }
- inline bool isMe(IrcUser *ircuser) const { return (ircuser->nick().toLower() == myNick().toLower()); }
+ inline bool isMe(IrcUser *ircuser) const { return (ircuser == me()); }
bool isChannelName(const QString &channelname) const;
int newOffset = event->pos().x() - dragStartX;
if(newOffset > 0)
offset = 0;
- else if(width() < textWidth || offset < newOffset)
+ else if(width() + 1 < textWidth || offset < newOffset)
offset = newOffset;
-// qDebug() << offset << (width() - textWidth) << width() << textWidth;
-// if(offset < width() - textWidth)
-// offset = width() - textWidth;
+
update();
}
void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) {
#ifndef SPUTDEV
event->accept();
- int textPart = 0;
- int textOffset = 0;
-
if(textPartOffset.isEmpty())
return;
// find the text part that contains the url. We don't expect color codes in urls so we expect only full parts (yet?)
- int x = event->pos().x();
+ int textPart = 0;
+ int x = event->pos().x() + offset;
while(textPart + 1 < textPartOffset.count()) {
- if(textPartOffset[textPart + 1] < x) {
+ if(textPartOffset[textPart + 1] < x)
textPart++;
- textOffset = textPartOffset[textPart];
- } else {
+ else
break;
- }
}
+ int textOffset = textPartOffset[textPart];
// we've Identified the needed text part \o/
QString text = styledContents.plainText.mid(styledContents.formatList[textPart].start, styledContents.formatList[textPart].length);
int start = 0;
int spacePos = text.indexOf(" ");
+ x -= offset; // offset needs to go here as it's already in the textOffset
while(spacePos != -1) {
if(fontMetric.width(text.left(spacePos + 1)) + textOffset < x) {
start = spacePos + 1;
len = end - start;
}
QString word = text.mid(start, len);
- qDebug() << word;
QRegExp regex("^(h|f)t{1,2}ps?:\\/\\/");
if(regex.indexIn(word) != -1) {
QDesktopServices::openUrl(QUrl(word));