Author: sh-sh-sh Date: Thu Jul 3 11:53:30 2008 New Revision: 48806 URL: http://svn.opensuse.org/viewcvs/yast?rev=48806&view=rev Log: fixed history Modified: branches/tmp/jdsn/registration/src/RegMain.cc branches/tmp/jdsn/registration/src/RegWizard.cc branches/tmp/jdsn/registration/src/RegWizard.h Modified: branches/tmp/jdsn/registration/src/RegMain.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegMain.cc?rev=48806&r1=48805&r2=48806&view=diff ============================================================================== --- branches/tmp/jdsn/registration/src/RegMain.cc (original) +++ branches/tmp/jdsn/registration/src/RegMain.cc Thu Jul 3 11:53:30 2008 @@ -31,7 +31,7 @@ updateRepoPage.setNextPage ( &updateRepoPage2 ); updateRepoPage2.setNextPage( &updateRepoPage3 ); - updateRepoPage.show(); + RegWizard::regWizard()->showPage( &updateRepoPage ); bool success = RegWizard::runWorkflow(); if ( success ) Modified: branches/tmp/jdsn/registration/src/RegWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.cc?rev=48806&r1=48805&r2=48806&view=diff ============================================================================== --- branches/tmp/jdsn/registration/src/RegWizard.cc (original) +++ branches/tmp/jdsn/registration/src/RegWizard.cc Thu Jul 3 11:53:30 2008 @@ -38,6 +38,9 @@ RegWizard::RegWizard() : _dialog( 0 ) , _wizard( 0 ) + , _currentPage( 0 ) + , _terminate( false ) + , _terminateResult( true ) { } @@ -138,6 +141,12 @@ RegWizardPage * currentPage = regWizard()->currentPage(); event = currentPage->handleEvent( event ); + if ( regWizard()->_terminate ) // terminateWorkflow() was called? + { + regWizard()->_terminate = false; + return regWizard()->_terminateResult; + } + if ( event ) // currentPage might have handled this event and returned 0 { if ( event->widget() == wiz->nextButton() ) @@ -183,6 +192,13 @@ } +void RegWizard::terminateWorkflow( bool result ) +{ + _terminate = true; + _terminateResult = result; +} + + void RegWizard::showPage( RegWizardPage * newPage ) { RegWizardPage * oldPage = regWizard()->currentPage(); @@ -196,18 +212,16 @@ regWizard()->setCurrentPage( newPage ); newPage->init(); newPage->show(); + historyAdd( newPage ); YWizard * wiz = wizard(); YUI_CHECK_PTR( wiz ); + wiz->backButton()->setEnabled( _history.size() > 1 ); wiz->nextButton()->setLabel( newPage->nextPage() ? _( "&Next" ) : _( "&Finish" ) ); - - if ( _history.empty() || _history.top() == newPage ) - wiz->backButton()->setEnabled( false ); - else - wiz->backButton()->setEnabled( true ); + // historyDump(); } @@ -218,10 +232,6 @@ yuiDebug() << "Adding page " << hex << page << dec << " to history" << endl; _history.push( page ); } - else - { - yuiDebug() << "Page already in history" << endl; - } } @@ -233,15 +243,44 @@ void RegWizard::historyBack() { + // yuiDebug() << "Going back one page" << endl; + // historyDump(); + + RegWizardPage * oldPage = currentPage(); + RegWizardPage * prevPage = oldPage; + + while ( prevPage == oldPage && ! _history.empty() ) + { + prevPage = _history.top(); + _history.pop(); + } + + if ( prevPage != oldPage ) + showPage( prevPage ); +} + + +void RegWizard::historyDump() +{ if ( _history.empty() ) { - yuiDebug() << "History empty" << endl; + yuiMilestone() << "Page history empty" << endl; return; } - yuiDebug() << "Going back one page" << endl; + // std::stack allows access only to the top of the stack, so the history + // needs to be copied here to inspect it completely + + RegWizardPageStack his ( _history ); + + yuiMilestone() << "Page history stack:" << endl; + int i=0; - _history.pop(); - RegWizardPage * prevPage = _history.top(); - showPage( prevPage ); + while ( ! his.empty() ) + { + yuiMilestone() << " #" << i++ << ": " + << hex << his.top() << dec + << endl; + his.pop(); + } } Modified: branches/tmp/jdsn/registration/src/RegWizard.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/registration/src/RegWizard.h?rev=48806&r1=48805&r2=48806&view=diff ============================================================================== --- branches/tmp/jdsn/registration/src/RegWizard.h (original) +++ branches/tmp/jdsn/registration/src/RegWizard.h Thu Jul 3 11:53:30 2008 @@ -65,7 +65,17 @@ * Return 'true' upon success (workflow finished) and 'false' if the user * terminates with "Abort" or WM_CLOSE. **/ - static bool runWorkflow(); + static bool runWorkflow(); + + /** + * Finish the workflow from some other place than the last page or via the + * "Abort" button. This can be used from the event handler of wizard pages + * for non-linear workflows. + * + * 'result' is what will be returned from any active 'runWorkflow' event + * loop. + **/ + void terminateWorkflow( bool result ); /** * Show another page. @@ -109,11 +119,18 @@ RegWizard(); ~RegWizard(); + /** + * Dump the page history to the log + **/ + void historyDump(); + private: YDialog * _dialog; YWizard * _wizard; RegWizardPage * _currentPage; RegWizardPageStack _history; + bool _terminate; + bool _terminateResult; }; #endif // RegWizard_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org