void TreeWidgetEditor::on_deleteItemButton_clicked() { QTreeWidgetItem *curItem = ui.treeWidget->currentItem(); if (!curItem) return; QTreeWidgetItem *nextCurrent = 0; if (curItem->parent()) { int idx = curItem->parent()->indexOfChild(curItem); if (idx == curItem->parent()->childCount() - 1) idx--; else idx++; if (idx < 0) nextCurrent = curItem->parent(); else nextCurrent = curItem->parent()->child(idx); } else { int idx = ui.treeWidget->indexOfTopLevelItem(curItem); if (idx == ui.treeWidget->topLevelItemCount() - 1) idx--; else idx++; if (idx >= 0) nextCurrent = ui.treeWidget->topLevelItem(idx); } closeEditors(); ui.treeWidget->blockSignals(true); delete curItem; ui.treeWidget->blockSignals(false); if (nextCurrent) ui.treeWidget->setCurrentItem(nextCurrent, ui.treeWidget->currentColumn()); updateEditor(); }
void TamyEditor::setActiveProject( Project* project ) { if ( m_activeProject == project ) { // nothing's changed return; } // close all active editors closeEditors( FilePath( "/" ), PathTest::FROM_METHOD( TamyEditor, allTrue, this ) ); // set the new project as the active one m_activeProject = project; // memorize project's path // set the project path if ( m_activeProject ) { m_activeProjectPath = m_activeProject->getFilePath(); } else { m_activeProjectPath = FilePath(); } // notify the resources browser about it m_resourcesBrowser->setActiveProject( m_activeProject ); }
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors) { //在Model中删除所有editor //这里有疑问,从model中移出了所有的Editor之后,调用openedEditors()不是返回 //空值才对吗? d->m_editorModel->removeAllRestoredEditors(); if (closeEditors(openedEditors(), askAboutModifiedEditors)) { return true; } return false; }
void TreeWidgetEditor::on_columnEditor_itemDeleted(int idx) { closeEditors(); int columnCount = ui.treeWidget->columnCount() - 1; if (!columnCount) ui.treeWidget->clear(); else moveColumnsRight(idx, columnCount); ui.treeWidget->setColumnCount(columnCount); updateEditor(); }
void TamyEditor::onFileRemoved( const FilePath& path ) { // if the removed file was the active project resource, close the project if ( m_activeProject && m_activeProjectPath == path ) { // yes it was - close the project setActiveProject( NULL ); } else { // and close any editors tied to this particular resource ( Project may also have an editor assigned to it and it may be open at the moment ) closeEditors( path, PathTest::FROM_METHOD( TamyEditor, isSamePath, this ) ); } }
void TamyEditor::onDirRemoved( const FilePath& dir ) { if ( m_activeProject ) { // if the removed directory was where the active project was located, we need to close the project if ( m_activeProjectPath.isSubPath( dir ) ) { // yes it was - close the project setActiveProject( NULL ); } } else { closeEditors( dir, PathTest::FROM_METHOD( TamyEditor, isResourceFromDeletedDir, this ) ); } }
void TreeWidgetEditor::on_deleteColumnButton_clicked() { QListWidgetItem *currentColumn = ui.listWidget->currentItem(); if (!currentColumn) return; m_updating = true; int idx = ui.listWidget->currentRow(); int columnCount = ui.treeWidget->columnCount(); moveColumnsRight(idx, columnCount - 1); ui.treeWidget->setColumnCount(columnCount - 1); closeEditors(); delete currentColumn; if (idx == columnCount - 1) idx--; if (idx >= 0) ui.listWidget->setCurrentRow(idx); m_updating = false; updateEditor(); }
void EditorManager::closeEditor(IEditor *editor) { if (!editor) return; closeEditors(QList<IEditor *>() << editor); }