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"
24 #include "BiblioInfo.h"
27 #include <QAbstractListModel>
28 #include <QStandardItemModel>
29 #include <QStringList>
30 #include <QStringListModel>
38 class GuiSelectionManager;
41 class GuiCitation : public DialogView, public Ui::CitationUi
47 GuiCitation(GuiView & lv);
50 void on_buttonBox_accepted();
51 void on_buttonBox_rejected();
52 void on_buttonBox_clicked(QAbstractButton *);
53 void on_literalCB_clicked();
55 void filterChanged(const QString & text);
56 void on_fieldsCO_currentIndexChanged(int index);
57 void on_entriesCO_currentIndexChanged(int index);
58 void on_citationStyleCO_currentIndexChanged(int index);
62 void instantChanged(bool checked);
64 /// set the citation keys, mark as changed
66 /// update the styles for the style combo, mark as changed
68 /// performs a limited update, suitable for internal call
69 void updateControls();
73 /// Dialog inherited methods
77 bool initialiseParams(std::string const & data);
79 void dispatchParams();
80 bool isBufferDependent() const { return true; }
81 void saveSession(QSettings & settings) const;
82 void restoreSession();
83 /** Disconnect from the inset when the Apply button is pressed.
84 * Allows easy insertion of multiple citations.
86 bool disconnectOnApply() const { return true; }
90 void showEvent(QShowEvent * e);
92 void closeEvent(QCloseEvent * e);
93 /// prepares a call to GuiCitation::searchKeys when we
94 /// are ready to search the BibTeX entries
95 void findText(QString const & text, bool reset = false);
96 /// check whether key is already selected
97 bool isSelected(const QModelIndex &);
98 /// update the display of BibTeX information
99 void updateInfo(BiblioInfo const & bi, QModelIndex const &);
100 /// enable/disable buttons
102 /// fill the fields combo
103 void fillFields(BiblioInfo const & bi);
104 /// fill the entries combo
105 void fillEntries(BiblioInfo const & bi);
106 /// set the styles combo
107 void updateStyles(BiblioInfo const & bi);
108 /// set the formatting widgets
109 void updateFormatting(CitationStyle const & currentStyle);
111 void updateControls(BiblioInfo const & bi);
112 /// Set the appropriate hinting text on the filter bar
113 void updateFilterHint();
116 /// Clear selected keys
117 void clearSelection();
119 /// Set selected keys
120 void setSelectedKeys(QStringList const);
121 /// Get selected keys
122 QStringList selectedKeys();
123 /// Set pre texts of qualified lists
124 void setPreTexts(std::vector<docstring> const & m);
125 /// Get pre texts of qualified lists
126 std::vector<docstring> getPreTexts();
127 /// Set post texts of qualified lists
128 void setPostTexts(std::vector<docstring> const & m);
129 /// Get post texts of qualified lists
130 std::vector<docstring> getPostTexts();
132 /// Find keys containing a string.
134 BiblioInfo const & bi, //< optimize by passing this
135 QString const & str, //< string expression
136 bool only_keys, //< set to true if only keys shall be searched.
137 docstring field, //<field to search, empty for all fields
138 docstring entryType, //<entry type to display, empty for all
139 bool case_sensitive, //< set to true for case sensitive search.
140 bool reg_exp, //< set to true if \c str is a regular expression.
141 bool reset = false //< whether to reset and search all keys
144 /// List of example cite strings and their correlating lyx name
145 BiblioInfo::CiteStringMap citationStyles(BiblioInfo const & bi,
148 /// Set the Params variable for the Controller.
149 void applyParams(int const choice, bool const full, bool const force,
150 QString before, QString after);
153 void filterByEntryType(BiblioInfo const & bi,
154 std::vector<docstring> & keyVector, docstring entryType);
156 /// Search a given string within the passed keys.
157 /// \return the vector of matched keys.
158 std::vector<docstring> searchKeys(
159 BiblioInfo const & bi, //< optimize by passing this
160 std::vector<docstring> const & keys_to_search, //< Keys to search.
161 bool only_keys, //< whether to search only the keys
162 docstring const & search_expression, //< Search expression (regex possible)
163 docstring field, //< field to search, empty for all fields
164 bool case_sensitive = false, //< set to true is the search should be case sensitive
165 bool regex = false //< \set to true if \c search_expression is a regex
168 /// The BibTeX information available to the dialog
169 /// Calls to this method will lead to checks of modification times and
170 /// the like, so it should be avoided.
171 BiblioInfo const & bibInfo() const;
173 /// contains the search box
174 FancyLineEdit * filter_;
178 /// Case sensitive action
179 QAction * casesense_;
180 /// Search as you type action
183 /// last used citation style
185 /// this is the last style chosen in the current dialog
186 QString last_chosen_style_;
188 GuiSelectionManager * selectionManager;
190 QStringListModel available_model_;
192 QStandardItemModel selected_model_;
194 QStringList all_keys_;
196 QStringList cited_keys_;
198 InsetCommandParams params_;
201 } // namespace frontend
204 #endif // GUICITATION_H