[rkward-cvs] rkward/rkward/plugin rkcomponent.cpp,1.12,1.13 rkcomponent.h,1.13,1.14 rkcomponentproperties.cpp,1.19,1.20 rkstandardcomponent.cpp,1.22,1.23 rkstandardcomponent.h,1.13,1.14 rkstandardcomponentgui.cpp,1.4,1.5

Thomas Friedrichsmeier tfry at users.sourceforge.net
Tue Mar 21 15:41:27 UTC 2006


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

Modified Files:
	rkcomponent.cpp rkcomponent.h rkcomponentproperties.cpp 
	rkstandardcomponent.cpp rkstandardcomponent.h 
	rkstandardcomponentgui.cpp 
Log Message:
Embedding a wizard (or dialog) inside a wizard works

Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkcomponent.h	20 Mar 2006 19:33:55 -0000	1.13
--- rkcomponent.h	21 Mar 2006 15:41:24 -0000	1.14
***************
*** 107,110 ****
--- 107,114 ----
  /** returns true, if the current page is satisfied (see isWizardish ()). Default implementation returns isSatisfied () */
  	virtual bool currentPageSatisfied () { return (isSatisfied ()); };
+ /** add a Page to the component. Don't worry, you'll only have to implement this is a meaningful way, if your component isWizardish (). Default implementation simply returns a new RKComponent (and raises an assert). */
+ 	virtual RKComponent *addPage ();
+ /** For wizardish guis: this gets called to register a component on the current page during construction. The component does not get reparented. It will have to be satisfied in order to move to the next page in the wizard. See isWizardish () see addPage (). Default implementation does nothing. */
+ 	virtual void addComponentToCurrentPage (RKComponent *component);
  public slots:
  /** This handles changes in the default properties (enabledness, visibility, requiredness). You will use similar slots in derived classes to handle

Index: rkstandardcomponentgui.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponentgui.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rkstandardcomponentgui.cpp	20 Mar 2006 20:30:58 -0000	1.4
--- rkstandardcomponentgui.cpp	21 Mar 2006 15:41:24 -0000	1.5
***************
*** 261,265 ****
  		updateState ();
  	} else {
! 		ok ();
  	}
  }
--- 261,266 ----
  		updateState ();
  	} else {
! 		if (enslaved) cancel ();
! 		else ok ();
  	}
  }
***************
*** 268,278 ****
  	RK_TRACE (PLUGIN);
  
! 	if (stack->havePage (false)) {
! 		stack->movePage (false);
! 		updateState ();
! 	} else if (is_switchable) {
! 		switchInterface ();
  	} else {
! 		RK_ASSERT (false);
  	}
  }
--- 269,288 ----
  	RK_TRACE (PLUGIN);
  
! 	if (enslaved) {
! 		if (stack->havePage (false)) {
! 			stack->movePage (false);
! 			updateState ();
! 		} else {
! 			cancel ();
! 		}
  	} else {
! 		if (stack->havePage (false)) {
! 			stack->movePage (false);
! 			updateState ();
! 		} else if (is_switchable) {
! 			switchInterface ();
! 		} else {
! 			RK_ASSERT (false);
! 		}
  	}
  }
***************
*** 281,294 ****
  	RK_TRACE (PLUGIN);
  
! 	if (stack->havePage (true) || enslaved) {		// not on last page
! 		next_button->setText (i18n ("Next >"));
! 		next_button->setEnabled (stack->currentPageSatisfied ());
! 		if (stack->havePage (false) || (!is_switchable) || enslaved) {		// not on first page
  			prev_button->setText (i18n ("< Back"));
- 			prev_button->setEnabled (stack->havePage (false));
  		} else {
! 			prev_button->setText (i18n ("Use Dialog"));
! 			prev_button->setEnabled (true);
  		}
  	} else {			// on last page
  		// do code update when on last page
--- 291,316 ----
  	RK_TRACE (PLUGIN);
  
! 	if (enslaved) {
! 		if (stack->havePage (true)) {		// not on last page
! 			next_button->setText (i18n ("Next >"));
! 			next_button->setEnabled (stack->currentPageSatisfied ());
! 		} else {			// on last page
! 			// do code update when on last page
! 			next_button->setText (i18n ("Done"));
! 			next_button->setEnabled (stack->currentPageSatisfied ());
! 		}
! 
! 		prev_button->setEnabled (true);
! 		if (stack->havePage (false)) {		// not on first page
  			prev_button->setText (i18n ("< Back"));
  		} else {
! 			prev_button->setText (i18n ("Close"));
  		}
+ 		return;
+ 	}
+ 
+ 	if (stack->havePage (true)) {		// not on last page
+ 		next_button->setText (i18n ("Next >"));
+ 		next_button->setEnabled (stack->currentPageSatisfied ());
  	} else {			// on last page
  		// do code update when on last page
***************
*** 297,300 ****
--- 319,330 ----
  		next_button->setEnabled (submit_enabled);
  	}
+ 
+ 	if (stack->havePage (false) || (!is_switchable)) {		// not on first page
+ 		prev_button->setText (i18n ("< Back"));
+ 		prev_button->setEnabled (stack->havePage (false));
+ 	} else {
+ 		prev_button->setText (i18n ("Use Dialog"));
+ 		prev_button->setEnabled (true);
+ 	}
  }
  

Index: rkstandardcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkstandardcomponent.h	20 Mar 2006 20:30:58 -0000	1.13
--- rkstandardcomponent.h	21 Mar 2006 15:41:24 -0000	1.14
***************
*** 55,58 ****
--- 55,60 ----
  /** for use by RKComponentBuilder to add a page to a wizardish component */
  	RKComponent *addPage ();
+ /** reimplemented to acutally register the component with the wizard */
+ 	void addComponentToCurrentPage (RKComponent *component);
  /** switch from dialog to wizard or vice versa */
  	void switchInterface ();

Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkcomponent.cpp	20 Mar 2006 19:33:55 -0000	1.12
--- rkcomponent.cpp	21 Mar 2006 15:41:24 -0000	1.13
***************
*** 145,148 ****
--- 145,160 ----
  }
  
+ RKComponent *RKComponent::addPage () {
+ 	RK_TRACE (PLUGIN);
+ 	RK_ASSERT (false);		// should not be called as isWizardish returns false
+ 
+ 	return (new RKComponent (this, this));
+ }
+ 
+ void RKComponent::addComponentToCurrentPage (RKComponent *component) {
+ 	RK_TRACE (PLUGIN);
+ 	RK_ASSERT (false);		// should not be called as isWizardish returns false
+ }
+ 
  void RKComponent::setVisible (bool visible) {
  	RK_TRACE (PLUGIN);

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** rkstandardcomponent.cpp	20 Mar 2006 20:30:58 -0000	1.22
--- rkstandardcomponent.cpp	21 Mar 2006 15:41:24 -0000	1.23
***************
*** 99,103 ****
  		}
  	} else if (!parent_widget) {				// we have a parent component, but should still have a separate GUI
! 		if (!createTopLevel (doc_element, 0, true)) {
  			RK_ASSERT (false);
  			deleteLater ();
--- 99,105 ----
  		}
  	} else if (!parent_widget) {				// we have a parent component, but should still have a separate GUI
! 		int force_mode = 1;
! 		if (parentComponent ()->isWizardish ()) force_mode = 2;
! 		if (!createTopLevel (doc_element, force_mode, true)) {
  			RK_ASSERT (false);
  			deleteLater ();
***************
*** 113,116 ****
--- 115,125 ----
  				gui_element = xml->getChildElement (doc_element, "dialog", DL_WARNING);
  				build_wizard = false;
+ 
+ 				QWidget *fake_page = parent_component->addPage ();
+ 				QVBoxLayout *layout = new QVBoxLayout (fake_page);	
+ 				QVBox *box = new QVBox (fake_page);
+ 				box->setSpacing (RKGlobals::spacingHint ());
+ 				layout->addWidget (box);
+ 				parent_widget = box;
  			}
  		} else {
***************
*** 181,185 ****
  		build_wizard = false;
  		if (dialog_element.isNull ()) {
! 			xml->displayError (&doc_element, "Dialog mode forced, but no dialog element given", DL_ERROR);
  			deleteLater ();
  			return false;
--- 190,194 ----
  		build_wizard = false;
  		if (dialog_element.isNull ()) {
! 			xml->displayError (&doc_element, "Dialog mode forced, but no dialog element given", DL_INFO);
  			deleteLater ();
  			return false;
***************
*** 188,192 ****
  		build_wizard = true;
  		if (wizard_element.isNull ()) {
! 			xml->displayError (&doc_element, "Wizard mode forced, but no wizard element given", DL_ERROR);
  			deleteLater ();
  			return false;
--- 197,201 ----
  		build_wizard = true;
  		if (wizard_element.isNull ()) {
! 			xml->displayError (&doc_element, "Wizard mode forced, but no wizard element given", DL_INFO);
  			deleteLater ();
  			return false;
***************
*** 319,323 ****
  	RK_TRACE (PLUGIN);
  
! 	return (wizard != 0);
  }
  
--- 328,334 ----
  	RK_TRACE (PLUGIN);
  
! 	if (gui) return (wizard != 0);
! 	if (parentComponent ()) return (parentComponent ()->isWizardish ());
! 	return false;
  }
  
***************
*** 345,352 ****
  RKComponent *RKStandardComponent::addPage () {
  	RK_TRACE (PLUGIN);
- 	RK_ASSERT (wizard);
  
! 	RKComponent *page = wizard->addPage (this);
! 	return page;
  }
  
--- 356,370 ----
  RKComponent *RKStandardComponent::addPage () {
  	RK_TRACE (PLUGIN);
  
! 	if (wizard) {
! 		RKComponent *page = wizard->addPage (this);
! 		return page;
! 	} else if (parentComponent ()) {
! 		RK_ASSERT (!gui);
! 		return parentComponent ()->addPage ();
! 	}
! 
! 	RK_ASSERT (false);
! 	return RKComponent::addPage ();
  }
  
***************
*** 354,360 ****
  	RK_TRACE (PLUGIN);
  
! 	if (wizard) {
  		if (!child->isProperty ()) {
! 			wizard->addComponentToCurrentPage (static_cast<RKComponent *>(child));
  		}
  	}
--- 372,378 ----
  	RK_TRACE (PLUGIN);
  
! 	if (wizard || (parentComponent () && parentComponent ()->isWizardish ())) {
  		if (!child->isProperty ()) {
! 			addComponentToCurrentPage (static_cast<RKComponent *>(child));
  		}
  	}
***************
*** 363,367 ****
--- 381,395 ----
  }
  
+ void RKStandardComponent::addComponentToCurrentPage (RKComponent *component) {
+ 	RK_TRACE (PLUGIN);
  
+ 	if (wizard) {
+ 		wizard->addComponentToCurrentPage (component);
+ 	} else if (parentComponent () && parentComponent ()->isWizardish ()) {
+ 		parentComponent ()->addComponentToCurrentPage (component);
+ 	} else {
+ 		RK_ASSERT (false);
+ 	}
+ }
  
  

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** rkcomponentproperties.cpp	20 Mar 2006 19:33:55 -0000	1.19
--- rkcomponentproperties.cpp	21 Mar 2006 15:41:24 -0000	1.20
***************
*** 49,57 ****
  
  - Add something like RKComponentPropertySelect for a property that accepts one or more of a set of predefined strings (like e.g. for a radio-box)
- 	- Maybe then, and in conjunction with sub-properties, the bool-property can be abstracted away (it would just be a select property, and an internal int-property could be used for bool purposes)?
  
  - Carefully check whether all API-elements are really needed once the implementation is complete
- 
- - All these TODOs should be delayed until there is at least a rudimentary implementation of components to play with
  */
  
--- 49,54 ----





More information about the rkward-tracker mailing list