Small API fixes. Preparing for mem-manager / async-gen. Removed KPDFDocument

dependancy from QObject. Kpdf_Part is now a Document Observer (only monitors
page changes to update actions).
Modified Accessibility(Recolor) settings and config dialog, fixed a bug,
page color change on-the-fly (pixmap refresh mechanism to add..).

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=361759
This commit is contained in:
Enrico Ros 2004-11-09 17:20:19 +00:00
parent 49438a20f6
commit b1ad685b54
11 changed files with 693 additions and 643 deletions

View file

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>362</height>
<width>376</width>
<height>358</height>
</rect>
</property>
<property name="caption">
@ -22,9 +22,31 @@
<property name="margin">
<number>0</number>
</property>
<widget class="QButtonGroup">
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_RenderMode</cstring>
<cstring>kcfg_HighlightImages</cstring>
</property>
<property name="text">
<string>Draw border around &amp;Images</string>
</property>
<property name="accel">
<string>Alt+I</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_HighlightLinks</cstring>
</property>
<property name="text">
<string>Draw border around &amp;Links</string>
</property>
<property name="accel">
<string>Alt+L</string>
</property>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>kcfg_ChangeColors</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
@ -35,453 +57,461 @@
</sizepolicy>
</property>
<property name="title">
<string>Page &amp;Rendering</string>
<string>Change &amp;Colors</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QRadioButton">
<widget class="QLabel">
<property name="name">
<cstring>radioNormal</cstring>
<cstring>warn</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="paletteForegroundColor">
<color>
<red>80</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="text">
<string>&amp;Normal (default)</string>
<string>Warning: these options can badly affect drawing speed.</string>
</property>
<property name="accel">
<string>Alt+N</string>
</property>
<property name="checked">
<bool>true</bool>
<property name="textFormat">
<enum>PlainText</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<widget class="QButtonGroup">
<property name="name">
<cstring>layout5</cstring>
<cstring>kcfg_RenderMode</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer>
<property name="name">
<cstring>spacer14_3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QLabel">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Paper color:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_PaperColor</cstring>
</property>
</widget>
<widget class="KColorButton">
<property name="name">
<cstring>kcfg_PaperColor</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>textLabel1_2</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>(needs restart)</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_PaperColor</cstring>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer7_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>radioInverted</cstring>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Invert colors</string>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accel">
<string>Alt+I</string>
<property name="frameShape">
<enum>NoFrame</enum>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>radioRecolor</cstring>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>&amp;Change foreground and background colors</string>
<property name="title">
<string></string>
</property>
<property name="accel">
<string>Alt+C</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout2</cstring>
</property>
<grid>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<spacer row="1" column="3">
<widget class="QRadioButton">
<property name="name">
<cstring>spacer12_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="KColorButton" row="1" column="2">
<property name="name">
<cstring>kcfg_RecolorBackground</cstring>
</property>
<property name="enabled">
<bool>false</bool>
<cstring>radioInverted</cstring>
</property>
<property name="text">
<string></string>
<string>&amp;Invert colors</string>
</property>
<property name="accel">
<string>Alt+I</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<spacer row="1" column="0">
<widget class="QRadioButton">
<property name="name">
<cstring>spacer14_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="KColorButton" row="0" column="2">
<property name="name">
<cstring>kcfg_RecolorForeground</cstring>
</property>
<property name="enabled">
<bool>false</bool>
<cstring>radioNormal</cstring>
</property>
<property name="text">
<string></string>
<string>Change &amp;paper color</string>
</property>
<property name="accel">
<string>Alt+P</string>
</property>
</widget>
<spacer row="0" column="3">
<widget class="QLayoutWidget">
<property name="name">
<cstring>spacer12</cstring>
<cstring>layout5</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="QLabel" row="1" column="1">
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer>
<property name="name">
<cstring>spacer14_3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QLabel">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Paper color:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_PaperColor</cstring>
</property>
</widget>
<widget class="KColorButton">
<property name="name">
<cstring>kcfg_PaperColor</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer7_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>textLabel3_2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
<cstring>radioRecolor</cstring>
</property>
<property name="text">
<string>Background color:</string>
<string>&amp;Change dark and light colors</string>
</property>
<property name="accel">
<string>Alt+C</string>
</property>
</widget>
<spacer row="0" column="0">
<widget class="QLayoutWidget">
<property name="name">
<cstring>spacer14</cstring>
<cstring>layout2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QLabel" row="0" column="1">
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<spacer row="1" column="3">
<property name="name">
<cstring>spacer12_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="KColorButton" row="1" column="2">
<property name="name">
<cstring>kcfg_RecolorBackground</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer14_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="KColorButton" row="0" column="2">
<property name="name">
<cstring>kcfg_RecolorForeground</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
<spacer row="0" column="3">
<property name="name">
<cstring>spacer12</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="QLabel" row="1" column="1">
<property name="name">
<cstring>textLabel3_2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Dark color:</string>
</property>
</widget>
<spacer row="0" column="0">
<property name="name">
<cstring>spacer14</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Light color:</string>
</property>
</widget>
</grid>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="enabled">
<bool>false</bool>
<cstring>radioContrast</cstring>
</property>
<property name="text">
<string>Foreground color:</string>
<string>Convert to &amp;Black and White</string>
</property>
<property name="accel">
<string>Alt+B</string>
</property>
</widget>
</grid>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>radioContrast</cstring>
</property>
<property name="text">
<string>Convert to &amp;Black and White</string>
</property>
<property name="accel">
<string>Alt+B</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout5</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="1" column="1">
<widget class="QLayoutWidget">
<property name="name">
<cstring>textLabel2_2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Contrast</string>
<cstring>layout5</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="1" column="1">
<property name="name">
<cstring>textLabel2_2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Contrast</string>
</property>
</widget>
<spacer row="1" column="3">
<property name="name">
<cstring>spacer10_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer11_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="0" column="0">
<property name="name">
<cstring>spacer11</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="0" column="3">
<property name="name">
<cstring>spacer10</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="QSlider" row="1" column="2">
<property name="name">
<cstring>kcfg_BWContrast</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QSlider" row="0" column="2">
<property name="name">
<cstring>kcfg_BWThreshold</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</grid>
</widget>
<spacer row="1" column="3">
<property name="name">
<cstring>spacer10_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer11_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="0" column="0">
<property name="name">
<cstring>spacer11</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="0" column="3">
<property name="name">
<cstring>spacer10</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>48</width>
<height>21</height>
</size>
</property>
</spacer>
<widget class="QSlider" row="1" column="2">
<property name="name">
<cstring>kcfg_BWContrast</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QSlider" row="0" column="2">
<property name="name">
<cstring>kcfg_BWThreshold</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pageStep">
<number>16</number>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>&amp;Visual Enhance</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_HighlightImages</cstring>
</property>
<property name="text">
<string>Draw &amp;border around images</string>
</property>
<property name="accel">
<string>Alt+B</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_HighlightLinks</cstring>
</property>
<property name="text">
<string>Highlight &amp;links</string>
</property>
<property name="accel">
<string>Alt+L</string>
</property>
</vbox>
</widget>
</vbox>
</widget>
@ -536,12 +566,6 @@
<receiver>kcfg_PaperColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>radioNormal</sender>
<signal>toggled(bool)</signal>
<receiver>textLabel1_2</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>radioContrast</sender>
<signal>toggled(bool)</signal>
@ -554,6 +578,12 @@
<receiver>kcfg_BWContrast</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>kcfg_ChangeColors</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_RenderMode</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>

View file

@ -11,17 +11,19 @@
<entry key="HighlightLinks" type="Bool" >
<default>false</default>
</entry>
<entry key="ChangeColors" type="Bool" >
<default>false</default>
</entry>
<entry key="RenderMode" type="Enum" >
<default>Normal</default>
<default>Inverted</default>
<choices>
<choice name="Normal" />
<choice name="pad_paper_color" />
<choice name="Inverted" />
<choice name="Paper" />
<choice name="pad_paper_color" />
<choice name="Recolor" />
<choice name="pad_fg_color" />
<choice name="pad_bg_color" />
<choice name="BlackWhite" />
<choice name="pad_contrast" />
</choices>
</entry>
<entry key="RecolorForeground" type="Color" >

View file

@ -57,6 +57,7 @@ public:
int currentPage;
QRect currentViewport;
QValueVector< KPDFPage* > pages;
QColor paperColor;
// find related
QString searchText;
@ -84,12 +85,9 @@ KPDFDocument::KPDFDocument()
d->pdfdoc = 0;
d->currentPage = -1;
d->searchPage = -1;
// load paper color from Settings
QColor col = Settings::paperColor();
SplashColor paperColor;
paperColor.rgb8 = splashMakeRGB8( col.red(), col.green(), col.blue() );
// create the output device
d->kpdfOutputDev = new KPDFOutputDev( paperColor );
d->kpdfOutputDev = 0;
// create the outputdev
reparseConfig();
}
KPDFDocument::~KPDFDocument()
@ -179,7 +177,7 @@ bool KPDFDocument::openDocument( const QString & docFile )
d->pages[i] = new KPDFPage( i, d->pdfdoc->getPageWidth(i+1), d->pdfdoc->getPageHeight(i+1), d->pdfdoc->getPageRotate(i+1) );
// filter pages, setup observers and set the first page as current
processPageList( true );
slotSetCurrentPage( 0 );
setCurrentPage( 0 );
}
// check local directory for an overlay xml
@ -212,6 +210,34 @@ void KPDFDocument::closeDocument()
}
void KPDFDocument::addObserver( KPDFDocumentObserver * pObserver )
{
d->observers[ pObserver->observerId() ] = pObserver;
}
void KPDFDocument::reparseConfig()
{
// load paper color from Settings or use the white default color
QColor color = ( (Settings::renderMode() == Settings::EnumRenderMode::Paper ) &&
Settings::changeColors() ) ? Settings::paperColor() : Qt::white;
if ( color != d->paperColor || !d->kpdfOutputDev )
{
d->paperColor = color;
SplashColor paperColor;
paperColor.rgb8 = splashMakeRGB8( d->paperColor.red(), d->paperColor.green(), d->paperColor.blue() );
// rebuild the output device using the new paper color
d->docLock.lock();
delete d->kpdfOutputDev;
d->kpdfOutputDev = new KPDFOutputDev( paperColor );
if ( d->pdfdoc )
d->kpdfOutputDev->startDoc( d->pdfdoc->getXRef() );
d->docLock.unlock();
// invalidate pixmaps
//FIXME missing
}
}
uint KPDFDocument::currentPage() const
{
return d->currentPage;
@ -222,19 +248,9 @@ uint KPDFDocument::pages() const
return d->pdfdoc ? d->pdfdoc->getNumPages() : 0;
}
bool KPDFDocument::atBegin() const
bool KPDFDocument::okToPrint() const
{
return d->currentPage < 1;
}
bool KPDFDocument::atEnd() const
{
return d->currentPage >= ((int)d->pages.count() - 1);
}
const KPDFPage * KPDFDocument::page( uint n ) const
{
return ( n < d->pages.count() ) ? d->pages[n] : 0;
return d->pdfdoc->okToPrint();
}
Outline * KPDFDocument::outline() const
@ -242,12 +258,12 @@ Outline * KPDFDocument::outline() const
return d->pdfdoc ? d->pdfdoc->getOutline() : 0;
}
void KPDFDocument::addObserver( KPDFDocumentObserver * pObserver )
const KPDFPage * KPDFDocument::page( uint n ) const
{
d->observers[ pObserver->observerId() ] = pObserver;
return ( n < d->pages.count() ) ? d->pages[n] : 0;
}
void KPDFDocument::requestPixmap( int id, uint page, int width, int height, bool syn )
{
KPDFPage * kp = d->pages[page];
@ -305,51 +321,7 @@ void KPDFDocument::requestTextPage( uint n )
page->setSearchPage( td.takeTextPage() );
}
bool KPDFDocument::okToPrint() const
{
return d->pdfdoc->okToPrint();
}
bool KPDFDocument::print(KPrinter &printer)
{
KTempFile tf( QString::null, ".ps" );
PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), d->pdfdoc->getXRef(), d->pdfdoc->getCatalog(), 1, d->pdfdoc->getNumPages(), psModePS);
if (psOut->isOk())
{
std::list<int> pages;
if (!printer.previewOnly())
{
QValueList<int> pageList = printer.pageList();
QValueList<int>::const_iterator it;
for(it = pageList.begin(); it != pageList.end(); ++it) pages.push_back(*it);
}
else
{
for(int i = 1; i <= d->pdfdoc->getNumPages(); i++) pages.push_back(i);
}
d->docLock.lock();
d->pdfdoc->displayPages(psOut, pages, 72, 72, 0, globalParams->getPSCrop(), gFalse);
d->docLock.unlock();
// needs to be here so that the file is flushed, do not merge with the one
// in the else
delete psOut;
printer.printFiles(tf.name(), true);
return true;
}
else
{
delete psOut;
return false;
}
}
// BEGIN slots
void KPDFDocument::slotSetCurrentPage( int page, const QRect & viewport )
void KPDFDocument::setCurrentPage( int page, const QRect & viewport )
{
if ( page < 0 )
page = 0;
@ -360,27 +332,9 @@ void KPDFDocument::slotSetCurrentPage( int page, const QRect & viewport )
d->currentPage = page;
d->currentViewport = viewport;
foreachObserver( pageSetCurrent( page, viewport ) );
pageChanged();
}
void KPDFDocument::slotSetFilter( const QString & pattern, bool keepCase )
{
d->filterText = pattern;
d->filterCase = keepCase;
processPageList( false );
}
void KPDFDocument::slotToggleBookmark( int n )
{
KPDFPage * page = ( n < (int)d->pages.count() ) ? d->pages[ n ] : 0;
if ( page )
{
page->toggleAttribute( KPDFPage::Bookmark );
foreachObserver( notifyPixmapChanged( n ) );
}
}
void KPDFDocument::slotFind( const QString & string, bool keepCase )
void KPDFDocument::findText( const QString & string, bool keepCase )
{
// turn selection drawing off on filtered pages
if ( !d->filterText.isEmpty() )
@ -435,14 +389,31 @@ void KPDFDocument::slotFind( const QString & string, bool keepCase )
int pageNumber = foundPage->number();
d->searchPage = pageNumber;
foundPage->setAttribute( KPDFPage::Highlight );
slotSetCurrentPage( pageNumber );
setCurrentPage( pageNumber );
foreachObserver( notifyPixmapChanged( pageNumber ) );
}
else
KMessageBox::information( 0, i18n("No matches found for '%1'.").arg(d->searchText) );
}
void KPDFDocument::slotProcessLink( const KPDFLink * link )
void KPDFDocument::findTextAll( const QString & pattern, bool keepCase )
{
d->filterText = pattern;
d->filterCase = keepCase;
processPageList( false );
}
void KPDFDocument::toggleBookmark( int n )
{
KPDFPage * page = ( n < (int)d->pages.count() ) ? d->pages[ n ] : 0;
if ( page )
{
page->toggleAttribute( KPDFPage::Bookmark );
foreachObserver( notifyPixmapChanged( n ) );
}
}
void KPDFDocument::processLink( const KPDFLink * link )
{
if ( !link )
return;
@ -512,7 +483,7 @@ void KPDFDocument::slotProcessLink( const KPDFLink * link )
destFitR
read and fit left,bottom,right,top
}*/
slotSetCurrentPage( pageNum, r );
setCurrentPage( pageNum, r );
}
delete namedDest;
delete dest;
@ -571,13 +542,13 @@ void KPDFDocument::slotProcessLink( const KPDFLink * link )
case KPDFLink::Named: {
const char * name = link->getName();
if ( !strcmp( name, "NextPage" ) && (d->currentPage < (int)d->pages.count() - 1) )
slotSetCurrentPage( d->currentPage + 1 );
setCurrentPage( d->currentPage + 1 );
else if ( !strcmp( name, "PrevPage" ) && d->currentPage > 0 )
slotSetCurrentPage( d->currentPage - 1 );
setCurrentPage( d->currentPage - 1 );
else if ( !strcmp( name, "FirstPage" ) )
slotSetCurrentPage( 0 );
setCurrentPage( 0 );
else if ( !strcmp( name, "LastPage" ) )
slotSetCurrentPage( d->pages.count() - 1 );
setCurrentPage( d->pages.count() - 1 );
else if ( !strcmp( name, "GoBack" ) )
{} //TODO
else if ( !strcmp( name, "GoForward" ) )
@ -601,6 +572,44 @@ void KPDFDocument::slotProcessLink( const KPDFLink * link )
break;
}
}
bool KPDFDocument::print(KPrinter &printer)
{
KTempFile tf( QString::null, ".ps" );
PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), d->pdfdoc->getXRef(), d->pdfdoc->getCatalog(), 1, d->pdfdoc->getNumPages(), psModePS);
if (psOut->isOk())
{
std::list<int> pages;
if (!printer.previewOnly())
{
QValueList<int> pageList = printer.pageList();
QValueList<int>::const_iterator it;
for(it = pageList.begin(); it != pageList.end(); ++it) pages.push_back(*it);
}
else
{
for(int i = 1; i <= d->pdfdoc->getNumPages(); i++) pages.push_back(i);
}
d->docLock.lock();
d->pdfdoc->displayPages(psOut, pages, 72, 72, 0, globalParams->getPSCrop(), gFalse);
d->docLock.unlock();
// needs to be here so that the file is flushed, do not merge with the one
// in the else
delete psOut;
printer.printFiles(tf.name(), true);
return true;
}
else
{
delete psOut;
return false;
}
}
//END slots
QString KPDFDocument::giveAbsolutePath( const QString & fileName )

View file

@ -15,9 +15,7 @@
#include <qvaluevector.h>
class KPrinter;
class Outline;
class KPDFPage;
class KPDFLink;
@ -29,21 +27,22 @@ class KPDFLink;
*/
class KPDFDocumentObserver
{
public:
// you must give each observer a unique ID (used for notifications)
virtual uint observerId() const = 0;
public:
// you must give each observer a unique ID (used for notifications)
virtual uint observerId() const = 0;
// monitor changes in pixmaps (generation thread complete)
virtual void notifyPixmapChanged( int /*pageNumber*/ ) {};
// monitor changes in pixmaps (generation thread complete)
virtual void notifyPixmapChanged( int /*pageNumber*/ ) {};
// commands from the Document to all observers
virtual void pageSetup( const QValueVector<KPDFPage*> & /*pages*/, bool /*documentChanged*/ ) {};
virtual void pageSetCurrent( int /*pageNumber*/, const QRect & /*viewport*/ = QRect() ) {};
// commands from the Document to all observers
virtual void pageSetup( const QValueVector<KPDFPage*> & /*pages*/, bool /*documentChanged*/ ) {};
virtual void pageSetCurrent( int /*pageNumber*/, const QRect & /*viewport*/ = QRect() ) {};
};
#define PAGEVIEW_ID 1
#define THUMBNAILS_ID 2
#define TOC_ID 3
#define PART_ID 1
#define PAGEVIEW_ID 2
#define THUMBNAILS_ID 3
#define TOC_ID 4
/**
* @short The information container. Actions (like open,find) take place here.
@ -51,54 +50,44 @@ public:
* xxxxxx
* yyy.
*/
class KPDFDocument : public QObject
class KPDFDocument
{
Q_OBJECT
public:
KPDFDocument();
~KPDFDocument();
public:
KPDFDocument();
~KPDFDocument();
// document handling
bool openDocument( const QString & docFile );
void closeDocument();
// document handling
bool openDocument( const QString & docFile );
void closeDocument();
// misc methods
void addObserver( KPDFDocumentObserver * pObserver );
void reparseConfig();
// query methods
uint currentPage() const;
uint pages() const;
bool atBegin() const;
bool atEnd() const;
const KPDFPage * page( uint page ) const;
Outline * outline() const;
// query methods (const ones)
uint currentPage() const;
uint pages() const;
bool okToPrint() const;
Outline * outline() const;
const KPDFPage * page( uint page ) const;
// observers related methods
void addObserver( KPDFDocumentObserver * pObserver );
void requestPixmap( int id, uint page, int width, int height, bool syncronous = false );
void requestTextPage( uint page );
// perform actions on document / pages
void requestPixmap( int id, uint page, int width, int height, bool syncronous = false );
void requestTextPage( uint page );
void setCurrentPage( int page, const QRect & viewport = QRect() );
void findText( const QString & text = "", bool caseSensitive = false );
void findTextAll( const QString & pattern, bool caseSensitive );
void toggleBookmark( int page );
void processLink( const KPDFLink * link );
bool print( KPrinter &printer );
bool okToPrint() const;
bool print(KPrinter &printer);
private:
QString giveAbsolutePath( const QString & fileName );
bool openRelativeFile( const QString & fileName );
void processPageList( bool documentChanged );
void unHilightPages();
//public slots: TODO remove me
// document commands via slots
void slotSetCurrentPage( int page, const QRect & viewport = QRect() );
void slotSetFilter( const QString & pattern, bool caseSensitive );
void slotToggleBookmark( int page );
void slotFind( const QString & text = "", bool caseSensitive = false );
void slotProcessLink( const KPDFLink * link );
signals:
// notify changes via signals
void pageChanged();
private:
QString giveAbsolutePath( const QString & fileName );
bool openRelativeFile( const QString & fileName );
void processPageList( bool documentChanged );
void unHilightPages();
class KPDFDocumentPrivate * d;
class KPDFDocumentPrivate * d;
};
#endif

View file

@ -84,14 +84,13 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
setInstance(KPDFPartFactory::instance());
// build the document
document = new KPDFDocument();
connect( document, SIGNAL( pageChanged() ), this, SLOT( updateActions() ) );
m_document = new KPDFDocument();
// widgets: ^searchbar (toolbar containing label and SearchWidget)
// m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
// m_searchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
// QLabel * sLabel = new QLabel( i18n( "&Search:" ), m_searchToolBar, "kde toolbar widget" );
// m_searchWidget = new SearchWidget( m_searchToolBar, document );
// m_searchWidget = new SearchWidget( m_searchToolBar, m_document );
// sLabel->setBuddy( m_searchWidget );
// m_searchToolBar->setStretchableWidget( m_searchWidget );
@ -105,14 +104,14 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_toolBox->setMinimumWidth( 60 );
m_toolBox->setMaximumWidth( 200 );
TOC * tocFrame = new TOC( m_toolBox, document );
TOC * tocFrame = new TOC( m_toolBox, m_document );
m_toolBox->addItem( tocFrame, QIconSet(SmallIcon("text_left")), i18n("Contents") );
connect(tocFrame, SIGNAL(hasTOC(bool)), this, SLOT(enableTOC(bool)));
enableTOC( false );
QVBox * thumbsBox = new ThumbnailsBox( m_toolBox );
m_searchWidget = new SearchWidget( thumbsBox, document );
m_thumbnailList = new ThumbnailList( thumbsBox, document );
m_searchWidget = new SearchWidget( thumbsBox, m_document );
m_thumbnailList = new ThumbnailList( thumbsBox, m_document );
connect( m_thumbnailList, SIGNAL( urlDropped( const KURL& ) ), SLOT( openURL( const KURL & )));
m_toolBox->addItem( thumbsBox, QIconSet(SmallIcon("thumbnail")), i18n("Thumbnails") );
m_toolBox->setCurrentItem( thumbsBox );
@ -126,14 +125,15 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_toolBox->setItemEnabled( iIdx, false );
// widgets: [] | [right 'pageView']
m_pageView = new PageView( m_splitter, document );
m_pageView = new PageView( m_splitter, m_document );
connect( m_pageView, SIGNAL( urlDropped( const KURL& ) ), SLOT( openURL( const KURL & )));
//connect(m_pageView, SIGNAL( rightClick() ), this, SIGNAL( rightClick() ));
// add document observers
document->addObserver( m_thumbnailList );
document->addObserver( m_pageView );
document->addObserver( tocFrame );
m_document->addObserver( this );
m_document->addObserver( m_thumbnailList );
m_document->addObserver( m_pageView );
m_document->addObserver( tocFrame );
// ACTIONS
KActionCollection * ac = actionCollection();
@ -186,15 +186,21 @@ Part::~Part()
// write to disk config file
Settings::writeConfig();
delete document;
delete m_document;
if ( --m_count == 0 )
delete globalParams;
}
void Part::pageSetCurrent( int, const QRect & )
{
// document tells that page has changed, so update actions
updateActions();
}
void Part::goToPage(uint i)
{
if (i <= document->pages())
document->slotSetCurrentPage( i - 1 );
if ( i <= m_document->pages() )
m_document->setCurrentPage( i - 1 );
}
void Part::openDocument(KURL doc)
@ -204,7 +210,7 @@ void Part::openDocument(KURL doc)
uint Part::pages()
{
return document->pages();
return m_document->pages();
}
//this don't go anywhere but is required by genericfactory.h
@ -220,7 +226,7 @@ KAboutData* Part::createAboutData()
bool Part::openFile()
{
bool ok = document->openDocument( m_file );
bool ok = m_document->openDocument( m_file );
m_find->setEnabled( ok );
return ok;
}
@ -234,28 +240,30 @@ bool Part::openURL(const KURL &url)
bool Part::closeURL()
{
document->closeDocument();
m_document->closeDocument();
return KParts::ReadOnlyPart::closeURL();
}
void Part::updateActions()
{
if ( document->pages() > 0 )
{
m_gotoPage->setEnabled(document->pages()>1);
m_firstPage->setEnabled(!document->atBegin());
m_prevPage->setEnabled(!document->atBegin());
m_lastPage->setEnabled(!document->atEnd());
m_nextPage->setEnabled(!document->atEnd());
}
else
{
m_gotoPage->setEnabled(false);
m_firstPage->setEnabled(false);
m_lastPage->setEnabled(false);
m_prevPage->setEnabled(false);
m_nextPage->setEnabled(false);
}
if ( m_document->pages() > 0 )
{
bool atBegin = m_document->currentPage() < 1;
bool atEnd = m_document->currentPage() >= (m_document->pages() - 1);
m_gotoPage->setEnabled( m_document->pages() > 1 );
m_firstPage->setEnabled( !atBegin );
m_prevPage->setEnabled( !atBegin );
m_lastPage->setEnabled( !atEnd );
m_nextPage->setEnabled( !atEnd );
}
else
{
m_gotoPage->setEnabled( false );
m_firstPage->setEnabled( false );
m_lastPage->setEnabled( false );
m_prevPage->setEnabled( false );
m_nextPage->setEnabled( false );
}
}
void Part::enableTOC(bool enable)
@ -295,52 +303,52 @@ public:
void Part::slotGoToPage()
{
KPDFGotoPageDialog pageDialog( m_pageView, document->currentPage() + 1, document->pages() );
if ( pageDialog.exec() == QDialog::Accepted )
document->slotSetCurrentPage( pageDialog.getPage() - 1 );
KPDFGotoPageDialog pageDialog( m_pageView, m_document->currentPage() + 1, m_document->pages() );
if ( pageDialog.exec() == QDialog::Accepted )
m_document->setCurrentPage( pageDialog.getPage() - 1 );
}
void Part::slotPreviousPage()
{
if ( !document->atBegin() )
document->slotSetCurrentPage( document->currentPage() - 1 );
if ( !m_document->currentPage() < 1 )
m_document->setCurrentPage( m_document->currentPage() - 1 );
}
void Part::slotNextPage()
{
if ( !document->atEnd() )
document->slotSetCurrentPage( document->currentPage() + 1 );
if ( m_document->currentPage() < (m_document->pages() - 1) )
m_document->setCurrentPage( m_document->currentPage() + 1 );
}
void Part::slotGotoFirst()
{
document->slotSetCurrentPage( 0 );
m_document->setCurrentPage( 0 );
}
void Part::slotGotoLast()
{
document->slotSetCurrentPage( document->pages() - 1 );
m_document->setCurrentPage( m_document->pages() - 1 );
}
void Part::slotFind()
{
KFindDialog dlg( widget() );
dlg.setHasCursor(false);
KFindDialog dlg( widget() );
dlg.setHasCursor( false );
#if KDE_IS_VERSION(3,3,90)
dlg.setSupportsBackwardsFind(false);
dlg.setSupportsWholeWordsFind(false);
dlg.setSupportsRegularExpressionFind(false);
dlg.setSupportsBackwardsFind( false );
dlg.setSupportsWholeWordsFind( false );
dlg.setSupportsRegularExpressionFind( false );
#endif
if (dlg.exec() == QDialog::Accepted)
{
m_findNext->setEnabled( true );
document->slotFind( dlg.pattern(), dlg.options() & KFindDialog::CaseSensitive );
}
if ( dlg.exec() == QDialog::Accepted )
{
m_findNext->setEnabled( true );
m_document->findText( dlg.pattern(), dlg.options() & KFindDialog::CaseSensitive );
}
}
void Part::slotFindNext()
{
document->slotFind();
m_document->findText();
}
void Part::slotSaveFileAs()
@ -395,6 +403,9 @@ void Part::slotNewConfig()
m_pageView->setVScrollBarMode( scrollBarMode );
}
// update document settings
m_document->reparseConfig();
// update Main View and ThumbnailList contents
// TODO do this only when changing Settings::renderMode()
m_pageView->updateContents();
@ -404,14 +415,14 @@ void Part::slotNewConfig()
void Part::slotPrintPreview()
{
if (document->pages() == 0) return;
if (m_document->pages() == 0) return;
double width, height;
int landscape, portrait;
KPrinter printer;
const KPDFPage *page;
printer.setMinMax(1, document->pages());
printer.setMinMax(1, m_document->pages());
printer.setPreviewOnly( true );
printer.setMargins(0, 0, 0, 0);
@ -419,9 +430,9 @@ void Part::slotPrintPreview()
// not accept a per page setting
landscape = 0;
portrait = 0;
for (uint i = 0; i < document->pages(); i++)
for (uint i = 0; i < m_document->pages(); i++)
{
page = document->page(i);
page = m_document->page(i);
width = page->width();
height = page->height();
if (page->rotation() == 90 || page->rotation() == 270) qSwap(width, height);
@ -435,7 +446,7 @@ void Part::slotPrintPreview()
void Part::slotPrint()
{
if (document->pages() == 0) return;
if (m_document->pages() == 0) return;
double width, height;
int landscape, portrait;
@ -443,17 +454,17 @@ void Part::slotPrint()
const KPDFPage *page;
printer.setPageSelection(KPrinter::ApplicationSide);
printer.setMinMax(1, document->pages());
printer.setCurrentPage(document->currentPage()+1);
printer.setMinMax(1, m_document->pages());
printer.setCurrentPage(m_document->currentPage()+1);
printer.setMargins(0, 0, 0, 0);
// if some pages are landscape and others are not the most common win as kprinter does
// not accept a per page setting
landscape = 0;
portrait = 0;
for (uint i = 0; i < document->pages(); i++)
for (uint i = 0; i < m_document->pages(); i++)
{
page = document->page(i);
page = m_document->page(i);
width = page->width();
height = page->height();
if (page->rotation() == 90 || page->rotation() == 270) qSwap(width, height);
@ -467,13 +478,13 @@ void Part::slotPrint()
void Part::doPrint(KPrinter &printer)
{
if (!document->okToPrint())
if (!m_document->okToPrint())
{
KMessageBox::error(widget(), i18n("Printing this document is not allowed."));
return;
}
if (!document->print(printer))
if (!m_document->print(printer))
{
KMessageBox::error(widget(), i18n("Could not print the document. Please report to bugs.kde.org"));
}
@ -487,7 +498,7 @@ void Part::restoreDocument(const KURL &url, int page)
void Part::saveDocumentRestoreInfo(KConfig* config)
{
config->writePathEntry( "URL", url().url() );
if (document->pages() > 0) config->writeEntry( "Page", document->currentPage() + 1);
if (m_document->pages() > 0) config->writeEntry( "Page", m_document->currentPage() + 1 );
}
/*

View file

@ -20,6 +20,7 @@
#include <kparts/part.h>
#include "kpdf_dcop.h"
#include "document.h"
class QWidget;
class QSplitter;
@ -39,7 +40,6 @@ class LinkDest;
class ThumbnailList;
class PageView;
class SearchWidget;
class KPDFDocument;
namespace KPDF {
@ -53,7 +53,7 @@ class BrowserExtension;
* @author Wilco Greven <greven@kde.org>
* @version 0.2
*/
class Part : public KParts::ReadOnlyPart, virtual public kpdf_dcop
class Part : public KParts::ReadOnlyPart, public KPDFDocumentObserver, virtual public kpdf_dcop
{
Q_OBJECT
@ -65,8 +65,12 @@ public:
// Destructor
~Part();
// inherited from KPDFDocumentObserver
uint observerId() const { return PART_ID; }
void pageSetCurrent( int pageNumber, const QRect & viewport );
static KAboutData* createAboutData();
ASYNC goToPage(uint page);
ASYNC openDocument(KURL doc);
uint pages();
@ -97,14 +101,14 @@ protected slots:
public slots:
// connected to Shell action (and browserExtension), not local one
void slotPrint();
void restoreDocument(const KURL &url, int page);
void saveDocumentRestoreInfo(KConfig* config);
void restoreDocument(const KURL &url, int page);
void saveDocumentRestoreInfo(KConfig* config);
private:
void doPrint( KPrinter& printer );
// the document
KPDFDocument * document;
KPDFDocument * m_document;
// main widgets
QSplitter *m_splitter;

View file

@ -185,12 +185,17 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
if ( !pixmap )
{
destPainter->fillRect( limits, Settings::paperColor() );
if ( Settings::changeColors() &&
Settings::renderMode() == Settings::EnumRenderMode::Paper )
destPainter->fillRect( limits, Settings::paperColor() );
else
destPainter->fillRect( limits, Qt::white );
return;
}
// we have a pixmap to paint, now let's paint it using a direct or buffered painter
bool backBuffer = Settings::renderMode() != Settings::EnumRenderMode::Normal;
bool backBuffer = Settings::changeColors() &&
Settings::renderMode() != Settings::EnumRenderMode::Paper;
// if PagePainter::Accessibility is not in 'flags', disable backBuffer
backBuffer = backBuffer && (flags & Accessibility);
QPixmap * backPixmap = 0;

View file

@ -430,7 +430,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
verticalScrollBar()->subtractPage();
}
else if ( d->vectorIndex > 0 )
d->document->slotSetCurrentPage( d->items[ d->vectorIndex - 1 ]->pageNumber() );
d->document->setCurrentPage( d->items[ d->vectorIndex - 1 ]->pageNumber() );
break;
case Key_Down:
case Key_PageDown:
@ -443,7 +443,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
verticalScrollBar()->addPage();
}
else if ( d->vectorIndex < (int)d->items.count() - 1 )
d->document->slotSetCurrentPage( d->items[ d->vectorIndex + 1 ]->pageNumber() );
d->document->setCurrentPage( d->items[ d->vectorIndex + 1 ]->pageNumber() );
break;
case Key_Left:
horizontalScrollBar()->subtractLine();
@ -595,13 +595,13 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
// activate link
int linkX = e->x() - pageItem->geometry().left(),
linkY = e->y() - pageItem->geometry().top();
d->document->slotProcessLink( pageItem->page()->getLink( linkX, linkY ) );
d->document->processLink( pageItem->page()->getLink( linkX, linkY ) );
}
else
{
// mouse not moved since press, so we have a click. select the page.
if ( e->globalPos() == d->mouseStartPos )
d->document->slotSetCurrentPage( pageItem->pageNumber() );
d->document->setCurrentPage( pageItem->pageNumber() );
}
}
else if ( rightButton && pageItem )
@ -625,7 +625,7 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
switch ( m_popup->exec(e->globalPos()) )
{
case 1:
d->document->slotToggleBookmark( kpdfPage->number() );
d->document->toggleBookmark( kpdfPage->number() );
break;
case 2:
// zoom: Fit Width, columns: 1. setActions + relayout + setPage + update
@ -639,7 +639,7 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
slotRelayoutPages();
viewport()->setUpdatesEnabled( true );
updateContents();
d->document->slotSetCurrentPage( kpdfPage->number() );
d->document->setCurrentPage( kpdfPage->number() );
break;
case 3: // ToDO switch to edit mode
slotSetMouseDraw();
@ -794,13 +794,13 @@ void PageView::wheelEvent( QWheelEvent *e )
{
// go to next page
if ( d->vectorIndex < (int)d->items.count() - 1 )
d->document->slotSetCurrentPage( d->items[ d->vectorIndex + 1 ]->pageNumber() );
d->document->setCurrentPage( d->items[ d->vectorIndex + 1 ]->pageNumber() );
}
else if ( delta >= 120 && !Settings::viewContinous() && vScroll == verticalScrollBar()->minValue() )
{
// go to prev page
if ( d->vectorIndex > 0 )
d->document->slotSetCurrentPage( d->items[ d->vectorIndex - 1 ]->pageNumber() );
d->document->setCurrentPage( d->items[ d->vectorIndex - 1 ]->pageNumber() );
}
else
QScrollView::wheelEvent( e );

View file

@ -56,7 +56,7 @@ SearchWidget::SearchWidget( QWidget * parent, KPDFDocument * document )
void SearchWidget::hideEvent( QHideEvent * )
{
m_document->slotSetFilter( QString::null, m_caseSensitive );
m_document->findTextAll( QString::null, m_caseSensitive );
}
void SearchWidget::slotTextChanged( const QString & text )
@ -64,12 +64,12 @@ void SearchWidget::slotTextChanged( const QString & text )
if ( text.length() > 2 || text.isEmpty() )
{
m_lineEdit->setPaletteForegroundColor( palette().active().text() );
m_document->slotSetFilter( text, m_caseSensitive );
m_document->findTextAll( text, m_caseSensitive );
}
else
{
m_lineEdit->setPaletteForegroundColor( Qt::red );
m_document->slotSetFilter( QString::null, m_caseSensitive );
m_document->findTextAll( QString::null, m_caseSensitive );
}
}

View file

@ -225,7 +225,7 @@ void ThumbnailList::keyPressEvent( QKeyEvent * keyEvent )
if ( m_selected )
m_selected->setSelected( false );
m_selected = 0;
m_document->slotSetCurrentPage( nextPage );
m_document->setCurrentPage( nextPage );
}
void ThumbnailList::contentsMousePressEvent( QMouseEvent * e )
@ -241,7 +241,7 @@ void ThumbnailList::contentsMousePressEvent( QMouseEvent * e )
int childTop = childY(t);
if ( clickY > childTop && clickY < (childTop + t->height()) )
{
m_document->slotSetCurrentPage( t->pageNumber() );
m_document->setCurrentPage( t->pageNumber() );
break;
}
}

View file

@ -140,7 +140,7 @@ void TOC::slotExecuted(QListViewItem *i)
{
TOCItem *ti = dynamic_cast<TOCItem*>(i);
KPDFLink l( ti->getAction() );
m_document->slotProcessLink( &l );
m_document->processLink( &l );
}
#include "toc.moc"