SelectionEditorFactory for creating combobox selections for use in QTableView.
TypeSelectionItemModelFactory to use the TypeSelectionItemModel with above factory.
This commit is contained in:
parent
f8d61b61f4
commit
e44f73166f
7 changed files with 138 additions and 0 deletions
|
|
@ -1,71 +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 = m_types.size();
|
||||
// if (!parent.isValid()) {
|
||||
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
int TypeSelectionItemModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
int result = 1;
|
||||
// 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[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;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
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.name);
|
||||
}
|
||||
}
|
||||
std::sort(m_types.begin(), m_types.end());
|
||||
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
||||
endResetModel();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue