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 Heck
12 * Full author contact details are available in file CREDITS.
18 #include "GuiDialog.h"
19 #include "GuiSelectionManager.h"
20 #include "ui_CitationUi.h"
22 #include "BiblioInfo.h"
25 #include "insets/InsetCommandParams.h"
27 #include <QStringList>
28 #include <QStringListModel>
33 class GuiCitation : public GuiDialog, public Ui::CitationUi
39 GuiCitation(GuiView & lv);
45 /// Update the display of the dialog whilst it is still visible.
50 void showEvent(QShowEvent * e);
52 void closeEvent(QCloseEvent * e);
53 /// prepares a call to GuiCitation::searchKeys when we
54 /// are ready to search the BibTeX entries
55 void findText(QString const & text, bool reset = false);
56 /// check whether key is already selected
57 bool isSelected(const QModelIndex &);
58 /// update the display of BibTeX information
59 void updateInfo(QModelIndex const &);
63 void on_okPB_clicked();
64 void on_cancelPB_clicked();
65 void on_restorePB_clicked();
66 void on_applyPB_clicked();
67 void on_searchPB_clicked();
68 void on_findLE_textChanged(const QString & text);
69 void on_fieldsCO_currentIndexChanged(int index);
70 void on_entriesCO_currentIndexChanged(int index);
71 void on_citationStyleCO_currentIndexChanged(int index);
72 void on_caseCB_stateChanged(int);
73 void on_regexCB_stateChanged(int);
74 void on_asTypeCB_stateChanged(int);
78 /// performs a limited update, suitable for internal call
82 /// enable/disable buttons
84 /// fill the styles combo
86 /// fill the fields combo
88 /// fill the entries combo
90 /// set the styles combo
92 /// set the formatting widgets
93 void updateFormatting(CiteStyle currentStyle);
94 /// last used citation style
97 GuiSelectionManager * selectionManager;
102 QStringListModel * available() { return &available_model_; }
104 QStringListModel * selected() { return &selected_model_; }
106 QString textBefore();
109 /// Get key description
110 QString getKeyInfo(QString const &);
111 /// Clear selected keys
112 void clearSelection();
113 /// Return a list of available fields
114 QStringList getFieldsAsQStringList();
115 /// Return a list of available fields
116 QStringList getEntriesAsQStringList();
118 /// Find keys containing a string.
120 QString const & str, //< string expression
121 bool only_keys, //< set to true if only keys shall be searched.
122 docstring field, //<field to search, empty for all fields
123 docstring entryType, //<entry type to display, empty for all
124 bool case_sensitive, //< set to true for case sensitive search.
125 bool reg_exp, //< set to true if \c str is a regular expression.
126 bool reset = false //< whether to reset and search all keys
129 /// List of example cite strings
130 QStringList citationStyles(int);
132 /// Set the Params variable for the Controller.
133 void apply(int const choice, bool const full, bool const force,
134 QString before, QString after);
136 bool initialiseParams(std::string const & data);
137 /// clean-up on hide.
139 /// clean-up on hide.
140 void dispatchParams();
142 bool isBufferDependent() const { return true; }
146 QStringListModel available_model_;
148 QStringListModel selected_model_;
150 QStringList all_keys_;
152 QStringList cited_keys_;
154 InsetCommandParams params_;
156 /** Disconnect from the inset when the Apply button is pressed.
157 * Allows easy insertion of multiple citations.
159 bool disconnectOnApply() const { return true; }
161 /// \return the list of all available bibliography keys.
162 std::vector<docstring> availableKeys() const;
163 /// \return the list of all used BibTeX fields
164 std::vector<docstring> availableFields() const;
165 /// \return the list of all used BibTeX entry types
166 std::vector<docstring> availableEntries() const;
168 void filterByEntryType(
169 std::vector<docstring> & keyVector, docstring entryType);
171 CiteEngine citeEngine() const;
173 /// \return information for this key.
174 docstring getInfo(docstring const & key) const;
176 /// Search a given string within the passed keys.
177 /// \return the vector of matched keys.
178 std::vector<docstring> searchKeys(
179 std::vector<docstring> const & keys_to_search, //< Keys to search.
180 bool only_keys, //< whether to search only the keys
181 docstring const & search_expression, //< Search expression (regex possible)
182 docstring field, //< field to search, empty for all fields
183 bool case_sensitive = false, //< set to true is the search should be case sensitive
184 bool regex = false //< \set to true if \c search_expression is a regex
188 /// The BibTeX information available to the dialog
189 BiblioInfo bibkeysInfo_;
192 } // namespace frontend
195 #endif // GUICITATION_H