diff options
author | Chris Porter <slug@qwebirc.org> | 2011-04-12 21:24:24 (GMT) |
---|---|---|
committer | Chris Porter <slug@qwebirc.org> | 2011-04-12 21:24:24 (GMT) |
commit | b035330dc6b9eb11df0dac69616a734fee674368 (patch) | |
tree | b306bcb3d104b0ca7f803930beeb825bdf5001a4 | |
parent | 5c420a8146e1f9f3149cc5eb17c8b04ac232e795 (diff) |
Add query renaming (patch from soczol).
-rw-r--r-- | js/irc/ircclient.js | 20 | ||||
-rw-r--r-- | js/ui/baseui.js | 23 | ||||
-rw-r--r-- | js/ui/baseuiwindow.js | 2 | ||||
-rw-r--r-- | js/ui/frontends/qui.js | 3 |
4 files changed, 46 insertions, 2 deletions
diff --git a/js/irc/ircclient.js b/js/irc/ircclient.js index b8d5967..75bd259 100644 --- a/js/irc/ircclient.js +++ b/js/irc/ircclient.js @@ -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}); diff --git a/js/ui/baseui.js b/js/ui/baseui.js index deb3a04..a167167 100644 --- a/js/ui/baseui.js +++ b/js/ui/baseui.js @@ -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(); diff --git a/js/ui/baseuiwindow.js b/js/ui/baseuiwindow.js index feda6dd..1802c03 100644 --- a/js/ui/baseuiwindow.js +++ b/js/ui/baseuiwindow.js @@ -258,5 +258,7 @@ qwebirc.ui.Window = new Class({ } this.lastPositionLineInserted = this.parentObject.uiOptions.LASTPOS_LINE; + }, + rename: function(name) { } }); diff --git a/js/ui/frontends/qui.js b/js/ui/frontends/qui.js index d6ae4d5..2ff8d3e 100644 --- a/js/ui/frontends/qui.js +++ b/js/ui/frontends/qui.js @@ -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); |