start on view the show single record as list of label + value
This commit is contained in:
parent
c71fdc4af7
commit
4ac87f285b
4 changed files with 119 additions and 7 deletions
61
pglab/widgets/SingleRecordModel.cpp
Normal file
61
pglab/widgets/SingleRecordModel.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "SingleRecordModel.h"
|
||||
#include "CustomDataRole.h"
|
||||
|
||||
SingleRecordModel::SingleRecordModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant SingleRecordModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int SingleRecordModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return elems.size();
|
||||
}
|
||||
|
||||
int SingleRecordModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return ColCount;
|
||||
}
|
||||
|
||||
QVariant SingleRecordModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
const int row = index.row();
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NameCol:
|
||||
return elems[row].name;
|
||||
case ValueCol:
|
||||
return elems[row].value;
|
||||
}
|
||||
}
|
||||
else if (role == CustomDataTypeRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NameCol:
|
||||
return Pgsql::text_oid;
|
||||
case ValueCol:
|
||||
return elems[row].oid;
|
||||
}
|
||||
}
|
||||
else if (role == CustomDataMeaningRole)
|
||||
{
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue