projects
/
quassel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
115bbb2
)
urls are now properly identified if the topic is scrolled
author
Marcus Eggenberger
<egs@quassel-irc.org>
Thu, 3 Jul 2008 11:08:47 +0000
(13:08 +0200)
committer
Marcus Eggenberger
<egs@quassel-irc.org>
Thu, 3 Jul 2008 11:08:47 +0000
(13:08 +0200)
src/common/ircuser.cpp
patch
|
blob
|
history
src/common/ircuser.h
patch
|
blob
|
history
src/common/network.cpp
patch
|
blob
|
history
src/common/network.h
patch
|
blob
|
history
src/qtui/topiclabel.cpp
patch
|
blob
|
history
diff --git
a/src/common/ircuser.cpp
b/src/common/ircuser.cpp
index
22df0c9
..
af3cb3e
100644
(file)
--- a/
src/common/ircuser.cpp
+++ b/
src/common/ircuser.cpp
@@
-21,18
+21,18
@@
#include "ircuser.h"
#include "util.h"
#include "ircuser.h"
#include "util.h"
-#include "network.h"
#include "signalproxy.h"
#include "ircchannel.h"
#include <QTextCodec>
#include <QDebug>
#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),
_initialized(false),
- _nick(n
ickFromMask(hostmask
)),
- _user(
userFromMask(hostmask
)),
- _host(
hostFromMask(hostmask
)),
+ _nick(n
etwork->encodeServerString(nickFromMask(hostmask)
)),
+ _user(
network->encodeServerString(userFromMask(hostmask)
)),
+ _host(
network->encodeServerString(hostFromMask(hostmask)
)),
_realName(),
_awayMessage(),
_away(false),
_realName(),
_awayMessage(),
_away(false),
@@
-107,16
+107,22
@@
QByteArray IrcUser::encodeString(const QString &string) const {
// PUBLIC SLOTS:
// ====================
void IrcUser::setUser(const QString &user) {
// 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) {
}
}
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);
+ }
}
}
}
}
@@
-128,9
+134,12
@@
void IrcUser::setAway(const bool &away) {
}
void IrcUser::setAwayMessage(const QString &awayMessage) {
}
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);
+ }
}
}
}
}
@@
-171,17
+180,23
@@
void IrcUser::setLastAwayMessage(const int &lastAwayMessage) {
}
void IrcUser::setHost(const QString &host) {
}
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) {
}
}
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);
+ }
}
}
}
}
@@
-200,7
+215,7
@@
void IrcUser::setSuserHost(const QString &suserHost) {
}
void IrcUser::updateObjectName() {
}
void IrcUser::updateObjectName() {
- renameObject(QString::number(network()->networkId().toInt()) + "/" +
_nick
);
+ renameObject(QString::number(network()->networkId().toInt()) + "/" +
nick()
);
}
void IrcUser::updateHostmask(const QString &mask) {
}
void IrcUser::updateHostmask(const QString &mask) {
diff --git
a/src/common/ircuser.h
b/src/common/ircuser.h
index
00df169
..
f2f84ff
100644
(file)
--- a/
src/common/ircuser.h
+++ b/
src/common/ircuser.h
@@
-28,9
+28,9
@@
#include <QDateTime>
#include "syncableobject.h"
#include <QDateTime>
#include "syncableobject.h"
+#include "network.h"
class SignalProxy;
class SignalProxy;
-class Network;
class IrcChannel;
class IrcUser : public SyncableObject {
class IrcChannel;
class IrcUser : public SyncableObject {
@@
-57,13
+57,13
@@
public:
IrcUser(const QString &hostmask, Network *network);
virtual ~IrcUser();
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; }
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; }
QDateTime idleTime();
inline QDateTime loginTime() const { return _loginTime; }
inline QString server() const { return _server; }
@@
-153,11
+153,11
@@
private:
bool _initialized;
bool _initialized;
- Q
String
_nick;
- Q
String
_user;
- Q
String
_host;
- Q
String
_realName;
- Q
String
_awayMessage;
+ Q
ByteArray
_nick;
+ Q
ByteArray
_user;
+ Q
ByteArray
_host;
+ Q
ByteArray
_realName;
+ Q
ByteArray
_awayMessage;
bool _away;
QString _server;
QDateTime _idleTime;
bool _away;
QString _server;
QDateTime _idleTime;
diff --git
a/src/common/network.cpp
b/src/common/network.cpp
index
cfcda7d
..
38d5095
100644
(file)
--- a/
src/common/network.cpp
+++ b/
src/common/network.cpp
@@
-22,6
+22,7
@@
#include <QDebug>
#include <QTextCodec>
#include <QDebug>
#include <QTextCodec>
+#include "ircuser.h"
#include "util.h"
QTextCodec *Network::_defaultCodecForServer = 0;
#include "util.h"
QTextCodec *Network::_defaultCodecForServer = 0;
diff --git
a/src/common/network.h
b/src/common/network.h
index
3759e56
..
6631043
100644
(file)
--- a/
src/common/network.h
+++ b/
src/common/network.h
@@
-33,9
+33,10
@@
#include "syncableobject.h"
#include "signalproxy.h"
#include "syncableobject.h"
#include "signalproxy.h"
-#include "ircuser.h"
#include "ircchannel.h"
#include "ircchannel.h"
+class IrcUser;
+
// defined below!
struct NetworkInfo;
// defined below!
struct NetworkInfo;
@@
-97,7
+98,7
@@
public:
inline void setProxy(SignalProxy *proxy) { _proxy = proxy; }
inline bool isMyNick(const QString &nick) const { return (myNick().toLower() == nick.toLower()); }
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;
bool isChannelName(const QString &channelname) const;
diff --git
a/src/qtui/topiclabel.cpp
b/src/qtui/topiclabel.cpp
index
ec9fc4e
..
5949777
100644
(file)
--- a/
src/qtui/topiclabel.cpp
+++ b/
src/qtui/topiclabel.cpp
@@
-103,11
+103,9
@@
void TopicLabel::mouseMoveEvent(QMouseEvent *event) {
int newOffset = event->pos().x() - dragStartX;
if(newOffset > 0)
offset = 0;
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;
offset = newOffset;
-// qDebug() << offset << (width() - textWidth) << width() << textWidth;
-// if(offset < width() - textWidth)
-// offset = width() - textWidth;
+
update();
}
update();
}
@@
-131,22
+129,19
@@
void TopicLabel::mouseReleaseEvent(QMouseEvent *event) {
void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) {
#ifndef SPUTDEV
event->accept();
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?)
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()) {
while(textPart + 1 < textPartOffset.count()) {
- if(textPartOffset[textPart + 1] < x)
{
+ if(textPartOffset[textPart + 1] < x)
textPart++;
textPart++;
- textOffset = textPartOffset[textPart];
- } else {
+ else
break;
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);
// we've Identified the needed text part \o/
QString text = styledContents.plainText.mid(styledContents.formatList[textPart].start, styledContents.formatList[textPart].length);
@@
-156,6
+151,7
@@
void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) {
int start = 0;
int spacePos = text.indexOf(" ");
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;
while(spacePos != -1) {
if(fontMetric.width(text.left(spacePos + 1)) + textOffset < x) {
start = spacePos + 1;
@@
-171,7
+167,6
@@
void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) {
len = end - start;
}
QString word = text.mid(start, len);
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));
QRegExp regex("^(h|f)t{1,2}ps?:\\/\\/");
if(regex.indexIn(word) != -1) {
QDesktopServices::openUrl(QUrl(word));