Logo Search packages:      
Sourcecode: canorus version File versions  Download package

void CAMainWin::rebuildUI ( bool  repaint = true  ) 

Rebuilds the GUI from data.

This method is called eg. when multiple viewports share the same data and a change has been made (eg. a note pitch has changed or a new element added). ViewPorts content is repositioned and redrawn (CAEngraver creates CADrawable elements for every score viewport, sources are updated in source viewports etc.).

This method in comparison to CAMainWin::rebuildUI(CASheet *s, bool repaint) rebuilds the whole GUI from scratch and creates new viewports for the sheets. This method is called for example when a new document is created or opened.

If repaint is True (default) the rebuilt viewports are also repainted. If False, viewports content is only created but not yet drawn. This is useful when multiple operations which could potentially change the content are to happen and we want to actually draw it only at the end.

Definition at line 1443 of file mainwin.cpp.

References _viewPortList, addSheet(), clearUI(), CAResourceView::rebuildUi(), CADocument::sheetCount(), and updateToolBars().

                                      {
      if (rebuildUILock()) return;

      setRebuildUILock( true );
      if (document()) {
            int curIndex = uiTabWidget->currentIndex();

            // save the current state of viewports
            QList<QRect> worldCoordsList;
            for (int i=0; i<_viewPortList.size(); i++)
                  if (_viewPortList[i]->viewPortType() == CAViewPort::ScoreViewPort)
                        worldCoordsList << static_cast<CAScoreViewPort*>(_viewPortList[i])->worldCoords();

            clearUI();
            for (int i=0; i<document()->sheetCount(); i++) {
                  addSheet(document()->sheetAt(i));

                  // restore the current state of viewports
                  if ( _viewPortList[i]->viewPortType() == CAViewPort::ScoreViewPort &&
                       i < worldCoordsList.size() )
                        static_cast<CAScoreViewPort*>(_viewPortList[i])->setWorldCoords(worldCoordsList[i]);
            }

            for (int i=0; i<_viewPortList.size(); i++) {
                  _viewPortList[i]->rebuild();

                  if (_viewPortList[i]->viewPortType() == CAViewPort::ScoreViewPort)
                        static_cast<CAScoreViewPort*>(_viewPortList[i])->checkScrollBars();

                  if (repaint)
                        _viewPortList[i]->repaint();
            }

            if ( curIndex<uiTabWidget->count() )
                  uiTabWidget->setCurrentIndex(curIndex);
      } else {
            clearUI();
      }

      if (_resourceView) {
            _resourceView->rebuildUi();
      }

      updateWindowTitle();
      updateToolBars();
      setRebuildUILock( false );
}


Generated by  Doxygen 1.6.0   Back to index