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