]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCitation.cpp
The View->Source pane resets the format every time you click into
[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 =
215                 engine == ENGINE_NATBIB_AUTHORYEAR ||
216                 engine == ENGINE_NATBIB_NUMERICAL;
217         bool const basic_engine = engine == ENGINE_BASIC;
218
219         bool const haveSelection = 
220                 selectedLV->model()->rowCount() > 0;
221
222         bool const isNocite = currentStyle == NOCITE;
223
224         bool const isCiteyear =
225                 currentStyle == CITEYEAR ||
226                 currentStyle == CITEYEARPAR;
227
228         fulllistCB->setEnabled(natbib_engine && haveSelection && !isNocite
229                 && !isCiteyear);
230         forceuppercaseCB->setEnabled(natbib_engine && haveSelection
231                 && !isNocite && !isCiteyear);
232         textBeforeED->setEnabled(!basic_engine && haveSelection && !isNocite);
233         textBeforeLA->setEnabled(!basic_engine && haveSelection && !isNocite);
234         textAfterED->setEnabled(haveSelection && !isNocite);
235         textAfterLA->setEnabled(haveSelection && !isNocite);
236         citationStyleCO->setEnabled(haveSelection);
237         citationStyleLA->setEnabled(haveSelection);
238 }
239
240
241 void GuiCitation::updateStyle()
242 {
243         string const & command = params_.getCmdName();
244
245         // Find the style of the citekeys
246         vector<CiteStyle> const & styles = citeStyles_;
247         CitationStyle const cs = citationStyleFromString(command);
248
249         vector<CiteStyle>::const_iterator cit =
250                 std::find(styles.begin(), styles.end(), cs.style);
251
252         if (cit != styles.end()) {
253                 fulllistCB->setChecked(cs.full);
254                 forceuppercaseCB->setChecked(cs.forceUpperCase);
255         } else {
256                 // restore the last used natbib style
257                 if (style_ >= 0 && style_ < citationStyleCO->count()) {
258                         // the necessary update will be performed later
259                         citationStyleCO->blockSignals(true);
260                         citationStyleCO->setCurrentIndex(style_);
261                         citationStyleCO->blockSignals(false);
262                 }
263                 fulllistCB->setChecked(false);
264                 forceuppercaseCB->setChecked(false);
265         }
266         updateFormatting(cs.style);
267 }
268
269
270 // This one needs to be called whenever citationStyleCO needs
271 // to be updated---and this would be on anything that changes the
272 // selection in selectedLV, or on a general update.
273 void GuiCitation::fillStyles(BiblioInfo const & bi)
274 {
275         QStringList selected_keys = selected_model_.stringList();
276         int curr = selectedLV->model()->rowCount() - 1;
277
278         if (curr < 0 || selected_keys.empty()) {
279                 citationStyleCO->clear();
280                 citationStyleCO->setEnabled(false);
281                 citationStyleLA->setEnabled(false);
282                 return;
283         }
284
285         if (!selectedLV->selectionModel()->selectedIndexes().empty())
286                 curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
287
288         QStringList sty = citationStyles(bi, curr);
289
290         if (sty.isEmpty()) {
291                 // some error
292                 citationStyleCO->setEnabled(false);
293                 citationStyleLA->setEnabled(false);
294                 citationStyleCO->clear();
295                 return;
296         }
297
298         citationStyleCO->blockSignals(true);
299
300         // save old index
301         int const oldIndex = citationStyleCO->currentIndex();
302         citationStyleCO->clear();
303         citationStyleCO->insertItems(0, sty);
304         citationStyleCO->setEnabled(true);
305         citationStyleLA->setEnabled(true);
306         // restore old index
307         if (oldIndex != -1 && oldIndex < citationStyleCO->count())
308                 citationStyleCO->setCurrentIndex(oldIndex);
309
310         citationStyleCO->blockSignals(false);
311 }
312
313
314 void GuiCitation::fillFields(BiblioInfo const & bi)
315 {
316         fieldsCO->blockSignals(true);
317         int const oldIndex = fieldsCO->currentIndex();
318         fieldsCO->clear();
319         QStringList const fields = to_qstring_list(bi.getFields());
320         fieldsCO->insertItem(0, qt_("All fields"));
321         fieldsCO->insertItem(1, qt_("Keys"));
322         fieldsCO->insertItems(2, fields);
323         if (oldIndex != -1 && oldIndex < fieldsCO->count())
324                 fieldsCO->setCurrentIndex(oldIndex);
325         fieldsCO->blockSignals(false);
326 }
327
328
329 void GuiCitation::fillEntries(BiblioInfo const & bi)
330 {
331         entriesCO->blockSignals(true);
332         int const oldIndex = entriesCO->currentIndex();
333         entriesCO->clear();
334         QStringList const entries = to_qstring_list(bi.getEntries());
335         entriesCO->insertItem(0, qt_("All entry types"));
336         entriesCO->insertItems(1, entries);
337         if (oldIndex != -1 && oldIndex < entriesCO->count())
338                 entriesCO->setCurrentIndex(oldIndex);
339         entriesCO->blockSignals(false);
340 }
341
342
343 bool GuiCitation::isSelected(QModelIndex const & idx)
344 {
345         QString const str = idx.data().toString();
346         return selected_model_.stringList().contains(str);
347 }
348
349
350 void GuiCitation::setButtons()
351 {
352         selectionManager->update();
353         int const srows = selectedLV->model()->rowCount();
354         applyPB->setEnabled(srows > 0);
355         okPB->setEnabled(srows > 0);
356 }
357
358
359 void GuiCitation::updateInfo(BiblioInfo const & bi, QModelIndex const & idx)
360 {
361         if (!idx.isValid() || bi.empty()) {
362                 infoML->document()->clear();
363                 return;
364         }
365
366         QString const keytxt = toqstr(
367                 bi.getInfo(qstring_to_ucs4(idx.data().toString()), documentBuffer(), true));
368         infoML->document()->setHtml(keytxt);
369 }
370
371
372 void GuiCitation::findText(QString const & text, bool reset)
373 {
374         //"All Fields" and "Keys" are the first two
375         int index = fieldsCO->currentIndex() - 2;
376         BiblioInfo const & bi = bibInfo();
377         vector<docstring> const & fields = bi.getFields();
378         docstring field;
379
380         if (index <= -1 || index >= int(fields.size()))
381                 //either "All Fields" or "Keys" or an invalid value
382                 field = from_ascii("");
383         else
384                 field = fields[index];
385
386         //Was it "Keys"?
387         bool const onlyKeys = index == -1;
388
389         //"All Entry Types" is first.
390         index = entriesCO->currentIndex() - 1;
391         vector<docstring> const & entries = bi.getEntries();
392         docstring entry_type;
393         if (index < 0 || index >= int(entries.size()))
394                 entry_type = from_ascii("");
395         else
396                 entry_type = entries[index];
397
398         bool const case_sentitive = caseCB->checkState();
399         bool const reg_exp = regexCB->checkState();
400         findKey(bi, text, onlyKeys, field, entry_type,
401                        case_sentitive, reg_exp, reset);
402         //FIXME
403         //It'd be nice to save and restore the current selection in
404         //availableLV. Currently, we get an automatic reset, since the
405         //model is reset.
406
407         updateControls(bi);
408 }
409
410
411 void GuiCitation::on_fieldsCO_currentIndexChanged(int /*index*/)
412 {
413         findText(findLE->text(), true);
414 }
415
416
417 void GuiCitation::on_entriesCO_currentIndexChanged(int /*index*/)
418 {
419         findText(findLE->text(), true);
420 }
421
422
423 void GuiCitation::on_citationStyleCO_currentIndexChanged(int index)
424 {
425         if (index >= 0 && index < citationStyleCO->count()) {
426                 vector<CiteStyle> const & styles = citeStyles_;
427                 updateFormatting(styles[index]);
428         }
429 }
430
431
432 void GuiCitation::on_findLE_textChanged(const QString & text)
433 {
434         bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked);
435         searchPB->setDisabled(text.isEmpty() || searchAsWeGo);
436         if (!text.isEmpty()) {
437                 if (searchAsWeGo)
438                         findText(findLE->text());
439                 return;
440         }
441         findText(findLE->text());
442         findLE->setFocus();
443 }
444
445 void GuiCitation::on_searchPB_clicked()
446 {
447         findText(findLE->text(), true);
448 }
449
450
451 void GuiCitation::on_caseCB_stateChanged(int)
452 {
453         findText(findLE->text());
454 }
455
456
457 void GuiCitation::on_regexCB_stateChanged(int)
458 {
459         findText(findLE->text());
460 }
461
462
463 void GuiCitation::on_asTypeCB_stateChanged(int)
464 {
465         bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked);
466         searchPB->setDisabled(findLE->text().isEmpty() || searchAsWeGo);
467         if (searchAsWeGo)
468                 findText(findLE->text(), true);
469 }
470
471
472 void GuiCitation::changed()
473 {
474         setButtons();
475 }
476
477
478 void GuiCitation::apply(int const choice, bool full, bool force,
479         QString before, QString after)
480 {
481         if (cited_keys_.isEmpty())
482                 return;
483
484         vector<CiteStyle> const & styles = citeStyles_;
485         if (styles[choice] == NOCITE) {
486                 full = false;
487                 force = false;
488                 before.clear();
489                 after.clear();
490         }
491         
492         CitationStyle s;
493         s.style = styles[choice];
494         s.full = full;
495         s.forceUpperCase = force;
496         string const command = citationStyleToString(s);
497
498         params_.setCmdName(command);
499         params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
500         params_["before"] = qstring_to_ucs4(before);
501         params_["after"] = qstring_to_ucs4(after);
502         dispatchParams();
503 }
504
505
506 void GuiCitation::clearSelection()
507 {
508         cited_keys_.clear();
509         selected_model_.setStringList(cited_keys_);
510 }
511
512
513 void GuiCitation::init()
514 {
515         // Make the list of all available bibliography keys
516         BiblioInfo const & bi = bibInfo();
517         all_keys_ = to_qstring_list(bi.getKeys());
518         available_model_.setStringList(all_keys_);
519
520         // Ditto for the keys cited in this inset
521         QString str = toqstr(params_["key"]);
522         if (str.isEmpty())
523                 cited_keys_.clear();
524         else
525                 cited_keys_ = str.split(",");
526         selected_model_.setStringList(cited_keys_);
527         if (selected_model_.rowCount()) {
528                 selectedLV->blockSignals(true);
529                 selectedLV->setFocus();
530                 QModelIndex idx = selected_model_.index(0, 0);
531                 selectedLV->selectionModel()->select(idx,
532                                 QItemSelectionModel::ClearAndSelect);
533                 selectedLV->blockSignals(false);
534
535                 // set the style combo appropriately
536                 string const & command = params_.getCmdName();
537                 vector<CiteStyle> const & styles = citeStyles_;
538                 CitationStyle const cs = citationStyleFromString(command);
539         
540                 vector<CiteStyle>::const_iterator cit =
541                         std::find(styles.begin(), styles.end(), cs.style);
542                 if (cit != styles.end()) {
543                         int const i = int(cit - styles.begin());
544                         // the necessary update will be performed later
545                         citationStyleCO->blockSignals(true);
546                         citationStyleCO->setCurrentIndex(i);
547                         citationStyleCO->blockSignals(false);
548                 }
549         } else
550                 availableLV->setFocus();
551         fillFields(bi);
552         fillEntries(bi);
553         updateControls(bi);
554 }
555
556
557 void GuiCitation::findKey(BiblioInfo const & bi,
558         QString const & str, bool only_keys,
559         docstring field, docstring entry_type,
560         bool case_sensitive, bool reg_exp, bool reset)
561 {
562         // Used for optimisation: store last searched string.
563         static QString last_searched_string;
564         // Used to disable the above optimisation.
565         static bool last_case_sensitive;
566         static bool last_reg_exp;
567         // Reset last_searched_string in case of changed option.
568         if (last_case_sensitive != case_sensitive
569                 || last_reg_exp != reg_exp) {
570                         LYXERR(Debug::GUI, "GuiCitation::findKey: optimisation disabled!");
571                 last_searched_string.clear();
572         }
573         // save option for next search.
574         last_case_sensitive = case_sensitive;
575         last_reg_exp = reg_exp;
576
577         Qt::CaseSensitivity qtcase = case_sensitive ?
578                         Qt::CaseSensitive: Qt::CaseInsensitive;
579         QStringList keys;
580         // If new string (str) contains the last searched one...
581         if (!reset &&
582                 !last_searched_string.isEmpty() &&
583                 str.size() > 1 &&
584                 str.contains(last_searched_string, qtcase))
585                 // ... then only search within already found list.
586                 keys = available_model_.stringList();
587         else
588                 // ... else search all keys.
589                 keys = all_keys_;
590         // save searched string for next search.
591         last_searched_string = str;
592
593         QStringList result;
594
595         // First, filter by entry_type, which will be faster than
596         // what follows, so we may get to do that on less.
597         vector<docstring> keyVector = to_docstring_vector(keys);
598         filterByEntryType(bi, keyVector, entry_type);
599
600         if (str.isEmpty())
601                 result = to_qstring_list(keyVector);
602         else
603                 result = to_qstring_list(searchKeys(bi, keyVector, only_keys,
604                         qstring_to_ucs4(str), field, case_sensitive, reg_exp));
605
606         available_model_.setStringList(result);
607 }
608
609
610 QStringList GuiCitation::citationStyles(BiblioInfo const & bi, int sel)
611 {
612         docstring const key = qstring_to_ucs4(cited_keys_[sel]);
613         return to_qstring_list(bi.getCiteStrings(key, documentBuffer()));
614 }
615
616
617 void GuiCitation::setCitedKeys()
618 {
619         cited_keys_ = selected_model_.stringList();
620 }
621
622
623 bool GuiCitation::initialiseParams(string const & data)
624 {
625         InsetCommand::string2params(data, params_);
626         CiteEngine const engine = citeEngine();
627         citeStyles_ = citeStyles(engine);
628         init();
629         return true;
630 }
631
632
633 void GuiCitation::clearParams()
634 {
635         params_.clear();
636 }
637
638
639 void GuiCitation::filterByEntryType(BiblioInfo const & bi,
640         vector<docstring> & keyVector, docstring entry_type)
641 {
642         if (entry_type.empty())
643                 return;
644
645         vector<docstring>::iterator it = keyVector.begin();
646         vector<docstring>::iterator end = keyVector.end();
647
648         vector<docstring> result;
649         for (; it != end; ++it) {
650                 docstring const key = *it;
651                 BiblioInfo::const_iterator cit = bi.find(key);
652                 if (cit == bi.end())
653                         continue;
654                 if (cit->second.entryType() == entry_type)
655                         result.push_back(key);
656         }
657         keyVector = result;
658 }
659
660
661 CiteEngine GuiCitation::citeEngine() const
662 {
663         return documentBuffer().params().citeEngine();
664 }
665
666
667 // Escape special chars.
668 // All characters are literals except: '.|*?+(){}[]^$\'
669 // These characters are literals when preceded by a "\", which is done here
670 // @todo: This function should be moved to support, and then the test in tests
671 //        should be moved there as well.
672 static docstring escape_special_chars(docstring const & expr)
673 {
674         // Search for all chars '.|*?+(){}[^$]\'
675         // Note that '[' and '\' must be escaped.
676         // This is a limitation of lyx::regex, but all other chars in BREs
677         // are assumed literal.
678         static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
679
680         // $& is a perl-like expression that expands to all
681         // of the current match
682         // The '$' must be prefixed with the escape character '\' for
683         // boost to treat it as a literal.
684         // Thus, to prefix a matched expression with '\', we use:
685         // FIXME: UNICODE
686         return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\\\$&")));
687 }
688
689
690 vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
691         vector<docstring> const & keys_to_search, bool only_keys,
692         docstring const & search_expression, docstring field,
693         bool case_sensitive, bool regex)
694 {
695         vector<docstring> foundKeys;
696
697         docstring expr = trim(search_expression);
698         if (expr.empty())
699                 return foundKeys;
700
701         if (!regex)
702                 // We must escape special chars in the search_expr so that
703                 // it is treated as a simple string by lyx::regex.
704                 expr = escape_special_chars(expr);
705
706         lyx::regex reg_exp;
707         try {
708                 reg_exp.assign(to_utf8(expr), case_sensitive ?
709                         lyx::regex_constants::ECMAScript : lyx::regex_constants::icase);
710         } catch (lyx::regex_error & e) {
711                 // lyx::regex throws an exception if the regular expression is not
712                 // valid.
713                 LYXERR(Debug::GUI, e.what());
714                 return vector<docstring>();
715         }
716
717         vector<docstring>::const_iterator it = keys_to_search.begin();
718         vector<docstring>::const_iterator end = keys_to_search.end();
719         for (; it != end; ++it ) {
720                 BiblioInfo::const_iterator info = bi.find(*it);
721                 if (info == bi.end())
722                         continue;
723
724                 BibTeXInfo const & kvm = info->second;
725                 string data;
726                 if (only_keys)
727                         data = to_utf8(*it);
728                 else if (field.empty())
729                         data = to_utf8(*it) + ' ' + to_utf8(kvm.allData());
730                 else
731                         data = to_utf8(kvm[field]);
732
733                 if (data.empty())
734                         continue;
735
736                 try {
737                         if (lyx::regex_search(data, reg_exp))
738                                 foundKeys.push_back(*it);
739                 }
740                 catch (lyx::regex_error & e) {
741                         LYXERR(Debug::GUI, e.what());
742                         return vector<docstring>();
743                 }
744         }
745         return foundKeys;
746 }
747
748
749 void GuiCitation::dispatchParams()
750 {
751         std::string const lfun = InsetCommand::params2string(params_);
752         dispatch(FuncRequest(getLfun(), lfun));
753 }
754
755
756 BiblioInfo const & GuiCitation::bibInfo() const
757 {
758         Buffer const & buf = documentBuffer();
759         buf.reloadBibInfoCache();
760         return buf.masterBibInfo();
761 }
762
763
764 void GuiCitation::saveSession() const
765 {
766         Dialog::saveSession();
767         QSettings settings;
768         settings.setValue(
769                 sessionKey() + "/regex", regexCB->isChecked());
770         settings.setValue(
771                 sessionKey() + "/casesensitive", caseCB->isChecked());
772         settings.setValue(
773                 sessionKey() + "/autofind", asTypeCB->isChecked());
774 }
775
776
777 void GuiCitation::restoreSession()
778 {
779         Dialog::restoreSession();
780         QSettings settings;
781         regexCB->setChecked(
782                 settings.value(sessionKey() + "/regex").toBool());
783         caseCB->setChecked(
784                 settings.value(sessionKey() + "/casesensitive").toBool());
785         asTypeCB->setChecked(
786                 settings.value(sessionKey() + "/autofind").toBool());
787 }
788
789
790 Dialog * createGuiCitation(GuiView & lv) { return new GuiCitation(lv); }
791
792
793 } // namespace frontend
794 } // namespace lyx
795
796 #include "moc_GuiCitation.cpp"
797