move the setTextSelections, setHighlight and deleteHighlights to the private class of Page, as they are private for now

svn path=/trunk/KDE/kdegraphics/okular/; revision=661486
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 1eb435cddb
commit 325b8711ea
  1. 14
      core/document.cpp
  2. 22
      core/page.cpp
  3. 16
      core/page.h
  4. 18
      core/page_p.h

@ -1483,7 +1483,7 @@ void Document::setPageTextSelection( int page, RegularAreaRect * rect, const QCo
// add or remove the selection basing whether rect is null or not // add or remove the selection basing whether rect is null or not
if ( rect ) if ( rect )
kp->setTextSelections( rect, color ); kp->d->setTextSelections( rect, color );
else else
kp->deleteTextSelections(); kp->deleteTextSelections();
@ -1641,7 +1641,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, Q
pagesToNotify += s->highlightedPages; pagesToNotify += s->highlightedPages;
QLinkedList< int >::const_iterator it = s->highlightedPages.begin(), end = s->highlightedPages.end(); QLinkedList< int >::const_iterator it = s->highlightedPages.begin(), end = s->highlightedPages.end();
for ( ; it != end; ++it ) for ( ; it != end; ++it )
d->m_pagesVector[ *it ]->deleteHighlights( searchID ); d->m_pagesVector[ *it ]->d->deleteHighlights( searchID );
s->highlightedPages.clear(); s->highlightedPages.clear();
// set hourglass cursor // set hourglass cursor
@ -1680,7 +1680,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, Q
break; break;
// add highligh rect to the page // add highligh rect to the page
page->setHighlight( searchID, lastMatch, color ); page->d->setHighlight( searchID, lastMatch, color );
addedHighlights = true; addedHighlights = true;
} }
delete lastMatch; delete lastMatch;
@ -1759,7 +1759,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, Q
s->continueOnMatch = *match; s->continueOnMatch = *match;
s->highlightedPages.append( currentPage ); s->highlightedPages.append( currentPage );
// ..add highlight to the page.. // ..add highlight to the page..
d->m_pagesVector[ currentPage ]->setHighlight( searchID, match, color ); d->m_pagesVector[ currentPage ]->d->setHighlight( searchID, match, color );
// ..queue page for notifying changes.. // ..queue page for notifying changes..
if ( !pagesToNotify.contains( currentPage ) ) if ( !pagesToNotify.contains( currentPage ) )
@ -1832,7 +1832,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, Q
break; break;
// add highligh rect to the page // add highligh rect to the page
page->setHighlight( searchID, lastMatch, wordColor ); page->d->setHighlight( searchID, lastMatch, wordColor );
wordMatched = true; wordMatched = true;
} }
allMatched = allMatched && wordMatched; allMatched = allMatched && wordMatched;
@ -1841,7 +1841,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, Q
// if not all words are present in page, remove partial highlights // if not all words are present in page, remove partial highlights
if ( !allMatched && matchAll ) if ( !allMatched && matchAll )
page->deleteHighlights( searchID ); page->d->deleteHighlights( searchID );
// if page contains all words, udpate internals and queue page for notify // if page contains all words, udpate internals and queue page for notify
if ( (allMatched && matchAll) || (anyMatched && !matchAll) ) if ( (allMatched && matchAll) || (anyMatched && !matchAll) )
@ -1898,7 +1898,7 @@ void Document::resetSearch( int searchID )
for ( ; it != end; ++it ) for ( ; it != end; ++it )
{ {
int pageNumber = *it; int pageNumber = *it;
d->m_pagesVector[ pageNumber ]->deleteHighlights( searchID ); d->m_pagesVector[ pageNumber ]->d->deleteHighlights( searchID );
foreachObserver( notifyPageChanged( pageNumber, DocumentObserver::Highlights ) ); foreachObserver( notifyPageChanged( pageNumber, DocumentObserver::Highlights ) );
} }

@ -123,7 +123,7 @@ Page::~Page()
{ {
deletePixmaps(); deletePixmaps();
deleteRects(); deleteRects();
deleteHighlights(); d->deleteHighlights();
deleteAnnotations(); deleteAnnotations();
deleteTextSelections(); deleteTextSelections();
deleteSourceReferences(); deleteSourceReferences();
@ -268,7 +268,7 @@ void PagePrivate::rotateAt( Rotation orientation )
if ( orientation == m_rotation ) if ( orientation == m_rotation )
return; return;
m_page->deleteHighlights(); deleteHighlights();
m_page->deleteTextSelections(); m_page->deleteTextSelections();
if ( ( (int)m_orientation + (int)m_rotation ) % 2 != ( (int)m_orientation + (int)orientation ) % 2 ) if ( ( (int)m_orientation + (int)m_rotation ) % 2 != ( (int)m_orientation + (int)orientation ) % 2 )
@ -403,27 +403,27 @@ void Page::setObjectRects( const QLinkedList< ObjectRect * > & rects )
m_rects << rects; m_rects << rects;
} }
void Page::setHighlight( int s_id, RegularAreaRect *rect, const QColor & color ) void PagePrivate::setHighlight( int s_id, RegularAreaRect *rect, const QColor & color )
{ {
HighlightAreaRect * hr = new HighlightAreaRect(rect); HighlightAreaRect * hr = new HighlightAreaRect(rect);
hr->s_id = s_id; hr->s_id = s_id;
hr->color = color; hr->color = color;
const QMatrix matrix = d->rotationMatrix(); const QMatrix matrix = rotationMatrix();
hr->transform( matrix ); hr->transform( matrix );
m_highlights.append( hr ); m_page->m_highlights.append( hr );
} }
void Page::setTextSelections( RegularAreaRect *r, const QColor & color ) void PagePrivate::setTextSelections( RegularAreaRect *r, const QColor & color )
{ {
deleteTextSelections(); m_page->deleteTextSelections();
if ( r ) if ( r )
{ {
HighlightAreaRect * hr = new HighlightAreaRect( r ); HighlightAreaRect * hr = new HighlightAreaRect( r );
hr->s_id = -1; hr->s_id = -1;
hr->color = color; hr->color = color;
d->m_textSelections = hr; m_textSelections = hr;
} }
} }
@ -596,16 +596,16 @@ void Page::deleteRects()
deleteObjectRects( m_rects, which ); deleteObjectRects( m_rects, which );
} }
void Page::deleteHighlights( int s_id ) void PagePrivate::deleteHighlights( int s_id )
{ {
// delete highlights by ID // delete highlights by ID
QLinkedList< HighlightAreaRect* >::iterator it = m_highlights.begin(), end = m_highlights.end(); QLinkedList< HighlightAreaRect* >::iterator it = m_page->m_highlights.begin(), end = m_page->m_highlights.end();
while ( it != end ) while ( it != end )
{ {
HighlightAreaRect* highlight = *it; HighlightAreaRect* highlight = *it;
if ( s_id == -1 || highlight->s_id == s_id ) if ( s_id == -1 || highlight->s_id == s_id )
{ {
it = m_highlights.erase( it ); it = m_page->m_highlights.erase( it );
delete highlight; delete highlight;
} }
else else

@ -209,17 +209,6 @@ class OKULAR_EXPORT Page
*/ */
void setObjectRects( const QLinkedList< ObjectRect * > & rects ); void setObjectRects( const QLinkedList< ObjectRect * > & rects );
/**
* Sets the @p color and @p area of the highlight for the observer with
* the given @p id.
*/
void setHighlight( int id, RegularAreaRect *area, const QColor & color );
/**
* Sets the @p color and @p areas of text selections.
*/
void setTextSelections( RegularAreaRect *areas, const QColor & color );
/** /**
* Sets the list of source reference objects @p rects. * Sets the list of source reference objects @p rects.
*/ */
@ -300,11 +289,6 @@ class OKULAR_EXPORT Page
*/ */
void deleteRects(); void deleteRects();
/**
* Deletes all highlight objects for the observer with the given @p id.
*/
void deleteHighlights( int id = -1 );
/** /**
* Deletes all text selection objects of the page. * Deletes all text selection objects of the page.
*/ */

@ -19,7 +19,9 @@
// local includes // local includes
#include "global.h" #include "global.h"
#include "area.h"
class QColor;
class QDomDocument; class QDomDocument;
class QDomNode; class QDomNode;
@ -73,6 +75,22 @@ class PagePrivate
*/ */
void changeSize( const PageSize &size ); void changeSize( const PageSize &size );
/**
* Sets the @p color and @p areas of text selections.
*/
void setTextSelections( RegularAreaRect *areas, const QColor & color );
/**
* Sets the @p color and @p area of the highlight for the observer with
* the given @p id.
*/
void setHighlight( int id, RegularAreaRect *area, const QColor & color );
/**
* Deletes all highlight objects for the observer with the given @p id.
*/
void deleteHighlights( int id = -1 );
class PixmapObject class PixmapObject
{ {
public: public:

Loading…
Cancel
Save