hide the text selection inside the private class of Page

svn path=/trunk/playground/graphics/okular/; revision=648095
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 874714e2b5
commit 95bb597a85
  1. 18
      core/page.cpp
  2. 7
      core/page.h
  3. 2
      core/page_p.h
  4. 7
      ui/pagepainter.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()

@ -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 )
};

@ -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;

@ -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;
//}

Loading…
Cancel
Save