]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
rename buffer parameter math_number_before to math_numbering_side
[lyx.git] / src / frontends / qt4 / GuiCitation.h
1 // -*- C++ -*-
2 /**
3  * \file GuiCitation.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Kalle Dalheimer
9  * \author Abdelrazak Younes
10  * \author Richard Heck
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUICITATION_H
16 #define GUICITATION_H
17
18 #include "DialogView.h"
19 #include "ui_CitationUi.h"
20 #include "FancyLineEdit.h"
21
22 #include "insets/InsetCommandParams.h"
23
24 #include "Citation.h"
25
26 #include <QAbstractListModel>
27 #include <QStandardItemModel>
28 #include <QStringList>
29 #include <QStringListModel>
30
31 namespace lyx {
32
33 class BiblioInfo;
34
35 namespace frontend {
36
37 class GuiSelectionManager;
38
39
40 class GuiCitation : public DialogView, public Ui::CitationUi
41 {
42         Q_OBJECT
43
44 public:
45         ///
46         GuiCitation(GuiView & lv);
47
48 private Q_SLOTS:
49         void on_okPB_clicked();
50         void on_cancelPB_clicked();
51         void on_restorePB_clicked();
52         void on_applyPB_clicked();
53         void filterPressed();
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);
58         void resetFilter();
59         void caseChanged();
60         void regexChanged();
61         void instantChanged(bool checked);
62         void changed();
63         /// set the citation keys, mark as changed
64         void setCitedKeys();
65         /// update the styles for the style combo, mark as changed
66         void updateStyles();
67         /// performs a limited update, suitable for internal call
68         void updateControls();
69
70
71 private:
72         /// Dialog inherited methods
73         //@{
74         void applyView();
75         void updateView() {}
76         bool initialiseParams(std::string const & data);
77         void clearParams();
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.
84          */
85         bool disconnectOnApply() const { return true; }
86         //@}
87
88         ///
89         void showEvent(QShowEvent * e);
90         ///
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
100         void setButtons();
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);
109         ///
110         void updateControls(BiblioInfo const & bi);
111         /// Set the appropriate hinting text on the filter bar
112         void updateFilterHint();
113         ///
114         void init();
115         /// Clear selected keys
116         void clearSelection();
117
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();
130
131         /// Find keys containing a string.
132         void findKey(
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
141                 );
142
143         /// List of example cite strings
144         QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
145
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);
149
150         ///
151         void filterByEntryType(BiblioInfo const & bi,
152                 std::vector<docstring> & keyVector, docstring entryType);
153
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
164                 ); //
165
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;
170
171         /// contains the search box
172         FancyLineEdit * filter_;
173
174         /// Regexp action
175         QAction * regexp_;
176         /// Case sensitive action
177         QAction * casesense_;
178         /// Search as you type action
179         QAction * instant_;
180
181         /// last used citation style
182         int style_;
183         ///
184         GuiSelectionManager * selectionManager;
185         /// available keys.
186         QStringListModel available_model_;
187         /// selected keys.
188         QStandardItemModel selected_model_;
189         /// All keys.
190         QStringList all_keys_;
191         /// Cited keys.
192         QStringList cited_keys_;
193         ///
194         InsetCommandParams params_;
195 };
196
197 } // namespace frontend
198 } // namespace lyx
199
200 #endif // GUICITATION_H