資源簡介
qdraw.zip

代碼片段和文件信息
#include?“commands.h“
#include?
MoveShapeCommand::MoveShapeCommand(QGraphicsScene?*graphicsScene?const?QPointF?&delta?QUndoCommand?*parent)
????:?QUndoCommand(parent)
{
????myItem?=?0;
????myItems?=?graphicsScene->selectedItems();
????myGraphicsScene?=?graphicsScene;
????myDelta?=?delta;
????bMoved?=?true;
}
MoveShapeCommand::MoveShapeCommand(QGraphicsItem?*?item?const?QPointF?&delta?QUndoCommand?*parent)
????:?QUndoCommand(parent)
{
????myGraphicsScene?=?0;
????myItem?=?item;
????myDelta?=?delta;
????bMoved?=?true;
}
//!?[2]
void?MoveShapeCommand::undo()
{
????if?(?myItem?)
????????myItem->moveBy(-myDelta.x()-myDelta.y());
????else?if(?myItems.count()?>?0?){
????????foreach?(QGraphicsItem?*item?myItems)?{
???????????item->moveBy(-myDelta.x()-myDelta.y());
????????}
????}
????setText(Qobject::tr(“Undo?Move?%1%2“)
????????.arg(-myDelta.x()).arg(-myDelta.y()));
????bMoved?=?false;
}
//!?[2]
//!?[3]
void?MoveShapeCommand::redo()
{
????if?(?!bMoved?){
????????if?(?myItem?){
????????????myItem->moveBy(myDelta.x()myDelta.y());
????????????myItem->scene()->update();
????????}else?if(?myItems.count()?>?0?){
????????????foreach?(QGraphicsItem?*item?myItems)?{
???????????????item->moveBy(myDelta.x()myDelta.y());
????????????}
????????????myGraphicsScene->update();
????????}
????}
????setText(Qobject::tr(“Redo?Move?%1%2“)
????????.arg(myDelta.x()).arg(myDelta.y()));
}
//!?[3]
//!?[4]
RemoveShapeCommand::RemoveShapeCommand(QGraphicsScene?*scene?QUndoCommand?*parent)
????:?QUndoCommand(parent)
{
????myGraphicsScene?=?scene;
????items?=?myGraphicsScene->selectedItems();
}
RemoveShapeCommand::~RemoveShapeCommand()
{
}
//!?[4]
//!?[5]
void?RemoveShapeCommand::undo()
{
????foreach?(QGraphicsItem?*item?items)?{
????????QGraphicsItemGroup?*g?=?dynamic_cast(item->parentItem());
????????if?(?!g?)
????????????myGraphicsScene->addItem(item);
????}
????myGraphicsScene->update();
????setText(Qobject::tr(“Undo?Delete?%1“).arg(items.count()));
}
//!?[5]
//!?[6]
void?RemoveShapeCommand::redo()
{
????foreach?(QGraphicsItem?*item?items)?{
????????QGraphicsItemGroup?*g?=?dynamic_cast(item->parentItem());
????????if?(?!g?)
????????????myGraphicsScene->removeItem(item);
????}
????????setText(Qobject::tr(“Redo?Delete?%1“).arg(items.count()));
}
//!?[6]
//!?[7]
AddShapeCommand::AddShapeCommand(QGraphicsItem?*item
???????????????????????QGraphicsScene?*scene?QUndoCommand?*parent)
????:?QUndoCommand(parent)
{
????static?int?itemCount?=?0;
????myGraphicsScene?=?scene;
????myDiagramItem?=?item;
????initialPosition?=?item->pos();
????++itemCount;
}
//!?[7]
AddShapeCommand::~AddShapeCommand()
{
????if?(!myDiagramItem->scene())
????????delete?myDiagramItem;
}
//!?[8]
void?AddShapeCommand::undo()
{
????myGraphicsScene->removeItem(myDiagramItem);
????myGraphicsScene->update();
????setText(Qobject::tr(“Undo?Add?%1“)
????????.arg(createCommandString(myDiagramItem?initialPosition)));
}
//!?[8]
//!?[9]
void?AddSha
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-23?11:54??qdraw-master\
?????文件????????6148??2017-12-23?11:54??qdraw-master\.DS_Store
?????目錄???????????0??2017-12-23?11:54??__MACOSX\
?????目錄???????????0??2017-12-23?11:54??__MACOSX\qdraw-master\
?????文件?????????120??2017-12-23?11:54??__MACOSX\qdraw-master\._.DS_Store
?????文件?????????242??2017-01-28?07:05??qdraw-master\.gitignore
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\._.gitignore
?????目錄???????????0??2017-01-28?07:05??qdraw-master\app\
?????文件?????????813??2017-01-28?07:05??qdraw-master\app\app.pro
?????目錄???????????0??2017-12-23?11:54??__MACOSX\qdraw-master\app\
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._app.pro
?????文件????????1427??2017-01-28?07:05??qdraw-master\app\app.qrc
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._app.qrc
?????文件???????10349??2017-01-28?07:05??qdraw-master\app\commands.cpp
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._commands.cpp
?????文件????????3645??2017-01-28?07:05??qdraw-master\app\commands.h
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._commands.h
?????文件???????17161??2017-01-28?07:05??qdraw-master\app\customproperty.cpp
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._customproperty.cpp
?????文件????????3143??2017-01-28?07:05??qdraw-master\app\customproperty.h
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._customproperty.h
?????文件??????????50??2017-01-28?07:05??qdraw-master\app\document.cpp
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._document.cpp
?????文件?????????108??2017-01-28?07:05??qdraw-master\app\document.h
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._document.h
?????文件???????41867??2017-01-28?07:05??qdraw-master\app\drawobj.cpp
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._drawobj.cpp
?????文件???????12333??2017-01-28?07:05??qdraw-master\app\drawobj.h
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._drawobj.h
?????文件???????11388??2017-01-28?07:05??qdraw-master\app\drawscene.cpp
?????文件?????????212??2017-01-28?07:05??__MACOSX\qdraw-master\app\._drawscene.cpp
............此處省略698個文件信息
評論
共有 條評論