KMyMoneyWizardPage Class Reference

#include <kmymoneywizard.h>

Inheritance diagram for KMyMoneyWizardPage:

WizardPage< T > WizardPage< NewAccountWizard::Wizard > WizardPage< NewUserWizard::Wizard > NewAccountWizard::AccountSummaryPage NewAccountWizard::AccountTypePage NewAccountWizard::BrokeragePage NewAccountWizard::CreditCardSchedulePage NewAccountWizard::GeneralLoanInfoPage NewAccountWizard::HierarchyPage NewAccountWizard::InstitutionPage NewAccountWizard::LoanDetailsPage NewAccountWizard::LoanPaymentPage NewAccountWizard::LoanPayoutPage NewAccountWizard::LoanSchedulePage NewUserWizard::AccountPage NewUserWizard::CategoriesPage NewUserWizard::CurrencyPage NewUserWizard::FilePage NewUserWizard::GeneralPage NewUserWizard::IntroPage NewUserWizard::PreferencePage
Collaboration diagram for KMyMoneyWizardPage:

Collaboration graph

List of all members.

Public Member Functions

virtual void enterPage (void)
virtual void leavePage (void)
virtual void resetPage (void)
virtual KMyMoneyWizardPagenextPage (void) const
virtual bool isLastPage (void) const
virtual bool isComplete (void) const
unsigned int step (void) const
QWidgetwidget (void) const
QObjectobject (void) const
virtual QWidgetinitialFocusWidget (void) const
virtual KMyMoneyWizardwizard (void) const =0
virtual const QString & helpContext (void) const
virtual ~KMyMoneyWizardPage ()

Protected Member Functions

 KMyMoneyWizardPage (unsigned int step, QWidget *widget, const char *name=0)
void completeStateChanged (void) const

Protected Attributes


Private Attributes

unsigned int m_step
KMyMoneyWizardPagePrivate *const d

Detailed Description

Thomas Baumgart (C) 2006
: the following documentation is somewhat outdated as of May 2007. Wizards should use a namespace for the pages and can use the WizardPage<T> template class. See the NewUserWizard class and NewUserWizardPages namespace as an example of this setup.
This class represents the base class for wizard pages for the KMyMoneyWizard. One cannot create a wizard page directly, but must derive from it. The KMyMoneyWizardPage class provides the necessary functionality to work in concert with KMyMoneyWizard.

Therefore, few steps are necessary to use this class. They seem to be awkward at some stage, but I wanted to be able to use Qt designer to actually design the widget for the page. That's why some things aren't implemented in a more straight fashion than one would normally do this.

The first step is to derive a specific base page for the specific wizard. In this example we use the name NewUser as template for the specific wizard. This class provides a 'back'-pointer to the actual wizard object for all pages.

 class KNewUserPage : public KMyMoneyWizardPage
   KNewUserPage(unsigned int step, QWidget* widget, KNewUserWizard* parent, const char* name);

   KNewUserWizard*    m_wizard;

The implementation of this class is rather straight-forward:

 KNewUserPage::KNewUserPage(unsigned int step, QWidget* widget, KNewUserWizard* parent, const char* name) :
   KMyMoneyWizardPage(step, widget, name),

For each page of the wizard, you will have to create a ui file with Qt designer. Let's assume we call the first page of the wizard 'General' and go from there. We also assume, that the wizard has more than one page. The ui designer generated class should have the name KNewUserGeneralDecl as all other dialogs. The class definition of KNewUserGeneral will look like this:

 class KNewUserGeneral : public KNewUserGeneralDecl, public KNewUserPage
   KNewUserGeneral(KNewUserWizard* parent, const char* name = 0);
   KMyMoneyWizardPage* nextPage(void);
   bool isLastPage(void) { return false; }

   KNewUserWizard*    m_wizard;

The implementation depends heavily on the logic of your code. If you only fill some widgets, it could be as simple as:

 KNewUserGeneral::KNewUserGeneral(KNewUserWizard* parent, const char* name) :
   KNewUserPage(1, this, parent, name)
   kMandatoryFieldGroup* mandatoryGroup = new kMandatoryFieldGroup(this);
   connect(m_mandatoryGroup, SIGNAL(stateChanged()), object(), SIGNAL(completeStateChanged()));

 KMyMoneyWizardPage* KNewUserGeneral::nextPage(void)
   return m_wizard->m_personalPage;

A note on the first parameter to KNewUserPage in the above example: it ties this page to be part of step 1 (see KMyMoneyWizard::addStep() for details).

Depending on the actual logic of the page, you would want to override the following methods: resetPage, nextPage, isLastPage and isComplete.

The implementation of this class is heavily based on ideas found at

Constructor & Destructor Documentation

virtual KMyMoneyWizardPage::~KMyMoneyWizardPage (  )  [inline, virtual]

KMyMoneyWizardPage::KMyMoneyWizardPage ( unsigned int  step,
QWidget widget,
const char *  name = 0 
) [protected]

Constructor (kept protected, so that one cannot create such an object directly)

Member Function Documentation

virtual void KMyMoneyWizardPage::enterPage ( void   )  [virtual]

virtual void KMyMoneyWizardPage::leavePage ( void   )  [virtual]

This method is called by the wizard when the page is left to return to the previous page. The default implementation does nothing.

virtual void KMyMoneyWizardPage::resetPage ( void   )  [virtual]

This method is called by the wizard whenever a page is entered (either in forward or backward direction). The default implementation does nothing.

virtual KMyMoneyWizardPage* KMyMoneyWizardPage::nextPage ( void   )  const [virtual]

virtual bool KMyMoneyWizardPage::isLastPage ( void   )  const [virtual]

This returns, if the current page is the last page of the wizard. The default implementation returns false if nextPage() returns 0, true otherwise.

Return values:
false more pages follow
true this is the last page of the wizard

virtual bool KMyMoneyWizardPage::isComplete ( void   )  const [virtual]

This returns, if all necessary data for this page has been filled. It is used to enabled the 'Next' or 'Finish' button. The button is only enabled, if this method returns true, which is the default implementation.

Return values:
false more data required from the user before we can proceed
true all data available, we allow to switch to the next page

Reimplemented in NewAccountWizard::AccountTypePage, NewAccountWizard::CreditCardSchedulePage, NewAccountWizard::GeneralLoanInfoPage, NewAccountWizard::LoanDetailsPage, NewAccountWizard::LoanPayoutPage, NewUserWizard::AccountPage, and NewUserWizard::FilePage.

unsigned int KMyMoneyWizardPage::step ( void   )  const [inline]

This method returns the step to which this page belongs. It is required by the KMyMoneyWizard and is not intended to be used by application code.

step of wizard this page belongs to

QWidget* KMyMoneyWizardPage::widget ( void   )  const [inline]

This method returns a pointer to the widget of the page. It is required by the KMyMoneyWizard and is not intended to be used by application code.

pointer to widget of page

QObject* KMyMoneyWizardPage::object ( void   )  const

This method returns a pointer to the QObject used for the signal/slot mechanism. It is required by the KMyMoneyWizard and can be used by application code for signal/slot connections as well. Other use is not foreseen.

virtual QWidget* KMyMoneyWizardPage::initialFocusWidget ( void   )  const [inline, virtual]

This method returns a pointer to the widget which should receive the focus when the page is opened.

pointer to widget or 0 if none is to be selected The default implementation returns 0

Reimplemented in NewAccountWizard::InstitutionPage, NewAccountWizard::AccountTypePage, NewAccountWizard::BrokeragePage, NewAccountWizard::CreditCardSchedulePage, NewAccountWizard::GeneralLoanInfoPage, NewAccountWizard::LoanDetailsPage, NewAccountWizard::LoanSchedulePage, NewAccountWizard::LoanPayoutPage, NewAccountWizard::HierarchyPage, and NewAccountWizard::AccountSummaryPage.

virtual KMyMoneyWizard* KMyMoneyWizardPage::wizard ( void   )  const [pure virtual]

virtual const QString& KMyMoneyWizardPage::helpContext ( void   )  const [virtual]

This method returns a specific help context for the page shown The default returns an empty string.

void KMyMoneyWizardPage::completeStateChanged ( void   )  const [protected]

This method must be called by the implementation when the data in the fields of the wizard change and the state of completeness changed.

If you do not override isComplete() then there is no need to call this method.

Member Data Documentation

unsigned int KMyMoneyWizardPage::m_step [private]

The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:08:14 2011 for KMyMoney by  doxygen 1.5.6