]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
4d85c0315ae242de88656a046503284b9112318b
[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 "BiblioInfo.h"
25 #include "Citation.h"
26
27 #include <QAbstractListModel>
28 #include <QStandardItemModel>
29 #include <QStringList>
30 #include <QStringListModel>
31
32 namespace lyx {
33
34 class BiblioInfo;
35
36 namespace frontend {
37
38 class GuiSelectionManager;
39
40
41 class GuiCitation : public DialogView, public Ui::CitationUi
42 {
43         Q_OBJECT
44
45 public:
46         ///
47         GuiCitation(GuiView & lv);
48
49 private Q_SLOTS:
50         void on_okPB_clicked();
51         void on_cancelPB_clicked();
52         void on_restorePB_clicked();
53         void on_applyPB_clicked();
54         void on_literalCB_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(QSettings & settings) 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 const & 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 and their correlating lyx name
146         BiblioInfo::CiteStringMap citationStyles(BiblioInfo const & bi,
147                                                                 size_t max_size);
148
149         /// Set the Params variable for the Controller.
150         void applyParams(int const choice, bool const full, bool const force,
151                                           QString before, QString after);
152
153         ///
154         void filterByEntryType(BiblioInfo const & bi,
155                 std::vector<docstring> & keyVector, docstring entryType);
156
157         /// Search a given string within the passed keys.
158         /// \return the vector of matched keys.
159         std::vector<docstring> searchKeys(
160                 BiblioInfo const & bi, //< optimize by passing this
161                 std::vector<docstring> const & keys_to_search, //< Keys to search.
162                 bool only_keys, //< whether to search only the keys
163                 docstring const & search_expression, //< Search expression (regex possible)
164                 docstring field, //< field to search, empty for all fields
165                 bool case_sensitive = false, //< set to true is the search should be case sensitive
166                 bool regex = false //< \set to true if \c search_expression is a regex
167                 ); //
168
169         /// The BibTeX information available to the dialog
170         /// Calls to this method will lead to checks of modification times and
171         /// the like, so it should be avoided.
172         BiblioInfo const & bibInfo() const;
173
174         /// contains the search box
175         FancyLineEdit * filter_;
176
177         /// Regexp action
178         QAction * regexp_;
179         /// Case sensitive action
180         QAction * casesense_;
181         /// Search as you type action
182         QAction * instant_;
183
184         /// last used citation style
185         QString style_;
186         ///
187         GuiSelectionManager * selectionManager;
188         /// available keys.
189         QStringListModel available_model_;
190         /// selected keys.
191         QStandardItemModel selected_model_;
192         /// All keys.
193         QStringList all_keys_;
194         /// Cited keys.
195         QStringList cited_keys_;
196         ///
197         InsetCommandParams params_;
198 };
199
200 } // namespace frontend
201 } // namespace lyx
202
203 #endif // GUICITATION_H