Type selection for parameters is now sorted and limited to non array and non composite types.
This commit is contained in:
parent
dd19077281
commit
0a809a7288
2 changed files with 15 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "typeselectionitemmodel.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
TypeSelectionItemModel::TypeSelectionItemModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
|
|
@ -8,7 +9,7 @@ TypeSelectionItemModel::TypeSelectionItemModel(QObject *parent)
|
|||
|
||||
int TypeSelectionItemModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
int result = m_types->count();
|
||||
int result = m_types.size();
|
||||
// if (!parent.isValid()) {
|
||||
|
||||
// }
|
||||
|
|
@ -32,9 +33,9 @@ QVariant TypeSelectionItemModel::data(const QModelIndex &index, int role) const
|
|||
int row = index.row();
|
||||
int column = index.column();
|
||||
if (role == Qt::DisplayRole) {
|
||||
const PgType &tp = m_types->getByIdx(row);
|
||||
//const PgType &tp = m_types->getByIdx(row);
|
||||
if (column == 0) {
|
||||
result = tp.typname;
|
||||
result = m_types[row]; //tp.typname;
|
||||
|
||||
// switch (row) {
|
||||
// case 0: result = "integer"; break;
|
||||
|
|
@ -58,7 +59,14 @@ QVariant TypeSelectionItemModel::data(const QModelIndex &index, int role) const
|
|||
void TypeSelectionItemModel::setTypeList(const PgTypeContainer* types)
|
||||
{
|
||||
beginResetModel();
|
||||
m_types = types;
|
||||
m_types.clear();
|
||||
for (const auto &e : *types) {
|
||||
if (e.typcategory != 'A'
|
||||
&& e.typtype != 'c') {
|
||||
m_types.push_back(e.typname);
|
||||
}
|
||||
}
|
||||
std::sort(m_types.begin(), m_types.end());
|
||||
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
||||
endResetModel();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define TYPESELECTIONITEMMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <vector>
|
||||
|
||||
class PgTypeContainer;
|
||||
|
||||
|
|
@ -19,7 +20,8 @@ public:
|
|||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
const PgTypeContainer* m_types;
|
||||
// const PgTypeContainer* m_types;
|
||||
std::vector<QString> m_types;
|
||||
};
|
||||
|
||||
#endif // TYPESELECTIONITEMMODEL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue