current highlighted search result is no longer reset when the search string changes...
[quassel.git] / src / common / network.cpp
index c813ebb..ed66ee3 100644 (file)
@@ -36,6 +36,7 @@ Network::Network(const NetworkId &networkid, QObject *parent)
     _networkId(networkid),
     _identity(0),
     _myNick(QString()),
+    _latency(0),
     _networkName(QString("<not initialized>")),
     _currentServer(QString()),
     _connected(false),
@@ -50,7 +51,8 @@ Network::Network(const NetworkId &networkid, QObject *parent)
     _unlimitedReconnectRetries(false),
     _codecForServer(0),
     _codecForEncoding(0),
-    _codecForDecoding(0)
+    _codecForDecoding(0),
+    _autoAwayActive(false)
 {
   setObjectName(QString::number(networkid.toInt()));
 }
@@ -254,7 +256,7 @@ IrcUser *Network::ircUser(QString nickname) const {
 
 IrcChannel *Network::newIrcChannel(const QString &channelname) {
   if(!_ircChannels.contains(channelname.toLower())) {
-    IrcChannel *channel = new IrcChannel(channelname, this);
+    IrcChannel *channel = ircChannelFactory(channelname);
 
     if(proxy())
       proxy()->synchronize(channel);
@@ -429,6 +431,13 @@ void Network::setMyNick(const QString &nickname) {
   emit myNickSet(nickname);
 }
 
+void Network::setLatency(int latency) {
+  if(_latency == latency)
+    return;
+  _latency = latency;
+  emit latencySet(latency);
+}
+
 void Network::setIdentity(IdentityId id) {
   _identity = id;
   emit identitySet(id);
@@ -529,7 +538,7 @@ QVariantMap Network::initIrcUsersAndChannels() const {
   QHash<QString, IrcChannel *>::const_iterator channelIter = _ircChannels.constBegin();
   QHash<QString, IrcChannel *>::const_iterator channelIterEnd = _ircChannels.constEnd();
   while(channelIter != channelIterEnd) {
-    channels[channelIter.key()] = channelIter.value()->toVariantMap();
+    channels[channelIter.value()->name()] = channelIter.value()->toVariantMap();
     channelIter++;
   }
   usersAndChannels["channels"] = channels;
@@ -539,7 +548,7 @@ QVariantMap Network::initIrcUsersAndChannels() const {
 
 void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
   Q_ASSERT(proxy());
-  if(!_ircUsers.isEmpty() || !_ircChannels.isEmpty()) {
+  if(isInitialized()) {
     qWarning() << "Network" << networkId() << "received init data for users and channels allthough there allready are known users or channels!";
     return;
   }
@@ -578,7 +587,7 @@ void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
 
   while(channelIter != channelIterEnd) {
     channelName = channelIter.key();
-    ircChannel = new IrcChannel(channelName, this);
+    ircChannel = ircChannelFactory(channelName);
     ircChannel->fromVariantMap(channelIter.value().toMap());
     ircChannel->setInitialized();
     proxy()->synchronize(ircChannel);
@@ -676,16 +685,16 @@ void Network::emitConnectionError(const QString &errorMsg) {
 // ====================
 void Network::determinePrefixes() {
   // seems like we have to construct them first
-  QString PREFIX = support("PREFIX");
+  QString prefix = support("PREFIX");
   
-  if(PREFIX.startsWith("(") && PREFIX.contains(")")) {
-    _prefixes = PREFIX.section(")", 1);
-    _prefixModes = PREFIX.mid(1).section(")", 0, 0);
+  if(prefix.startsWith("(") && prefix.contains(")")) {
+    _prefixes = prefix.section(")", 1);
+    _prefixModes = prefix.mid(1).section(")", 0, 0);
   } else {
     QString defaultPrefixes("~&@%+");
     QString defaultPrefixModes("qaohv");
 
-    if(PREFIX.isEmpty()) {
+    if(prefix.isEmpty()) {
       _prefixes = defaultPrefixes;
       _prefixModes = defaultPrefixModes;
       return;
@@ -693,7 +702,7 @@ void Network::determinePrefixes() {
 
     // we just assume that in PREFIX are only prefix chars stored
     for(int i = 0; i < defaultPrefixes.size(); i++) {
-      if(PREFIX.contains(defaultPrefixes[i])) {
+      if(prefix.contains(defaultPrefixes[i])) {
        _prefixes += defaultPrefixes[i];
        _prefixModes += defaultPrefixModes[i];
       }
@@ -705,7 +714,7 @@ void Network::determinePrefixes() {
     // well... our assumption was obviously wrong...
     // check if it's only prefix modes
     for(int i = 0; i < defaultPrefixes.size(); i++) {
-      if(PREFIX.contains(defaultPrefixModes[i])) {
+      if(prefix.contains(defaultPrefixModes[i])) {
        _prefixes += defaultPrefixes[i];
        _prefixModes += defaultPrefixModes[i];
       }