]> git.lyx.org Git - features.git/blob - src/frontends/qt/GuiCitation.h
Regenerate previews after zoom (#11919)
[features.git] / src / frontends / qt / 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 Kimberly 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 "DialogView.h"
19 #include "ui_CitationUi.h"
20
21 #include "insets/InsetCommandParams.h"
22
23 #include "BiblioInfo.h"
24
25 #include <QAbstractListModel>
26 #include <QStandardItemModel>
27 #include <QStringList>
28 #include <QStringListModel>
29
30 namespace lyx {
31
32 class CitationStyle;
33
34 namespace frontend {
35
36 class FancyLineEdit;
37 class GuiSelectionManager;
38
39
40 class GuiCitation : public DialogView, public Ui::CitationUi
41 {
42         Q_OBJECT
43
44 public:
45         ///
46         GuiCitation(GuiView & lv);
47
48 private Q_SLOTS:
49         void on_buttonBox_accepted();
50         void on_buttonBox_rejected();
51         void on_buttonBox_clicked(QAbstractButton *);
52         void on_literalCB_clicked();
53         void filterPressed();
54         void filterChanged(const QString & text);
55         void on_fieldsCO_currentIndexChanged(int index);
56         void on_entriesCO_currentIndexChanged(int index);
57         void on_citationStyleCO_currentIndexChanged(int index);
58         void resetFilter();
59         void caseChanged();
60         void regexChanged();
61         void instantChanged(bool checked);
62         void changed();
63         /// set the citation keys, mark as changed
64         void setCitedKeys();
65         /// update the styles for the style combo, mark as changed
66         void updateStyles();
67         /// performs a limited update, suitable for internal call
68         void updateControls();
69
70
71 private:
72         /// Dialog inherited methods
73         //@{
74         void applyView() override;
75         void updateView() override {}
76         bool initialiseParams(std::string const & data) override;
77         void clearParams() override;
78         void dispatchParams() override;
79         bool isBufferDependent() const override { return true; }
80         void saveSession(QSettings & settings) const override;
81         void restoreSession() override;
82         //@}
83
84         ///
85         void showEvent(QShowEvent * e) override;
86         ///
87         void closeEvent(QCloseEvent * e) override;
88         /// prepares a call to GuiCitation::searchKeys when we
89         /// are ready to search the BibTeX entries
90         void findText(QString const & text, bool reset = false);
91         /// check whether key is already selected
92         bool isSelected(const QModelIndex &);
93         /// update the display of BibTeX information
94         void updateInfo(BiblioInfo const & bi, QModelIndex const &);
95         /// enable/disable buttons
96         void setButtons();
97         /// fill the fields combo
98         void fillFields(BiblioInfo const & bi);
99         /// fill the entries combo
100         void fillEntries(BiblioInfo const & bi);
101         /// set the styles combo
102         void updateStyles(BiblioInfo const & bi);
103         /// set the formatting widgets
104         void updateFormatting(CitationStyle const & currentStyle);
105         ///
106         void updateControls(BiblioInfo const & bi);
107         /// Set the appropriate hinting text on the filter bar
108         void updateFilterHint();
109         ///
110         void init();
111         /// Clear selected keys
112         void clearSelection();
113
114         /// Set selected keys
115         void setSelectedKeys(QStringList const &);
116         /// Get selected keys
117         QStringList selectedKeys();
118         /// Set pre texts of qualified lists
119         void setPreTexts(std::vector<docstring> const & m);
120         /// Get pre texts of qualified lists
121         std::vector<docstring> getPreTexts();
122         /// Set post texts of qualified lists
123         void setPostTexts(std::vector<docstring> const & m);
124         /// Get post texts of qualified lists
125         std::vector<docstring> getPostTexts();
126
127         /// Find keys containing a string.
128         void findKey(
129                 BiblioInfo const & bi, //< optimize by passing this
130                 QString const & str, //< string expression
131                 bool only_keys, //< set to true if only keys shall be searched.
132                 docstring field, //<field to search, empty for all fields
133                 docstring entryType, //<entry type to display, empty for all
134                 bool case_sensitive, //< set to true for case sensitive search.
135                 bool reg_exp, //< set to true if \c str is a regular expression.
136                 bool reset = false //< whether to reset and search all keys
137                 );
138
139         /// List of example cite strings and their correlating lyx name
140         BiblioInfo::CiteStringMap citationStyles(BiblioInfo const & bi,
141                                                                 size_t max_size);
142
143         /// Set the Params variable for the Controller.
144         void applyParams(int const choice, bool const full, bool const force,
145                                           QString before, QString after);
146
147         ///
148         void filterByEntryType(BiblioInfo const & bi,
149                 std::vector<docstring> & keyVector, docstring const & entryType);
150
151         /// Search a given string within the passed keys.
152         /// \return the vector of matched keys.
153         std::vector<docstring> searchKeys(
154                 BiblioInfo const & bi, //< optimize by passing this
155                 std::vector<docstring> const & keys_to_search, //< Keys to search.
156                 bool only_keys, //< whether to search only the keys
157                 docstring const & search_expression, //< Search expression (regex possible)
158                 docstring const & field, //< field to search, empty for all fields
159                 bool case_sensitive = false, //< set to true is the search should be case sensitive
160                 bool regex = false //< \set to true if \c search_expression is a regex
161                 ); //
162
163         /// The BibTeX information available to the dialog
164         /// Calls to this method will lead to checks of modification times and
165         /// the like, so it should be avoided.
166         BiblioInfo const & bibInfo() const;
167
168         /// contains the search box
169         FancyLineEdit * filter_;
170
171         /// Regexp action
172         QAction * regexp_;
173         /// Case sensitive action
174         QAction * casesense_;
175         /// Search as you type action
176         QAction * instant_;
177
178         /// last used citation style
179         QString style_;
180         /// this is the last style chosen in the current dialog
181         QString last_chosen_style_;
182         ///
183         GuiSelectionManager * selectionManager;
184         /// available keys.
185         QStringListModel available_model_;
186         /// selected keys.
187         QStandardItemModel selected_model_;
188         /// All keys.
189         QStringList all_keys_;
190         /// Cited keys.
191         QStringList cited_keys_;
192         ///
193         InsetCommandParams params_;
194 };
195
196 } // namespace frontend
197 } // namespace lyx
198
199 #endif // GUICITATION_H