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);
77 /// performs a limited update, suitable for internal call
81 /// enable/disable buttons
83 /// fill the styles combo
85 /// fill the fields combo
87 /// fill the entries combo
89 /// set the styles combo
91 /// set the formatting widgets
92 void updateFormatting(CiteStyle currentStyle);
93 /// last used citation style
96 GuiSelectionManager * selectionManager;
101 QStringListModel * available() { return &available_model_; }
103 QStringListModel * selected() { return &selected_model_; }
105 QString textBefore();
108 /// Get key description
109 QString getKeyInfo(QString const &);
110 /// Clear selected keys
111 void clearSelection();
112 /// Return a list of available fields
113 QStringList getFieldsAsQStringList();
114 /// Return a list of available fields
115 QStringList getEntriesAsQStringList();
117 /// Find keys containing a string.
119 QString const & str, //< string expression
120 bool only_keys, //< set to true if only keys shall be searched.
121 docstring field, //<field to search, empty for all fields
122 docstring entryType, //<entry type to display, empty for all
123 bool case_sensitive, //< set to true for case sensitive search.
124 bool reg_exp, //< set to true if \c str is a regular expression.
125 bool reset = false //< whether to reset and search all keys
128 /// List of example cite strings
129 QStringList citationStyles(int);
131 /// Set the Params variable for the Controller.
132 void apply(int const choice, bool const full, bool const force,
133 QString before, QString after);
135 bool initialiseParams(std::string const & data);
136 /// clean-up on hide.
138 /// clean-up on hide.
139 void dispatchParams();
141 bool isBufferDependent() const { return true; }
145 QStringListModel available_model_;
147 QStringListModel selected_model_;
149 QStringList all_keys_;
151 QStringList cited_keys_;
153 InsetCommandParams params_;
155 /** Disconnect from the inset when the Apply button is pressed.
156 * Allows easy insertion of multiple citations.
158 bool disconnectOnApply() const { return true; }
160 /// \return the list of all available bibliography keys.
161 std::vector<docstring> availableKeys() const;
162 /// \return the list of all used BibTeX fields
163 std::vector<docstring> availableFields() const;
164 /// \return the list of all used BibTeX entry types
165 std::vector<docstring> availableEntries() const;
167 void filterByEntryType(
168 std::vector<docstring> & keyVector, docstring entryType);
170 CiteEngine citeEngine() const;
172 /// \return information for this key.
173 docstring getInfo(docstring const & key) const;
175 /// Search a given string within the passed keys.
176 /// \return the vector of matched keys.
177 std::vector<docstring> searchKeys(
178 std::vector<docstring> const & keys_to_search, //< Keys to search.
179 bool only_keys, //< whether to search only the keys
180 docstring const & search_expression, //< Search expression (regex possible)
181 docstring field, //< field to search, empty for all fields
182 bool case_sensitive = false, //< set to true is the search should be case sensitive
183 bool regex = false //< \set to true if \c search_expression is a regex
187 /// The BibTeX information available to the dialog
188 BiblioInfo bibkeysInfo_;
191 } // namespace frontend
194 #endif // GUICITATION_H