summaryrefslogtreecommitdiffstats
path: root/src/entrywidget.h
blob: 3d9ad2f1e271a909c1629a212491fb1e92174d0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/***************************************************************************
*   Copyright (C) 2004-2006 by Thomas Fischer                             *
*   fischer@unix-ag.uni-kl.de                                             *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
#ifndef KBIBTEXENTRYWIDGET_H
#define KBIBTEXENTRYWIDGET_H

#include <ntqwidget.h>
#include <ntqdialog.h>
#include <ntqvaluelist.h>
#include <ntqmap.h>

#include <kdialogbase.h>

#include <entry.h>
#include <entrywidgetsource.h>
#include <webquery.h>

class TQComboBox;
class TQLineEdit;
class TQCheckBox;
class TQTabWidget;
class TQString;
class TQTimer;
class TQListView;

class KConfig;

namespace KBibTeX
{
    class EntryWidgetTab;
    class WebQueryArXiv;

    class EntryWidget : public TQWidget
    {
        Q_OBJECT

        friend class EntryWidgetDialog;

    public:
        ~EntryWidget();

        static TQDialog::DialogCode execute( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, TQWidget *parent = 0, const char *name = 0 );

    protected:
        EntryWidget( BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, TQDialog *parent, const char *name = 0 );
        void showEvent( TQShowEvent * );
        bool queryClose();

    private slots:
        void apply();
        void reset();
        void apply( BibTeX::Entry *entry );
        void reset( BibTeX::Entry *entry );
        void slotEnableAllFields();
        void slotForceDefaultIdSuggestion();
        void slotEntryTypeChanged();
        void slotCurrentPageChanged( TQWidget* newPage );
        void warningsExecute( TQListViewItem* item );
        void updateWarnings();
        void insertIdSuggestion( int id );
        void updateIdSuggestionsMenu();
        void refreshFromURL();
        void useExternalEntry( BibTeX::Entry*, bool );
        void endExternalSearch( WebQuery::Status );

    signals:
        void updateTabs( BibTeX::Entry::EntryType entryType, bool enableAll, bool isReadOnly );

    private:
        EntryWidget( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, TQDialog *parent, const char *name = 0 );
        BibTeX::Entry *m_originalEntry;
        BibTeX::File *m_bibtexfile;
        bool m_isReadOnly;
        bool m_isNew;
        bool m_defaultIdSuggestionAvailable;

        TQComboBox *m_comboBoxEntryType;
        TQLineEdit *m_lineEditID;
        TQPushButton *m_pushButtonForceDefaultIdSuggestion;
        TQPushButton *m_pushButtonIdSuggestions;
        TQPopupMenu *m_menuIdSuggestions;
        TQMap<int, TQString> m_idToSuggestion;
        TQCheckBox *m_checkBoxEnableAll;
        TQPushButton *m_pushButtonRefetch;
        TQListView *m_listViewWarnings;
        TQTabWidget *m_tabWidget;
        KBibTeX::EntryWidgetSource *m_sourcePage;
        TQValueList<KBibTeX::EntryWidgetTab*> m_internalEntryWidgets;
        TQWidget *m_lastPage;
        TQTimer *m_updateWarningsTimer;
        TQDialog *m_dlgParent;
        WebQueryArXiv *m_wqa;
        TQString m_oldId;

        void setupGUI( TQWidget *parent, bool showWarnings = TRUE );
        void addTabWidgets();
        void addTabWidget( EntryWidgetTab *widget, const TQString& title );
        void setupEntryTypes();
        void updateGUI();
        void internalApply( BibTeX::Entry *entry );
        void internalReset( BibTeX::Entry *entry );
        void restoreWindowSize( KConfig *config );
        void saveWindowSize( KConfig *config ) const;
    };

    class EntryWidgetDialog: public KDialogBase
    {
        Q_OBJECT
    public:
        EntryWidgetDialog( TQWidget *parent = 0, const char *name = 0, bool modal = true, const TQString &caption = TQString::null, int buttonMask = Ok | Apply | Cancel ) : KDialogBase( parent, name, modal, caption, buttonMask ) {/* nothing */};
        ~EntryWidgetDialog() {/* nothing */};
        void setMainWidget( EntryWidget *widget )
        {
            KDialogBase::setMainWidget( widget );
            m_widget = widget;
        };

    protected:
        void closeEvent( TQCloseEvent * e )
        {
            if ( m_widget->queryClose() ) e->accept();
            else e->ignore();
        }

    protected slots:
        void slotCancel()
        {
            if ( m_widget->queryClose() ) TQDialog::done( Cancel );
        }

        void slotClose()
        {
            if ( m_widget->queryClose() ) TQDialog::done( Cancel );
        }

    private:
        EntryWidget *m_widget;
    };

}

#endif