File indexing completed on 2024-06-02 05:09:12
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2019 Thomas Fischer <fischer@unix-ag.uni-kl.de> 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 0018 ***************************************************************************/ 0019 0020 #ifndef KBIBTEX_GUI_ELEMENTEDITOR_H 0021 #define KBIBTEX_GUI_ELEMENTEDITOR_H 0022 0023 #include <QWidget> 0024 0025 #include "kbibtexgui_export.h" 0026 0027 class Element; 0028 class File; 0029 0030 /** 0031 @author Thomas Fischer 0032 */ 0033 class KBIBTEXGUI_EXPORT ElementEditor : public QWidget 0034 { 0035 Q_OBJECT 0036 public: 0037 class ApplyElementInterface 0038 { 0039 public: 0040 virtual ~ApplyElementInterface() { 0041 /** nothing */ 0042 } 0043 virtual void apply(QSharedPointer<Element>) = 0; 0044 virtual bool validate(QWidget **widgetWithIssue, QString &message) const = 0; 0045 }; 0046 0047 ElementEditor(bool scrollable, QWidget *parent); 0048 ~ElementEditor() override; 0049 0050 void setElement(QSharedPointer<Element> element, const File *file); 0051 void setElement(QSharedPointer<const Element> element, const File *file); 0052 void setReadOnly(bool isReadOnly = true); 0053 bool elementChanged(); 0054 bool elementUnapplied(); 0055 bool validate(QWidget **widgetWithIssue, QString &message); 0056 0057 QWidget *currentPage() const; 0058 void setCurrentPage(QWidget *tab); 0059 0060 Q_SIGNALS: 0061 void modified(bool); 0062 0063 public Q_SLOTS: 0064 void apply(); 0065 void reset(); 0066 bool validate(); 0067 0068 private Q_SLOTS: 0069 void tabChanged(); 0070 void switchToTab(const QString &tabIdentifier); 0071 void childModified(bool); 0072 0073 private: 0074 class ElementEditorPrivate; 0075 ElementEditorPrivate *d; 0076 }; 0077 0078 #endif // KBIBTEX_GUI_ELEMENTEDITOR_H