Author: sh-sh-sh
Date: Wed Jul 2 14:53:47 2008
New Revision: 48782
URL: http://svn.opensuse.org/viewcvs/yast?rev=48782&view=rev
Log:
history handling (still not 100% reliable)
Modified:
branches/tmp/jdsn/registration/src/RegMain.cc
branches/tmp/jdsn/registration/src/RegWizard.cc
branches/tmp/jdsn/registration/src/RegWizard.h
branches/tmp/jdsn/registration/src/RegWizardPage.h
Modified: branches/tmp/jdsn/registration/src/RegMain.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegMain.cc?rev=48782&r1=48781&r2=48782&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegMain.cc (original)
+++ branches/tmp/jdsn/registration/src/RegMain.cc Wed Jul 2 14:53:47 2008
@@ -31,7 +31,7 @@
updateRepoPage.setNextPage ( &updateRepoPage2 );
updateRepoPage2.setNextPage( &updateRepoPage3 );
- updateRepoPage.show();
+ RegWizard::regWizard()->showPage( &updateRepoPage );
bool success = RegWizard::runWorkflow();
Modified: branches/tmp/jdsn/registration/src/RegWizard.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.cc?rev=48782&r1=48781&r2=48782&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizard.cc (original)
+++ branches/tmp/jdsn/registration/src/RegWizard.cc Wed Jul 2 14:53:47 2008
@@ -118,11 +118,9 @@
{
YUI_CHECK_PTR( regWizard()->currentPage() );
- YDialog * dia = dialog();
- YWizard * wiz = wizard();
- YUI_CHECK_PTR( dia );
- YUI_CHECK_PTR( wiz );
-
+ YDialog * dia = dialog(); YUI_CHECK_PTR( dia );
+ YWizard * wiz = wizard(); YUI_CHECK_PTR( wiz );
+
while( true )
{
YEvent * event = dia->waitForEvent();
@@ -136,24 +134,13 @@
{
if ( event->widget() == wiz->nextButton() )
{
- // Go to next page
+ // Go to next page, if there is any
RegWizardPage * nextPage = currentPage->nextPage();
if ( nextPage )
{
- currentPage->save();
- currentPage->forgetWidgets();
-
- currentPage = nextPage;
- currentPage->init();
- currentPage->show();
- regWizard()->setCurrentPage( currentPage );
-
- if ( ! currentPage->nextPage() )
- {
- wiz->nextButton()->setLabel( _( "&Finish" ) );
- }
+ regWizard()->showPage( nextPage );
}
else // No next page -> finished
{
@@ -163,10 +150,7 @@
}
else if ( event->widget() == wiz->backButton() )
{
- // Go back in page history
-
-
- // TO DO
+ regWizard()->historyBack();
}
else if ( event->widget() == wiz->abortButton() ||
event->eventType() == YEvent::CancelEvent )
@@ -189,3 +173,67 @@
}
}
}
+
+
+void RegWizard::showPage( RegWizardPage * newPage )
+{
+ RegWizardPage * oldPage = regWizard()->currentPage();
+
+ if ( oldPage )
+ {
+ oldPage->save();
+ oldPage->forgetWidgets();
+ }
+
+ regWizard()->setCurrentPage( newPage );
+ newPage->init();
+ newPage->show();
+
+ YWizard * wiz = wizard();
+ YUI_CHECK_PTR( wiz );
+
+ wiz->nextButton()->setLabel( newPage->nextPage() ?
+ _( "&Next" ) :
+ _( "&Finish" ) );
+
+ if ( _history.empty() || _history.top() == newPage )
+ wiz->backButton()->setEnabled( false );
+ else
+ wiz->backButton()->setEnabled( true );
+
+ if ( _history.empty() || _history.top() != newPage )
+ historyAdd( newPage );
+ else
+ {
+ yuiDebug() << "page already in history" << endl;
+ }
+}
+
+
+void RegWizard::historyAdd( RegWizardPage * page )
+{
+ yuiDebug() << "Adding page " << hex << page << dec << " to history" << endl;
+ _history.push( page );
+}
+
+
+bool RegWizard::historyEmpty() const
+{
+ return _history.empty();
+}
+
+
+void RegWizard::historyBack()
+{
+ if ( _history.empty() )
+ {
+ yuiDebug() << "History empty" << endl;
+ return;
+ }
+
+ yuiDebug() << "Going back one page" << endl;
+
+ _history.pop();
+ RegWizardPage * prevPage = _history.top();
+ showPage( prevPage );
+}
Modified: branches/tmp/jdsn/registration/src/RegWizard.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.h?rev=48782&r1=48781&r2=48782&view=diff
==============================================================================
--- branches/tmp/jdsn/registration/src/RegWizard.h (original)
+++ branches/tmp/jdsn/registration/src/RegWizard.h Wed Jul 2 14:53:47 2008
@@ -3,10 +3,16 @@
#ifndef RegWizard_h
#define RegWizard_h
+#include <stack>
+
class YDialog;
class YWizard;
class RegWizardPage;
+using std::stack;
+
+typedef std::stack