PSFListModel isa ListModel instead of hasa

This commit is contained in:
howard-stearns 2018-06-09 16:03:45 -07:00
parent d2cf042a88
commit 421edbfa1e
6 changed files with 10 additions and 26 deletions

View file

@ -98,7 +98,7 @@ Column {
} }
ListView { ListView {
id: scroll; id: scroll;
model: suggestions.model; model: suggestions;
orientation: ListView.Horizontal; orientation: ListView.Horizontal;
highlightFollowsCurrentItem: false highlightFollowsCurrentItem: false
highlightMoveDuration: -1; highlightMoveDuration: -1;

View file

@ -785,7 +785,7 @@ Rectangle {
resizable: false; resizable: false;
} }
model: connectionsUserModel.model; model: connectionsUserModel;
Connections { Connections {
target: connectionsTable.flickableItem; target: connectionsTable.flickableItem;
onAtYEndChanged: { onAtYEndChanged: {

View file

@ -519,7 +519,7 @@ Item {
} }
visible: !connectionsLoading.visible; visible: !connectionsLoading.visible;
clip: true; clip: true;
model: connectionsModel.model; model: connectionsModel;
onAtYEndChanged: if (connectionsList.atYEnd && !connectionsList.atYBeginning) { connectionsModel.getNextPage(); } onAtYEndChanged: if (connectionsList.atYEnd && !connectionsList.atYBeginning) { connectionsModel.getNextPage(); }
snapMode: ListView.SnapToItem; snapMode: ListView.SnapToItem;
// Anchors // Anchors

View file

@ -583,7 +583,7 @@ Rectangle {
id: purchasesContentsList; id: purchasesContentsList;
visible: purchasesModel.count !== 0; visible: purchasesModel.count !== 0;
clip: true; clip: true;
model: purchasesModel.model; model: purchasesModel;
snapMode: ListView.SnapToItem; snapMode: ListView.SnapToItem;
// Anchors // Anchors
anchors.top: separator.bottom; anchors.top: separator.bottom;

View file

@ -323,7 +323,7 @@ Item {
height: parent.height; height: parent.height;
visible: transactionHistoryModel.count !== 0; visible: transactionHistoryModel.count !== 0;
clip: true; clip: true;
model: transactionHistoryModel.model; model: transactionHistoryModel;
delegate: Item { delegate: Item {
width: parent.width; width: parent.width;
height: (model.transaction_type === "pendingCount" && model.count !== 0) ? 40 : ((model.status === "confirmed" || model.status === "invalidated") ? transactionText.height + 30 : 0); height: (model.transaction_type === "pendingCount" && model.count !== 0) ? 40 : ((model.status === "confirmed" || model.status === "invalidated") ? transactionText.height + 30 : 0);

View file

@ -17,7 +17,7 @@
import QtQuick 2.7 import QtQuick 2.7
Item { ListModel {
id: root; id: root;
// Used when printing debug statements // Used when printing debug statements
property string listModelName: endpoint; property string listModelName: endpoint;
@ -50,7 +50,7 @@ Item {
// Not normally set directly, but rather by giving a truthy argument to getFirstPage(true); // Not normally set directly, but rather by giving a truthy argument to getFirstPage(true);
property bool delayedClear: false; property bool delayedClear: false;
function resetModel() { function resetModel() {
if (!delayedClear) { finalModel.clear(); } if (!delayedClear) { root.clear(); }
currentPageToRetrieve = 1; currentPageToRetrieve = 1;
retrievedAtLeastOnePage = false; retrievedAtLeastOnePage = false;
} }
@ -87,12 +87,12 @@ Item {
} }
if (delayedClear) { if (delayedClear) {
finalModel.clear(); root.clear();
delayedClear = false; delayedClear = false;
} }
finalModel.append(processed); // FIXME keep index steady, and apply any post sort root.append(processed); // FIXME keep index steady, and apply any post sort
retrievedAtLeastOnePage = true; retrievedAtLeastOnePage = true;
debugView('after handlePage'); console.debug(listModelName, 'after handlePage count', root.count);
} }
function debugView(label) { function debugView(label) {
if (!listView) { return; } if (!listView) { return; }
@ -152,20 +152,4 @@ Item {
requestPending = true; requestPending = true;
getPage(); getPage();
} }
// Redefining members and methods so that the parent of this Item
// can use PSFListModel as they would a regular ListModel
property alias model: finalModel;
property alias count: finalModel.count;
function clear() { finalModel.clear(); }
function get(index) { return finalModel.get(index); }
function remove(index) { return finalModel.remove(index); }
function setProperty(index, prop, value) { return finalModel.setProperty(index, prop, value); }
function move(from, to, n) { return finalModel.move(from, to, n); }
function insert(index, newElement) { finalModel.insert(index, newElement); }
function append(newElements) { finalModel.append(newElements); }
ListModel {
id: finalModel;
}
} }