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

void KBear::fillWindowMenu (  )  [virtual, slot]

Update of the window menu contents.

Reimplemented from QextMdiMainFrm.

Definition at line 443 of file kbear_slots.cpp.

References QextMdiChildView::caption(), QextMdiChildView::isAttached(), QextMdiChildView::isMinimized(), QextMdiChildView::isToolView(), and QextMdiChildView::setWindowMenuID().

Referenced by createGUI().

                           {
      bool bTabPageMode = (m_mdiMode == QextMdi::TabPageMode);
      bool bNoViewOpened = m_pWinList->isEmpty();
      action("window_close")->setEnabled( ! bNoViewOpened );
      action("window_close_all")->setEnabled( ! bNoViewOpened );
      action("window_minimize_all")->setEnabled( ! bNoViewOpened && ! bTabPageMode );
      m_dockUndockMenu->setEnabled( ! bNoViewOpened && ! bTabPageMode );
      m_tileMenu->setEnabled( m_mdiMode == QextMdi::ChildframeMode );

      // for all child frame windows: give an ID to every window and connect them in the end with windowMenuItemActivated()
      unplugActionList("window_list");
      QPtrListIterator<KAction> iter(m_dockUndockActions);
      for( ; iter.current(); ++iter) {
            m_dockUndockMenu->remove( iter.current() );
      }

      m_windowListActions.clear();
      m_dockUndockActions.clear();
      int i = 100;
      QextMdiChildView* pView = 0L;
      QPtrListIterator<QextMdiChildView> it(*m_pWinList);


      for( ; it.current(); ++it) {
            pView = it.current();
            if( pView->isToolView())
                  continue;

            QString item;
            // set titles of minimized windows in brackets
            if( pView->isMinimized()) {
                  item = "(";
                  item += pView->caption();
                  item += ")";
            }
            else {
                  item = " ";
                  item += pView->caption();
            }

            // insert the window entry sorted in alphabetical order
            unsigned int indx;
            unsigned int windowItemCount = m_windowListActions.count();
            bool inserted = false;
            QString tmpString;
            KRadioAction* radioAction = new KRadioAction( item, 0, pView, SLOT(slot_clickedInWindowMenu()), this, "window_list_"+item );
            radioAction->setChecked( pView == m_pCurrentWindow );
            KToggleAction* toggleAction = 0L;
            if( ! bNoViewOpened )
                  toggleAction = new KToggleAction( item, 0, pView, SLOT(slot_clickedInDockMenu()), this, "dock_undock_list_"+item );
            for( indx = 0; indx < windowItemCount; indx++) {
                  tmpString = m_windowListActions.at( indx )->text();
                  if( tmpString.right( tmpString.length()-2) > item.right( item.length()-2)) {
                        m_windowListActions.insert( indx, radioAction );
                        pView->setWindowMenuID( i );
                        if( ! bTabPageMode && ! bNoViewOpened ) {
                              m_dockUndockActions.insert( indx, toggleAction );
                              toggleAction->setChecked( pView->isAttached() );
                        }
                        inserted = true;
                        indx = windowItemCount+1;  // break the loop
                  }
            }
            if( ! inserted ) {  // append it
                  m_windowListActions.append( radioAction );
                  pView->setWindowMenuID( i );
                  if( ! bTabPageMode && ! bNoViewOpened ) {
                        m_dockUndockActions.append( toggleAction );
                        toggleAction->setChecked( pView->isAttached() );
                  }
            }
            i++;
      }
      for( iter.toFirst(); iter.current(); ++iter) {
            m_dockUndockMenu->insert( iter.current() );
      }
      plugActionList("window_list", m_windowListActions );
}


Generated by  Doxygen 1.6.0   Back to index