//------------------------------------------------------------------------------ void AssignmentRuleTest::updateCondition() { AssignmentRule* rule(ruleWithMultipleConditions); QUndoCommand* cmd = rule->updateCondition(1, AssignmentRule::Condition(AssignmentRule::Date, AssignmentRule::Before, false, "5/5/13")); // Assert pre-conditions QCOMPARE(rule->conditionCount(), 2); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); QCOMPARE(rule->conditionAt(1).field, AssignmentRule::DepositAccount); QCOMPARE(rule->conditionAt(1).op, AssignmentRule::BeginsWith); QCOMPARE(rule->conditionAt(1).value, QString("Condition2")); cmd->redo(); QCOMPARE(rule->conditionCount(), 2); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); QCOMPARE(rule->conditionAt(1).field, AssignmentRule::Date); QCOMPARE(rule->conditionAt(1).op, AssignmentRule::Before); QCOMPARE(rule->conditionAt(1).value, QString("5/5/13")); cmd->undo(); QCOMPARE(rule->conditionCount(), 2); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); QCOMPARE(rule->conditionAt(1).field, AssignmentRule::DepositAccount); QCOMPARE(rule->conditionAt(1).op, AssignmentRule::BeginsWith); QCOMPARE(rule->conditionAt(1).value, QString("Condition2")); }
//------------------------------------------------------------------------------ void AssignmentRuleTest::addCondition() { QFETCH(uint, ruleId); QFETCH(int, oldCount); QFETCH(int, newCount); QFETCH(int, newIndex); QFETCH(int, existingIndex); AssignmentRule* rule = rules->find(ruleId); QUndoCommand* cmd = rule->addCondition(); QCOMPARE(rule->conditionCount(), oldCount); AssignmentRule::Field field; if (existingIndex >= 0) { field = rule->conditionAt(existingIndex).field; } cmd->redo(); QCOMPARE(rule->conditionCount(), newCount); QCOMPARE(rule->conditionAt(newIndex).field, AssignmentRule::FieldNotDefined); if (existingIndex >= 0) { QCOMPARE(rule->conditionAt(existingIndex).field, field); } cmd->undo(); QCOMPARE(rule->conditionCount(), oldCount); if (existingIndex >= 0) { QCOMPARE(rule->conditionAt(existingIndex).field, field); } }
void KarbonPathRefineCommand::redo() { // check if we have to create the insert points commands if (! d->initialized) { // create insert point commands, one for each point to insert // into each segment for (uint iteration = 0; iteration < d->insertCount; ++iteration) { // in each iteration collect the (iteration+1)th point which starts a segments // into which we insert the point of this iteration QList<KoPathPointData> pointData; // calculate the segment position where to insert the point qreal insertPosition = 1.0 / (d->insertCount + 1 - iteration); int subpathCount = d->path->subpathCount(); // iterate over the paths subpaths for (int subpathIndex = 0; subpathIndex < subpathCount; ++subpathIndex) { int pointCount = d->path->subpathPointCount(subpathIndex); // iterate over the subpaths points for (int pointIndex = 0; pointIndex < pointCount; ++pointIndex) { // we only collect the (iteration+1)th point if ((pointIndex + 1) % (iteration + 1) != 0) continue; pointData.append(KoPathPointData(d->path, KoPathPointIndex(subpathIndex, pointIndex))); } } // create the command and execute it QUndoCommand * cmd = new KoPathPointInsertCommand(pointData, insertPosition, this); cmd->redo(); } d->initialized = true; } else { QUndoCommand::redo(); } d->path->update(); }
//------------------------------------------------------------------------------ void AssignmentRuleTest::removeConditionFromRuleWithNone() { AssignmentRule* rule(ruleWithNoConditions); QUndoCommand* cmd = rule->removeCondition(0); QCOMPARE(rule->conditionCount(), 0); cmd->redo(); QCOMPARE(rule->conditionCount(), 0); cmd->undo(); QCOMPARE(rule->conditionCount(), 0); }
//------------------------------------------------------------------------------ void AssignmentRuleTest::removeConditionFromRuleWithOne() { AssignmentRule* rule(ruleWithOneCondition); QUndoCommand* cmd = rule->removeCondition(0); QCOMPARE(rule->conditionCount(), 1); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); cmd->redo(); QCOMPARE(rule->conditionCount(), 0); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::FieldNotDefined); cmd->undo(); QCOMPARE(rule->conditionCount(), 1); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); }
void TestShapeReorderCommand::testMoveDownOverlapping() { #if 0 // disable a current alogrithm does not yet support this MockShape shape1, shape2, shape3, shape4, shape5; shape1.setSize(QSizeF(100, 100)); shape1.setZIndex(1); shape2.setSize(QSizeF(100, 100)); shape2.setZIndex(2); shape3.setSize(QSizeF(300, 300)); shape3.setZIndex(3); shape4.setSize(QSizeF(100, 100)); shape4.setPosition(QPointF(200,200)); shape4.setZIndex(4); shape5.setSize(QSizeF(100, 100)); shape5.setPosition(QPointF(200,200)); shape5.setZIndex(5); QList<KShape*> shapes; shapes.append(&shape1); shapes.append(&shape2); shapes.append(&shape3); shapes.append(&shape4); shapes.append(&shape5); MockCanvas canvas; KShapeManager manager(&canvas, shapes); QVERIFY(shape1.zIndex() < shape2.zIndex()); QVERIFY(shape2.zIndex() < shape3.zIndex()); QVERIFY(shape3.zIndex() < shape4.zIndex()); QVERIFY(shape4.zIndex() < shape5.zIndex()); QList<KShape*> selectedShapes; selectedShapes.append(&shape5); QUndoCommand * cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::LowerShape); cmd->redo(); delete cmd; QVERIFY(shape1.zIndex() < shape2.zIndex()); QVERIFY(shape2.zIndex() < shape3.zIndex()); QVERIFY(shape3.zIndex() < shape4.zIndex()); QVERIFY(shape4.zIndex() > shape5.zIndex()); QVERIFY(shape3.zIndex() > shape5.zIndex()); #endif }
//------------------------------------------------------------------------------ void AssignmentRuleTest::removeConditionFromRuleWithMany() { AssignmentRule* rule(ruleWithMultipleConditions); QUndoCommand* cmd = rule->removeCondition(0); QCOMPARE(rule->conditionCount(), 2); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); QCOMPARE(rule->conditionAt(1).field, AssignmentRule::DepositAccount); cmd->redo(); QCOMPARE(rule->conditionCount(), 1); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::DepositAccount); cmd->undo(); QCOMPARE(rule->conditionCount(), 2); QCOMPARE(rule->conditionAt(0).field, AssignmentRule::Payee); QCOMPARE(rule->conditionAt(1).field, AssignmentRule::DepositAccount); }
void CUndoRedoStack::redo() { QUndoCommand* topCmd = d->redoStack.count() ? d->redoStack.pop() : 0; if(!topCmd) return; QString cmdText = topCmd->text(); topCmd->redo(); d->undoStack.push(topCmd); qWarning("Redo: %s", qPrintable(cmdText)); // emit change notifications. emit redone(cmdText); emit canUndoChanged(d->undoStack.count()); emit canRedoChanged(d->redoStack.count()); }
void TestShapeReorderCommand::testMoveUpOverlapping() { MockShape shape1, shape2, shape3, shape4, shape5; shape1.setSize(QSizeF(100, 100)); shape1.setZIndex(1); shape2.setSize(QSizeF(100, 100)); shape2.setZIndex(2); shape3.setSize(QSizeF(300, 300)); shape3.setZIndex(3); shape4.setSize(QSizeF(100, 100)); shape4.setPosition(QPointF(200,200)); shape4.setZIndex(4); shape5.setSize(QSizeF(100, 100)); shape5.setPosition(QPointF(200,200)); shape5.setZIndex(5); QList<KShape*> shapes; shapes.append(&shape1); shapes.append(&shape2); shapes.append(&shape3); shapes.append(&shape4); shapes.append(&shape5); MockCanvas canvas; KShapeManager manager(&canvas, shapes); QVERIFY(shape1.zIndex() < shape2.zIndex()); QVERIFY(shape2.zIndex() < shape3.zIndex()); QVERIFY(shape3.zIndex() < shape4.zIndex()); QVERIFY(shape4.zIndex() < shape5.zIndex()); QList<KShape*> selectedShapes; selectedShapes.append(&shape1); QUndoCommand * cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::RaiseShape); cmd->redo(); delete cmd; QVERIFY(shape1.zIndex() > shape2.zIndex()); QVERIFY(shape2.zIndex() < shape3.zIndex()); QVERIFY(shape1.zIndex() < shape3.zIndex()); QVERIFY(shape3.zIndex() < shape4.zIndex()); QVERIFY(shape4.zIndex() < shape5.zIndex()); }
void ImportCommand::undo() { if ( !folder().isEmpty() ) { // we created a group -> just delete it DeleteCommand cmd(m_model, m_group); cmd.redo(); } else { // we imported at the root -> delete everything KBookmarkGroup root = GlobalBookmarkManager::self()->root(); QUndoCommand *cmd = DeleteCommand::deleteAll(m_model, root); cmd->redo(); delete cmd; // and recreate what was there before m_cleanUpCmd->undo(); } }
static PyObject *meth_QUndoCommand_redo(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf)); { QUndoCommand *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QUndoCommand, &sipCpp)) { (sipSelfWasArg ? sipCpp->QUndoCommand::redo() : sipCpp->redo()); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QUndoCommand, sipName_redo, doc_QUndoCommand_redo); return NULL; }
void TestShapeReorderCommand::testSendToBack() { MockShape shape1, shape2, shape3; shape1.setSize(QSizeF(100, 100)); shape1.setZIndex(1); shape2.setSize(QSizeF(100, 100)); shape2.setZIndex(2); shape3.setSize(QSizeF(100, 100)); shape3.setZIndex(3); QList<KShape*> shapes; shapes.append(&shape1); shapes.append(&shape2); shapes.append(&shape3); MockCanvas canvas; KShapeManager manager(&canvas, shapes); qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&shape1), 0); QCOMPARE(shapes.indexOf(&shape2), 1); QCOMPARE(shapes.indexOf(&shape3), 2); QList<KShape*> selectedShapes; selectedShapes.append(&shape3); QUndoCommand * cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::SendToBack); cmd->redo(); qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&shape3), 0); QCOMPARE(shapes.indexOf(&shape1), 1); QCOMPARE(shapes.indexOf(&shape2), 2); delete cmd; }
void TestShapeReorderCommand::testSendToBackChildren() { MockShape shape1, shape2, shape3; shape1.setSize(QSizeF(100, 100)); shape1.setZIndex(1); shape2.setSize(QSizeF(100, 100)); shape2.setZIndex(2); shape3.setSize(QSizeF(100, 100)); shape3.setZIndex(3); MockContainer container; container.addShape(&shape1); container.addShape(&shape2); container.addShape(&shape3); QList<KShape*> shapes; shapes.append(&shape1); shapes.append(&shape2); shapes.append(&shape3); shapes.append(&container); MockCanvas canvas; KShapeManager manager(&canvas, shapes); qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&container), 0); // atm the parent is always lower than its children QCOMPARE(shapes.indexOf(&shape1), 1); QCOMPARE(shapes.indexOf(&shape2), 2); QCOMPARE(shapes.indexOf(&shape3), 3); QList<KShape*> selectedShapes; selectedShapes.append(&shape3); QUndoCommand * cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::SendToBack); cmd->redo(); delete cmd; qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&container), 0); // atm the parent is always lower than its children QCOMPARE(shapes.indexOf(&shape3), 1); QVERIFY(shape3.zIndex() < shape1.zIndex()); QCOMPARE(shapes.indexOf(&shape1), 2); QVERIFY(shape1.zIndex() < shape2.zIndex()); QCOMPARE(shapes.indexOf(&shape2), 3); selectedShapes.clear(); selectedShapes.append(&shape2); cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::SendToBack); cmd->redo(); delete cmd; qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&container), 0); // atm the parent is always lower than its children QCOMPARE(shapes.indexOf(&shape2), 1); QVERIFY(shape2.zIndex() < shape3.zIndex()); QCOMPARE(shapes.indexOf(&shape3), 2); QVERIFY(shape3.zIndex() < shape1.zIndex()); QCOMPARE(shapes.indexOf(&shape1), 3); selectedShapes.clear(); selectedShapes.append(&shape1); cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::SendToBack); cmd->redo(); delete cmd; qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&container), 0); // atm the parent is always lower than its children QCOMPARE(shapes.indexOf(&shape1), 1); QVERIFY(shape1.zIndex() < shape2.zIndex()); QCOMPARE(shapes.indexOf(&shape2), 2); QVERIFY(shape2.zIndex() < shape3.zIndex()); QCOMPARE(shapes.indexOf(&shape3), 3); }