Changeset View
Changeset View
Standalone View
Standalone View
commands/tools/selection/kpToolSelectionDestroyCommand.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 74 | { | |||
---|---|---|---|---|---|
84 | Q_ASSERT (!m_oldSelectionPtr); | 84 | Q_ASSERT (!m_oldSelectionPtr); | ||
85 | m_oldSelectionPtr = doc->selection ()->clone (); | 85 | m_oldSelectionPtr = doc->selection ()->clone (); | ||
86 | 86 | | |||
87 | if (m_pushOntoDocument) | 87 | if (m_pushOntoDocument) | ||
88 | { | 88 | { | ||
89 | m_oldDocImage = doc->getImageAt (doc->selection ()->boundingRect ()); | 89 | m_oldDocImage = doc->getImageAt (doc->selection ()->boundingRect ()); | ||
90 | doc->selectionPushOntoDocument (); | 90 | doc->selectionPushOntoDocument (); | ||
91 | } | 91 | } | ||
92 | else | 92 | else { | ||
93 | doc->selectionDelete (); | 93 | doc->selectionDelete (); | ||
94 | } | ||||
94 | 95 | | |||
95 | environ ()->somethingBelowTheCursorChanged (); | 96 | environ ()->somethingBelowTheCursorChanged (); | ||
96 | } | 97 | } | ||
97 | 98 | | |||
98 | //--------------------------------------------------------------------- | 99 | //--------------------------------------------------------------------- | ||
99 | 100 | | |||
100 | // public virtual [base kpCommand] | 101 | // public virtual [base kpCommand] | ||
101 | void kpToolSelectionDestroyCommand::unexecute () | 102 | void kpToolSelectionDestroyCommand::unexecute () | ||
Show All 20 Lines | 103 | { | |||
122 | 123 | | |||
123 | if (m_pushOntoDocument) | 124 | if (m_pushOntoDocument) | ||
124 | { | 125 | { | ||
125 | qCDebug(kpLogCommands) << "\tunpush oldDocImage onto doc first"; | 126 | qCDebug(kpLogCommands) << "\tunpush oldDocImage onto doc first"; | ||
126 | doc->setImageAt (m_oldDocImage, m_oldSelectionPtr->topLeft ()); | 127 | doc->setImageAt (m_oldDocImage, m_oldSelectionPtr->topLeft ()); | ||
127 | } | 128 | } | ||
128 | 129 | | |||
129 | qCDebug(kpLogCommands) << "\tsetting selection to: rect=" << m_oldSelectionPtr->boundingRect () | 130 | qCDebug(kpLogCommands) << "\tsetting selection to: rect=" << m_oldSelectionPtr->boundingRect () | ||
130 | << " hasContent=" << m_oldSelectionPtr->hasContent () | 131 | << " hasContent=" << m_oldSelectionPtr->hasContent (); | ||
131 | << endl; | 132 | auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr); | ||
132 | kpAbstractImageSelection *imageSel = | 133 | auto *textSel = dynamic_cast <kpTextSelection *> (m_oldSelectionPtr); | ||
133 | dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr); | 134 | | ||
134 | kpTextSelection *textSel = | | |||
135 | dynamic_cast <kpTextSelection *> (m_oldSelectionPtr); | | |||
136 | if (imageSel) | 135 | if (imageSel) | ||
137 | { | 136 | { | ||
138 | if (imageSel->transparency () != environ ()->imageSelectionTransparency ()) | 137 | if (imageSel->transparency () != environ ()->imageSelectionTransparency ()) { | ||
139 | environ ()->setImageSelectionTransparency (imageSel->transparency ()); | 138 | environ ()->setImageSelectionTransparency (imageSel->transparency ()); | ||
140 | if (dynamic_cast <kpTextSelection *> (doc->selection())) | 139 | } | ||
140 | if (dynamic_cast <kpTextSelection *> (doc->selection())) { | ||||
141 | doc->selectionPushOntoDocument(); | 141 | doc->selectionPushOntoDocument(); | ||
142 | } | 142 | } | ||
143 | } | ||||
143 | else if (textSel) | 144 | else if (textSel) | ||
144 | { | 145 | { | ||
145 | if (textSel->textStyle () != environ ()->textStyle ()) | 146 | if (textSel->textStyle () != environ ()->textStyle ()) { | ||
146 | environ ()->setTextStyle (textSel->textStyle ()); | 147 | environ ()->setTextStyle (textSel->textStyle ()); | ||
147 | if (dynamic_cast <kpAbstractImageSelection *> (doc->selection())) | 148 | } | ||
149 | if (dynamic_cast <kpAbstractImageSelection *> (doc->selection())) { | ||||
148 | doc->selectionPushOntoDocument(); | 150 | doc->selectionPushOntoDocument(); | ||
149 | } | 151 | } | ||
150 | else | 152 | } | ||
153 | else { | ||||
151 | Q_ASSERT (!"Unknown selection type"); | 154 | Q_ASSERT (!"Unknown selection type"); | ||
155 | } | ||||
152 | 156 | | |||
153 | viewManager ()->setTextCursorPosition (m_textRow, m_textCol); | 157 | viewManager ()->setTextCursorPosition (m_textRow, m_textCol); | ||
154 | doc->setSelection (*m_oldSelectionPtr); | 158 | doc->setSelection (*m_oldSelectionPtr); | ||
155 | 159 | | |||
156 | environ ()->somethingBelowTheCursorChanged (); | 160 | environ ()->somethingBelowTheCursorChanged (); | ||
157 | 161 | | |||
158 | delete m_oldSelectionPtr; | 162 | delete m_oldSelectionPtr; | ||
159 | m_oldSelectionPtr = nullptr; | 163 | m_oldSelectionPtr = nullptr; | ||
160 | } | 164 | } | ||
161 | 165 | |