]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
3dd2143e9e4d50982f24361b51daeb283c4eca2d
[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
21 #include "insets/InsetCommandParams.h"
22
23 #include "Citation.h"
24
25 #include <QStringList>
26 #include <QStringListModel>
27
28 namespace lyx {
29
30 class BiblioInfo;
31
32 namespace frontend {
33
34 class GuiSelectionManager;
35
36 class GuiCitation : public DialogView, public Ui::CitationUi
37 {
38         Q_OBJECT
39
40 public:
41         ///
42         GuiCitation(GuiView & lv);
43         ///
44         ~GuiCitation();
45
46 private Q_SLOTS:
47         void cleanUp();
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);
60         void changed();
61         ///
62         void setCitedKeys();
63         /// performs a limited update, suitable for internal call
64         void updateControls();
65         
66
67 private:
68         /// Dialog inherited methods
69         //@{
70         void applyView();
71         void updateView() {}
72         bool initialiseParams(std::string const & data);
73         void clearParams();
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.
78          */
79         bool disconnectOnApply() const { return true; }
80         //@}
81
82         ///
83         void showEvent(QShowEvent * e);
84         ///
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
94         void setButtons();
95         /// fill the styles combo
96         void fillStyles();
97         /// fill the fields combo
98         void fillFields();
99         /// fill the entries combo
100         void fillEntries();
101         /// set the styles combo
102         void updateStyle();
103         /// set the formatting widgets
104         void updateFormatting(CiteStyle currentStyle);
105         ///
106         void init();
107         /// Clear selected keys
108         void clearSelection();
109         
110         /// Find keys containing a string.
111         void findKey(
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
119                 );
120
121         /// List of example cite strings
122         QStringList citationStyles(int);
123
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);
127
128         ///
129         void filterByEntryType(
130                 std::vector<docstring> & keyVector, docstring entryType);
131         ///
132         CiteEngine citeEngine() const;
133
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
143                 ); //
144
145         /// The BibTeX information available to the dialog
146         BiblioInfo const & bibInfo() const;
147
148         /// last used citation style
149         int style_;
150         ///
151         GuiSelectionManager * selectionManager;
152         /// available keys.
153         QStringListModel available_model_;
154         /// selected keys.
155         QStringListModel selected_model_;
156         /// All keys.
157         QStringList all_keys_;
158         /// Cited keys.
159         QStringList cited_keys_;
160         ///
161         InsetCommandParams params_;
162 };
163
164 } // namespace frontend
165 } // namespace lyx
166
167 #endif // GUICITATION_H