diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index 62ab1ecd350..822e452c350 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -126,9 +126,9 @@ const char * const TOGGLE_SIDEBAR = "QtCreator.ToggleSidebar"; const char * const MINIMIZE_WINDOW = "QtCreator.MinimizeWindow"; const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow"; -const char * const HORIZONTAL = "QtCreator.Horizontal"; -const char * const VERTICAL = "QtCreator.Vertical"; -const char * const REMOVE = "QtCreator.Remove"; +const char * const SPLIT = "QtCreator.Split"; +const char * const SPLIT_SIDE_BY_SIDE = "QtCreator.SplitSideBySide"; +const char * const UNSPLIT = "QtCreator.Unsplit"; const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout"; const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout"; const char * const CLOSE = "QtCreator.Close"; diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index d66eb9c4a70..45c769c5254 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -34,11 +34,8 @@ SOURCES += mainwindow.cpp \ vcsmanager.cpp \ viewmanager.cpp \ versiondialog.cpp \ - editormanager/editorgroup.cpp \ editormanager/editormanager.cpp \ editormanager/editorview.cpp \ - editormanager/stackededitorgroup.cpp \ - editormanager/editorsplitter.cpp \ editormanager/openeditorsview.cpp \ editormanager/openeditorswindow.cpp \ actionmanager/actionmanager.cpp \ @@ -91,11 +88,8 @@ HEADERS += mainwindow.h \ outputpane.h \ vcsmanager.h \ viewmanager.h \ - editormanager/editorgroup.h \ editormanager/editormanager.h \ editormanager/editorview.h \ - editormanager/stackededitorgroup.h \ - editormanager/editorsplitter.h \ editormanager/openeditorsview.h \ editormanager/openeditorswindow.h \ editormanager/ieditor.h \ diff --git a/src/plugins/coreplugin/editormanager/editorgroup.cpp b/src/plugins/coreplugin/editormanager/editorgroup.cpp index 88f36e9665d..6973bf7d487 100644 --- a/src/plugins/coreplugin/editormanager/editorgroup.cpp +++ b/src/plugins/coreplugin/editormanager/editorgroup.cpp @@ -34,7 +34,7 @@ #include "editorgroup.h" #include "editormanager.h" -#include "editorview.h" + #include #include diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 830f9cecf94..72751522ad2 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -70,6 +70,7 @@ #include #include #include +#include using namespace Core; using namespace Core::Internal; @@ -129,6 +130,9 @@ struct EditorManagerPrivate { explicit EditorManagerPrivate(ICore *core, QWidget *parent); ~EditorManagerPrivate(); Internal::EditorView *m_view; + QSplitter *m_splitter; + QStackedLayout *m_stackedLayout; + ICore *m_core; bool m_suppressEditorChanges; @@ -144,6 +148,9 @@ struct EditorManagerPrivate { QAction *m_goBackAction; QAction *m_goForwardAction; QAction *m_openInExternalEditorAction; + QAction *m_splitAction; + QAction *m_splitSideBySideAction; + QAction *m_unsplitAction; QList m_editorHistory; QList m_navigationHistory; @@ -165,6 +172,8 @@ struct EditorManagerPrivate { EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) : m_view(0), + m_splitter(0), + m_stackedLayout(0), m_core(core), m_suppressEditorChanges(false), m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), parent)), @@ -307,6 +316,25 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE); connect(m_d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory())); + m_d->m_splitAction = new QAction(tr("Split"), this); + cmd = am->registerAction(m_d->m_splitAction, Constants::SPLIT, editManagerContext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,1"))); + mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); + connect(m_d->m_splitAction, SIGNAL(triggered()), this, SLOT(split())); + + m_d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this); + cmd = am->registerAction(m_d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,2"))); + mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); + connect(m_d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide())); + + m_d->m_unsplitAction = new QAction(tr("Unsplit"), this); + cmd = am->registerAction(m_d->m_unsplitAction, Constants::UNSPLIT, editManagerContext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,0"))); + mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); + connect(m_d->m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit())); + + ActionContainer *medit = am->actionContainer(Constants::M_EDIT); ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED); @@ -328,10 +356,8 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : connect(m_d->m_view, SIGNAL(closeRequested(Core::IEditor *)), this, SLOT(closeEditor(Core::IEditor *))); - QHBoxLayout *l = new QHBoxLayout(this); - l->setSpacing(0); - l->setMargin(0); - l->addWidget(m_d->m_view); + m_d->m_stackedLayout = new QStackedLayout(this); + m_d->m_stackedLayout->addWidget(m_d->m_view); updateActions(); @@ -1250,8 +1276,6 @@ bool EditorManager::restoreState(const QByteArray &state) QByteArray version; stream >> version; - qDebug() << "restore state" << version; - if (version != "EditorManagerV1") return false; @@ -1271,13 +1295,11 @@ bool EditorManager::restoreState(const QByteArray &state) int editorCount = 0; stream >> editorCount; - qDebug() << "restore editors:" << editorCount; while (--editorCount >= 0) { QString fileName; stream >> fileName; QByteArray kind; stream >> kind; - qDebug() << "openEditor" << fileName << kind; openEditor(fileName, kind, true); } @@ -1447,6 +1469,22 @@ QString EditorManager::externalEditor() const return m_d->m_externalEditor; } + +void EditorManager::split() +{ + qDebug() << "split"; +} + +void EditorManager::splitSideBySide() +{ + qDebug() << "splitSideBySide"; +} + +void EditorManager::unsplit() +{ + qDebug() << "unsplit"; +} + //===================EditorClosingCoreListener====================== EditorClosingCoreListener::EditorClosingCoreListener(EditorManager *em) diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 1a8c159ef9e..f8805881a43 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -181,7 +181,6 @@ signals: void editorOpened(Core::IEditor *editor); void editorAboutToClose(Core::IEditor *editor); void editorsClosed(QList editors); - void editorGroupsChanged(); public slots: bool closeAllEditors(bool askAboutModifiedEditors = true); @@ -201,6 +200,9 @@ private slots: void goBackInNavigationHistory(); void goForwardInNavigationHistory(); void makeCurrentEditorWritable(); + void split(); + void splitSideBySide(); + void unsplit(); private: QList filesForEditors(QList editors) const; diff --git a/src/plugins/coreplugin/editormanager/editorsplitter.cpp b/src/plugins/coreplugin/editormanager/editorsplitter.cpp index 7e4f53f4e40..0b43372b120 100644 --- a/src/plugins/coreplugin/editormanager/editorsplitter.cpp +++ b/src/plugins/coreplugin/editormanager/editorsplitter.cpp @@ -76,6 +76,7 @@ void EditorSplitter::registerActions() ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); Command *cmd; +#if 0 //Horizontal Action m_horizontalSplitAction = new QAction(tr("Split Left/Right"), this); cmd = am->registerAction(m_horizontalSplitAction, Constants::HORIZONTAL, editorManagerContext); @@ -97,6 +98,8 @@ void EditorSplitter::registerActions() connect(m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit())); +#endif + //Default Layout menu ActionContainer *mLayout = am->createMenu("QtCreator.Menu.Window.Layout"); mwindow->addMenu(mLayout, Constants::G_WINDOW_SPLIT); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 6a31cb70421..317668054d9 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -176,7 +176,6 @@ void EditorModel::itemChanged() EditorView::EditorView(EditorModel *model, QWidget *parent) : QWidget(parent), - m_toplevel(new QWidget), m_toolBar(new QWidget), m_container(new QStackedWidget(this)), m_editorList(new QComboBox), @@ -186,7 +185,7 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) : m_infoWidget(new QFrame(this)), m_editorForInfoWidget(0) { - QVBoxLayout *tl = new QVBoxLayout(m_toplevel); + QVBoxLayout *tl = new QVBoxLayout(this); tl->setSpacing(0); tl->setMargin(0); { @@ -272,11 +271,6 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) : } tl->addWidget(m_container); - QHBoxLayout *l = new QHBoxLayout; - l->setSpacing(0); - l->setMargin(0); - l->addWidget(m_toplevel); - setLayout(l); } void EditorView::showEditorInfoBar(const QString &kind, @@ -343,6 +337,11 @@ void EditorView::insertEditor(int index, IEditor *editor) // emit editorAdded(editor); } +bool EditorView::hasEditor(IEditor *editor) const +{ + return (m_container->indexOf(editor->widget()) != -1); +} + void EditorView::sendCloseRequest() { emit closeRequested(currentEditor()); @@ -367,7 +366,6 @@ void EditorView::removeEditor(IEditor *editor) toolBar->setVisible(false); toolBar->setParent(0); } -// emit editorRemoved(editor); } } @@ -387,10 +385,9 @@ void EditorView::setCurrentEditor(IEditor *editor) QTC_ASSERT(idx >= 0, return); if (m_container->currentIndex() != idx) { m_container->setCurrentIndex(idx); - - const bool block = m_editorList->blockSignals(true); + disconnect(m_editorList, SIGNAL(currentIndexChanged(int)), this, SLOT(listSelectionChanged(int))); m_editorList->setCurrentIndex(qobject_cast(m_editorList->model())->indexOf(editor->file()->fileName()).row()); - m_editorList->blockSignals(block); + connect(m_editorList, SIGNAL(currentIndexChanged(int)), this, SLOT(listSelectionChanged(int))); } setEditorFocus(idx); diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h index f89a4fb2efb..14cebf1f9ae 100644 --- a/src/plugins/coreplugin/editormanager/editorview.h +++ b/src/plugins/coreplugin/editormanager/editorview.h @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -104,6 +105,9 @@ public: void removeEditor(IEditor *editor); IEditor *currentEditor() const; void setCurrentEditor(IEditor *editor); + + bool hasEditor(IEditor *editor) const; + QList editors() const; void showEditorInfoBar(const QString &kind, const QString &infoText, @@ -128,7 +132,6 @@ private: void updateToolBar(IEditor *editor); void checkProjectLoaded(IEditor *editor); - QWidget *m_toplevel; QWidget *m_toolBar; QToolBar *m_activeToolBar; QStackedWidget *m_container; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 50baf0f1100..2716d978f07 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -89,6 +89,7 @@ void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor) return; } EditorManager *em = EditorManager::instance(); + m_ui.editorList->clearSelection(); //we are in extended selectionmode m_ui.editorList->setCurrentIndex(em->openedEditorsModel()->indexOf(editor)); m_ui.editorList->scrollTo(m_ui.editorList->currentIndex()); } diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index c4e3a0ea206..cd92e3e93d6 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -84,8 +84,6 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) : this, SLOT(updateEditorList())); connect(em, SIGNAL(editorsClosed(QList)), this, SLOT(updateEditorList())); - connect(em, SIGNAL(editorGroupsChanged()), - this, SLOT(updateEditorList())); connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateEditorList())); } diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 8c71ead4334..2b891e83f2b 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -165,7 +165,7 @@ ProjectTreeWidget::ProjectTreeWidget(Core::ICore *core, QWidget *parent) m_toggleSync->setToolTip(tr("Synchronize with Editor")); connect(m_toggleSync, SIGNAL(clicked(bool)), this, SLOT(toggleAutoSynchronization())); - //setAutoSynchronization(true); + setAutoSynchronization(true); } QToolButton *ProjectTreeWidget::toggleSync() @@ -216,25 +216,20 @@ void ProjectTreeWidget::setCurrentItem(Node *node, Project *project) qDebug() << "ProjectTreeWidget::setCurrentItem(" << (project ? project->name() : "0") << ", " << (node ? node->path() : "0") << ")"; if (!project) { - m_view->selectionModel()->reset(); return; } const QModelIndex mainIndex = m_model->indexForNode(node); - if (!mainIndex.isValid()) { - if (debug) - qDebug() << "no main index, clear selection"; - m_view->selectionModel()->clearSelection(); - } else if (mainIndex != m_view->selectionModel()->currentIndex()) { - QItemSelectionModel *selections = m_view->selectionModel(); - if (debug) - qDebug() << "ProjectTreeWidget - changing selection"; - - selections->setCurrentIndex(mainIndex, QItemSelectionModel::SelectCurrent - | QItemSelectionModel::Clear); + if (mainIndex.isValid() && mainIndex != m_view->selectionModel()->currentIndex()) { + m_view->setCurrentIndex(mainIndex); m_view->scrollTo(mainIndex); + } else { + if (debug) + qDebug() << "clear selection"; + m_view->clearSelection(); } + } void ProjectTreeWidget::handleCurrentItemChange(const QModelIndex ¤t) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index e6e2455cced..afeb3c3469a 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -216,22 +216,7 @@ void ProjectWindow::updateTreeWidget() m_treeWidget->addTopLevelItem(item); - if (m_projectExplorer->currentProject() == project) { - m_treeWidget->setCurrentItem(item, 0, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); - } } - - - if (!m_treeWidget->currentItem()) { - if (m_treeWidget->topLevelItemCount() > 0) - m_treeWidget->setCurrentItem(m_treeWidget->topLevelItem(0), 0, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); - else - handleCurrentItemChanged(0); - } - - - // Hack around Qt bug - m_treeWidget->viewport()->update(); } @@ -255,10 +240,6 @@ void ProjectWindow::handleCurrentItemChanged(QTreeWidgetItem *current) return; } } - - // we only get here if either current is zero or we didn't find a project for the path - m_projectExplorer->setCurrentFile(0, QString()); - showProperties(0, QModelIndex()); }