4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
8 * \author Kalle Dalheimer
9 * \author Abdelrazak Younes
10 * \author Richard Kimberly Heck
12 * Full author contact details are available in file CREDITS.
18 #include "DialogView.h"
19 #include "ui_CitationUi.h"
21 #include "insets/InsetCommandParams.h"
23 #include "BiblioInfo.h"
25 #include <QAbstractListModel>
26 #include <QStandardItemModel>
27 #include <QStringList>
28 #include <QStringListModel>
37 class GuiSelectionManager;
40 class GuiCitation : public DialogView, public Ui::CitationUi
46 GuiCitation(GuiView & lv);
49 void on_buttonBox_accepted();
50 void on_buttonBox_rejected();
51 void on_buttonBox_clicked(QAbstractButton *);
52 void on_literalCB_clicked();
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);
61 void instantChanged(bool checked);
63 /// set the citation keys, mark as changed
65 /// update the styles for the style combo, mark as changed
67 /// performs a limited update, suitable for internal call
68 void updateControls();
72 /// Dialog inherited methods
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;
85 void showEvent(QShowEvent * e) override;
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
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);
106 void updateControls(BiblioInfo const & bi);
107 /// Set the appropriate hinting text on the filter bar
108 void updateFilterHint();
111 /// Clear selected keys
112 void clearSelection();
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();
127 /// Find keys containing a string.
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
139 /// List of example cite strings and their correlating lyx name
140 BiblioInfo::CiteStringMap citationStyles(BiblioInfo const & bi,
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);
148 void filterByEntryType(BiblioInfo const & bi,
149 std::vector<docstring> & keyVector, docstring const & entryType);
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
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;
168 /// contains the search box
169 FancyLineEdit * filter_;
173 /// Case sensitive action
174 QAction * casesense_;
175 /// Search as you type action
178 /// last used citation style
180 /// this is the last style chosen in the current dialog
181 QString last_chosen_style_;
183 GuiSelectionManager * selectionManager;
185 QStringListModel available_model_;
187 QStandardItemModel selected_model_;
189 QStringList all_keys_;
191 QStringList cited_keys_;
193 InsetCommandParams params_;
196 } // namespace frontend
199 #endif // GUICITATION_H