#include <QPainter>
#include <QStyleOption>
-#include <QTextStream>
-#include <iostream>
-
#define DARK_COLOR_LIGHT 250
/*!
myAreaRect->hide();
}
+
/*
- \class QtxWorkstackAreaTitleButton
+ \class CloseButton
\brief Workstack area close button.
\internal
*/
+class CloseButton : public QAbstractButton
+{
+public:
+ CloseButton( QWidget* );
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void enterEvent( QEvent* );
+ void leaveEvent( QEvent* );
+ void paintEvent( QPaintEvent* );
+};
/*!
\brief Constructor
\internal
\param parent parent widget
*/
-QtxWorkstackAreaTitleButton::QtxWorkstackAreaTitleButton( QWidget* parent )
+CloseButton::CloseButton( QWidget* parent )
: QAbstractButton( parent )
{
setFocusPolicy( Qt::NoFocus );
\internal
\return size value
*/
-QSize QtxWorkstackAreaTitleButton::sizeHint() const
+QSize CloseButton::sizeHint() const
{
ensurePolished();
int dim = 0;
\internal
\return minimum size value
*/
-QSize QtxWorkstackAreaTitleButton::minimumSizeHint() const
+QSize CloseButton::minimumSizeHint() const
{
return sizeHint();
}
\internal
\param event mouse enter event
*/
-void QtxWorkstackAreaTitleButton::enterEvent( QEvent *event )
+void CloseButton::enterEvent( QEvent *event )
{
if ( isEnabled() )
update();
\internal
\param event mouse leave event
*/
-void QtxWorkstackAreaTitleButton::leaveEvent( QEvent *event )
+void CloseButton::leaveEvent( QEvent *event )
{
if( isEnabled() )
update();
\internal
\param event paint event
*/
-void QtxWorkstackAreaTitleButton::paintEvent( QPaintEvent* )
+void CloseButton::paintEvent( QPaintEvent* )
{
QPainter p( this );
myBar = new QtxWorkstackTabBar( top );
tl->addWidget( myBar, 1 );
- QtxWorkstackAreaTitleButton* close = new QtxWorkstackAreaTitleButton( top );
+ CloseButton* close = new CloseButton( top );
close->setIcon( style()->standardIcon( QStyle::SP_TitleBarCloseButton ) );
myClose = close;
tl->addWidget( myClose );
QApplication::instance()->removeEventFilter( this );
}
+/*!
+ \brief Check if workarea contains any widgets.
+ \return \c true if area is null (havn't any child widgets)
+*/
+bool QtxWorkstackArea::isNull() const
+{
+ return myList.isEmpty();
+}
+
/*!
\brief Check if workarea contains visible widgets.
\return \c true if area is empty (all child widgets are removed or now shown)
myChild.remove( wid );
if ( del )
- {
delete child( wid );
- if ( myList.isEmpty() )
- delete this;
- else
- updateState();
- }
+
+ if ( isNull() )
+ deleteLater();
else
updateState();
}
if ( e->type() == QEvent::WindowTitleChange || e->type() == QEvent::WindowIconChange )
emit captionChanged( this );
- if ( !e->spontaneous() && ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ) )
+ if ( !e->spontaneous() && e->type() == QEvent::ShowToParent )
emit shown( this );
- if ( !e->spontaneous() && ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ) )
+ if ( !e->spontaneous() && e->type() == QEvent::HideToParent )
emit hidden( this );
if ( e->type() == QEvent::FocusIn )
{
if ( !split )
return;
- //const QObjectList& objs = split->children();
- QObjectList objs;
- for(int si = 0; si < split->count(); si++) {
- objs.append((QObject*)split->widget(si));
- }
+
+ const QObjectList& objs = split->children();
QString sizesStr;
QList<int> sizes = split->sizes();
info += QString( "(splitter orientation=%1 sizes=%3 " ).arg( split->orientation() ).arg( sizesStr );
- for ( QObjectList::const_iterator it = objs.begin(); it != objs.end(); ++it )
+ for( int index = 0, count = split->count(); index < count; index++ )
{
- if ( (*it)->inherits( "QSplitter" ) )
- splitterInfo( (QSplitter*)*it, info );
- else if ( (*it)->inherits( "QtxWorkstackArea" ) )
+ QObject* obj = split->widget( index );
+ if ( obj->inherits( "QSplitter" ) )
+ splitterInfo( (QSplitter*)obj, info );
+ else if ( obj->inherits( "QtxWorkstackArea" ) )
{
- QtxWorkstackArea* area = (QtxWorkstackArea*)*it;
+ QtxWorkstackArea* area = (QtxWorkstackArea*)obj;
if ( area->isEmpty() )
continue;
info += QString( "(views active='%1'" ).arg( area->activeWidget()->objectName() );
#include <QTabBar>
#include <QEvent>
#include <QMap>
-#include <QAbstractButton>
class QAction;
class QSplitter;
friend class QtxWorkstackDrag;
};
-class QtxWorkstackAreaTitleButton : public QAbstractButton
-{
- Q_OBJECT
-public:
- QtxWorkstackAreaTitleButton( QWidget* );
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void enterEvent( QEvent* );
- void leaveEvent( QEvent* );
- void paintEvent( QPaintEvent* );
-};
-
class QtxWorkstackArea : public QFrame
{
Q_OBJECT
QtxWorkstackArea( QWidget* );
virtual ~QtxWorkstackArea();
+ bool isNull() const;
bool isEmpty() const;
QWidget* insertWidget( QWidget*, const int = -1, Qt::WindowFlags = 0 );