summaryrefslogtreecommitdiffstats
path: root/src/kbibtex_part.h
blob: f9a045af9d82729b34da51fe725612c96d6ae34e (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
159
160
161
162
163
164
165
166
167
168
169
/***************************************************************************
*   Copyright (C) 2004-2006 by Thomas Fischer                             *
*   [email protected]                                             *
*                                                                         *
*   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 _KBIBTEXPART_H_
#define _KBIBTEXPART_H_

#include <kparts/part.h>
#include <kparts/factory.h>

#include <element.h>
#include <xsltransform.h>
#include <documentwidget.h>
#include <settingsdlg.h>

class QWidget;
class QTextEdit;
class QFile;
class QLabel;
class QTabWidget;
class QPainter;
class QListViewItem;
class QProgressDialog;
class KURL;
class KListView;
class KAction;
class KActionMenu;
class KToggleAction;
class KMainWindow;

class KBibTeXPart : public KParts::ReadWritePart
{
    Q_OBJECT

public:
    KBibTeXPart( QWidget *parentWidget, const char *widgetName,
                 QObject *parent, const char *name );

    virtual ~KBibTeXPart();

    void setReadWrite( bool rw );

    void setModified( bool modified );

    bool saveAs();
    bool queryClose();
    virtual bool closeURL();

public slots:
    virtual bool save();

signals:
    void signalAddRecentURL( const KURL& );

protected:
    virtual bool openFile();
    virtual bool saveFile();

protected slots:
    void slotFileSaveAs();
    void slotFileMerge();
    void slotFileExport();
    void slotFileStatistics();
    void slotFileFindDups();
    void slotPreferences();

private slots:
    bool slotNewElement();
    void slotSearchWebsites( int id );
    void slotToggleShowSpecialElements();
    void slotDeferredInitialization();
    void slotUpdateMenu( int numSelectedItems );
    void slotUndoChanged( bool undoAvailable );
    void slotUseInPipe();

private:
    enum SearchDirection
    {
        sdForward, sdBackward
    };
    enum SaveStatus
    {
        ssSave, ssExport, ssFailed
    };

    int m_defInitCounter;
    QLabel *m_preview;
    QProgressDialog *m_progressDialog;
    KBibTeX::DocumentWidget *m_documentWidget;
    KBibTeX::SettingsDlg *m_settingsDlg;
    KAction *m_actionFileMerge;
    KAction *m_actionFileExport;
    KAction *m_actionFileStatistics;
    KAction *m_actionFileFindDups;
    KAction *m_actionEditUndo;
    KAction *m_actionElementSendToLyX;
    KAction *m_actionEditElement;
    KAction *m_actionDeleteElement;
    KAction *m_actionEditCut;
    KAction *m_actionEditCopy;
    KAction *m_actionEditCopyRef;
    KAction *m_actionEditPaste;
    KAction *m_actionEditSelectAll;
    KAction *m_actionEditFind;
    KAction *m_actionEditFindNext;
    KAction *m_actionPreferences;
    KAction *m_actionSearchOnlineDatabases;
    KActionMenu *m_actionViewDocument;
    KAction *m_actionViewFirstDocument;
    KAction *m_actionViewDocumentOnlineRef;
    KActionMenu *m_actionAssignKeywords;
    KAction *m_actionNormalizeIds;
    KActionMenu *m_actionMenuSearchWebsites;
    KActionMenu *m_actionViewShowColumns;
    KAction *m_actionSearchNCBI;
    KToggleAction *m_actionUseInPipe;
    KToggleAction *m_actionShowComments;
    KToggleAction *m_actionShowMacros;
    KMainWindow *m_mainWindow;
    QValueList<KBibTeX::WebQuery*> webQueryList;
    bool m_initializationDone;
    QFile *m_inPipe;

    void readSettings();
    void writeSettings();

    void setupGUI( QWidget *parentWidget, const char *name );
    void setupActions();

signals:
    void progressCancel();
};

class KInstance;
class KAboutData;

class KBibTeXPartFactory : public KParts::Factory
{
    Q_OBJECT
public:
    KBibTeXPartFactory();
    virtual ~KBibTeXPartFactory();
    virtual KParts::Part* createPartObject( QWidget * parentWidget, const char * widgetName,
                                            QObject * parent, const char * name,
                                            const char * classname, const QStringList & /* args */ );
    static KInstance* instance();

private:
    static KInstance* s_instance;
    static KAboutData* s_about;
};

#endif // _KBIBTEXPART_H_