Warning, file /office/calligra/libs/text/KoList.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KOLIST_H
0021 #define KOLIST_H
0022 
0023 #include "styles/KoListStyle.h"
0024 
0025 #include <QMetaType>
0026 #include <QPointer>
0027 #include <QVector>
0028 #include <QTextList>
0029 
0030 class KoListPrivate;
0031 
0032 /**
0033  * This class represents an ODF list. An ODF list may have upto 10 levels
0034  * Each of the levels is represented as a QTextList (QTextList does not support
0035  * embedded lists). There is always an associated KoListStyle that holds the
0036  * styling information for various level of the ODF list.
0037  */
0038 class KOTEXT_EXPORT KoList : public QObject
0039 {
0040     Q_OBJECT
0041 public:
0042     enum Type {
0043         TextList,
0044         NumberedParagraph
0045     };
0046 
0047     /// Constructor
0048     KoList(const QTextDocument *document, KoListStyle *style, Type type = TextList);
0049 
0050     /// Destructor
0051     ~KoList() override;
0052 
0053     /// Adds \a block to \a level of this list
0054     void add(const QTextBlock &block, int level);
0055 
0056     /// Removes \a block from any KoList the block is a part of
0057     static void remove(const QTextBlock &block);
0058 
0059     /**
0060      * Adds \a block to a list that follows \a style at \a level. If the block is
0061      * already a part of a list, it is removed from that list. If the block before
0062      * or after this block is part of a list that follows \a style, this block is
0063      * added to that list. If required a new KoList is created.
0064      * Returns the KoList that this block was added to.
0065     */
0066     static KoList *applyStyle(const QTextBlock &block, KoListStyle *style, int level);
0067 
0068     /// Sets the style of this list
0069     void setStyle(KoListStyle *style);
0070 
0071     /// Returns the style of this list
0072     KoListStyle *style() const;
0073 
0074     /// Return true if this list contains \a textlist
0075     bool contains(QTextList *textList) const;
0076 
0077     /// Returns the QTextLists that form this list
0078     QVector<QPointer<QTextList> > textLists() const;
0079 
0080     QVector<KoListStyle::ListIdType> textListIds() const;
0081 
0082     static int level(const QTextBlock &block);
0083 
0084     /// Update the stored QTextList pointer for the given block
0085     void updateStoredList(const QTextBlock &block);
0086 
0087     KoList *listContinuedFrom() const;
0088     void setListContinuedFrom(KoList *list);
0089 
0090 private:
0091     KoListPrivate * const d;
0092 
0093     Q_PRIVATE_SLOT(d, void styleChanged(int))
0094 };
0095 
0096 Q_DECLARE_METATYPE(KoList*)
0097 Q_DECLARE_METATYPE(QList<KoList*>)
0098 
0099 #endif // KOLIST_H