PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/frontends/qt4/GuiListings.cpp

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