]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
Mention style-dependency of of features in the tooltips, part 2
[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         ~GuiCitation();
49
50 private Q_SLOTS:
51         void on_okPB_clicked();
52         void on_cancelPB_clicked();
53         void on_restorePB_clicked();
54         void on_applyPB_clicked();
55         void filterPressed();
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);
60         void resetFilter();
61         void caseChanged();
62         void regexChanged();
63         void instantChanged(bool checked);
64         void changed();
65         /// set the citation keys, mark as changed
66         void setCitedKeys();
67         /// update the styles for the style combo, mark as changed
68         void updateStyles();
69         /// performs a limited update, suitable for internal call
70         void updateControls();
71
72
73 private:
74         /// Dialog inherited methods
75         //@{
76         void applyView();
77         void updateView() {}
78         bool initialiseParams(std::string const & data);
79         void clearParams();
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.
86          */
87         bool disconnectOnApply() const { return true; }
88         //@}
89
90         ///
91         void showEvent(QShowEvent * e);
92         ///
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
102         void setButtons();
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);
111         ///
112         void updateControls(BiblioInfo const & bi);
113         /// Set the appropriate hinting text on the filter bar
114         void updateFilterHint();
115         ///
116         void init();
117         /// Clear selected keys
118         void clearSelection();
119
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();
132
133         /// Find keys containing a string.
134         void findKey(
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
143                 );
144
145         /// List of example cite strings
146         QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
147
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);
151
152         ///
153         void filterByEntryType(BiblioInfo const & bi,
154                 std::vector<docstring> & keyVector, docstring entryType);
155
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
166                 ); //
167
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;
172
173         /// contains the search box
174         FancyLineEdit * filter_;
175
176         /// Regexp action
177         QAction * regexp_;
178         /// Case sensitive action
179         QAction * casesense_;
180         /// Search as you type action
181         QAction * instant_;
182
183         /// last used citation style
184         int style_;
185         ///
186         GuiSelectionManager * selectionManager;
187         /// available keys.
188         QStringListModel available_model_;
189         /// selected keys.
190         QStandardItemModel selected_model_;
191         /// All keys.
192         QStringList all_keys_;
193         /// Cited keys.
194         QStringList cited_keys_;
195         ///
196         InsetCommandParams params_;
197 };
198
199 } // namespace frontend
200 } // namespace lyx
201
202 #endif // GUICITATION_H