]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.h
renaming of some methods that hurt the eyes + removal of:
[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 "ControlCitation.h"
22 #include "support/docstring.h"
23
24 #include <QKeyEvent>
25 #include <QStringList>
26 #include <QStringListModel>
27
28 namespace lyx {
29 namespace frontend {
30
31 class GuiCitation;
32
33 class GuiCitationDialog : public QDialog,
34         public Ui::CitationUi, public Dialog::View
35 {
36         Q_OBJECT
37
38 public:
39         GuiCitationDialog(Dialog &, GuiCitation * form );
40
41         virtual ~GuiCitationDialog();
42
43         virtual void applyView();
44
45         /// Hide the dialog from sight
46         void hideView();
47
48         /// Redraw the dialog (e.g. if the colors have been remapped).
49         void redrawView() {}
50
51         /// Create the dialog if necessary, update it and display it.
52         void showView();
53
54         /// \return true if the dialog is visible.
55         bool isVisibleView() const;
56
57 public Q_SLOTS:
58         /// Update the display of the dialog whilst it is still visible.
59         void updateView();
60
61 protected:
62         void closeEvent(QCloseEvent * e);
63         /// prepares a call to GuiCitation::searchKeys when we
64         /// are ready to search the BibTeX entries
65         void findText(QString const & text, bool reset = false);
66         /// check whether key is already selected
67         bool isSelected(const QModelIndex &);
68         /// update the display of BibTeX information
69         void updateInfo(QModelIndex const &);
70
71 protected Q_SLOTS:
72         void cleanUp();
73         void on_okPB_clicked();
74         void on_cancelPB_clicked();
75         void on_restorePB_clicked();
76         void on_applyPB_clicked();
77         void on_findLE_textChanged(const QString & text);
78         void on_fieldsCO_currentIndexChanged(int index);
79         void on_entriesCO_currentIndexChanged(int index);
80         void on_caseCB_stateChanged(int);
81         void on_regexCB_stateChanged(int);
82         virtual void changed();
83         ///
84         void setCitedKeys();
85         /// performs a limited update, suitable for internal call
86         void updateDialog();
87         
88 private:
89         /// enable/disable buttons
90         void setButtons();
91         /// fill the styles combo
92         void fillStyles();
93         /// fill the fields combo
94         void fillFields();
95         /// fill the entries combo
96         void fillEntries();
97         /// set the styles combo
98         void updateStyle();
99         /// last used citation style
100         int style_;
101         
102         GuiCitation * form_;
103
104         GuiSelectionManager * selectionManager;
105 };
106
107
108 class GuiCitation : public ControlCitation
109 {
110 public:
111         ///
112         GuiCitation(GuiDialog &);
113         virtual ~GuiCitation() {}
114         virtual bool initialiseParams(std::string const & data);
115
116         ///
117         void init();
118
119         /// Available keys
120         QStringListModel * available() { return &available_model_; }
121
122         /// Selected keys
123         QStringListModel * selected() { return &selected_model_; }
124
125         /// Text before cite
126         QString textBefore();
127
128         /// Text after cite
129         QString textAfter();
130
131         /// Get key description
132         QString getKeyInfo(QString const &);
133
134         /// Clear selected keys
135         void clearSelection();
136         
137         /// Return a list of available fields 
138         QStringList getFieldsAsQStringList();
139         
140         /// Return a list of available fields 
141         QStringList getEntriesAsQStringList();
142         
143         /// Find keys containing a string.
144         void findKey(
145                 QString const & str, //< string expression
146                 bool only_keys, //< set to true if only keys shall be searched.
147                 docstring field, //<field to search, empty for all fields
148                 docstring entryType, //<entry type to display, empty for all
149                 bool case_sensitive, //< set to true for case sensitive search.
150                 bool reg_exp, //< set to true if \c str is a regular expression.
151                 bool reset = false //< whether to reset and search all keys
152                 );
153
154         /// List of example cite strings
155         QStringList citationStyles(int);
156
157         /// Set the Params variable for the Controller.
158         virtual void apply(int const choice, bool const full, bool const force,
159                                           QString before, QString after);
160         
161         void setCitedKeys();
162
163 private:
164         /// available keys.
165         QStringListModel available_model_;
166         /// selected keys.
167         QStringListModel selected_model_;
168         /// All keys.
169         QStringList all_keys_;
170         /// Cited keys.
171         QStringList cited_keys_;
172 };
173
174
175 } // namespace frontend
176 } // namespace lyx
177
178 #endif // GUICITATION_H