SelectionEditorFactory + ItemModel + ItemModelFactory combination is working
in new EditTableWidget (EditTableWidget is very much WIP)
This commit is contained in:
parent
e44f73166f
commit
742fd0a4d3
19 changed files with 419 additions and 80 deletions
|
|
@ -9,7 +9,7 @@ TypeSelectionItemModel::TypeSelectionItemModel(QObject *parent)
|
|||
|
||||
int TypeSelectionItemModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
int result = m_types.size();
|
||||
int result = static_cast<int>(m_types.size());
|
||||
// if (!parent.isValid()) {
|
||||
|
||||
// }
|
||||
|
|
@ -18,7 +18,7 @@ int TypeSelectionItemModel::rowCount(const QModelIndex &/*parent*/) const
|
|||
|
||||
int TypeSelectionItemModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
int result = 1;
|
||||
int result = 2;
|
||||
// if (parent.isValid())
|
||||
// result = 1;
|
||||
|
||||
|
|
@ -35,21 +35,8 @@ QVariant TypeSelectionItemModel::data(const QModelIndex &index, int role) const
|
|||
if (role == Qt::DisplayRole) {
|
||||
//const PgType &tp = m_types->getByIdx(row);
|
||||
if (column == 0) {
|
||||
result = m_types[row]; //tp.typname;
|
||||
result = m_types[static_cast<size_t>(row)]; //tp.typname;
|
||||
|
||||
// switch (row) {
|
||||
// case 0: result = "integer"; break;
|
||||
// case 1: result = "numeric"; break;
|
||||
// case 2: result = "timestamp"; break;
|
||||
// case 3: result = "timestamptz"; break;
|
||||
// case 4: result = "float"; break;
|
||||
// case 5: result = "double"; break;
|
||||
// case 6: result = "date"; break;
|
||||
// case 7: result = "varchar"; break;
|
||||
// case 8: result = "varchar"; break;
|
||||
// case 9: result = "varchar"; break;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,3 +56,48 @@ void TypeSelectionItemModel::setTypeList(std::shared_ptr<const PgTypeContainer>
|
|||
//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.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
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