1
/***************************************************************************
2
* Copyright (C) 2004-2010 by Thomas Fischer *
3
* fischer@unix-ag.uni-kl.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
#ifndef KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H
22
#define KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H
24
#include <kbibtexgui_export.h>
31
#include <entrylayout.h>
35
class QTreeWidgetItem;
46
class ElementWidget : public QWidget
51
ElementWidget(QWidget *parent);
52
virtual bool apply(Element *element) const = 0;
53
virtual bool reset(const Element *element) = 0;
54
virtual void setReadOnly(bool isReadOnly) {
55
this->isReadOnly = isReadOnly;
57
virtual QString label() = 0;
58
virtual KIcon icon() = 0;
59
bool isModified() const;
60
void setModified(bool);
62
void setFile(const File *file) {
66
static bool canEdit(const Element *element) {
85
class EntryConfiguredWidget : public ElementWidget
89
QMap<QString, FieldInput*> bibtexKeyToWidget;
93
EntryConfiguredWidget(EntryTabLayout &entryTabLayout, QWidget *parent);
95
bool apply(Element *element) const;
96
bool reset(const Element *element);
97
void setReadOnly(bool isReadOnly);
101
static bool canEdit(const Element *element);
104
class ReferenceWidget : public ElementWidget
107
KComboBox *entryType;
112
ReferenceWidget(QWidget *parent);
114
bool apply(Element *element) const;
115
bool reset(const Element *element);
116
void setReadOnly(bool isReadOnly);
120
static bool canEdit(const Element *element);
123
class FilesWidget : public ElementWidget
126
FieldInput *fileList;
129
FilesWidget(QWidget *parent);
131
bool apply(Element *element) const;
132
bool reset(const Element *element);
133
void setReadOnly(bool isReadOnly);
137
static bool canEdit(const Element *element);
140
class OtherFieldsWidget : public ElementWidget
145
KLineEdit *fieldName;
146
FieldInput *fieldContent;
147
QTreeWidget *otherFieldsList;
148
KPushButton *buttonDelete;
149
KPushButton *buttonOpen;
150
KPushButton *buttonAddApply;
152
const QStringList blackListed;
153
Entry *internalEntry;
154
QStringList deletedKeys, modifiedKeys;
161
OtherFieldsWidget(const QStringList &blacklistedFields, QWidget *parent);
162
~OtherFieldsWidget();
164
bool apply(Element *element) const;
165
bool reset(const Element *element);
166
void setReadOnly(bool isReadOnly);
170
static bool canEdit(const Element *element);
173
void listElementExecuted(QTreeWidgetItem *item, int column);
174
void listCurrentChanged(QTreeWidgetItem *item, QTreeWidgetItem *previous);
175
void actionAddApply();
181
class MacroWidget : public ElementWidget
184
FieldInput *fieldInputValue;
189
MacroWidget(QWidget *parent);
191
bool apply(Element *element) const;
192
bool reset(const Element *element);
193
void setReadOnly(bool isReadOnly);
197
static bool canEdit(const Element *element);
200
class PreambleWidget : public ElementWidget
203
FieldInput *fieldInputValue;
208
PreambleWidget(QWidget *parent);
210
bool apply(Element *element) const;
211
bool reset(const Element *element);
212
void setReadOnly(bool isReadOnly);
216
static bool canEdit(const Element *element);
219
class SourceWidget : public ElementWidget
224
QTextEdit *sourceEdit;
225
QString originalText;
230
SourceWidget(QWidget *parent);
232
bool apply(Element *element) const;
233
bool reset(const Element *element);
234
void setReadOnly(bool isReadOnly);
238
static bool canEdit(const Element *element);
244
KPushButton *m_buttonRestore;
247
#endif // KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H