All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
GeopsyGui::AsciiSignalRulesItem Class Reference

#include <AsciiSignalRulesWidget.h>

List of all members.

Public Member Functions

 AsciiSignalRulesItem (QObject *parent)
virtual int columnCount (const QModelIndex &) const
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
virtual Qt::ItemFlags flags (const QModelIndex &index) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
virtual int rowCount (const QModelIndex &) const
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void setFormat (AsciiSignalFormat *f)
void setHeader (const QString &h)

Constructor & Destructor Documentation

: QAbstractTableModel(parent) {_format=0;}

Member Function Documentation

virtual int GeopsyGui::AsciiSignalRulesItem::columnCount ( const QModelIndex &  ) const [inline, virtual]
{return 9;}
QVariant GeopsyGui::AsciiSignalRulesItem::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const [virtual]

References GeopsyCore::AsciiSignalFormatRule::channel(), GeopsyCore::AsciiSignalFormatRule::constant(), GeopsyCore::AsciiSignalFormatRule::data(), GeopsyCore::AsciiSignalFormatRule::factor(), GeopsyCore::MetaDataIndex::index(), GeopsyCore::AsciiSignalFormatRule::mandatory(), GeopsyCore::AsciiSignalFormatRule::pattern(), GeopsyCore::AsciiSignalFormatRule::patternIndex(), GeopsyCore::AsciiSignalFormat::rule(), and GeopsyCore::AsciiSignalFormatRule::value().

{
  const AsciiSignalFormatRule& r=_format->rule(index.row());
  switch(role) {
  case Qt::DisplayRole:
    switch(index.column()) {
    case 1:
      return r.value();
    case 3:
      return r.pattern();
    case 4:
      return r.patternIndex();
    case 5:
      return r.factor();
    case 6:
      return r.channel();
    case 7:
      return MetaDataFactory::instance()->baseName(r.data());
    case 8:
      return r.data().index();
    default:
      return QVariant();
    }
    break;
  case Qt::CheckStateRole:
    switch(index.column()) {
    case 0:
      return r.constant();
    case 2:
      return r.mandatory();
    default:
      return QVariant();
    }
    break;
  default:
    return QVariant();
  }
}
Qt::ItemFlags GeopsyGui::AsciiSignalRulesItem::flags ( const QModelIndex &  index) const [virtual]

References GeopsyCore::AsciiSignalFormatRule::constant(), and GeopsyCore::AsciiSignalFormat::rule().

{
  const AsciiSignalFormatRule& r=_format->rule(index.row());
  if(r.constant()) {
    switch(index.column()) {
    case 0:
      return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
    case 1:
      return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
    default:
      return 0;
    }
  } else {
    switch(index.column()) {
    case 0:
    case 2:
      return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
    case 1:
      return 0;
    default:
      return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;;
    }
  }
}
QVariant GeopsyGui::AsciiSignalRulesItem::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const [virtual]

References QGpCoreTools::tr().

{
  switch(role) {
  case Qt::DisplayRole:
    if(orientation==Qt::Vertical) {
      return section+1;
    } else {
      switch(section) {
      case 0:
        return tr("Constant");
      case 1:
        return tr("Value");
      case 2:
        return tr("Mandatory");
      case 3:
        return tr("Pattern");
      case 4:
        return tr("Index");
      case 5:
        return tr("Factor");
      case 6:
        return tr("Channel");
      case 7:
        return tr("Data");
      case 8:
        return tr("Index");
      default:
        return QVariant();
      }
    }
    break;
  case Qt::ToolTipRole:
    if(orientation==Qt::Horizontal) {
      switch(section) {
      case 0:
        return tr("Value is not extracted from header");
      case 1:
        return tr("For constant values only");
      case 2:
        return tr("Generate an error if pattern cannot be found");
      case 3:
        return tr("Regular expression to identify information in header");
      case 4:
        return tr("Pattern must contain at least one expression between (), "
                  "this index identifies the value to extract");
      case 5:
        return tr("Multiply the value by this factor");
      case 6:
        return tr("Assign the value only if signal matches this channel number");
      case 7:
        return tr("Signal data to assign");
      case 8:
        return tr("For signal data vectors, the index to assign");
      default:
        return QVariant();
      }
    }
    break;
  default:
    break;
  }
  return QVariant();
}
bool GeopsyGui::AsciiSignalRulesItem::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
) [virtual]

References GeopsyCore::AsciiSignalFormat::insertRule().

{
  beginInsertRows(parent, row, row+count-1);
  for(int i=0;i<count;i++) {
    _format->insertRule(row, AsciiSignalFormatRule());
  }
  endInsertRows();
  return true;
}
bool GeopsyGui::AsciiSignalRulesItem::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
) [virtual]

References GeopsyCore::AsciiSignalFormat::removeRule().

{
  beginRemoveRows(parent, row, row+count-1);
  for(int i=0;i<count;i++) {
    _format->removeRule(row);
  }
  endRemoveRows();
  return true;
}
virtual int GeopsyGui::AsciiSignalRulesItem::rowCount ( const QModelIndex &  ) const [inline, virtual]

References GeopsyCore::AsciiSignalFormat::ruleCount().

{return _format ? _format->ruleCount() : 0;}
bool GeopsyGui::AsciiSignalRulesItem::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

References GeopsyCore::AsciiSignalFormatRule::data(), GeopsyCore::MetaDataIndex::index(), GeopsyCore::AsciiSignalFormat::rule(), GeopsyCore::AsciiSignalFormatRule::setChannel(), GeopsyCore::AsciiSignalFormatRule::setConstant(), GeopsyCore::AsciiSignalFormatRule::setData(), GeopsyCore::AsciiSignalFormatRule::setFactor(), GeopsyCore::MetaDataIndex::setIndex(), GeopsyCore::AsciiSignalFormatRule::setMandatory(), GeopsyCore::AsciiSignalFormatRule::setPattern(), GeopsyCore::AsciiSignalFormatRule::setPatternIndex(), and GeopsyCore::AsciiSignalFormatRule::setValue().

{
  AsciiSignalFormatRule& r=_format->rule(index.row());
  switch(role) {
  case Qt::EditRole:
    switch(index.column()) {
    case 0:
      r.setConstant(value.toBool());
      updateValue(index);
      return true;
    case 1:
      r.setValue(value);
      return true;
    case 2:
      r.setMandatory(value.toBool());
      return true;
    case 3:
      r.setPattern(value.toString());
      updateValue(index);
      return true;
    case 4:
      r.setPatternIndex(value.toInt());
      updateValue(index);
      return true;
    case 5:
      r.setFactor(value.toDouble());
      updateValue(index);
      return true;
    case 6:
      r.setChannel(value.toInt());
      updateValue(index);
      return true;
    case 7: {
        MetaDataIndex index=MetaDataFactory::instance()->index(value.toString());
        index.setIndex(r.data().index());
        r.setData(index);
      }
      return true;
    case 8: {
        MetaDataIndex index=r.data();
        index.setIndex(value.toString());
        r.setData(index);
      }
      return true;
    default:
      return false;
    }
    break;
  default:
    return false;
  }
}
{
  _format=f;
  reset();
}
void GeopsyGui::AsciiSignalRulesItem::setHeader ( const QString &  h)

References GeopsyCore::AsciiSignalFormat::parseHeader().

{
  _header=h;
  _format->parseHeader(_header);
  reset();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines