Changeset View
Changeset View
Standalone View
Standalone View
lib/document/document.cpp
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | |||||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | void DocumentPrivate::downSampleImage(int invertedZoom) | 125 | void DocumentPrivate::downSampleImage(int invertedZoom) | ||
126 | { | 126 | { | ||
127 | mDownSampledImageMap[invertedZoom] = mImage.scaled(mImage.size() / invertedZoom, Qt::KeepAspectRatio, Qt::FastTransformation); | 127 | mDownSampledImageMap[invertedZoom] = mImage.scaled(mImage.size() / invertedZoom, Qt::KeepAspectRatio, Qt::FastTransformation); | ||
128 | if (mDownSampledImageMap[invertedZoom].size().isEmpty()) { | 128 | if (mDownSampledImageMap[invertedZoom].size().isEmpty()) { | ||
129 | mDownSampledImageMap[invertedZoom] = mImage; | 129 | mDownSampledImageMap[invertedZoom] = mImage; | ||
130 | } | 130 | } | ||
131 | q->downSampledImageReady(); | 131 | emit q->downSampledImageReady(); | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | //- DownSamplingJob --------------------------------------- | 134 | //- DownSamplingJob --------------------------------------- | ||
135 | void DownSamplingJob::doStart() | 135 | void DownSamplingJob::doStart() | ||
136 | { | 136 | { | ||
137 | DocumentPrivate* d = document()->d; | 137 | DocumentPrivate* d = document()->d; | ||
138 | d->downSampleImage(mInvertedZoom); | 138 | d->downSampleImage(mInvertedZoom); | ||
139 | setError(NoError); | 139 | setError(NoError); | ||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Line(s) | |||||
315 | { | 315 | { | ||
316 | if (job->error()) { | 316 | if (job->error()) { | ||
317 | setErrorString(job->errorString()); | 317 | setErrorString(job->errorString()); | ||
318 | } else { | 318 | } else { | ||
319 | d->mUndoStack.setClean(); | 319 | d->mUndoStack.setClean(); | ||
320 | SaveJob* saveJob = static_cast<SaveJob*>(job); | 320 | SaveJob* saveJob = static_cast<SaveJob*>(job); | ||
321 | d->mUrl = saveJob->newUrl(); | 321 | d->mUrl = saveJob->newUrl(); | ||
322 | d->mImageMetaInfoModel.setUrl(d->mUrl); | 322 | d->mImageMetaInfoModel.setUrl(d->mUrl); | ||
323 | saved(saveJob->oldUrl(), d->mUrl); | 323 | emit saved(saveJob->oldUrl(), d->mUrl); | ||
324 | } | 324 | } | ||
325 | } | 325 | } | ||
326 | 326 | | |||
327 | QByteArray Document::format() const | 327 | QByteArray Document::format() const | ||
328 | { | 328 | { | ||
329 | return d->mFormat; | 329 | return d->mFormat; | ||
330 | } | 330 | } | ||
331 | 331 | | |||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | |||||
483 | } | 483 | } | ||
484 | 484 | | |||
485 | void Document::imageOperationCompleted() | 485 | void Document::imageOperationCompleted() | ||
486 | { | 486 | { | ||
487 | if (d->mUndoStack.isClean()) { | 487 | if (d->mUndoStack.isClean()) { | ||
488 | // If user just undid all his changes this does not really correspond | 488 | // If user just undid all his changes this does not really correspond | ||
489 | // to a save, but it's similar enough as far as Document users are | 489 | // to a save, but it's similar enough as far as Document users are | ||
490 | // concerned | 490 | // concerned | ||
491 | saved(d->mUrl, d->mUrl); | 491 | emit saved(d->mUrl, d->mUrl); | ||
492 | } else { | 492 | } else { | ||
493 | modified(d->mUrl); | 493 | emit modified(d->mUrl); | ||
494 | } | 494 | } | ||
495 | } | 495 | } | ||
496 | 496 | | |||
497 | bool Document::isEditable() const | 497 | bool Document::isEditable() const | ||
498 | { | 498 | { | ||
499 | return d->mImpl->isEditable(); | 499 | return d->mImpl->isEditable(); | ||
500 | } | 500 | } | ||
501 | 501 | | |||
Show All 18 Lines | 518 | { | |||
520 | job->setDocument(Ptr(this)); | 520 | job->setDocument(Ptr(this)); | ||
521 | connect(job, &LoadingJob::finished, this, &Document::slotJobFinished); | 521 | connect(job, &LoadingJob::finished, this, &Document::slotJobFinished); | ||
522 | if (d->mCurrentJob) { | 522 | if (d->mCurrentJob) { | ||
523 | d->mJobQueue.enqueue(job); | 523 | d->mJobQueue.enqueue(job); | ||
524 | } else { | 524 | } else { | ||
525 | d->mCurrentJob = job; | 525 | d->mCurrentJob = job; | ||
526 | LOG("Starting first job"); | 526 | LOG("Starting first job"); | ||
527 | job->start(); | 527 | job->start(); | ||
528 | busyChanged(d->mUrl, true); | 528 | emit busyChanged(d->mUrl, true); | ||
529 | } | 529 | } | ||
530 | LOG_QUEUE("Job added", d); | 530 | LOG_QUEUE("Job added", d); | ||
531 | } | 531 | } | ||
532 | 532 | | |||
533 | void Document::slotJobFinished(KJob* job) | 533 | void Document::slotJobFinished(KJob* job) | ||
534 | { | 534 | { | ||
535 | LOG("job=" << job); | 535 | LOG("job=" << job); | ||
536 | GV_RETURN_IF_FAIL(job == d->mCurrentJob.data()); | 536 | GV_RETURN_IF_FAIL(job == d->mCurrentJob.data()); | ||
537 | 537 | | |||
538 | if (d->mJobQueue.isEmpty()) { | 538 | if (d->mJobQueue.isEmpty()) { | ||
539 | LOG("All done"); | 539 | LOG("All done"); | ||
540 | d->mCurrentJob.clear(); | 540 | d->mCurrentJob.clear(); | ||
541 | busyChanged(d->mUrl, false); | 541 | emit busyChanged(d->mUrl, false); | ||
542 | allTasksDone(); | 542 | emit allTasksDone(); | ||
543 | } else { | 543 | } else { | ||
544 | LOG("Starting next job"); | 544 | LOG("Starting next job"); | ||
545 | d->mCurrentJob = d->mJobQueue.dequeue(); | 545 | d->mCurrentJob = d->mJobQueue.dequeue(); | ||
546 | GV_RETURN_IF_FAIL(d->mCurrentJob); | 546 | GV_RETURN_IF_FAIL(d->mCurrentJob); | ||
547 | d->mCurrentJob.data()->start(); | 547 | d->mCurrentJob.data()->start(); | ||
548 | } | 548 | } | ||
549 | LOG_QUEUE("Removed done job", d); | 549 | LOG_QUEUE("Removed done job", d); | ||
550 | } | 550 | } | ||
Show All 22 Lines |