Ejemplo n.º 1
0
void EditActions::addStep() {
    Step* step = new Step();

    QUndoCommand* parentCommand = new QUndoCommand();
    parentCommand->setText(i18nc("@action", "Add step"));
    TutorialCommands(mTutorialEditor->tutorial()).addStep(step, parentCommand);

    StepDataWidget* widget = new StepDataWidget(step);
    widget->enableStepIdCompletion(mTutorialEditor->tutorial());
    widget->setParentUndoCommand(parentCommand);
    if (showEditionDialog(widget) == QDialog::Rejected) {
        delete parentCommand;
    }
}
Ejemplo n.º 2
0
void ObjectContainer::rendererModification(std::vector<QJsonObject> data)
{
	QUndoCommand * transformation = new QUndoCommand();
	transformation->setText("Modify via 3D view");

	for (const auto& json : data)
	{
		ObjectItem* item = getItem(json["id"].toInt());
		if (!item)
			continue;
		new ModifyObjectCmd(item->data().toJsonObject(), json, item, Position | Scaling | Rotation, transformation); // Add command to command group
	}

	g_undoStack.push(transformation);
}
Ejemplo n.º 3
0
void EditActions::addReaction() {
    Q_ASSERT(mCurrentStep);

    Reaction* reaction = new Reaction();

    QUndoCommand* parentCommand = new QUndoCommand();
    parentCommand->setText(i18nc("@action", "Add reaction"));
    StepCommands(mCurrentStep).addReaction(reaction, parentCommand);

    ReactionWidget* widget = new ReactionWidget(reaction);
    widget->enableStepIdCompletion(mTutorialEditor->tutorial(), mCurrentStep);
    widget->setParentUndoCommand(parentCommand);
    if (showEditionDialog(widget) == QDialog::Rejected) {
        delete parentCommand;
    }
}
Ejemplo n.º 4
0
/**
 * Duplicates the currently selected layer.
 */
void MapDocument::duplicateLayer()
{
    if (!mCurrentLayer)
        return;

    Layer *duplicate = mCurrentLayer->clone();
    duplicate->setName(tr("Copy of %1").arg(duplicate->name()));

    if (duplicate->layerType() == Layer::ObjectGroupType)
        static_cast<ObjectGroup*>(duplicate)->resetObjectIds();

    auto parentLayer = mCurrentLayer ? mCurrentLayer->parentLayer() : nullptr;
    const int index = layerIndex(mCurrentLayer) + 1;
    QUndoCommand *cmd = new AddLayer(this, index, duplicate, parentLayer);
    cmd->setText(tr("Duplicate Layer"));
    mUndoStack->push(cmd);
    setCurrentLayer(duplicate);
}
Ejemplo n.º 5
0
void QUndoStack::beginMacro(const QString &text)
{
    Q_D(QUndoStack);
    QUndoCommand *cmd = new QUndoCommand();
    cmd->setText(text);

    if (d->macro_stack.isEmpty()) {
        while (d->index < d->command_list.size())
            delete d->command_list.takeLast();
        if (d->clean_index > d->index)
            d->clean_index = -1; // we've deleted the clean state
        d->command_list.append(cmd);
    } else {
        d->macro_stack.last()->d->child_list.append(cmd);
    }
    d->macro_stack.append(cmd);

    if (d->macro_stack.count() == 1) {
        emit canUndoChanged(false);
        emit undoTextChanged(QString());
        emit canRedoChanged(false);
        emit redoTextChanged(QString());
    }
}
Ejemplo n.º 6
0
static PyObject *meth_QUndoCommand_setText(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        QUndoCommand *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QUndoCommand, &sipCpp, sipType_QString,&a0, &a0State))
        {
            sipCpp->setText(*a0);
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QUndoCommand, sipName_setText, doc_QUndoCommand_setText);

    return NULL;
}