lib

KoTextIterator.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17*/
18
19#ifndef KOTEXTITERATOR_H
20#define KOTEXTITERATOR_H
21
22#include <tqvaluelist.h>
23#include <tqstring.h>
24#include <tqpair.h>
25#include <tqobject.h>
26#include <koffice_export.h>
27class KoTextParag;
28class KoTextObject;
29class KoTextView;
30
36class KOTEXT_EXPORT KoTextIterator : public TQObject
37{
38 TQ_OBJECT
39
40public:
46 KoTextIterator( const TQValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options ) {
47 init( lstObjects, textView, options );
48 }
49 void init( const TQValueList<KoTextObject *> & lstObjects, KoTextView* textView, int options );
50
54 void restart();
55
61 void setOptions( int options );
62
66 int options() const { return m_options; }
67
71 void operator++();
72
76 bool atEnd() const;
77
82 bool hasText() const;
83
87 TQString currentText() const;
88
92 KoTextParag* currentParag() const { return m_currentParag; }
93
97 KoTextObject* currentTextObject() const { return *m_currentTextObj; }
98
102 int currentStartIndex() const;
103
110 TQPair<int, TQString> currentTextAndIndex() const;
111
112signals:
117 void currentParagraphModified( int modifyType, int pos, int length );
118
124
125protected:
126 void connectTextObjects();
127 void nextTextObject();
128
129protected slots:
130 void slotParagraphDeleted( KoTextParag* parag );
131 void slotParagraphModified( KoTextParag* parag, int /*ParagModifyType*/, int pos, int length );
132
133private:
134 // The reason we use a TQValueList of pointers instead of TQPtrList
135 // is that having a TQPtrListIterator member var can't work, one can't
136 // initialize it afterwards.
137 TQValueList<KoTextObject *> m_lstObjects;
138 int m_options;
139
140 // This is relative to the first textobject in m_lstObjects
141 // We always start from this paragraph (even when going backwards)
142 KoTextParag* m_firstParag;
143 int m_firstIndex;
144
145 // This is relative to the last textobject in m_lstObjects
146 // We're done when we hit this paragraph
147 KoTextParag* m_lastParag;
148 int m_lastIndex;
149
150 // Our current position
151 TQValueList<KoTextObject *>::Iterator m_currentTextObj;
152 KoTextParag* m_currentParag;
153};
154
155#endif
A convenient way to iterate over paragraphs, possibly in multiple textobjects, with many options (fro...
KoTextParag * currentParag() const
void currentParagraphDeleted()
Emitted when the current paragraph has been deleted by the user.
int options() const
Return the options currently used by the iterator.
KoTextIterator(const TQValueList< KoTextObject * > &lstObjects, KoTextView *textView, int options)
KoTextObject * currentTextObject() const
void currentParagraphModified(int modifyType, int pos, int length)
Emitted when the current paragraph has been modified by the user.
The KoTextObject is the high-level object that contains a KoTextDocument (the list of paragraphs),...
Object that is created to edit a KoTextObject.
Definition KoTextView.h:54