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"
21 #include "insets/InsetCommandParams.h"
25 #include <QStringList>
26 #include <QStringListModel>
34 class GuiSelectionManager;
36 class GuiCitation : public DialogView, public Ui::CitationUi
42 GuiCitation(GuiView & lv);
47 void on_citationTB_currentChanged(int i);
48 void on_okPB_clicked();
49 void on_cancelPB_clicked();
50 void on_restorePB_clicked();
51 void on_applyPB_clicked();
52 void on_searchPB_clicked();
53 void on_findLE_textChanged(const QString & text);
54 void on_fieldsCO_currentIndexChanged(int index);
55 void on_entriesCO_currentIndexChanged(int index);
56 void on_citationStyleCO_currentIndexChanged(int index);
57 void on_caseCB_stateChanged(int);
58 void on_regexCB_stateChanged(int);
59 void on_asTypeCB_stateChanged(int);
61 /// set the citation keys, mark as changed
63 /// update the styles for the style combo, mark as changed
65 /// performs a limited update, suitable for internal call
66 void updateControls();
70 /// Dialog inherited methods
74 bool initialiseParams(std::string const & data);
76 void dispatchParams();
77 bool isBufferDependent() const { return true; }
78 void saveSession() const;
79 void restoreSession();
80 /** Disconnect from the inset when the Apply button is pressed.
81 * Allows easy insertion of multiple citations.
83 bool disconnectOnApply() const { return true; }
87 void showEvent(QShowEvent * e);
89 void closeEvent(QCloseEvent * e);
90 /// prepares a call to GuiCitation::searchKeys when we
91 /// are ready to search the BibTeX entries
92 void findText(QString const & text, bool reset = false);
93 /// check whether key is already selected
94 bool isSelected(const QModelIndex &);
95 /// update the display of BibTeX information
96 void updateInfo(BiblioInfo const & bi, QModelIndex const &);
97 /// enable/disable buttons
99 /// fill the fields combo
100 void fillFields(BiblioInfo const & bi);
101 /// fill the entries combo
102 void fillEntries(BiblioInfo const & bi);
103 /// set the styles combo
104 void updateStyles(BiblioInfo const & bi);
105 /// set the formatting widgets
106 void updateFormatting(CitationStyle currentStyle);
108 void updateControls(BiblioInfo const & bi);
111 /// Clear selected keys
112 void clearSelection();
114 /// Find keys containing a string.
116 BiblioInfo const & bi, //< optimize by passing this
117 QString const & str, //< string expression
118 bool only_keys, //< set to true if only keys shall be searched.
119 docstring field, //<field to search, empty for all fields
120 docstring entryType, //<entry type to display, empty for all
121 bool case_sensitive, //< set to true for case sensitive search.
122 bool reg_exp, //< set to true if \c str is a regular expression.
123 bool reset = false //< whether to reset and search all keys
126 /// List of example cite strings
127 QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
129 /// Set the Params variable for the Controller.
130 void applyParams(int const choice, bool const full, bool const force,
131 QString before, QString after);
134 void filterByEntryType(BiblioInfo const & bi,
135 std::vector<docstring> & keyVector, docstring entryType);
137 /// Search a given string within the passed keys.
138 /// \return the vector of matched keys.
139 std::vector<docstring> searchKeys(
140 BiblioInfo const & bi, //< optimize by passing this
141 std::vector<docstring> const & keys_to_search, //< Keys to search.
142 bool only_keys, //< whether to search only the keys
143 docstring const & search_expression, //< Search expression (regex possible)
144 docstring field, //< field to search, empty for all fields
145 bool case_sensitive = false, //< set to true is the search should be case sensitive
146 bool regex = false //< \set to true if \c search_expression is a regex
149 /// The BibTeX information available to the dialog
150 /// Calls to this method will lead to checks of modification times and
151 /// the like, so it should be avoided.
152 BiblioInfo const & bibInfo() const;
154 /// last used citation style
157 GuiSelectionManager * selectionManager;
159 QStringListModel available_model_;
161 QStringListModel selected_model_;
163 QStringList all_keys_;
165 QStringList cited_keys_;
167 InsetCommandParams params_;
170 } // namespace frontend
173 #endif // GUICITATION_H