more porting, area.h is begining to loose but i need sleep

svn path=/branches/work/kde4/playground/graphics/okular/; revision=520838
remotes/origin/old/work/newpageview
Albert Astals Cid 20 years ago
parent b412aba1f1
commit c0a2772c9a
  1. 2
      core/area.cpp
  2. 52
      core/area.h
  3. 18
      core/textpage.cpp
  4. 8
      core/textpage.h

@ -125,5 +125,5 @@ ObjectRect::~ObjectRect()
if ( m_objectType == Link )
delete static_cast<KPDFLink*>( m_pointer );
else
kdDebug() << "Object deletion not implemented for type '" << m_objectType << "' ." << endl;
kDebug() << "Object deletion not implemented for type '" << m_objectType << "' ." << endl;
}

@ -9,7 +9,7 @@
#ifndef _KPDF_AREA_H_
#define _KPDF_AREA_H_
#include <qlinkedlist.h>
#include <qlist.h>
#include <qcolor.h>
#include <kdebug.h>
class QRect;
@ -108,13 +108,9 @@ struct HighlightRect : public NormalizedRect
*/
template <class NormalizedShape, class Shape> class RegularArea :
public QLinkedList<NormalizedShape*>
public QList<NormalizedShape*>
{
public:
typedef QValueListIterator<NormalizedShape*> Iterator;
typedef QValueListConstIterator<NormalizedShape*> ConstIterator;
// RegularArea<NormalizedShape,Shape> (NormalizedShape* x) { QLinkedList(x) ; } ;
// class Iterator : public QLinkedListIterator<NormalizedShape*> {};
bool contains( double x, double y ) const;
bool contains( NormalizedShape * ) const;
bool intersects (const RegularArea<NormalizedShape,Shape> * area) const;
@ -122,14 +118,14 @@ public QLinkedList<NormalizedShape*>
void appendArea (const RegularArea<NormalizedShape,Shape> *area);
void simplify ();
bool isNull() const;
QLinkedList<Shape>* geometry( int xScale, int yScale, int dx=0,int dy=0 ) const;
QList<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;
QLinkedList <NormalizedShape*> m_remove;
QList <NormalizedShape*> m_remove;
for (;i<end;i++)
{
if ( i < (end-1) )
@ -162,9 +158,8 @@ bool RegularArea<NormalizedShape, Shape>::isNull() const
if (this->isEmpty())
return false;
ConstIterator i;
for (i=this->begin();i!=this->end();++i)
if (!((*i)->isNull()))
foreach(const NormalizedShape *ns, this)
if (!(ns->isNull()))
return false;
return true;
@ -179,10 +174,9 @@ bool RegularArea<NormalizedShape, Shape>::intersects (const NormalizedShape *rec
if (this->isEmpty())
return false;
ConstIterator i;
for (i=this->begin();i!=this->end();++i)
foreach(const NormalizedShape *ns, this)
{
if(!((*i)->isNull()) && (*i)->intersects (rect))
if(!(ns->isNull()) && ns->intersects (rect))
return true;
}
return false;
@ -197,12 +191,11 @@ bool RegularArea<NormalizedShape, Shape>::intersects
if (this->isEmpty())
return false;
Iterator i,j;
for (i=this->begin();i!=this->end();++i)
foreach(const NormalizedShape ns, this)
{
for (j=area->begin();j!=area->end();++j)
foreach(const Shape s, area)
{
if(!((*i)->isNull) && (*i)->intersects (j))
if(!(ns->isNull) && ns->intersects (s))
return true;
}
}
@ -216,10 +209,9 @@ void RegularArea<NormalizedShape, Shape>::appendArea
if (!this)
return false;
ConstIterator j;
for (j=area->begin();j!=area->end();++j)
foreach(const Shape s, area)
{
this->append(*j);
this->append(s);
}
}
@ -232,10 +224,9 @@ bool RegularArea<NormalizedShape, Shape>::contains (double x, double y) const
if (this->isEmpty())
return false;
ConstIterator i;
for (i=this->begin();i!=this->end();++i)
foreach(const NormalizedShape ns, this)
{
if((*i)->contains (x,y))
if(ns->contains (x,y))
return true;
}
return false;
@ -249,12 +240,12 @@ bool RegularArea<NormalizedShape, Shape>::contains (NormalizedShape * shape) con
if (this->isEmpty())
return false;
const QLinkedList<NormalizedShape*> * const lista=dynamic_cast<const QLinkedList<NormalizedShape*> * const >(this);
const QList<NormalizedShape*> * const lista=dynamic_cast<const QList<NormalizedShape*> * const >(this);
return lista->contains(shape);
}
template <class NormalizedShape, class Shape>
QLinkedList<Shape> *
QList<Shape> *
RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale, int dx, int dy ) const
{
if (!this)
@ -262,13 +253,12 @@ RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale, int dx, i
if (this->isEmpty())
return 0;
ConstIterator i;
QLinkedList<Shape>* ret=new QLinkedList<Shape>;
QList<Shape>* ret=new QList<Shape>;
Shape t;
for (i=this->begin();i!=this->end();++i)
foreach(const NormalizedShape ns, this)
{
t=(*i)->geometry(xScale,yScale);
t.moveBy(dx,dy);
t=ns->geometry(xScale,yScale);
t.moveBy(dx,dy);
ret->append(t);
}

@ -13,11 +13,7 @@
KPDFTextPage::~KPDFTextPage()
{
QLinkedList<KPDFTextEntity*>::Iterator it;
for (it=m_words.begin();it!=m_words.end();++it)
{
delete (*it);
}
qDeleteAll(m_words);
}
RegularAreaRect * KPDFTextPage::getTextArea ( TextSelection * sel) const
@ -145,7 +141,7 @@ const bool &strictCase, const RegularAreaRect *area)
// invalid search request
if (query.isEmpty() || (area->isNull() && dir!=FromTop))
return 0;
QLinkedList<KPDFTextEntity*>::Iterator start;
QList<KPDFTextEntity*>::Iterator start;
if (dir == FromTop)
{
start=m_words.begin();
@ -158,7 +154,7 @@ const bool &strictCase, const RegularAreaRect *area)
QString * str=0;
int j=0, len=0, queryLeft=query.length()-1;
bool haveMatch=false;
QLinkedList<KPDFTextEntity*>::Iterator it;
QList<KPDFTextEntity*>::Iterator it;
for( it=m_words.begin() ; it != m_words.end(); ++it )
{
str= &((*it)->txt);
@ -214,8 +210,8 @@ const bool &strictCase, const RegularAreaRect *area)
RegularAreaRect* KPDFTextPage::findTextInternal(const QString &query, bool forward,
bool strictCase, const QLinkedList<KPDFTextEntity*>::Iterator &start,
const QLinkedList<KPDFTextEntity*>::Iterator &end)
bool strictCase, const QList<KPDFTextEntity*>::Iterator &start,
const QList<KPDFTextEntity*>::Iterator &end)
{
RegularAreaRect* ret=new RegularAreaRect;
@ -227,7 +223,7 @@ RegularAreaRect* KPDFTextPage::findTextInternal(const QString &query, bool forwa
int j=0, len=0, queryLeft=query.length();
bool haveMatch=false;
bool dontIncrement=false;
QLinkedList<KPDFTextEntity*>::Iterator it;
QList<KPDFTextEntity*>::Iterator it;
// we dont support backward search yet
for( it=start ; it != end; (!dontIncrement) ? (++it) : it )
{
@ -307,7 +303,7 @@ QString * KPDFTextPage::getText(const RegularAreaRect *area)
return 0;
QString* ret = new QString;
QLinkedList<KPDFTextEntity*>::Iterator it,end = m_words.end();
QList<KPDFTextEntity*>::Iterator it,end = m_words.end();
KPDFTextEntity * last=0;
for( it=m_words.begin() ; it != end; ++it )
{

@ -11,7 +11,7 @@
#define _KPDF_TETXTPAGE_H_
#include <qlinkedlist.h>
#include <qlist.h>
#include <qstringlist.h>
#include "area.h"
class TextSelection;
@ -64,15 +64,15 @@ class KPDFTextPage {
const bool &strictCase, const RegularAreaRect *area);
QString * getText(const RegularAreaRect *rect);
RegularAreaRect * getTextArea ( TextSelection* ) const;
KPDFTextPage(QLinkedList<KPDFTextEntity*> words) : m_words(words) {};
KPDFTextPage(QList<KPDFTextEntity*> words) : m_words(words) {};
KPDFTextPage() : m_words() {};
void append(QString txt, NormalizedRect* area)
{ m_words.append(new KPDFTextEntity(txt,area) ); };
~KPDFTextPage();
private:
RegularAreaRect * findTextInternal(const QString &query, bool forward,
bool strictCase, const QLinkedList<KPDFTextEntity*>::Iterator &start, const QLinkedList<KPDFTextEntity*>::Iterator &end);
QLinkedList<KPDFTextEntity*> m_words;
bool strictCase, const QList<KPDFTextEntity*>::Iterator &start, const QList<KPDFTextEntity*>::Iterator &end);
QList<KPDFTextEntity*> m_words;
};

Loading…
Cancel
Save