[rkward-cvs] rkward/rkward/settings rksettingsmoduler.cpp,1.9,1.10 rksettingsmoduler.h,1.5,1.6

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed Oct 12 17:02:35 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/settings
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6910/rkward/settings

Modified Files:
	rksettingsmoduler.cpp rksettingsmoduler.h 
Log Message:
Add GUI for most important R options in Settings->R backend

Index: rksettingsmoduler.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/settings/rksettingsmoduler.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rksettingsmoduler.cpp	2 Oct 2005 13:29:44 -0000	1.9
--- rksettingsmoduler.cpp	12 Oct 2005 17:02:33 -0000	1.10
***************
*** 21,24 ****
--- 21,25 ----
  #include <kstandarddirs.h>
  #include <kinputdialog.h>
+ #include <knuminput.h>
  
  #include <qlayout.h>
***************
*** 26,29 ****
--- 27,32 ----
  #include <qvbuttongroup.h>
  #include <qcheckbox.h>
+ #include <qcombobox.h>
+ #include <qlineedit.h>
  
  #include "../misc/multistringselector.h"
***************
*** 34,41 ****
  // static members
  QString RKSettingsModuleR::r_home_dir;
- bool RKSettingsModuleR::r_nosave;
- bool RKSettingsModuleR::r_slave;
  bool RKSettingsModuleR::archive_packages;
  QStringList RKSettingsModuleR::package_repositories;
  
  RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
--- 37,51 ----
  // static members
  QString RKSettingsModuleR::r_home_dir;
  bool RKSettingsModuleR::archive_packages;
  QStringList RKSettingsModuleR::package_repositories;
+ QString RKSettingsModuleR::options_outdec;
+ int RKSettingsModuleR::options_width;
+ int RKSettingsModuleR::options_warn;
+ int RKSettingsModuleR::options_warningslength;
+ bool RKSettingsModuleR::options_keepsource;
+ bool RKSettingsModuleR::options_keepsourcepkgs;
+ int RKSettingsModuleR::options_expressions;
+ int RKSettingsModuleR::options_digits;
+ bool RKSettingsModuleR::options_checkbounds;
  
  RKSettingsModuleR::RKSettingsModuleR (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
***************
*** 44,50 ****
  	QVBoxLayout *main_vbox = new QVBoxLayout (this, RKGlobals::marginHint ());
  
! 	QLabel *label = new QLabel (i18n ("Note: Settings marked with (*) will not take effect until you restart RKWard!"), this);
  	label->setAlignment (Qt::AlignAuto | Qt::AlignVCenter | Qt::ExpandTabs | Qt::WordBreak);
! 	main_vbox->addWidget (label);
  	main_vbox->addStretch ();
  
--- 54,60 ----
  	QVBoxLayout *main_vbox = new QVBoxLayout (this, RKGlobals::marginHint ());
  
! /*	QLabel *label = new QLabel (i18n ("Note: Settings marked with (*) will not take effect until you restart RKWard!"), this);
  	label->setAlignment (Qt::AlignAuto | Qt::AlignVCenter | Qt::ExpandTabs | Qt::WordBreak);
! 	main_vbox->addWidget (label); */
  	main_vbox->addStretch ();
  
***************
*** 62,74 ****
  	main_vbox->addStretch ();
  
! 	QVButtonGroup *group = new QVButtonGroup (i18n ("R options (*)"), this);
! 	nosave_box = new QCheckBox ("--no-save", group);
! 	nosave_box->setChecked (r_nosave);
! 	connect (nosave_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
! 	slave_box = new QCheckBox ("--slave", group);
! 	slave_box->setChecked (r_slave);
! 	connect (slave_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
  
! 	main_vbox->addWidget (group);	
  }
  
--- 72,150 ----
  	main_vbox->addStretch ();
  
! 	QLabel *label = new QLabel (i18n ("The following settings mostly affect R behavior in the console. It's generally safe to keep these unchanged."), this);
! 	label->setAlignment (Qt::AlignAuto | Qt::AlignVCenter | Qt::ExpandTabs | Qt::WordBreak);
! 	main_vbox->addWidget (label);
  
! 	QGridLayout *grid = new QGridLayout (main_vbox, 1, 2, RKGlobals::spacingHint ());
! 	int row = -1;
! 
! 	// options (warn)
! 	grid->addWidget (new QLabel (i18n ("Display warnings"), this), ++row, 0);
! 	warn_input = new QComboBox (false, this);
! 	warn_input->insertItem (i18n ("Suppress warnings"));			// do not change the order of options! See also: applyChanges ()
! 	warn_input->insertItem (i18n ("Print warnings later (default)"));
! 	warn_input->insertItem (i18n ("Print warnings immediately"));
! 	warn_input->insertItem (i18n ("Convert warnings to errors"));
! 	warn_input->setCurrentItem (options_warn + 1);
! 	connect (warn_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (warn_input, row, 1);
! 
! 	// options (OutDec)
! 	grid->addWidget (new QLabel (i18n ("Decimal character (only for printing)"), this), ++row, 0);
! 	outdec_input = new QLineEdit (options_outdec, this);
! 	outdec_input->setMaxLength (1);
! 	connect (outdec_input, SIGNAL (textChanged (const QString &)), this, SLOT (textChanged (const QString &)));
! 	grid->addWidget (outdec_input, row, 1);
! 
! 	// options (width)
! 	grid->addWidget (new QLabel (i18n ("Output width (characters)"), this), ++row, 0);
! 	width_input = new KIntSpinBox (10, 10000, 1, options_width, 10, this);
! 	connect (width_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (width_input, row, 1);
! 
! 	// options (warnings.length)
! 	grid->addWidget (new QLabel (i18n ("Maximum length of warnings/errors to print"), this), ++row, 0);
! 	warningslength_input = new KIntSpinBox (100, 8192, 1, options_warningslength, 10, this);
! 	connect (warningslength_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (warningslength_input, row, 1);
! 
! 	// options (keep.source)
! 	grid->addWidget (new QLabel (i18n ("Keep comments in functions"), this), ++row, 0);
! 	keepsource_input = new QComboBox (false, this);
! 	keepsource_input->insertItem (i18n ("TRUE (default)"));			// do not change the order of options! See also: applyChanges ()
! 	keepsource_input->insertItem (i18n ("FALSE"));
! 	keepsource_input->setCurrentItem (options_keepsource ? 0 : 1);
! 	connect (keepsource_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (keepsource_input, row, 1);
! 
! 	// options (keep.source.pkgs)
! 	grid->addWidget (new QLabel (i18n ("Keep comments in packages"), this), ++row, 0);
! 	keepsourcepkgs_input = new QComboBox (false, this);
! 	keepsourcepkgs_input->insertItem (i18n ("TRUE)"));			// do not change the order of options! See also: applyChanges ()
! 	keepsourcepkgs_input->insertItem (i18n ("FALSE (default)"));
! 	keepsourcepkgs_input->setCurrentItem (options_keepsourcepkgs ? 0 : 1);
! 	connect (keepsourcepkgs_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (keepsourcepkgs_input, row, 1);
! 
! 	// options (expressions)
! 	grid->addWidget (new QLabel (i18n ("Maximum level of nested expressions"), this), ++row, 0);
! 	expressions_input = new KIntSpinBox (25, 500000, 1, options_expressions, 10, this);
! 	connect (expressions_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (expressions_input, row, 1);
! 
! 	// options (digits)
! 	grid->addWidget (new QLabel (i18n ("Default decimal precision in print ()"), this), ++row, 0);
! 	digits_input = new KIntSpinBox (1, 22, 1, options_digits, 10, this);
! 	connect (digits_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (digits_input, row, 1);
! 
! 	// options (check.bounds)
! 	grid->addWidget (new QLabel (i18n ("Check vector bounds (warn)"), this), ++row, 0);
! 	checkbounds_input = new QComboBox (false, this);
! 	checkbounds_input->insertItem (i18n ("TRUE)"));			// do not change the order of options! See also: applyChanges ()
! 	checkbounds_input->insertItem (i18n ("FALSE (default)"));
! 	checkbounds_input->setCurrentItem (options_checkbounds ? 0 : 1);
! 	connect (checkbounds_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
! 	grid->addWidget (checkbounds_input, row, 1);
  }
  
***************
*** 87,90 ****
--- 163,171 ----
  }
  
+ void RKSettingsModuleR::textChanged (const QString &) {
+ 	RK_TRACE (SETTINGS);
+ 	change ();
+ }
+ 
  void RKSettingsModuleR::addRepository (QStringList *string_list) {
  	RK_TRACE (SETTINGS);
***************
*** 106,114 ****
  	RK_TRACE (SETTINGS);
  
- 	r_nosave = nosave_box->isChecked ();
- 	r_slave = slave_box->isChecked ();
  	archive_packages = archive_packages_box->isChecked ();
  
  	package_repositories = repository_selector->getValues ();
  	QString command = "options (repos=c(";
  	for (QStringList::const_iterator it = package_repositories.begin (); it != package_repositories.end (); ++it) {
--- 187,216 ----
  	RK_TRACE (SETTINGS);
  
  	archive_packages = archive_packages_box->isChecked ();
  
  	package_repositories = repository_selector->getValues ();
+ 
+ 	options_outdec = outdec_input->text ();
+ 	options_width = width_input->value ();
+ 	options_warn = warn_input->currentItem () - 1;
+ 	options_warningslength = warningslength_input->value ();
+ 	options_keepsource = (keepsource_input->currentItem () == 0);
+ 	options_keepsourcepkgs = (keepsourcepkgs_input->currentItem () == 0);
+ 	options_expressions = expressions_input->value ();
+ 	options_digits = digits_input->value ();
+ 	options_checkbounds = (checkbounds_input->currentItem () == 0);
+ 
+ // apply run time options in R
+ 	QStringList commands = makeRRunTimeOptionCommands ();
+ 	for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
+ 		RKGlobals::rInterface ()->issueCommand (*it, RCommand::App, QString::null, 0, 0, commandChain ());
+ 	}
+ }
+ 
+ //static
+ QStringList RKSettingsModuleR::makeRRunTimeOptionCommands () {
+ 	QStringList list;
+ 
+ // package repositories
  	QString command = "options (repos=c(";
  	for (QStringList::const_iterator it = package_repositories.begin (); it != package_repositories.end (); ++it) {
***************
*** 118,122 ****
  		command.append ("\"" + *it + "\"");
  	}
! 	RKGlobals::rInterface ()->issueCommand (command + "))\n", RCommand::App, QString::null, 0, 0, commandChain ());
  }
  
--- 220,240 ----
  		command.append ("\"" + *it + "\"");
  	}
! 	list.append (command + "))\n");
! 
! 	QString tf;
! 	list.append ("options (OutDec=\"" + options_outdec.left (1) + "\")\n");
! 	list.append ("options (width=" + QString::number (options_width) + ")\n");
! 	list.append ("options (warn=" + QString::number (options_warn) + ")\n");
! 	list.append ("options (warnings.length=" + QString::number (options_warningslength) + ")\n");
! 	if (options_keepsource) tf = "TRUE"; else tf = "FALSE";
! 	list.append ("options (keep.source=" + tf + ")\n");
! 	if (options_keepsourcepkgs) tf = "TRUE"; else tf = "FALSE";
! 	list.append ("options (keep.source.pkgs=" + tf + ")\n");
! 	list.append ("options (expressions=" + QString::number (options_expressions) + ")\n");
! 	list.append ("options (digits=" + QString::number (options_digits) + ")\n");
! 	if (options_checkbounds) tf = "TRUE"; else tf = "FALSE";
! 	list.append ("options (checkbounds=" + tf + ")\n");
! 
! 	return list;
  }
  
***************
*** 132,139 ****
  	config->setGroup ("R Settings");
  	config->writeEntry ("R_HOME", r_home_dir);
- 	config->writeEntry ("--no-save", r_nosave);
- 	config->writeEntry ("--slave", r_slave);
  	config->writeEntry ("archive packages", archive_packages);
  	config->writeEntry ("Repositories", package_repositories);
  }
  
--- 250,265 ----
  	config->setGroup ("R Settings");
  	config->writeEntry ("R_HOME", r_home_dir);
  	config->writeEntry ("archive packages", archive_packages);
  	config->writeEntry ("Repositories", package_repositories);
+ 
+ 	config->writeEntry ("OutDec", options_outdec);
+ 	config->writeEntry ("width", options_width);
+ 	config->writeEntry ("warn", options_warn);
+ 	config->writeEntry ("warnings.length", options_warningslength);
+ 	config->writeEntry ("keep.source", options_keepsource);
+ 	config->writeEntry ("keep.source.pkgs", options_keepsourcepkgs);
+ 	config->writeEntry ("expressions", options_expressions);
+ 	config->writeEntry ("digits", options_digits);
+ 	config->writeEntry ("checkboungs", options_checkbounds);
  }
  
***************
*** 143,148 ****
  	config->setGroup ("R Settings");
  	r_home_dir = config->readEntry ("R_HOME", QString::null);
- 	r_nosave = config->readBoolEntry ("--no-save", true);
- 	r_slave = config->readBoolEntry ("--slave", true);
  	archive_packages = config->readBoolEntry ("archive packages", false);
  	package_repositories = config->readListEntry ("Repositories");
--- 269,272 ----
***************
*** 150,167 ****
  		package_repositories.append ("@CRAN@");
  	}
- }
- 
- // static
- QStringList RKSettingsModuleR::getOptionList () {
- 	RK_TRACE (SETTINGS);
  
! 	QStringList ret;
! 	if (r_nosave) {
! 		ret.append ("--no-save");
! 	}
! 	if (r_slave) {
! 		ret.append ("--slave");
! 	}
! 	return ret;
  }
  
--- 274,287 ----
  		package_repositories.append ("@CRAN@");
  	}
  
! 	options_outdec = config->readEntry ("OutDec", ".");
! 	options_width = config->readNumEntry ("width", 80);
! 	options_warn = config->readNumEntry ("warn", 0);
! 	options_warningslength = config->readNumEntry ("warnings.length", 1000);
! 	options_keepsource = config->readBoolEntry ("keep.source", true);
! 	options_keepsourcepkgs = config->readBoolEntry ("keep.source.pkgs", false);
! 	options_expressions = config->readNumEntry ("expressions", 5000);
! 	options_digits = config->readNumEntry ("digits", 7);
! 	options_checkbounds = config->readNumEntry ("check.bounds", false);
  }
  

Index: rksettingsmoduler.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/settings/rksettingsmoduler.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rksettingsmoduler.h	18 Sep 2005 15:17:55 -0000	1.5
--- rksettingsmoduler.h	12 Oct 2005 17:02:33 -0000	1.6
***************
*** 24,28 ****
--- 24,31 ----
  
  class QCheckBox;
+ class QComboBox;
+ class QLineEdit;
  class MultiStringSelector;
+ class KIntSpinBox;
  
  /**
***************
*** 48,70 ****
  	
  	static QString &rHomeDir () { return r_home_dir; };
- 	static bool rNosave () { return r_nosave; };
- 	static bool rSlave () { return r_slave; };
  	static bool archivePackages () { return archive_packages; }
! 	static QStringList getOptionList ();
! 	static QStringList getPackageRepositories () { return package_repositories; };
  public slots:
  	void boxChanged (int);
  	void pathChanged ();
  	void addRepository (QStringList *string_list);
  private:
- 	QCheckBox *nosave_box;
- 	QCheckBox *slave_box;
  	QCheckBox *archive_packages_box;
  	MultiStringSelector *repository_selector;
! friend class RInterface;
! 	static bool r_nosave;
! 	static bool r_slave;
  	static bool archive_packages;
  	static QStringList package_repositories;
  	static QString r_home_dir;
  };
--- 51,89 ----
  	
  	static QString &rHomeDir () { return r_home_dir; };
  	static bool archivePackages () { return archive_packages; }
! //	static QStringList getPackageRepositories () { return package_repositories; };
! 
! /** generate the commands needed to set the R run time options */
! 	static QStringList makeRRunTimeOptionCommands ();
  public slots:
  	void boxChanged (int);
  	void pathChanged ();
+ 	void textChanged (const QString &);
  	void addRepository (QStringList *string_list);
  private:
  	QCheckBox *archive_packages_box;
  	MultiStringSelector *repository_selector;
! 	QLineEdit *outdec_input;
! 	KIntSpinBox *width_input;
! 	QComboBox *warn_input;
! 	KIntSpinBox *warningslength_input;
! 	QComboBox *keepsource_input;
! 	QComboBox *keepsourcepkgs_input;
! 	KIntSpinBox *expressions_input;
! 	KIntSpinBox *digits_input;
! 	QComboBox *checkbounds_input;
! 
  	static bool archive_packages;
  	static QStringList package_repositories;
+ 	static QString options_outdec;
+ 	static int options_width;
+ 	static int options_warn;
+ 	static int options_warningslength;
+ 	static bool options_keepsource;
+ 	static bool options_keepsourcepkgs;
+ 	static int options_expressions;
+ 	static int options_digits;
+ 	static bool options_checkbounds;
+ friend class RInterface;
  	static QString r_home_dir;
  };





More information about the rkward-tracker mailing list