Skip to content

Commit

Permalink
Fix #4014: Undefined rows on second Hash page (#4019)
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Feb 22, 2018
1 parent fd5f44d commit 2ac864a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/modules/value-editor/valueviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ bool ValueEditor::ValueViewModel::isRowLoaded(int i)
return m_model.isRowLoaded(i);
}

void ValueEditor::ValueViewModel::loadRows(int start, int count)
void ValueEditor::ValueViewModel::loadRows(int start, int limit)
{
int rowsLeft = totalRowCount() - start;
int loaded = (rowsLeft > limit) ? limit : rowsLeft;

// frame already loaded
if (m_model.isRowLoaded(start)) {
m_startFramePosition = start;
m_lastLoadedRowFrameSize = loaded;

emit layoutAboutToBeChanged();
emit rowsLoaded(start, count);
emit rowsLoaded(start, loaded);
emit layoutChanged();
return;
}
Expand All @@ -85,15 +90,12 @@ void ValueEditor::ValueViewModel::loadRows(int start, int count)
try {
// NOTE(u_glide): Do so for proper rendering of QML table
m_lastLoadedRowFrameSize = totalRowCount() - start;
m_model.loadRows(start, count, [this, start, count, msg](const QString& err)
m_model.loadRows(start, limit, [this, start, limit, loaded, msg](const QString& err)
{
if (!err.isEmpty()) {
emit error(msg.arg(err));
return;
}

int loaded = totalRowCount() - start;
loaded = (loaded > count) ? count : loaded;
}

m_lastLoadedRowFrameSize = loaded;
m_startFramePosition = start;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/value-editor/valueviewmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ValueViewModel : public QAbstractListModel
Q_INVOKABLE QVariantMap getRow(int i);

// multi row operations
Q_INVOKABLE void loadRows(int start, int count);
Q_INVOKABLE void loadRows(int start, int limit);
Q_INVOKABLE bool isMultiRow();
Q_INVOKABLE void reload();
Q_INVOKABLE int totalRowCount();
Expand Down

0 comments on commit 2ac864a

Please sign in to comment.