]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QListings.cpp
delete unneeded Menubar virtual interface.
[lyx.git] / src / frontends / qt4 / QListings.cpp
1 /**
2  * \file QListings.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Bo Peng
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QListings.h"
15 #include "Qt2BC.h"
16 #include "qt_helpers.h"
17 #include "controllers/ControlListings.h"
18 #include "insets/InsetListingsParams.h"
19 #include "debug.h"
20
21 #include "support/convert.h"
22 #include "support/lstrings.h"
23
24 #include <QLineEdit>
25 #include <QCloseEvent>
26 #include <QPushButton>
27 #include <QValidator>
28 #include <QRegExpValidator>
29
30
31 using std::string;
32 using std::vector;
33 using lyx::support::findToken;
34 using lyx::support::getVectorFromString;
35 using lyx::support::getStringFromVector;
36 using lyx::support::prefixIs;
37 using lyx::support::suffixIs;
38 using lyx::support::contains;
39
40 namespace lyx {
41 namespace frontend {
42
43 /////////////////////////////////////////////////////////////////////
44 //
45 // QListingsDialog
46 //
47 /////////////////////////////////////////////////////////////////////
48
49
50 char const * languages[] =
51 { "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
52   "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
53   "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
54   "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
55   "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
56   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
57   "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
58   "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
59   "VRML", "XML", "XSLT", "" };
60
61
62 char const * languages_gui[] =
63 { N_("No language"), "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic",
64   "C", "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
65   "Eiffel", "Elan", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
66   "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
67   "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
68   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
69   "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
70   "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
71   "VRML", "XML", "XSLT", "" };
72
73
74 struct dialect_info {
75         /// the dialect
76         char const * dialect;
77         /// the associated language
78         char const * language;
79         /// representation of the dialect in the gui
80         char const * gui;
81         /// is this the default dialect?
82         bool is_default;
83 };
84
85
86 dialect_info const dialects[] = {
87         { "R/2 4.3", "ABAP", "R/2 4.3", false },
88         { "R/2 5.0", "ABAP", "R/2 5.0", false },
89         { "R/3 3.1", "ABAP", "R/3 3.1", false },
90         { "R/3 4.6C", "ABAP", "R/3 4.6C", false },
91         { "R/3 6.10", "ABAP", "R/3 6.10", true },
92         { "2005", "Ada", "2005", true },
93         { "83", "Ada", "83", false },
94         { "95", "Ada", "95", false },
95         { "60", "Algol", "60", false },
96         { "68", "Algol", "68", true },
97         { "Motorola68k", "Assembler", "Motorola 68xxx", false },
98         { "x86masm", "Assembler", "x86 (MASM)", false },
99         { "gnu", "Awk", "gnu", true },
100         { "POSIX", "Awk", "POSIX", false },
101         { "Visual", "Basic", "Visual", false },
102         { "ANSI", "C", "ANSI", true },
103         { "Handel", "C", "Handel", false },
104         { "Objective", "C", "Objective", false },
105         { "Sharp", "C", "Sharp", false },
106         { "ANSI", "C++", "ANSI", false },
107         { "GNU", "C++", "GNU", false },
108         { "ISO", "C++", "ISO", true },
109         { "Visual", "C++", "Visual", false },
110         { "light", "Caml", "light", true },
111         { "Objective", "Caml", "Objective", false },
112         { "1974", "Cobol", "1974", false },
113         { "1985", "Cobol", "1985", true },
114         { "ibm", "Cobol", "IBM", false },
115         { "WinXP", "command.com", "Windows XP", true },
116         { "77", "Fortran", "77", false },
117         { "90", "Fortran", "90", false },
118         { "95", "Fortran", "95", true },
119         { "CORBA", "IDL", "CORBA", false },
120         { "AspectJ", "Java", "Aspect J", false },
121         { "Auto", "Lisp", "Auto", false },
122         { "gnu", "make", "gnu", false },
123         { "1.0", "Mathematica", "1.0", false },
124         { "3.0", "Mathematica", "3.0", false },
125         { "5.2", "Mathematica", "5.2", true },
126         { "decorative", "OCL", "decorative", false },
127         { "OMG", "OCL", "OMG", true },
128         { "Borland6", "Pascal", "Borland 6", false },
129         { "Standard", "Pascal", "Standard", true },
130         { "XSC", "Pascal", "XSC", false },
131         { "PLUS", "S", "PLUS", false },
132         { "67", "Simula", "67", true },
133         { "CII", "Simula", "CII", false },
134         { "DEC", "Simula", "DEC", false },
135         { "IBM", "Simula", "IBM", false },
136         { "tk", "tcl", "tk", false },
137         { "AlLaTeX", "TeX", "AlLaTeX", false },
138         { "common", "TeX", "common", false },
139         { "LaTeX", "TeX", "LaTeX", false },
140         { "plain", "TeX", "plain", true },
141         { "primitive", "TeX", "primitive", false },
142         { "AMS", "VHDL", "AMS", false },
143         { "97", "VRML", "97", true }
144 };
145
146
147 size_t const nr_dialects = sizeof(dialects) / sizeof(dialect_info);
148
149
150 char const * font_sizes[] =
151 { "default", "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
152   "Large", "" };
153
154 char const * font_sizes_gui[] =
155 { N_("Default"), N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"),
156   N_("Large"), N_("Larger"), "" };
157
158 char const * font_styles[] =
159 { "default", "rmfamily", "ttfamily", "sffamily", "" };
160
161 char const * font_styles_gui[] =
162 { N_("Default"), N_("Roman"), N_("Typewriter"), N_("Sans Serif"), "" };
163
164
165
166 QListingsDialog::QListingsDialog(QListings * form)
167         : form_(form)
168 {
169         setupUi(this);
170
171         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
172         connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply()));
173         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
174
175         connect(languageCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
176         connect(dialectCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
177         connect(inlineCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
178         connect(floatCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
179         connect(placementLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
180         connect(numberSideCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
181         connect(numberStepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
182         connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
183         connect(firstlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
184         connect(lastlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
185         connect(fontsizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
186         connect(fontstyleCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
187         connect(breaklinesCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
188         connect(spaceCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
189         connect(spaceInStringCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
190         connect(extendedcharsCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
191
192         connect(listingsED,  SIGNAL(textChanged()), this, SLOT(change_adaptor()));
193         connect(listingsED,  SIGNAL(textChanged()), this, SLOT(set_listings_msg()));
194         connect(bypassCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
195         connect(bypassCB, SIGNAL(clicked()), this, SLOT(set_listings_msg()));
196
197         for (int n = 0; languages[n][0]; ++n)
198                 languageCO->addItem(qt_(languages_gui[n]));
199
200         for (int n = 0; font_styles[n][0]; ++n)
201                 fontstyleCO->addItem(qt_(font_styles_gui[n]));
202
203         for (int n = 0; font_sizes[n][0]; ++n) {
204                 QString font = qt_(font_sizes_gui[n]);
205                 fontsizeCO->addItem(font);
206                 numberFontSizeCO->addItem(font);
207         }
208
209         // set validators
210         numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
211         firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
212         lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
213         placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
214 }
215
216
217 void QListingsDialog::closeEvent(QCloseEvent * e)
218 {
219         form_->slotWMHide();
220         e->accept();
221 }
222
223
224 void QListingsDialog::change_adaptor()
225 {
226         form_->changed();
227 }
228
229
230 string QListingsDialog::construct_params()
231 {
232         string language = languages[languageCO->currentIndex()];
233         string dialect;
234         string const dialect_gui = fromqstr(dialectCO->currentText());
235         if (dialectCO->currentIndex() > 0) {
236                 for (size_t i = 0; i < nr_dialects; ++i) {
237                         if (dialect_gui == dialects[i].gui
238                         && dialects[i].language == language
239                         && !dialects[i].is_default) {
240                                 dialect = dialects[i].dialect;
241                                 break;
242                         }
243                 }
244         }
245
246         bool float_ = floatCB->isChecked();
247         string placement;
248         if (placementLE->isEnabled())
249                 placement = fromqstr(placementLE->text());
250
251         string numberSide;
252         switch (numberSideCO->currentIndex()) {
253         case 0:
254                 numberSide = "none";
255                 break;
256         case 1:
257                 numberSide = "left";
258                 break;
259         case 2:
260                 numberSide = "right";
261                 break;
262         default:
263                 numberSide = "none";
264                 break;
265         }
266         string stepnumber = fromqstr(numberStepLE->text());
267         string numberfontsize = font_sizes[numberFontSizeCO->currentIndex()];
268         string firstline = fromqstr(firstlineLE->text());
269         string lastline = fromqstr(lastlineLE->text());
270
271         string fontsize = font_sizes[fontsizeCO->currentIndex()];
272         string fontstyle = font_styles[fontstyleCO->currentIndex()];
273         string basicstyle;
274         if (fontsize != "default")
275                 basicstyle = "\\" + fontsize;
276         if (fontstyle != "default")
277                 basicstyle += "\\" + fontstyle;
278         bool breakline = breaklinesCB->isChecked();
279         bool space = spaceCB->isChecked();
280         bool spaceInString = spaceInStringCB->isChecked();
281         bool extendedchars = extendedcharsCB->isChecked();
282         string extra = fromqstr(listingsED->toPlainText());
283
284         // compose a string
285         InsetListingsParams par;
286         if (language != "no language" && !contains(extra, "language=")) {
287                 if (dialect.empty())
288                         par.addParam("language", language);
289                 else
290                         par.addParam("language", "{[" + dialect + "]" + language + "}");
291         }
292         // this dialog uses float=placement instead of float,floatplacement=placement
293         // because float accepts *tbph and floatplacement accepts bph.
294         // our placement textedit is actually for the float parameter
295         if (float_)
296                 par.addParam("float", placement);
297         if (numberSide != "none")
298                 par.addParam("numbers", numberSide);
299         if (numberfontsize != "default" && numberSide != "none")
300                 par.addParam("numberstyle", "\\" + numberfontsize);
301         if (!stepnumber.empty() && numberSide != "none")
302                 par.addParam("stepnumber", stepnumber);
303         if (!firstline.empty())
304                 par.addParam("firstline", firstline);
305         if (!lastline.empty())
306                 par.addParam("lastline", lastline);
307         if (!basicstyle.empty())
308                 par.addParam("basicstyle", basicstyle);
309         if (breakline)
310                 par.addParam("breaklines", "true");
311         if (space)
312                 par.addParam("showspaces", "true");
313         if (!spaceInString)
314                 par.addParam("showstringspaces", "false");
315         if (extendedchars)
316                 par.addParam("extendedchars", "true");
317         par.addParams(extra);
318         return par.params();
319 }
320
321
322 docstring QListingsDialog::validate_listings_params()
323 {
324         // use a cache here to avoid repeated validation
325         // of the same parameters
326         static string param_cache = string();
327         static docstring msg_cache = docstring();
328         
329         if (bypassCB->isChecked())
330                 return docstring();
331
332         string params = construct_params();
333         if (params != param_cache) {
334                 param_cache = params;
335                 msg_cache = InsetListingsParams(params).validate();
336         }
337         return msg_cache;
338 }
339
340
341 void QListingsDialog::set_listings_msg()
342 {
343         static bool isOK = true;
344         docstring msg = validate_listings_params();
345         if (msg.empty()) {
346                 if (isOK)
347                         return;
348                 isOK = true;
349                 listingsTB->setPlainText(
350                         qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
351         } else {
352                 isOK = false;
353                 listingsTB->setPlainText(toqstr(msg));
354         }
355 }
356
357
358 void QListingsDialog::on_floatCB_stateChanged(int state)
359 {
360         if (state == Qt::Checked) {
361                 inlineCB->setChecked(false);
362                 placementLE->setEnabled(true);
363         } else
364                 placementLE->setEnabled(false);
365 }
366
367
368 void QListingsDialog::on_inlineCB_stateChanged(int state)
369 {
370         if (state == Qt::Checked) {
371                 floatCB->setChecked(false);
372                 placementLE->setEnabled(false);
373         }
374 }
375
376
377 void QListingsDialog::on_numberSideCO_currentIndexChanged(int index)
378 {
379         numberStepLE->setEnabled(index > 0);
380         numberFontSizeCO->setEnabled(index > 0);
381 }
382
383
384 void QListingsDialog::on_languageCO_currentIndexChanged(int index)
385 {
386         dialectCO->clear();
387         // 0 is "no dialect"
388         int default_dialect = 0;
389         dialectCO->addItem(qt_("No dialect"));
390         string const language = languages[index];
391
392         for (size_t i = 0; i < nr_dialects; ++i) {
393                 if (language == dialects[i].language) {
394                         dialectCO->addItem(qt_(dialects[i].gui));
395                         if (dialects[i].is_default)
396                                 default_dialect =
397                                         dialectCO->findText(qt_(dialects[i].gui));
398                 }
399         }
400         dialectCO->setCurrentIndex(default_dialect);
401         dialectCO->setEnabled(dialectCO->count() > 1);
402 }
403
404
405 /////////////////////////////////////////////////////////////////////
406 //
407 // QListings
408 //
409 /////////////////////////////////////////////////////////////////////
410
411 typedef QController<ControlListings, QView<QListingsDialog> > listings_wrap_base_class;
412
413 QListings::QListings(Dialog & parent)
414         : listings_wrap_base_class(parent, _("Program Listing Settings"))
415 {
416 }
417
418
419 void QListings::build_dialog()
420 {
421         dialog_.reset(new QListingsDialog(this));
422
423         bcview().setOK(dialog_->okPB);
424         bcview().setApply(dialog_->applyPB);
425         bcview().setCancel(dialog_->closePB);
426         dialog_->listingsTB->setPlainText(
427                 qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
428
429         update_contents();
430 }
431
432
433 void QListings::apply()
434 {
435         InsetListingsParams & params = controller().params();
436         params.setInline(dialog_->inlineCB->isChecked());
437         params.setParams(dialog_->construct_params());
438         controller().setParams(params);
439 }
440
441
442 namespace {
443
444 string plainParam(std::string const & par)
445 {
446         // remove enclosing braces
447         if (prefixIs(par, "{") && suffixIs(par, "}"))
448                 return par.substr(1, par.size() - 2);
449         return par;
450 }
451
452 } //namespace anon
453
454
455 void QListings::update_contents()
456 {
457         // set default values
458         dialog_->listingsTB->setPlainText(
459                 qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
460         dialog_->languageCO->setCurrentIndex(findToken(languages, "no language"));
461         dialog_->dialectCO->setCurrentIndex(0);
462         dialog_->floatCB->setChecked(false);
463         dialog_->placementLE->clear();
464         dialog_->numberSideCO->setCurrentIndex(0);
465         dialog_->numberStepLE->clear();
466         dialog_->numberFontSizeCO->setCurrentIndex(findToken(font_sizes, "default"));
467         dialog_->firstlineLE->clear();
468         dialog_->lastlineLE->clear();
469         dialog_->fontstyleCO->setCurrentIndex(findToken(font_styles, "default"));
470         dialog_->fontsizeCO->setCurrentIndex(findToken(font_sizes, "default"));
471         dialog_->breaklinesCB->setChecked(false);
472         dialog_->spaceCB->setChecked(false);
473         dialog_->spaceInStringCB->setChecked(true);
474         dialog_->extendedcharsCB->setChecked(false);
475
476         // set values from param string
477         InsetListingsParams & params = controller().params();
478         dialog_->inlineCB->setChecked(params.isInline());
479         if (params.isInline()) {
480                 dialog_->floatCB->setChecked(false);
481                 dialog_->placementLE->setEnabled(false);
482         }
483         // break other parameters and set values
484         vector<string> pars = getVectorFromString(params.separatedParams(), "\n");
485         // process each of them
486         for (vector<string>::iterator it = pars.begin();
487             it != pars.end(); ++it) {
488                 if (prefixIs(*it, "language=")) {
489                         string arg = plainParam(it->substr(9));
490                         // has dialect?
491                         string language;
492                         string dialect;
493                         bool in_gui = false;
494                         if (prefixIs(arg, "[") && contains(arg, "]")) {
495                                 string::size_type end_dialect = arg.find("]");
496                                 dialect = arg.substr(1, end_dialect - 1);
497                                 language = arg.substr(end_dialect + 1);
498                         } else
499                                 language = arg;
500                         int n = findToken(languages, language);
501                         if (n >= 0) {
502                                 dialog_->languageCO->setCurrentIndex(n);
503                                 in_gui = true;
504                         }
505                         // on_languageCO_currentIndexChanged should have set dialects
506                         if (!dialect.empty()) {
507                                 string dialect_gui;
508                                 for (size_t i = 0; i < nr_dialects; ++i) {
509                                         if (dialect == dialects[i].dialect
510                                             && dialects[i].language == language) {
511                                                 dialect_gui = dialects[i].gui;
512                                                 break;
513                                         }
514                                 }
515                                 n = dialog_->dialectCO->findText(qt_(dialect_gui));
516                                 if (n >= 0)
517                                         dialog_->dialectCO->setCurrentIndex(n);
518                                 else
519                                         in_gui = false;
520                         }
521                         if (in_gui)
522                                 *it = "";
523                         dialog_->languageCO->setEnabled(in_gui);
524                         dialog_->dialectCO->setEnabled(
525                                 in_gui && dialog_->dialectCO->count() > 1);
526                 } else if (prefixIs(*it, "float")) {
527                         dialog_->floatCB->setChecked(true);
528                         dialog_->inlineCB->setChecked(false);
529                         dialog_->placementLE->setEnabled(true);
530                         if (prefixIs(*it, "float="))
531                                 dialog_->placementLE->setText(
532                                         toqstr(plainParam(it->substr(6))));
533                         *it = "";
534                 } else if (prefixIs(*it, "numbers=")) {
535                         string s = plainParam(it->substr(8));
536                         int n = 0;
537                         if (s == "left")
538                                 n = 1;
539                         else if (s == "right")
540                                 n = 2;
541                         dialog_->numberSideCO->setCurrentIndex(n);
542                         *it = "";
543                 } else if (prefixIs(*it, "stepnumber=")) {
544                         dialog_->numberStepLE->setText(
545                                 toqstr(plainParam(it->substr(11))));
546                         *it = "";
547                 } else if (prefixIs(*it, "numberstyle=")) {
548                         string par = plainParam(it->substr(12));
549                         int n = findToken(font_sizes, par.substr(1));
550                         if (n >= 0)
551                                 dialog_->numberFontSizeCO->setCurrentIndex(n);
552                         *it = "";
553                 } else if (prefixIs(*it, "firstline=")) {
554                         dialog_->firstlineLE->setText(
555                                 toqstr(plainParam(it->substr(10))));
556                         *it = "";
557                 } else if (prefixIs(*it, "lastline=")) {
558                         dialog_->lastlineLE->setText(
559                                 toqstr(plainParam(it->substr(9))));
560                         *it = "";
561                 } else if (prefixIs(*it, "basicstyle=")) {
562                         string style;
563                         string size;
564                         for (int n = 0; font_styles[n][0]; ++n) {
565                                 string const s = font_styles[n];
566                                 if (contains(*it, "\\" + s)) {
567                                         style = "\\" + s;
568                                         break;
569                                 }
570                         }
571                         for (int n = 0; font_sizes[n][0]; ++n) {
572                                 string const s = font_sizes[n];
573                                 if (contains(*it, "\\" + s)) {
574                                         size = "\\" + s;
575                                         break;
576                                 }
577                         }
578                         if (plainParam(it->substr(11)) == style + size
579                             || plainParam(it->substr(11)) == size + style) {
580                                 if (!style.empty()) {
581                                         int n = findToken(font_styles, style.substr(1));
582                                         if (n >= 0)
583                                                 dialog_->fontstyleCO->setCurrentIndex(n);
584                                 }
585                                 if (!size.empty()) {
586                                         int n = findToken(font_sizes, size.substr(1));
587                                         if (n >= 0)
588                                                 dialog_->fontsizeCO->setCurrentIndex(n);
589                                 }
590                                 *it = "";
591                         }
592                 } else if (prefixIs(*it, "breaklines=")) {
593                         dialog_->breaklinesCB->setChecked(contains(*it, "true"));
594                         *it = "";
595                 } else if (prefixIs(*it, "showspaces=")) {
596                         dialog_->spaceCB->setChecked(contains(*it, "true"));
597                         *it = "";
598                 } else if (prefixIs(*it, "showstringspaces=")) {
599                         dialog_->spaceInStringCB->setChecked(contains(*it, "true"));
600                         *it = "";
601                 } else if (prefixIs(*it, "extendedchars=")) {
602                         dialog_->extendedcharsCB->setChecked(contains(*it, "true"));
603                         *it = "";
604                 }
605         }
606
607         dialog_->numberStepLE->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
608         dialog_->numberFontSizeCO->setEnabled(dialog_->numberSideCO->currentIndex() > 0);
609         // parameters that can be handled by widgets are cleared
610         // the rest is put to the extra edit box.
611         string extra = getStringFromVector(pars);
612         dialog_->listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
613 }
614
615
616 bool QListings::isValid()
617 {
618         return dialog_->validate_listings_params().empty();
619 }
620
621
622 } // namespace frontend
623 } // namespace lyx
624
625
626 #include "QListings_moc.cpp"