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"
20 #include "FancyLineEdit.h"
22 #include "insets/InsetCommandParams.h"
26 #include <QStringList>
27 #include <QStringListModel>
35 class GuiSelectionManager;
37 class GuiCitation : public DialogView, public Ui::CitationUi
43 GuiCitation(GuiView & lv);
48 void on_okPB_clicked();
49 void on_cancelPB_clicked();
50 void on_restorePB_clicked();
51 void on_applyPB_clicked();
53 void filterChanged(const QString & text);
54 void on_fieldsCO_currentIndexChanged(int index);
55 void on_entriesCO_currentIndexChanged(int index);
56 void on_citationStyleCO_currentIndexChanged(int index);
60 void instantChanged(bool checked);
62 /// set the citation keys, mark as changed
64 /// update the styles for the style combo, mark as changed
66 /// performs a limited update, suitable for internal call
67 void updateControls();
71 /// Dialog inherited methods
75 bool initialiseParams(std::string const & data);
77 void dispatchParams();
78 bool isBufferDependent() const { return true; }
79 void saveSession() const;
80 void restoreSession();
81 /** Disconnect from the inset when the Apply button is pressed.
82 * Allows easy insertion of multiple citations.
84 bool disconnectOnApply() const { return true; }
88 void showEvent(QShowEvent * e);
90 void closeEvent(QCloseEvent * e);
91 /// prepares a call to GuiCitation::searchKeys when we
92 /// are ready to search the BibTeX entries
93 void findText(QString const & text, bool reset = false);
94 /// check whether key is already selected
95 bool isSelected(const QModelIndex &);
96 /// update the display of BibTeX information
97 void updateInfo(BiblioInfo const & bi, QModelIndex const &);
98 /// enable/disable buttons
100 /// fill the fields combo
101 void fillFields(BiblioInfo const & bi);
102 /// fill the entries combo
103 void fillEntries(BiblioInfo const & bi);
104 /// set the styles combo
105 void updateStyles(BiblioInfo const & bi);
106 /// set the formatting widgets
107 void updateFormatting(CitationStyle currentStyle);
109 void updateControls(BiblioInfo const & bi);
110 /// Set the appropriate hinting text on the filter bar
111 void updateFilterHint();
114 /// Clear selected keys
115 void clearSelection();
117 /// Find keys containing a string.
119 BiblioInfo const & bi, //< optimize by passing this
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(BiblioInfo const & bi, size_t max_size);
132 /// Set the Params variable for the Controller.
133 void applyParams(int const choice, bool const full, bool const force,
134 QString before, QString after);
137 void filterByEntryType(BiblioInfo const & bi,
138 std::vector<docstring> & keyVector, docstring entryType);
140 /// Search a given string within the passed keys.
141 /// \return the vector of matched keys.
142 std::vector<docstring> searchKeys(
143 BiblioInfo const & bi, //< optimize by passing this
144 std::vector<docstring> const & keys_to_search, //< Keys to search.
145 bool only_keys, //< whether to search only the keys
146 docstring const & search_expression, //< Search expression (regex possible)
147 docstring field, //< field to search, empty for all fields
148 bool case_sensitive = false, //< set to true is the search should be case sensitive
149 bool regex = false //< \set to true if \c search_expression is a regex
152 /// The BibTeX information available to the dialog
153 /// Calls to this method will lead to checks of modification times and
154 /// the like, so it should be avoided.
155 BiblioInfo const & bibInfo() const;
157 /// contains the search box
158 FancyLineEdit * filter_;
162 /// Case sensitive action
163 QAction * casesense_;
164 /// Search as you type action
167 /// last used citation style
170 GuiSelectionManager * selectionManager;
172 QStringListModel available_model_;
174 QStringListModel selected_model_;
176 QStringList all_keys_;
178 QStringList cited_keys_;
180 InsetCommandParams params_;
183 } // namespace frontend
186 #endif // GUICITATION_H