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 "DialogView.h"
19 #include "ui_CitationUi.h"
21 #include "insets/InsetCommandParams.h"
25 #include <QStringList>
26 #include <QStringListModel>
34 class GuiSelectionManager;
36 class GuiCitation : public DialogView, public Ui::CitationUi
42 GuiCitation(GuiView & lv);
52 void showEvent(QShowEvent * e);
54 void closeEvent(QCloseEvent * e);
55 /// prepares a call to GuiCitation::searchKeys when we
56 /// are ready to search the BibTeX entries
57 void findText(QString const & text, bool reset = false);
58 /// check whether key is already selected
59 bool isSelected(const QModelIndex &);
60 /// update the display of BibTeX information
61 void updateInfo(QModelIndex const &);
65 void on_okPB_clicked();
66 void on_cancelPB_clicked();
67 void on_restorePB_clicked();
68 void on_applyPB_clicked();
69 void on_searchPB_clicked();
70 void on_findLE_textChanged(const QString & text);
71 void on_fieldsCO_currentIndexChanged(int index);
72 void on_entriesCO_currentIndexChanged(int index);
73 void on_citationStyleCO_currentIndexChanged(int index);
74 void on_caseCB_stateChanged(int);
75 void on_regexCB_stateChanged(int);
76 void on_asTypeCB_stateChanged(int);
80 /// performs a limited update, suitable for internal call
81 void updateControls();
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 /// set the formatting widgets
95 void updateFormatting(CiteStyle currentStyle);
96 /// last used citation style
99 GuiSelectionManager * selectionManager;
104 QStringListModel * available() { return &available_model_; }
106 QStringListModel * selected() { return &selected_model_; }
108 QString textBefore();
111 /// Get key description
112 QString getKeyInfo(QString const &);
113 /// Clear selected keys
114 void clearSelection();
115 /// Return a list of available fields
116 QStringList getFieldsAsQStringList();
117 /// Return a list of available fields
118 QStringList getEntriesAsQStringList();
120 /// Find keys containing a string.
122 QString const & str, //< string expression
123 bool only_keys, //< set to true if only keys shall be searched.
124 docstring field, //<field to search, empty for all fields
125 docstring entryType, //<entry type to display, empty for all
126 bool case_sensitive, //< set to true for case sensitive search.
127 bool reg_exp, //< set to true if \c str is a regular expression.
128 bool reset = false //< whether to reset and search all keys
131 /// List of example cite strings
132 QStringList citationStyles(int);
134 /// Set the Params variable for the Controller.
135 void apply(int const choice, bool const full, bool const force,
136 QString before, QString after);
138 bool initialiseParams(std::string const & data);
139 /// clean-up on hide.
141 /// clean-up on hide.
142 void dispatchParams();
144 bool isBufferDependent() const { return true; }
148 QStringListModel available_model_;
150 QStringListModel selected_model_;
152 QStringList all_keys_;
154 QStringList cited_keys_;
156 InsetCommandParams params_;
158 /** Disconnect from the inset when the Apply button is pressed.
159 * Allows easy insertion of multiple citations.
161 bool disconnectOnApply() const { return true; }
163 /// \return the list of all available bibliography keys.
164 std::vector<docstring> availableKeys() const;
165 /// \return the list of all used BibTeX fields
166 std::vector<docstring> availableFields() const;
167 /// \return the list of all used BibTeX entry types
168 std::vector<docstring> availableEntries() const;
170 void filterByEntryType(
171 std::vector<docstring> & keyVector, docstring entryType);
173 CiteEngine citeEngine() const;
175 /// \return information for this key.
176 docstring getInfo(docstring const & key) const;
178 /// Search a given string within the passed keys.
179 /// \return the vector of matched keys.
180 std::vector<docstring> searchKeys(
181 std::vector<docstring> const & keys_to_search, //< Keys to search.
182 bool only_keys, //< whether to search only the keys
183 docstring const & search_expression, //< Search expression (regex possible)
184 docstring field, //< field to search, empty for all fields
185 bool case_sensitive = false, //< set to true is the search should be case sensitive
186 bool regex = false //< \set to true if \c search_expression is a regex
190 /// The BibTeX information available to the dialog
191 BiblioInfo const & bibInfo() const;
194 } // namespace frontend
197 #endif // GUICITATION_H