~ubuntu-branches/ubuntu/wily/kbibtex/wily

« back to all changes in this revision

Viewing changes to src/entrywidget.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-2006 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
 
#ifndef KBIBTEXENTRYWIDGET_H
21
 
#define KBIBTEXENTRYWIDGET_H
22
 
 
23
 
#include <qwidget.h>
24
 
#include <qdialog.h>
25
 
#include <qvaluelist.h>
26
 
#include <qmap.h>
27
 
 
28
 
#include <kdialogbase.h>
29
 
 
30
 
#include <entry.h>
31
 
#include <entrywidgetsource.h>
32
 
#include <webquery.h>
33
 
 
34
 
class QComboBox;
35
 
class QLineEdit;
36
 
class QCheckBox;
37
 
class QTabWidget;
38
 
class QString;
39
 
class QTimer;
40
 
class QListView;
41
 
 
42
 
class KConfig;
43
 
 
44
 
namespace KBibTeX
45
 
{
46
 
    class EntryWidgetTab;
47
 
    class WebQueryArXiv;
48
 
 
49
 
    class EntryWidget : public QWidget
50
 
    {
51
 
        Q_OBJECT
52
 
 
53
 
        friend class EntryWidgetDialog;
54
 
 
55
 
    public:
56
 
        ~EntryWidget();
57
 
 
58
 
        static QDialog::DialogCode execute( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QWidget *parent = 0, const char *name = 0 );
59
 
 
60
 
    protected:
61
 
        EntryWidget( BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name = 0 );
62
 
        void showEvent( QShowEvent * );
63
 
        bool queryClose();
64
 
 
65
 
    private slots:
66
 
        void apply();
67
 
        void reset();
68
 
        void apply( BibTeX::Entry *entry );
69
 
        void reset( BibTeX::Entry *entry );
70
 
        void slotEnableAllFields();
71
 
        void slotForceDefaultIdSuggestion();
72
 
        void slotEntryTypeChanged();
73
 
        void slotCurrentPageChanged( QWidget* newPage );
74
 
        void warningsExecute( QListViewItem* item );
75
 
        void updateWarnings();
76
 
        void insertIdSuggestion( int id );
77
 
        void updateIdSuggestionsMenu();
78
 
        void refreshFromURL();
79
 
        void useExternalEntry( BibTeX::Entry*, bool );
80
 
        void endExternalSearch( WebQuery::Status );
81
 
 
82
 
    signals:
83
 
        void updateTabs( BibTeX::Entry::EntryType entryType, bool enableAll, bool isReadOnly );
84
 
 
85
 
    private:
86
 
        EntryWidget( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name = 0 );
87
 
        BibTeX::Entry *m_originalEntry;
88
 
        BibTeX::File *m_bibtexfile;
89
 
        bool m_isReadOnly;
90
 
        bool m_isNew;
91
 
        bool m_defaultIdSuggestionAvailable;
92
 
 
93
 
        QComboBox *m_comboBoxEntryType;
94
 
        QLineEdit *m_lineEditID;
95
 
        QPushButton *m_pushButtonForceDefaultIdSuggestion;
96
 
        QPushButton *m_pushButtonIdSuggestions;
97
 
        QPopupMenu *m_menuIdSuggestions;
98
 
        QMap<int, QString> m_idToSuggestion;
99
 
        QCheckBox *m_checkBoxEnableAll;
100
 
        QPushButton *m_pushButtonRefetch;
101
 
        QListView *m_listViewWarnings;
102
 
        QTabWidget *m_tabWidget;
103
 
        KBibTeX::EntryWidgetSource *m_sourcePage;
104
 
        QValueList<KBibTeX::EntryWidgetTab*> m_internalEntryWidgets;
105
 
        QWidget *m_lastPage;
106
 
        QTimer *m_updateWarningsTimer;
107
 
        QDialog *m_dlgParent;
108
 
        WebQueryArXiv *m_wqa;
109
 
        QString m_oldId;
110
 
 
111
 
        void setupGUI( QWidget *parent, bool showWarnings = TRUE );
112
 
        void addTabWidgets();
113
 
        void addTabWidget( EntryWidgetTab *widget, const QString& title );
114
 
        void setupEntryTypes();
115
 
        void updateGUI();
116
 
        void internalApply( BibTeX::Entry *entry );
117
 
        void internalReset( BibTeX::Entry *entry );
118
 
        void restoreWindowSize( KConfig *config );
119
 
        void saveWindowSize( KConfig *config ) const;
120
 
    };
121
 
 
122
 
    class EntryWidgetDialog: public KDialogBase
123
 
    {
124
 
        Q_OBJECT
125
 
    public:
126
 
        EntryWidgetDialog( QWidget *parent = 0, const char *name = 0, bool modal = true, const QString &caption = QString::null, int buttonMask = Ok | Apply | Cancel ) : KDialogBase( parent, name, modal, caption, buttonMask ) {/* nothing */};
127
 
        ~EntryWidgetDialog() {/* nothing */};
128
 
        void setMainWidget( EntryWidget *widget )
129
 
        {
130
 
            KDialogBase::setMainWidget( widget );
131
 
            m_widget = widget;
132
 
        };
133
 
 
134
 
    protected:
135
 
        void closeEvent( QCloseEvent * e )
136
 
        {
137
 
            if ( m_widget->queryClose() ) e->accept();
138
 
            else e->ignore();
139
 
        }
140
 
 
141
 
    protected slots:
142
 
        void slotCancel()
143
 
        {
144
 
            if ( m_widget->queryClose() ) QDialog::done( Cancel );
145
 
        }
146
 
 
147
 
        void slotClose()
148
 
        {
149
 
            if ( m_widget->queryClose() ) QDialog::done( Cancel );
150
 
        }
151
 
 
152
 
    private:
153
 
        EntryWidget *m_widget;
154
 
    };
155
 
 
156
 
}
157
 
 
158
 
#endif