class KNoteBook

KNoteBook. More...

Definition#include <knotebook.h>
InheritsKDialog
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members

Protected Slots

Signals


Detailed Description

KNoteBook is a tabbed dialog where each tab can have multiple pages. The widget has the advantages of both KTabCtl and QTabDialog plus some more.

Features:

- Multiple pages per tab with previous/next button and optional arrow buttons in the title..

- An optional popup menu which takes you to a specific page in a specific section (tab).

- Easy additions of Ok, Cancel, Default and Help buttons.

- Automatic resizing/repainting/repositioning of buttons. Not like QTabDialog where there is always an Ok button.

- Scrollable tab bar.

- Can be used as both modal/non-modal dialog and a child widget.

KNoteBook (QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0)

Constructs a KNoteBook.

A modal notebook can be created like this:


 KNoteBook *nb = new KNoteBook(this, "notebook", true);
 connect(nb, SIGNAL(okclicked()), SLOT(nb->hide()));
 connect(nb, SIGNAL(okclicked()), SLOT(readNewInput()));

A very simple program where the main window is a KNoteBook with one tab and one page inserted could look like this:


 int main(int argc, char **argv)
 {
   KApplication a(argc,argv,"knotebooktest");  // create an application object
   KNoteBook *nb = new KNoteBook(); // create the notebook
   nb->setCancelButton();           // add a Cancel button and connect it to the quit() slot
   QObject::connect( nb, SIGNAL(cancelclicked()), &a, SLOT(quit()) );
 
   QTab *tab = new QTab;            // create a QTab to hold the tab data
   tab->label = "A tab";
   tab->enabled = true;
   nb->addTab( tab );
   QLabel *l = new QLabel(nb);
   l->setAlignment(AlignCenter);
   l->setText("This is a QLabel as a page");
   l->setMinimumSize(400, 300);
   KWizardPage *p = new KWizardPage;
   p->w = l;
   p->title.setNum("A page title");
   p->enabled = true;
   nb->addPage( p );
 
   a.setMainWidget(nb);
   nb->adjustSize();
   nb->show();
   return a.exec();
 }

Parameters:
parentThe parent of the notebook.
nameThe internal name.
modalIf modal is true the notebook wil become a modal dialog.
fWindow flags.

See also: QDialog::QDialog

~KNoteBook ()

Destructor

int addTab (QTab *tab, KWizardPage *p = 0L)

Adds a new tab to the notebook and creates a new KWizard to hold the pages. The tabs are numbered from 0 to n where 0 is the tab first added and n is the tab last added. if you add 4 tabs the last tab will be number 3. Subsequent calls to addPage will add pages to this tab until a new call to addTab().

Parameters:
tabThe QTab containing the tab data.
pThe optional KWizardPage containing the page data.If 'p' is not 0 it will be added as a new page. This is equivalent to addPage (p);

Returns: Returns the id of the new tab.

int addPage (KWizardPage *p)

Adds a new page to the last added tab. The pages are numbered from 0 to n where 1 is the page first added and n is the page last added. Subsequent calls to addPage will add pages to the last added tab until a new call to addTab().

Parameters:
pThe KWizardPage containing the page data..

Returns: Returns the id of the new page. The id is relative to the KWizard, NOT the KNoteBook.

void gotoTab (int tab)

Turn to another tab. This method calls showSection to show the corresponding KWizard.

Parameters:
tabThe tab to turn to

void setCancelButton ()

Adds a Cancel button to the bottom of the dialog. The text will be a translated version of the string '&Cancel' thereby giving it the shortcut key 'c'. If any buttons are added a space will be created at the bottom of the dialog to fit the buttons. When clicked the button will emit the cancelclicked signal.

See also: translate

void setCancelButton (const char *text)

Adds a Cancel button to the bottom of the dialog.

Parameters:
textA user supplied text to write to the button.

void setDefaultButton ()

Adds a Default button to the bottom of the dialog. The text will be a translated version of the string '&Default' thereby giving it the shortcut key 'd'. If any buttons are added a space will be created at the bottom of the dialog to fit the buttons. When clicked the button will emit the defaultclicked signal.

See also: KLocal::translate

void setDefaultButton (const char *text)

Adds a Default button to the bottom of the dialog.

Parameters:
textA user supplied text to write to the button.

void setHelpButton ()

Adds a Help button to the bottom right of the dialog. The text will be a translated version of the string '&Help' thereby giving it the shortcut key 'h'. If any buttons are added a space will be created at the bottom of the dialog to fit the buttons. When clicked the button will emit the helpclicked signal.

void setHelpButton (const char *)

Adds a Help button to the bottom of the dialog. This button will generate the signal helpclicked where the int is the page to which the help was requested.

Parameters:
textA user supplied text to write to the button.

void setOkButton ()

Adds an Ok button to the bottom right of the dialog. The text will be a translated version of the string '&Ok' thereby giving it the shortcut key 'o'. If any buttons are added a space will be created at the bottom of the dialog to fit the buttons. When clicked the button will emit the okclicked signal.

void setOkButton (const char *)

Adds an Ok button to the bottom of the dialog. This button will generate the signal okclicked where the int is the page to which the help was requested.

Parameters:
textA user supplied text to write to the button.

QButton * getOkButton ()

Get Ok button.

Returns: Returns the Ok buttonwidget or 0L if no button is added.

QButton * getCancelButton ()

Get Cancel button.

Returns: Returns the Cancel buttonwidget or 0L if no button is added.

QButton * getDefaultButton ()

Get Default button.

Returns: Returns the Default buttonwidget or 0L if no button is added.

QButton * getHelpButton ()

Get Help button.

Returns: Returns the Help buttonwidget or 0L if no button is added.

void setDirectionsReflectsPage (bool state)

Let direction buttons reflect page.

Parameters:
stateIf state is true the direction buttons (Previous and Next) will have the title of the corresponding page.

See also: directionsReflectsPage

bool directionsReflectsPage ()

Returns: Returns whether the direction buttons reflects the title of the corresponding page.

See also: setDirectionsReflectsPage(bool, state)

void setEnablePopupMenu (bool state)

En/Disable the popup menu.

Parameters:
stateIf state is true a menu containing the pages in the wizard will popup when the user RMB-clicks on the page-title.

bool enablePopupMenu ()

Returns whether the menu is enabled or not.

Returns: 'true' if the menu is enabled, otherwise 'false'.

QPopupMenu * getMenu ()

Get the popup menu.

Returns: Returns the handle of the popup menu.

void setEnableArrowButtons (bool state)

En/Disable the arrowbuttons.

Parameters:
stateIf state is true two arrows will appear to the right of the title.

See also: enableArrowButtons, KWizard#setEnableArrowButtons.

bool enableArrowButtons ()

Returns: Returns whether the arrow buttons are enabled or not.

See also: setEnableArrowButtons, KWizard#enableArrowButtons.

KTabBar * getTabBar ()

Returns the handle of the tab bar.

int numTabs ()

Returns the number of tabs in the notebook.

void setTabEnabled (int tab, bool state)

En/Disable a tab in the notebook. If a tab is disabled it is not selectable from the tab bar. If the user reaches a disabled tab by traversing through the pages the notebook will jump to the next enabled tab.

bool isTabEnabled (int tab)

Returns: Returns whether the tab is enabled or not.

See also: setTabEnabled

void setPageEnabled (int tab, int page, bool state)

En/Disable a page in a section (tab) in the notebook

See also: setPageEnabled

bool isPageEnabled (int tab, int page)

Returns: Returns whether a page in a section (tab) is enabled or not.

See also: setTabEnabled

void okclicked ()
[signal]

This signal is emitted when the user clicks on the Ok button.

void cancelclicked ()
[signal]

This signal is emitted when the user clicks on the Cancel button.

void defaultclicked (int)
[signal]

This signal is emitted when the user clicks on the Default button.

void helpclicked (int)
[signal]

This signal is emitted when the user clicks on the Help button. The int is the page which was showing when help was requested.

See also: setHelpButton

void showSection (int)
[protected slot]

Called by gotoTab to show the appropriate KWizard.

void popupMenu (QPoint pos)
[protected slot]

If the menu is enabled by enablePopupMenu this method will let the menu popup at 'pos'.

void menuChoice (int)
[protected slot]

void menuChoiceRedirect (int)
[protected slot]

void directionButton (bool, bool)
[protected slot]

void okClicked ()
[protected slot]

void cancelClicked ()
[protected slot]

void defaultClicked ()
[protected slot]

void helpClicked ()
[protected slot]

void tabScroll ( ArrowType )
[protected slot]

void init ()
[protected]

void resizeEvent (QResizeEvent *)
[protected]

Reimplemented from QWidget

void paintEvent (QPaintEvent *)
[protected]

Reimplemented from QWidget

void setSizes ()
[protected]

QSize childSize ()
[protected]

KNoteBookProtected * pnote
[protected]

QList<KWizard> * sections
[protected]