From c0a2772c9ab2b64227f59f925c4ba1bbbaee0e81 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 20 Mar 2006 23:14:05 +0000 Subject: [PATCH] more porting, area.h is begining to loose but i need sleep svn path=/branches/work/kde4/playground/graphics/okular/; revision=520838 --- core/area.cpp | 2 +- core/area.h | 52 +++++++++++++++++++---------------------------- core/textpage.cpp | 18 +++++++--------- core/textpage.h | 8 ++++---- 4 files changed, 33 insertions(+), 47 deletions(-) diff --git a/core/area.cpp b/core/area.cpp index 1b42741af..4dd3d4760 100644 --- a/core/area.cpp +++ b/core/area.cpp @@ -125,5 +125,5 @@ ObjectRect::~ObjectRect() if ( m_objectType == Link ) delete static_cast( m_pointer ); else - kdDebug() << "Object deletion not implemented for type '" << m_objectType << "' ." << endl; + kDebug() << "Object deletion not implemented for type '" << m_objectType << "' ." << endl; } diff --git a/core/area.h b/core/area.h index 9b1508840..1e1b81222 100644 --- a/core/area.h +++ b/core/area.h @@ -9,7 +9,7 @@ #ifndef _KPDF_AREA_H_ #define _KPDF_AREA_H_ -#include +#include #include #include class QRect; @@ -108,13 +108,9 @@ struct HighlightRect : public NormalizedRect */ template class RegularArea : -public QLinkedList +public QList { public: - typedef QValueListIterator Iterator; - typedef QValueListConstIterator ConstIterator; -// RegularArea (NormalizedShape* x) { QLinkedList(x) ; } ; -// class Iterator : public QLinkedListIterator {}; bool contains( double x, double y ) const; bool contains( NormalizedShape * ) const; bool intersects (const RegularArea * area) const; @@ -122,14 +118,14 @@ public QLinkedList void appendArea (const RegularArea *area); void simplify (); bool isNull() const; - QLinkedList* geometry( int xScale, int yScale, int dx=0,int dy=0 ) const; + QList* geometry( int xScale, int yScale, int dx=0,int dy=0 ) const; }; template void RegularArea::simplify() { int end=this->count(),i=0,x=0; - QLinkedList m_remove; + QList m_remove; for (;i::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::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::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::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::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::contains (NormalizedShape * shape) con if (this->isEmpty()) return false; - const QLinkedList * const lista=dynamic_cast * const >(this); + const QList * const lista=dynamic_cast * const >(this); return lista->contains(shape); } template -QLinkedList * +QList * RegularArea::geometry( int xScale, int yScale, int dx, int dy ) const { if (!this) @@ -262,13 +253,12 @@ RegularArea::geometry( int xScale, int yScale, int dx, i if (this->isEmpty()) return 0; - ConstIterator i; - QLinkedList* ret=new QLinkedList; + QList* ret=new QList; 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); } diff --git a/core/textpage.cpp b/core/textpage.cpp index 505229584..212be722b 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -13,11 +13,7 @@ KPDFTextPage::~KPDFTextPage() { - QLinkedList::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::Iterator start; + QList::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::Iterator it; + QList::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::Iterator &start, - const QLinkedList::Iterator &end) + bool strictCase, const QList::Iterator &start, + const QList::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::Iterator it; + QList::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::Iterator it,end = m_words.end(); + QList::Iterator it,end = m_words.end(); KPDFTextEntity * last=0; for( it=m_words.begin() ; it != end; ++it ) { diff --git a/core/textpage.h b/core/textpage.h index a227e4883..7dfee2c43 100644 --- a/core/textpage.h +++ b/core/textpage.h @@ -11,7 +11,7 @@ #define _KPDF_TETXTPAGE_H_ -#include +#include #include #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 words) : m_words(words) {}; + KPDFTextPage(QList 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::Iterator &start, const QLinkedList::Iterator &end); - QLinkedList m_words; + bool strictCase, const QList::Iterator &start, const QList::Iterator &end); + QList m_words; };