void DocManager::giveDocumentFocus( Document * toFocus, ViewArea * viewAreaForNew ) { if ( !toFocus ) return; if ( View * activeView = toFocus->activeView() ) KTechlab::self()->tabWidget()->showPage( activeView->viewContainer() ); else if ( viewAreaForNew ) createNewView( toFocus, viewAreaForNew ); }
Document* DocManager::openURL( const KURL &url, ViewArea *viewArea ) { if ( url.isEmpty() ) return 0; if ( url.isLocalFile() ) { QFile file(url.path()); if ( file.open(IO_ReadOnly) == false ) { KMessageBox::sorry( 0l, i18n("Could not open '%1'").arg( url.prettyURL() ) ); return 0l; } file.close(); } // If the currently active view area is empty, and we were not given a view area // to open into, then use the empty view area if ( !viewArea ) { ViewContainer * currentVC = static_cast<ViewContainer*>( KTechlab::self()->tabWidget()->currentPage() ); if ( currentVC ) { ViewArea * va = currentVC->viewArea( currentVC->activeViewArea() ); if ( !va->view() ) viewArea = va; } } // If the document is already open, and a specific view area hasn't been // specified, then just return that document - otherwise, create a new // view in the viewarea Document *document = findDocument(url); if ( document ) { if ( viewArea ) createNewView( document, viewArea ); else giveDocumentFocus( document, viewArea ); return document; } QString fileName = url.fileName(); QString extension = fileName.right( fileName.length() - fileName.findRev('.') ); if ( extension == ".circuit" ) return openCircuitFile( url, viewArea ); else if ( extension == ".flowcode" ) return openFlowCodeFile( url, viewArea ); else if ( extension == ".mechanics" ) return openMechanicsFile( url, viewArea ); else return openTextFile( url, viewArea ); }
void DocManager::giveDocumentFocus( Document * toFocus, ViewArea * viewAreaForNew ) { if ( !toFocus ) return; if ( View * activeView = toFocus->activeView() ) { //KTechlab::self()->tabWidget()->showPage( activeView->viewContainer() ); // 2018.12.01 KTechlab::self()->tabWidget()->setCurrentIndex( KTechlab::self()->tabWidget()->indexOf(activeView->viewContainer()) ); } else if ( viewAreaForNew ) createNewView( toFocus, viewAreaForNew ); }
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 ); }