Brief description of class still missing. More...
#include <SourceDelegate.h>
Public Slots | |
| void | colorClicked (const QModelIndex &index) |
Public Member Functions | |
| virtual QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &style, const QModelIndex &index) const |
| virtual void | paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| virtual void | setEditorData (QWidget *editor, const QModelIndex &index) const |
| virtual void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
| void | setSourceType (SourceParameters::Type t) |
| virtual QSize | sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const |
| SourceDelegate (QObject *parent) | |
| ~SourceDelegate () | |
Brief description of class still missing.
Full description of class still missing
| SourceDelegate::SourceDelegate | ( | QObject * | parent | ) |
References SourceParameters::PlaneWaves, and TRACE.
: QItemDelegate(parent)
{
TRACE;
_sourceType=SourceParameters::PlaneWaves;
}
| void SourceDelegate::colorClicked | ( | const QModelIndex & | index | ) | [slot] |
References SourceParameters::CircularWaves, SourceParameters::PlaneWaves, and TRACE.
{
TRACE;
if((index.column()==5 && _sourceType==SourceParameters::PlaneWaves) ||
(index.column()==8 && _sourceType==SourceParameters::CircularWaves)) {
QColor c=index.model()->data(index).value<QColor>();
c=QColorDialog::getColor(c, Application::activeWindow());
if(c.isValid()) {
const_cast<QAbstractItemModel *>(index.model())->setData(index, c);
}
}
}
| QWidget * SourceDelegate::createEditor | ( | QWidget * | parent, |
| const QStyleOptionViewItem & | style, | ||
| const QModelIndex & | index | ||
| ) | const [virtual] |
References SourceParameters::CircularWaves, and SourceParameters::PlaneWaves.
{
DoubleSpinBox * sb;
switch(_sourceType) {
case SourceParameters::PlaneWaves:
switch (index.column()) {
case 1:
case 3:
sb=new DoubleSpinBox(parent);
sb->setWrapping(true);
connect(sb,SIGNAL(valueChanged(double)), this, SLOT(commitSpin()));
sb->setMinimum(0.0);
sb->setMaximum(360.0);
return sb;
case 2:
case 4:
sb=new DoubleSpinBox(parent);
connect(sb,SIGNAL(valueChanged(double)), this, SLOT(commitSpin()));
sb->setMinimum(0.0);
sb->setMaximum(1e99);
return sb;
case 5:
return QItemDelegate::createEditor(parent, style, index);
case 0:
default:
break;
}
break;
case SourceParameters::CircularWaves:
switch (index.column()) {
case 1:
case 6:
sb=new DoubleSpinBox(parent);
sb->setWrapping(true);
connect(sb,SIGNAL(valueChanged(double)), this, SLOT(commitSpin()));
sb->setMinimum(0.0);
sb->setMaximum(360.0);
return sb;
case 2:
case 5:
case 7:
sb=new DoubleSpinBox(parent);
connect(sb,SIGNAL(valueChanged(double)), this, SLOT(commitSpin()));
sb->setMinimum(0.0);
sb->setMaximum(1e99);
return sb;
case 8:
return QItemDelegate::createEditor(parent, style, index);
case 3:
case 4:
sb=new DoubleSpinBox(parent);
connect(sb,SIGNAL(valueChanged(double)), this, SLOT(commitSpin()));
sb->setMinimum(-1e99);
sb->setMaximum(1e99);
return sb;
case 0:
default:
break;
}
break;
}
return new QLineEdit(parent);
}
| void SourceDelegate::paint | ( | QPainter * | painter, |
| const QStyleOptionViewItem & | option, | ||
| const QModelIndex & | index | ||
| ) | const [virtual] |
References SourceParameters::CircularWaves, SourceParameters::PlaneWaves, and TRACE.
{
TRACE;
if((index.column()==5 && _sourceType==SourceParameters::PlaneWaves) ||
(index.column()==8 && _sourceType==SourceParameters::CircularWaves)) {
QPoint p=option.rect.center();
drawBackground(painter, option, index);
QColor c=index.model() ->data(index).value<QColor>();
painter->fillRect(p.x()-8, p.y()-8, 16, 16 , c);
} else {
QItemDelegate::paint(painter, option, index);
}
}
| void SourceDelegate::setEditorData | ( | QWidget * | editor, |
| const QModelIndex & | index | ||
| ) | const [virtual] |
References SourceParameters::CircularWaves, SourceParameters::PlaneWaves, and TRACE.
{
TRACE;
DoubleSpinBox * sb;
QLineEdit * le;
switch(_sourceType) {
case SourceParameters::PlaneWaves:
switch (index.column()) {
case 1:
case 3:
case 2:
case 4:
sb=qobject_cast<DoubleSpinBox *>(editor);
if( !sb) return;
sb->setValue(index.model()->data(index).toDouble());
break;
case 5:
QItemDelegate::setEditorData(editor, index);
break;
case 0:
default:
le=qobject_cast<QLineEdit *>(editor);
if( !le) return;
le->setText(index.model()->data(index).toString());
le->selectAll();
break;
}
break;
case SourceParameters::CircularWaves:
switch (index.column()) {
case 1:
case 6:
case 2:
case 5:
case 7:
case 3:
case 4:
sb=qobject_cast<DoubleSpinBox *>(editor);
if( !sb) return;
sb->setValue(index.model() ->data(index).toDouble());
break;
case 8:
QItemDelegate::setEditorData(editor, index);
break;
case 0:
default:
le=qobject_cast<QLineEdit *>(editor);
if( !le) return;
le->setText(index.model() ->data(index).toString());
le->selectAll();
break;
}
break;
}
}
| void SourceDelegate::setModelData | ( | QWidget * | editor, |
| QAbstractItemModel * | model, | ||
| const QModelIndex & | index | ||
| ) | const [virtual] |
References SourceParameters::CircularWaves, SourceParameters::PlaneWaves, TRACE, and QGpGuiTools::DoubleSpinBox::value().
{
TRACE;
DoubleSpinBox * sb;
QLineEdit * le;
switch(_sourceType) {
case SourceParameters::PlaneWaves:
switch (index.column()) {
case 1:
case 3:
case 2:
case 4:
sb=qobject_cast<DoubleSpinBox *>(editor);
if( !sb) return ;
model->setData(index, sb->value());
break;
case 5:
break;
case 0:
default:
le=qobject_cast<QLineEdit *>(editor);
if( !le) return;
model->setData(index, le->text());
break;
}
break;
case SourceParameters::CircularWaves:
switch (index.column()) {
case 1:
case 6:
case 2:
case 5:
case 7:
case 3:
case 4:
sb=qobject_cast<DoubleSpinBox *>(editor);
if( !sb) return ;
model->setData(index, sb->value());
break;
case 8:
break;
case 0:
default:
le=qobject_cast<QLineEdit *>(editor);
if( !le) return;
model->setData(index, le->text());
break;
}
break;
}
}
| void SourceDelegate::setSourceType | ( | SourceParameters::Type | t | ) | [inline] |
{_sourceType=t;}
| QSize SourceDelegate::sizeHint | ( | const QStyleOptionViewItem & | option, |
| const QModelIndex & | index | ||
| ) | const [virtual] |
References SourceParameters::CircularWaves, SourceParameters::PlaneWaves, and TRACE.
{
TRACE;
switch(_sourceType) {
case SourceParameters::PlaneWaves:
switch (index.column()) {
case 5:
return QSize(30, 0);
default:
break;
}
break;
case SourceParameters::CircularWaves:
switch (index.column()) {
case 8:
return QSize(30, 0);
default:
break;
}
break;
}
return QItemDelegate::sizeHint(option, index);
}