]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
On Linux show in crash message box the backtrace
[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 on_okPB_clicked();
48         void on_cancelPB_clicked();
49         void on_restorePB_clicked();
50         void on_applyPB_clicked();
51         void on_searchPB_clicked();
52         void on_findLE_textChanged(const QString & text);
53         void on_fieldsCO_currentIndexChanged(int index);
54         void on_entriesCO_currentIndexChanged(int index);
55         void on_citationStyleCO_currentIndexChanged(int index);
56         void on_caseCB_stateChanged(int);
57         void on_regexCB_stateChanged(int);
58         void on_asTypeCB_stateChanged(int);
59         void changed();
60         /// set the citation keys, mark as changed
61         void setCitedKeys();
62         /// update the styles for the style combo, mark as changed
63         void updateStyles();
64         /// performs a limited update, suitable for internal call
65         void updateControls();
66
67
68 private:
69         /// Dialog inherited methods
70         //@{
71         void applyView();
72         void updateView() {}
73         bool initialiseParams(std::string const & data);
74         void clearParams();
75         void dispatchParams();
76         bool isBufferDependent() const { return true; }
77         void saveSession() const;
78         void restoreSession();
79         /** Disconnect from the inset when the Apply button is pressed.
80          *  Allows easy insertion of multiple citations.
81          */
82         bool disconnectOnApply() const { return true; }
83         //@}
84
85         ///
86         void showEvent(QShowEvent * e);
87         ///
88         void closeEvent(QCloseEvent * e);
89         /// prepares a call to GuiCitation::searchKeys when we
90         /// are ready to search the BibTeX entries
91         void findText(QString const & text, bool reset = false);
92         /// check whether key is already selected
93         bool isSelected(const QModelIndex &);
94         /// update the display of BibTeX information
95         void updateInfo(BiblioInfo const & bi, QModelIndex const &);
96         /// enable/disable buttons
97         void setButtons();
98         /// fill the fields combo
99         void fillFields(BiblioInfo const & bi);
100         /// fill the entries combo
101         void fillEntries(BiblioInfo const & bi);
102         /// set the styles combo
103         void updateStyles(BiblioInfo const & bi);
104         /// set the formatting widgets
105         void updateFormatting(CitationStyle currentStyle);
106         ///
107         void updateControls(BiblioInfo const & bi);
108         ///
109         void init();
110         /// Clear selected keys
111         void clearSelection();
112
113         /// Find keys containing a string.
114         void findKey(
115                 BiblioInfo const & bi, //< optimize by passing this
116                 QString const & str, //< string expression
117                 bool only_keys, //< set to true if only keys shall be searched.
118                 docstring field, //<field to search, empty for all fields
119                 docstring entryType, //<entry type to display, empty for all
120                 bool case_sensitive, //< set to true for case sensitive search.
121                 bool reg_exp, //< set to true if \c str is a regular expression.
122                 bool reset = false //< whether to reset and search all keys
123                 );
124
125         /// List of example cite strings
126         QStringList citationStyles(BiblioInfo const & bi, size_t max_size);
127
128         /// Set the Params variable for the Controller.
129         void apply(int const choice, bool const full, bool const force,
130                                           QString before, QString after);
131
132         ///
133         void filterByEntryType(BiblioInfo const & bi,
134                 std::vector<docstring> & keyVector, docstring entryType);
135
136         /// Search a given string within the passed keys.
137         /// \return the vector of matched keys.
138         std::vector<docstring> searchKeys(
139                 BiblioInfo const & bi, //< optimize by passing this
140                 std::vector<docstring> const & keys_to_search, //< Keys to search.
141                 bool only_keys, //< whether to search only the keys
142                 docstring const & search_expression, //< Search expression (regex possible)
143                 docstring field, //< field to search, empty for all fields
144                 bool case_sensitive = false, //< set to true is the search should be case sensitive
145                 bool regex = false //< \set to true if \c search_expression is a regex
146                 ); //
147
148         /// The BibTeX information available to the dialog
149         /// Calls to this method will lead to checks of modification times and
150         /// the like, so it should be avoided.
151         BiblioInfo const & bibInfo() const;
152
153         /// last used citation style
154         int style_;
155         ///
156         GuiSelectionManager * selectionManager;
157         /// available keys.
158         QStringListModel available_model_;
159         /// selected keys.
160         QStringListModel selected_model_;
161         /// All keys.
162         QStringList all_keys_;
163         /// Cited keys.
164         QStringList cited_keys_;
165         ///
166         InsetCommandParams params_;
167 };
168
169 } // namespace frontend
170 } // namespace lyx
171
172 #endif // GUICITATION_H