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"
23 #include "ControlCommand.h"
26 #include <QStringList>
27 #include <QStringListModel>
33 : public GuiDialog, public Ui::CitationUi, public ControlCommand
39 GuiCitation(LyXView & lv);
43 /// Hide the dialog from sight
45 /// Redraw the dialog (e.g. if the colors have been remapped).
47 /// Create the dialog if necessary, update it and display it.
49 /// \return true if the dialog is visible.
50 bool isVisibleView() const;
53 /// Update the display of the dialog whilst it is still visible.
58 ControlCommand & controller() { return *this; }
60 void closeEvent(QCloseEvent * e);
61 /// prepares a call to GuiCitation::searchKeys when we
62 /// are ready to search the BibTeX entries
63 void findText(QString const & text, bool reset = false);
64 /// check whether key is already selected
65 bool isSelected(const QModelIndex &);
66 /// update the display of BibTeX information
67 void updateInfo(QModelIndex const &);
71 void on_okPB_clicked();
72 void on_cancelPB_clicked();
73 void on_restorePB_clicked();
74 void on_applyPB_clicked();
75 void on_findLE_textChanged(const QString & text);
76 void on_fieldsCO_currentIndexChanged(int index);
77 void on_entriesCO_currentIndexChanged(int index);
78 void on_caseCB_stateChanged(int);
79 void on_regexCB_stateChanged(int);
83 /// performs a limited update, suitable for internal call
87 /// enable/disable buttons
89 /// fill the styles combo
91 /// fill the fields combo
93 /// fill the entries combo
95 /// set the styles combo
97 /// last used citation style
100 GuiSelectionManager * selectionManager;
106 QStringListModel * available() { return &available_model_; }
109 QStringListModel * selected() { return &selected_model_; }
112 QString textBefore();
117 /// Get key description
118 QString getKeyInfo(QString const &);
120 /// Clear selected keys
121 void clearSelection();
123 /// Return a list of available fields
124 QStringList getFieldsAsQStringList();
126 /// Return a list of available fields
127 QStringList getEntriesAsQStringList();
129 /// Find keys containing a string.
131 QString const & str, //< string expression
132 bool only_keys, //< set to true if only keys shall be searched.
133 docstring field, //<field to search, empty for all fields
134 docstring entryType, //<entry type to display, empty for all
135 bool case_sensitive, //< set to true for case sensitive search.
136 bool reg_exp, //< set to true if \c str is a regular expression.
137 bool reset = false //< whether to reset and search all keys
140 /// List of example cite strings
141 QStringList citationStyles(int);
143 /// Set the Params variable for the Controller.
144 void apply(int const choice, bool const full, bool const force,
145 QString before, QString after);
149 QStringListModel available_model_;
151 QStringListModel selected_model_;
153 QStringList all_keys_;
155 QStringList cited_keys_;
158 bool initialiseParams(std::string const & data);
160 /// clean-up on hide.
163 /** Disconnect from the inset when the Apply button is pressed.
164 * Allows easy insertion of multiple citations.
166 bool disconnectOnApply() const { return true; }
168 /// \return the list of all available bibliography keys.
169 std::vector<docstring> const availableKeys() const;
170 /// \return the list of all used BibTeX fields
171 std::vector<docstring> const availableFields() const;
172 /// \return the list of all used BibTeX entry types
173 std::vector<docstring> const availableEntries() const;
175 void filterByEntryType(
176 std::vector<docstring> & keyVector, docstring entryType);
178 biblio::CiteEngine getEngine() const;
180 /// \return information for this key.
181 docstring getInfo(docstring const & key) const;
183 /// Search a given string within the passed keys.
184 /// \return the vector of matched keys.
185 std::vector<docstring> searchKeys(
186 std::vector<docstring> const & keys_to_search, //< Keys to search.
187 bool only_keys, //< whether to search only the keys
188 docstring const & search_expression, //< Search expression (regex possible)
189 docstring field, //< field to search, empty for all fields
190 bool case_sensitive = false, //< set to true is the search should be case sensitive
191 bool regex = false //< \set to true if \c search_expression is a regex
195 /// The BibTeX information available to the dialog
196 BiblioInfo bibkeysInfo_;
199 } // namespace frontend
202 #endif // GUICITATION_H