Reorganize files in pglablib
The enitities and containers of the catalog now go into catalog subfolder Models go into model
This commit is contained in:
parent
56cbeea183
commit
f0c1035378
121 changed files with 226 additions and 183 deletions
|
|
@ -1,103 +0,0 @@
|
|||
#include "TypeSelectionItemModel.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
TypeSelectionItemModel::TypeSelectionItemModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int TypeSelectionItemModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
int result = static_cast<int>(m_types.size());
|
||||
// if (!parent.isValid()) {
|
||||
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
int TypeSelectionItemModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
int result = 2;
|
||||
// if (parent.isValid())
|
||||
// result = 1;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant TypeSelectionItemModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant result;
|
||||
if (index.isValid()) {
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
if (role == Qt::DisplayRole) {
|
||||
//const PgType &tp = m_types->getByIdx(row);
|
||||
if (column == 0) {
|
||||
result = m_types[static_cast<size_t>(row)]; //tp.typname;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TypeSelectionItemModel::setTypeList(std::shared_ptr<const PgTypeContainer> types)
|
||||
{
|
||||
beginResetModel();
|
||||
m_types.clear();
|
||||
for (const auto &e : *types) {
|
||||
if (e.category != TypCategory::Array && e.type != "c") {
|
||||
m_types.push_back(e.objectName());
|
||||
}
|
||||
}
|
||||
std::sort(m_types.begin(), m_types.end());
|
||||
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
||||
|
||||
TypeModel::TypeModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int TypeModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
if (m_types)
|
||||
return static_cast<int>(m_types->count());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TypeModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return colCount;
|
||||
}
|
||||
|
||||
QVariant TypeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
if (role == Qt::DisplayRole) {
|
||||
//const PgType &tp = m_types->getByIdx(row);
|
||||
auto elem = m_types->getByIdx(row);
|
||||
switch (column) {
|
||||
case OidCol: return elem.oid();
|
||||
case NameCol: return elem.objectName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void TypeModel::setTypeList(std::shared_ptr<const PgTypeContainer> types)
|
||||
{
|
||||
beginResetModel();
|
||||
m_types = types;
|
||||
endResetModel();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue