#include <kmymoneywizard.h>
Signals | |
void | createPayee (const QString &txt, QString &id) |
void | createCategory (const QString &txt, QString &id) |
Public Member Functions | |
void | setTitle (const QString &txt) |
void | addStep (const QString &text) |
QValueList< KMyMoneyWizardPage * > | historyPages (void) const |
void | reselectStep (void) |
void | setHelpContext (const QString &ctx) |
virtual | ~KMyMoneyWizard () |
Protected Slots | |
virtual void | accept (void) |
void | completeStateChanged (void) |
Protected Member Functions | |
KMyMoneyWizard (QWidget *parent=0, const char *name=0, bool modal=false, WFlags f=0) | |
void | setFirstPage (KMyMoneyWizardPage *page) |
void | setStepHidden (unsigned int step, bool hidden=true) |
Protected Attributes | |
KPushButton * | m_cancelButton |
KPushButton * | m_backButton |
KPushButton * | m_nextButton |
KPushButton * | m_finishButton |
KPushButton * | m_helpButton |
Private Slots | |
void | backButtonClicked (void) |
void | nextButtonClicked (void) |
void | helpButtonClicked (void) |
Private Member Functions | |
void | updateStepCount (void) |
void | switchPage (KMyMoneyWizardPage *oldPage) |
void | selectStep (unsigned int step) |
Private Attributes | |
QVBoxLayout * | m_wizardLayout |
QVBoxLayout * | m_stepLayout |
QVBoxLayout * | m_pageLayout |
QHBoxLayout * | m_buttonLayout |
QFrame * | m_stepFrame |
QLabel * | m_stepLabel |
QPalette | m_stepPalette |
QValueList< QLabel * > | m_steps |
int | m_step |
KMyMoneyTitleLabel * | m_titleLabel |
QValueList< KMyMoneyWizardPage * > | m_history |
QString | m_helpContext |
Friends | |
class | KMyMoneyWizardPage |
+-wizardLayout-----------------------------------------------+ | | +------------------------------------------------------------+ |+-stepLayout--++-------------------------------------------+| || ||+-pageLayout------------------------------+|| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||+-----------------------------------------+|| || |||+-buttonLayout--------------------------+||| || |||| |||| || |||+---------------------------------------+||| || ||+-----------------------------------------+|| |+-------------++-------------------------------------------+| +------------------------------------------------------------+
The top bar is filled with a KMyMoneyTitleLabel as known from KMyMoney's views. To the left there is an area in the same color as the title bar showing the steps for this wizard. Each such step can consist of one or more wizard pages. At the bottom of this area the text "Step x of y" is shown and updated. To the right of this part, the actual wizard page is shown. At the bottom of the page the class inserts a standard button widget consisting of a Help, Back, Next/Finish and Cancel button.
The wizard serves as container for the wizard pages. In order to access the data filled into the pages, one would have to provide getter methods.
Here is an example how this object could be used. Please also see the example described with the KMyMoneyWizardPage class.
class KNewUserGeneral; class KNewUserPersonal; class KNewUserWizard : public KMyMoneyWizard { Q_OBJECT public: KNewUserWizard(QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags flags = 0); private: KNewUserGeneral* m_generalPage; KNewUserPersonal* m_personalPage; KNewUserFinal* m_finalPage; // add more pages here friend class KNewUserGeneral; friend class KNewUserPersonal; friend class KNewUserFinal; // add more pages here };
The implementation is also easy and looks like this:
KNewUserWizard::KNewUserWizard(QWidget* parent, const char* name, bool modal, WFlags flags) : KMyMoneyWizard(parent, name, modal, flags) { setTitle("KMyMoney New User Setup"); addStep("General Data"); addStep("Personal Data"); addStep("Finish"); m_generalPage = new KNewUserGeneral(this); m_personalPage = new KNewUserPersonal(this); m_finalPage = new KNewUserFinal(this); setFirstPage(m_testPage1); }
Don't forget to call setFirstPage() to get things started.
The code to use this whole structure would then look something like this:
KNewUserWizard* wizard = new KNewUserWizard(this, "NewUserWizard"); int rc = wizard->exec();
The return code of exec() is either QDialog::Accepted
or QDialog::Rejected
.
virtual KMyMoneyWizard::~KMyMoneyWizard | ( | ) | [inline, virtual] |
KMyMoneyWizard::KMyMoneyWizard | ( | QWidget * | parent = 0 , |
|
const char * | name = 0 , |
|||
bool | modal = false , |
|||
WFlags | f = 0 | |||
) | [protected] |
Constructor (kept protected, so that one cannot create such an object directly)
void KMyMoneyWizard::setTitle | ( | const QString & | txt | ) |
Modify the title of the wizard to be txt
.
txt | The text that should be used as title |
void KMyMoneyWizard::addStep | ( | const QString & | text | ) |
Add step text
to the wizard
text | Text to be shown for this step |
QValueList<KMyMoneyWizardPage*> KMyMoneyWizard::historyPages | ( | void | ) | const [inline] |
void KMyMoneyWizard::reselectStep | ( | void | ) |
This method repeats selection of the current step in the step frame. This is used to allow changes made to showing and hiding pages to immediately to be reflected in the step frame
void KMyMoneyWizard::setHelpContext | ( | const QString & | ctx | ) | [inline] |
Setup a global help context for the wizard. It will be used whenever there is no specific help context available for the current page.
void KMyMoneyWizard::createPayee | ( | const QString & | txt, | |
QString & | id | |||
) | [signal] |
This signal is sent out, when a new payee needs to be created
txt | The name of the payee to be created | |
id | A connected slot should store the id of the created object in this variable |
void KMyMoneyWizard::createCategory | ( | const QString & | txt, | |
QString & | id | |||
) | [signal] |
This signal is sent out, when a new category needs to be created
txt | The name of the category to be created | |
id | A connected slot should store the id of the created object in this variable |
void KMyMoneyWizard::setFirstPage | ( | KMyMoneyWizardPage * | page | ) | [protected] |
This method sets up the first page after creation of the object
page | pointer to first page of wizard |
void KMyMoneyWizard::setStepHidden | ( | unsigned int | step, | |
bool | hidden = true | |||
) | [protected] |
This method allows to hide or show a step
.
step | step to be shown/hidden | |
hidden | hide step if true (the default) or show it if false |
virtual void KMyMoneyWizard::accept | ( | void | ) | [protected, virtual, slot] |
void KMyMoneyWizard::completeStateChanged | ( | void | ) | [protected, slot] |
void KMyMoneyWizard::updateStepCount | ( | void | ) | [private] |
void KMyMoneyWizard::backButtonClicked | ( | void | ) | [private, slot] |
void KMyMoneyWizard::nextButtonClicked | ( | void | ) | [private, slot] |
void KMyMoneyWizard::helpButtonClicked | ( | void | ) | [private, slot] |
void KMyMoneyWizard::switchPage | ( | KMyMoneyWizardPage * | oldPage | ) | [private] |
Switch to page which is currently the top of the history stack. oldPage
is a pointer to the current page or 0 if no page is shown.
oldPage | pointer to currently displayed page |
void KMyMoneyWizard::selectStep | ( | unsigned int | step | ) | [private] |
This method selects the step given by step
.
step | step to be selected |
friend class KMyMoneyWizardPage [friend] |
KPushButton* KMyMoneyWizard::m_cancelButton [protected] |
KPushButton* KMyMoneyWizard::m_backButton [protected] |
KPushButton* KMyMoneyWizard::m_nextButton [protected] |
KPushButton* KMyMoneyWizard::m_finishButton [protected] |
KPushButton* KMyMoneyWizard::m_helpButton [protected] |
QVBoxLayout* KMyMoneyWizard::m_wizardLayout [private] |
QVBoxLayout* KMyMoneyWizard::m_stepLayout [private] |
QVBoxLayout* KMyMoneyWizard::m_pageLayout [private] |
QHBoxLayout* KMyMoneyWizard::m_buttonLayout [private] |
QFrame* KMyMoneyWizard::m_stepFrame [private] |
QLabel* KMyMoneyWizard::m_stepLabel [private] |
QPalette KMyMoneyWizard::m_stepPalette [private] |
QValueList<QLabel*> KMyMoneyWizard::m_steps [private] |
int KMyMoneyWizard::m_step [private] |
KMyMoneyTitleLabel* KMyMoneyWizard::m_titleLabel [private] |
QValueList<KMyMoneyWizardPage*> KMyMoneyWizard::m_history [private] |
QString KMyMoneyWizard::m_helpContext [private] |