class KJanusWidget

Easy to use widget with many layouts. More...

Definition#include <kjanuswidget.h>
InheritsQWidget (kdecore)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Slots

Protected Methods


Detailed Description

This class provides a number of ready to use layouts (faces). It is used as an internal widget in KDialogBase, but can also used as a widget of its own.

It provides TreeList, IconList, Tabbed, Plain and Swallow layouts.

The TreeList face provides a list in the left area and pages in the right. The area are separated by a movable splitter. The style is somewhat similar to the layout in the Control Center. A page is raised by selecting the corresponding tree list item.

The IconList face provides an icon list in the left area and pages in the right. For each entry the Icon is on top with the text below. The style is somewhat similar to the layout of the Eudora configuation dialog box. A page is raised by selecting the corresponding icon list item. The preferred icon size is 32x32 pixels.

The Tabbed face is a common tabbed widget. The procedure for creating a page is similar for creating a TreeList. This has the advantage that if your widget contain too many pages it is trivial to convert it into a TreeList. Just change the face in the KJanusWidget constructor to KJanusWidget::TreeList and you have a tree list layout instead.

The Plain face provides an empty widget (QFrame) where you can place your widgets. The KJanusWidget makes no assumptions regarding the contents so you are free to add whatever you want.

The Swallow face is provided in order to simplify the usage of existing widgets and to allow changing the visible widget. You specify the widget to be displayed by setSwallowedWidget . Your widget will be reparented inside the widget. You can specify a Null (0) widget. A empty space is then displayed.

For all modes it is important that you specify the QWidget::minimumSize on the page, plain widget or the swallowed widget. If you use a QLayout on the page, plain widget or the swallowed widget this will be taken care of automatically. The size is used when the KJanusWidget determines its own minimum size. You get the minimum size by using the minimumSizeHint or sizeHint methods.

 KJanusWidget ( QWidget *parent=0, const char *name=0, int face=Plain )

Constructor where you specify the face.

Parameters:
parentParent of the widget.
nameWidget name.
intface The kind of dialog, Use TreeList, Tabbed, Plain or Swallow.

KJanusWidget ()

Destructor.

bool  showPage ( int index )

Raises the page which was added by addPage().

@parame index The index of the page you want to raise.

int  activePageIndex ()

[const]

Retrieve the index of the page that are currently displayed.

Returns: The index or -1 if the face is not Tabbed, TreeList or IconList.

bool  isValid ()

[const]

Use this to verify that no memory allocation failed.

Returns: true if the widget was properly created.

int  face ()

[const]

Retrieve the face type.

Returns: The face type.

QSize  minimumSizeHint ()

[const virtual]

Retrieve the minimum size that must be made available for the widget so that UIs can be displayed properly

Returns: The minimum size.

QSize  sizeHint ()

[const virtual]

Returns the recommended size for the widget in order to be displayed properly.

Returns: The recommended size.

QFrameplainPage ()

Retrieve the empty widget that is available in Plain mode.

Returns: The widget or 0 if the face in not Plain.

QFrameaddPage (const QString &item,const QString &header=QString::null, const QPixmap &pixmap=QPixmap() )

Add a new page when the class is used in TreeList, IconList or Tabbed mode. The returned widget is empty and you must add your widgets as children to this widget. In most cases you must create a layout manager and associate it with this widget as well.

Parameters:
itemString used in the list or Tab item.
headerA longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead.
pixmapUsed in IconList mode. You should prefer a pixmap with size 32x32 pixels.

Returns: The empty page or 0 if the face is not TreeList, IconList or Tabbed.

QVBoxaddVBoxPage ( const QString &item, const QString &header=QString::null, const QPixmap &pixmap=QPixmap() )

Add a new page when the class is used in TreeList, IconList or Tabbed mode. The returned widget is empty and you must add your widgets as children to this widget. The returned widget is a QVBox so it contains a QVBoxLayout layout that lines up the child widgets are vertically.

Parameters:
itemString used in the list or Tab item.
headerA longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead.
pixmapUsed in IconList mode. You should prefer a pixmap with size 32x32 pixels.

Returns: The empty page or 0 if the face is not TreeList, IconList or Tabbed.

QHBoxaddHBoxPage ( const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap() )

Add a new page when the class is used in TreeList, IconList or Tabbed mode. The returned widget is empty and you must add your widgets as children to this widget. The returned widget is a QHBox so it contains a QHBoxLayout layout that lines up the child widgets are horizontally.

Parameters:
itemString used in the list or Tab item.
headerA longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead.
pixmapUsed in IconList mode. You should prefer a pixmap with size 32x32 pixels.

Returns: The empty page or 0 if the face is not TreeList, IconList or Tabbed.

QGridaddGridPage ( int n, QGrid::Direction dir, const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap() )

Add a new page when the class is used in either TreeList or Tabbed mode. The returned widget is empty and you must add your widgets as children to this widget. The returned widget is a QGrid so it contains a QGridLayout layout that places up the child widgets in a grid.

Parameters:
nSpecifies the number of columns if 'dir' is QGrid::Horizontal or the number of rows if 'dir' is QGrid::Vertical.
dirCan be QGrid::Horizontal or QGrid::Vertical.
itemString used in the list or Tab item.
headerA longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead.
pixmapUsed in IconList mode. You should prefer a pixmap with size 32x32 pixels.

Returns: The empty page or 0 if the face is not TreeList, IconList or Tabbed.

int  pageIndex ( QWidget *widget )

[const]

Returns the index of a page created with addPage , addVBoxPage , addHBoxPage or addGridPage . You can can compare this index with the value returned from activePageIndex if you need to do some page specific actions in your code.

The returned index will never change so you can safely use this function once and save the value.

Parameters:
widgetThe widget returned by addPage , addVBoxPage , addHBoxPage or addGridPage .

Returns: The index or -1 if the face is not Tabbed, TreeList or IconList

bool  setSwallowedWidget ( QWidget *widget )

Defines the widget to be swallowed.

This method can be used several times. Only the latest defined widget will be shown.

Parameters:
widgetThe widget to be swallowed. If 0, then an empty rectangle is displayed.

void  setTreeListAutoResize ( bool state )

This function has only effect in TreeList mode.

Defines how the tree list is resized when the widget is resized horizontally. By default the tree list keeps its width when the widget becomes wider.

Parameters:
stateThe resize mode. If false (default) the TreeList keeps its current width when the widget becomes wider.

void  setIconListAllVisible ( bool state )

This function has only effect in IconList mode.

Defines how the icon list widget is displayed. By default it is the widgets in the pages that decide the minimum height of the toplevel widget. A vertical scrollbar can be used in the icon list area.

Parameters:
stateThe visibility mode. If true, the minimum height is adjusted so that every icon in the list is visible at the same time. The vertical scrollbar will never be visible.

void  setFocus ()

[virtual slot]

Give the keyboard input focus to the widget.

void  showEvent ( QShowEvent * )

[protected virtual]

Reimplemented to handle the splitter width when the the face is TreeList

bool  eventFilter ( QObject *o, QEvent *e )

[protected virtual]

This function is used internally when in IconList mode. If you reimplment this class a make your own event filter, make sure to call this function from your filter.

Parameters:
oObject that has received an event.
eThe event.