Salome HOME
no message
authorstv <stv@opencascade.com>
Tue, 31 May 2005 08:54:36 +0000 (08:54 +0000)
committerstv <stv@opencascade.com>
Tue, 31 May 2005 08:54:36 +0000 (08:54 +0000)
src/Qtx/QtxDockWindow.cxx
src/Qtx/QtxDockWindow.h
src/Qtx/QtxToolBar.cxx
src/Qtx/QtxToolBar.h

index 0432faa5cd5e91eb6117707c350df86a22305e7b..e87e07a110bdcfc131655927e9ea2088bb42f016 100644 (file)
@@ -19,6 +19,9 @@ class QtxDockWindow::Watcher : public QObject
 public:
   Watcher( QtxDockWindow* );
 
+  void           shown( QtxDockWindow* );
+  void           hided( QtxDockWindow* );
+
   virtual bool   eventFilter( QObject*, QEvent* );
 
 protected:
@@ -27,23 +30,30 @@ protected:
 private:
   void           installFilters();
 
+  void           showContainer();
+  void           hideContainer();
+
   void           updateIcon();
   void           updateCaption();
   void           updateVisibility();
 
 private:
-  bool           myVis;
   QtxDockWindow* myCont;
+  bool           myState;
+  bool           myEmpty;
+  bool           myVisible;
 };
 
 QtxDockWindow::Watcher::Watcher( QtxDockWindow* cont )
 : QObject( cont ), myCont( cont ),
-myVis( true )
+myState( true ),
+myEmpty( true )
 {
   if ( myCont->mainWindow() )
-    myVis = myCont->mainWindow()->appropriate( myCont );
+    myState = myCont->mainWindow()->appropriate( myCont );
 
   myCont->installEventFilter( this );
+  myVisible = myCont->isVisibleTo( myCont->parentWidget() );
 
   installFilters();
 }
@@ -71,6 +81,44 @@ bool QtxDockWindow::Watcher::eventFilter( QObject* o, QEvent* e )
   return false;
 }
 
+void QtxDockWindow::Watcher::shown( QtxDockWindow* dw )
+{
+  if ( dw != myCont )
+    return;
+
+  myVisible = true;
+}
+
+void QtxDockWindow::Watcher::hided( QtxDockWindow* dw )
+{
+  if ( dw != myCont )
+    return;
+
+  myVisible = false;
+}
+
+void QtxDockWindow::Watcher::showContainer()
+{
+  if ( !myCont )
+    return;
+
+  QtxDockWindow* cont = myCont;
+  myCont = 0;
+  cont->show();
+  myCont = cont;
+}
+
+void QtxDockWindow::Watcher::hideContainer()
+{
+  if ( !myCont )
+    return;
+
+  QtxDockWindow* cont = myCont;
+  myCont = 0;
+  cont->hide();
+  myCont = cont;
+}
+
 void QtxDockWindow::Watcher::customEvent( QCustomEvent* e )
 {
   installFilters();
@@ -110,19 +158,21 @@ void QtxDockWindow::Watcher::updateVisibility()
     vis = it.current()->widget() && it.current()->widget()->isVisibleTo( myCont );
 
   QMainWindow* mw = myCont->mainWindow();
-  if ( mw )
+  if ( mw && myEmpty != vis )
   {
-    if ( vis )
-      mw->setAppropriate( myCont, myVis );
+    myEmpty = vis;
+    if ( myEmpty )
+      mw->setAppropriate( myCont, myState );
     else
     {
-      myVis = mw->appropriate( myCont );
+      myState = mw->appropriate( myCont );
       mw->setAppropriate( myCont, false );
     }
   }
 
+  vis = myEmpty && myVisible;
   if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
-    vis ? myCont->show() : myCont->hide();
+    vis ? showContainer() : hideContainer();
 }
 
 void QtxDockWindow::Watcher::updateIcon()
@@ -253,3 +303,19 @@ QMainWindow* QtxDockWindow::mainWindow() const
 
   return mw;
 }
+
+void QtxDockWindow::show()
+{
+  if ( myWatcher )
+    myWatcher->shown( this );
+
+  QDockWindow::show();
+}
+
+void QtxDockWindow::hide()
+{
+  if ( myWatcher )
+    myWatcher->hided( this );
+
+  QDockWindow::hide();
+}
index e1d4902d593ebded67e3df02d5c420207562acce..77dffb46f283d17766ea3a25660ad73706ff76da 100644 (file)
@@ -27,6 +27,10 @@ public:
 
   QMainWindow*  mainWindow() const;
 
+public slots:
+  virtual void  show();
+  virtual void  hide();
+
 private:
   Watcher*      myWatcher;
   bool          myStretch;
index 094923942b4516f467fd561f86c689a77c89f990..311f1deb37c9cbfa932bdd55135b7f5bf93032cf 100644 (file)
@@ -20,6 +20,9 @@ class QtxToolBar::Watcher : public QObject
 public:
   Watcher( QtxToolBar* );
 
+  void         shown( QtxToolBar* );
+  void         hided( QtxToolBar* );
+
   virtual bool eventFilter( QObject*, QEvent* );
 
 protected:
@@ -31,24 +34,31 @@ private:
 private:
   void         installFilters();
 
+  void         showContainer();
+  void         hideContainer();
+
   void         updateIcon();
   void         updateCaption();
   void         updateVisibility();
 
 private:
-  bool         myVis;
   QtxToolBar*  myCont;
+  bool         myState;
+  bool         myEmpty;
+  bool         myVisible;
 };
 
 QtxToolBar::Watcher::Watcher( QtxToolBar* cont )
 : QObject( cont ),
 myCont( cont ),
-myVis( true )
+myState( true ),
+myEmpty( true )
 {
   if ( myCont->mainWindow() )
-    myVis = myCont->mainWindow()->appropriate( myCont );
+    myState = myCont->mainWindow()->appropriate( myCont );
 
   myCont->installEventFilter( this );
+  myVisible = myCont->isVisibleTo( myCont->parentWidget() );
 
   installFilters();
 }
@@ -80,6 +90,44 @@ bool QtxToolBar::Watcher::eventFilter( QObject* o, QEvent* e )
   return false;
 }
 
+void QtxToolBar::Watcher::shown( QtxToolBar* tb )
+{
+  if ( tb != myCont )
+    return;
+
+  myVisible = true;
+}
+
+void QtxToolBar::Watcher::hided( QtxToolBar* tb )
+{
+  if ( tb != myCont )
+    return;
+
+  myVisible = false;
+}
+
+void QtxToolBar::Watcher::showContainer()
+{
+  if ( !myCont )
+    return;
+
+  QtxToolBar* cont = myCont;
+  myCont = 0;
+  cont->show();
+  myCont = cont;
+}
+
+void QtxToolBar::Watcher::hideContainer()
+{
+  if ( !myCont )
+    return;
+
+  QtxToolBar* cont = myCont;
+  myCont = 0;
+  cont->hide();
+  myCont = cont;
+}
+
 void QtxToolBar::Watcher::customEvent( QCustomEvent* e )
 {
   switch ( e->type() )
@@ -132,19 +180,21 @@ void QtxToolBar::Watcher::updateVisibility()
   }
 
   QMainWindow* mw = myCont->mainWindow();
-  if ( mw )
+  if ( mw && myEmpty != vis )
   {
-    if ( vis )
-      mw->setAppropriate( myCont, myVis );
+    myEmpty = vis;
+    if ( myEmpty )
+      mw->setAppropriate( myCont, myState );
     else
     {
-      myVis = mw->appropriate( myCont );
+      myState = mw->appropriate( myCont );
       mw->setAppropriate( myCont, false );
     }
   }
 
+  vis = myEmpty && myVisible;
   if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
-    vis ? myCont->show() : myCont->hide();
+    vis ? showContainer() : hideContainer();
 }
 
 void QtxToolBar::Watcher::updateIcon()
@@ -278,3 +328,19 @@ QSize QtxToolBar::minimumSizeHint() const
 
   return sz;
 }
+
+void QtxToolBar::show()
+{
+  if ( myWatcher )
+    myWatcher->shown( this );
+
+  QToolBar::show();
+}
+
+void QtxToolBar::hide()
+{
+  if ( myWatcher )
+    myWatcher->hided( this );
+
+  QToolBar::hide();
+}
index 61e3bfc48b675a83716bcd725799c586092c0d45..35283e7250968d30f7084de40019910666762aaa 100644 (file)
@@ -26,6 +26,10 @@ public:
   virtual QSize sizeHint() const;
   virtual QSize minimumSizeHint() const;
 
+public slots:
+  virtual void  show();
+  virtual void  hide();
+
 private:
   Watcher*      myWatcher;
   bool          myStretch;