Commits

Chris Porter committed 754f3d0 Draft

Add query renaming (patch from soczol).

Comments (0)

Files changed (4)

js/irc/ircclient.js

   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) {
       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});
   __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();

js/ui/baseuiwindow.js

     }
     
     this.lastPositionLineInserted = this.parentObject.uiOptions.LASTPOS_LINE;
+  },
+  rename: function(name) {
   }
 });

js/ui/frontends/qui.js

     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);