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

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

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

Loading…
Cancel
Save