Author: sh-sh-sh
Date: Wed Jul 2 12:05:29 2008
New Revision: 48771
URL: http://svn.opensuse.org/viewcvs/yast?rev=48771&view=rev
Log:
handle wizard [Next] button
Added:
branches/tmp/jdsn/registration/src/RegWizardPage.cc
branches/tmp/jdsn/registration/src/RegWizardPage.h
Modified:
branches/tmp/jdsn/registration/src/Makefile.am
branches/tmp/jdsn/registration/src/RegMain.cc
branches/tmp/jdsn/registration/src/RegUpdateRepoPage.cc
branches/tmp/jdsn/registration/src/RegUpdateRepoPage.h
branches/tmp/jdsn/registration/src/RegWizard.cc
branches/tmp/jdsn/registration/src/RegWizard.h
Modified: branches/tmp/jdsn/registration/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/Makefile.am?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/Makefile.am (original)
+++ branches/tmp/jdsn/registration/src/Makefile.am Wed Jul 2 12:05:29 2008
@@ -9,6 +9,7 @@
yast2_registration_SOURCES = \
RegMain.cc \
RegWizard.cc \
+ RegWizardPage.cc \
RegUpdateRepoPage.cc
yast2_registration_LDADD = -L$(top_srcdir)/src -lyui
Modified: branches/tmp/jdsn/registration/src/RegMain.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegMain.cc?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegMain.cc (original)
+++ branches/tmp/jdsn/registration/src/RegMain.cc Wed Jul 2 12:05:29 2008
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
#include "Reg_i18n.h"
#include "RegWizard.h"
@@ -24,9 +25,20 @@
YUILog::enableDebugLogging();
RegUpdateRepoPage updateRepoPage( true, "http://download.opensuse.org/update/11.0/" );
+ RegUpdateRepoPage updateRepoPage2( true, "Page 2" );
+ RegUpdateRepoPage updateRepoPage3( true, "Page 3" );
+
+ updateRepoPage.setNextPage ( &updateRepoPage2 );
+ updateRepoPage2.setNextPage( &updateRepoPage3 );
updateRepoPage.show();
- updateRepoPage.waitForEvent();
+
+ bool success = RegWizard::runWorkflow();
+
+ if ( success )
+ {
+ // write data
+ }
RegWizard::close();
}
Modified: branches/tmp/jdsn/registration/src/RegUpdateRepoPage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegUpdateRepoPage.cc?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegUpdateRepoPage.cc (original)
+++ branches/tmp/jdsn/registration/src/RegUpdateRepoPage.cc Wed Jul 2 12:05:29 2008
@@ -31,11 +31,16 @@
}
-void RegUpdateRepoPage::show()
+RegUpdateRepoPage::~RegUpdateRepoPage()
{
- if ( ! RegWizard::isOpen() )
- RegWizard::open();
+ // NOP
+}
+
+void RegUpdateRepoPage::show()
+{
+ RegWizardPage::show();
+
YWizard * wizard = RegWizard::regWizard()->wizard();
YUI_CHECK_PTR( wizard );
@@ -70,6 +75,11 @@
// Trigger geometry management once all new widgets are created
wizard->contentsReplacePoint()->showChild();
+
+ YDialog * dialog = wizard->findDialog();
+ YUI_CHECK_PTR( dialog );
+ dialog->setInitialSize();
+ dialog->checkShortcuts();
}
@@ -84,15 +94,6 @@
}
-void RegUpdateRepoPage::waitForEvent()
-{
- YDialog * dialog = RegWizard::dialog();
- YUI_CHECK_PTR( dialog );
-
- dialog->waitForEvent();
-}
-
-
void RegUpdateRepoPage::save()
{
_enableUpdates = _enableUpdatesCheckBoxFrame->value();
Modified: branches/tmp/jdsn/registration/src/RegUpdateRepoPage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegUpdateRepoPage.h?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegUpdateRepoPage.h (original)
+++ branches/tmp/jdsn/registration/src/RegUpdateRepoPage.h Wed Jul 2 12:05:29 2008
@@ -3,6 +3,7 @@
#ifndef RegUpdateRepoPage_h
#define RegUpdateRepoPage_h
+#include "RegWizardPage.h"
#include <string>
using std::string;
@@ -17,7 +18,7 @@
* This class holds the data of this page, regardless whether or not this page
* is currently displayed.
**/
-class RegUpdateRepoPage
+class RegUpdateRepoPage: public RegWizardPage
{
public:
/**
@@ -30,31 +31,38 @@
const string & updateRepoURL );
/**
- * Show the page inside a RegWizard. This will create the RegWizard if it
- * doesn't exist yet.
- **/
- void show();
+ * Destructor.
+ **/
+ virtual ~RegUpdateRepoPage();
/**
- * Event handler
+ * Show the page inside a RegWizard. This will create the RegWizard if it
+ * doesn't exist yet.
+ *
+ * Reimplemented from RegWizardPage.
**/
- void waitForEvent();
+ virtual void show();
/**
* Save the widget values to the internal values.
+ *
+ * Reimplemented from RegWizardPage.
**/
- void save();
+ virtual void save();
/**
* Clear all pointers to internally stored widgets.
- * This needs to be done prior to showing another wizard page.
+ *
+ * Reimplemented from RegWizardPage.
**/
- void forgetWidgets();
+ virtual void forgetWidgets();
/**
* Return the help text for this wizard page.
+ *
+ * Reimplemented from RegWizardPage.
**/
- string helpText();
+ virtual string helpText();
/**
* Return 'true' if updates are enabled. If the page is currently shown,
Modified: branches/tmp/jdsn/registration/src/RegWizard.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.cc?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizard.cc (original)
+++ branches/tmp/jdsn/registration/src/RegWizard.cc Wed Jul 2 12:05:29 2008
@@ -10,8 +10,11 @@
#include
#include
#include
+#include
+#include
#include "RegWizard.h"
+#include "RegWizardPage.h"
#include "Reg_i18n.h"
@@ -109,3 +112,78 @@
return regWizard()->_wizard;
}
+
+bool
+RegWizard::runWorkflow()
+{
+ YUI_CHECK_PTR( regWizard()->currentPage() );
+
+ YDialog * dia = dialog();
+ YWizard * wiz = wizard();
+ YUI_CHECK_PTR( dia );
+ YUI_CHECK_PTR( wiz );
+
+ while( true )
+ {
+ YEvent * event = dia->waitForEvent();
+
+ if ( event )
+ {
+ RegWizardPage * currentPage = regWizard()->currentPage();
+ event = currentPage->handleEvent( event );
+
+ if ( event ) // currentPage might have handled this event and returned 0
+ {
+ if ( event->widget() == wiz->nextButton() )
+ {
+ // Go to next page
+
+ RegWizardPage * nextPage = currentPage->nextPage();
+
+ if ( nextPage )
+ {
+ currentPage->forgetWidgets();
+
+ currentPage = nextPage;
+ currentPage->show();
+ regWizard()->setCurrentPage( currentPage );
+
+ if ( ! currentPage->nextPage() )
+ {
+ wiz->nextButton()->setLabel( _( "&Finish" ) );
+ }
+ }
+ else // No next page -> finished
+ {
+ yuiMilestone() << "Workflow finished" << endl;
+ return true;
+ }
+ }
+ else if ( event->widget() == wiz->backButton() )
+ {
+ // Go back in page history
+
+
+ // TO DO
+ }
+ else if ( event->widget() == wiz->abortButton() ||
+ event->eventType() == YEvent::CancelEvent )
+ {
+ // Handle "Abort" / WM_CLOSE
+
+ // TO DO: Ask user for confirmation
+
+ // TO DO: Global "dirty" flag
+
+ bool confirmed = true;
+
+ if ( confirmed )
+ {
+ yuiMilestone() << "User aborted" << endl;
+ return false;
+ }
+ }
+ }
+ }
+ }
+}
Modified: branches/tmp/jdsn/registration/src/RegWizard.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.h?rev=48771&r1=48770&r2=48771&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizard.h (original)
+++ branches/tmp/jdsn/registration/src/RegWizard.h Wed Jul 2 12:05:29 2008
@@ -3,9 +3,9 @@
#ifndef RegWizard_h
#define RegWizard_h
-
class YDialog;
class YWizard;
+class RegWizardPage;
/**
@@ -24,7 +24,7 @@
/**
* Return 'true' if the registration wizard is open.
- **/
+ **/
static bool isOpen();
/**
@@ -41,12 +41,37 @@
* Return the dialog for this wizard or 0 if there is none.
**/
static YDialog * dialog();
-
+
/**
* Return the wizard widget or 0 if there is none.
**/
static YWizard * wizard();
+ /**
+ * Set the current page for this workflow.
+ * This is called from RegWizardPage() each time a new page is shown.
+ **/
+ void setCurrentPage( RegWizardPage * page ) { _currentPage = page; }
+
+ /**
+ * Return the current page.
+ **/
+ RegWizardPage * currentPage() const { return _currentPage; }
+
+ /**
+ * Run the workflow: Wait for events and handle them until the workflow is
+ * finished (the last page is reached) or until the user clicks the "Abort"
+ * or WM_CLOSE buttons.
+ *
+ * This calls the current page's handleEvent() method for each event that
+ * is received.
+ *
+ * Return 'true' upon success (workflow finished) and 'false' if the user
+ * terminates with "Abort" or WM_CLOSE.
+ **/
+ static bool runWorkflow();
+
+
protected:
// Constructor and destructor are not public:
// Use the public static methods instead.
@@ -54,8 +79,9 @@
~RegWizard();
private:
- YDialog * _dialog;
- YWizard * _wizard;
+ YDialog * _dialog;
+ YWizard * _wizard;
+ RegWizardPage * _currentPage;
};
#endif // RegWizard_h
Added: branches/tmp/jdsn/registration/src/RegWizardPage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizardPage.cc?rev=48771&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizardPage.cc (added)
+++ branches/tmp/jdsn/registration/src/RegWizardPage.cc Wed Jul 2 12:05:29 2008
@@ -0,0 +1,29 @@
+// Base class for wizard pages
+
+
+#define YUILogComponent "reg"
+#include
+
+#include "RegWizard.h"
+#include "RegWizardPage.h"
+
+
+RegWizardPage::RegWizardPage()
+ : _nextPage( 0 )
+{
+}
+
+
+RegWizardPage::~RegWizardPage()
+{
+}
+
+
+void RegWizardPage::show()
+{
+ if ( ! RegWizard::isOpen() )
+ RegWizard::open();
+
+ RegWizard::regWizard()->setCurrentPage( this );
+}
+
Added: branches/tmp/jdsn/registration/src/RegWizardPage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizardPage.h?rev=48771&view=auto
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizardPage.h (added)
+++ branches/tmp/jdsn/registration/src/RegWizardPage.h Wed Jul 2 12:05:29 2008
@@ -0,0 +1,102 @@
+// Base class for wizard pages
+
+#ifndef RegWizardPage_h
+#define RegWizardPage_h
+
+
+class YEvent;
+
+/**
+ * Abstract base class for all wizard pages in the registration workflow.
+ **/
+class RegWizardPage
+{
+public:
+ /**
+ * Constructor.
+ **/
+ RegWizardPage();
+
+ /**
+ * Destructor.
+ **/
+ virtual ~RegWizardPage();
+
+ /**
+ * Show the page inside a RegWizard. This will create the RegWizard if it
+ * doesn't exist yet.
+ *
+ * Derived classes should implement this and call this base class method at
+ * the start of the new implementation.
+ **/
+ virtual void show();
+
+ /**
+ * Initialize internal data just prior to show().
+ *
+ * Derived classes can implement this to read external data etc.
+ **/
+ virtual void init() {}
+
+ /**
+ * Event handler.
+ *
+ * This base class event handler handles the wizard buttons "Next", "Back",
+ * "Abort" and the window manager WM_CLOSE button.
+ *
+ * Derived classes can overwrite this, but they should call
+ * this base class method in the new implementation.
+ *
+ * Note that there will always be a confirmation when the user hits "Abort"
+ * or WM_CLOSE. If this is not desired, the derived class should check if
+ * any data were changed and handle those buttons before this base class
+ * method is called.
+ *
+ * The return value is 0 if the event was handled and the original event
+ * otherwise.
+ **/
+ virtual YEvent * handleEvent( YEvent * event ) { return event; }
+
+ /**
+ * Save the widget values to the internal values.
+ *
+ * Derived classes should implement this.
+ **/
+ virtual void save() {}
+
+ /**
+ * Clear all pointers to internally stored widgets.
+ * This needs to be done prior to showing another wizard page.
+ *
+ * Derived classes that store widget pointers should implement this.
+ **/
+ virtual void forgetWidgets() {}
+
+ /**
+ * Return the help text for this wizard page.
+ **/
+ virtual string helpText() = 0;
+
+ /**
+ * Set the next wizard page for this page.
+ *
+ * This is used in the default event handlers to go to the next page.
+ * Derived classes are free to change this next page on the fly if they
+ * wish, but the default should be that the next pages are all set up prior
+ * to running the workflow.
+ **/
+ void setNextPage( RegWizardPage * page ) { _nextPage = page; }
+
+ /**
+ * Return the next page for this page or 0 if there is none.
+ **/
+ RegWizardPage * nextPage() const { return _nextPage; }
+
+
+private:
+
+ RegWizardPage * _nextPage;
+};
+
+
+#endif // RegWizardPage_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org