From 95bb597a854c158bf989fc53dc9e405ee9fdb4c1 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 30 Mar 2007 14:08:20 +0000 Subject: [PATCH] hide the text selection inside the private class of Page svn path=/trunk/playground/graphics/okular/; revision=648095 --- core/page.cpp | 18 +++++++++++------- core/page.h | 7 ++++++- core/page_p.h | 2 ++ ui/pagepainter.cpp | 7 ++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/core/page.cpp b/core/page.cpp index ab0efcf29..cd96841fe 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -48,7 +48,7 @@ PagePrivate::PagePrivate( Page *page, uint n, double w, double h, Rotation o ) : m_page( page ), m_number( n ), m_orientation( o ), m_width( w ), m_height( h ), m_rotation( Rotation0 ), m_maxuniqueNum( 0 ), - m_text( 0 ), m_transition( 0 ), + m_text( 0 ), m_transition( 0 ), m_textSelections( 0 ), m_openingAction( 0 ), m_closingAction( 0 ), m_duration( -1 ) { // avoid Division-By-Zero problems in the program @@ -111,8 +111,7 @@ QMatrix PagePrivate::rotationMatrix() const /** class Page **/ Page::Page( uint page, double w, double h, Rotation o ) - : d( new PagePrivate( this, page, w, h, o ) ), - m_textSelections( 0 ) + : d( new PagePrivate( this, page, w, h, o ) ) { } @@ -420,7 +419,7 @@ void Page::setTextSelections( RegularAreaRect *r, const QColor & color ) HighlightAreaRect * hr = new HighlightAreaRect( r ); hr->s_id = -1; hr->color = color; - m_textSelections = hr; + d->m_textSelections = hr; } } @@ -453,7 +452,12 @@ QString Page::label() const const RegularAreaRect * Page::textSelection() const { - return m_textSelections; + return d->m_textSelections; +} + +QColor Page::textSelectionColor() const +{ + return d->m_textSelections ? d->m_textSelections->color : QColor(); } void Page::addAnnotation( Annotation * annotation ) @@ -607,8 +611,8 @@ void Page::deleteHighlights( int s_id ) void Page::deleteTextSelections() { - delete m_textSelections; - m_textSelections = 0; + delete d->m_textSelections; + d->m_textSelections = 0; } void Page::deleteSourceReferences() diff --git a/core/page.h b/core/page.h index 22701c2b4..721b2d5dd 100644 --- a/core/page.h +++ b/core/page.h @@ -267,6 +267,12 @@ class OKULAR_EXPORT Page */ const RegularAreaRect * textSelection() const; + /** + * Returns the color of the current text selection, or an invalid color + * if no text selection has been set. + */ + QColor textSelectionColor() const; + /** * Adds a new @p annotation to the page. */ @@ -359,7 +365,6 @@ class OKULAR_EXPORT Page QLinkedList< ObjectRect* > m_rects; QLinkedList< HighlightAreaRect* > m_highlights; QLinkedList< Annotation* > m_annotations; - HighlightAreaRect *m_textSelections; Q_DISABLE_COPY( Page ) }; diff --git a/core/page_p.h b/core/page_p.h index 0d43b3ec7..613b0dd16 100644 --- a/core/page_p.h +++ b/core/page_p.h @@ -23,6 +23,7 @@ namespace Okular { class FormField; +class HighlightAreaRect; class Link; class Page; class PageTransition; @@ -55,6 +56,7 @@ class PagePrivate TextPage * m_text; PageTransition * m_transition; + HighlightAreaRect *m_textSelections; QLinkedList< FormField * > formfields; Link * m_openingAction; Link * m_closingAction; diff --git a/ui/pagepainter.cpp b/ui/pagepainter.cpp index 2cb222946..32d9a2e5c 100644 --- a/ui/pagepainter.cpp +++ b/ui/pagepainter.cpp @@ -74,7 +74,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const Okular::Page /** 2 - FIND OUT WHAT TO PAINT (Flags + Configuration + Presence) **/ bool canDrawHighlights = (flags & Highlights) && !page->m_highlights.isEmpty(); - bool canDrawTextSelection = (flags & TextSelection) && page->m_textSelections; + bool canDrawTextSelection = (flags & TextSelection) && page->textSelection(); bool canDrawAnnotations = (flags & Annotations) && !page->m_annotations.isEmpty(); bool enhanceLinks = (flags & EnhanceLinks) && Okular::Settings::highlightLinks(); bool enhanceImages = (flags & EnhanceImages) && Okular::Settings::highlightImages(); @@ -119,11 +119,12 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const Okular::Page /* else {*/ Okular::NormalizedRect* limitRect = new Okular::NormalizedRect(nXMin, nYMin, nXMax, nYMax ); - Okular::HighlightAreaRect::const_iterator hIt = page->m_textSelections->begin(), hEnd = page->m_textSelections->end(); + const Okular::RegularAreaRect *textSelection = page->textSelection(); + Okular::HighlightAreaRect::const_iterator hIt = textSelection->begin(), hEnd = textSelection->end(); for ( ; hIt != hEnd; ++hIt ) { if ( (*hIt).intersects( limitRect ) ) - bufferedHighlights->append( qMakePair( page->m_textSelections->color, *hIt ) ); + bufferedHighlights->append( qMakePair( page->textSelectionColor(), *hIt ) ); } delete limitRect; //}