Sequence and Function pages are now properly filtered on namespace.
This commit is contained in:
parent
7ca671a078
commit
f2808de613
17 changed files with 136 additions and 48 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "catalog/PgProcContainer.h"
|
||||
#include "catalog/PgLanguageContainer.h"
|
||||
#include "catalog/PgNamespace.h"
|
||||
#include "CustomDataRole.h"
|
||||
|
||||
ProcTableModel::ProcTableModel(QObject *parent)
|
||||
|
|
@ -27,17 +28,48 @@ QVariant ProcTableModel::headerData(int section, Qt::Orientation orientation, in
|
|||
|
||||
void ProcTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
||||
{
|
||||
m_catalog = cat;
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void ProcTableModel::setNamespaceFilter(NamespaceFilter filter)
|
||||
{
|
||||
m_namespaceFilter = filter;
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void ProcTableModel::reloadData()
|
||||
{
|
||||
if (!m_catalog)
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
|
||||
m_catalog = cat;
|
||||
m_procs = cat->procs();
|
||||
auto && procs = m_catalog->procs();
|
||||
m_procs.clear();
|
||||
for (auto&& p : *procs) {
|
||||
bool add = false;
|
||||
switch (m_namespaceFilter) {
|
||||
case NamespaceFilter::User:
|
||||
add = !p.ns().isSystemCatalog();
|
||||
break;
|
||||
case NamespaceFilter::PgCatalog:
|
||||
add = p.ns().objectName() == "pg_catalog";
|
||||
break;
|
||||
case NamespaceFilter::InformationSchema:
|
||||
add = p.ns().objectName() == "information_schema";
|
||||
break;
|
||||
}
|
||||
if (add)
|
||||
m_procs.push_back(p);
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int ProcTableModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return m_procs ? static_cast<int>(m_procs->count()) : 0;
|
||||
return static_cast<int>(m_procs.size());
|
||||
}
|
||||
|
||||
int ProcTableModel::columnCount(const QModelIndex &) const
|
||||
|
|
@ -60,7 +92,7 @@ QVariant ProcTableModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
PgProc ProcTableModel::proc(int row) const
|
||||
{
|
||||
return m_procs->getByIdx(row);
|
||||
return m_procs.at(static_cast<size_t>(row));
|
||||
}
|
||||
|
||||
Oid ProcTableModel::getType(int ) const
|
||||
|
|
@ -77,7 +109,7 @@ Oid ProcTableModel::getType(int ) const
|
|||
|
||||
QVariant ProcTableModel::getData(const QModelIndex &index) const
|
||||
{
|
||||
auto&& t = m_procs->getByIdx(index.row());
|
||||
auto&& t = m_procs.at(static_cast<size_t>(index.row()));
|
||||
switch (index.column()) {
|
||||
case NameCol: return t.objectName();
|
||||
case NamespaceCol: return t.nsName();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue