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();
// request search page if needed
if ( !page->hasSearchPage() )
if ( !page->hasTextPage() )
requestTextPage( pageNumber );
// 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);
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;
if ( lastPage && lastPage->number() == s->continueOnPage )
{
@ -1094,7 +1094,7 @@ bool Document::searchText( int searchID, const QString & text, bool fromStart, b
// get page
Page * page = pages_vector[ currentPage ];
// request search page if needed
if ( !page->hasSearchPage() )
if ( !page->hasTextPage() )
requestTextPage( page->number() );
// if found a match on the current page, end the loop
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();
// request search page if needed
if ( !page->hasSearchPage() )
if ( !page->hasTextPage() )
requestTextPage( pageNumber );
// 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);
}
bool Page::hasSearchPage() const
bool Page::hasTextPage() const
{
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;
m_text = tp;

@ -54,7 +54,23 @@ class OKULAR_EXPORT Page : public QObject
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 );
/**
* Destroys the page.
*/
~Page();
// 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 height() const { return m_height; }
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 hasObjectRect( double x, double y, double xScale, double yScale ) const;
bool hasHighlights( int s_id = -1 ) const;
@ -90,7 +115,7 @@ class OKULAR_EXPORT Page : public QObject
// operations: set contents (by Document)
void setPixmap( int p_id, QPixmap *pixmap );
void setSearchPage( TextPage * text );
void setTextPage( TextPage * text );
void setBookmark( bool state );
void setObjectRects( const QLinkedList< ObjectRect * > rects );
void setHighlight( int s_id, RegularAreaRect *r, const QColor & color );

@ -268,7 +268,7 @@ void CHMGenerator::additionalRequestData()
{
Okular::Page * page=m_request->page();
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 )
{
@ -345,7 +345,7 @@ void CHMGenerator::additionalRequestData()
kDebug() << "Generating text page - start" << endl;
Okular::TextPage *tp=new Okular::TextPage();
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 ));
Okular::TextPage *tp=new Okular::TextPage();
recursiveExploreNodes( m_syncGen->htmlDocument(), tp);
page->setSearchPage(tp);
page->setTextPage(tp);
syncLock.unlock();
}

@ -260,7 +260,7 @@ void DviGenerator::generateSyncTextPage( Okular::Page* page )
m_dviRenderer->getText( pageInfo );
Okular::TextPage *ktp = extractTextFromPage( pageInfo, page->totalOrientation() );
page->setSearchPage( ktp );
page->setTextPage( ktp );
}
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.
// 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());
// generate links and image rects if rendering pages on pageview
bool genObjectRects = request->id() & (PAGEVIEW_ID | PRESENTATION_ID);
@ -622,7 +622,7 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
if ( genTextPage )
{
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);
}
delete p;
@ -649,7 +649,7 @@ void PDFGenerator::generateSyncTextPage( Okular::Page * page )
docLock.unlock();
delete pp;
// ..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);
}
@ -1286,7 +1286,7 @@ void PDFGenerator::threadFinished()
delete outImage;
if ( !outText.isEmpty() )
{
request->page()->setSearchPage( abstractTextPage( outText ,
request->page()->setTextPage( abstractTextPage( outText ,
request->page()->height(), request->page()->width(),request->page()->totalOrientation()));
qDeleteAll(outText);
}
@ -1433,7 +1433,7 @@ void PDFPixmapGeneratorThread::run()
// 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?
bool genTextPage = !page->hasSearchPage() &&
bool genTextPage = !page->hasTextPage() &&
( width == page->width() ) &&
( height == page->height() );

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

Loading…
Cancel
Save