~ubuntu-branches/ubuntu/precise/kbibtex/precise

« back to all changes in this revision

Viewing changes to src/gui/element/elementwidgets.h

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-07-18 09:29:48 UTC
  • mfrom: (1.1.6) (2.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20110718092948-ksxjmg7kdfamolmg
Tags: 0.3-1
* First upstream release for KDE4 (Closes: #634255). A number of search
  engines are still missing, in comparison to the 0.2 series.
* Bumped Standards-Version to 3.9.2, no changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   Copyright (C) 2004-2010 by Thomas Fischer                             *
 
3
*   fischer@unix-ag.uni-kl.de                                             *
 
4
*                                                                         *
 
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.                                   *
 
9
*                                                                         *
 
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.                          *
 
14
*                                                                         *
 
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
***************************************************************************/
 
20
 
 
21
#ifndef KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H
 
22
#define KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H
 
23
 
 
24
#include <kbibtexgui_export.h>
 
25
 
 
26
#include <QWidget>
 
27
 
 
28
#include <KUrl>
 
29
#include <KIcon>
 
30
 
 
31
#include <entrylayout.h>
 
32
 
 
33
class QTextEdit;
 
34
class QTreeWidget;
 
35
class QTreeWidgetItem;
 
36
 
 
37
class KLineEdit;
 
38
class KComboBox;
 
39
class KPushButton;
 
40
 
 
41
class File;
 
42
class Entry;
 
43
class Element;
 
44
class FieldInput;
 
45
 
 
46
class ElementWidget : public QWidget
 
47
{
 
48
    Q_OBJECT
 
49
 
 
50
public:
 
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;
 
56
    };
 
57
    virtual QString label() = 0;
 
58
    virtual KIcon icon() = 0;
 
59
    bool isModified() const;
 
60
    void setModified(bool);
 
61
 
 
62
    void setFile(const File *file) {
 
63
        m_file = file;
 
64
    }
 
65
 
 
66
    static bool canEdit(const Element *element) {
 
67
        Q_UNUSED(element)
 
68
        return false;
 
69
    };
 
70
 
 
71
protected:
 
72
    bool isReadOnly;
 
73
    const File *m_file;
 
74
 
 
75
protected slots:
 
76
    void gotModified();
 
77
 
 
78
private:
 
79
    bool m_isModified;
 
80
 
 
81
signals:
 
82
    void modified(bool);
 
83
};
 
84
 
 
85
class EntryConfiguredWidget : public ElementWidget
 
86
{
 
87
private:
 
88
    EntryTabLayout &etl;
 
89
    QMap<QString, FieldInput*> bibtexKeyToWidget;
 
90
    void createGUI();
 
91
 
 
92
public:
 
93
    EntryConfiguredWidget(EntryTabLayout &entryTabLayout, QWidget *parent);
 
94
 
 
95
    bool apply(Element *element) const;
 
96
    bool reset(const Element *element);
 
97
    void setReadOnly(bool isReadOnly);
 
98
    QString label();
 
99
    KIcon icon();
 
100
 
 
101
    static bool canEdit(const Element *element);
 
102
};
 
103
 
 
104
class ReferenceWidget : public ElementWidget
 
105
{
 
106
private:
 
107
    KComboBox *entryType;
 
108
    KLineEdit *entryId;
 
109
    void createGUI();
 
110
 
 
111
public:
 
112
    ReferenceWidget(QWidget *parent);
 
113
 
 
114
    bool apply(Element *element) const;
 
115
    bool reset(const Element *element);
 
116
    void setReadOnly(bool isReadOnly);
 
117
    QString label();
 
118
    KIcon icon();
 
119
 
 
120
    static bool canEdit(const Element *element);
 
121
};
 
122
 
 
123
class FilesWidget : public ElementWidget
 
124
{
 
125
private:
 
126
    FieldInput *fileList;
 
127
 
 
128
public:
 
129
    FilesWidget(QWidget *parent);
 
130
 
 
131
    bool apply(Element *element) const;
 
132
    bool reset(const Element *element);
 
133
    void setReadOnly(bool isReadOnly);
 
134
    QString label();
 
135
    KIcon icon();
 
136
 
 
137
    static bool canEdit(const Element *element);
 
138
};
 
139
 
 
140
class OtherFieldsWidget : public ElementWidget
 
141
{
 
142
    Q_OBJECT
 
143
 
 
144
private:
 
145
    KLineEdit *fieldName;
 
146
    FieldInput *fieldContent;
 
147
    QTreeWidget *otherFieldsList;
 
148
    KPushButton *buttonDelete;
 
149
    KPushButton *buttonOpen;
 
150
    KPushButton *buttonAddApply;
 
151
    KUrl currentUrl;
 
152
    const QStringList blackListed;
 
153
    Entry *internalEntry;
 
154
    QStringList deletedKeys, modifiedKeys;
 
155
    bool m_isReadOnly;
 
156
 
 
157
    void createGUI();
 
158
    void updateList();
 
159
 
 
160
public:
 
161
    OtherFieldsWidget(const QStringList &blacklistedFields, QWidget *parent);
 
162
    ~OtherFieldsWidget();
 
163
 
 
164
    bool apply(Element *element) const;
 
165
    bool reset(const Element *element);
 
166
    void setReadOnly(bool isReadOnly);
 
167
    QString label();
 
168
    KIcon icon();
 
169
 
 
170
    static bool canEdit(const Element *element);
 
171
 
 
172
private slots:
 
173
    void listElementExecuted(QTreeWidgetItem *item, int column);
 
174
    void listCurrentChanged(QTreeWidgetItem *item, QTreeWidgetItem *previous);
 
175
    void actionAddApply();
 
176
    void actionDelete();
 
177
    void actionOpen();
 
178
    void updateGUI();
 
179
};
 
180
 
 
181
class MacroWidget : public ElementWidget
 
182
{
 
183
private:
 
184
    FieldInput *fieldInputValue;
 
185
 
 
186
    void createGUI();
 
187
 
 
188
public:
 
189
    MacroWidget(QWidget *parent);
 
190
 
 
191
    bool apply(Element *element) const;
 
192
    bool reset(const Element *element);
 
193
    void setReadOnly(bool isReadOnly);
 
194
    QString label();
 
195
    KIcon icon();
 
196
 
 
197
    static bool canEdit(const Element *element);
 
198
};
 
199
 
 
200
class PreambleWidget : public ElementWidget
 
201
{
 
202
private:
 
203
    FieldInput *fieldInputValue;
 
204
 
 
205
    void createGUI();
 
206
 
 
207
public:
 
208
    PreambleWidget(QWidget *parent);
 
209
 
 
210
    bool apply(Element *element) const;
 
211
    bool reset(const Element *element);
 
212
    void setReadOnly(bool isReadOnly);
 
213
    QString label();
 
214
    KIcon icon();
 
215
 
 
216
    static bool canEdit(const Element *element);
 
217
};
 
218
 
 
219
class SourceWidget : public ElementWidget
 
220
{
 
221
    Q_OBJECT
 
222
 
 
223
private:
 
224
    QTextEdit *sourceEdit;
 
225
    QString originalText;
 
226
 
 
227
    void createGUI();
 
228
 
 
229
public:
 
230
    SourceWidget(QWidget *parent);
 
231
 
 
232
    bool apply(Element *element) const;
 
233
    bool reset(const Element *element);
 
234
    void setReadOnly(bool isReadOnly);
 
235
    QString label();
 
236
    KIcon icon();
 
237
 
 
238
    static bool canEdit(const Element *element);
 
239
 
 
240
private slots:
 
241
    void reset();
 
242
 
 
243
private:
 
244
    KPushButton *m_buttonRestore;
 
245
};
 
246
 
 
247
#endif // KBIBTEX_GUI_DIALOGS_ELEMENTSWIDGETS_H