lib Library API Documentation

kotextiterator.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #ifndef KOTEXTITERATOR_H
00020 #define KOTEXTITERATOR_H
00021 
00022 #include <qvaluelist.h>
00023 #include <qstring.h>
00024 #include <qpair.h>
00025 #include <qobject.h>
00026 #include <koffice_export.h>
00027 class KoTextParag;
00028 class KoTextObject;
00029 class KoTextView;
00030 
00036 class KOTEXT_EXPORT KoTextIterator : public QObject
00037 {
00038     Q_OBJECT
00039 public:
00043     KoTextIterator( const QValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options ) {
00044         init( lstObjects, textView, options );
00045     }
00046     void init( const QValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options );
00047 
00051     void restart();
00052 
00058     void setOptions( int options );
00059 
00063     int options() const { return m_options; }
00064 
00068     void operator++();
00069 
00073     bool atEnd() const;
00074 
00079     bool hasText() const;
00080 
00084     QString currentText() const;
00085 
00089     KoTextParag* currentParag() const { return m_currentParag; }
00090 
00094     KoTextObject* currentTextObject() const { return *m_currentTextObj; }
00095 
00099     int currentStartIndex() const;
00100 
00107     QPair<int, QString> currentTextAndIndex() const;
00108 
00109 signals:
00114     void currentParagraphModified( int modifyType, int pos, int length );
00115 
00120     void currentParagraphDeleted();
00121 
00122 protected:
00123     void connectTextObjects();
00124     void nextTextObject();
00125 
00126 protected slots:
00127     void slotParagraphDeleted( KoTextParag* parag );
00128     void slotParagraphModified( KoTextParag* parag, int /*ParagModifyType*/, int pos, int length );
00129 
00130 private:
00131     // The reason we use a QValueList of pointers instead of QPtrList
00132     // is that having a QPtrListIterator member var can't work, one can't
00133     // initialize it afterwards.
00134     QValueList<KoTextObject *> m_lstObjects;
00135     int m_options;
00136 
00137     // This is relative to the first textobject in m_lstObjects
00138     // We always start from this paragraph (even when going backwards)
00139     KoTextParag* m_firstParag;
00140     int m_firstIndex;
00141 
00142     // This is relative to the last textobject in m_lstObjects
00143     // We're done when we hit this paragraph
00144     KoTextParag* m_lastParag;
00145     int m_lastIndex;
00146 
00147     // Our current position
00148     QValueList<KoTextObject *>::Iterator m_currentTextObj;
00149     KoTextParag* m_currentParag;
00150 };
00151 
00152 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:09 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003