]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
583d432b9caf598ad1ddecb97c328b5f3c700f69
[lyx.git] / src / frontends / qt4 / GuiCitation.h
1 // -*- C++ -*-
2 /**
3  * \file GuiCitation.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Kalle Dalheimer
9  * \author Abdelrazak Younes
10  * \author Richard Heck
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUICITATION_H
16 #define GUICITATION_H
17
18 #include "GuiDialog.h"
19 #include "ControlCitation.h"
20 #include "GuiSelectionManager.h"
21 #include "ui_CitationUi.h"
22 #include "support/docstring.h"
23
24 #include <QKeyEvent>
25 #include <QStringList>
26 #include <QStringListModel>
27
28 namespace lyx {
29 namespace frontend {
30
31 class GuiCitationDialog : public GuiDialog, public Ui::CitationUi
32 {
33         Q_OBJECT
34
35 public:
36         ///
37         GuiCitationDialog(LyXView & lv);
38
39         ///
40         void applyView();
41         /// Hide the dialog from sight
42         void hideView();
43         /// Redraw the dialog (e.g. if the colors have been remapped).
44         void redrawView() {}
45         /// Create the dialog if necessary, update it and display it.
46         void showView();
47         /// \return true if the dialog is visible.
48         bool isVisibleView() const;
49
50 public Q_SLOTS:
51         /// Update the display of the dialog whilst it is still visible.
52         void updateView();
53
54 private:
55         ///
56         ControlCitation & controller();
57         ///
58         void closeEvent(QCloseEvent * e);
59         /// prepares a call to GuiCitation::searchKeys when we
60         /// are ready to search the BibTeX entries
61         void findText(QString const & text, bool reset = false);
62         /// check whether key is already selected
63         bool isSelected(const QModelIndex &);
64         /// update the display of BibTeX information
65         void updateInfo(QModelIndex const &);
66
67 private Q_SLOTS:
68         void cleanUp();
69         void on_okPB_clicked();
70         void on_cancelPB_clicked();
71         void on_restorePB_clicked();
72         void on_applyPB_clicked();
73         void on_findLE_textChanged(const QString & text);
74         void on_fieldsCO_currentIndexChanged(int index);
75         void on_entriesCO_currentIndexChanged(int index);
76         void on_caseCB_stateChanged(int);
77         void on_regexCB_stateChanged(int);
78         void changed();
79         ///
80         void setCitedKeys();
81         /// performs a limited update, suitable for internal call
82         void updateDialog();
83         
84 private:
85         /// enable/disable buttons
86         void setButtons();
87         /// fill the styles combo
88         void fillStyles();
89         /// fill the fields combo
90         void fillFields();
91         /// fill the entries combo
92         void fillEntries();
93         /// set the styles combo
94         void updateStyle();
95         /// last used citation style
96         int style_;
97         
98         GuiSelectionManager * selectionManager;
99
100         ///
101         void init();
102
103         /// Available keys
104         QStringListModel * available() { return &available_model_; }
105
106         /// Selected keys
107         QStringListModel * selected() { return &selected_model_; }
108
109         /// Text before cite
110         QString textBefore();
111
112         /// Text after cite
113         QString textAfter();
114
115         /// Get key description
116         QString getKeyInfo(QString const &);
117
118         /// Clear selected keys
119         void clearSelection();
120         
121         /// Return a list of available fields 
122         QStringList getFieldsAsQStringList();
123         
124         /// Return a list of available fields 
125         QStringList getEntriesAsQStringList();
126         
127         /// Find keys containing a string.
128         void findKey(
129                 QString const & str, //< string expression
130                 bool only_keys, //< set to true if only keys shall be searched.
131                 docstring field, //<field to search, empty for all fields
132                 docstring entryType, //<entry type to display, empty for all
133                 bool case_sensitive, //< set to true for case sensitive search.
134                 bool reg_exp, //< set to true if \c str is a regular expression.
135                 bool reset = false //< whether to reset and search all keys
136                 );
137
138         /// List of example cite strings
139         QStringList citationStyles(int);
140
141         /// Set the Params variable for the Controller.
142         void apply(int const choice, bool const full, bool const force,
143                                           QString before, QString after);
144
145 private:
146         /// available keys.
147         QStringListModel available_model_;
148         /// selected keys.
149         QStringListModel selected_model_;
150         /// All keys.
151         QStringList all_keys_;
152         /// Cited keys.
153         QStringList cited_keys_;
154 };
155
156
157 } // namespace frontend
158 } // namespace lyx
159
160 #endif // GUICITATION_H