]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add query renaming (patch from soczol).
authorChris Porter <redacted>
Tue, 12 Apr 2011 21:24:24 +0000 (22:24 +0100)
committerChris Porter <redacted>
Tue, 12 Apr 2011 21:24:24 +0000 (22:24 +0100)
js/irc/ircclient.js
js/ui/baseui.js
js/ui/baseuiwindow.js
js/ui/frontends/qui.js

index b8d59676d830e6e41ecc087174b6c8dd02bc6d15..75bd25976f7cc2d3132911a585f275bbccb04172 100644 (file)
@@ -102,6 +102,17 @@ qwebirc.irc.IRCClient = new Class({
   getWindow: function(name) {
     return this.windows[this.toIRCLower(name)];
   },
+  renameWindow: function(oldname, newname) {
+    var oldwindow = this.getWindow(oldname);
+    if(!oldwindow || this.getWindow(newname))
+      return;
+
+    var window = this.ui.renameWindow(oldwindow, newname);
+    if(window) {
+      this.windows[this.toIRCLower(newname)] = window;
+      delete this.windows[this.toIRCLower(oldname)];
+    }
+  },
   newWindow: function(name, type, select) {
     var w = this.getWindow(name);
     if(!w) {
@@ -339,10 +350,15 @@ qwebirc.irc.IRCClient = new Class({
       var found = true;
       
       this.newChanLine(c, "NICK", user, {"w": newnick});
-      /* TODO: rename queries */
       this.updateNickList(c);
     }
-
+    
+    if(this.getQueryWindow(oldnick)) {
+      var found = true;
+      this.renameWindow(oldnick, newnick);
+      this.newLine(newnick, "NICK", {"n": oldnick, "w": newnick});
+    }
+    
     /* this is quite horrible */
     if(!found)
       this.newServerLine("NICK", {"w": newnick, n: user.hostToNick(), h: user.hostToHost(), "-": this.nickname});
index deb3a04a4039ee1606856a393bd5a57acc07592a..a16716758716d4ea06469d8e30a2fe48360f0676 100644 (file)
@@ -114,6 +114,29 @@ qwebirc.ui.BaseUI = new Class({
   __setActiveWindow: function(window) {
     this.active = window;
   },
+  renameWindow: function(window, name) {
+    if(this.getWindow(window.client, window.type, name))
+      return null;
+    
+    var clientId = this.getClientId(window.client);
+    var index = this.windowArray.indexOf(window);
+    if(index == -1)
+      return null;
+    
+    delete this.windows[clientId][window.identifier];
+    
+    var window = this.windowArray[index];
+    window.name = name;
+    window.identifier = this.getWindowIdentifier(window.client, window.type, window.name);
+    
+    this.windows[clientId][window.identifier] = this.windowArray[index];
+    
+    if(window.active)
+      this.updateTitle(window.name + " - " + this.options.appTitle);
+    
+    window.rename(window.name);
+    return window;
+  },
   selectWindow: function(window) {
     if(this.active)
       this.active.deselect();
index feda6dd807a19e875278a17d4991a6e60a1a99e4..1802c03328c8b2defe6b7837828735b884f0c1bd 100644 (file)
@@ -258,5 +258,7 @@ qwebirc.ui.Window = new Class({
     }
     
     this.lastPositionLineInserted = this.parentObject.uiOptions.LASTPOS_LINE;
+  },
+  rename: function(name) {
   }
 });
index d6ae4d5bc65f1eafe05d15ec9bf6a5cb02ebe471..2ff8d3e3742d955b4a976c6968ecf6ed6b5a862e 100644 (file)
@@ -434,6 +434,9 @@ qwebirc.ui.QUI.Window = new Class({
     this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
     this.reflow();    
   },
+  rename: function(name) {
+    this.tab.replaceChild(document.createTextNode(name), this.tab.firstChild);
+  },
   editTopic: function() {
     if(!this.client.nickOnChanHasPrefix(this.client.nickname, this.name, "@")) {
 /*      var cmodes = this.client.getChannelModes(channel);