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"
21 #include "support/docstring.h"
22 #include "BiblioInfo.h"
25 #include <QStringList>
26 #include <QStringListModel>
31 class GuiCitation : public GuiCommand, public Ui::CitationUi
37 GuiCitation(GuiView & lv);
43 /// Update the display of the dialog whilst it is still visible.
48 void showEvent(QShowEvent * e);
50 void closeEvent(QCloseEvent * e);
51 /// prepares a call to GuiCitation::searchKeys when we
52 /// are ready to search the BibTeX entries
53 void findText(QString const & text, bool reset = false);
54 /// check whether key is already selected
55 bool isSelected(const QModelIndex &);
56 /// update the display of BibTeX information
57 void updateInfo(QModelIndex const &);
61 void on_okPB_clicked();
62 void on_cancelPB_clicked();
63 void on_restorePB_clicked();
64 void on_applyPB_clicked();
65 void on_findLE_textChanged(const QString & text);
66 void on_fieldsCO_currentIndexChanged(int index);
67 void on_entriesCO_currentIndexChanged(int index);
68 void on_citationStyleCO_currentIndexChanged(int index);
69 void on_caseCB_stateChanged(int);
70 void on_regexCB_stateChanged(int);
74 /// performs a limited update, suitable for internal call
78 /// enable/disable buttons
80 /// fill the styles combo
82 /// fill the fields combo
84 /// fill the entries combo
86 /// set the styles combo
88 /// set the formatting widgets
89 void updateFormatting(biblio::CiteStyle currentStyle);
90 /// last used citation style
93 GuiSelectionManager * selectionManager;
98 QStringListModel * available() { return &available_model_; }
100 QStringListModel * selected() { return &selected_model_; }
102 QString textBefore();
105 /// Get key description
106 QString getKeyInfo(QString const &);
107 /// Clear selected keys
108 void clearSelection();
109 /// Return a list of available fields
110 QStringList getFieldsAsQStringList();
111 /// Return a list of available fields
112 QStringList getEntriesAsQStringList();
114 /// Find keys containing a string.
116 QString const & str, //< string expression
117 bool only_keys, //< set to true if only keys shall be searched.
118 docstring field, //<field to search, empty for all fields
119 docstring entryType, //<entry type to display, empty for all
120 bool case_sensitive, //< set to true for case sensitive search.
121 bool reg_exp, //< set to true if \c str is a regular expression.
122 bool reset = false //< whether to reset and search all keys
125 /// List of example cite strings
126 QStringList citationStyles(int);
128 /// Set the Params variable for the Controller.
129 void apply(int const choice, bool const full, bool const force,
130 QString before, QString after);
134 QStringListModel available_model_;
136 QStringListModel selected_model_;
138 QStringList all_keys_;
140 QStringList cited_keys_;
143 bool initialiseParams(std::string const & data);
145 /// clean-up on hide.
148 /** Disconnect from the inset when the Apply button is pressed.
149 * Allows easy insertion of multiple citations.
151 bool disconnectOnApply() const { return true; }
153 /// \return the list of all available bibliography keys.
154 std::vector<docstring> const availableKeys() const;
155 /// \return the list of all used BibTeX fields
156 std::vector<docstring> const availableFields() const;
157 /// \return the list of all used BibTeX entry types
158 std::vector<docstring> const availableEntries() const;
160 void filterByEntryType(
161 std::vector<docstring> & keyVector, docstring entryType);
163 biblio::CiteEngine getEngine() const;
165 /// \return information for this key.
166 docstring getInfo(docstring const & key) const;
168 /// Search a given string within the passed keys.
169 /// \return the vector of matched keys.
170 std::vector<docstring> searchKeys(
171 std::vector<docstring> const & keys_to_search, //< Keys to search.
172 bool only_keys, //< whether to search only the keys
173 docstring const & search_expression, //< Search expression (regex possible)
174 docstring field, //< field to search, empty for all fields
175 bool case_sensitive = false, //< set to true is the search should be case sensitive
176 bool regex = false //< \set to true if \c search_expression is a regex
180 /// The BibTeX information available to the dialog
181 BiblioInfo bibkeysInfo_;
184 } // namespace frontend
187 #endif // GUICITATION_H