All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Slots | Signals | Public Member Functions
SciFigs::LegendTableDelegate Class Reference

Brief description of class still missing. More...

#include <LegendTableDelegate.h>

List of all members.

Public Slots

void colorClicked (const QModelIndex &index)

Signals

void dataChanged () const

Public Member Functions

virtual QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
 LegendTableDelegate (QObject *parent=0)
virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setColumnIndexes (const QHash< int, LegendTable::Column > *columnIndexes)
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
virtual QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

SciFigs::LegendTableDelegate::LegendTableDelegate ( QObject *  parent = 0) [inline]
: QItemDelegate(parent) {}

Member Function Documentation

void SciFigs::LegendTableDelegate::colorClicked ( const QModelIndex &  index) [slot]
QWidget * SciFigs::LegendTableDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

References 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::LegendTable::initBrushStyles(), SciFigs::LegendTable::initPenStyles(), SciFigs::LegendTable::initSymbolTypes(), TRACE, and w.

{
  TRACE;
  switch (column( index.column()) ) {
  case LegendTable::ColumnNull: return 0;
  case LegendTable::ColumnText: {
      QLineEdit * w=new QLineEdit(parent);
      return w;
    }
  case LegendTable::ColumnPenColor:
  case LegendTable::ColumnSymbolPenColor:
  case LegendTable::ColumnSymbolBrushColor:
  case LegendTable::ColumnTextColor:
    return QItemDelegate::createEditor(parent, option, index);
  case LegendTable::ColumnPenWidth:
  case LegendTable::ColumnSymbolSize:
  case LegendTable::ColumnSymbolPenWidth: {
      DoubleSpinBox * w=new DoubleSpinBox(parent);
      w->setSingleStep(0.1);
      w->setMinimum(0.0);
      w->setMaximum(100.0);
      connect(w, SIGNAL(valueChanged(double)), this, SLOT(commitWidget()) );
      return w;
    }
  case LegendTable::ColumnPenStyle:
  case LegendTable::ColumnSymbolPenStyle: {
      QComboBox * w=new QComboBox(parent);
      connect(w, SIGNAL(activated(int)), this, SLOT(commitWidget()) );
      LegendTable::initPenStyles(w);
      return w;
    }
  case LegendTable::ColumnSymbolType: {
      QComboBox * w=new QComboBox(parent);
      connect(w, SIGNAL(activated(int)), this, SLOT(commitWidget()) );
      LegendTable::initSymbolTypes(w);
      return w;
    }
  case LegendTable::ColumnSymbolBrushStyle: {
      QComboBox * w=new QComboBox(parent);
      connect(w, SIGNAL(activated(int)), this, SLOT(commitWidget()) );
      LegendTable::initBrushStyles(w);
      return w;
    }
  }
  return 0;
}

Referenced by colorClicked(), and setModelData().

void SciFigs::LegendTableDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

References 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::paint(), and TRACE.

{
  TRACE;
  if(index.row()<2) {
    QItemDelegate::paint(painter, option, index);
  } else {
    QPoint p=option.rect.center();
    switch (column( index.column()) ) {
    case LegendTable::ColumnNull:
    case LegendTable::ColumnText:
    case LegendTable::ColumnPenWidth:
    case LegendTable::ColumnSymbolSize:
    case LegendTable::ColumnSymbolPenWidth:
      QItemDelegate::paint(painter, option, index);
      break;
    case LegendTable::ColumnPenColor:
    case LegendTable::ColumnSymbolPenColor:
    case LegendTable::ColumnSymbolBrushColor:
    case LegendTable::ColumnTextColor: {
        drawBackground(painter, option, index);
        QColor c=index.model() ->data(index).value<QColor>();
        painter->fillRect(p.x()-8, p.y()-8, 16, 16 , c);
      }
      break;
    case LegendTable::ColumnPenStyle:
    case LegendTable::ColumnSymbolPenStyle: {
        drawBackground(painter, option, index);
        Qt::PenStyle s=(Qt::PenStyle) index.model() ->data(index).toInt();
        painter->fillRect(p.x()-16, p.y()-8, 32, 16, Qt::white);
        painter->setPen(QPen( Qt::black, 0, s) );
        painter->drawLine(p.x()-16, p.y(), p.x()+16, p.y());
      }
      break;
    case LegendTable::ColumnSymbolType: {
        drawBackground(painter, option, index);
        Symbol::Type t=(Symbol::Type) index.model() ->data(index).toInt();
        painter->fillRect(p.x()-8, p.y()-8, 16, 16, Qt::white);
        Symbol s(t, 3.5);
        s.paint( *painter, QPointF(p.x()-1, p.y()-1));
      }
      break;
    case LegendTable::ColumnSymbolBrushStyle: {
        drawBackground(painter, option, index);
        Qt::BrushStyle s=(Qt::BrushStyle) index.model() ->data(index).toInt();
        painter->fillRect(p.x()-8, p.y()-8, 16, 16, Qt::white);
        painter->setPen(QPen( Qt::NoPen) );
        painter->setBrush(QBrush( Qt::black, s) );
        painter->drawRect(p.x()-8, p.y()-8, 16, 16);
      }
      break;
    }
  }
}
void SciFigs::LegendTableDelegate::setColumnIndexes ( const QHash< int, LegendTable::Column > *  columnIndexes)

References TRACE.

{
  TRACE;
  _columnIndexes=columnIndexes;
}
void SciFigs::LegendTableDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const [virtual]

References 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, TRACE, and w.

{
  TRACE;
  switch (column( index.column()) ) {
  case LegendTable::ColumnNull: break;
  case LegendTable::ColumnText: {
      QLineEdit * w=qobject_cast<QLineEdit *>(editor);
      ASSERT(w);
      w->setText(index.model() ->data(index).toString());
      w->selectAll();
    }
    break;
  case LegendTable::ColumnPenColor:
  case LegendTable::ColumnSymbolPenColor:
  case LegendTable::ColumnSymbolBrushColor:
  case LegendTable::ColumnTextColor:
    QItemDelegate::setEditorData(editor, index);
    break;
  case LegendTable::ColumnPenWidth:
  case LegendTable::ColumnSymbolSize:
  case LegendTable::ColumnSymbolPenWidth: {
      DoubleSpinBox * w=qobject_cast<DoubleSpinBox *>(editor);
      ASSERT(w);
      w->setValue(index.model() ->data(index).toDouble());
      break;
    }
  case LegendTable::ColumnPenStyle:
  case LegendTable::ColumnSymbolPenStyle:
  case LegendTable::ColumnSymbolType:
  case LegendTable::ColumnSymbolBrushStyle: {
      QComboBox * w=qobject_cast<QComboBox *>(editor);
      ASSERT(w);
      w->setCurrentIndex(index.model()->data(index).toInt());
      break;
    }
  }
}
void SciFigs::LegendTableDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const [virtual]

References 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, dataChanged(), TRACE, QGpGuiTools::DoubleSpinBox::value(), and w.

{
  TRACE;
  switch (column( index.column()) ) {
  case LegendTable::ColumnNull: break;
  case LegendTable::ColumnText: {
      QLineEdit * w=qobject_cast<QLineEdit *>(editor);
      ASSERT(w);
      if(w->isModified() && model->data(index)!=w->text()) {
        model->setData(index, w->text());
        emit dataChanged();
      }
    }
    break;
  case LegendTable::ColumnPenColor:
  case LegendTable::ColumnSymbolPenColor:
  case LegendTable::ColumnTextColor:
  case LegendTable::ColumnSymbolBrushColor:
    break;
  case LegendTable::ColumnPenWidth:
  case LegendTable::ColumnSymbolSize:
  case LegendTable::ColumnSymbolPenWidth: {
      DoubleSpinBox * w=qobject_cast<DoubleSpinBox *>(editor);
      ASSERT(w);
      QVariant oldValue=model->data(index);
      if(oldValue!=w->value()) {
        model->setData(index, w->value());
        emit dataChanged();
      }
      break;
    }
  case LegendTable::ColumnPenStyle:
  case LegendTable::ColumnSymbolPenStyle:
  case LegendTable::ColumnSymbolType:
  case LegendTable::ColumnSymbolBrushStyle: {
      QComboBox * w=qobject_cast<QComboBox *>(editor);
      ASSERT(w);
      QVariant oldValue=model->data(index);
      if(oldValue!=w->currentIndex()) {
        model->setData(index, w->currentIndex());
        emit dataChanged();
      }
      break;
    }
  }
}
QSize SciFigs::LegendTableDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

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