Skip to content

Commit

Permalink
Merge commit '825400f079d914940bc6b90b92327eed49717e11'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspackman committed Jun 25, 2024
2 parents a3a75be + 825400f commit 93b4a42
Show file tree
Hide file tree
Showing 13 changed files with 1,061 additions and 446 deletions.
426 changes: 426 additions & 0 deletions source/class/qxl/datagrid/ClippedScrollDataGrid.js

Large diffs are not rendered by default.

440 changes: 33 additions & 407 deletions source/class/qxl/datagrid/DataGrid.js

Large diffs are not rendered by default.

494 changes: 494 additions & 0 deletions source/class/qxl/datagrid/VirtualScrollDataGrid.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions source/class/qxl/datagrid/column/tree/ExpansionColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionColumn", {
* @Override
*/
bindWidget(widget, model, factory) {
// debugger;
let bindings = super.bindWidget(widget, model);
let state = factory.getDataSource().getNodeStateFor(model);
if (state == null) {
Expand All @@ -62,14 +61,15 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionColumn", {
widget.setIcon(iconPath);
}
}
widget.addListener("changeState", evt => {
let listenerId = widget.addListener("changeState", async evt => {
let state = evt.getData();
if (state == "open") {
factory.getDataSource().expandNode(model);
await factory.getDataSource().expandNode(model);
} else if (state == "closed") {
factory.getDataSource().collapseNode(model);
await factory.getDataSource().collapseNode(model);
}
});
bindings.add(widget, listenerId, "listener");
return bindings;
}
}
Expand Down
14 changes: 7 additions & 7 deletions source/class/qxl/datagrid/demo/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ qx.Class.define("qxl.datagrid.demo.Application", {
qx.log.appender.Native;
qx.log.appender.Console;
}
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.Position);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.Range);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.util.Labels);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.column.FilteredColumns);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.TreeDataSource);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.ui.GridSizeCalculator);
await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.ui.DataGrid);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.Position);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.Range);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.util.Labels);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.column.FilteredColumns);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.source.TreeDataSource);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.ui.GridSizeCalculator);
// await qxl.datagrid.test.TestRunner.runAll(qxl.datagrid.test.ui.DataGrid);

let doc = this.getRoot();
doc.add(new qxl.datagrid.demo.Demo(), { left: 0, top: 0, right: 0, bottom: 0 });
Expand Down
2 changes: 1 addition & 1 deletion source/class/qxl/datagrid/demo/array/ArrayDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ qx.Class.define("qxl.datagrid.demo.array.ArrayDemo", {
},

grid() {
return new qxl.datagrid.DataGrid(this.getQxObject("columns")).set({
return new qxl.datagrid.ClippedScrollDataGrid(this.getQxObject("columns")).set({
dataSource: this.getQxObject("dataSource")
});
},
Expand Down
4 changes: 2 additions & 2 deletions source/class/qxl/datagrid/demo/biggrid/BigGridDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ qx.Class.define("qxl.datagrid.demo.biggrid.BigGridDemo", {
objects: {
dataSource() {
// Create a massive data source with 1,000,000 rows and 10,000 columns
return new qxl.datagrid.demo.biggrid.DummyDataSource(1000000, 10000);
return new qxl.datagrid.demo.biggrid.DummyDataSource(1_000_000, 10_000);
},

grid() {
Expand All @@ -98,7 +98,7 @@ qx.Class.define("qxl.datagrid.demo.biggrid.BigGridDemo", {
columns.add(column);
}

var grid = new qxl.datagrid.DataGrid(columns).set({
var grid = new qxl.datagrid.ClippedScrollDataGrid(columns).set({
dataSource: dataSource
});

Expand Down
6 changes: 6 additions & 0 deletions source/class/qxl/datagrid/demo/biggrid/DummyDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ qx.Class.define("qxl.datagrid.demo.biggrid.DummyDataSource", {
return new qxl.datagrid.source.Position(value.getRowIndex(), value.getColumnIndex());
},

/**
* @Override
*/
isModelValid(value) {
return !!this.getPositionOfModel(value);
},
/**
* @override
*/
Expand Down
2 changes: 1 addition & 1 deletion source/class/qxl/datagrid/demo/tree/TreeDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ qx.Class.define("qxl.datagrid.demo.tree.TreeDemo", {
grid() {
var dataSource = this.getQxObject("dataSource");

var grid = new qxl.datagrid.DataGrid(this.getQxObject("columns")).set({
var grid = new qxl.datagrid.ClippedScrollDataGrid(this.getQxObject("columns")).set({
dataSource: dataSource
});
const sel = grid.getSelection();
Expand Down
13 changes: 0 additions & 13 deletions source/class/qxl/datagrid/source/tree/TreeDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,6 @@ qx.Class.define("qxl.datagrid.source.tree.TreeDataSource", {
}
},

/**
* @override
* Disposes of a row meta data obect
*
* @param {RowMetaData} rowMeta
*/
__disposeRowMetaData(rowMeta) {
if (rowMeta.childrenChangeBinding) {
rowMeta.childrenChangeBinding.dispose();
delete rowMeta.childrenChangeBinding;
}
},

/**
* Returns node metadata for the node object
*/
Expand Down
83 changes: 75 additions & 8 deletions source/class/qxl/datagrid/ui/GridSizeCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {

events: {
/** Fired when the sizes change */
change: "qx.data.event.Event"
change: "qx.event.type.Data"
},

members: {
Expand Down Expand Up @@ -112,6 +112,9 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
/** @type {Integer} the top scroll position */
_top: null,

/** @type {Boolean} whether overflow is enabled */
_overflow: null,

/**
* Gets the sizes for a given available size and scroll position of a Visible Space
*
Expand All @@ -138,15 +141,16 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
* @param {Integer} top
* @returns {Boolean} true if the widgets need to be redrawn because the previous data is invalid
*/
setAvailableSize(width, height, startRowIndex, startColumnIndex, left, top) {
if (width !== this._width || height !== this._height || startRowIndex != this._startRowIndex || startColumnIndex != this._startColumnIndex) {
setAvailableSize(width, height, startRowIndex, startColumnIndex, left, top, overflow = false) {
if (width !== this._width || height !== this._height || startRowIndex !== this._startRowIndex || startColumnIndex !== this._startColumnIndex || this._overflow !== overflow) {
this.invalidate();
this._width = width;
this._height = height;
this._startRowIndex = startRowIndex;
this._startColumnIndex = startColumnIndex;
this._left = left;
this._top = top;
this._overflow = overflow;
}
return !this.__sizes;
},
Expand All @@ -157,10 +161,71 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
getSizes() {
if (!this.__sizes && this._width && this._height) {
this.__sizes = this._calculateSizes();
this.fireDataEvent("change", this.__sizes);
}
return this.__sizes;
},

getPaneBounds() {
let styling = this.getStyling();
let sizes = this.getSizes();
let width = 0;
let height = 0;
if (sizes) {
let skipColumns = styling.getNumFixedColumns();
for (let column of sizes.columns.slice(skipColumns)) {
width += column.width;
}
width += styling.getHorizontalSpacing() * (sizes.columns.length - skipColumns - 1);

let skipRows = styling.getNumFixedRows();
for (let row of sizes.rows.slice(skipRows)) {
height += row.height;
}
height += styling.getVerticalSpacing() * (sizes.rows.length - skipRows - 1);
}
return { width, height };
},

getColHeaderBounds() {
let styling = this.getStyling();
let sizes = this.getSizes();
let width = 0;
let height = 0;
if (sizes) {
for (let column of sizes.columns) {
width += column.width;
}
width += styling.getHorizontalSpacing() * (sizes.columns.length - 1);

let rowCount = styling.getNumHeaderRows() + styling.getNumFixedRows();
for (let i = 0; i < rowCount; i++) {
height += sizes.rows[i].height;
}
height += styling.getVerticalSpacing() * (rowCount - 1);
}
return { width, height };
},

getRowHeaderBounds() {
let styling = this.getStyling();
let sizes = this.getSizes();
let width = 0;
let height = 0;
if (sizes) {
let colCount = styling.getNumFixedColumns();
for (let i = 0; i < colCount; i++) {
width += sizes.columns[i].width;
}
width += styling.getHorizontalSpacing() * (colCount - 1);
for (let row of sizes.rows) {
height += row.height;
}
height += styling.getVerticalSpacing() * (sizes.rows.length - 1);
}
return { width, height };
},

/**
* Gets the left and top initial offsets
*
Expand Down Expand Up @@ -259,15 +324,15 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
if (startIndex.column >= 0) {
// process the remaining columns, starting from the Visible Index
for (let absoluteColumnIndex = startIndex.column; absoluteColumnIndex < this._columns.getLength(); absoluteColumnIndex++) {
if (totalColumnWidth >= this._width) {
if (!this._overflow && totalColumnWidth >= this._width) {
break;
}
calculateColumnWidth(absoluteColumnIndex);
}
} else {
// process the remaining columns, starting from the end and working backwards until the space is filled
for (let absoluteColumnIndex = this._columns.getLength() - 1; absoluteColumnIndex >= 0; absoluteColumnIndex--) {
if (totalColumnWidth >= this._width) {
if (!this._overflow && totalColumnWidth >= this._width) {
break;
}
calculateColumnWidth(absoluteColumnIndex);
Expand Down Expand Up @@ -296,7 +361,9 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
flexAmount = maxFlex;
}
}

if (flexAmount < 0) {
flexAmount = 0;
}
flexAvailable -= flexAmount;
totalColumnWidth += flexAmount;
columnWidths[index] += flexAmount;
Expand Down Expand Up @@ -361,7 +428,7 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
if (startIndex.row >= 0) {
// process the remaining rows, starting from the Visible Index
for (let absoluteRowIndex = startIndex.row; absoluteRowIndex < numRows; absoluteRowIndex++) {
if (totalRowHeight >= this._height) {
if (!this._overflow && totalRowHeight >= this._height) {
break;
}
// only calculate the row height if it hasn't already been calculated by the fixed rows/headers
Expand All @@ -372,7 +439,7 @@ qx.Class.define("qxl.datagrid.ui.GridSizeCalculator", {
} else {
// process the remaining rows, starting from the end and working backwards until the space is filled
for (let absoluteRowIndex = numRows - 1; absoluteRowIndex >= 0; absoluteRowIndex--) {
if (totalRowHeight >= this._height) {
if (!this._overflow && totalRowHeight >= this._height) {
break;
}
// only calculate the row height if it hasn't already been calculated by the fixed rows/headers
Expand Down
1 change: 1 addition & 0 deletions source/class/qxl/datagrid/ui/OddEvenRowBackgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ qx.Class.define("qxl.datagrid.ui.OddEvenRowBackgrounds", {

let rowWidth = 0;
sizesData.columns.forEach(cd => (rowWidth += cd.width));
rowWidth += styling.getHorizontalSpacing() * (sizesData.columns.length - 1);

let top = this.__sizeCalculator.getInitialOffsets().top;
let verticalSpacing = styling.getVerticalSpacing();
Expand Down
14 changes: 11 additions & 3 deletions source/class/qxl/datagrid/ui/WidgetPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ qx.Class.define("qxl.datagrid.ui.WidgetPane", {
appearance: {
init: "qxl-datagrid-widgetpane",
refine: true
},

shouldDiscardWidgets: {
check: "Boolean",
init: true,
event: "changeShouldDiscardWidgets"
}
},

Expand Down Expand Up @@ -183,7 +189,7 @@ qx.Class.define("qxl.datagrid.ui.WidgetPane", {
}

let model = dataSource.getModelForPosition(new qxl.datagrid.source.Position(rowSizeData.rowIndex, columnSizeData.columnIndex));
if (!child) {
if (!child || invalidateAll) {
child = this.__widgetFactory.getWidgetFor(rowSizeData.rowIndex, columnSizeData.columnIndex);
children[id] = child;
child.setUserData("qxl.datagrid.cellData", {
Expand Down Expand Up @@ -269,9 +275,11 @@ qx.Class.define("qxl.datagrid.ui.WidgetPane", {
this.__widgetFactory.unbindWidget(child);
child.setUserData("qxl.datagrid.cellData", null);
this._remove(child);
this.__widgetFactory.disposeWidget(child);
if (this.getShouldDiscardWidgets()) {
this.__widgetFactory.disposeWidget(child);
}
}
if (id in this.__children) {
if (this.getShouldDiscardWidgets() && id in this.__children) {
delete this.__children[id];
}
},
Expand Down

0 comments on commit 93b4a42

Please sign in to comment.