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 class KoTextParag;
00027 class KoTextObject;
00028 class KoTextView;
00029 
00035 class KoTextIterator : public QObject
00036 {
00037     Q_OBJECT
00038 public:
00042     KoTextIterator( const QValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options ) {
00043         init( lstObjects, textView, options );
00044     }
00045     void init( const QValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options );
00046 
00050     void restart();
00051 
00057     void setOptions( int options );
00058 
00062     int options() const { return m_options; }
00063 
00067     void operator++();
00068 
00072     bool atEnd() const;
00073 
00078     bool hasText() const;
00079 
00083     QString currentText() const;
00084 
00088     KoTextParag* currentParag() const { return m_currentParag; }
00089 
00093     KoTextObject* currentTextObject() const { return *m_currentTextObj; }
00094 
00098     int currentStartIndex() const;
00099 
00106     QPair<int, QString> currentTextAndIndex() const;
00107 
00108 signals:
00113     void currentParagraphModified( int modifyType, int pos, int length );
00114 
00115 protected:
00116     void connectTextObjects();
00117     void nextTextObject();
00118 
00119 protected slots:
00120     void slotParagraphDeleted( KoTextParag* parag );
00121     void slotParagraphModified( KoTextParag* parag, int /*ParagModifyType*/, int pos, int length );
00122 
00123 private:
00124     // The reason we use a QValueList of pointers instead of QPtrList
00125     // is that having a QPtrListIterator member var can't work, one can't
00126     // initialize it afterwards.
00127     QValueList<KoTextObject *> m_lstObjects;
00128     int m_options;
00129 
00130     // This is relative to the first textobject in m_lstObjects
00131     // We always start from this paragraph (even when going backwards)
00132     KoTextParag* m_firstParag;
00133     int m_firstIndex;
00134 
00135     // This is relative to the last textobject in m_lstObjects
00136     // We're done when we hit this paragraph
00137     KoTextParag* m_lastParag;
00138     int m_lastIndex;
00139 
00140     // Our current position
00141     QValueList<KoTextObject *>::Iterator m_currentTextObj;
00142     KoTextParag* m_currentParag;
00143 };
00144 
00145 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 13:19:26 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003