Warning, file /office/calligra/libs/textlayout/IndexGeneratorManager.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) 2011 Ko GmbH <cbo@kogmbh.com> 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 #ifndef INDEXGENERATORMANAGER_H 0020 #define INDEXGENERATORMANAGER_H 0021 0022 0023 #include <QObject> 0024 #include <QMetaType> 0025 #include <QHash> 0026 #include <QTimer> 0027 0028 class QTextDocument; 0029 class KoTextDocumentLayout; 0030 class KoTableOfContentsGeneratorInfo; 0031 class ToCGenerator; 0032 0033 class IndexGeneratorManager : public QObject 0034 { 0035 Q_OBJECT 0036 private: 0037 explicit IndexGeneratorManager(QTextDocument *document); 0038 public: 0039 ~IndexGeneratorManager() override; 0040 0041 static IndexGeneratorManager *instance(QTextDocument *document); 0042 0043 bool generate(); 0044 0045 public Q_SLOTS: 0046 void requestGeneration(); 0047 void startDoneTimer(); 0048 0049 private Q_SLOTS: 0050 void layoutDone(); 0051 void timeout(); 0052 0053 private: 0054 enum State { 0055 Resting, // We are not doing anything, and don't need to either 0056 FirstRunNeeded, // We would like to update the indexes, with dummy pg nums 0057 FirstRun, // Updating indexes, so prevent layout and ignore documentChanged() 0058 FirstRunLayouting, // KoTextDocumentLayout is layouting so sit still 0059 SecondRunNeeded, // Would like to update the indexes, getting pg nums right 0060 SecondRun, // Updating indexes, so prevent layout and ignore documentChanged() 0061 SecondRunLayouting // KoTextDocumentLayout is layouting so sit still 0062 }; 0063 QTextDocument *m_document; 0064 KoTextDocumentLayout *m_documentLayout; 0065 QHash<KoTableOfContentsGeneratorInfo *, ToCGenerator *> m_generators; 0066 State m_state; 0067 QTimer m_updateTimer; 0068 QTimer m_doneTimer; 0069 }; 0070 0071 Q_DECLARE_METATYPE(IndexGeneratorManager *) 0072 0073 #endif