* Licence details can be found in the file COPYING.
*
* \author Bo Peng
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include "GuiListings.h"
#include "qt_helpers.h"
+
#include "FuncRequest.h"
+
#include "insets/InsetListings.h"
#include "insets/InsetListingsParams.h"
-#include "support/debug.h"
+#include "support/convert.h"
+#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include <QLineEdit>
-#include <QCloseEvent>
#include <QPushButton>
#include <QValidator>
#include <QRegExpValidator>
/////////////////////////////////////////////////////////////////////
-char const * languages[] =
+char const * languages_supported[] =
{ "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
"C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
"Eiffel", "Elan", "erlang", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
this, SLOT(change_adaptor()));
connect(spaceInStringCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(tabsizeSB, SIGNAL(valueChanged(int)),
+ this, SLOT(change_adaptor()));
connect(extendedcharsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()),
- this, SLOT(set_listings_msg()));
+ this, SLOT(setListingsMsg()));
connect(bypassCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(bypassCB, SIGNAL(clicked()),
- this, SLOT(set_listings_msg()));
+ this, SLOT(setListingsMsg()));
- for (int n = 0; languages[n][0]; ++n)
+ for (int n = 0; languages_supported[n][0]; ++n)
languageCO->addItem(qt_(languages_gui[n]));
for (int n = 0; font_styles[n][0]; ++n)
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
+ bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
string GuiListings::construct_params()
{
- string language = languages[languageCO->currentIndex()];
+ string language = languages_supported[qMax(0, languageCO->currentIndex())];
string dialect;
string const dialect_gui = fromqstr(dialectCO->currentText());
if (dialectCO->currentIndex() > 0) {
placement = fromqstr(placementLE->text());
string numberSide;
- switch (numberSideCO->currentIndex()) {
+ switch (qMax(0, numberSideCO->currentIndex())) {
case 0:
numberSide = "none";
break;
break;
}
string stepnumber = fromqstr(numberStepLE->text());
- string numberfontsize = font_sizes[numberFontSizeCO->currentIndex()];
+ string numberfontsize = font_sizes[qMax(0, numberFontSizeCO->currentIndex())];
string firstline = fromqstr(firstlineLE->text());
string lastline = fromqstr(lastlineLE->text());
- string fontsize = font_sizes[fontsizeCO->currentIndex()];
- string fontstyle = font_styles[fontstyleCO->currentIndex()];
+ string fontsize = font_sizes[qMax(0, fontsizeCO->currentIndex())];
+ string fontstyle = font_styles[qMax(0, fontstyleCO->currentIndex())];
string basicstyle;
if (fontsize != "default")
basicstyle = "\\" + fontsize;
basicstyle += "\\" + fontstyle;
bool breakline = breaklinesCB->isChecked();
bool space = spaceCB->isChecked();
+ int tabsize = tabsizeSB->value();
bool spaceInString = spaceInStringCB->isChecked();
bool extendedchars = extendedcharsCB->isChecked();
string extra = fromqstr(listingsED->toPlainText());
par.addParam("showspaces", "true");
if (!spaceInString)
par.addParam("showstringspaces", "false");
+ if (tabsize != 8)
+ par.addParam("tabsize", convert<string>(tabsize));
if (extendedchars)
par.addParam("extendedchars", "true");
par.addParams(extra);
{
// use a cache here to avoid repeated validation
// of the same parameters
+ // FIXME THREAD
static string param_cache;
static docstring msg_cache;
}
-void GuiListings::set_listings_msg()
+void GuiListings::setListingsMsg()
{
+ // FIXME THREAD
static bool isOK = true;
docstring msg = validate_listings_params();
if (msg.empty()) {
// 0 is "no dialect"
int default_dialect = 0;
dialectCO->addItem(qt_("No dialect"));
- string const language = languages[index];
+ string const language = languages_supported[index];
for (size_t i = 0; i != nr_dialects; ++i) {
if (language == dialects[i].language) {
// set default values
listingsTB->setPlainText(
qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
- languageCO->setCurrentIndex(findToken(languages, "no language"));
+ languageCO->setCurrentIndex(findToken(languages_supported, "no language"));
dialectCO->setCurrentIndex(0);
floatCB->setChecked(false);
placementLE->clear();
breaklinesCB->setChecked(false);
spaceCB->setChecked(false);
spaceInStringCB->setChecked(true);
+ tabsizeSB->setValue(8);
extendedcharsCB->setChecked(false);
// set values from param string
} else {
language = arg;
}
- int n = findToken(languages, language);
+ int n = findToken(languages_supported, language);
if (n >= 0) {
languageCO->setCurrentIndex(n);
in_gui = true;
} else if (prefixIs(*it, "showstringspaces=")) {
spaceInStringCB->setChecked(contains(*it, "true"));
*it = "";
+ } else if (prefixIs(*it, "tabsize=")) {
+ tabsizeSB->setValue(convert<int>(plainParam(it->substr(8))));
+ *it = "";
} else if (prefixIs(*it, "extendedchars=")) {
extendedcharsCB->setChecked(contains(*it, "true"));
*it = "";
bool GuiListings::initialiseParams(string const & data)
{
- InsetListingsMailer::string2params(data, params_);
+ InsetListings::string2params(data, params_);
return true;
}
void GuiListings::dispatchParams()
{
- string const lfun = InsetListingsMailer::params2string(params_);
+ string const lfun = InsetListings::params2string(params_);
dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace lyx
-#include "GuiListings_moc.cpp"
+#include "moc_GuiListings.cpp"