void Document::slotViewDestroyed( QObject *obj ) { View *view = static_cast<View*>(obj); m_viewList.remove(view); if ( m_pActiveView == (QPointer<View>)view ) { m_pActiveView = 0l; emit viewUnfocused(); } if ( m_viewList.isEmpty() ) deleteLater(); }
void DocManager::handleNewDocument( Document *document, ViewArea *viewArea ) { if ( !document || m_documentList.contains(document) ) return; m_documentList.append(document); document->setDCOPID(m_nextDocumentID++); connect( document, SIGNAL(modifiedStateChanged()), KTechlab::self(), SLOT(slotDocModifiedChanged()) ); connect( document, SIGNAL(fileNameChanged(const KURL&)), KTechlab::self(), SLOT(slotDocModifiedChanged()) ); connect( document, SIGNAL(fileNameChanged(const KURL&)), KTechlab::self(), SLOT(addRecentFile(const KURL&)) ); connect( document, SIGNAL(destroyed(QObject* )), this, SLOT(documentDestroyed(QObject* )) ); connect( document, SIGNAL(viewFocused(View* )), this, SLOT(slotViewFocused(View* )) ); connect( document, SIGNAL(viewUnfocused()), this, SLOT(slotViewUnfocused()) ); createNewView( document, viewArea ); }
void Document::handleNewView( View *view ) { if ( !view || m_viewList.contains(view) ) return; m_viewList.append(view); view->setDCOPID(m_nextViewID++); view->setCaption(m_caption); connect( view, SIGNAL(destroyed(QObject* )), this, SLOT(slotViewDestroyed(QObject* )) ); connect( view, SIGNAL(focused(View* )), this, SLOT(slotViewFocused(View* )) ); connect( view, SIGNAL(unfocused()), this, SIGNAL(viewUnfocused()) ); view->show(); if ( !DocManager::self()->getFocusedView() ) view->setFocus(); }