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