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>
32 class GuiCitation : public GuiCommand, public Ui::CitationUi
38 GuiCitation(LyXView & lv);
42 /// Hide the dialog from sight
44 /// Redraw the dialog (e.g. if the colors have been remapped).
46 /// Create the dialog if necessary, update it and display it.
48 /// \return true if the dialog is visible.
49 bool isVisibleView() const;
52 /// Update the display of the dialog whilst it is still visible.
57 void closeEvent(QCloseEvent * e);
58 /// prepares a call to GuiCitation::searchKeys when we
59 /// are ready to search the BibTeX entries
60 void findText(QString const & text, bool reset = false);
61 /// check whether key is already selected
62 bool isSelected(const QModelIndex &);
63 /// update the display of BibTeX information
64 void updateInfo(QModelIndex const &);
68 void on_okPB_clicked();
69 void on_cancelPB_clicked();
70 void on_restorePB_clicked();
71 void on_applyPB_clicked();
72 void on_findLE_textChanged(const QString & text);
73 void on_fieldsCO_currentIndexChanged(int index);
74 void on_entriesCO_currentIndexChanged(int index);
75 void on_caseCB_stateChanged(int);
76 void on_regexCB_stateChanged(int);
80 /// performs a limited update, suitable for internal call
84 /// enable/disable buttons
86 /// fill the styles combo
88 /// fill the fields combo
90 /// fill the entries combo
92 /// set the styles combo
94 /// last used citation style
97 GuiSelectionManager * selectionManager;
102 QStringListModel * available() { return &available_model_; }
104 QStringListModel * selected() { return &selected_model_; }
106 QString textBefore();
109 /// Get key description
110 QString getKeyInfo(QString const &);
111 /// Clear selected keys
112 void clearSelection();
113 /// Return a list of available fields
114 QStringList getFieldsAsQStringList();
115 /// Return a list of available fields
116 QStringList getEntriesAsQStringList();
118 /// Find keys containing a string.
120 QString const & str, //< string expression
121 bool only_keys, //< set to true if only keys shall be searched.
122 docstring field, //<field to search, empty for all fields
123 docstring entryType, //<entry type to display, empty for all
124 bool case_sensitive, //< set to true for case sensitive search.
125 bool reg_exp, //< set to true if \c str is a regular expression.
126 bool reset = false //< whether to reset and search all keys
129 /// List of example cite strings
130 QStringList citationStyles(int);
132 /// Set the Params variable for the Controller.
133 void apply(int const choice, bool const full, bool const force,
134 QString before, QString after);
138 QStringListModel available_model_;
140 QStringListModel selected_model_;
142 QStringList all_keys_;
144 QStringList cited_keys_;
147 bool initialiseParams(std::string const & data);
149 /// clean-up on hide.
152 /** Disconnect from the inset when the Apply button is pressed.
153 * Allows easy insertion of multiple citations.
155 bool disconnectOnApply() const { return true; }
157 /// \return the list of all available bibliography keys.
158 std::vector<docstring> const availableKeys() const;
159 /// \return the list of all used BibTeX fields
160 std::vector<docstring> const availableFields() const;
161 /// \return the list of all used BibTeX entry types
162 std::vector<docstring> const availableEntries() const;
164 void filterByEntryType(
165 std::vector<docstring> & keyVector, docstring entryType);
167 biblio::CiteEngine getEngine() const;
169 /// \return information for this key.
170 docstring getInfo(docstring const & key) const;
172 /// Search a given string within the passed keys.
173 /// \return the vector of matched keys.
174 std::vector<docstring> searchKeys(
175 std::vector<docstring> const & keys_to_search, //< Keys to search.
176 bool only_keys, //< whether to search only the keys
177 docstring const & search_expression, //< Search expression (regex possible)
178 docstring field, //< field to search, empty for all fields
179 bool case_sensitive = false, //< set to true is the search should be case sensitive
180 bool regex = false //< \set to true if \c search_expression is a regex
184 /// The BibTeX information available to the dialog
185 BiblioInfo bibkeysInfo_;
188 } // namespace frontend
191 #endif // GUICITATION_H