2017-02-04 11:55:49 +01:00
|
|
|
|
#include "ParamListModel.h"
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
|
|
|
|
|
ParamListModel::ParamListModel(QObject *parent)
|
|
|
|
|
|
: QAbstractTableModel(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVariant ParamListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
|
|
|
|
{
|
|
|
|
|
|
// FIXME: Implement me!
|
|
|
|
|
|
QVariant result;
|
|
|
|
|
|
if (orientation == Qt::Horizontal) {
|
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
|
if (section == 0) {
|
|
|
|
|
|
// result = tr("$n");
|
|
|
|
|
|
result = tr("Value");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (section == 1) {
|
|
|
|
|
|
result = tr("Type");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (orientation == Qt::Vertical) {
|
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
|
result = tr("$%1").arg(section + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//bool ParamListModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (value != headerData(section, orientation, role)) {
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
// emit headerDataChanged(orientation, section, section);
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ParamListModel::rowCount(const QModelIndex &parent) const
|
|
|
|
|
|
{
|
|
|
|
|
|
//if (parent.isValid())
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Implement me!
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ParamListModel::columnCount(const QModelIndex &parent) const
|
|
|
|
|
|
{
|
|
|
|
|
|
//if (parent.isValid())
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Implement me!
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVariant ParamListModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
|
{
|
|
|
|
|
|
QVariant result;
|
|
|
|
|
|
if (index.isValid()) {
|
|
|
|
|
|
int row = index.row();
|
|
|
|
|
|
int col = index.column();
|
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
|
switch (col) {
|
|
|
|
|
|
case 0: // value column
|
|
|
|
|
|
result = tr("val, %1").arg(row);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1: // type column
|
|
|
|
|
|
result = tr("type, %1").arg(row);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Implement me!
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ParamListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (data(index, role) != value) {
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
|
|
|
|
|
|
emit dataChanged(index, index, QVector<int>() << role);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Qt::ItemFlags ParamListModel::flags(const QModelIndex &index) const
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
|
return Qt::NoItemFlags;
|
|
|
|
|
|
|
|
|
|
|
|
return Qt::ItemIsEnabled | Qt::ItemIsEditable; // FIXME: Implement me!
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//bool ParamListModel::insertRows(int row, int count, const QModelIndex &parent)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// beginInsertRows(parent, row, row + count - 1);
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
// endInsertRows();
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//bool ParamListModel::insertColumns(int column, int count, const QModelIndex &parent)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// beginInsertColumns(parent, column, column + count - 1);
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
// endInsertColumns();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//bool ParamListModel::removeRows(int row, int count, const QModelIndex &parent)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// beginRemoveRows(parent, row, row + count - 1);
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
// endRemoveRows();
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//bool ParamListModel::removeColumns(int column, int count, const QModelIndex &parent)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// beginRemoveColumns(parent, column, column + count - 1);
|
|
|
|
|
|
// // FIXME: Implement me!
|
|
|
|
|
|
// endRemoveColumns();
|
|
|
|
|
|
//}
|