org.kde.koala

Class KJanusWidget

public class KJanusWidget extends QWidget

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. This class provides KJanusWidget.TreeList, KJanusWidget.IconList, KJanusWidget.Tabbed, KJanusWidget.Plain and KJanusWidget.Swallow layouts. 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. Pages that have been added in TreeList, IconList or Tabbed mode can be removed by simply deleting the page. However, it would be preferable to use the QObject.deleteLater() function on the page as the main event loop may have optimized UI update events of the page by scheduling them for later. See KJanusWidgetSignals for signals emitted by KJanusWidget

Author: Espen Sand (espen@kde.org)

UNKNOWN: Easy to use widget with many layouts.

Field Summary
static intIconList
static intPlain
static intSwallow
static intTabbed
static intTreeList
Constructor Summary
protected KJanusWidget(Class dummy)
KJanusWidget(QWidget parent, String name, int face)
Constructor where you specify the face.
KJanusWidget(QWidget parent, String name)
KJanusWidget(QWidget parent)
KJanusWidget()
Method Summary
intactivePageIndex()
Returns the index of the page that are currently displayed.
voidaddButtonBelowList(String text, QObject recv, String slot)
Add a button at the bottom of the TreeList/IconList.
voidaddButtonBelowList(KGuiItem guiitem, QObject recv, String slot)
The same as the above function, but with a KGuiItem providing the text and icon for the button at the bottom of the TreeList/IconList.
QGridaddGridPage(int n, int dir, String itemName, String header, QPixmap pixmap)
Add a new page when the class is used in either TreeList or Tabbed mode.
QGridaddGridPage(int n, int dir, String itemName, String header)
QGridaddGridPage(int n, int dir, String itemName)
QGridaddGridPage(int n, int dir, String[] items, String header, QPixmap pixmap)
This is like addGridPage just above, with the difference that the first element is a list of strings.
QGridaddGridPage(int n, int dir, String[] items, String header)
QGridaddGridPage(int n, int dir, String[] items)
QHBoxaddHBoxPage(String itemName, String header, QPixmap pixmap)
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
QHBoxaddHBoxPage(String itemName, String header)
QHBoxaddHBoxPage(String itemName)
QHBoxaddHBoxPage(String[] items, String header, QPixmap pixmap)
This is like addHBoxPage just above, with the difference that the first element is a list of strings.
QHBoxaddHBoxPage(String[] items, String header)
QHBoxaddHBoxPage(String[] items)
QFrameaddPage(String item, String header, QPixmap pixmap)
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
QFrameaddPage(String item, String header)
QFrameaddPage(String item)
QFrameaddPage(String[] items, String header, QPixmap pixmap)
This is like addPage just above, with the difference that the first element is a list of strings.
QFrameaddPage(String[] items, String header)
QFrameaddPage(String[] items)
protected voidaddPageWidget(QFrame page, String[] items, String header, QPixmap pixmap)
QVBoxaddVBoxPage(String item, String header, QPixmap pixmap)
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
QVBoxaddVBoxPage(String item, String header)
QVBoxaddVBoxPage(String item)
QVBoxaddVBoxPage(String[] items, String header, QPixmap pixmap)
This is like addVBoxPage just above, with the difference that the first element is a list of strings.
QVBoxaddVBoxPage(String[] items, String header)
QVBoxaddVBoxPage(String[] items)
voidaddWidgetBelowList(QWidget widget)
Add a widget at the bottom of the TreeList/IconList.
StringclassName()
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
booleaneventFilter(QObject o, QEvent e)
This function is used internally when in IconList mode.
intface()
Returns the face type.
protected voidfinalize()
Deletes the wrapped C++ instance
protected QWidgetFindParent()
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisValid()
Use this to verify that no memory allocation failed.
protected voidInsertTreeListItem(String[] items, QPixmap pixmap, QFrame page)
QMetaObjectmetaObject()
QSizeminimumSizeHint()
Returns the minimum size that must be made available for the widget so that UIs can be displayed properly
intpageIndex(QWidget widget)
Returns the index of a page created with addPage , addVBoxPage , addHBoxPage or addGridPage .
StringpageTitle(int index)
Returns the title string associated with a page index in TreeList or IconList mode.
QWidgetpageWidget(int index)
Returns the page widget associated with a page index or null if there is no such page.
QFrameplainPage()
Returns the empty widget that is available in Plain mode.
voidremovePage(QWidget page)
voidsetFocus()
Give the keyboard input focus to the widget.
voidsetFolderIcon(String[] path, QPixmap pixmap)
Sets the icon used in TreeList Mode for the given path.
voidsetIconListAllVisible(boolean state)
This function has only effect in IconList mode.
voidsetRootIsDecorated(boolean state)
This function has only effect in TreeList mode.
voidsetShowIconsInTreeList(boolean state)
This function has only effect in TreeList mode.
booleansetSwallowedWidget(QWidget widget)
Defines the widget to be swallowed.
voidsetTreeListAutoResize(boolean state)
This function has only effect in TreeList mode.
voidshowEvent(QShowEvent arg1)
Reimplemented to handle the splitter width when the the face is TreeList
booleanshowPage(int index)
Raises the page which was added by addPage().
protected booleanshowPage(QWidget w)
QSizesizeHint()
Returns the recommended size for the widget in order to be displayed properly.
voidunfoldTreeList(boolean persist)
This function has only effect in TreeList mode.
voidunfoldTreeList()

Field Detail

IconList

public static final int IconList

Plain

public static final int Plain

Swallow

public static final int Swallow

Tabbed

public static final int Tabbed

TreeList

public static final int TreeList

Constructor Detail

KJanusWidget

protected KJanusWidget(Class dummy)

KJanusWidget

public KJanusWidget(QWidget parent, String name, int face)
Constructor where you specify the face.

Parameters: parent Parent of the widget. name Widget name. face The kind of dialog, Use TreeList, Tabbed, Plain or Swallow.

UNKNOWN: Constructor where you specify the face.

KJanusWidget

public KJanusWidget(QWidget parent, String name)

KJanusWidget

public KJanusWidget(QWidget parent)

KJanusWidget

public KJanusWidget()

Method Detail

activePageIndex

public int activePageIndex()
Returns the index of the page that are currently displayed.

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

UNKNOWN: Returns the index of the page that are currently displayed.

addButtonBelowList

public void addButtonBelowList(String text, QObject recv, String slot)
Add a button at the bottom of the TreeList/IconList.

Parameters: text The text on the PushButton. recv The object that is to receive the signal when the button is clicked. slot The slot to connect to the clicked signal of the button.

UNKNOWN: Add a button at the bottom of the TreeList/IconList.

addButtonBelowList

public void addButtonBelowList(KGuiItem guiitem, QObject recv, String slot)
The same as the above function, but with a KGuiItem providing the text and icon for the button at the bottom of the TreeList/IconList.

Parameters: guiitem The text and icon on the PushButton. recv The object that is to receive the signal when the button is clicked. slot The slot to connect to the clicked signal of the button.

UNKNOWN: The same as the above function, but with a KGuiItem providing the text and icon for the button at the bottom of the TreeList/IconList.

addGridPage

public QGrid addGridPage(int n, int dir, String itemName, String header, QPixmap pixmap)
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. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

Parameters: n Specifies the number of columns if 'dir' is QGrid.Horizontal or the number of rows if 'dir' is QGrid.Vertical. dir Can be QGrid.Horizontal or QGrid.Vertical. itemName String used in the list or Tab item. header A longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead. pixmap Used in IconList mode or in TreeList 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.

UNKNOWN: Add a new page when the class is used in either TreeList or Tabbed mode.

addGridPage

public QGrid addGridPage(int n, int dir, String itemName, String header)

addGridPage

public QGrid addGridPage(int n, int dir, String itemName)

addGridPage

public QGrid addGridPage(int n, int dir, String[] items, String header, QPixmap pixmap)
This is like addGridPage just above, with the difference that the first element is a list of strings. These strings are used to form a path of folders down to the given page. The initial elements are names for the folders, while the last element is the name of the page. Note: This does yet only work for the TreeList face. Later this may be added for the IconList face too. In other faces than the TreeList, all the strings except the last one is ignored. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

UNKNOWN: This is like addGridPage just above, with the difference that the first element is a list of strings.

addGridPage

public QGrid addGridPage(int n, int dir, String[] items, String header)

addGridPage

public QGrid addGridPage(int n, int dir, String[] items)

addHBoxPage

public QHBox addHBoxPage(String itemName, String header, QPixmap pixmap)
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. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

Parameters: itemName String used in the list or Tab item. header A longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead. pixmap Used in IconList mode or in TreeList 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.

UNKNOWN: Add a new page when the class is used in TreeList, IconList or Tabbed mode.

addHBoxPage

public QHBox addHBoxPage(String itemName, String header)

addHBoxPage

public QHBox addHBoxPage(String itemName)

addHBoxPage

public QHBox addHBoxPage(String[] items, String header, QPixmap pixmap)
This is like addHBoxPage just above, with the difference that the first element is a list of strings. These strings are used to form a path of folders down to the given page. The initial elements are names for the folders, while the last element is the name of the page. Note: This does yet only work for the TreeList face. Later this may be added for the IconList face too. In other faces than the TreeList, all the strings except the last one is ignored. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

UNKNOWN: This is like addHBoxPage just above, with the difference that the first element is a list of strings.

addHBoxPage

public QHBox addHBoxPage(String[] items, String header)

addHBoxPage

public QHBox addHBoxPage(String[] items)

addPage

public QFrame addPage(String item, String header, QPixmap pixmap)
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. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

Parameters: item String used in the list or Tab item. header A longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead. pixmap Used in IconList mode or in TreeList 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.

UNKNOWN: Add a new page when the class is used in TreeList, IconList or Tabbed mode.

addPage

public QFrame addPage(String item, String header)

addPage

public QFrame addPage(String item)

addPage

public QFrame addPage(String[] items, String header, QPixmap pixmap)
This is like addPage just above, with the difference that the first element is a list of strings. These strings are used to form a path of folders down to the given page. The initial elements are names for the folders, while the last element is the name of the page. Note: This does yet only work for the TreeList face. Later this may be added for the IconList face too. In other faces than the TreeList, all the strings except the last one is ignored. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

UNKNOWN: This is like addPage just above, with the difference that the first element is a list of strings.

addPage

public QFrame addPage(String[] items, String header)

addPage

public QFrame addPage(String[] items)

addPageWidget

protected void addPageWidget(QFrame page, String[] items, String header, QPixmap pixmap)

addVBoxPage

public QVBox addVBoxPage(String item, String header, QPixmap pixmap)
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. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

Parameters: item String used in the list or Tab item. header A longer string used in TreeList and IconList mode to describe the contents of a page. If empty, the item string will be used instead. pixmap Used in IconList mode or in TreeList 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.

UNKNOWN: Add a new page when the class is used in TreeList, IconList or Tabbed mode.

addVBoxPage

public QVBox addVBoxPage(String item, String header)

addVBoxPage

public QVBox addVBoxPage(String item)

addVBoxPage

public QVBox addVBoxPage(String[] items, String header, QPixmap pixmap)
This is like addVBoxPage just above, with the difference that the first element is a list of strings. These strings are used to form a path of folders down to the given page. The initial elements are names for the folders, while the last element is the name of the page. Note: This does yet only work for the TreeList face. Later this may be added for the IconList face too. In other faces than the TreeList, all the strings except the last one is ignored. Deleting the returned frame will cause the listitem or tab to be removed (you can re-add a page with the same name later.

UNKNOWN: This is like addVBoxPage just above, with the difference that the first element is a list of strings.

addVBoxPage

public QVBox addVBoxPage(String[] items, String header)

addVBoxPage

public QVBox addVBoxPage(String[] items)

addWidgetBelowList

public void addWidgetBelowList(QWidget widget)
Add a widget at the bottom of the TreeList/IconList.

Parameters: widget The widget to be added. It will be reparented into the KJanusWidget, therefor it will be deleted with the KJanusWidget, too. To be on the save side just don't keep the pointer to this widget.

UNKNOWN: Add a widget at the bottom of the TreeList/IconList.

className

public String className()

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

eventFilter

public boolean eventFilter(QObject o, QEvent e)
This function is used internally when in IconList mode. If you reimplement this class a make your own event filter, make sure to call this function from your filter.

Parameters: o Object that has received an event. e The event.

UNKNOWN: This function is used internally when in IconList mode.

face

public int face()
Returns the face type.

Returns: The face type.

UNKNOWN: Returns the face type.

finalize

protected void finalize()
Deletes the wrapped C++ instance

FindParent

protected QWidget FindParent()

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

isValid

public boolean isValid()
Use this to verify that no memory allocation failed.

Returns: true if the widget was properly created.

UNKNOWN: Use this to verify that no memory allocation failed.

InsertTreeListItem

protected void InsertTreeListItem(String[] items, QPixmap pixmap, QFrame page)

metaObject

public QMetaObject metaObject()

minimumSizeHint

public QSize minimumSizeHint()
Returns the minimum size that must be made available for the widget so that UIs can be displayed properly

Returns: The minimum size.

UNKNOWN: Returns the minimum size that must be made available for the widget so that UIs can be displayed properly

pageIndex

public int pageIndex(QWidget widget)
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: widget The widget returned by addPage , addVBoxPage , addHBoxPage or addGridPage .

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

UNKNOWN: Returns the index of a page created with addPage , addVBoxPage , addHBoxPage or addGridPage .

pageTitle

public String pageTitle(int index)
Returns the title string associated with a page index in TreeList or IconList mode.

Parameters: index The index of the page or null if there is no such page.

See Also: KJanusWidget

UNKNOWN: Returns the title string associated with a page index in TreeList or IconList mode.

pageWidget

public QWidget pageWidget(int index)
Returns the page widget associated with a page index or null if there is no such page.

Parameters: index The index of the page.

See Also: KJanusWidget

UNKNOWN: Returns the page widget associated with a page index or null if there is no such page.

plainPage

public QFrame plainPage()
Returns the empty widget that is available in Plain mode.

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

UNKNOWN: Returns the empty widget that is available in Plain mode.

removePage

public void removePage(QWidget page)

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

UNKNOWN: Removes a page created with addPage, addVBoxPage, addHBoxPage or addGridPage. If the page has already been deleted or has already been removed, nothing happens. The widget itself is not deleted.

setFocus

public void setFocus()
Give the keyboard input focus to the widget.

UNKNOWN: Give the keyboard input focus to the widget.

setFolderIcon

public void setFolderIcon(String[] path, QPixmap pixmap)
Sets the icon used in TreeList Mode for the given path.

Parameters: path The path for which this icon should be shown. pixmap The icon used.

UNKNOWN: Sets the icon used in TreeList Mode for the given path.

setIconListAllVisible

public void setIconListAllVisible(boolean 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: state The 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.

UNKNOWN: This function has only effect in IconList mode.

setRootIsDecorated

public void setRootIsDecorated(boolean state)
This function has only effect in TreeList mode. This tells the widgets whether the root should be decorated. For details see QListView.setRootIsDecorated

Parameters: state Root will be decorated if true.

UNKNOWN: This function has only effect in TreeList mode.

setShowIconsInTreeList

public void setShowIconsInTreeList(boolean state)
This function has only effect in TreeList mode. This tells the widgets whether the icons given in the addPage, addVBoxPage, addHBoxPage, or addGridPage methods should be shown in the TreeList. Note: This method must be called before calling any of the methods which add icons to the page.

Parameters: state If true the icons are shown.

UNKNOWN: This function has only effect in TreeList mode.

setSwallowedWidget

public boolean 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: widget The widget to be swallowed. If 0, then an empty rectangle is displayed.

UNKNOWN: Defines the widget to be swallowed.

setTreeListAutoResize

public void setTreeListAutoResize(boolean 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: state The resize mode. If false (default) the TreeList keeps its current width when the widget becomes wider.

UNKNOWN: This function has only effect in TreeList mode.

showEvent

public void showEvent(QShowEvent arg1)
Reimplemented to handle the splitter width when the the face is TreeList

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

showPage

public boolean showPage(int index)
Raises the page which was added by addPage().

Parameters: index The index of the page you want to raise.

UNKNOWN: Raises the page which was added by addPage().

showPage

protected boolean showPage(QWidget w)

sizeHint

public QSize sizeHint()
Returns the recommended size for the widget in order to be displayed properly.

Returns: The recommended size.

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

unfoldTreeList

public void unfoldTreeList(boolean persist)
This function has only effect in TreeList mode. This tells the TreeList to unfold the whole tree so that all entries are visible. If the list is empty when you call this method newly created entries will not automatically be opened. If the persist flag is set opened entries cannot be closed again, though.

Parameters: persist If true the tree always stays unfolded.

UNKNOWN: This function has only effect in TreeList mode.

unfoldTreeList

public void unfoldTreeList()