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);
46 /// Update the display of the dialog whilst it is still visible.
51 void showEvent(QShowEvent * e);
53 void closeEvent(QCloseEvent * e);
54 /// prepares a call to GuiCitation::searchKeys when we
55 /// are ready to search the BibTeX entries
56 void findText(QString const & text, bool reset = false);
57 /// check whether key is already selected
58 bool isSelected(const QModelIndex &);
59 /// update the display of BibTeX information
60 void updateInfo(QModelIndex const &);
64 void on_okPB_clicked();
65 void on_cancelPB_clicked();
66 void on_restorePB_clicked();
67 void on_applyPB_clicked();
68 void on_searchPB_clicked();
69 void on_findLE_textChanged(const QString & text);
70 void on_fieldsCO_currentIndexChanged(int index);
71 void on_entriesCO_currentIndexChanged(int index);
72 void on_citationStyleCO_currentIndexChanged(int index);
73 void on_caseCB_stateChanged(int);
74 void on_regexCB_stateChanged(int);
75 void on_asTypeCB_stateChanged(int);
79 /// performs a limited update, suitable for internal call
83 /// enable/disable buttons
85 /// fill the styles combo
87 /// fill the fields combo
89 /// fill the entries combo
91 /// set the styles combo
93 /// set the formatting widgets
94 void updateFormatting(CiteStyle currentStyle);
95 /// last used citation style
98 GuiSelectionManager * selectionManager;
103 QStringListModel * available() { return &available_model_; }
105 QStringListModel * selected() { return &selected_model_; }
107 QString textBefore();
110 /// Get key description
111 QString getKeyInfo(QString const &);
112 /// Clear selected keys
113 void clearSelection();
114 /// Return a list of available fields
115 QStringList getFieldsAsQStringList();
116 /// Return a list of available fields
117 QStringList getEntriesAsQStringList();
119 /// Find keys containing a string.
121 QString const & str, //< string expression
122 bool only_keys, //< set to true if only keys shall be searched.
123 docstring field, //<field to search, empty for all fields
124 docstring entryType, //<entry type to display, empty for all
125 bool case_sensitive, //< set to true for case sensitive search.
126 bool reg_exp, //< set to true if \c str is a regular expression.
127 bool reset = false //< whether to reset and search all keys
130 /// List of example cite strings
131 QStringList citationStyles(int);
133 /// Set the Params variable for the Controller.
134 void apply(int const choice, bool const full, bool const force,
135 QString before, QString after);
137 bool initialiseParams(std::string const & data);
138 /// clean-up on hide.
140 /// clean-up on hide.
141 void dispatchParams();
143 bool isBufferDependent() const { return true; }
147 QStringListModel available_model_;
149 QStringListModel selected_model_;
151 QStringList all_keys_;
153 QStringList cited_keys_;
155 InsetCommandParams params_;
157 /** Disconnect from the inset when the Apply button is pressed.
158 * Allows easy insertion of multiple citations.
160 bool disconnectOnApply() const { return true; }
162 /// \return the list of all available bibliography keys.
163 std::vector<docstring> availableKeys() const;
164 /// \return the list of all used BibTeX fields
165 std::vector<docstring> availableFields() const;
166 /// \return the list of all used BibTeX entry types
167 std::vector<docstring> availableEntries() const;
169 void filterByEntryType(
170 std::vector<docstring> & keyVector, docstring entryType);
172 CiteEngine citeEngine() const;
174 /// \return information for this key.
175 docstring getInfo(docstring const & key) const;
177 /// Search a given string within the passed keys.
178 /// \return the vector of matched keys.
179 std::vector<docstring> searchKeys(
180 std::vector<docstring> const & keys_to_search, //< Keys to search.
181 bool only_keys, //< whether to search only the keys
182 docstring const & search_expression, //< Search expression (regex possible)
183 docstring field, //< field to search, empty for all fields
184 bool case_sensitive = false, //< set to true is the search should be case sensitive
185 bool regex = false //< \set to true if \c search_expression is a regex
189 /// The BibTeX information available to the dialog
190 BiblioInfo const & bibInfo() const;
193 } // namespace frontend
196 #endif // GUICITATION_H