Exemplo n.º 1
0
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
    const QModelIndex& index) const
{
    NastyTableModelHack hack (*model);
    QStyledItemDelegate::setModelData (editor, &hack, index);
    mUndoStack.push (new CSMWorld::ModifyCommand (*model, index, hack.getData()));
}
Exemplo n.º 2
0
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
    const QModelIndex& index) const
{
    NastyTableModelHack hack (*model);
    QStyledItemDelegate::setModelData (editor, &hack, index);

    QVariant new_ = hack.getData();

    if ((model->data (index)!=new_) && (model->flags(index) & Qt::ItemIsEditable))
        getUndoStack().push (new CSMWorld::ModifyCommand (*model, index, new_));
}
Exemplo n.º 3
0
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
    const QModelIndex& index) const
{
    if (!mCommandDispatcher)
        return;

    QVariant new_;
    // Color columns use a custom editor, so we need explicitly extract a data from it
    CSVWidget::ColorEditor *colorEditor = qobject_cast<CSVWidget::ColorEditor *>(editor);
    if (colorEditor != NULL)
    {
        new_ = colorEditor->color();
    }
    else
    {
        NastyTableModelHack hack (*model);
        QStyledItemDelegate::setModelData (editor, &hack, index);
        new_ = hack.getData();
    }

    if ((model->data (index)!=new_) && (model->flags(index) & Qt::ItemIsEditable))
        mCommandDispatcher->executeModify (model, index, new_);
}
Exemplo n.º 4
0
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
    const QModelIndex& index) const
{
    if (!mCommandDispatcher)
        return;

    QVariant variant;

    // Color columns use a custom editor, so we need to fetch selected color from it.
    CSVWidget::ColorEditor *colorEditor = qobject_cast<CSVWidget::ColorEditor *>(editor);
    if (colorEditor != nullptr)
    {
        variant = colorEditor->colorInt();
    }
    else
    {
        NastyTableModelHack hack (*model);
        QStyledItemDelegate::setModelData (editor, &hack, index);
        variant = hack.getData();
    }

    if ((model->data (index)!=variant) && (model->flags(index) & Qt::ItemIsEditable))
        mCommandDispatcher->executeModify (model, index, variant);
}