]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
Speed up exit time
[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 <QStringList>
27 #include <QStringListModel>
28
29 namespace lyx {
30
31 class BiblioInfo;
32
33 namespace frontend {
34
35 class GuiSelectionManager;
36
37 class GuiCitation : public DialogView, public Ui::CitationUi
38 {
39         Q_OBJECT
40
41 public:
42         ///
43         GuiCitation(GuiView & lv);
44         ///
45         ~GuiCitation();
46
47 private Q_SLOTS:
48         void on_okPB_clicked();
49         void on_cancelPB_clicked();
50         void on_restorePB_clicked();
51         void on_applyPB_clicked();
52         void filterPressed();
53         void filterChanged(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 resetFilter();
58         void caseChanged();
59         void regexChanged();
60         void instantChanged(bool checked);
61         void changed();
62         /// set the citation keys, mark as changed
63         void setCitedKeys();
64         /// update the styles for the style combo, mark as changed
65         void updateStyles();
66         /// performs a limited update, suitable for internal call
67         void updateControls();
68
69
70 private:
71         /// Dialog inherited methods
72         //@{
73         void applyView();
74         void updateView() {}
75         bool initialiseParams(std::string const & data);
76         void clearParams();
77         void dispatchParams();
78         bool isBufferDependent() const { return true; }
79         void saveSession(QSettings & settings) const;
80         void restoreSession();
81         /** Disconnect from the inset when the Apply button is pressed.
82          *  Allows easy insertion of multiple citations.
83          */
84         bool disconnectOnApply() const { return true; }
85         //@}
86
87         ///
88         void showEvent(QShowEvent * e);
89         ///
90         void closeEvent(QCloseEvent * e);
91         /// prepares a call to GuiCitation::searchKeys when we
92         /// are ready to search the BibTeX entries
93         void findText(QString const & text, bool reset = false);
94         /// check whether key is already selected
95         bool isSelected(const QModelIndex &);
96         /// update the display of BibTeX information
97         void updateInfo(BiblioInfo const & bi, QModelIndex const &);
98         /// enable/disable buttons
99         void setButtons();
100         /// fill the fields combo
101         void fillFields(BiblioInfo const & bi);
102         /// fill the entries combo
103         void fillEntries(BiblioInfo const & bi);
104         /// set the styles combo
105         void updateStyles(BiblioInfo const & bi);
106         /// set the formatting widgets
107         void updateFormatting(CitationStyle currentStyle);
108         ///
109         void updateControls(BiblioInfo const & bi);
110         /// Set the appropriate hinting text on the filter bar
111         void updateFilterHint();
112         ///
113         void init();
114         /// Clear selected keys
115         void clearSelection();
116
117         /// Find keys containing a string.
118         void findKey(
119                 BiblioInfo const & bi, //< optimize by passing this
120                 QString const & str, //< string expression
121                 bool only_keys, //< set to true if only keys shall be searched.
122                 docstring field, //<field to search, empty for all fields
123                 docstring entryType, //<entry type to display, empty for all
124                 bool case_sensitive, //< set to true for case sensitive search.
125                 bool reg_exp, //< set to true if \c str is a regular expression.
126                 bool reset = false //< whether to reset and search all keys
127                 );
128
129         /// List of example cite strings
130         QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
131
132         /// Set the Params variable for the Controller.
133         void applyParams(int const choice, bool const full, bool const force,
134                                           QString before, QString after);
135
136         ///
137         void filterByEntryType(BiblioInfo const & bi,
138                 std::vector<docstring> & keyVector, docstring entryType);
139
140         /// Search a given string within the passed keys.
141         /// \return the vector of matched keys.
142         std::vector<docstring> searchKeys(
143                 BiblioInfo const & bi, //< optimize by passing this
144                 std::vector<docstring> const & keys_to_search, //< Keys to search.
145                 bool only_keys, //< whether to search only the keys
146                 docstring const & search_expression, //< Search expression (regex possible)
147                 docstring field, //< field to search, empty for all fields
148                 bool case_sensitive = false, //< set to true is the search should be case sensitive
149                 bool regex = false //< \set to true if \c search_expression is a regex
150                 ); //
151
152         /// The BibTeX information available to the dialog
153         /// Calls to this method will lead to checks of modification times and
154         /// the like, so it should be avoided.
155         BiblioInfo const & bibInfo() const;
156
157         /// contains the search box
158         FancyLineEdit * filter_;
159
160         /// Regexp action
161         QAction * regexp_;
162         /// Case sensitive action
163         QAction * casesense_;
164         /// Search as you type action
165         QAction * instant_;
166
167         /// last used citation style
168         int style_;
169         ///
170         GuiSelectionManager * selectionManager;
171         /// available keys.
172         QStringListModel available_model_;
173         /// selected keys.
174         QStringListModel selected_model_;
175         /// All keys.
176         QStringList all_keys_;
177         /// Cited keys.
178         QStringList cited_keys_;
179         ///
180         InsetCommandParams params_;
181 };
182
183 } // namespace frontend
184 } // namespace lyx
185
186 #endif // GUICITATION_H