]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
getting rid of superfluous lyx::support:: statements.
[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 "GuiDialog.h"
19 #include "GuiSelectionManager.h"
20 #include "ui_CitationUi.h"
21 #include "support/docstring.h"
22 #include "BiblioInfo.h"
23
24 #include <QKeyEvent>
25 #include <QStringList>
26 #include <QStringListModel>
27
28 namespace lyx {
29 namespace frontend {
30
31 class GuiCitation : public GuiCommand, public Ui::CitationUi
32 {
33         Q_OBJECT
34
35 public:
36         ///
37         GuiCitation(GuiView & lv);
38
39         ///
40         void applyView();
41
42 public Q_SLOTS:
43         /// Update the display of the dialog whilst it is still visible.
44         void updateView();
45
46 private:
47         ///
48         void showEvent(QShowEvent * e);
49         ///
50         void closeEvent(QCloseEvent * e);
51         /// prepares a call to GuiCitation::searchKeys when we
52         /// are ready to search the BibTeX entries
53         void findText(QString const & text, bool reset = false);
54         /// check whether key is already selected
55         bool isSelected(const QModelIndex &);
56         /// update the display of BibTeX information
57         void updateInfo(QModelIndex const &);
58
59 private Q_SLOTS:
60         void cleanUp();
61         void on_okPB_clicked();
62         void on_cancelPB_clicked();
63         void on_restorePB_clicked();
64         void on_applyPB_clicked();
65         void on_findLE_textChanged(const QString & text);
66         void on_fieldsCO_currentIndexChanged(int index);
67         void on_entriesCO_currentIndexChanged(int index);
68         void on_caseCB_stateChanged(int);
69         void on_regexCB_stateChanged(int);
70         void changed();
71         ///
72         void setCitedKeys();
73         /// performs a limited update, suitable for internal call
74         void updateDialog();
75         
76 private:
77         /// enable/disable buttons
78         void setButtons();
79         /// fill the styles combo
80         void fillStyles();
81         /// fill the fields combo
82         void fillFields();
83         /// fill the entries combo
84         void fillEntries();
85         /// set the styles combo
86         void updateStyle();
87         /// last used citation style
88         int style_;
89         
90         GuiSelectionManager * selectionManager;
91
92         ///
93         void init();
94         /// Available keys
95         QStringListModel * available() { return &available_model_; }
96         /// Selected keys
97         QStringListModel * selected() { return &selected_model_; }
98         /// Text before cite
99         QString textBefore();
100         /// Text after cite
101         QString textAfter();
102         /// Get key description
103         QString getKeyInfo(QString const &);
104         /// Clear selected keys
105         void clearSelection();
106         /// Return a list of available fields 
107         QStringList getFieldsAsQStringList();
108         /// Return a list of available fields 
109         QStringList getEntriesAsQStringList();
110         
111         /// Find keys containing a string.
112         void findKey(
113                 QString const & str, //< string expression
114                 bool only_keys, //< set to true if only keys shall be searched.
115                 docstring field, //<field to search, empty for all fields
116                 docstring entryType, //<entry type to display, empty for all
117                 bool case_sensitive, //< set to true for case sensitive search.
118                 bool reg_exp, //< set to true if \c str is a regular expression.
119                 bool reset = false //< whether to reset and search all keys
120                 );
121
122         /// List of example cite strings
123         QStringList citationStyles(int);
124
125         /// Set the Params variable for the Controller.
126         void apply(int const choice, bool const full, bool const force,
127                                           QString before, QString after);
128
129 private:
130         /// available keys.
131         QStringListModel available_model_;
132         /// selected keys.
133         QStringListModel selected_model_;
134         /// All keys.
135         QStringList all_keys_;
136         /// Cited keys.
137         QStringList cited_keys_;
138
139         ///
140         bool initialiseParams(std::string const & data);
141
142         /// clean-up on hide.
143         void clearParams();
144
145         /** Disconnect from the inset when the Apply button is pressed.
146          *  Allows easy insertion of multiple citations.
147          */
148         bool disconnectOnApply() const { return true; }
149
150         /// \return the list of all available bibliography keys.
151         std::vector<docstring> const availableKeys() const;
152         /// \return the list of all used BibTeX fields
153         std::vector<docstring> const availableFields() const;
154         /// \return the list of all used BibTeX entry types
155         std::vector<docstring> const availableEntries() const;
156         ///
157         void filterByEntryType(
158                 std::vector<docstring> & keyVector, docstring entryType);
159         ///
160         biblio::CiteEngine getEngine() const;
161
162         /// \return information for this key.
163         docstring getInfo(docstring const & key) const;
164
165         /// Search a given string within the passed keys.
166         /// \return the vector of matched keys.
167         std::vector<docstring> searchKeys(
168                 std::vector<docstring> const & keys_to_search, //< Keys to search.
169                 bool only_keys, //< whether to search only the keys
170                 docstring const & search_expression, //< Search expression (regex possible)
171                 docstring field, //< field to search, empty for all fields
172                 bool case_sensitive = false, //< set to true is the search should be case sensitive
173                 bool regex = false //< \set to true if \c search_expression is a regex
174                 ); //
175
176 private:
177         /// The BibTeX information available to the dialog
178         BiblioInfo bibkeysInfo_;
179 };
180
181 } // namespace frontend
182 } // namespace lyx
183
184 #endif // GUICITATION_H