qmdiWorkspace Class Reference

An advanced work space-widget, which is capable of changing menus and toolbars on the fly. More...

Inheritance diagram for qmdiWorkspace:

qmdiServer List of all members.

Public Slots

bool eventFilter (QObject *obj, QEvent *event)
 event filter for the tabbar
void workspaceChanged (QWidget *w)
 called when the active window in the workspace is changed [SLOT]
void tabBarChanged (int index)
 called when the a new tab bar changed [SLOT]
void windowDeleted (QObject *o)
 called when a window is closed [SLOT]
void on_middleMouse_pressed (int, QPoint)
 mouse middle button click callback
void on_rightMouse_pressed (int, QPoint)
 mouse right button click callback

Public Member Functions

 qmdiWorkspace (QWidget *parent=NULL, qmdiHost *host=NULL)
 default constructor
void addTab (QWidget *widget, QString name)
 add a new MDI client to the workspace
QWidget * currentWidget ()
 returns the current widget
const QWidget * cornerWidget (Qt::Corner corner=Qt::TopRightCorner)
 return the widget found in a corner
void setCornerWidget (QWidget *widget, Qt::Corner corner=Qt::TopRightCorner)
 set the widget at a corner of the widget
QWidget * widget (int i)
 return a widget by number
int currentIndex ()
 returns the index of the current active window
int count ()
 return the number of widgets available on the workspace
virtual void addClient (qmdiClient *client)
 add a new MDI client to the workspace
virtual int getClientsCount ()
 return the number of sub clients in this server
virtual qmdiClientgetClient (int i)
 return the number of sub clients in this server

Detailed Description

An advanced work space-widget, which is capable of changing menus and toolbars on the fly.

This class is a new MDI server, based on top of QWorkspace. It is built with a similar API to qmdiTabWidget and QTabWidget. Since the API is similar this means you can switch applications from QTabWidget to qmdiWorkspace in very small modifications to your code.

This class is also a valid qmdiServer, which means it will dynamically modify the main window menus and toolbars when a new child is selected.

The relations are:

When a new widget is selected on the qmdiServer (the user changes), the old widget is removed from the qmdiHost, and only then the new MDI client is added to the qmdiHost.

To use this class properly, insert it into a QMainWindow which also derives qmdiHost, and insert into it QWidgets which also derive qmdiClient.

Since:
0.0.3
See also:
qmdiTabBar


Constructor & Destructor Documentation

qmdiWorkspace::qmdiWorkspace ( QWidget *  parent = NULL,
qmdiHost host = NULL 
)

default constructor

Parameters:
parent the parent of this widget
host the MDI host to connect to
This is the default constructor of qmdiWorkspace. If no host is passed, the parent widget will be queried for the qmdiHost interface. This means that the easiest way to work with this class is to insert it into a qmdiHost derived QMainWindow.

The constructor also creates the tab bar, to make this widget look like a QTabWidget


Member Function Documentation

void qmdiWorkspace::addTab ( QWidget *  widget,
QString  name 
)

add a new MDI client to the workspace

Parameters:
widget the widget to be added to the workspace
name the name to be associated with this widget
This function does the job of adding an MDI client to the MDI server. It will do the job behind the scene of setting up the MDI client, and re-parenting it as needed. The name is generally the name you will see on the tabbar.

Since this class is API compatible to QTabWidget, is takes the same arguments.

See also:
QTabWidget::addTab( QWidget*, QString )

QWidget * qmdiWorkspace::currentWidget (  ) 

returns the current widget

Returns:
the currently selected widget
This function will return the widget which is currently active on the QWorkspace used internally, and the tab which is currently selected.

See also:
QWorkspace::activeWindow()

QTabWidget::currentWidget()

const QWidget * qmdiWorkspace::cornerWidget ( Qt::Corner  corner = Qt::TopRightCorner  ) 

return the widget found in a corner

Parameters:
corner corner to be queried
Returns:
the widget found in a specific corner
This function return the corner widget for the desired corner.

See also:
QTabWidget::cornerWidget( Qt::Corner )

void qmdiWorkspace::setCornerWidget ( QWidget *  widget,
Qt::Corner  corner = Qt::TopRightCorner 
)

set the widget at a corner of the widget

Parameters:
widget the widget to be stored
corner the corner in which the widget should be stored
Set the widget to be put on one of the corners of this widget. Usually used to put "close" or "new" buttons on the right or left of the widget.

See also:
QTabWidget::setCornerWidget( QWidget *, Qt:Corner )

QWidget * qmdiWorkspace::widget ( int  i  ) 

return a widget by number

Parameters:
i the number of the widget to search
Returns:
the widget with the specified index
This function returns the widget number i in the QWorkspace used internally.

See also:
QWorkspace::windowList()

int qmdiWorkspace::currentIndex (  ) 

returns the index of the current active window

Returns:
a number representing the id of the current active window
This function is made for compability with QTabWidget.

int qmdiWorkspace::count (  ) 

return the number of widgets available on the workspace

Returns the number of widgets (or windows) available. The number should be the same as the number of tabs seen on screen.

void qmdiWorkspace::addClient ( qmdiClient client  )  [virtual]

add a new MDI client to the workspace

Parameters:
client the client to be added to the workspace
Adds a MDI client to the MDI server. Internally calls addTab()

See also:
addTab

Implements qmdiServer.

int qmdiWorkspace::getClientsCount (  )  [virtual]

return the number of sub clients in this server

Return the number of sub-widgets in this server. Please note that this function can return also non-mdi clients.

This function return the value or QTabWidget::count()

Implements qmdiServer.

qmdiClient * qmdiWorkspace::getClient ( int  i  )  [virtual]

return the number of sub clients in this server

Parameters:
i the number of sub widget to return
Return the number of sub-widgets in this server. Please note that this function can return also non-mdi clients.

This function return the value or QTabWidget::widget(i)

Implements qmdiServer.

bool qmdiWorkspace::eventFilter ( QObject *  obj,
QEvent *  event 
) [slot]

event filter for the tabbar

Parameters:
obj the object which created the event
event the event to be processed
This function is used to catch when the user is clicking a tab. On earlier version, a new class has been used. Since version 0.0.4 a proper event filter is used, which reduces the amount of code and class count in the library.

The function will call the functions:

Future implementations might also re-order the tabs.

For more information read the documentation of QObject::installEventFilter.

Since:
0.0.4

void qmdiWorkspace::workspaceChanged ( QWidget *  w  )  [slot]

called when the active window in the workspace is changed [SLOT]

Parameters:
w the new window which has been focused
This slot is called when a new window is selected on the workspace. This slot will also select the new tab on the tab header as well as merge the MDI client menus and toolbars.

This slot is connected at the constructor.

void qmdiWorkspace::tabBarChanged ( int  index  )  [slot]

called when the a new tab bar changed [SLOT]

Parameters:
index the index of the client which was focused
This slot is called when the user selects a new tab on the tab header. It will select the corresponding window/widget in the workspace. This function will call will workspaceChanged() to ensure that the corresponding menus and toolbars are merged in.

This slot is connected at the constructor.

See also:
workspaceChanged( QWidget* )

void qmdiWorkspace::windowDeleted ( QObject *  o  )  [slot]

called when a window is closed [SLOT]

Parameters:
o the window which has been deleted from the workspace
This slot is called when a window is closed on the workspace.

This slot is connected when a window is added to the workspace.

void qmdiWorkspace::on_middleMouse_pressed ( int  i,
QPoint   
) [slot]

mouse middle button click callback

Parameters:
i number of client pressed
This function is connected to the mouse middle click even on the tabbar. It will try to close the client.

See also:
qmdiServer::tryCloseClient

void qmdiWorkspace::on_rightMouse_pressed ( int  i,
QPoint  p 
) [slot]

mouse right button click callback

Parameters:
i number of client pressed
p coordinate of the click event
This function is connected to the mouse right click even on the tabbar. This function will display a popup menu.

See also:
qmdiServer::showClientMenu


The documentation for this class was generated from the following files:
Generated on Fri Jun 29 21:56:34 2007 for qmdilib by  doxygen 1.5.1