Page::setSearchPage( TextPage* );
  Page::hasSearchPage();

with

  Page::setTextPage( TextPage* );
  Page::hasTextPage();

to make the API clearer. The TextPage is not only used for
searching but also for extracting selected text, so the term
'search' is confusing...


svn path=/trunk/playground/graphics/okular/; revision=607195
remotes/origin/KDE/4.0
Tobias Koenig 20 years ago
parent 47636c5ae0
commit a7b04cb92b
  1. 8
      core/document.cpp
  2. 4
      core/page.cpp
  3. 31
      core/page.h
  4. 6
      generators/chm/generator_chm.cpp
  5. 2
      generators/dvi/generator_dvi.cpp
  6. 10
      generators/poppler/generator_pdf.cpp
  7. 8
      ui/pageview.cpp

@ -1020,7 +1020,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, b
int pageNumber = page->number(); int pageNumber = page->number();
// request search page if needed // request search page if needed
if ( !page->hasSearchPage() ) if ( !page->hasTextPage() )
requestTextPage( pageNumber ); requestTextPage( pageNumber );
// loop on a page adding highlights for all found items // loop on a page adding highlights for all found items
@ -1066,7 +1066,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, b
int currentPage = fromStart ? 0 : ((s->continueOnPage != -1) ? s->continueOnPage : viewportPage); int currentPage = fromStart ? 0 : ((s->continueOnPage != -1) ? s->continueOnPage : viewportPage);
Page * lastPage = fromStart ? 0 : pages_vector[ currentPage ]; Page * lastPage = fromStart ? 0 : pages_vector[ currentPage ];
// continue checking last SearchPage first (if it is the current page) // continue checking last TextPage first (if it is the current page)
RegularAreaRect * match = 0; RegularAreaRect * match = 0;
if ( lastPage && lastPage->number() == s->continueOnPage ) if ( lastPage && lastPage->number() == s->continueOnPage )
{ {
@ -1094,7 +1094,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, b
// get page // get page
Page * page = pages_vector[ currentPage ]; Page * page = pages_vector[ currentPage ];
// request search page if needed // request search page if needed
if ( !page->hasSearchPage() ) if ( !page->hasTextPage() )
requestTextPage( page->number() ); requestTextPage( page->number() );
// if found a match on the current page, end the loop // if found a match on the current page, end the loop
if ( ( match = page->findText( searchID, text, FromTop, caseSensitive ) ) ) if ( ( match = page->findText( searchID, text, FromTop, caseSensitive ) ) )
@ -1156,7 +1156,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, b
int pageNumber = page->number(); int pageNumber = page->number();
// request search page if needed // request search page if needed
if ( !page->hasSearchPage() ) if ( !page->hasTextPage() )
requestTextPage( pageNumber ); requestTextPage( pageNumber );
// loop on a page adding highlights for all found items // loop on a page adding highlights for all found items

@ -87,7 +87,7 @@ bool Page::hasPixmap( int id, int width, int height ) const
return (pixmap->width() == width && pixmap->height() == height); return (pixmap->width() == width && pixmap->height() == height);
} }
bool Page::hasSearchPage() const bool Page::hasTextPage() const
{ {
return m_text != 0; return m_text != 0;
} }
@ -289,7 +289,7 @@ void Page::setPixmap( int id, QPixmap *pixmap )
} }
} }
void Page::setSearchPage( TextPage * tp ) void Page::setTextPage( TextPage * tp )
{ {
delete m_text; delete m_text;
m_text = tp; m_text = tp;

@ -54,7 +54,23 @@ class OKULAR_EXPORT Page : public QObject
Closing Closing
}; };
/**
* Creates a new page.
*
* @param number The number of the page in the document.
* @param width The width of the page.
* @param height The height of the page.
* @param orientation The orientation of the page with
* 0 = 0°
* 1 = 90°
* 2 = 180°
* 3 = 270°
*/
Page( uint number, double width, double height, int orientation ); Page( uint number, double width, double height, int orientation );
/**
* Destroys the page.
*/
~Page(); ~Page();
// query properties (const read-only methods) // query properties (const read-only methods)
@ -65,8 +81,17 @@ class OKULAR_EXPORT Page : public QObject
inline double width() const { return m_width; } inline double width() const { return m_width; }
inline double height() const { return m_height; } inline double height() const { return m_height; }
inline double ratio() const { return m_height / m_width; } inline double ratio() const { return m_height / m_width; }
bool hasPixmap( int p_id, int width = -1, int height = -1 ) const;
bool hasSearchPage() const; /**
* Returns whether the page has a pixmap of size @p width x @p height
* for the observer with given @p id.
*/
bool hasPixmap( int id, int width = -1, int height = -1 ) const;
/**
* Returns whether the page provides a text page (@see TextPage).
*/
bool hasTextPage() const;
bool hasBookmark() const; bool hasBookmark() const;
bool hasObjectRect( double x, double y, double xScale, double yScale ) const; bool hasObjectRect( double x, double y, double xScale, double yScale ) const;
bool hasHighlights( int s_id = -1 ) const; bool hasHighlights( int s_id = -1 ) const;
@ -90,7 +115,7 @@ class OKULAR_EXPORT Page : public QObject
// operations: set contents (by Document) // operations: set contents (by Document)
void setPixmap( int p_id, QPixmap *pixmap ); void setPixmap( int p_id, QPixmap *pixmap );
void setSearchPage( TextPage * text ); void setTextPage( TextPage * text );
void setBookmark( bool state ); void setBookmark( bool state );
void setObjectRects( const QLinkedList< ObjectRect * > rects ); void setObjectRects( const QLinkedList< ObjectRect * > rects );
void setHighlight( int s_id, RegularAreaRect *r, const QColor & color ); void setHighlight( int s_id, RegularAreaRect *r, const QColor & color );

@ -268,7 +268,7 @@ void CHMGenerator::additionalRequestData()
{ {
Okular::Page * page=m_request->page(); Okular::Page * page=m_request->page();
bool genObjectRects = m_request->id() & (PAGEVIEW_ID | PRESENTATION_ID); bool genObjectRects = m_request->id() & (PAGEVIEW_ID | PRESENTATION_ID);
bool genTextPage = !m_request->page()->hasSearchPage() && genObjectRects; bool genTextPage = !m_request->page()->hasTextPage() && genObjectRects;
if (genObjectRects || genTextPage ) if (genObjectRects || genTextPage )
{ {
@ -345,7 +345,7 @@ void CHMGenerator::additionalRequestData()
kDebug() << "Generating text page - start" << endl; kDebug() << "Generating text page - start" << endl;
Okular::TextPage *tp=new Okular::TextPage(); Okular::TextPage *tp=new Okular::TextPage();
recursiveExploreNodes(domDoc,tp); recursiveExploreNodes(domDoc,tp);
page->setSearchPage (tp); page->setTextPage (tp);
} }
} }
} }
@ -364,7 +364,7 @@ void CHMGenerator::generateSyncTextPage( Okular::Page * page )
preparePageForSyncOperation(zoom, m_file->getUrlForPage ( page->number() + 1 )); preparePageForSyncOperation(zoom, m_file->getUrlForPage ( page->number() + 1 ));
Okular::TextPage *tp=new Okular::TextPage(); Okular::TextPage *tp=new Okular::TextPage();
recursiveExploreNodes( m_syncGen->htmlDocument(), tp); recursiveExploreNodes( m_syncGen->htmlDocument(), tp);
page->setSearchPage(tp); page->setTextPage(tp);
syncLock.unlock(); syncLock.unlock();
} }

@ -260,7 +260,7 @@ void DviGenerator::generateSyncTextPage( Okular::Page* page )
m_dviRenderer->getText( pageInfo ); m_dviRenderer->getText( pageInfo );
Okular::TextPage *ktp = extractTextFromPage( pageInfo, page->totalOrientation() ); Okular::TextPage *ktp = extractTextFromPage( pageInfo, page->totalOrientation() );
page->setSearchPage( ktp ); page->setTextPage( ktp );
} }
delete pageInfo; delete pageInfo;
} }

@ -590,7 +590,7 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
// setup Okular:: output device: text page is generated only if we are at 72dpi. // setup Okular:: output device: text page is generated only if we are at 72dpi.
// since we can pre-generate the TextPage at the right res.. why not? // since we can pre-generate the TextPage at the right res.. why not?
bool genTextPage = !page->hasSearchPage() && (request->width() == page->width()) && bool genTextPage = !page->hasTextPage() && (request->width() == page->width()) &&
(request->height() == page->height()); (request->height() == page->height());
// generate links and image rects if rendering pages on pageview // generate links and image rects if rendering pages on pageview
bool genObjectRects = request->id() & (PAGEVIEW_ID | PRESENTATION_ID); bool genObjectRects = request->id() & (PAGEVIEW_ID | PRESENTATION_ID);
@ -622,7 +622,7 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
if ( genTextPage ) if ( genTextPage )
{ {
QList<Poppler::TextBox*> textList = p->textList((Poppler::Page::Rotation)request->page()->rotation()); QList<Poppler::TextBox*> textList = p->textList((Poppler::Page::Rotation)request->page()->rotation());
page->setSearchPage( abstractTextPage(textList, page->height(), page->width(), request->page()->totalOrientation()) ); page->setTextPage( abstractTextPage(textList, page->height(), page->width(), request->page()->totalOrientation()) );
qDeleteAll(textList); qDeleteAll(textList);
} }
delete p; delete p;
@ -649,7 +649,7 @@ void PDFGenerator::generateSyncTextPage( Okular::Page * page )
docLock.unlock(); docLock.unlock();
delete pp; delete pp;
// ..and attach it to the page // ..and attach it to the page
page->setSearchPage( abstractTextPage(textList, page->height(), page->width(), page->totalOrientation()) ); page->setTextPage( abstractTextPage(textList, page->height(), page->width(), page->totalOrientation()) );
qDeleteAll(textList); qDeleteAll(textList);
} }
@ -1286,7 +1286,7 @@ void PDFGenerator::threadFinished()
delete outImage; delete outImage;
if ( !outText.isEmpty() ) if ( !outText.isEmpty() )
{ {
request->page()->setSearchPage( abstractTextPage( outText , request->page()->setTextPage( abstractTextPage( outText ,
request->page()->height(), request->page()->width(),request->page()->totalOrientation())); request->page()->height(), request->page()->width(),request->page()->totalOrientation()));
qDeleteAll(outText); qDeleteAll(outText);
} }
@ -1433,7 +1433,7 @@ void PDFPixmapGeneratorThread::run()
// setup Okular:: output device: text page is generated only if we are at 72dpi. // setup Okular:: output device: text page is generated only if we are at 72dpi.
// since we can pre-generate the TextPage at the right res.. why not? // since we can pre-generate the TextPage at the right res.. why not?
bool genTextPage = !page->hasSearchPage() && bool genTextPage = !page->hasTextPage() &&
( width == page->width() ) && ( width == page->width() ) &&
( height == page->height() ); ( height == page->height() );

@ -1598,8 +1598,8 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
{ {
// request the textpage if there isn't one // request the textpage if there isn't one
okularPage= item->page(); okularPage= item->page();
kWarning() << "checking if page " << item->pageNumber() << " has text " << okularPage->hasSearchPage() << endl; kWarning() << "checking if page " << item->pageNumber() << " has text " << okularPage->hasTextPage() << endl;
if ( !okularPage->hasSearchPage() ) if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() ); d->document->requestTextPage( okularPage->number() );
// grab text in the rect that intersects itemRect // grab text in the rect that intersects itemRect
QRect relativeRect = selectionRect.intersect( itemRect ); QRect relativeRect = selectionRect.intersect( itemRect );
@ -2089,7 +2089,7 @@ Okular::RegularAreaRect * PageView::textSelectionForItem( PageViewItem * item, c
const Okular::Page * okularPage = item->page(); const Okular::Page * okularPage = item->page();
if ( !okularPage->hasSearchPage() ) if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() ); d->document->requestTextPage( okularPage->number() );
Okular::RegularAreaRect * selectionArea = okularPage->getTextArea( &mouseTextSelectionInfo ); Okular::RegularAreaRect * selectionArea = okularPage->getTextArea( &mouseTextSelectionInfo );
@ -2617,7 +2617,7 @@ void PageView::slotRequestVisiblePixmaps()
#ifdef PAGEVIEW_DEBUG #ifdef PAGEVIEW_DEBUG
kWarning() << "checking for pixmap for page " << i->pageNumber() << " = " << i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) << "\n"; kWarning() << "checking for pixmap for page " << i->pageNumber() << " = " << i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) << "\n";
#endif #endif
kWarning() << "checking for text for page " << i->pageNumber() << " = " << i->page()->hasSearchPage() << "\n"; kWarning() << "checking for text for page " << i->pageNumber() << " = " << i->page()->hasTextPage() << "\n";
// if the item has not the right pixmap, add a request for it // if the item has not the right pixmap, add a request for it
if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) ) if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) )
{ {

Loading…
Cancel
Save