Permalink
Browse files

Add code for inserting info into peer table (without updating).

  • Loading branch information...
arcusfelis committed Mar 14, 2013
1 parent 218e8a9 commit 2776a965ba7cd233da656460f16216341a168e62
@@ -80,6 +80,12 @@ qx.Class.define("cascadae.BasicTable",
__columnNums : null,
__columnNames : null,
__columnCaptions : null,
+ __active : false,
+ // Is this widget newer activated?
+ __virgin : true,
+ // If true, than the data must be reloaded, when the table will be active
+ // again.
+ __dirty : false,
_onKeyPress : function(e)
{
@@ -378,7 +384,7 @@ qx.Class.define("cascadae.BasicTable",
this.__filteredView = tm.addView(this._mainTableFilter, this);
var msm = main.getSelectionModel();
- msm.addListener("changeSelection", this.updateFilters, this);
+ msm.addListener("changeSelection", this._changeMainTableSelection, this);
},
_mainTableFilter : function(row)
@@ -388,17 +394,43 @@ qx.Class.define("cascadae.BasicTable",
return (this._oldSelection.indexOf(tid) != -1);
},
+ setActive : function(bActive) {
+ if (bActive == this.__active)
+ return;
+
+ // is visable
+ this.__active = bActive;
+ if (bActive && this.__dirty)
+ this.updateFilters();
+ this.__dirty = false;
+ this.fireEvent(this.__active ? "activated" : "deactivated");
+
+ this.info("Activate peer table " + this.__active);
+ if (this.__virgin)
+ {
+ this.fireDataEvent("d_updateFilters",
+ {"torrent_ids": this._oldSelection});
+ this.__virgin = false;
+ }
+ },
+
+ _changeMainTableSelection: function(e) {
+ if (this.__active) this.updateFilters();
+ else this.__dirty = true;
+ },
+
/**
* TODOC
*
*/
- updateFilters : function(e)
+ updateFilters : function()
{
this.info("change selection");
var tm = this.__tableModel;
var newSel = this.__mainTable.getSelectedIds();
if (qx.lang.Array.equals(this._oldSelection, newSel)) return;
+ this.fireDataEvent("d_updateFilters", {"torrent_ids": newSel});
this._oldSelection = qx.lang.Array.clone(newSel);
@@ -417,8 +449,18 @@ qx.Class.define("cascadae.BasicTable",
events :
{
+ /**
+ * The data is a map containing this properties:
+ * <ul>
+ * <li>torrent_ids - New visible torrent ids</li>
+ * </ul>
+ */
+ "d_updateFilters" : "qx.event.type.Data",
+ "activated" : "qx.event.type.Event",
+ "deactivated" : "qx.event.type.Event",
+
// Data in the table model was changed
- "tableRefreshed" : "qx.event.type.Event",
+ "tableRefreshed" : "qx.event.type.Event",
// Remote events
"rd_dataAdded" : "qx.event.type.Data",
@@ -73,6 +73,7 @@ qx.Class.define("cascadae.Container",
this.__pageVisibility.addListener("change",
this.__checkPageVisibility,
this);
+ this.addListener("r_checkVisibility", this.__checkPageVisibility, this);
socket.registerObject(this);
},
@@ -400,6 +401,7 @@ qx.Class.define("cascadae.Container",
{
var isFileViewEnabled = false;
var isWishViewEnabled = false;
+ var isPeerViewEnabled = false;
this.info("Select view " + show);
switch(show)
@@ -423,6 +425,7 @@ qx.Class.define("cascadae.Container",
this.__stack.setSelection([ this.__peersView ]);
this.__stack.show();
this.__peersView.focus();
+ isPeerViewEnabled = true;
break;
case "log":
@@ -437,8 +440,11 @@ qx.Class.define("cascadae.Container",
this.__table.focus();
}
+ this.__filesTree.setActive(isFileViewEnabled);
this.__filesTree.setActive(isFileViewEnabled);
this.__wishesList.setActive(isWishViewEnabled);
+ this.__peersTable.setActive(isPeerViewEnabled);
+ this.__logTable.setActive(true);
},
@@ -262,6 +262,9 @@ qx.Class.define("cascadae.files.Tree",
setActive : function(bActive) {
+ if (bActive == this.__active)
+ return;
+
// is visable
this.__active = bActive;
if (bActive && this.__dirty)
@@ -21,7 +21,9 @@ qx.Class.define("cascadae.peers.Table",
"state" : this.tr("State"),
"choke_state" : this.tr("Choking"),
"interest_state" : this.tr("Intersted"),
- "local_choke" : this.tr("Is choking?")
+ "local_choke" : this.tr("Is choking?"),
+ "recv_rate" : this.tr("Rate In"),
+ "send_rate" : this.tr("Rate Out")
};
this.base(arguments, n2c);
@@ -39,6 +41,11 @@ qx.Class.define("cascadae.peers.Table",
rb.set(n2p.interest_state, { width:"1*", minWidth: 60 });
rb.set(n2p.choke_state, { width:"1*", minWidth: 60 });
rb.set(n2p.local_choke, { width:"1*", minWidth: 40 });
+ rb.set(n2p.recv_rate, { width:"1*", minWidth: 70 });
+ rb.set(n2p.send_rate, { width:"1*", minWidth: 70 });
+
+ tcm.setDataCellRenderer(n2p.recv_rate, new cascadae.cellrenderer.Speed());
+ tcm.setDataCellRenderer(n2p.send_rate, new cascadae.cellrenderer.Speed());
tcm.setDataCellRenderer(n2p.local_choke,
new qx.ui.table.cellrenderer.Boolean());
@@ -207,6 +207,9 @@ qx.Class.define("cascadae.wishlist.List",
setActive : function(bActive)
{
+ if (bActive == this.__active)
+ return;
+
// is visable
this.__active = bActive;
if (bActive)
Oops, something went wrong.

0 comments on commit 2776a96

Please sign in to comment.