* 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 "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>
-
-using std::string;
-using std::vector;
-using lyx::support::findToken;
-using lyx::support::getVectorFromString;
-using lyx::support::getStringFromVector;
-using lyx::support::prefixIs;
-using lyx::support::suffixIs;
-using lyx::support::contains;
-
+using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace frontend {
/////////////////////////////////////////////////////////////////////
-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",
GuiListings::GuiListings(GuiView & lv)
- : GuiDialog(lv, "listings")
+ : GuiDialog(lv, "listings", qt_("Program Listing Settings"))
{
setupUi(this);
- setViewTitle(_("Program Listing Settings"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
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);
}
-void GuiListings::closeEvent(QCloseEvent * e)
-{
- slotClose();
- e->accept();
-}
-
-
void GuiListings::change_adaptor()
{
changed();
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);
}
-void GuiListings::set_listings_msg()
+void GuiListings::setListingsMsg()
{
static bool isOK = true;
docstring msg = validate_listings_params();
// 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) {
}
-static string plainParam(std::string const & par)
+static string plainParam(string const & par)
{
// remove enclosing braces
if (prefixIs(par, "{") && suffixIs(par, "}"))
// 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
string dialect;
bool in_gui = false;
if (prefixIs(arg, "[") && contains(arg, "]")) {
- string::size_type end_dialect = arg.find("]");
+ size_t end_dialect = arg.find("]");
dialect = arg.substr(1, end_dialect - 1);
language = arg.substr(end_dialect + 1);
- } else
+ } 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"