Changeset View
Changeset View
Standalone View
Standalone View
commands/tools/selection/kpToolSelectionMoveCommand.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | { | 49 | { | ||
50 | kpDocument *doc = document (); | 50 | kpDocument *doc = document (); | ||
51 | Q_ASSERT (doc); | 51 | Q_ASSERT (doc); | ||
52 | Q_ASSERT (doc->selection ()); | 52 | Q_ASSERT (doc->selection ()); | ||
53 | 53 | | |||
54 | m_startPoint = m_endPoint = doc->selection ()->topLeft (); | 54 | m_startPoint = m_endPoint = doc->selection ()->topLeft (); | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | kpToolSelectionMoveCommand::~kpToolSelectionMoveCommand () | 57 | kpToolSelectionMoveCommand::~kpToolSelectionMoveCommand () = default; | ||
58 | { | | |||
59 | } | | |||
60 | 58 | | |||
61 | 59 | | |||
62 | // public | 60 | // public | ||
63 | kpAbstractSelection *kpToolSelectionMoveCommand::originalSelectionClone () const | 61 | kpAbstractSelection *kpToolSelectionMoveCommand::originalSelectionClone () const | ||
64 | { | 62 | { | ||
65 | kpDocument *doc = document (); | 63 | kpDocument *doc = document (); | ||
66 | Q_ASSERT (doc); | 64 | Q_ASSERT (doc); | ||
67 | Q_ASSERT (doc->selection ()); | 65 | Q_ASSERT (doc->selection ()); | ||
Show All 25 Lines | 84 | { | |||
93 | // Must have content before it can be moved. | 91 | // Must have content before it can be moved. | ||
94 | Q_ASSERT (sel && sel->hasContent ()); | 92 | Q_ASSERT (sel && sel->hasContent ()); | ||
95 | 93 | | |||
96 | kpViewManager *vm = viewManager (); | 94 | kpViewManager *vm = viewManager (); | ||
97 | Q_ASSERT (vm); | 95 | Q_ASSERT (vm); | ||
98 | 96 | | |||
99 | vm->setQueueUpdates (); | 97 | vm->setQueueUpdates (); | ||
100 | { | 98 | { | ||
101 | foreach (const QPoint &p, m_copyOntoDocumentPoints) | 99 | for (const auto &p : m_copyOntoDocumentPoints) | ||
102 | { | 100 | { | ||
103 | sel->moveTo (p); | 101 | sel->moveTo (p); | ||
104 | doc->selectionCopyOntoDocument (); | 102 | doc->selectionCopyOntoDocument (); | ||
105 | } | 103 | } | ||
106 | 104 | | |||
107 | sel->moveTo (m_endPoint); | 105 | sel->moveTo (m_endPoint); | ||
108 | 106 | | |||
109 | environ ()->somethingBelowTheCursorChanged (); | 107 | environ ()->somethingBelowTheCursorChanged (); | ||
Show All 13 Lines | 114 | { | |||
123 | // Must have content before it can be un-moved. | 121 | // Must have content before it can be un-moved. | ||
124 | Q_ASSERT (sel && sel->hasContent ()); | 122 | Q_ASSERT (sel && sel->hasContent ()); | ||
125 | 123 | | |||
126 | kpViewManager *vm = viewManager (); | 124 | kpViewManager *vm = viewManager (); | ||
127 | Q_ASSERT (vm); | 125 | Q_ASSERT (vm); | ||
128 | 126 | | |||
129 | vm->setQueueUpdates (); | 127 | vm->setQueueUpdates (); | ||
130 | 128 | | |||
131 | if (!m_oldDocumentImage.isNull ()) | 129 | if (!m_oldDocumentImage.isNull ()) { | ||
132 | doc->setImageAt (m_oldDocumentImage, m_documentBoundingRect.topLeft ()); | 130 | doc->setImageAt (m_oldDocumentImage, m_documentBoundingRect.topLeft ()); | ||
131 | } | ||||
133 | qCDebug(kpLogCommands) << "\tmove to startPoint=" << m_startPoint; | 132 | qCDebug(kpLogCommands) << "\tmove to startPoint=" << m_startPoint; | ||
134 | sel->moveTo (m_startPoint); | 133 | sel->moveTo (m_startPoint); | ||
135 | 134 | | |||
136 | environ ()->somethingBelowTheCursorChanged (); | 135 | environ ()->somethingBelowTheCursorChanged (); | ||
137 | 136 | | |||
138 | vm->restoreQueueUpdates (); | 137 | vm->restoreQueueUpdates (); | ||
139 | } | 138 | } | ||
140 | 139 | | |||
141 | // public | 140 | // public | ||
142 | void kpToolSelectionMoveCommand::moveTo (const QPoint &point, bool moveLater) | 141 | void kpToolSelectionMoveCommand::moveTo (const QPoint &point, bool moveLater) | ||
143 | { | 142 | { | ||
144 | qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::moveTo" << point | 143 | qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::moveTo" << point | ||
145 | << " moveLater=" << moveLater | 144 | << " moveLater=" << moveLater; | ||
146 | <<endl; | | |||
147 | 145 | | |||
148 | if (!moveLater) | 146 | if (!moveLater) | ||
149 | { | 147 | { | ||
150 | kpDocument *doc = document (); | 148 | kpDocument *doc = document (); | ||
151 | Q_ASSERT (doc); | 149 | Q_ASSERT (doc); | ||
152 | 150 | | |||
153 | kpAbstractSelection *sel = doc->selection (); | 151 | kpAbstractSelection *sel = doc->selection (); | ||
154 | // Must have content before it can be moved. | 152 | // Must have content before it can be moved. | ||
155 | Q_ASSERT (sel && sel->hasContent ()); | 153 | Q_ASSERT (sel && sel->hasContent ()); | ||
156 | 154 | | |||
157 | if (point == sel->topLeft ()) | 155 | if (point == sel->topLeft ()) { | ||
158 | return; | 156 | return; | ||
157 | } | ||||
159 | 158 | | |||
160 | sel->moveTo (point); | 159 | sel->moveTo (point); | ||
161 | } | 160 | } | ||
162 | 161 | | |||
163 | m_endPoint = point; | 162 | m_endPoint = point; | ||
164 | } | 163 | } | ||
165 | 164 | | |||
166 | // public | 165 | // public | ||
Show All 10 Lines | 173 | { | |||
177 | kpDocument *doc = document (); | 176 | kpDocument *doc = document (); | ||
178 | Q_ASSERT (doc); | 177 | Q_ASSERT (doc); | ||
179 | 178 | | |||
180 | kpAbstractSelection *sel = doc->selection (); | 179 | kpAbstractSelection *sel = doc->selection (); | ||
181 | // Must have content before we allow it be stamped onto the document, | 180 | // Must have content before we allow it be stamped onto the document, | ||
182 | // to be consistent with the requirement on other selection operations. | 181 | // to be consistent with the requirement on other selection operations. | ||
183 | Q_ASSERT (sel && sel->hasContent ()); | 182 | Q_ASSERT (sel && sel->hasContent ()); | ||
184 | 183 | | |||
185 | if (m_oldDocumentImage.isNull ()) | 184 | if (m_oldDocumentImage.isNull ()) { | ||
186 | m_oldDocumentImage = doc->image (); | 185 | m_oldDocumentImage = doc->image (); | ||
186 | } | ||||
187 | 187 | | |||
188 | QRect selBoundingRect = sel->boundingRect (); | 188 | QRect selBoundingRect = sel->boundingRect (); | ||
189 | m_documentBoundingRect = m_documentBoundingRect.united (selBoundingRect); | 189 | m_documentBoundingRect = m_documentBoundingRect.united (selBoundingRect); | ||
190 | 190 | | |||
191 | doc->selectionCopyOntoDocument (); | 191 | doc->selectionCopyOntoDocument (); | ||
192 | 192 | | |||
193 | m_copyOntoDocumentPoints.putPoints (m_copyOntoDocumentPoints.count (), | 193 | m_copyOntoDocumentPoints.putPoints (m_copyOntoDocumentPoints.count (), | ||
194 | 1, | 194 | 1, | ||
Show All 14 Lines |