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 <QAbstractListModel>
27 #include <QStandardItemModel>
28 #include <QStringList>
29 #include <QStringListModel>
37 class GuiSelectionManager;
40 class GuiCitation : public DialogView, public Ui::CitationUi
46 GuiCitation(GuiView & lv);
51 void on_okPB_clicked();
52 void on_cancelPB_clicked();
53 void on_restorePB_clicked();
54 void on_applyPB_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() 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 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
146 QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
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
186 GuiSelectionManager * selectionManager;
188 QStringListModel available_model_;
190 QStandardItemModel selected_model_;
192 QStringList all_keys_;
194 QStringList cited_keys_;
196 InsetCommandParams params_;
199 } // namespace frontend
202 #endif // GUICITATION_H