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 "GuiCommand.h"
19 #include "GuiSelectionManager.h"
20 #include "ui_CitationUi.h"
21 #include "BiblioInfo.h"
23 #include <QStringList>
24 #include <QStringListModel>
29 class GuiCitation : public GuiCommand, public Ui::CitationUi
35 GuiCitation(GuiView & lv);
41 /// Update the display of the dialog whilst it is still visible.
46 void showEvent(QShowEvent * e);
48 void closeEvent(QCloseEvent * e);
49 /// prepares a call to GuiCitation::searchKeys when we
50 /// are ready to search the BibTeX entries
51 void findText(QString const & text, bool reset = false);
52 /// check whether key is already selected
53 bool isSelected(const QModelIndex &);
54 /// update the display of BibTeX information
55 void updateInfo(QModelIndex const &);
59 void on_okPB_clicked();
60 void on_cancelPB_clicked();
61 void on_restorePB_clicked();
62 void on_applyPB_clicked();
63 void on_findLE_textChanged(const QString & text);
64 void on_fieldsCO_currentIndexChanged(int index);
65 void on_entriesCO_currentIndexChanged(int index);
66 void on_citationStyleCO_currentIndexChanged(int index);
67 void on_caseCB_stateChanged(int);
68 void on_regexCB_stateChanged(int);
72 /// performs a limited update, suitable for internal call
76 /// enable/disable buttons
78 /// fill the styles combo
80 /// fill the fields combo
82 /// fill the entries combo
84 /// set the styles combo
86 /// set the formatting widgets
87 void updateFormatting(biblio::CiteStyle currentStyle);
88 /// last used citation style
91 GuiSelectionManager * selectionManager;
96 QStringListModel * available() { return &available_model_; }
98 QStringListModel * selected() { return &selected_model_; }
100 QString textBefore();
103 /// Get key description
104 QString getKeyInfo(QString const &);
105 /// Clear selected keys
106 void clearSelection();
107 /// Return a list of available fields
108 QStringList getFieldsAsQStringList();
109 /// Return a list of available fields
110 QStringList getEntriesAsQStringList();
112 /// Find keys containing a string.
114 QString const & str, //< string expression
115 bool only_keys, //< set to true if only keys shall be searched.
116 docstring field, //<field to search, empty for all fields
117 docstring entryType, //<entry type to display, empty for all
118 bool case_sensitive, //< set to true for case sensitive search.
119 bool reg_exp, //< set to true if \c str is a regular expression.
120 bool reset = false //< whether to reset and search all keys
123 /// List of example cite strings
124 QStringList citationStyles(int);
126 /// Set the Params variable for the Controller.
127 void apply(int const choice, bool const full, bool const force,
128 QString before, QString after);
132 QStringListModel available_model_;
134 QStringListModel selected_model_;
136 QStringList all_keys_;
138 QStringList cited_keys_;
141 bool initialiseParams(std::string const & data);
143 /// clean-up on hide.
146 /** Disconnect from the inset when the Apply button is pressed.
147 * Allows easy insertion of multiple citations.
149 bool disconnectOnApply() const { return true; }
151 /// \return the list of all available bibliography keys.
152 std::vector<docstring> availableKeys() const;
153 /// \return the list of all used BibTeX fields
154 std::vector<docstring> availableFields() const;
155 /// \return the list of all used BibTeX entry types
156 std::vector<docstring> availableEntries() const;
158 void filterByEntryType(
159 std::vector<docstring> & keyVector, docstring entryType);
161 biblio::CiteEngine citeEngine() const;
163 /// \return information for this key.
164 docstring getInfo(docstring const & key) const;
166 /// Search a given string within the passed keys.
167 /// \return the vector of matched keys.
168 std::vector<docstring> searchKeys(
169 std::vector<docstring> const & keys_to_search, //< Keys to search.
170 bool only_keys, //< whether to search only the keys
171 docstring const & search_expression, //< Search expression (regex possible)
172 docstring field, //< field to search, empty for all fields
173 bool case_sensitive = false, //< set to true is the search should be case sensitive
174 bool regex = false //< \set to true if \c search_expression is a regex
178 /// The BibTeX information available to the dialog
179 BiblioInfo bibkeysInfo_;
182 } // namespace frontend
185 #endif // GUICITATION_H