[rkward-cvs] rkward/rkward/plugin rkinput.cpp,1.1,1.2 rkpluginbrowser.cpp,1.1,1.2 rkvarselector.cpp,1.11,1.12 rkvarselector.h,1.6,1.7 rkvarslot.cpp,1.7,1.8 rkvarslot.h,1.5,1.6

Pierre ecoch at users.sourceforge.net
Sat Apr 2 08:48:12 UTC 2005


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

Modified Files:
	rkinput.cpp rkpluginbrowser.cpp rkvarselector.cpp 
	rkvarselector.h rkvarslot.cpp rkvarslot.h 
Log Message:
Patch by Adrien + using nice icons instead of '-->' in varslot

Index: rkvarselector.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarselector.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkvarselector.h	26 Mar 2005 10:32:17 -0000	1.6
--- rkvarselector.h	2 Apr 2005 08:48:10 -0000	1.7
***************
*** 26,29 ****
--- 26,30 ----
  class RObject;
  class RKVariable;
+ class RContainerObject;
  
  #define VARSELECTOR_WIDGET 2
***************
*** 48,62 ****
  /** Returns pointers to the currently selected variables */
  	QValueList<RKVariable*> selectedVars ();
  	int type () { return VARSELECTOR_WIDGET; };
  /** find out, whether the given object is available in the RKVarselector (i.e. it a) exists and b) matched the filter requirements) */
  	bool containsObject (RObject *object);
!   void setEnabled(bool);
  public slots:
  	void objectListChanged ();
!   void slotActive();
!   void slotActive(bool);
  private:
  	RKObjectListView *list_view;
!     QString depend;
  };
  
--- 49,65 ----
  /** Returns pointers to the currently selected variables */
  	QValueList<RKVariable*> selectedVars ();
+ 	QValueList<RContainerObject*> selectedContainer ();
  	int type () { return VARSELECTOR_WIDGET; };
  /** find out, whether the given object is available in the RKVarselector (i.e. it a) exists and b) matched the filter requirements) */
  	bool containsObject (RObject *object);
! 	void setEnabled(bool);
! 	int numSelectedContainer();
  public slots:
  	void objectListChanged ();
! 	void slotActive();
! 	void slotActive(bool);
  private:
  	RKObjectListView *list_view;
! 	QString depend;
  };
  

Index: rkvarselector.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarselector.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rkvarselector.cpp	26 Mar 2005 10:32:17 -0000	1.11
--- rkvarselector.cpp	2 Apr 2005 08:48:10 -0000	1.12
***************
*** 23,34 ****
  #include <qlabel.h>
  
  #include "../core/rkvariable.h"
  #include "../rkglobals.h"
  #include "../misc/rkobjectlistview.h"
! 
  #include "../debug.h"
  
  RKVarSelector::RKVarSelector (const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget (element, parent, plugin) {
  	RK_TRACE (PLUGIN);
  	QVBoxLayout  *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	depend = element.attribute ("depend", "");
--- 23,36 ----
  #include <qlabel.h>
  
+ #include "../core/rcontainerobject.h"
  #include "../core/rkvariable.h"
  #include "../rkglobals.h"
  #include "../misc/rkobjectlistview.h"
! #include "../core/robjectlist.h"
  #include "../debug.h"
  
  RKVarSelector::RKVarSelector (const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget (element, parent, plugin) {
  	RK_TRACE (PLUGIN);
+ 	RKGlobals::rObjectList ()->updateFromR ();
  	QVBoxLayout  *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	depend = element.attribute ("depend", "");
***************
*** 58,62 ****
  	RK_TRACE (PLUGIN);
  	QValueList<RKVariable*> selected;
- 
  	QListViewItem *current;
  	current = list_view->firstChild ();
--- 60,63 ----
***************
*** 120,121 ****
--- 121,166 ----
  list_view->setEnabled(isOk) ;
  }
+ 
+ 
+ 
+ QValueList <RContainerObject*> RKVarSelector::selectedContainer()
+ {
+ 	RK_TRACE (PLUGIN);
+ 	QValueList<RContainerObject*> selected;
+ 	QListViewItem *current;
+ 	current = list_view->firstChild ();
+ 	while (current->itemBelow ()) {
+ 		current = current->itemBelow ();
+ 		if (current->isSelected ()) {
+ 			RObject *obj = list_view->findItemObject (current);
+ 			RK_ASSERT (obj);
+ 			if (obj->isContainer()) {
+ 				selected.append (static_cast<RContainerObject*> (obj));
+ 			}
+ 		}
+ 	}
+ 
+ 	return selected;
+ }
+ 
+ 
+ int RKVarSelector::numSelectedContainer()
+ {
+ 	RK_TRACE (PLUGIN);
+ 	int i=0;
+ 
+ 	QListViewItem *current;
+ 	current = list_view->firstChild ();
+ 	while (current->itemBelow ()) {
+ 		current = current->itemBelow ();
+ 		if (current->isSelected ()) {
+ 			RObject *obj = list_view->findItemObject (current);
+ 			RK_ASSERT (obj);
+ 			if (obj->isContainer ()) {
+ 				++i;
+ 			}
+ 		}
+ 	}
+ 
+ 	return i;
+ }

Index: rkvarslot.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarslot.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkvarslot.cpp	26 Mar 2005 10:32:17 -0000	1.7
--- rkvarslot.cpp	2 Apr 2005 08:48:10 -0000	1.8
***************
*** 24,29 ****
--- 24,31 ----
  #include <qlistview.h>
  #include <qlayout.h>
+ #include <qstringlist.h>
  
  #include <klocale.h>
+ #include <kiconloader.h>
  
  #include "rkvarselector.h"
***************
*** 31,34 ****
--- 33,38 ----
  #include "../rkglobals.h"
  #include "../core/rkvariable.h"
+ #include "../core/rcontainerobject.h"
+ 
  
  RKVarSlot::RKVarSlot(const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget (element, parent, plugin) {
***************
*** 38,43 ****
  	QGridLayout *g_layout = new QGridLayout (this, 3, 3, RKGlobals::spacingHint ());
  
! 	select = new QPushButton ("-->", this);
! 	select->setFixedWidth (select->fontMetrics ().width (" --> "));
  	connect (select, SIGNAL (clicked ()), this, SLOT (selectPressed ()));
  	g_layout->addWidget (select, 1, 0);
--- 42,49 ----
  	QGridLayout *g_layout = new QGridLayout (this, 3, 3, RKGlobals::spacingHint ());
  
! 	
! 	select = new QPushButton ("", this);
! 	select->setPixmap(SmallIcon("1rightarrow"));
! 
  	connect (select, SIGNAL (clicked ()), this, SLOT (selectPressed ()));
  	g_layout->addWidget (select, 1, 0);
***************
*** 69,72 ****
--- 75,82 ----
  	source_id = element.attribute ("source");
  	depend = element.attribute ("depend", "");
+ 	classes = element.attribute ("classes", "all");
+ 	if (classes=="frame") classes = "data.frame matrix list array";
+ 	else if (classes=="number") classes = "numeric integer" ;
+ 	else if (classes=="vector") classes ="numeric integer character factor" ; 
  	required = (element.attribute ("required") == "true");
  	num_vars = 0;
***************
*** 84,87 ****
--- 94,98 ----
  }
  
+ // TODO make the same with cont_map 
  void RKVarSlot::objectListChanged () {
  	if (!source) return;
***************
*** 92,96 ****
  				item_map.remove (0);
  				num_vars = 0;
! 				select->setText ("-->");
  			} else {
  				line_edit->setText (item_map[0]->getShortName ());
--- 103,107 ----
  				item_map.remove (0);
  				num_vars = 0;
! 				select->setPixmap(SmallIcon("1rightarrow"));
  			} else {
  				line_edit->setText (item_map[0]->getShortName ());
***************
*** 134,140 ****
  	
  	if (selection) {
! 		select->setText ("<--");
  	} else {
! 		select->setText ("-->");
  	}
  }
--- 145,151 ----
  	
  	if (selection) {
! 		select->setPixmap(SmallIcon("1leftarrow"));
  	} else {
! 		select->setPixmap(SmallIcon("1rightarrow"));
  	}
  }
***************
*** 144,158 ****
  		if (!num_vars) {
  			if (!source) return;
! 			if (source->numSelectedVars() != 1) return;
! 			RKVariable *sel = source->selectedVars ().first ();
! 			line_edit->setText (sel->getShortName ());
! 			item_map.insert (0, sel);
! 			num_vars = 1;
! 			select->setText ("<--");
!    	 } else {
  			line_edit->setText ("");
  			item_map.remove (0);
  			num_vars = 0;
! 			select->setText ("-->");
  		}
  	} else {	// multi-slot
--- 155,185 ----
  		if (!num_vars) {
  			if (!source) return;
! 			if (source->numSelectedVars() == 1) {
! 				RKVariable *sel = source->selectedVars ().first ();
! 				if (belongToClasses(sel->makeClassString(""))){
! 					line_edit->setText (sel->getShortName ());
! 					item_map.insert (0, sel);
! 					num_vars = 1;
! 					select->setPixmap(SmallIcon("1leftarrow"));
! 					varOrCont = true ; 
! 				}
! 			}else if (source->numSelectedContainer() == 1 ){
! 				RContainerObject *sel = source->selectedContainer().first ();
! 				if (belongToClasses(sel->makeClassString(""))){
! 				line_edit->setText (sel->getShortName ());
! 				cont_map.insert (0, sel);
! 				num_vars = 1;
! 				select->setPixmap(SmallIcon("1leftarrow"));
! 				varOrCont = false ; 
! 				}
! 			}
! 			else return ;
! 			
! 		} else {
  			line_edit->setText ("");
  			item_map.remove (0);
+ 			cont_map.remove (0);
  			num_vars = 0;
! 			select->setPixmap(SmallIcon("1rightarrow"));
  		}
  	} else {	// multi-slot
***************
*** 185,189 ****
  					}
  				}
! 				if (!duplicate) {
  					QListViewItem *new_item = new QListViewItem (list, sel->getShortName ());
  					list->insertItem (new_item);
--- 212,216 ----
  					}
  				}
! 				if (!duplicate && belongToClasses(sel->makeClassString(""))) {
  					QListViewItem *new_item = new QListViewItem (list, sel->getShortName ());
  					list->insertItem (new_item);
***************
*** 191,194 ****
--- 218,238 ----
  				}
  			}
+ 			QValueList<RContainerObject*> contlist = source->selectedContainer();
+ 			for (QValueList<RContainerObject*>::Iterator et = contlist.begin (); et != contlist.end (); ++et) {
+ 				RContainerObject* selcont = *et;
+ 				// don't allow duplicates
+ 				bool duplicate = false;
+ 				for (ContMap::const_iterator eet = cont_map.begin (); eet != cont_map.end (); ++eet) {
+ 					if (eet.data () == selcont) {
+ 						duplicate = true;
+ 						break;
+ 					}
+ 				}
+ 				if (!duplicate && belongToClasses(selcont->makeClassString(""))) {
+ 					QListViewItem *new_item = new QListViewItem (list, selcont->getShortName ());
+ 					list->insertItem (new_item);
+ 					cont_map.insert (new_item, selcont);
+ 				}
+ 			}
  		}
  		num_vars = list->childCount ();
***************
*** 229,240 ****
  
  QString RKVarSlot::value (const QString &modifier) {
  	if (!multi) {
  		if (num_vars) {
  			if (modifier == "label") {
! 				return item_map[0]->getDescription ();
  			} else if (modifier == "shortname") {
! 				return item_map[0]->getShortName ();
  			} else {
! 				return (item_map[0]->getFullName ());
  			}
  		} else {
--- 273,288 ----
  
  QString RKVarSlot::value (const QString &modifier) {
+ QString ret;
  	if (!multi) {
  		if (num_vars) {
  			if (modifier == "label") {
! 				if (varOrCont)	return item_map[0]->getDescription();
! 				else	return cont_map[0]->getDescription();
  			} else if (modifier == "shortname") {
! 				if (varOrCont)	return item_map[0]->getShortName();
! 				else	return cont_map[0]->getShortName();
  			} else {
! 				if (varOrCont)	return item_map[0]->getFullName();
! 				else	return cont_map[0]->getFullName();
  			}
  		} else {
***************
*** 242,261 ****
  		}
  	} else {
- 		QString ret;
- 
  		QListViewItem *item = list->firstChild ();
  		while (item) {
  			if (modifier == "label") {
! 				ret.append (item_map[item]->getDescription () + "\n");
  			} else if (modifier == "shortname") {
! 				ret.append (item_map[item]->getShortName () + "\n");
  			} else {
! 				ret.append (item_map[item]->getFullName () + "\n");
  			}
  			item = item->nextSibling ();
  		}
- 	
- 		return ret;
  	}
  }
  
--- 290,316 ----
  		}
  	} else {
  		QListViewItem *item = list->firstChild ();
  		while (item) {
  			if (modifier == "label") {
! 				ItemMap::iterator it = item_map.find (item);
! 				if (it != item_map.end ())  ret.append (item_map[item]->getDescription() + "\n");
! 				ContMap::iterator et = cont_map.find (item);
! 				if (et != cont_map.end ())  ret.append (cont_map[item]->getDescription() + "\n");
  			} else if (modifier == "shortname") {
! 				ItemMap::iterator it = item_map.find (item);
! 				if (it != item_map.end ())  ret.append (item_map[item]->getShortName () + "\n");
! 				ContMap::iterator et = cont_map.find (item);
! 				if (et != cont_map.end ())  ret.append (cont_map[item]->getShortName () + "\n");
  			} else {
! 				ItemMap::iterator it = item_map.find (item);
! 				if (it != item_map.end ())  ret.append (item_map[item]->getFullName () + "\n");
! 				ContMap::iterator et = cont_map.find (item);
! 				if (et != cont_map.end ())  ret.append (cont_map[item]->getFullName () + "\n");
  			}
  			item = item->nextSibling ();
  		}
  	}
+ //		qDebug ( "%s", ret.latin1() ) ;
+ return ret;
  }
  
***************
*** 281,282 ****
--- 336,342 ----
  }
  
+ bool RKVarSlot::belongToClasses(const QString &nom ) {
+ if (classes=="all") return true ;
+ if (classes.find( nom, 0 ) != -1) return true; 
+ else return false ;
+ }

Index: rkvarslot.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarslot.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rkvarslot.h	26 Mar 2005 10:32:17 -0000	1.5
--- rkvarslot.h	2 Apr 2005 08:48:10 -0000	1.6
***************
*** 30,33 ****
--- 30,34 ----
  class RKVarSelector;
  class RKVariable;
+ class RContainerObject;
  
  #define VARSLOT_WIDGET 1
***************
*** 43,49 ****
  	~RKVarSlot();
  	int getNumVars () { return num_vars; };
  	QValueList<RKVariable*> getVariables ();
!   int type() {return VARSLOT_WIDGET ;};
!   void  setEnabled(bool);
    
  public slots:
--- 44,51 ----
  	~RKVarSlot();
  	int getNumVars () { return num_vars; };
+ 	int getNumCont () { return num_cont; };
  	QValueList<RKVariable*> getVariables ();
!   	int type() {return VARSLOT_WIDGET ;};
!   	void  setEnabled(bool);
    
  public slots:
***************
*** 53,58 ****
  /// find out whether all items are still present, remove items which are no longer present and update text for all others
  	void objectListChanged ();
!   void slotActive();
!   void slotActive(bool);
  private:
  	QLineEdit *line_edit;
--- 55,60 ----
  /// find out whether all items are still present, remove items which are no longer present and update text for all others
  	void objectListChanged ();
!   	void slotActive();
!   	void slotActive(bool);
  private:
  	QLineEdit *line_edit;
***************
*** 61,67 ****
  	RKVarSelector *source;
  	QString source_id;
!   QString depend;
!   int min_vars;
  	int num_vars;
  	bool multi;
  	bool required;
--- 63,71 ----
  	RKVarSelector *source;
  	QString source_id;
! 	QString depend;
! 	QString varchier;
! 	int min_vars;
  	int num_vars;
+ 	int num_cont;
  	bool multi;
  	bool required;
***************
*** 69,73 ****
--- 73,82 ----
  	typedef QMap<QListViewItem*, RKVariable*> ItemMap; 
  	ItemMap item_map;
+ 	typedef QMap<QListViewItem*, RContainerObject*> ContMap; 
+ 	ContMap cont_map;
+ 	QString classes ; 
  	void updateState ();
+ 	bool belongToClasses (const QString &nom) ;
+ 	bool varOrCont ;
  protected:
  	bool isSatisfied ();

Index: rkinput.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkinput.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rkinput.cpp	26 Mar 2005 10:33:30 -0000	1.1
--- rkinput.cpp	2 Apr 2005 08:48:10 -0000	1.2
***************
*** 16,20 ****
  	vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	label = new QLabel (element.attribute ("label", "Enter your text"), this);
! 	textedit = new QTextEdit ( element.attribute ("intial") ,
  	QString::null,this, element.attribute ("id")) ;
  	vbox->addWidget (label);
--- 16,21 ----
  	vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	label = new QLabel (element.attribute ("label", "Enter your text"), this);
! 	QString initial = element.attribute ("initial","") ;
! 	textedit = new QTextEdit ( initial ,
  	QString::null,this, element.attribute ("id")) ;
  	vbox->addWidget (label);
***************
*** 61,65 ****
  
  QString RKInput::value (const QString &) {
- 	qDebug("la valeur de edit est %s",textedit->text().latin1());
  	return textedit->text();
  }
--- 62,65 ----

Index: rkpluginbrowser.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkpluginbrowser.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rkpluginbrowser.cpp	26 Mar 2005 10:33:30 -0000	1.1
--- rkpluginbrowser.cpp	2 Apr 2005 08:48:10 -0000	1.2
***************
*** 29,33 ****
  	vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	label = new QLabel (element.attribute ("label", "Enter your text"), this);
! 	textedit = new QTextEdit ( element.attribute ("intial") ,
  	QString::null,this, element.attribute ("id")) ;
  	button = new QPushButton ("Browser...",this);
--- 29,33 ----
  	vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  	label = new QLabel (element.attribute ("label", "Enter your text"), this);
! 	textedit = new QTextEdit ( element.attribute ("initial" ,"") ,
  	QString::null,this, element.attribute ("id")) ;
  	button = new QPushButton ("Browser...",this);
***************
*** 43,52 ****
  	size = element.attribute ("size", "small");
  	if (size == "small") {
- 	textedit->setMaximumSize (300,25) ; 
  	textedit->setMinimumSize (300,25) ; 
  	}
  	else if (size == "big") {
- 	textedit->setMaximumSize (300,100) ; 
  	textedit->setMinimumSize (300,100) ; 
  	}
  	
--- 43,54 ----
  	size = element.attribute ("size", "small");
  	if (size == "small") {
  	textedit->setMinimumSize (300,25) ; 
+ 	button ->setMinimumSize (300,25) ; 
+ 	textedit->setMaximumSize (300,25) ; 
+ 	button ->setMaximumSize (300,25) ; 
  	}
  	else if (size == "big") {
  	textedit->setMinimumSize (300,100) ; 
+ 	button->setMinimumSize (300,100) ; 
  	}
  	





More information about the rkward-tracker mailing list