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