Tab with list of sequences and create sql for selected sequence.
This commit is contained in:
parent
769307c821
commit
437736a023
19 changed files with 507 additions and 63 deletions
82
pglab/SequenceModel.cpp
Normal file
82
pglab/SequenceModel.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#include "SequenceModel.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "catalog/PgSequenceContainer.h"
|
||||
|
||||
SequenceModel::SequenceModel(QObject * parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{}
|
||||
|
||||
QVariant SequenceModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case NameCol: return tr("Name");
|
||||
case SchemaCol: return tr("Schema");
|
||||
case OwnerCol: return tr("Owner");
|
||||
case LastCol: return tr("Last");
|
||||
case StartCol: return tr("Start");
|
||||
case MinCol: return tr("Min");
|
||||
case MaxCol: return tr("Max");
|
||||
case IncrementCol: return tr("Inc");
|
||||
case CacheCol: return tr("Cached");
|
||||
case CycledCol: return tr("Cycled");
|
||||
case CalledCol: return tr("Called");
|
||||
case AclCol: return tr("ACL");
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void SequenceModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
m_catalog = cat;
|
||||
m_sequences = cat->sequences();
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
PgSequence SequenceModel::sequence(int row) const
|
||||
{
|
||||
return m_sequences->getByIdx(row);
|
||||
}
|
||||
|
||||
int SequenceModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return m_sequences ? static_cast<int>(m_sequences->count()) : 0;
|
||||
}
|
||||
|
||||
int SequenceModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
return colCount;
|
||||
}
|
||||
|
||||
QVariant SequenceModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!m_sequences)
|
||||
return {};
|
||||
|
||||
int row = index.row();
|
||||
auto && seq = m_sequences->getByIdx(row);
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case NameCol: return seq.objectName();
|
||||
case SchemaCol: return seq.nsName();
|
||||
case OwnerCol: return seq.ownerName();
|
||||
case LastCol: return seq.last;
|
||||
case StartCol: return seq.start;
|
||||
case MinCol: return seq.min;
|
||||
case MaxCol: return seq.max;
|
||||
case IncrementCol: return seq.increment;
|
||||
case CacheCol: return seq.cache;
|
||||
case CycledCol: return seq.cycled;
|
||||
case CalledCol: return seq.called;
|
||||
case AclCol: return seq.aclString();
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue