void KPrViewModeNotes::updateActivePage( KoPAPageBase *page ) { if ( m_view->activePage() != page ) { m_view->setActivePage( page ); } KPrPage *prPage = dynamic_cast<KPrPage *>( page ); if ( !prPage ) return; KPrNotes *notes = prPage->pageNotes(); notes->updatePageThumbnail(); KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( notes->childShapes().last() ); KoPageLayout &layout = notes->pageLayout(); QSize size(layout.width, layout.height); m_view->horizontalRuler()->setRulerLength(layout.width); m_view->verticalRuler()->setRulerLength(layout.height); m_view->horizontalRuler()->setActiveRange(layout.left, layout.width - layout.right); m_view->verticalRuler()->setActiveRange(layout.top, layout.height - layout.bottom); m_view->zoomController()->setPageSize(size); m_view->zoomController()->setDocumentSize(size); m_canvas->update(); m_canvas->shapeManager()->setShapes( layer->childShapes() ); m_canvas->masterShapeManager()->setShapes(QList<KoShape*>()); KoSelection *selection = m_canvas->shapeManager()->selection(); selection->select(notes->textShape()); selection->setActiveLayer( layer ); QString tool = KoToolManager::instance()->preferredToolForSelection(selection->selectedShapes()); KoToolManager::instance()->switchToolRequested(tool); }
void KPrViewModeNotes::removeShape( KoShape *shape ) { KoShape *parent = shape; KPrNotes *notes = 0; while ( !notes && ( parent = parent->parent() ) ) { notes = dynamic_cast<KPrNotes *>( parent ); } if ( notes ) { KPrPage *activePage = static_cast<KPrPage *>( m_view->activePage() ); if ( notes == activePage->pageNotes() ) { m_view->kopaCanvas()->shapeManager()->remove( shape ); } } }
void KPrViewModeNotes::addShape( KoShape *shape ) { KoShape *parent = shape; KPrNotes *notes = 0; // similar to KoPADocument::pageByShape() while ( !notes && ( parent = parent->parent() ) ) { notes = dynamic_cast<KPrNotes *>( parent ); } if ( notes ) { KPrPage *activePage = static_cast<KPrPage *>( m_view->activePage() ); if ( notes == activePage->pageNotes() ) { m_view->kopaCanvas()->shapeManager()->addShape( shape ); } } }