Fixed loading of data in CrudModel.

This commit is contained in:
eelke 2018-12-31 09:33:34 +01:00
parent 15bee33076
commit 424fb5984d
2 changed files with 4 additions and 14 deletions

View file

@ -172,8 +172,8 @@ void CrudModel::loadData()
if (res.valid()) { if (res.valid()) {
auto dbres = res.get(); auto dbres = res.get();
if (dbres && *dbres) { if (dbres && *dbres) {
/// \todo Use ControllableTask instead with QFUtureWatcher QMetaObject::invokeMethod(this, "loadIntoModel", Qt::QueuedConnection,
// m_asyncWindow->QueueTask([this, dbres]() { loadIntoModel(dbres); }); Q_ARG(std::shared_ptr<Pgsql::Result>, dbres));
} }
} }
else { else {
@ -197,7 +197,7 @@ void CrudModel::loadIntoModel(std::shared_ptr<Pgsql::Result> data)
void CrudModel::initRowMapping() void CrudModel::initRowMapping()
{ {
m_rowMapping.resize(m_rowCount); m_rowMapping.resize(static_cast<size_t>(m_rowCount));
for (int i = 0; i < m_rowCount; ++i) for (int i = 0; i < m_rowCount; ++i)
m_rowMapping[i] = RowMapping{ i }; m_rowMapping[i] = RowMapping{ i };
} }

View file

@ -263,13 +263,6 @@ private:
/// call on initial load to fill in the mappings /// call on initial load to fill in the mappings
void initRowMapping(); void initRowMapping();
// using RedirectVec = std::vector<int>;
// /// In sync with the actual table, used to efficiently find the correct row in the result
// RedirectVec m_redirectVector;
void loadIntoModel(std::shared_ptr<Pgsql::Result> data);
Value getData(const QModelIndex &index) const; Value getData(const QModelIndex &index) const;
Oid getType(int column) const; Oid getType(int column) const;
@ -317,11 +310,8 @@ private:
int attNumToCol(int attnum) const { return attnum - 1; } int attNumToCol(int attnum) const { return attnum - 1; }
private slots: private slots:
void loadIntoModel(std::shared_ptr<Pgsql::Result> data);
void connectionStateChanged(ASyncDBConnection::State state); void connectionStateChanged(ASyncDBConnection::State state);
// void queryResult(std::shared_ptr<Pgsql::Result> result);
// void queryError();
// void dataProcessingFutureFinished();
}; };
#endif // CRUDMODEL_H #endif // CRUDMODEL_H