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

Brief description of class still missing. More...

#include <LegendTableItem.h>

List of all members.

Public Member Functions

virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual QVariant data (const QModelIndex &index, int role) const
virtual Qt::ItemFlags flags (const QModelIndex &) const
 LegendTableItem (QObject *parent=0)
bool oneColor () const
bool readOnlyText () const
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
void setColumnIndexes (const QHash< int, LegendTable::Column > *columnIndexes)
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void setLegend (Legend *legend)
void setOneColor (bool oc)
void setReadOnlyText (bool ro)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

SciFigs::LegendTableItem::LegendTableItem ( QObject *  parent = 0)

Description of constructor still missing

  : QAbstractTableModel(parent)
{
  _legend=0;
  _columnIndexes=0;
  _readOnlyText=false;
  _oneColor=true;
}

Member Function Documentation

int SciFigs::LegendTableItem::columnCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Referenced by setData().

{
  return _columnIndexes ? _columnIndexes->count() : 0;
}
QVariant SciFigs::LegendTableItem::data ( const QModelIndex &  index,
int  role 
) const [virtual]

References SciFigs::Symbol::brush(), SciFigs::LegendTable::brushItem(), SciFigs::Pen::color(), SciFigs::LegendTable::ColumnNull, SciFigs::LegendTable::ColumnPenColor, SciFigs::LegendTable::ColumnPenStyle, SciFigs::LegendTable::ColumnPenWidth, SciFigs::LegendTable::ColumnSymbolBrushColor, SciFigs::LegendTable::ColumnSymbolBrushStyle, SciFigs::LegendTable::ColumnSymbolPenColor, SciFigs::LegendTable::ColumnSymbolPenStyle, SciFigs::LegendTable::ColumnSymbolPenWidth, SciFigs::LegendTable::ColumnSymbolSize, SciFigs::LegendTable::ColumnSymbolType, SciFigs::LegendTable::ColumnText, SciFigs::LegendTable::ColumnTextColor, SciFigs::Symbol::pen(), SciFigs::Legend::pen(), SciFigs::LegendTable::penItem(), SciFigs::Symbol::size(), SciFigs::Pen::style(), SciFigs::Legend::symbol(), SciFigs::LegendTable::symbolItem(), SciFigs::Legend::text(), SciFigs::Legend::textColor(), QGpCoreTools::tr(), TRACE, SciFigs::Symbol::type(), and SciFigs::Pen::width().

{
  TRACE;
  if( !index.isValid()) return QVariant();
  switch (index.row()) {
  case 0:
    switch (role) {
    case Qt::DisplayRole:
      switch (column( index.column()) ) {
        case LegendTable::ColumnNull:
        case LegendTable::ColumnPenWidth:
        case LegendTable::ColumnPenStyle:
        case LegendTable::ColumnSymbolSize:
        case LegendTable::ColumnSymbolPenWidth:
        case LegendTable::ColumnSymbolPenStyle:
        case LegendTable::ColumnSymbolBrushStyle:
          break;
        case LegendTable::ColumnPenColor: return tr("Pen");
        case LegendTable::ColumnSymbolType: return tr("Symbol");
        case LegendTable::ColumnSymbolPenColor: return tr("Symbol pen");
        case LegendTable::ColumnSymbolBrushColor: return tr("Symbol brush");
        case LegendTable::ColumnText:
        case LegendTable::ColumnTextColor: return tr("Text");
      }
      return QVariant();
    case Qt::BackgroundRole:
      return QColor(239,239,239);
    case Qt::TextAlignmentRole:
      return (int) (Qt::AlignHCenter | Qt::AlignVCenter);
    default:
      return QVariant();
    }
    break;
  case 1:
    switch (role) {
    case Qt::DisplayRole:
      switch (column( index.column()) ) {
        case LegendTable::ColumnNull:
        case LegendTable::ColumnPenColor: return tr("Color");
        case LegendTable::ColumnPenWidth: return tr("Width");
        case LegendTable::ColumnPenStyle: return tr("Style");
        case LegendTable::ColumnSymbolType: return tr("Type");
        case LegendTable::ColumnSymbolSize: return tr("Size");
        case LegendTable::ColumnSymbolPenColor: return tr("Color");
        case LegendTable::ColumnSymbolPenWidth: return tr("Width");
        case LegendTable::ColumnSymbolPenStyle: return tr("Style");
        case LegendTable::ColumnSymbolBrushColor: return tr("Color");
        case LegendTable::ColumnSymbolBrushStyle: return tr("Style");
        case LegendTable::ColumnTextColor: return tr("Color");
        case LegendTable::ColumnText: return tr("Text");
      }
      return QVariant();
    case Qt::BackgroundRole:
      return QColor(245,245,245);
    case Qt::TextAlignmentRole:
      return (int) (Qt::AlignHCenter | Qt::AlignVCenter);
    default:
      return QVariant();
    }
    break;
  default: {
      int row=index.row()-2;
      switch (role) {
      case Qt::DisplayRole:
        switch (column( index.column()) ) {
        case LegendTable::ColumnNull: break;
        case LegendTable::ColumnPenColor:
          return _legend->pen(row).color();
        case LegendTable::ColumnPenWidth:
          return _legend->pen(row).width();
        case LegendTable::ColumnPenStyle:
          return LegendTable::penItem(_legend->pen(row).style());
        case LegendTable::ColumnSymbolType:
          return LegendTable::symbolItem(_legend->symbol(row).type());
        case LegendTable::ColumnSymbolSize:
          return _legend->symbol(row).size();
        case LegendTable::ColumnSymbolPenColor:
          return _legend->symbol(row).pen().color();
        case LegendTable::ColumnSymbolPenWidth:
          return _legend->symbol(row).pen().width();
        case LegendTable::ColumnSymbolPenStyle:
          return LegendTable::penItem(_legend->symbol(row).pen().style());
        case LegendTable::ColumnSymbolBrushColor:
          return _legend->symbol(row).brush().color();
        case LegendTable::ColumnSymbolBrushStyle:
          return LegendTable::brushItem(_legend->symbol(row).brush().style());
        case LegendTable::ColumnTextColor:
          return _legend->textColor(row);
        case LegendTable::ColumnText:
          return _legend->text(row);
        }
        return QVariant();
      case Qt::TextAlignmentRole:
        if(column( index.column())!=LegendTable::ColumnText) {
          return (int) (Qt::AlignHCenter | Qt::AlignVCenter);
        } else {
          return QVariant();
        }
      default:
        return QVariant();
      }
    }
    break;
  }
}
Qt::ItemFlags SciFigs::LegendTableItem::flags ( const QModelIndex &  index) const [virtual]
bool SciFigs::LegendTableItem::oneColor ( ) const [inline]
{return _oneColor;}
bool SciFigs::LegendTableItem::readOnlyText ( ) const [inline]
{return _readOnlyText;}
int SciFigs::LegendTableItem::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

References SciFigs::Legend::count(), and TRACE.

{
  TRACE;
  if( !parent.isValid() && _legend)
    return 2+_legend->count();
  return 2;
}
void SciFigs::LegendTableItem::setColumnIndexes ( const QHash< int, LegendTable::Column > *  columnIndexes)

References TRACE.

{
  TRACE;
  _columnIndexes=columnIndexes;
  reset();
}
bool SciFigs::LegendTableItem::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

References SciFigs::Symbol::brush(), SciFigs::LegendTable::brushStyle(), columnCount(), SciFigs::LegendTable::ColumnNull, SciFigs::LegendTable::ColumnPenColor, SciFigs::LegendTable::ColumnPenStyle, SciFigs::LegendTable::ColumnPenWidth, SciFigs::LegendTable::ColumnSymbolBrushColor, SciFigs::LegendTable::ColumnSymbolBrushStyle, SciFigs::LegendTable::ColumnSymbolPenColor, SciFigs::LegendTable::ColumnSymbolPenStyle, SciFigs::LegendTable::ColumnSymbolPenWidth, SciFigs::LegendTable::ColumnSymbolSize, SciFigs::LegendTable::ColumnSymbolType, SciFigs::LegendTable::ColumnText, SciFigs::LegendTable::ColumnTextColor, SciFigs::Symbol::pen(), SciFigs::Legend::pen(), SciFigs::LegendTable::penStyle(), SciFigs::Symbol::setBrush(), SciFigs::Pen::setColor(), SciFigs::Symbol::setPen(), SciFigs::Legend::setPen(), SciFigs::Symbol::setSize(), SciFigs::Pen::setStyle(), SciFigs::Legend::setSymbol(), SciFigs::Legend::setText(), SciFigs::Legend::setTextColor(), SciFigs::Symbol::setType(), SciFigs::Pen::setWidth(), SciFigs::Legend::symbol(), SciFigs::LegendTable::symbolType(), and TRACE.

{
  TRACE;
  if( !index.isValid() || index.row()<2) return false;
  int row=index.row()-2;
  switch (role) {
  case Qt::EditRole:
    switch (column( index.column()) ) {
    case LegendTable::ColumnNull: return false;
    case LegendTable::ColumnPenColor: {
        if(_oneColor) {
          setColor(row, value.value<QColor>());
        } else {
          Pen p=_legend->pen(row);
          p.setColor(value.value<QColor>());
          _legend->setPen(row, p);
        }
      }
      break;
    case LegendTable::ColumnPenWidth: {
        Pen p=_legend->pen(row);
        p.setWidth(value.toDouble());
        _legend->setPen(row, p);
      }
      break;
    case LegendTable::ColumnPenStyle: {
        Pen p=_legend->pen(row);
        p.setStyle(LegendTable::penStyle(value.toInt()) );
        _legend->setPen(row, p);
      }
      break;
    case LegendTable::ColumnSymbolType: {
        Symbol s=_legend->symbol(row);
        s.setType(LegendTable::symbolType(value.toInt()) );
        _legend->setSymbol(row, s);
      }
      break;
    case LegendTable::ColumnSymbolSize: {
        Symbol s=_legend->symbol(row);
        s.setSize(value.toDouble());
        _legend->setSymbol(row, s);
      }
      break;
    case LegendTable::ColumnSymbolPenColor: {
        if(_oneColor) {
          setColor(row, value.value<QColor>());
        } else {
          Symbol s=_legend->symbol(row);
          Pen p=s.pen();
          p.setColor(value.value<QColor>());
          s.setPen(p);
          _legend->setSymbol(row, s);
        }
      }
      break;
    case LegendTable::ColumnSymbolPenWidth: {
        Symbol s=_legend->symbol(row);
        Pen p=s.pen();
        p.setWidth(value.toDouble());
        s.setPen(p);
        _legend->setSymbol(row, s);
      }
      break;
    case LegendTable::ColumnSymbolPenStyle: {
        Symbol s=_legend->symbol(row);
        Pen p=s.pen();
        p.setStyle(LegendTable::penStyle(value.toInt()) );
        s.setPen(p);
        _legend->setSymbol(row, s);
      }
      break;
    case LegendTable::ColumnSymbolBrushColor: {
        if(_oneColor) {
          setColor(row, value.value<QColor>());
        } else {
          Symbol s=_legend->symbol(row);
          Brush b=s.brush();
          b.setColor(value.value<QColor>());
          s.setBrush(b);
          _legend->setSymbol(row, s);
        }
      }
      break;
    case LegendTable::ColumnSymbolBrushStyle: {
        Symbol s=_legend->symbol(row);
        Brush b=s.brush();
        b.setStyle(LegendTable::brushStyle(value.toInt()) );
        s.setBrush(b);
        _legend->setSymbol(row, s);
      }
      break;
    case LegendTable::ColumnTextColor:
      if(_oneColor) {
        setColor(row, value.value<QColor>());
      } else {
        _legend->setTextColor(row, value.value<QColor>());
      }
      break;
    case LegendTable::ColumnText:
      _legend->setText(row, value.toString());
      break;
    }
    emit dataChanged(createIndex( row+2, 0), createIndex(row+2, columnCount()-1) );
    return true;
  default:
    return false;
  }
}

References TRACE.

{
  TRACE;
  _legend=legend;
  reset();
}
void SciFigs::LegendTableItem::setOneColor ( bool  oc) [inline]
{_oneColor=oc;}
void SciFigs::LegendTableItem::setReadOnlyText ( bool  ro) [inline]
{_readOnlyText=ro;}

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