Added page with the types (no details yet)
This commit is contained in:
parent
bdef76ed8a
commit
4c175d8c2c
16 changed files with 418 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "TypeSelectionItemModel.h"
|
||||
//#include "CustomDataRole.h"
|
||||
#include "catalog/PgTypeContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ void TypeSelectionItemModel::setTypeList(std::shared_ptr<const PgTypeContainer>
|
|||
std::sort(m_types.begin(), m_types.end());
|
||||
}
|
||||
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
||||
endResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
|
@ -82,6 +83,9 @@ int TypeModel::columnCount(const QModelIndex &/*parent*/) const
|
|||
|
||||
QVariant TypeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// if (role == CustomDataTypeRole)
|
||||
// return getType(index.column());
|
||||
|
||||
if (index.isValid()) {
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
|
|
@ -91,15 +95,90 @@ QVariant TypeModel::data(const QModelIndex &index, int role) const
|
|||
switch (column) {
|
||||
case OidCol: return elem.oid();
|
||||
case NameCol: return elem.objectName();
|
||||
case NamespaceCol: return elem.nsName();
|
||||
case OwnerCol: return elem.ownerName();
|
||||
case CategoryCol: return TypCategoryString(elem.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QString TypeModel::TypCategoryString(TypCategory tc)
|
||||
{
|
||||
switch (tc) {
|
||||
case TypCategory::Array:
|
||||
return tr("array");
|
||||
case TypCategory::Boolean:
|
||||
return tr("boolean");
|
||||
case TypCategory::Composite:
|
||||
return tr("composite");
|
||||
case TypCategory::DateTime:
|
||||
return tr("datetime");
|
||||
case TypCategory::Enum:
|
||||
return tr("enum");
|
||||
case TypCategory::Geometric:
|
||||
return tr("geometric");
|
||||
case TypCategory::NetworkAddress:
|
||||
return tr("networkaddress");
|
||||
case TypCategory::Numeric:
|
||||
return tr("numeric");
|
||||
case TypCategory::Pseudo:
|
||||
return tr("pseude");
|
||||
case TypCategory::Range:
|
||||
return tr("range");
|
||||
case TypCategory::String:
|
||||
return tr("string");
|
||||
case TypCategory::Timespan:
|
||||
return tr("timespan");
|
||||
case TypCategory::UserDefined:
|
||||
return tr("user");
|
||||
case TypCategory::BitString:
|
||||
return tr("bitstring");
|
||||
case TypCategory::Unknown:
|
||||
return tr("unknown");
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
Oid TypeModel::getType(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case OidCol:
|
||||
return Pgsql::oid_oid;
|
||||
case NameCol:
|
||||
case NamespaceCol:
|
||||
case OwnerCol:
|
||||
case CategoryCol:
|
||||
return Pgsql::varchar_oid;
|
||||
}
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
void TypeModel::setTypeList(std::shared_ptr<const PgTypeContainer> types)
|
||||
{
|
||||
beginResetModel();
|
||||
m_types = types;
|
||||
endResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
PgType TypeModel::typ(int row) const
|
||||
{
|
||||
return m_types->getByIdx(row);
|
||||
}
|
||||
|
||||
QVariant TypeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case OidCol: return tr("Oid");
|
||||
case NameCol: return tr("Name");
|
||||
case NamespaceCol: return tr("Schema");
|
||||
case OwnerCol: return tr("Owner");
|
||||
case CategoryCol: return tr("Category");
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <QAbstractListModel>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "catalog/PgType.h"
|
||||
|
||||
class PgTypeContainer;
|
||||
|
||||
|
|
@ -28,19 +29,27 @@ public:
|
|||
enum e_Columns : int {
|
||||
OidCol,
|
||||
NameCol, //
|
||||
NamespaceCol,
|
||||
OwnerCol,
|
||||
CategoryCol,
|
||||
colCount
|
||||
};
|
||||
|
||||
explicit TypeModel(QObject *parent = 0);
|
||||
|
||||
void setTypeList(std::shared_ptr<const PgTypeContainer> types);
|
||||
PgType typ(int row) const;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<const PgTypeContainer> m_types;
|
||||
|
||||
static QString TypCategoryString(TypCategory tc);
|
||||
Oid getType(int column) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue