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_findLE_textChanged(const QString & text);
68 void on_fieldsCO_currentIndexChanged(int index);
69 void on_entriesCO_currentIndexChanged(int index);
70 void on_citationStyleCO_currentIndexChanged(int index);
71 void on_caseCB_stateChanged(int);
72 void on_regexCB_stateChanged(int);
76 /// performs a limited update, suitable for internal call
80 /// enable/disable buttons
82 /// fill the styles combo
84 /// fill the fields combo
86 /// fill the entries combo
88 /// set the styles combo
90 /// set the formatting widgets
91 void updateFormatting(CiteStyle currentStyle);
92 /// last used citation style
95 GuiSelectionManager * selectionManager;
100 QStringListModel * available() { return &available_model_; }
102 QStringListModel * selected() { return &selected_model_; }
104 QString textBefore();
107 /// Get key description
108 QString getKeyInfo(QString const &);
109 /// Clear selected keys
110 void clearSelection();
111 /// Return a list of available fields
112 QStringList getFieldsAsQStringList();
113 /// Return a list of available fields
114 QStringList getEntriesAsQStringList();
116 /// Find keys containing a string.
118 QString const & str, //< string expression
119 bool only_keys, //< set to true if only keys shall be searched.
120 docstring field, //<field to search, empty for all fields
121 docstring entryType, //<entry type to display, empty for all
122 bool case_sensitive, //< set to true for case sensitive search.
123 bool reg_exp, //< set to true if \c str is a regular expression.
124 bool reset = false //< whether to reset and search all keys
127 /// List of example cite strings
128 QStringList citationStyles(int);
130 /// Set the Params variable for the Controller.
131 void apply(int const choice, bool const full, bool const force,
132 QString before, QString after);
134 bool initialiseParams(std::string const & data);
135 /// clean-up on hide.
137 /// clean-up on hide.
138 void dispatchParams();
140 bool isBufferDependent() const { return true; }
144 QStringListModel available_model_;
146 QStringListModel selected_model_;
148 QStringList all_keys_;
150 QStringList cited_keys_;
152 InsetCommandParams params_;
154 /** Disconnect from the inset when the Apply button is pressed.
155 * Allows easy insertion of multiple citations.
157 bool disconnectOnApply() const { return true; }
159 /// \return the list of all available bibliography keys.
160 std::vector<docstring> availableKeys() const;
161 /// \return the list of all used BibTeX fields
162 std::vector<docstring> availableFields() const;
163 /// \return the list of all used BibTeX entry types
164 std::vector<docstring> availableEntries() const;
166 void filterByEntryType(
167 std::vector<docstring> & keyVector, docstring entryType);
169 CiteEngine citeEngine() const;
171 /// \return information for this key.
172 docstring getInfo(docstring const & key) const;
174 /// Search a given string within the passed keys.
175 /// \return the vector of matched keys.
176 std::vector<docstring> searchKeys(
177 std::vector<docstring> const & keys_to_search, //< Keys to search.
178 bool only_keys, //< whether to search only the keys
179 docstring const & search_expression, //< Search expression (regex possible)
180 docstring field, //< field to search, empty for all fields
181 bool case_sensitive = false, //< set to true is the search should be case sensitive
182 bool regex = false //< \set to true if \c search_expression is a regex
186 /// The BibTeX information available to the dialog
187 BiblioInfo bibkeysInfo_;
190 } // namespace frontend
193 #endif // GUICITATION_H