53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
|
|
#include "typeselectionitemmodel.h"
|
|||
|
|
|
|||
|
|
TypeSelectionItemModel::TypeSelectionItemModel(QObject *parent)
|
|||
|
|
: QAbstractListModel(parent)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int TypeSelectionItemModel::rowCount(const QModelIndex &parent) const
|
|||
|
|
{
|
|||
|
|
int result = 10;
|
|||
|
|
// 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) {
|
|||
|
|
if (column == 0) {
|
|||
|
|
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;
|
|||
|
|
}
|