Changeset View
Changeset View
Standalone View
Standalone View
components/Document.cpp
Show All 37 Lines | |||||
38 | #include "impl/SpreadsheetImpl.h" | 38 | #include "impl/SpreadsheetImpl.h" | ||
39 | #include "impl/PresentationImpl.h" | 39 | #include "impl/PresentationImpl.h" | ||
40 | 40 | | |||
41 | using namespace Calligra::Components; | 41 | using namespace Calligra::Components; | ||
42 | 42 | | |||
43 | class Document::Private | 43 | class Document::Private | ||
44 | { | 44 | { | ||
45 | public: | 45 | public: | ||
46 | Private(Document* qq) : q{qq}, impl{nullptr}, status{DocumentStatus::Unloaded}, textEditor{nullptr} | 46 | Private(Document* qq) : q{qq}, impl{nullptr}, status{DocumentStatus::Unloaded} | ||
47 | { } | 47 | { } | ||
48 | 48 | | |||
49 | void updateImpl(); | 49 | void updateImpl(); | ||
50 | 50 | | |||
51 | Document* q; | 51 | Document* q; | ||
52 | 52 | | |||
53 | QUrl source; | 53 | QUrl source; | ||
54 | DocumentImpl* impl; | 54 | DocumentImpl* impl; | ||
55 | DocumentStatus::Status status; | 55 | DocumentStatus::Status status; | ||
56 | KoTextEditor* textEditor; | | |||
57 | }; | 56 | }; | ||
58 | 57 | | |||
59 | Document::Document(QObject* parent) | 58 | Document::Document(QObject* parent) | ||
60 | : QObject{parent}, d{new Private{this}} | 59 | : QObject{parent}, d{new Private{this}} | ||
61 | { | 60 | { | ||
62 | 61 | | |||
63 | } | 62 | } | ||
64 | 63 | | |||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 206 | { | |||
208 | if(d->impl) | 207 | if(d->impl) | ||
209 | return d->impl->urlAtPoint(point); | 208 | return d->impl->urlAtPoint(point); | ||
210 | return QUrl(); | 209 | return QUrl(); | ||
211 | } | 210 | } | ||
212 | 211 | | |||
213 | QObject * Document::textEditor() | 212 | QObject * Document::textEditor() | ||
214 | { | 213 | { | ||
215 | if (d->impl && d->impl->canvasController()) { | 214 | if (d->impl && d->impl->canvasController()) { | ||
216 | if (d->textEditor) { | 215 | return KoTextEditor::getTextEditorFromCanvas(d->impl->canvasController()->canvas()); | ||
217 | disconnect(d->textEditor, SIGNAL(cursorPositionChanged()), this, SIGNAL(selectionChanged())); | | |||
218 | } | | |||
219 | d->textEditor = KoTextEditor::getTextEditorFromCanvas(d->impl->canvasController()->canvas()); | | |||
220 | if (d->textEditor) { | | |||
221 | disconnect(d->textEditor, SIGNAL(cursorPositionChanged()), this, SIGNAL(selectionChanged())); | | |||
leinir: What happens to this signal now? | |||||
Nothing, but that's how it used to be. The intention might have been different, but effectively it's two disconnects without actual connection appearing anywhere as far as I can tell. And then again don't think the ::textEditor() getter should really be a place for adjusting any connections anyway. pvuorela: Nothing, but that's how it used to be. The intention might have been different, but effectively… | |||||
Hmm... Think that this was probably something not yet ported from the old Qt Quick 1 components, which had considerably more editing functionality than the QtQuick2 components... it would be good to have that restored, but yeah, for now at any rate, it does seem to have little effect. leinir: Hmm... Think that this was probably something not yet ported from the old Qt Quick 1 components… | |||||
222 | } | | |||
223 | // emit selectionChanged(); | | |||
224 | return d->textEditor; | | |||
225 | } | 216 | } | ||
226 | return 0; | 217 | return 0; | ||
227 | } | 218 | } | ||
228 | 219 | | |||
229 | void Document::deselectEverything() | 220 | void Document::deselectEverything() | ||
230 | { | 221 | { | ||
231 | KoTextEditor* editor = KoTextEditor::getTextEditorFromCanvas(d->impl->canvasController()->canvas()); | 222 | KoTextEditor* editor = KoTextEditor::getTextEditorFromCanvas(d->impl->canvasController()->canvas()); | ||
232 | if (editor) { | 223 | if (editor) { | ||
233 | editor->clearSelection(); | 224 | editor->clearSelection(); | ||
234 | } | 225 | } | ||
235 | d->impl->canvasController()->canvas()->shapeManager()->selection()->deselectAll(); | 226 | d->impl->canvasController()->canvas()->shapeManager()->selection()->deselectAll(); | ||
236 | emit requestViewUpdate(); | 227 | emit requestViewUpdate(); | ||
237 | } | 228 | } | ||
238 | 229 | | |||
239 | void Document::Private::updateImpl() | 230 | void Document::Private::updateImpl() | ||
240 | { | 231 | { | ||
241 | if(impl) { | | |||
242 | delete impl; | 232 | delete impl; | ||
243 | } | 233 | impl = nullptr; | ||
244 | 234 | | |||
245 | if(!source.isEmpty()) { | | |||
246 | auto type = Global::documentType(source); | 235 | auto type = Global::documentType(source); | ||
247 | switch(type) { | 236 | switch(type) { | ||
248 | case DocumentType::TextDocument: | 237 | case DocumentType::TextDocument: | ||
249 | impl = new TextDocumentImpl{q}; | 238 | impl = new TextDocumentImpl{q}; | ||
250 | break; | 239 | break; | ||
251 | case DocumentType::Spreadsheet: | 240 | case DocumentType::Spreadsheet: | ||
252 | impl = new SpreadsheetImpl{q}; | 241 | impl = new SpreadsheetImpl{q}; | ||
253 | break; | 242 | break; | ||
254 | case DocumentType::Presentation: | 243 | case DocumentType::Presentation: | ||
255 | impl = new PresentationImpl{q}; | 244 | impl = new PresentationImpl{q}; | ||
256 | break; | 245 | break; | ||
257 | default: | 246 | default: | ||
258 | impl = nullptr; | | |||
259 | break; | 247 | break; | ||
260 | } | 248 | } | ||
261 | } else { | | |||
262 | impl = nullptr; | | |||
263 | } | | |||
264 | 249 | | |||
265 | if(impl) { | 250 | if(impl) { | ||
266 | connect(impl, &DocumentImpl::documentSizeChanged, q, &Document::documentSizeChanged); | 251 | connect(impl, &DocumentImpl::documentSizeChanged, q, &Document::documentSizeChanged); | ||
267 | connect(impl, &DocumentImpl::currentIndexChanged, q, &Document::currentIndexChanged); | 252 | connect(impl, &DocumentImpl::currentIndexChanged, q, &Document::currentIndexChanged); | ||
268 | connect(impl, &DocumentImpl::requestViewUpdate, q, &Document::requestViewUpdate); | 253 | connect(impl, &DocumentImpl::requestViewUpdate, q, &Document::requestViewUpdate); | ||
269 | } | 254 | } | ||
270 | emit q->documentChanged(); | 255 | emit q->documentChanged(); | ||
271 | } | 256 | } | ||
272 | 257 | | |||
273 | #include "moc_Document.cpp" | 258 | #include "moc_Document.cpp" |
What happens to this signal now?