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