]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
Compil fix.
[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         void saveSession() const;
77         void restoreSession();
78         /** Disconnect from the inset when the Apply button is pressed.
79          *  Allows easy insertion of multiple citations.
80          */
81         bool disconnectOnApply() const { return true; }
82         //@}
83
84         ///
85         void showEvent(QShowEvent * e);
86         ///
87         void closeEvent(QCloseEvent * e);
88         /// prepares a call to GuiCitation::searchKeys when we
89         /// are ready to search the BibTeX entries
90         void findText(QString const & text, bool reset = false);
91         /// check whether key is already selected
92         bool isSelected(const QModelIndex &);
93         /// update the display of BibTeX information
94         void updateInfo(QModelIndex const &);
95         /// enable/disable buttons
96         void setButtons();
97         /// fill the styles combo
98         void fillStyles();
99         /// fill the fields combo
100         void fillFields();
101         /// fill the entries combo
102         void fillEntries();
103         /// set the styles combo
104         void updateStyle();
105         /// set the formatting widgets
106         void updateFormatting(CiteStyle currentStyle);
107         ///
108         void init();
109         /// Clear selected keys
110         void clearSelection();
111         
112         /// Find keys containing a string.
113         void findKey(
114                 QString const & str, //< string expression
115                 bool only_keys, //< set to true if only keys shall be searched.
116                 docstring field, //<field to search, empty for all fields
117                 docstring entryType, //<entry type to display, empty for all
118                 bool case_sensitive, //< set to true for case sensitive search.
119                 bool reg_exp, //< set to true if \c str is a regular expression.
120                 bool reset = false //< whether to reset and search all keys
121                 );
122
123         /// List of example cite strings
124         QStringList citationStyles(int);
125
126         /// Set the Params variable for the Controller.
127         void apply(int const choice, bool const full, bool const force,
128                                           QString before, QString after);
129
130         ///
131         void filterByEntryType(
132                 std::vector<docstring> & keyVector, docstring entryType);
133         ///
134         CiteEngine citeEngine() const;
135
136         /// Search a given string within the passed keys.
137         /// \return the vector of matched keys.
138         std::vector<docstring> searchKeys(
139                 std::vector<docstring> const & keys_to_search, //< Keys to search.
140                 bool only_keys, //< whether to search only the keys
141                 docstring const & search_expression, //< Search expression (regex possible)
142                 docstring field, //< field to search, empty for all fields
143                 bool case_sensitive = false, //< set to true is the search should be case sensitive
144                 bool regex = false //< \set to true if \c search_expression is a regex
145                 ); //
146
147         /// The BibTeX information available to the dialog
148         BiblioInfo const & bibInfo() const;
149
150         /// last used citation style
151         int style_;
152         ///
153         GuiSelectionManager * selectionManager;
154         /// available keys.
155         QStringListModel available_model_;
156         /// selected keys.
157         QStringListModel selected_model_;
158         /// All keys.
159         QStringList all_keys_;
160         /// Cited keys.
161         QStringList cited_keys_;
162         ///
163         InsetCommandParams params_;
164 };
165
166 } // namespace frontend
167 } // namespace lyx
168
169 #endif // GUICITATION_H