ginebra2/ViewController.cpp
changeset 6 1c3b8676e58c
parent 5 0f2326c2a325
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
    35     }
    35     }
    36   }
    36   }
    37 
    37 
    38   void ViewController::addView(ControllableViewBase *controllableView) {
    38   void ViewController::addView(ControllableViewBase *controllableView) {
    39     assert(controllableView);
    39     assert(controllableView);
    40     qDebug() << "ViewController::addView: adding " << controllableView
       
    41              << " jsObject=" << controllableView->jsObject();
       
    42     QString key;
    40     QString key;
    43     // Set up parent/child link for javascript access to the view.
    41     // Set up parent/child link for javascript access to the view.
    44     if (controllableView->jsObject()) {
    42     if (controllableView->jsObject()) {
    45       // Use the view's javascript object.
    43       // Use the view's javascript object.
    46       controllableView->jsObject()->setParent(this);
    44       controllableView->jsObject()->setParent(this);
    67     }
    65     }
    68     return *result;
    66     return *result;
    69   }
    67   }
    70 
    68 
    71   void ViewController::showCurrent() {
    69   void ViewController::showCurrent() {
    72       qDebug() << "ViewController::showCurrent: " << m_current.value();
       
    73       ControllableViewBase *currentView = m_current.value();
    70       ControllableViewBase *currentView = m_current.value();
    74       if (!currentView) return;
    71       if (!currentView) return;
    75 
    72 
    76       if (!currentView->isActive()) {
    73       if (!currentView->isActive()) {
    77           emit currentViewChanging();
    74           emit currentViewChanging();
    80           currentView->show();
    77           currentView->show();
    81 
    78 
    82           // Deactivate all others.
    79           // Deactivate all others.
    83           foreach(ControllableViewBase *view, m_viewMap) {
    80           foreach(ControllableViewBase *view, m_viewMap) {
    84               if (view && view->isActive() && view != currentView) {
    81               if (view && view->isActive() && view != currentView) {
    85                   view->hide();
    82                 //If this view has the same widget as the current view,
    86                   view->deactivate();
    83                 //then don't hide this view.
       
    84 		if(currentView->widget() != view->widget())
       
    85 		  view->hide();
       
    86 		view->deactivate();
    87               }
    87               }
    88           }
    88           }
    89           emit currentViewChanged();
    89           emit currentViewChanged();
    90       }
    90       }
    91   }
    91   }