00001 /* This file is part of the KDE project 00002 * Copyright (C) 2006 Thomas Zander <zander@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 as published by the Free Software Foundation; version 2. 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., 51 Franklin Street, Fifth Floor, 00016 * Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef KOSTYLEMANAGER_H 00020 #define KOSTYLEMANAGER_H 00021 00022 #include <koffice_export.h> 00023 00024 #include <QObject> 00025 #include <QTextDocument> 00026 00027 class KoCharacterStyle; 00028 class KoParagraphStyle; 00029 class ChangeFollower; 00030 class KoStyleManagerPrivate; 00031 00035 class KOTEXT_EXPORT KoStyleManager : public QObject { 00036 Q_OBJECT 00037 public: 00042 KoStyleManager(QObject *parent = 0); 00043 00047 void add(KoCharacterStyle *style); 00051 void add(KoParagraphStyle *style); 00055 void remove(KoCharacterStyle *style); 00059 void remove(KoParagraphStyle *style); 00060 00066 void add(QTextDocument *document); 00070 void remove(QTextDocument *document); 00071 00079 KoCharacterStyle *characterStyle(int id) const; 00080 00088 KoParagraphStyle *paragraphStyle(int id) const; 00089 00097 KoCharacterStyle *characterStyle(const QString &name) const; 00098 00106 KoParagraphStyle *paragraphStyle(const QString &name) const; 00107 00115 KoParagraphStyle *defaultParagraphStyle() const; 00116 00117 public slots: 00123 void alteredStyle(const KoParagraphStyle *style); 00129 void alteredStyle(const KoCharacterStyle *style); 00130 00131 private slots: 00132 void updateAlteredStyles(); // for the QTimer::singleshot 00133 00134 private: 00135 friend class ChangeFollower; 00136 void requestFireUpdate(); 00137 void remove(ChangeFollower *cf); 00138 00139 private: 00140 static int s_stylesNumber; // For giving out unique numbers to the styles for referencing 00141 00142 QList<KoCharacterStyle*> m_charStyles; 00143 QList<KoParagraphStyle*> m_paragStyles; 00144 QList<ChangeFollower*> m_documentUpdaterProxies; 00145 00146 bool m_updateTriggered; 00147 QList<int> m_updateQueue; 00148 00149 00150 KoParagraphStyle *m_standard; 00151 }; 00152 00153 #endif