Commit 4387e148 authored by Piotr Szymanski's avatar Piotr Szymanski

- GIGANTIC 2700 line diff with LOTS OF FEATURES!

- 1. editor-like text selection, and I do mean it, its not pseudo-editor 
  (like the ones acroread and kviewshell have) it doesnt intersect the 
  selection area with words under it, no, it does a lot more, including 
  work on cursors and searching for the text area closest to the given
  cursor
- 2. rotation support, change the orientation of the documents if 
  you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
  is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender 
  instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended, 
  the kviewshell is only one state, while we support it in both 
  continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
  it is an impressive bit right? but oKular cant be run by only one person, 
  join in on the fun! i can introduce you into the code just mail niedakh@gmail.com


svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
parent efd05b1e
......@@ -8,56 +8,195 @@
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>416</height>
<width>340</width>
<height>554</height>
</rect>
</property>
<property name="caption">
<string>DlgGeneral</string>
</property>
<spacer>
<property name="name">
<cstring>spacer3</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>510</y>
<width>20</width>
<height>40</height>
</rect>
</property>
</spacer>
<spacer>
<property name="name">
<cstring>spacer4</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>180</y>
<width>40</width>
<height>20</height>
</rect>
</property>
</spacer>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout7</cstring>
<cstring>layout13</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>1</y>
<width>348</width>
<height>408</height>
<y>0</y>
<width>295</width>
<height>501</height>
</rect>
</property>
<grid>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QGroupBox" row="2" column="0">
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox2_2</cstring>
<cstring>groupBox2</cstring>
</property>
<property name="title">
<string>Temporary DEBUG Options</string>
<string>Program Look</string>
</property>
<vbox>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<widget class="QLayoutWidget">
<property name="name">
<cstring>kcfg_DebugDrawBoundaries</cstring>
</property>
<property name="text">
<string>DebugDrawBoundaries</string>
<cstring>layout6</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowScrollBars</cstring>
</property>
<property name="text">
<string>Show scroll&amp;bars</string>
</property>
<property name="accel">
<string>Alt+B</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowSearchBar</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Show &amp;search bar in thumbnails list</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_SyncThumbnailsViewport</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Link the &amp;thumbnails with the page</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowOSD</cstring>
</property>
<property name="text">
<string>Show &amp;hints and info messages</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_CenterFirstPageInRow</cstring>
</property>
<property name="text">
<string>Center &amp;first page in facing mode</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QCheckBox">
<widget class="QLayoutWidget">
<property name="name">
<cstring>kcfg_DebugDrawAnnotationRect</cstring>
</property>
<property name="text">
<string>DebugDrawAnnotationRect</string>
<cstring>layout3_2</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>pixmapLabel1_2</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap>"kpdf", 32</pixmap>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacerV1</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</vbox>
</hbox>
</widget>
<widget class="QGroupBox" row="1" column="0">
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox3</cstring>
</property>
......@@ -126,6 +265,9 @@
<property name="text">
<string>&amp;Obey DRM limitations</string>
</property>
<property name="accel">
<string>Alt+O</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
......@@ -134,6 +276,9 @@
<property name="text">
<string>&amp;Watch file</string>
</property>
<property name="accel">
<string>Alt+W</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
......@@ -150,145 +295,117 @@
</widget>
</grid>
</widget>
<widget class="QGroupBox" row="0" column="0">
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox2</cstring>
<cstring>groupBox2_2_2</cstring>
</property>
<property name="title">
<string>Program Look</string>
<string>Rendering options</string>
</property>
<hbox>
<widget class="QLayoutWidget">
<property name="name">
<cstring>unnamed</cstring>
<cstring>layout12</cstring>
</property>
<widget class="QLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>230</width>
<height>58</height>
</rect>
</property>
<grid>
<property name="name">
<cstring>layout6</cstring>
<cstring>unnamed</cstring>
</property>
<vbox>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>unnamed</cstring>
<cstring>columnLabel</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowScrollBars</cstring>
</property>
<property name="text">
<string>Show scroll&amp;bars</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowSearchBar</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Show &amp;search bar in thumbnails list</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_SyncThumbnailsViewport</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Link the &amp;thumbnails with the page</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ShowOSD</cstring>
</property>
<property name="text">
<string>Show &amp;hints and info messages</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_CenterFirstPageInRow</cstring>
</property>
<property name="text">
<string>Center &amp;first page in facing mode</string>
</property>
</widget>
</vbox>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Overview columns:</string>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>rowLabel</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Overview rows:</string>
</property>
</widget>
<widget class="QSpinBox" row="1" column="1">
<property name="name">
<cstring>kcfg_ViewColumns</cstring>
</property>
<property name="maxValue">
<number>10</number>
</property>
<property name="minValue">
<number>3</number>
</property>
</widget>
<widget class="QSpinBox" row="0" column="1">
<property name="name">
<cstring>kcfg_ViewRows</cstring>
</property>
<property name="maxValue">
<number>6</number>
</property>
<property name="minValue">
<number>1</number>
</property>
</widget>
</grid>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox2_2</cstring>
</property>
<property name="title">
<string>Temporary DEBUG Options</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_DebugDrawBoundaries</cstring>
</property>
<property name="text">
<string>DebugDrawBoundaries</string>
</property>
</widget>
<widget class="QLayoutWidget">
<widget class="QCheckBox">
<property name="name">
<cstring>layout3_2</cstring>
<cstring>kcfg_DebugDrawAnnotationRect</cstring>
</property>
<property name="text">
<string>DebugDrawAnnotationRect</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>pixmapLabel1_2</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap>"kpdf", 32</pixmap>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacerV1</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</hbox>
</vbox>
</widget>
</grid>
</vbox>
</widget>
<spacer>
<property name="name">
<cstring>spacer3</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="geometry">
<rect>
<x>160</x>
<y>410</y>
<width>20</width>
<height>40</height>
</rect>
</property>
</spacer>
</widget>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
......
......@@ -184,6 +184,11 @@
<min>1</min>
<max>8</max>
</entry>
<entry key="ViewRows" type="UInt" >
<default>1</default>
<min>1</min>
<max>5</max>
</entry>
<entry key="ViewContinuous" type="Bool" >
<default>true</default>
</entry>
......
......@@ -145,10 +145,10 @@ Annotation::Annotation( const QDomNode & annNode )
// parse boundary
if ( ee.tagName() == "boundary" )
{
boundary.left = ee.attribute( "l" ).toDouble();
boundary.top = ee.attribute( "t" ).toDouble();
boundary.right = ee.attribute( "r" ).toDouble();
boundary.bottom = ee.attribute( "b" ).toDouble();
boundary=NormalizedRect(ee.attribute( "l" ).toDouble(),
ee.attribute( "t" ).toDouble(),
ee.attribute( "r" ).toDouble(),
ee.attribute( "b" ).toDouble());
}
// parse penStyle if not default
else if ( ee.tagName() == "penStyle" )
......
......@@ -37,7 +37,7 @@ NormalizedRect::NormalizedRect( const QRect & r, double xScale, double yScale )
bool NormalizedRect::isNull() const
{
return left == 0 && top == 0 && right == 0 && bottom == 0;
return left == 0 && top== 0 && right == 0 && bottom == 0;
}
bool NormalizedRect::contains( double x, double y ) const
......@@ -60,6 +60,28 @@ bool NormalizedRect::intersects( double l, double t, double r, double b ) const
return (l <= right) && (r >= left) && (t <= bottom) && (b >= top);
}
NormalizedRect NormalizedRect::operator| (const NormalizedRect & r) const
{
NormalizedRect ret;
// todo !
ret.left=QMIN(left,r.left);
ret.top=QMIN(top,r.top);
ret.bottom=QMAX(bottom,r.bottom);
ret.right=QMAX(right,r.right);
return ret;
}
NormalizedRect& NormalizedRect::operator|= (const NormalizedRect & r)
{
return ((*this) = (*this) | r );
}
/*
kdbgstream& operator << (kdbgstream& str , const NormalizedRect &r)
{
str << "[" <<r.left() << "," << r.top() << "] x "<< "[" <<r.right() << "," << r.bottom() << "]";
return str;
}*/
QRect NormalizedRect::geometry( int xScale, int yScale ) const
{
int l = (int)( left * xScale ),
......
......@@ -11,6 +11,7 @@
#define _KPDF_AREA_H_
#include <qvaluelist.h>
#include <qcolor.h>
#include <kdebug.h>
class QRect;
class KPDFLink;
......@@ -44,8 +45,11 @@ class NormalizedRect
bool intersects( double l, double t, double r, double b ) const;
bool intersects( const NormalizedRect * r ) const;
QRect geometry( int xScale, int yScale ) const;
NormalizedRect operator| (const NormalizedRect & r) const;
NormalizedRect& operator|= (const NormalizedRect & r);
};
// kdbgstream& operator << (kdbgstream &, const NormalizedRect &);
/**
* @short NormalizedRect that contains a reference to an object.
......@@ -98,6 +102,7 @@ struct HighlightRect : public NormalizedRect
* intersects(NormalizedShape)
* isNull()
* geometry(int,int)
* operator | and |= which unite two NormalizedShapes
*/
template <class NormalizedShape, class Shape> class RegularArea :
......@@ -109,13 +114,43 @@ public QValueList<NormalizedShape*>
// RegularArea<NormalizedShape,Shape> (NormalizedShape* x) { QValueList(x) ; } ;
// class Iterator : public QValueListIterator<NormalizedShape*> {};
bool contains( double x, double y ) const;
bool contains( NormalizedShape * ) const;
bool intersects (const RegularArea<NormalizedShape,Shape> * area) const;
bool intersects (const NormalizedShape * shape) const;
void appendArea (const RegularArea<NormalizedShape,Shape> *area);
void simplify ();
bool isNull() const;
QValueList<Shape>* geometry( int xScale, int yScale ) const;
QValueList<Shape>* geometry( int xScale, int yScale, int dx=0,int dy=0 ) const;
};
template <class NormalizedShape, class Shape>
void RegularArea<NormalizedShape, Shape>::simplify()
{
int end=this->count(),i=0,x=0;
QValueList <NormalizedShape*> m_remove;
for (;i<end;i++)
{
if ( i < (end-1) )
{
if ( (*this)[x]->intersects( (*this)[i+1] ) )
{
*((*this)[x]) |= *((*this)[i+1]);
m_remove.append( (*this)[i+1] );
}
else
{
x=i+1;
}
}
}
while (!m_remove.isEmpty())
{
this->remove( m_remove.last() );
m_remove.pop_back();
}
kdDebug() << "from " << end << " to " << this->count() << endl;
}
template <class NormalizedShape, class Shape>
bool RegularArea<NormalizedShape, Shape>::isNull() const
{
......@@ -204,9 +239,21 @@ bool RegularArea<NormalizedShape, Shape>::contains (double x, double y) const
return false;
}
template <class NormalizedShape, class Shape>
bool RegularArea<NormalizedShape, Shape>::contains (NormalizedShape * shape) const
{
if (!this)
return false;
if (this->isEmpty())
return false;
const QValueList<NormalizedShape*> * const lista=dynamic_cast<const QValueList<NormalizedShape*> * const >(this);
return lista->contains(shape);
}
template <class NormalizedShape, class Shape>
QValueList<Shape> *
RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale ) const
RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale, int dx, int dy ) const
{
if (!this)
return false;
......@@ -214,11 +261,13 @@ RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale ) const
return 0;