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_okPB_clicked();
51 void on_cancelPB_clicked();
52 void on_restorePB_clicked();
53 void on_applyPB_clicked();
54 void on_literalCB_clicked();
56 void filterChanged(const QString & text);
57 void on_fieldsCO_currentIndexChanged(int index);
58 void on_entriesCO_currentIndexChanged(int index);
59 void on_citationStyleCO_currentIndexChanged(int index);
63 void instantChanged(bool checked);
65 /// set the citation keys, mark as changed
67 /// update the styles for the style combo, mark as changed
69 /// performs a limited update, suitable for internal call
70 void updateControls();
74 /// Dialog inherited methods
78 bool initialiseParams(std::string const & data);
80 void dispatchParams();
81 bool isBufferDependent() const { return true; }
82 void saveSession(QSettings & settings) const;
83 void restoreSession();
84 /** Disconnect from the inset when the Apply button is pressed.
85 * Allows easy insertion of multiple citations.
87 bool disconnectOnApply() const { return true; }
91 void showEvent(QShowEvent * e);
93 void closeEvent(QCloseEvent * e);
94 /// prepares a call to GuiCitation::searchKeys when we
95 /// are ready to search the BibTeX entries
96 void findText(QString const & text, bool reset = false);
97 /// check whether key is already selected
98 bool isSelected(const QModelIndex &);
99 /// update the display of BibTeX information
100 void updateInfo(BiblioInfo const & bi, QModelIndex const &);
101 /// enable/disable buttons
103 /// fill the fields combo
104 void fillFields(BiblioInfo const & bi);
105 /// fill the entries combo
106 void fillEntries(BiblioInfo const & bi);
107 /// set the styles combo
108 void updateStyles(BiblioInfo const & bi);
109 /// set the formatting widgets
110 void updateFormatting(CitationStyle const & currentStyle);
112 void updateControls(BiblioInfo const & bi);
113 /// Set the appropriate hinting text on the filter bar
114 void updateFilterHint();
117 /// Clear selected keys
118 void clearSelection();
120 /// Set selected keys
121 void setSelectedKeys(QStringList const);
122 /// Get selected keys
123 QStringList selectedKeys();
124 /// Set pre texts of qualified lists
125 void setPreTexts(std::vector<docstring> const m);
126 /// Get pre texts of qualified lists
127 std::vector<docstring> getPreTexts();
128 /// Set post texts of qualified lists
129 void setPostTexts(std::vector<docstring> const m);
130 /// Get post texts of qualified lists
131 std::vector<docstring> getPostTexts();
133 /// Find keys containing a string.
135 BiblioInfo const & bi, //< optimize by passing this
136 QString const & str, //< string expression
137 bool only_keys, //< set to true if only keys shall be searched.
138 docstring field, //<field to search, empty for all fields
139 docstring entryType, //<entry type to display, empty for all
140 bool case_sensitive, //< set to true for case sensitive search.
141 bool reg_exp, //< set to true if \c str is a regular expression.
142 bool reset = false //< whether to reset and search all keys
145 /// List of example cite strings and their correlating lyx name
146 BiblioInfo::CiteStringMap citationStyles(BiblioInfo const & bi,
149 /// Set the Params variable for the Controller.
150 void applyParams(int const choice, bool const full, bool const force,
151 QString before, QString after);
154 void filterByEntryType(BiblioInfo const & bi,
155 std::vector<docstring> & keyVector, docstring entryType);
157 /// Search a given string within the passed keys.
158 /// \return the vector of matched keys.
159 std::vector<docstring> searchKeys(
160 BiblioInfo const & bi, //< optimize by passing this
161 std::vector<docstring> const & keys_to_search, //< Keys to search.
162 bool only_keys, //< whether to search only the keys
163 docstring const & search_expression, //< Search expression (regex possible)
164 docstring field, //< field to search, empty for all fields
165 bool case_sensitive = false, //< set to true is the search should be case sensitive
166 bool regex = false //< \set to true if \c search_expression is a regex
169 /// The BibTeX information available to the dialog
170 /// Calls to this method will lead to checks of modification times and
171 /// the like, so it should be avoided.
172 BiblioInfo const & bibInfo() const;
174 /// contains the search box
175 FancyLineEdit * filter_;
179 /// Case sensitive action
180 QAction * casesense_;
181 /// Search as you type action
184 /// last used citation style
187 GuiSelectionManager * selectionManager;
189 QStringListModel available_model_;
191 QStandardItemModel selected_model_;
193 QStringList all_keys_;
195 QStringList cited_keys_;
197 InsetCommandParams params_;
200 } // namespace frontend
203 #endif // GUICITATION_H