Populate table sizes
This commit is contained in:
parent
39dbab4d36
commit
abc0dd892f
10 changed files with 47 additions and 62 deletions
|
|
@ -57,10 +57,7 @@ void TablesTableModel::refresh()
|
|||
if (!m_catalog)
|
||||
return;
|
||||
|
||||
// Later afscheiden naar filter functie
|
||||
auto classes = m_catalog->classes();
|
||||
|
||||
std::map<Oid, int> oidIndex;
|
||||
rootNode.reset();
|
||||
|
||||
auto nsfilter = GetNamespaceFilterLambda();
|
||||
|
|
@ -70,7 +67,8 @@ void TablesTableModel::refresh()
|
|||
temp.emplace(e.oid(), e);
|
||||
|
||||
TableTreeBuilder treeBuilder(temp, *m_catalog->inherits());
|
||||
rootNode = treeBuilder.Build();
|
||||
auto [rn, oidIndex] = treeBuilder.Build();
|
||||
rootNode = rn;
|
||||
|
||||
StartLoadTableSizes(std::move(oidIndex));
|
||||
}
|
||||
|
|
@ -189,16 +187,6 @@ QVariant TablesTableModel::getData(const QModelIndex &index) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
//PgClass TablesTableModel::getTable(int row) const
|
||||
//{
|
||||
// return rootNode->children[row]->_class;
|
||||
//}
|
||||
|
||||
//Oid TablesTableModel::getTableOid(int row) const
|
||||
//{
|
||||
// return rootNode->children[row]->_class.oid();
|
||||
//}
|
||||
|
||||
QVariant TablesTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
|
|
@ -221,7 +209,7 @@ QVariant TablesTableModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
void TablesTableModel::StartLoadTableSizes(std::map<Oid, int> oidIndex)
|
||||
void TablesTableModel::StartLoadTableSizes(OidClassIndex oidIndex)
|
||||
{
|
||||
QPointer p(this);
|
||||
QtConcurrent::run([this]
|
||||
|
|
@ -231,7 +219,7 @@ void TablesTableModel::StartLoadTableSizes(std::map<Oid, int> oidIndex)
|
|||
.then(qApp, [p, oidIndex] (TableSizes sizes)
|
||||
{
|
||||
if (p)
|
||||
p.data()->PopulateSizes(std::move(oidIndex), std::move(sizes));
|
||||
p.data()->PopulateSizes(oidIndex, sizes);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -280,20 +268,23 @@ TablesTableModel::TableSizes TablesTableModel::QueryTableSizes() const
|
|||
return sizes;
|
||||
}
|
||||
|
||||
void TablesTableModel::PopulateSizes(std::map<Oid, int> oidIndex, std::vector<TableSize> sizes)
|
||||
void TablesTableModel::PopulateSizes(
|
||||
const OidClassIndex &oidIndex,
|
||||
const std::vector<TableSize> &sizes
|
||||
)
|
||||
{
|
||||
// for (auto s : sizes)
|
||||
// {
|
||||
// auto findIter = oidIndex.find(s.oid);
|
||||
// if (findIter != oidIndex.end())
|
||||
// {
|
||||
// rootNode->children[findIter->second]->sizes = s;
|
||||
// }
|
||||
// }
|
||||
// emit dataChanged(
|
||||
// createIndex(0, TotalSizeCol),
|
||||
// createIndex(static_cast<int>(rootNode->children.size()), ToastSizeCol)
|
||||
// );
|
||||
for (auto s : sizes)
|
||||
{
|
||||
auto findIter = oidIndex.find(s.oid);
|
||||
if (findIter != oidIndex.end())
|
||||
{
|
||||
findIter->second->sizes = s;
|
||||
}
|
||||
}
|
||||
emit dataChanged(
|
||||
index(0, TotalSizeCol),
|
||||
index(static_cast<int>(rootNode->children.size()), ToastSizeCol)
|
||||
);
|
||||
}
|
||||
|
||||
const TableNode* TablesTableModel::nodeFromIndex(const QModelIndex &index)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue