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);
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);
63 /// performs a limited update, suitable for internal call
64 void updateControls();
68 /// Dialog inherited methods
72 bool initialiseParams(std::string const & data);
74 void dispatchParams();
75 bool isBufferDependent() const { return true; }
76 /** Disconnect from the inset when the Apply button is pressed.
77 * Allows easy insertion of multiple citations.
79 bool disconnectOnApply() const { return true; }
83 void showEvent(QShowEvent * e);
85 void closeEvent(QCloseEvent * e);
86 /// prepares a call to GuiCitation::searchKeys when we
87 /// are ready to search the BibTeX entries
88 void findText(QString const & text, bool reset = false);
89 /// check whether key is already selected
90 bool isSelected(const QModelIndex &);
91 /// update the display of BibTeX information
92 void updateInfo(QModelIndex const &);
93 /// enable/disable buttons
95 /// fill the styles combo
97 /// fill the fields combo
99 /// fill the entries combo
101 /// set the styles combo
103 /// set the formatting widgets
104 void updateFormatting(CiteStyle currentStyle);
107 /// Clear selected keys
108 void clearSelection();
110 /// Find keys containing a string.
112 QString const & str, //< string expression
113 bool only_keys, //< set to true if only keys shall be searched.
114 docstring field, //<field to search, empty for all fields
115 docstring entryType, //<entry type to display, empty for all
116 bool case_sensitive, //< set to true for case sensitive search.
117 bool reg_exp, //< set to true if \c str is a regular expression.
118 bool reset = false //< whether to reset and search all keys
121 /// List of example cite strings
122 QStringList citationStyles(int);
124 /// Set the Params variable for the Controller.
125 void apply(int const choice, bool const full, bool const force,
126 QString before, QString after);
129 void filterByEntryType(
130 std::vector<docstring> & keyVector, docstring entryType);
132 CiteEngine citeEngine() const;
134 /// Search a given string within the passed keys.
135 /// \return the vector of matched keys.
136 std::vector<docstring> searchKeys(
137 std::vector<docstring> const & keys_to_search, //< Keys to search.
138 bool only_keys, //< whether to search only the keys
139 docstring const & search_expression, //< Search expression (regex possible)
140 docstring field, //< field to search, empty for all fields
141 bool case_sensitive = false, //< set to true is the search should be case sensitive
142 bool regex = false //< \set to true if \c search_expression is a regex
145 /// The BibTeX information available to the dialog
146 BiblioInfo const & bibInfo() const;
148 /// last used citation style
151 GuiSelectionManager * selectionManager;
153 QStringListModel available_model_;
155 QStringListModel selected_model_;
157 QStringList all_keys_;
159 QStringList cited_keys_;
161 InsetCommandParams params_;
164 } // namespace frontend
167 #endif // GUICITATION_H