1 /*************************************************************************** 2 * Copyright (C) 2004-2020 by Thomas Fischer <fischer@unix-ag.uni-kl.de> * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 16 ***************************************************************************/ 17 18 #ifndef KBIBTEX_GUI_FIELDLINEEDIT_H 19 #define KBIBTEX_GUI_FIELDLINEEDIT_H 20 21 #include "kbibtexgui_export.h" 22 23 #include <QIcon> 24 25 #include "value.h" 26 #include "menulineedit.h" 27 #include "kbibtex.h" 28 29 class QMenu; 30 class QSignalMapper; 31 32 class Element; 33 34 /** 35 * @author Thomas Fischer <fischer@unix-ag.uni-kl.de> 36 */ 37 class KBIBTEXGUI_EXPORT FieldLineEdit : public MenuLineEdit 38 { 39 Q_OBJECT 40 41 public: 42 FieldLineEdit(KBibTeX::TypeFlag preferredTypeFlag, KBibTeX::TypeFlags typeFlags, bool isMultiLine = false, QWidget *parent = nullptr); 43 ~FieldLineEdit() override; 44 45 bool reset(const Value &value); 46 bool apply(Value &value) const; 47 bool validate(QWidget **widgetWithIssue, QString &message) const; 48 void clear() override; 49 void setReadOnly(bool) override; 50 51 void setFile(const File *file); 52 void setElement(const Element *element); 53 void setFieldKey(const QString &fieldKey); 54 55 protected: 56 void dragEnterEvent(QDragEnterEvent *event) override; 57 void dropEvent(QDropEvent *event) override; 58 59 private: 60 bool m_incompleteRepresentation; 61 62 63 KBibTeX::TypeFlag typeFlag(); 64 KBibTeX::TypeFlag setTypeFlag(KBibTeX::TypeFlag typeFlag); 65 66 void setupMenu(); 67 void updateGUI(); 68 69 class FieldLineEditPrivate; 70 FieldLineEdit::FieldLineEditPrivate *d; 71 72 private slots: 73 void slotTypeChanged(int); 74 void slotTextChanged(const QString &); 75 void slotOpenUrl(); 76 }; 77 78 #endif // KBIBTEX_GUI_FIELDLINEEDIT_H 79