From: stv Date: Fri, 6 Jul 2007 09:25:59 +0000 (+0000) Subject: no message X-Git-Tag: qt4_porting_delivery_220807~116 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1cf82e74cbd02cebee9a22ff66911a5f93ab3afd;p=modules%2Fgui.git no message --- diff --git a/src/Qtx/QtxToolBar.cxx b/src/Qtx/QtxToolBar.cxx index edbf469e0..50972d29a 100644 --- a/src/Qtx/QtxToolBar.cxx +++ b/src/Qtx/QtxToolBar.cxx @@ -72,10 +72,6 @@ QtxToolBar::Watcher::Watcher( QtxToolBar* cont ) myState( true ), myEmpty( false ) { -/* - if ( myCont->mainWindow() ) - myState = myCont->mainWindow()->appropriate( myCont ); -*/ myCont->installEventFilter( this ); myVisible = myCont->isVisibleTo( myCont->parentWidget() ); @@ -208,18 +204,14 @@ void QtxToolBar::Watcher::updateVisibility() bool vis = false; - const QObjectList& objList = myCont->children(); - for ( QObjectList::const_iterator it = objList.begin(); it != objList.end() && !vis; ++it ) - { - QObject* obj = *it; - if ( !obj->isWidgetType() || !qstrcmp( "qt_dockwidget_internal", obj->objectName().toLatin1() ) ) - continue; + QList actList = myCont->actions(); - if ( obj->inherits( "QToolBarHandle" ) || obj->inherits( "QToolBarExtension" ) ) + for ( QList::const_iterator it = actList.begin(); it != actList.end() && !vis; ++it ) + { + if ( (*it)->isSeparator() ) continue; - QWidget* wid = (QWidget*)*it; - vis = wid->isVisibleTo( wid->parentWidget() ); + vis = (*it)->isVisible(); } QMainWindow* mw = myCont->mainWindow(); @@ -259,7 +251,9 @@ QtxToolBar::QtxToolBar( const bool watch, const QString& label, QWidget* parent { if ( watch ) myWatcher = new Watcher( this ); - setObjectName( label ); + + if ( QMainWindow* mw = ::qobject_cast( parent ) ) + mw->addToolBar( this ); } /*! @@ -272,7 +266,8 @@ QtxToolBar::QtxToolBar( const QString& label, QWidget* parent ) myWatcher( 0 ), myStretch( false ) { - setObjectName( label ); + if ( QMainWindow* mw = ::qobject_cast( parent ) ) + mw->addToolBar( this ); } /*! @@ -288,6 +283,9 @@ QtxToolBar::QtxToolBar( const bool watch, QWidget* parent ) { if ( watch ) myWatcher = new Watcher( this ); + + if ( QMainWindow* mw = ::qobject_cast( parent ) ) + mw->addToolBar( this ); } /*! @@ -299,6 +297,8 @@ QtxToolBar::QtxToolBar( QWidget* parent ) myWatcher( 0 ), myStretch( false ) { + if ( QMainWindow* mw = ::qobject_cast( parent ) ) + mw->addToolBar( this ); } /*! @@ -308,44 +308,6 @@ QtxToolBar::~QtxToolBar() { } -/*! - \brief Get the recommended size for the widget. - \return recommended toolbar size -*/ -QSize QtxToolBar::sizeHint() const -{ - QSize sz = QToolBar::sizeHint(); -/* - if ( place() == InDock && isStretchable() && area() ) - { - if ( orientation() == Horizontal ) - sz.setWidth( area()->width() ); - else - sz.setHeight( area()->height() ); - } -*/ - return sz; -} - -/*! - \brief Get the recommended minimum size for the widget. - \return recommended toolbar minimum size -*/ -QSize QtxToolBar::minimumSizeHint() const -{ - QSize sz = QToolBar::minimumSizeHint(); -/* - if ( place() == InDock && isStretchable() && area() ) - { - if ( orientation() == Horizontal ) - sz.setWidth( area()->width() ); - else - sz.setHeight( area()->height() ); - } -*/ - return sz; -} - /*! \brief Show/hide the toolbar. \param on new visibility state @@ -378,3 +340,11 @@ QMainWindow* QtxToolBar::mainWindow() const } return mw; } + +bool QtxToolBar::event( QEvent* e ) +{ + if ( e->type() == QEvent::WindowTitleChange && objectName().isEmpty() ) + setObjectName( windowTitle() ); + + return QToolBar::event( e ); +} diff --git a/src/Qtx/QtxToolBar.h b/src/Qtx/QtxToolBar.h index 8e520d715..56207f26b 100644 --- a/src/Qtx/QtxToolBar.h +++ b/src/Qtx/QtxToolBar.h @@ -39,14 +39,14 @@ public: QtxToolBar( QWidget* = 0 ); virtual ~QtxToolBar(); - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - QMainWindow* mainWindow() const; public slots: virtual void setVisible( bool ); +protected: + virtual bool event( QEvent* ); + private: Watcher* myWatcher; //!< watcher object bool myStretch; //!< stretching toolbar flag (not used)