MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / PasteUndoCommand

Method PasteUndoCommand

Gui/KnobUndoCommand.cpp:76–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74};
75
76PasteUndoCommand::PasteUndoCommand(const KnobGuiPtr& knob,
77 KnobClipBoardType type,
78 int fromDimension,
79 int targetDimension,
80 const KnobIPtr& fromKnob)
81 : QUndoCommand(0)
82 , _imp( new PasteUndoCommandPrivate() )
83{
84 _imp->knob = knob;
85 _imp->type = type;
86 _imp->fromDimension = fromDimension;
87 _imp->targetDimension = targetDimension;
88 _imp->fromKnob = fromKnob;
89
90 {
91 std::ostringstream ss;
92 {
93 try {
94 boost::archive::xml_oarchive oArchive(ss);
95 _imp->originalSerialization->initialize( knob->getKnob() );
96 oArchive << boost::serialization::make_nvp("KnobClipboard", *_imp->originalSerialization);
97 } catch (...) {
98 assert(false);
99 }
100 }
101 _imp->originalSerialization = std::make_shared<KnobSerialization>();
102 std::string str = ss.str();
103 {
104 try {
105 std::stringstream ss(str);
106 boost::archive::xml_iarchive iArchive(ss);
107 iArchive >> boost::serialization::make_nvp("KnobClipboard", *_imp->originalSerialization);
108 } catch (...) {
109 assert(false);
110 }
111 }
112 }
113 assert( _imp->originalSerialization->getKnob() );
114
115 assert(knob);
116 assert( _imp->targetDimension >= -1 && _imp->targetDimension < _imp->knob.lock()->getKnob()->getDimension() );
117 assert( _imp->fromDimension >= -1 && _imp->fromDimension < _imp->fromKnob->getDimension() );
118 QString text;
119 switch (type) {
120 case eKnobClipBoardTypeCopyAnim:
121 text = tr("Paste Animation to %1");
122 break;
123 case eKnobClipBoardTypeCopyValue:
124 text = tr("Paste Value to %1");
125 break;
126 case eKnobClipBoardTypeCopyLink:
127 text = tr("Paste Link to %1");
128 break;
129 }
130 setText( text.arg( QString::fromUtf8( knob->getKnob()->getLabel().c_str() ) ) );
131}
132
133PasteUndoCommand::~PasteUndoCommand()

Callers

nothing calls this directly

Calls 6

setTextFunction · 0.85
initializeMethod · 0.45
getKnobMethod · 0.45
getDimensionMethod · 0.45
lockMethod · 0.45
getLabelMethod · 0.45

Tested by

no test coverage detected