Changeset View
Changeset View
Standalone View
Standalone View
mainWindow/kpMainWindow_View_Zoom.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 197 | { | |||
---|---|---|---|---|---|
198 | zoomLevel = d->mainView->zoomLevelX (); | 198 | zoomLevel = d->mainView->zoomLevelX (); | ||
199 | } | 199 | } | ||
200 | } | 200 | } | ||
201 | #endif | 201 | #endif | ||
202 | 202 | | |||
203 | int index = 0; | 203 | int index = 0; | ||
204 | QList <int>::Iterator it = d->zoomList.begin (); | 204 | QList <int>::Iterator it = d->zoomList.begin (); | ||
205 | 205 | | |||
206 | while (index < (int) d->zoomList.count () && zoomLevel > *it) | 206 | while (index < d->zoomList.count () && zoomLevel > *it) | ||
207 | it++, index++; | 207 | it++, index++; | ||
208 | 208 | | |||
209 | if (zoomLevel != *it) | 209 | if (zoomLevel != *it) | ||
210 | d->zoomList.insert (it, zoomLevel); | 210 | d->zoomList.insert (it, zoomLevel); | ||
211 | 211 | | |||
212 | // OPT: We get called twice on startup. sendZoomListToActionZoom() is very slow. | 212 | // OPT: We get called twice on startup. sendZoomListToActionZoom() is very slow. | ||
213 | sendZoomListToActionZoom (); | 213 | sendZoomListToActionZoom (); | ||
214 | 214 | | |||
Show All 11 Lines | 220 | qCDebug(kpLogMainWindow) << "\tcurrentItem=" | |||
226 | << endl;; | 226 | << endl;; | ||
227 | #endif | 227 | #endif | ||
228 | 228 | | |||
229 | 229 | | |||
230 | if (viewMenuDocumentActionsEnabled ()) | 230 | if (viewMenuDocumentActionsEnabled ()) | ||
231 | { | 231 | { | ||
232 | d->actionActualSize->setEnabled (zoomLevel != 100); | 232 | d->actionActualSize->setEnabled (zoomLevel != 100); | ||
233 | 233 | | |||
234 | d->actionZoomIn->setEnabled (d->actionZoom->currentItem () < (int) d->zoomList.count () - 1); | 234 | d->actionZoomIn->setEnabled (d->actionZoom->currentItem () < d->zoomList.count () - 1); | ||
235 | d->actionZoomOut->setEnabled (d->actionZoom->currentItem () > 0); | 235 | d->actionZoomOut->setEnabled (d->actionZoom->currentItem () > 0); | ||
236 | } | 236 | } | ||
237 | 237 | | |||
238 | 238 | | |||
239 | // TODO: Is this actually needed? | 239 | // TODO: Is this actually needed? | ||
240 | if (d->viewManager) | 240 | if (d->viewManager) | ||
241 | d->viewManager->setQueueUpdates (); | 241 | d->viewManager->setQueueUpdates (); | ||
242 | 242 | | |||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 386 | #if DEBUG_KP_MAIN_WINDOW | |||
387 | qCDebug(kpLogMainWindow) << "\tcenterUnderCursor: reposition cursor; viewUnderCursor=" | 387 | qCDebug(kpLogMainWindow) << "\tcenterUnderCursor: reposition cursor; viewUnderCursor=" | ||
388 | << vuc->objectName () << endl; | 388 | << vuc->objectName () << endl; | ||
389 | #endif | 389 | #endif | ||
390 | 390 | | |||
391 | const double viewX = vuc->transformDocToViewX (targetDocX); | 391 | const double viewX = vuc->transformDocToViewX (targetDocX); | ||
392 | const double viewY = vuc->transformDocToViewY (targetDocY); | 392 | const double viewY = vuc->transformDocToViewY (targetDocY); | ||
393 | // Rounding error from zooming in and out :( | 393 | // Rounding error from zooming in and out :( | ||
394 | // TODO: do everything in terms of tool doc points in type "double". | 394 | // TODO: do everything in terms of tool doc points in type "double". | ||
395 | const QPoint viewPoint ((int) viewX, (int) viewY); | 395 | const QPoint viewPoint (static_cast<int> (viewX), static_cast<int> (viewY)); | ||
396 | #if DEBUG_KP_MAIN_WINDOW | 396 | #if DEBUG_KP_MAIN_WINDOW | ||
397 | qCDebug(kpLogMainWindow) << "\t\tdoc: (" << targetDocX << "," << targetDocY << ")" | 397 | qCDebug(kpLogMainWindow) << "\t\tdoc: (" << targetDocX << "," << targetDocY << ")" | ||
398 | << " viewUnderCursor: (" << viewX << "," << viewY << ")" | 398 | << " viewUnderCursor: (" << viewX << "," << viewY << ")" | ||
399 | << endl; | 399 | << endl; | ||
400 | #endif | 400 | #endif | ||
401 | 401 | | |||
402 | if (vuc->visibleRegion ().contains (viewPoint)) | 402 | if (vuc->visibleRegion ().contains (viewPoint)) | ||
403 | { | 403 | { | ||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | |||||
562 | 562 | | |||
563 | // public slot | 563 | // public slot | ||
564 | void kpMainWindow::slotFitToWidth () | 564 | void kpMainWindow::slotFitToWidth () | ||
565 | { | 565 | { | ||
566 | if ( d->document ) | 566 | if ( d->document ) | ||
567 | { | 567 | { | ||
568 | const QRect docRect ( | 568 | const QRect docRect ( | ||
569 | 0/*x*/, | 569 | 0/*x*/, | ||
570 | (int) d->mainView->transformViewToDocY (d->scrollView->verticalScrollBar()->value ())/*maintain y*/, | 570 | static_cast<int> (d->mainView->transformViewToDocY (d->scrollView->verticalScrollBar()->value ()))/*maintain y*/, | ||
571 | d->document->width (), | 571 | d->document->width (), | ||
572 | 1/*don't care about height*/); | 572 | 1/*don't care about height*/); | ||
573 | zoomToRect ( | 573 | zoomToRect ( | ||
574 | docRect, | 574 | docRect, | ||
575 | true/*account for grips*/, | 575 | true/*account for grips*/, | ||
576 | true/*care about width*/, false/*don't care about height*/); | 576 | true/*care about width*/, false/*don't care about height*/); | ||
577 | } | 577 | } | ||
578 | } | 578 | } | ||
579 | 579 | | |||
580 | //--------------------------------------------------------------------- | 580 | //--------------------------------------------------------------------- | ||
581 | 581 | | |||
582 | // public slot | 582 | // public slot | ||
583 | void kpMainWindow::slotFitToHeight () | 583 | void kpMainWindow::slotFitToHeight () | ||
584 | { | 584 | { | ||
585 | if ( d->document ) | 585 | if ( d->document ) | ||
586 | { | 586 | { | ||
587 | const QRect docRect ( | 587 | const QRect docRect ( | ||
588 | (int) d->mainView->transformViewToDocX (d->scrollView->horizontalScrollBar()->value ())/*maintain x*/, | 588 | static_cast<int> (d->mainView->transformViewToDocX (d->scrollView->horizontalScrollBar()->value ()))/*maintain x*/, | ||
589 | 0/*y*/, | 589 | 0/*y*/, | ||
590 | 1/*don't care about width*/, | 590 | 1/*don't care about width*/, | ||
591 | d->document->height ()); | 591 | d->document->height ()); | ||
592 | zoomToRect ( | 592 | zoomToRect ( | ||
593 | docRect, | 593 | docRect, | ||
594 | true/*account for grips*/, | 594 | true/*account for grips*/, | ||
595 | false/*don't care about width*/, true/*care about height*/); | 595 | false/*don't care about width*/, true/*care about height*/); | ||
596 | } | 596 | } | ||
597 | } | 597 | } | ||
598 | 598 | | |||
599 | //--------------------------------------------------------------------- | 599 | //--------------------------------------------------------------------- | ||
600 | 600 | | |||
601 | // public | 601 | // public | ||
602 | void kpMainWindow::zoomIn (bool centerUnderCursor) | 602 | void kpMainWindow::zoomIn (bool centerUnderCursor) | ||
603 | { | 603 | { | ||
604 | #if DEBUG_KP_MAIN_WINDOW | 604 | #if DEBUG_KP_MAIN_WINDOW | ||
605 | qCDebug(kpLogMainWindow) << "kpMainWindow::zoomIn(centerUnderCursor=" | 605 | qCDebug(kpLogMainWindow) << "kpMainWindow::zoomIn(centerUnderCursor=" | ||
606 | << centerUnderCursor << ") currentItem=" | 606 | << centerUnderCursor << ") currentItem=" | ||
607 | << d->actionZoom->currentItem () | 607 | << d->actionZoom->currentItem () | ||
608 | << endl; | 608 | << endl; | ||
609 | #endif | 609 | #endif | ||
610 | const int targetItem = d->actionZoom->currentItem () + 1; | 610 | const int targetItem = d->actionZoom->currentItem () + 1; | ||
611 | 611 | | |||
612 | if (targetItem >= (int) d->zoomList.count ()) | 612 | if (targetItem >= static_cast<int> (d->zoomList.count ())) | ||
613 | return; | 613 | return; | ||
614 | 614 | | |||
615 | d->actionZoom->setCurrentItem (targetItem); | 615 | d->actionZoom->setCurrentItem (targetItem); | ||
616 | 616 | | |||
617 | #if DEBUG_KP_MAIN_WINDOW | 617 | #if DEBUG_KP_MAIN_WINDOW | ||
618 | qCDebug(kpLogMainWindow) << "\tnew currentItem=" << d->actionZoom->currentItem (); | 618 | qCDebug(kpLogMainWindow) << "\tnew currentItem=" << d->actionZoom->currentItem (); | ||
619 | #endif | 619 | #endif | ||
620 | 620 | | |||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |