pgLab/pglablib/PgTriggerContainer.cpp
eelke 2a75e86102 Added listing of triggers for selected table (not completely finished).
Used slightly different approach. This tab is fully build in source code
using subclasses to adjust behaviour of widgets for reuse in the other tabs.
Uses custom proxy model for filtering triggers for correct table and supporting
out of the box sorting by QTableView.

SqlCodePreview: QPlainTextEditor which sql highlighter and in readonly mode but allows copy.
2018-10-07 19:40:06 +02:00

33 lines
794 B
C++

#include "PgTriggerContainer.h"
#include "Pgsql_Connection.h"
#include "Pgsql_Col.h"
#include <algorithm>
#include <iterator>
std::string PgTriggerContainer::getLoadQuery() const
{
return R"(SELECT oid, *
FROM pg_trigger
WHERE NOT tgisinternal)";
}
PgTrigger PgTriggerContainer::loadElem(const Pgsql::Row &row)
{
Pgsql::Col col(row);
PgTrigger v;
col >> v.oid >> v.relid >> v.name >> v.foid >> v.type >> v.enabled >> v.isinternal >> v.constrrelid
>> v.constrindid >> v.constraint >> v.deferrable >> v.initdeferred >> v.nargs >> v.attr
>> v.args >> v.qual;
return v;
}
std::vector<PgTrigger> PgTriggerContainer::getTriggersForRelation(Oid cls) const
{
std::vector<PgTrigger> result;
for (auto e : m_container)
if (e.relid == cls)
result.push_back(e);
return result;
}