mirror of
https://invent.kde.org/graphics/okular
synced 2024-11-05 18:34:53 +00:00
Fixing selection for zooms!=100%.
svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=359121
This commit is contained in:
parent
7ba71e2bdd
commit
f68cf649d7
4 changed files with 10 additions and 6 deletions
|
@ -67,11 +67,15 @@ bool KPDFPage::hasSearchPage() const
|
|||
return ( m_text != 0 );
|
||||
}
|
||||
|
||||
QString KPDFPage::getTextInRect( const QRect & rect ) const
|
||||
QString KPDFPage::getTextInRect( const QRect & rect, double zoom ) const
|
||||
{
|
||||
if ( !m_text )
|
||||
return QString();
|
||||
GString * text = m_text->getText( rect.left(), rect.top(), rect.right(), rect.bottom() );
|
||||
int left = (int)((double)rect.left() / zoom),
|
||||
top = (int)((double)rect.top() / zoom),
|
||||
right = (int)((double)rect.right() / zoom),
|
||||
bottom = (int)((double)rect.bottom() / zoom);
|
||||
GString * text = m_text->getText( left, top, right, bottom );
|
||||
return QString( text->getCString() );
|
||||
}
|
||||
|
||||
|
@ -151,7 +155,7 @@ void KPDFPage::drawPixmap( int id, QPainter * p, const QRect & limits, int width
|
|||
p->drawLine( 0, 0, width-1, height-1 );
|
||||
p->drawLine( 0, height-1, width-1, 0 );
|
||||
}
|
||||
// draw selection
|
||||
// draw selection (note: it is rescaled since the text page is at 100% scale)
|
||||
if ( m_hilighting )
|
||||
{
|
||||
int x = (int)( m_sLeft * width / m_width ),
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
bool isBookmarked() const { return m_bookmarking; }
|
||||
bool hasPixmap( int id, int width, int height ) const;
|
||||
bool hasSearchPage() const;
|
||||
QString getTextInRect( const QRect & rect ) const;
|
||||
QString getTextInRect( const QRect & rect, double zoom = 1.0 ) const;
|
||||
bool hasLink( int mouseX, int mouseY ) const;
|
||||
const KPDFLink * getLink( int mouseX, int mouseY ) const;
|
||||
bool hasActiveRect( int mouseX, int mouseY ) const;
|
||||
|
|
|
@ -649,7 +649,7 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
|
|||
QClipboard *cb = QApplication::clipboard();
|
||||
QRect relativeRect = d->mouseSelectionRect;
|
||||
relativeRect.moveBy( -d->activeItem->geometry().left(), -d->activeItem->geometry().top() );
|
||||
const QString & selection = kpdfPage->getTextInRect( relativeRect );
|
||||
const QString & selection = kpdfPage->getTextInRect( relativeRect, d->activeItem->zoomFactor() );
|
||||
|
||||
cb->setText( selection, QClipboard::Clipboard );
|
||||
if ( cb->supportsSelection() )
|
||||
|
|
|
@ -35,7 +35,7 @@ class PageViewItem
|
|||
m_geometry.setHeight( h );
|
||||
m_zoomFactor = z;
|
||||
}
|
||||
float zoomFactor() { return m_zoomFactor; }
|
||||
double zoomFactor() { return m_zoomFactor; }
|
||||
|
||||
int pageNumber() const { return m_page->number(); }
|
||||
const KPDFPage * page() const { return m_page; }
|
||||
|
|
Loading…
Reference in a new issue