Warning, file /office/calligra/libs/text/OdfTextTrackStyles.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) 2006 Thomas Zander <zander@kde.org>
0003  * Copyright (C) 2012 C. Boemann <cbo@boemann.dk>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef CHANGEFOLLOWER_H
0022 #define CHANGEFOLLOWER_H
0023 
0024 #include "commands/ChangeStylesMacroCommand.h"
0025 
0026 #include <KoStyleManager.h>
0027 
0028 #include <QObject>
0029 #include <QPointer>
0030 #include <QSet>
0031 #include <QTextDocument>
0032 
0033 /**
0034  * OdfTextTrackStyles is used to update a list of qtextdocument with
0035  * any changes made in the style manager.
0036  * 
0037  * It also creates undo commands and adds them to the undo stack
0038  *
0039  * Style changes affect a lot of qtextdocuments and we store the changes and apply
0040  * the changes to every qtextdocument, so every KoTextDocument has to
0041  * register their QTextDocument to us.
0042  *
0043  * We use the QObject principle of children getting deleted when the
0044  * parent gets deleted. Thus we die when the KoStyleManager dies.
0045  */
0046 class OdfTextTrackStyles : public QObject
0047 {
0048 
0049     Q_OBJECT
0050 
0051 public:
0052     static OdfTextTrackStyles *instance(KoStyleManager *manager);
0053 
0054 private:
0055     static QHash<QObject *, OdfTextTrackStyles *> instances;
0056 
0057     explicit OdfTextTrackStyles(KoStyleManager *manager);
0058 
0059     /// Destructor, called when the parent is deleted.
0060     ~OdfTextTrackStyles() override;
0061 
0062 private Q_SLOTS:
0063     void beginEdit();
0064     void endEdit();
0065     void recordStyleChange(int id, const KoParagraphStyle *origStyle, const KoParagraphStyle *newStyle);
0066     void recordStyleChange(int id, const KoCharacterStyle *origStyle, const KoCharacterStyle *newStyle);
0067     void styleManagerDied(QObject *manager);
0068     void documentDied(QObject *manager);
0069 
0070 public:
0071     void registerDocument(QTextDocument *qDoc);
0072     void unregisterDocument(QTextDocument *qDoc);
0073 
0074 private:
0075     QList<QTextDocument *> m_documents;
0076     QPointer<KoStyleManager> m_styleManager;
0077     ChangeStylesMacroCommand *m_changeCommand;
0078 };
0079 
0080 #endif