]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.cpp
HTML output for InsetMathCancel.
[lyx.git] / src / frontends / qt4 / GuiCitation.cpp
1
2 /**
3  * \file GuiCitation.cpp
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 #include <config.h>
16
17 #include "GuiCitation.h"
18
19 #include "GuiSelectionManager.h"
20 #include "qt_helpers.h"
21
22 #include "Buffer.h"
23 #include "BufferView.h"
24 #include "BiblioInfo.h"
25 #include "BufferParams.h"
26 #include "FuncRequest.h"
27
28 #include "insets/InsetCommand.h"
29
30 #include "support/debug.h"
31 #include "support/docstring.h"
32 #include "support/gettext.h"
33 #include "support/lstrings.h"
34
35 #include <QCloseEvent>
36 #include <QSettings>
37 #include <QShowEvent>
38 #include <QVariant>
39
40 #include <vector>
41 #include <string>
42
43 #undef KeyPress
44
45 #include "support/regex.h"
46
47 #include <algorithm>
48 #include <string>
49 #include <vector>
50
51 using namespace std;
52 using namespace lyx::support;
53
54 namespace lyx {
55 namespace frontend {
56
57 static vector<CiteStyle> citeStyles_;
58
59
60 template<typename String>
61 static QStringList to_qstring_list(vector<String> const & v)
62 {
63         QStringList qlist;
64
65         for (size_t i = 0; i != v.size(); ++i) {
66                 if (v[i].empty())
67                         continue;
68                 qlist.append(lyx::toqstr(v[i]));
69         }
70         return qlist;
71 }
72
73
74 static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
75 {
76         vector<lyx::docstring> v;
77         for (int i = 0; i != qlist.size(); ++i) {
78                 if (qlist[i].isEmpty())
79                         continue;
80                 v.push_back(lyx::qstring_to_ucs4(qlist[i]));
81         }
82         return v;
83 }
84
85
86 GuiCitation::GuiCitation(GuiView & lv)
87         : DialogView(lv, "citation", qt_("Citation")),
88           params_(insetCode("citation"))
89 {
90         setupUi(this);
91
92         connect(citationStyleCO, SIGNAL(activated(int)),
93                 this, SLOT(on_citationStyleCO_currentIndexChanged(int)));
94         connect(fulllistCB, SIGNAL(clicked()),
95                 this, SLOT(changed()));
96         connect(forceuppercaseCB, SIGNAL(clicked()),
97                 this, SLOT(changed()));
98         connect(textBeforeED, SIGNAL(textChanged(QString)),
99                 this, SLOT(changed()));
100         connect(textAfterED, SIGNAL(textChanged(QString)),
101                 this, SLOT(changed()));
102         connect(findLE, SIGNAL(returnPressed()),
103                 this, SLOT(on_searchPB_clicked()));
104         connect(textBeforeED, SIGNAL(returnPressed()),
105                 this, SLOT(on_okPB_clicked()));
106         connect(textAfterED, SIGNAL(returnPressed()),
107                 this, SLOT(on_okPB_clicked()));
108
109         selectionManager = new GuiSelectionManager(availableLV, selectedLV,
110                         addPB, deletePB, upPB, downPB, &available_model_, &selected_model_);
111         connect(selectionManager, SIGNAL(selectionChanged()),
112                 this, SLOT(setCitedKeys()));
113         connect(selectionManager, SIGNAL(updateHook()),
114                 this, SLOT(updateControls()));
115         connect(selectionManager, SIGNAL(okHook()),
116                 this, SLOT(on_okPB_clicked()));
117
118         setFocusProxy(availableLV);
119 }
120
121
122 GuiCitation::~GuiCitation()
123 {
124         delete selectionManager;
125 }
126
127
128 void GuiCitation::closeEvent(QCloseEvent * e)
129 {
130         clearSelection();
131         DialogView::closeEvent(e);
132 }
133
134
135 void GuiCitation::applyView()
136 {
137         int const choice = max(0, citationStyleCO->currentIndex());
138         style_ = choice;
139         bool const full  = fulllistCB->isChecked();
140         bool const force = forceuppercaseCB->isChecked();
141
142         QString const before = textBeforeED->text();
143         QString const after = textAfterED->text();
144
145         apply(choice, full, force, before, after);
146 }
147
148
149 void GuiCitation::showEvent(QShowEvent * e)
150 {
151         findLE->clear();
152         availableLV->setFocus();
153         DialogView::showEvent(e);
154 }
155
156
157 void GuiCitation::on_okPB_clicked()
158 {
159         applyView();
160         clearSelection();
161         hide();
162 }
163
164
165 void GuiCitation::on_cancelPB_clicked()
166 {
167         clearSelection();
168         hide();
169 }
170
171
172 void GuiCitation::on_applyPB_clicked()
173 {
174         applyView();
175 }
176
177
178 void GuiCitation::on_restorePB_clicked()
179 {
180         init();
181 }
182
183
184 void GuiCitation::updateControls()
185 {
186         BiblioInfo const & bi = bibInfo();
187         updateControls(bi);
188 }
189
190
191 // The main point of separating this out is that the fill*() methods
192 // called in update() do not need to be called for INTERNAL updates,
193 // such as when addPB is pressed, as the list of fields, entries, etc,
194 // will not have changed. At the moment, however, the division between
195 // fillStyles() and updateStyle() doesn't lend itself to dividing the
196 // two methods, though they should be divisible. That is, we should
197 // not have to call fillStyles() every time through here.
198 void GuiCitation::updateControls(BiblioInfo const & bi)
199 {
200         QModelIndex idx = selectionManager->getSelectedIndex();
201         updateInfo(bi, idx);
202         setButtons();
203
204         textBeforeED->setText(toqstr(params_["before"]));
205         textAfterED->setText(toqstr(params_["after"]));
206         fillStyles(bi);
207         updateStyle();
208 }
209
210
211 void GuiCitation::updateFormatting(CiteStyle currentStyle)
212 {
213         CiteEngine const engine = citeEngine();
214         bool const natbib_engine = engine == ENGINE_NATBIB;
215         bool const basic_engine = engine == ENGINE_BASIC;
216
217         bool const haveSelection = 
218                 selectedLV->model()->rowCount() > 0;
219
220         bool const isNocite = currentStyle == NOCITE;
221
222         bool const isCiteyear =
223                 currentStyle == CITEYEAR ||
224                 currentStyle == CITEYEARPAR;
225
226         fulllistCB->setEnabled(natbib_engine && haveSelection && !isNocite
227                 && !isCiteyear);
228         forceuppercaseCB->setEnabled(natbib_engine && haveSelection
229                 && !isNocite && !isCiteyear);
230         textBeforeED->setEnabled(!basic_engine && haveSelection && !isNocite);
231         textBeforeLA->setEnabled(!basic_engine && haveSelection && !isNocite);
232         textAfterED->setEnabled(haveSelection && !isNocite);
233         textAfterLA->setEnabled(haveSelection && !isNocite);
234         citationStyleCO->setEnabled(haveSelection);
235         citationStyleLA->setEnabled(haveSelection);
236 }
237
238
239 void GuiCitation::updateStyle()
240 {
241         string const & command = params_.getCmdName();
242
243         // Find the style of the citekeys
244         vector<CiteStyle> const & styles = citeStyles_;
245         CitationStyle const cs = citationStyleFromString(command);
246
247         vector<CiteStyle>::const_iterator cit =
248                 std::find(styles.begin(), styles.end(), cs.style);
249
250         if (cit != styles.end()) {
251                 fulllistCB->setChecked(cs.full);
252                 forceuppercaseCB->setChecked(cs.forceUpperCase);
253         } else {
254                 // restore the last used natbib style
255                 if (style_ >= 0 && style_ < citationStyleCO->count()) {
256                         // the necessary update will be performed later
257                         citationStyleCO->blockSignals(true);
258                         citationStyleCO->setCurrentIndex(style_);
259                         citationStyleCO->blockSignals(false);
260                 }
261                 fulllistCB->setChecked(false);
262                 forceuppercaseCB->setChecked(false);
263         }
264         updateFormatting(cs.style);
265 }
266
267
268 // This one needs to be called whenever citationStyleCO needs
269 // to be updated---and this would be on anything that changes the
270 // selection in selectedLV, or on a general update.
271 void GuiCitation::fillStyles(BiblioInfo const & bi)
272 {
273         QStringList selected_keys = selected_model_.stringList();
274         int curr = selectedLV->model()->rowCount() - 1;
275
276         if (curr < 0 || selected_keys.empty()) {
277                 citationStyleCO->clear();
278                 citationStyleCO->setEnabled(false);
279                 citationStyleLA->setEnabled(false);
280                 return;
281         }
282
283         if (!selectedLV->selectionModel()->selectedIndexes().empty())
284                 curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
285
286         QStringList sty = citationStyles(bi, curr);
287
288         if (sty.isEmpty()) {
289                 // some error
290                 citationStyleCO->setEnabled(false);
291                 citationStyleLA->setEnabled(false);
292                 citationStyleCO->clear();
293                 return;
294         }
295
296         citationStyleCO->blockSignals(true);
297
298         // save old index
299         int const oldIndex = citationStyleCO->currentIndex();
300         citationStyleCO->clear();
301         citationStyleCO->insertItems(0, sty);
302         citationStyleCO->setEnabled(true);
303         citationStyleLA->setEnabled(true);
304         // restore old index
305         if (oldIndex != -1 && oldIndex < citationStyleCO->count())
306                 citationStyleCO->setCurrentIndex(oldIndex);
307
308         citationStyleCO->blockSignals(false);
309 }
310
311
312 void GuiCitation::fillFields(BiblioInfo const & bi)
313 {
314         fieldsCO->blockSignals(true);
315         int const oldIndex = fieldsCO->currentIndex();
316         fieldsCO->clear();
317         QStringList const fields = to_qstring_list(bi.getFields());
318         fieldsCO->insertItem(0, qt_("All fields"));
319         fieldsCO->insertItem(1, qt_("Keys"));
320         fieldsCO->insertItems(2, fields);
321         if (oldIndex != -1 && oldIndex < fieldsCO->count())
322                 fieldsCO->setCurrentIndex(oldIndex);
323         fieldsCO->blockSignals(false);
324 }
325
326
327 void GuiCitation::fillEntries(BiblioInfo const & bi)
328 {
329         entriesCO->blockSignals(true);
330         int const oldIndex = entriesCO->currentIndex();
331         entriesCO->clear();
332         QStringList const entries = to_qstring_list(bi.getEntries());
333         entriesCO->insertItem(0, qt_("All entry types"));
334         entriesCO->insertItems(1, entries);
335         if (oldIndex != -1 && oldIndex < entriesCO->count())
336                 entriesCO->setCurrentIndex(oldIndex);
337         entriesCO->blockSignals(false);
338 }
339
340
341 bool GuiCitation::isSelected(QModelIndex const & idx)
342 {
343         QString const str = idx.data().toString();
344         return selected_model_.stringList().contains(str);
345 }
346
347
348 void GuiCitation::setButtons()
349 {
350         selectionManager->update();
351         int const srows = selectedLV->model()->rowCount();
352         applyPB->setEnabled(srows > 0);
353         okPB->setEnabled(srows > 0);
354 }
355
356
357 void GuiCitation::updateInfo(BiblioInfo const & bi, QModelIndex const & idx)
358 {
359         if (!idx.isValid() || bi.empty()) {
360                 infoML->document()->clear();
361                 return;
362         }
363
364         QString const keytxt = toqstr(
365                 bi.getInfo(qstring_to_ucs4(idx.data().toString()), documentBuffer(), true));
366         infoML->document()->setHtml(keytxt);
367 }
368
369
370 void GuiCitation::findText(QString const & text, bool reset)
371 {
372         //"All Fields" and "Keys" are the first two
373         int index = fieldsCO->currentIndex() - 2;
374         BiblioInfo const & bi = bibInfo();
375         vector<docstring> const & fields = bi.getFields();
376         docstring field;
377
378         if (index <= -1 || index >= int(fields.size()))
379                 //either "All Fields" or "Keys" or an invalid value
380                 field = from_ascii("");
381         else
382                 field = fields[index];
383
384         //Was it "Keys"?
385         bool const onlyKeys = index == -1;
386
387         //"All Entry Types" is first.
388         index = entriesCO->currentIndex() - 1;
389         vector<docstring> const & entries = bi.getEntries();
390         docstring entry_type;
391         if (index < 0 || index >= int(entries.size()))
392                 entry_type = from_ascii("");
393         else
394                 entry_type = entries[index];
395
396         bool const case_sentitive = caseCB->checkState();
397         bool const reg_exp = regexCB->checkState();
398         findKey(bi, text, onlyKeys, field, entry_type,
399                        case_sentitive, reg_exp, reset);
400         //FIXME
401         //It'd be nice to save and restore the current selection in
402         //availableLV. Currently, we get an automatic reset, since the
403         //model is reset.
404
405         updateControls(bi);
406 }
407
408
409 void GuiCitation::on_fieldsCO_currentIndexChanged(int /*index*/)
410 {
411         findText(findLE->text(), true);
412 }
413
414
415 void GuiCitation::on_entriesCO_currentIndexChanged(int /*index*/)
416 {
417         findText(findLE->text(), true);
418 }
419
420
421 void GuiCitation::on_citationStyleCO_currentIndexChanged(int index)
422 {
423         if (index >= 0 && index < citationStyleCO->count()) {
424                 vector<CiteStyle> const & styles = citeStyles_;
425                 updateFormatting(styles[index]);
426         }
427 }
428
429
430 void GuiCitation::on_findLE_textChanged(const QString & text)
431 {
432         bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked);
433         searchPB->setDisabled(text.isEmpty() || searchAsWeGo);
434         if (!text.isEmpty()) {
435                 if (searchAsWeGo)
436                         findText(findLE->text());
437                 return;
438         }
439         findText(findLE->text());
440         findLE->setFocus();
441 }
442
443 void GuiCitation::on_searchPB_clicked()
444 {
445         findText(findLE->text(), true);
446 }
447
448
449 void GuiCitation::on_caseCB_stateChanged(int)
450 {
451         findText(findLE->text());
452 }
453
454
455 void GuiCitation::on_regexCB_stateChanged(int)
456 {
457         findText(findLE->text());
458 }
459
460
461 void GuiCitation::on_asTypeCB_stateChanged(int)
462 {
463         bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked);
464         searchPB->setDisabled(findLE->text().isEmpty() || searchAsWeGo);
465         if (searchAsWeGo)
466                 findText(findLE->text(), true);
467 }
468
469
470 void GuiCitation::changed()
471 {
472         setButtons();
473 }
474
475
476 void GuiCitation::apply(int const choice, bool full, bool force,
477         QString before, QString after)
478 {
479         if (cited_keys_.isEmpty())
480                 return;
481
482         vector<CiteStyle> const & styles = citeStyles_;
483         if (styles[choice] == NOCITE) {
484                 full = false;
485                 force = false;
486                 before.clear();
487                 after.clear();
488         }
489         
490         CitationStyle s;
491         s.style = styles[choice];
492         s.full = full;
493         s.forceUpperCase = force;
494         string const command = citationStyleToString(s);
495
496         params_.setCmdName(command);
497         params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
498         params_["before"] = qstring_to_ucs4(before);
499         params_["after"] = qstring_to_ucs4(after);
500         dispatchParams();
501 }
502
503
504 void GuiCitation::clearSelection()
505 {
506         cited_keys_.clear();
507         selected_model_.setStringList(cited_keys_);
508 }
509
510
511 void GuiCitation::init()
512 {
513         // Make the list of all available bibliography keys
514         BiblioInfo const & bi = bibInfo();
515         all_keys_ = to_qstring_list(bi.getKeys());
516         available_model_.setStringList(all_keys_);
517
518         // Ditto for the keys cited in this inset
519         QString str = toqstr(params_["key"]);
520         if (str.isEmpty())
521                 cited_keys_.clear();
522         else
523                 cited_keys_ = str.split(",");
524         selected_model_.setStringList(cited_keys_);
525         if (selected_model_.rowCount()) {
526                 selectedLV->blockSignals(true);
527                 selectedLV->setFocus();
528                 QModelIndex idx = selected_model_.index(0, 0);
529                 selectedLV->selectionModel()->select(idx,
530                                 QItemSelectionModel::ClearAndSelect);
531                 selectedLV->blockSignals(false);
532
533                 // set the style combo appropriately
534                 string const & command = params_.getCmdName();
535                 vector<CiteStyle> const & styles = citeStyles_;
536                 CitationStyle const cs = citationStyleFromString(command);
537         
538                 vector<CiteStyle>::const_iterator cit =
539                         std::find(styles.begin(), styles.end(), cs.style);
540                 if (cit != styles.end()) {
541                         int const i = int(cit - styles.begin());
542                         // the necessary update will be performed later
543                         citationStyleCO->blockSignals(true);
544                         citationStyleCO->setCurrentIndex(i);
545                         citationStyleCO->blockSignals(false);
546                 }
547         } else
548                 availableLV->setFocus();
549         fillFields(bi);
550         fillEntries(bi);
551         updateControls(bi);
552 }
553
554
555 void GuiCitation::findKey(BiblioInfo const & bi,
556         QString const & str, bool only_keys,
557         docstring field, docstring entry_type,
558         bool case_sensitive, bool reg_exp, bool reset)
559 {
560         // Used for optimisation: store last searched string.
561         static QString last_searched_string;
562         // Used to disable the above optimisation.
563         static bool last_case_sensitive;
564         static bool last_reg_exp;
565         // Reset last_searched_string in case of changed option.
566         if (last_case_sensitive != case_sensitive
567                 || last_reg_exp != reg_exp) {
568                         LYXERR(Debug::GUI, "GuiCitation::findKey: optimisation disabled!");
569                 last_searched_string.clear();
570         }
571         // save option for next search.
572         last_case_sensitive = case_sensitive;
573         last_reg_exp = reg_exp;
574
575         Qt::CaseSensitivity qtcase = case_sensitive ?
576                         Qt::CaseSensitive: Qt::CaseInsensitive;
577         QStringList keys;
578         // If new string (str) contains the last searched one...
579         if (!reset &&
580                 !last_searched_string.isEmpty() &&
581                 str.size() > 1 &&
582                 str.contains(last_searched_string, qtcase))
583                 // ... then only search within already found list.
584                 keys = available_model_.stringList();
585         else
586                 // ... else search all keys.
587                 keys = all_keys_;
588         // save searched string for next search.
589         last_searched_string = str;
590
591         QStringList result;
592
593         // First, filter by entry_type, which will be faster than
594         // what follows, so we may get to do that on less.
595         vector<docstring> keyVector = to_docstring_vector(keys);
596         filterByEntryType(bi, keyVector, entry_type);
597
598         if (str.isEmpty())
599                 result = to_qstring_list(keyVector);
600         else
601                 result = to_qstring_list(searchKeys(bi, keyVector, only_keys,
602                         qstring_to_ucs4(str), field, case_sensitive, reg_exp));
603
604         available_model_.setStringList(result);
605 }
606
607
608 QStringList GuiCitation::citationStyles(BiblioInfo const & bi, int sel)
609 {
610         docstring const key = qstring_to_ucs4(cited_keys_[sel]);
611         return to_qstring_list(bi.getCiteStrings(key, documentBuffer()));
612 }
613
614
615 void GuiCitation::setCitedKeys()
616 {
617         cited_keys_ = selected_model_.stringList();
618 }
619
620
621 bool GuiCitation::initialiseParams(string const & data)
622 {
623         InsetCommand::string2params(data, params_);
624         CiteEngine const engine = citeEngine();
625         CiteEngineType const engine_type = citeEngineType();
626         citeStyles_ = citeStyles(engine, engine_type);
627         init();
628         return true;
629 }
630
631
632 void GuiCitation::clearParams()
633 {
634         params_.clear();
635 }
636
637
638 void GuiCitation::filterByEntryType(BiblioInfo const & bi,
639         vector<docstring> & keyVector, docstring entry_type)
640 {
641         if (entry_type.empty())
642                 return;
643
644         vector<docstring>::iterator it = keyVector.begin();
645         vector<docstring>::iterator end = keyVector.end();
646
647         vector<docstring> result;
648         for (; it != end; ++it) {
649                 docstring const key = *it;
650                 BiblioInfo::const_iterator cit = bi.find(key);
651                 if (cit == bi.end())
652                         continue;
653                 if (cit->second.entryType() == entry_type)
654                         result.push_back(key);
655         }
656         keyVector = result;
657 }
658
659
660 CiteEngine GuiCitation::citeEngine() const
661 {
662         return documentBuffer().params().citeEngine();
663 }
664
665
666 CiteEngineType GuiCitation::citeEngineType() const
667 {
668         return documentBuffer().params().citeEngineType();
669 }
670
671
672 // Escape special chars.
673 // All characters are literals except: '.|*?+(){}[]^$\'
674 // These characters are literals when preceded by a "\", which is done here
675 // @todo: This function should be moved to support, and then the test in tests
676 //        should be moved there as well.
677 static docstring escape_special_chars(docstring const & expr)
678 {
679         // Search for all chars '.|*?+(){}[^$]\'
680         // Note that '[' and '\' must be escaped.
681         // This is a limitation of lyx::regex, but all other chars in BREs
682         // are assumed literal.
683         static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
684
685         // $& is a perl-like expression that expands to all
686         // of the current match
687         // The '$' must be prefixed with the escape character '\' for
688         // boost to treat it as a literal.
689         // Thus, to prefix a matched expression with '\', we use:
690         // FIXME: UNICODE
691         return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\\\$&")));
692 }
693
694
695 vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
696         vector<docstring> const & keys_to_search, bool only_keys,
697         docstring const & search_expression, docstring field,
698         bool case_sensitive, bool regex)
699 {
700         vector<docstring> foundKeys;
701
702         docstring expr = trim(search_expression);
703         if (expr.empty())
704                 return foundKeys;
705
706         if (!regex)
707                 // We must escape special chars in the search_expr so that
708                 // it is treated as a simple string by lyx::regex.
709                 expr = escape_special_chars(expr);
710
711         lyx::regex reg_exp;
712         try {
713                 reg_exp.assign(to_utf8(expr), case_sensitive ?
714                         lyx::regex_constants::ECMAScript : lyx::regex_constants::icase);
715         } catch (lyx::regex_error & e) {
716                 // lyx::regex throws an exception if the regular expression is not
717                 // valid.
718                 LYXERR(Debug::GUI, e.what());
719                 return vector<docstring>();
720         }
721
722         vector<docstring>::const_iterator it = keys_to_search.begin();
723         vector<docstring>::const_iterator end = keys_to_search.end();
724         for (; it != end; ++it ) {
725                 BiblioInfo::const_iterator info = bi.find(*it);
726                 if (info == bi.end())
727                         continue;
728
729                 BibTeXInfo const & kvm = info->second;
730                 string data;
731                 if (only_keys)
732                         data = to_utf8(*it);
733                 else if (field.empty())
734                         data = to_utf8(*it) + ' ' + to_utf8(kvm.allData());
735                 else
736                         data = to_utf8(kvm[field]);
737
738                 if (data.empty())
739                         continue;
740
741                 try {
742                         if (lyx::regex_search(data, reg_exp))
743                                 foundKeys.push_back(*it);
744                 }
745                 catch (lyx::regex_error & e) {
746                         LYXERR(Debug::GUI, e.what());
747                         return vector<docstring>();
748                 }
749         }
750         return foundKeys;
751 }
752
753
754 void GuiCitation::dispatchParams()
755 {
756         std::string const lfun = InsetCommand::params2string(params_);
757         dispatch(FuncRequest(getLfun(), lfun));
758 }
759
760
761 BiblioInfo const & GuiCitation::bibInfo() const
762 {
763         Buffer const & buf = documentBuffer();
764         buf.reloadBibInfoCache();
765         return buf.masterBibInfo();
766 }
767
768
769 void GuiCitation::saveSession() const
770 {
771         Dialog::saveSession();
772         QSettings settings;
773         settings.setValue(
774                 sessionKey() + "/regex", regexCB->isChecked());
775         settings.setValue(
776                 sessionKey() + "/casesensitive", caseCB->isChecked());
777         settings.setValue(
778                 sessionKey() + "/autofind", asTypeCB->isChecked());
779 }
780
781
782 void GuiCitation::restoreSession()
783 {
784         Dialog::restoreSession();
785         QSettings settings;
786         regexCB->setChecked(
787                 settings.value(sessionKey() + "/regex").toBool());
788         caseCB->setChecked(
789                 settings.value(sessionKey() + "/casesensitive").toBool());
790         asTypeCB->setChecked(
791                 settings.value(sessionKey() + "/autofind").toBool());
792 }
793
794
795 Dialog * createGuiCitation(GuiView & lv) { return new GuiCitation(lv); }
796
797
798 } // namespace frontend
799 } // namespace lyx
800
801 #include "moc_GuiCitation.cpp"
802