Version: 9.12.0
QtxWorkstack Class Reference

Workstack widget. More...

#include <QtxWorkstack.h>

Inheritance diagram for QtxWorkstack:
Inheritance graph

Public Types

enum  {
  SplitVertical = 0x01 , SplitHorizontal = 0x02 , Close = 0x04 , Rename = 0x08 ,
  All
}
 Workstack actions (context menu items) More...
 
enum  { VersionMarker = 0x01 , SplitMarker = 0x02 , AreaMarker = 0x04 , WidgetMarker = 0x08 }
 
enum  { Horizontal = 0x01 , Visible = 0x02 }
 
enum  SplitType { SplitStay , SplitAt , SplitMove }
 Workstack splitting type. More...
 

Public Slots

void splitVertical ()
 Split widgets vertically. More...
 
void splitHorizontal ()
 Split widgets horizontally. More...
 

Signals

void windowActivated (QWidget *)
 Emitted when the workstack's child widget \w is activated. More...
 

Public Member Functions

 QtxWorkstack (QWidget *=0)
 Constructor. More...
 
virtual ~QtxWorkstack ()
 Destructor. More...
 
QWidgetList windowList (QWidget *=0) const
 Get list of all widgets in all areas or in specified area which given widget belongs to. More...
 
QWidgetList splitWindowList () const
 Get all child widgets in the active workarea. More...
 
QWidgetactiveWindow () const
 Get active widget. More...
 
void setActiveWindow (QWidget *)
 Set active widget. More...
 
int accel (const int) const
 Get the action's accelerator key-combination. More...
 
void setAccel (const int, const int)
 Set accelerator key-combination for the action with specified id. More...
 
QIcon icon (const int) const
 Get icon for the specified action. More...
 
void setIcon (const int, const QIcon &)
 Set menu item icon for the specified action. More...
 
void setMenuActions (const int)
 Set actions to be visible in the context popup menu. More...
 
int menuActions () const
 Set actions to be visible in the context popup menu. More...
 
void stack ()
 Group all windows in one area. More...
 
void split (const int)
 Split workstack. More...
 
bool move (QWidget *wid, QWidget *wid_to, const bool before)
 Moves the first widget to the same area which the second widget belongs to. More...
 
QWidgetaddWindow (QWidget *, Qt::WindowFlags=0)
 Add child widget. More...
 
QByteArray saveState (int) const
 Dump workstack configuration to the state description array. More...
 
bool restoreState (const QByteArray &, int)
 Restore workstack configuration from the state description array. More...
 
void setOpaqueResize (bool=true)
 Set resize mode of all splitters opaque or transparent. More...
 
bool opaqueResize () const
 Get resize mode of all splitters: opaque (true) or transparent (false). More...
 
void splittersVisible (QWidget *, bool=true)
 Show/hide splitters state and area. More...
 
void Split (QWidget *wid, const Qt::Orientation o, const SplitType type)
 Split workarea of the given widget on two parts. More...
 
void Attract (QWidget *wid1, QWidget *wid2, const bool all)
 Move widget(s) from the source workarea into the target workarea or reorder widgets inside one workarea. More...
 
void SetRelativePosition (QWidget *wid, const Qt::Orientation o, const double pos)
 Set position of the widget relatively to the entire workstack. More...
 
void SetRelativePositionInSplitter (QWidget *wid, const double pos)
 Set position of the widget relatively to its parent splitter. More...
 
void updateState ()
 Update internal state. More...
 

Protected Member Functions

virtual void customEvent (QEvent *)
 Handle custom events. More...
 
QActionaction (const int) const
 
void saveState (QDataStream &) const
 
bool restoreState (QDataStream &)
 

Private Slots

void onRename ()
 Called when user activates "Rename" menu item. More...
 
void onCloseWindow ()
 Close active window. More...
 
void onDestroyed (QObject *)
 Called when workarea is destroyed. More...
 
void onWindowActivated (QWidget *)
 Called on window activating. More...
 
void onContextMenuRequested (QWidget *, QPoint)
 Create and show popup menu for workarea. More...
 
void onDeactivated (QtxWorkstackArea *)
 Called on window deactivating. More...
 

Private Member Functions

QSplittersplitter (QtxWorkstackArea *) const
 Get splitter corresponding to the workarea. More...
 
void splitters (QSplitter *, QList< QSplitter * > &, const bool=false) const
 Get list of child splitters. More...
 
void areas (QSplitter *, QList< QtxWorkstackArea * > &, const bool=false) const
 Get list of child workareas. More...
 
QSplitterwrapSplitter (QtxWorkstackArea *)
 Wrap area into the new splitter. More...
 
void insertWidget (QWidget *, QWidget *, QWidget *)
 Reparent and add widget. More...
 
QtxWorkstackAreaareaAt (const QPoint &) const
 Get workarea covering point. More...
 
QtxWorkstackAreawgArea (QWidget *) const
 Gets area containing given widget. More...
 
QtxWorkstackAreatargetArea ()
 Get target area (for which the current operation should be done). More...
 
QtxWorkstackAreaactiveArea () const
 Get active workarea. More...
 
QtxWorkstackAreacurrentArea () const
 Get current workarea. More...
 
void setActiveArea (QtxWorkstackArea *)
 Set active workarea. More...
 
QtxWorkstackAreaneighbourArea (QtxWorkstackArea *) const
 Get workarea which is nearest to area. More...
 
QtxWorkstackAreacreateArea (QWidget *) const
 Create new workarea. More...
 
void updateState (QSplitter *)
 Update splitter state. More...
 
void splitterVisible (QWidget *, QList< QSplitter * > &, QSplitter *, bool)
 Show/hide splitter state and area. More...
 
void distributeSpace (QSplitter *) const
 Redistribute space among widgets equally. More...
 
int setPosition (QWidget *wid, QSplitter *split, const Qt::Orientation o, const int need_pos, const int splitter_pos)
 Set position of the widget. More...
 

Private Attributes

QPointer< QWidgetmyWin
 active widget More...
 
QPointer< QtxWorkstackAreamyArea
 active workarea More...
 
QtxWorkstackSplittermySplit
 tol-level splitter More...
 
QPointer< QWidgetmyWorkWin
 widget where popup menu is invoked (used internally) More...
 
QPointer< QtxWorkstackAreamyWorkArea
 workarea where popup menu is invoked (used internally) More...
 
QMap< int, QAction * > myActionsMap
 actions map More...
 

Friends

class QtxWorkstackArea
 
class QtxWorkstackDrag
 
class QtxWorkstackAction
 
class QtxWorkstackSplitter
 

Detailed Description

Workstack widget.

Organizes the child widgets in the tabbed space. Allows splitting the working area to arrange the child widgets in arbitrary way. Any widgets can be moved to another working area with drag-n-drop operation.

This widget can be used as workspace of the application main window, for example, as kind of implementation of multi-document interface.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Workstack actions (context menu items)

Enumerator
SplitVertical 

"Split vertically" menu item

SplitHorizontal 

"Split horizontally" menu item

Close 

"Close" menu item

Rename 

"Rename" menu item

All 

all menu items

◆ anonymous enum

anonymous enum
Enumerator
VersionMarker 
SplitMarker 
AreaMarker 
WidgetMarker 

◆ anonymous enum

anonymous enum
Enumerator
Horizontal 
Visible 

◆ SplitType

Workstack splitting type.

Enumerator
SplitStay 

selected widget stays in current workarea, others widgets are moved into a new workarea

SplitAt 

all widgets before selected widget stay in current workarea, other widgess are moved into a new workarea

SplitMove 

selected widget is moved into a new workarea, all other widgets stay in an old workarea

Constructor & Destructor Documentation

◆ QtxWorkstack()

QtxWorkstack::QtxWorkstack ( QWidget parent = 0)

◆ ~QtxWorkstack()

QtxWorkstack::~QtxWorkstack ( )
virtual

Destructor.

Member Function Documentation

◆ accel()

int QtxWorkstack::accel ( const int  id) const

Get the action's accelerator key-combination.

Parameters
idaction ID
Returns
action accelerator

References myActionsMap.

◆ action()

QAction * QtxWorkstack::action ( const int  id) const
protected

References myActionsMap.

◆ activeArea()

QtxWorkstackArea * QtxWorkstack::activeArea ( ) const
private

Get active workarea.

Returns
active workarea

References myArea.

◆ activeWindow()

QWidget * QtxWorkstack::activeWindow ( ) const

Get active widget.

Returns
active widget

References myWin.

◆ addWindow()

QWidget * QtxWorkstack::addWindow ( QWidget w,
Qt::WindowFlags  f = 0 
)

Add child widget.

Parameters
wwidget
fwidget flags
Returns
child widget container

References QtxWorkstackArea::insertWidget(), and targetArea().

◆ areaAt()

QtxWorkstackArea * QtxWorkstack::areaAt ( const QPoint &  p) const
private

Get workarea covering point.

Returns
workarea
Parameters
ppoint

References areas(), and mySplit.

◆ areas()

void QtxWorkstack::areas ( QSplitter split,
QList< QtxWorkstackArea * > &  areaList,
const bool  rec = false 
) const
private

Get list of child workareas.

Parameters
splitparent splitter
areaListlist to be filled with child workareas
recif true, perform recursive search of children

References split().

◆ Attract()

void QtxWorkstack::Attract ( QWidget wid1,
QWidget wid2,
const bool  all 
)

Move widget(s) from the source workarea into the target workarea or reorder widgets inside one workarea.

Move wid2 in target workarea. Put it right after wid1. If all parameter is true, all widgets from source workarea will be moved including wid2 and source workarea will be deleted then.

If wid1 and wid2 belongs to one workarea, widgets will be just reordered in that workarea.

Parameters
wid1widget from target workarea
wid2widget from source workarea
allif true, all widgets from source workarea will be moved into the target one, else only the wid2 will be moved

References QtxWorkstackArea::activeWidget(), areas(), distributeSpace(), QtxWorkstackArea::insertWidget(), mySplit, QtxWorkstackArea::removeWidget(), QtxWorkstackArea::setActiveWidget(), splitter(), and QtxWorkstackArea::widgetList().

◆ createArea()

QtxWorkstackArea * QtxWorkstack::createArea ( QWidget parent) const
private

Create new workarea.

Parameters
parentparent widget
Returns
created workarea

References onContextMenuRequested(), onDeactivated(), onDestroyed(), onWindowActivated(), and QtxWorkstackArea.

◆ currentArea()

QtxWorkstackArea * QtxWorkstack::currentArea ( ) const
private

Get current workarea.

Current workarea is that one which has input focus.

Returns
current area

◆ customEvent()

void QtxWorkstack::customEvent ( QEvent )
protectedvirtual

Handle custom events.

Parameters
ecustom event (not used)

References updateState().

◆ distributeSpace()

void QtxWorkstack::distributeSpace ( QSplitter split) const
private

Redistribute space among widgets equally.

Parameters
splitsplitter

References Horizontal, and split().

◆ icon()

QIcon QtxWorkstack::icon ( const int  id) const

Get icon for the specified action.

If id is invalid, null icon is returned.

Parameters
idmenu action ID
Returns
menu item icon

References myActionsMap.

◆ insertWidget()

void QtxWorkstack::insertWidget ( QWidget wid,
QWidget pWid,
QWidget after 
)
private

Reparent and add widget.

Parameters
widwidget
pWidparent widget
afterwidget after which wid should be added

◆ menuActions()

int QtxWorkstack::menuActions ( ) const

Set actions to be visible in the context popup menu.

Actions, which IDs are set in flags parameter, will be shown in the context popup menu. Other actions will not be shown.

Parameters
flagsORed together actions flags

References Close, myActionsMap, Rename, SplitHorizontal, and SplitVertical.

◆ move()

bool QtxWorkstack::move ( QWidget wid,
QWidget wid_to,
const bool  before 
)

Moves the first widget to the same area which the second widget belongs to.

Parameters
widwidget to be moved
wid_towidget specified the destination area
beforespecifies whether the first widget has to be moved before or after the second widget
Returns
true if operation is completed successfully, false otherwise

References QtxWorkstackArea::insertWidget(), QtxWorkstackArea::removeWidget(), wgArea(), and QtxWorkstackArea::widgetList().

◆ neighbourArea()

QtxWorkstackArea * QtxWorkstack::neighbourArea ( QtxWorkstackArea area) const
private

Get workarea which is nearest to area.

Parameters
areaarea for which neighbour is searched
Returns
neighbour area (or 0 if not found)

References areas(), and mySplit.

◆ onCloseWindow

void QtxWorkstack::onCloseWindow ( )
privateslot

Close active window.

References activeWindow(), and myWorkWin.

◆ onContextMenuRequested

void QtxWorkstack::onContextMenuRequested ( QWidget w,
QPoint  p 
)
privateslot

Create and show popup menu for workarea.

Parameters
wworkarea
ppopup position

References activeArea(), Close, myActionsMap, myWorkArea, myWorkWin, Rename, Qtx::simplifySeparators(), SplitHorizontal, SplitVertical, and QtxWorkstackArea::widgetList().

◆ onDeactivated

void QtxWorkstack::onDeactivated ( QtxWorkstackArea area)
privateslot

Called on window deactivating.

Parameters
areaworkarea being deactivated

References QtxWorkstackArea::activeWidget(), areas(), myArea, mySplit, myWin, and neighbourArea().

◆ onDestroyed

void QtxWorkstack::onDestroyed ( QObject obj)
privateslot

Called when workarea is destroyed.

Set input focus to the neighbour area.

Parameters
objworkarea being destroyed

References myArea, and neighbourArea().

◆ onRename

void QtxWorkstack::onRename ( )
privateslot

Called when user activates "Rename" menu item.

Changes widget title.

References myWorkWin.

◆ onWindowActivated

void QtxWorkstack::onWindowActivated ( QWidget )
privateslot

Called on window activating.

Parameters
areaworkarea being activated (not used)

References setActiveArea().

◆ opaqueResize()

bool QtxWorkstack::opaqueResize ( ) const

Get resize mode of all splitters: opaque (true) or transparent (false).

Returns
current opaque mode

References mySplit.

◆ restoreState() [1/2]

bool QtxWorkstack::restoreState ( const QByteArray &  state,
int  version 
)

Restore workstack configuration from the state description array.

Parameters
versionnumber
Returns
restore performing state

References VersionMarker.

◆ restoreState() [2/2]

bool QtxWorkstack::restoreState ( QDataStream &  stream)
protected

◆ saveState() [1/2]

QByteArray QtxWorkstack::saveState ( int  version) const

Dump workstack configuration to the state description array.

Parameters
versionnumber
Returns
state byte array.

References VersionMarker.

◆ saveState() [2/2]

void QtxWorkstack::saveState ( QDataStream &  stream) const
protected

◆ setAccel()

void QtxWorkstack::setAccel ( const int  id,
const int  accel 
)

Set accelerator key-combination for the action with specified id.

Parameters
idaction ID
accelaction accelerator

References accel(), and myActionsMap.

◆ setActiveArea()

void QtxWorkstack::setActiveArea ( QtxWorkstackArea area)
private

Set active workarea.

Parameters
workarea

References myArea, myWin, QtxWorkstackArea::updateActiveState(), and windowActivated().

◆ setActiveWindow()

void QtxWorkstack::setActiveWindow ( QWidget wid)

Set active widget.

Parameters
widwidget to activate

References activeArea(), and QtxWorkstackArea::setActiveWidget().

◆ setIcon()

void QtxWorkstack::setIcon ( const int  id,
const QIcon &  icon 
)

Set menu item icon for the specified action.

Parameters
idmenu action ID
iconew menu item icon

References icon(), and myActionsMap.

◆ setMenuActions()

void QtxWorkstack::setMenuActions ( const int  flags)

Set actions to be visible in the context popup menu.

Actions, which IDs are set in flags parameter, will be shown in the context popup menu. Other actions will not be shown.

Parameters
flagsORed together actions flags

References Close, myActionsMap, Rename, SplitHorizontal, and SplitVertical.

◆ setOpaqueResize()

void QtxWorkstack::setOpaqueResize ( bool  opaque = true)

Set resize mode of all splitters opaque or transparent.

Parameters
opaqueopaque mode

References mySplit, split(), and splitters().

◆ setPosition()

int QtxWorkstack::setPosition ( QWidget wid,
QSplitter split,
const Qt::Orientation  o,
const int  need_pos,
const int  splitter_pos 
)
private

Set position of the widget.

Called from SetRelativePosition() public method.

Parameters
widwidget to be moved
splitcurrently processed splitter (goes from more common to more particular splitter in recursion calls)
oorientation of positioning
need_posrequired position of the given widget in pixels (from top/left side of workstack area)
splitter_posposition of the splitter split (from top/left side of workstack area)
Returns
difference between a required and a distinguished position

References areas(), QtxWorkstackArea::contains(), Horizontal, positionSimple(), setSizes(), and split().

◆ SetRelativePosition()

void QtxWorkstack::SetRelativePosition ( QWidget wid,
const Qt::Orientation  o,
const double  position 
)

Set position of the widget relatively to the entire workstack.

If o is Qt::Horizontal, the horizontal position of wid will be changed. If o is Qt::Vertical, the vertical position of wid will be changed.

Parameters
widwidget
oorientation of positioning (Qt::Horizontal or Qt::Vertical)
posposition relatively to the workstack; value in range [0..1]

References Horizontal, mySplit, and setPosition().

◆ SetRelativePositionInSplitter()

void QtxWorkstack::SetRelativePositionInSplitter ( QWidget wid,
const double  position 
)

Set position of the widget relatively to its parent splitter.

Orientation of positioning will correspond to the splitter orientation.

Parameters
widwidget
posposition relatively to the splitter; value in the range [0..1]

References areas(), Horizontal, mySplit, setSizes(), split(), and splitter().

◆ split()

void QtxWorkstack::split ( const int  o)

Split workstack.

Splitting is possible only if there are two or more widgets in the workarea. This function splits current workarea to two new ones.

Parameters
osplitting orientation (Qt::Orientation)

References activeArea(), QtxWorkstackArea::activeWidget(), areas(), createArea(), distributeSpace(), QtxWorkstackArea::insertWidget(), myWorkArea, QtxWorkstackArea::removeWidget(), splitter(), splitters(), QtxWorkstackArea::widgetList(), and wrapSplitter().

◆ Split()

void QtxWorkstack::Split ( QWidget wid,
const Qt::Orientation  o,
const SplitType  type 
)

Split workarea of the given widget on two parts.

Splitting is possible only if there are two or more widgets in the workarea. This function splits current workarea to two new ones.

Parameters
widwidget belonging to the workstack
osplitting orientation type (Qt::Orientation)
typesplitting type (QtxWorkstack::SplitType)

References QtxWorkstackArea::activeWidget(), areas(), createArea(), distributeSpace(), QtxWorkstackArea::insertWidget(), insertWidget(), mySplit, QtxWorkstackArea::removeWidget(), SplitAt, SplitMove, SplitStay, splitter(), splitters(), QtxWorkstackArea::widgetList(), and wrapSplitter().

◆ splitHorizontal

void QtxWorkstack::splitHorizontal ( )
slot

Split widgets horizontally.

References split(), and Vertical.

◆ splitter()

QSplitter * QtxWorkstack::splitter ( QtxWorkstackArea area) const
private

Get splitter corresponding to the workarea.

Parameters
workarea
Returns
splitter corresponding to the workarea

References split().

◆ splitters()

void QtxWorkstack::splitters ( QSplitter split,
QList< QSplitter * > &  splitList,
const bool  rec = false 
) const
private

Get list of child splitters.

Parameters
splitparent splitter
splitListlist to be filled with child splitters
recif true, perform recursive search of children

References split().

◆ splittersVisible()

void QtxWorkstack::splittersVisible ( QWidget wid,
bool  visible = true 
)

Show/hide splitters state and area.

Parameters
widwidget (and parent area) will be shown/hidden
visiblesplitters

References mySplit, and splitterVisible().

◆ splitterVisible()

void QtxWorkstack::splitterVisible ( QWidget wid,
QList< QSplitter * > &  parent_list,
QSplitter split,
bool  visible 
)
private

Show/hide splitter state and area.

Parameters
widwidget (and parent area) will be shown/hidden
parent_listparent splitters list
splitsplitter will be shown/hidden
visiblesplitter

References areas(), QtxWorkstackArea::childList(), mySplit, QtxWorkstackArea::showTabBar(), split(), splitter(), and splitters().

◆ splitVertical

void QtxWorkstack::splitVertical ( )
slot

Split widgets vertically.

References Horizontal, and split().

◆ splitWindowList()

QWidgetList QtxWorkstack::splitWindowList ( ) const

Get all child widgets in the active workarea.

Returns
list of widgets in active workarea

References myArea.

◆ stack()

void QtxWorkstack::stack ( )

Group all windows in one area.

Returns
true if operation is completed successfully, false otherwise

References QtxWorkstackArea::insertWidget(), QtxWorkstackArea::removeWidget(), wgArea(), and windowList().

◆ targetArea()

QtxWorkstackArea * QtxWorkstack::targetArea ( )
private

Get target area (for which the current operation should be done).

Returns active workarea or current area (if there is no active workarea). If there are no workareas, create new workarea and return it.

Returns
workarea

References activeArea(), areas(), createArea(), currentArea(), and mySplit.

◆ updateState() [1/2]

void QtxWorkstack::updateState ( )

Update internal state.

References mySplit.

◆ updateState() [2/2]

void QtxWorkstack::updateState ( QSplitter split)
private

Update splitter state.

Parameters
splitsplitter to be updated

References areas(), mySplit, split(), splitters(), and updateState().

◆ wgArea()

QtxWorkstackArea * QtxWorkstack::wgArea ( QWidget wid) const
private

Gets area containing given widget.

Parameters
widwidget
Returns
pointer to QtxWorkstackArea* object

References areas(), and mySplit.

◆ windowActivated

void QtxWorkstack::windowActivated ( QWidget w)
signal

Emitted when the workstack's child widget \w is activated.

Parameters
wwidget being activated

◆ windowList()

QWidgetList QtxWorkstack::windowList ( QWidget wid = 0) const

Get list of all widgets in all areas or in specified area which given widget belongs to.

Parameters
widwidget specifying area if it is equal to null when widgets of all areas are retuned
Returns
list of widgets

References areas(), mySplit, and wgArea().

◆ wrapSplitter()

QSplitter * QtxWorkstack::wrapSplitter ( QtxWorkstackArea area)
private

Wrap area into the new splitter.

Parameters
workarea
Returns
new splitter

References QtxWorkstackSplitter, and splitter().

Friends And Related Function Documentation

◆ QtxWorkstackAction

friend class QtxWorkstackAction
friend

◆ QtxWorkstackArea

friend class QtxWorkstackArea
friend

◆ QtxWorkstackDrag

friend class QtxWorkstackDrag
friend

◆ QtxWorkstackSplitter

friend class QtxWorkstackSplitter
friend

Member Data Documentation

◆ myActionsMap

QMap<int, QAction*> QtxWorkstack::myActionsMap
private

actions map

◆ myArea

QPointer<QtxWorkstackArea> QtxWorkstack::myArea
private

active workarea

◆ mySplit

QtxWorkstackSplitter* QtxWorkstack::mySplit
private

tol-level splitter

◆ myWin

QPointer<QWidget> QtxWorkstack::myWin
private

active widget

◆ myWorkArea

QPointer<QtxWorkstackArea> QtxWorkstack::myWorkArea
private

workarea where popup menu is invoked (used internally)

◆ myWorkWin

QPointer<QWidget> QtxWorkstack::myWorkWin
private

widget where popup menu is invoked (used internally)


The documentation for this class was generated from the following files: