File indexing completed on 2024-05-12 16:34:58
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2011 C. Boemann <cbo@boemann.dk> 0003 * Copyright (C) 2013 Aman Madaan <madaan.amanmadaan@gmail.com> 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 REFERENCESTOOL_H 0022 #define REFERENCESTOOL_H 0023 0024 #include "TextTool.h" 0025 #include <signal.h> 0026 0027 class KoCanvasBase; 0028 class TableOfContentsConfigure; 0029 class SimpleTableOfContentsWidget; 0030 class SimpleFootEndNotesWidget; 0031 class SimpleCitationBibliographyWidget; 0032 class KoInlineNote; 0033 class KoTextEditor; 0034 class KoBibliographyInfo; 0035 class KoTableOfContentsGeneratorInfo; 0036 class SimpleLinksWidget; 0037 class LabeledWidget; 0038 /// This tool is the ui for inserting Table of Contents, Citations/bibliography, footnotes, endnotes, index, table of illustrations etc 0039 0040 class ReferencesTool : public TextTool 0041 { 0042 Q_OBJECT 0043 public: 0044 explicit ReferencesTool(KoCanvasBase *canvas); 0045 0046 ~ReferencesTool() override; 0047 0048 void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override; 0049 void deactivate() override; 0050 0051 void createActions() override; 0052 0053 KoTextEditor *editor(); 0054 /// inserts a ToC and open a configure dialog for customization 0055 void insertCustomToC(KoTableOfContentsGeneratorInfo *defaultTemplate); 0056 /// insert a bibliography and open a configure dialog for customization 0057 void insertCustomBibliography(KoBibliographyInfo *defaultTemplate); 0058 0059 protected: 0060 /// reimplemented from superclass 0061 QList<QPointer<QWidget> > createOptionWidgets() override; 0062 0063 private Q_SLOTS: 0064 /// insert a citation 0065 void insertCitation(); 0066 /// configure a bibliography 0067 void configureBibliography(); 0068 /// format the table of contents template 0069 void formatTableOfContents(); 0070 /// shows the configuration dialog for a ToC 0071 void showConfigureDialog(QAction *action); 0072 /// hides the configuration dialog for ToC 0073 void hideCofigureDialog(); 0074 /// insert an autonumbered footnote 0075 void insertAutoFootNote(); 0076 /// insert a labeled footnote 0077 void insertLabeledFootNote(const QString &label); 0078 /// insert an autonumbered endnote 0079 void insertAutoEndNote(); 0080 /// insert a labeled endnote 0081 void insertLabeledEndNote(const QString &label); 0082 /// show the configuration dialog for footnotes 0083 void showFootnotesConfigureDialog(); 0084 /// show the configuration dialog for endnotes 0085 void showEndnotesConfigureDialog(); 0086 /// enable/disable buttons if cursor in notes' body or not 0087 void updateButtons(); 0088 0089 void customToCGenerated(); 0090 /// insert a Link 0091 void insertLink(); 0092 ///insert a bookmark 0093 void insertBookmark(QString bookmarkName); 0094 /// validate a bookmark 0095 bool validateBookmark(QString bookmarkName); 0096 private: 0097 TableOfContentsConfigure *m_configure; 0098 SimpleTableOfContentsWidget *m_stocw; 0099 SimpleFootEndNotesWidget *m_sfenw; 0100 KoInlineNote *m_note; 0101 SimpleCitationBibliographyWidget *m_scbw; 0102 SimpleLinksWidget *m_slw; 0103 LabeledWidget *m_bmark; 0104 KoCanvasBase *m_canvas; 0105 }; 0106 0107 class QAction; 0108 class QLineEdit; 0109 class QLabel; 0110 class LabeledWidget : public QWidget 0111 { 0112 Q_OBJECT 0113 public: 0114 enum LabelPosition {INLINE, ABOVE}; 0115 LabeledWidget(QAction *action, const QString &label, LabelPosition pos, bool warningLabelRequired); 0116 void setWarningText(int pos, const QString &warning); 0117 void clearLineEdit(); 0118 Q_SIGNALS: 0119 void triggered(const QString &label); 0120 void lineEditChanged(const QString &); 0121 0122 private Q_SLOTS: 0123 void returnPressed(); 0124 0125 protected: 0126 void enterEvent(QEvent *event) override; 0127 0128 private : 0129 QLineEdit *m_lineEdit; 0130 QLabel *m_warningLabel[2]; 0131 QAction *m_action; 0132 }; 0133 0134 #endif // REFERENCESTOOL_H