forked from qt-creator/qt-creator
more stuff works, but this requires more refactoring
This commit is contained in:
@@ -128,6 +128,7 @@ const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow";
|
|||||||
const char * const SPLIT = "QtCreator.Split";
|
const char * const SPLIT = "QtCreator.Split";
|
||||||
const char * const SPLIT_SIDE_BY_SIDE = "QtCreator.SplitSideBySide";
|
const char * const SPLIT_SIDE_BY_SIDE = "QtCreator.SplitSideBySide";
|
||||||
const char * const UNSPLIT = "QtCreator.Unsplit";
|
const char * const UNSPLIT = "QtCreator.Unsplit";
|
||||||
|
const char * const GOTO_OTHER_WINDOW = "QtCreator.GotoOtherWindow";
|
||||||
const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout";
|
const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout";
|
||||||
const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout";
|
const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout";
|
||||||
const char * const CLOSE = "QtCreator.Close";
|
const char * const CLOSE = "QtCreator.Close";
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ struct EditorManagerPrivate {
|
|||||||
QAction *m_splitAction;
|
QAction *m_splitAction;
|
||||||
QAction *m_splitSideBySideAction;
|
QAction *m_splitSideBySideAction;
|
||||||
QAction *m_unsplitAction;
|
QAction *m_unsplitAction;
|
||||||
|
QAction *m_gotoOtherWindowAction;
|
||||||
|
|
||||||
QList<IEditor *> m_editorHistory;
|
QList<IEditor *> m_editorHistory;
|
||||||
QList<EditLocation *> m_navigationHistory;
|
QList<EditLocation *> m_navigationHistory;
|
||||||
@@ -352,6 +353,11 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
connect(m_d->m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit()));
|
connect(m_d->m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit()));
|
||||||
|
|
||||||
|
m_d->m_gotoOtherWindowAction = new QAction(tr("Goto other window"), this);
|
||||||
|
cmd = am->registerAction(m_d->m_gotoOtherWindowAction, Constants::GOTO_OTHER_WINDOW, editManagerContext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,o")));
|
||||||
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
|
connect(m_d->m_gotoOtherWindowAction, SIGNAL(triggered()), this, SLOT(gotoOtherWindow()));
|
||||||
|
|
||||||
|
|
||||||
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||||
@@ -384,8 +390,6 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
this, SLOT(updateEditorHistory()));
|
this, SLOT(updateEditorHistory()));
|
||||||
m_d->m_view = new EditorView(m_d->m_editorModel, this);
|
m_d->m_view = new EditorView(m_d->m_editorModel, this);
|
||||||
m_d->m_splitter = new SplitterOrView(m_d->m_view);
|
m_d->m_splitter = new SplitterOrView(m_d->m_view);
|
||||||
connect(m_d->m_view, SIGNAL(closeRequested(Core::IEditor *)),
|
|
||||||
this, SLOT(closeEditor(Core::IEditor *)));
|
|
||||||
|
|
||||||
m_d->m_stackedLayout = new QStackedLayout(this);
|
m_d->m_stackedLayout = new QStackedLayout(this);
|
||||||
m_d->m_stackedLayout->addWidget(m_d->m_splitter);
|
m_d->m_stackedLayout->addWidget(m_d->m_splitter);
|
||||||
@@ -489,6 +493,13 @@ void EditorManager::updateCurrentEditorAndGroup(IContext *context)
|
|||||||
qDebug() << "leaving method" << Q_FUNC_INFO;
|
qDebug() << "leaving method" << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEditor *EditorManager::activateEditor(IEditor *editor, bool ignoreNavigationHistory)
|
||||||
|
{
|
||||||
|
if (m_d->m_suppressEditorChanges)
|
||||||
|
return editor;
|
||||||
|
return activateEditor(m_d->m_splitter->findView(m_d->m_currentEditor)->view(), editor, ignoreNavigationHistory);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
|
void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
|
||||||
{
|
{
|
||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
@@ -499,13 +510,19 @@ void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHisto
|
|||||||
return;
|
return;
|
||||||
m_d->m_currentEditor = editor;
|
m_d->m_currentEditor = editor;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
|
qDebug() << "EditorManager::setCurrentEditor" << editor << editor->file()->fileName();
|
||||||
bool addToHistory = (!ignoreNavigationHistory && editor != currentEditor());
|
bool addToHistory = (!ignoreNavigationHistory && editor != currentEditor());
|
||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
qDebug() << Q_FUNC_INFO << (addToHistory ? "adding to history" : "not adding to history");
|
qDebug() << Q_FUNC_INFO << (addToHistory ? "adding to history" : "not adding to history");
|
||||||
if (addToHistory)
|
if (addToHistory)
|
||||||
addCurrentPositionToNavigationHistory(true);
|
addCurrentPositionToNavigationHistory(true);
|
||||||
m_d->m_suppressEditorChanges = true;
|
m_d->m_suppressEditorChanges = true;
|
||||||
m_d->m_view->setCurrentEditor(editor);
|
|
||||||
|
EditorView *view = m_d->m_splitter->findView(editor)->view();
|
||||||
|
if (view == m_d->m_view && m_d->m_splitter)
|
||||||
|
unsplitAll();
|
||||||
|
view->setCurrentEditor(editor);
|
||||||
|
|
||||||
m_d->m_suppressEditorChanges = false;
|
m_d->m_suppressEditorChanges = false;
|
||||||
if (addToHistory)
|
if (addToHistory)
|
||||||
addCurrentPositionToNavigationHistory();
|
addCurrentPositionToNavigationHistory();
|
||||||
@@ -545,26 +562,23 @@ void EditorManager::closeEditor()
|
|||||||
QTimer::singleShot(0, this, SLOT(closeEditor()));
|
QTimer::singleShot(0, this, SLOT(closeEditor()));
|
||||||
postpone = false;
|
postpone = false;
|
||||||
} else {
|
} else {
|
||||||
closeEditor(currentEditor());
|
closeEditor(m_d->m_splitter->findView(m_d->m_currentEditor)->view(), m_d->m_currentEditor);
|
||||||
postpone = true;
|
postpone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::closeEditor(IEditor *editor)
|
void EditorManager::closeEditor(Core::Internal::EditorView *view, Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor || !view)
|
||||||
editor = currentEditor();
|
|
||||||
if (!editor)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "EditorManager::closeEditor";
|
Q_ASSERT(view->hasEditor(editor));
|
||||||
if (m_d->m_view->hasEditor(editor)) {
|
if (view == m_d->m_view) {
|
||||||
qDebug() << "it's a main editor, do unsplit";
|
|
||||||
unsplitAll();
|
|
||||||
closeEditors(QList<IEditor *>() << editor);
|
closeEditors(QList<IEditor *>() << editor);
|
||||||
} else {
|
} else {
|
||||||
// ### TODO close duplicate editor
|
view->removeEditor(editor);
|
||||||
|
closeDuplicate(editor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -688,12 +702,14 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
|
|||||||
|
|
||||||
void EditorManager::closeDuplicate(Core::IEditor *editor, bool doDelete)
|
void EditorManager::closeDuplicate(Core::IEditor *editor, bool doDelete)
|
||||||
{
|
{
|
||||||
|
m_d->m_editorHistory.removeAll(editor);
|
||||||
emit editorAboutToClose(editor);
|
emit editorAboutToClose(editor);
|
||||||
|
emit editorsClosed(QList<Core::IEditor *>() << editor);
|
||||||
if (doDelete)
|
if (doDelete)
|
||||||
delete editor;
|
delete editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::activateEditor(Core::Internal::EditorView *view, Core::IEditor *editor)
|
Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, Core::IEditor *editor, bool ignoreNavigationHistory)
|
||||||
{
|
{
|
||||||
Q_ASSERT(view && editor);
|
Q_ASSERT(view && editor);
|
||||||
Q_ASSERT(m_d->m_view->hasEditor(editor));
|
Q_ASSERT(m_d->m_view->hasEditor(editor));
|
||||||
@@ -705,18 +721,17 @@ void EditorManager::activateEditor(Core::Internal::EditorView *view, Core::IEdit
|
|||||||
|
|
||||||
if (view == m_d->m_view || view->hasEditor(editor)) {
|
if (view == m_d->m_view || view->hasEditor(editor)) {
|
||||||
view->setCurrentEditor(editor);
|
view->setCurrentEditor(editor);
|
||||||
return;
|
return editor;
|
||||||
}
|
}
|
||||||
QList<IEditor*> editors = view->editors();
|
QList<IEditor*> editors = view->editors();
|
||||||
IEditor *duplicate = duplicateEditor(editor);
|
IEditor *duplicate = duplicateEditor(editor);
|
||||||
view->addEditor(duplicate);
|
view->addEditor(duplicate);
|
||||||
view->setCurrentEditor(duplicate);
|
view->setCurrentEditor(duplicate, ignoreNavigationHistory);
|
||||||
foreach(IEditor *e, editors) {
|
foreach(IEditor *e, editors) {
|
||||||
view->removeEditor(e);
|
view->removeEditor(e);
|
||||||
closeDuplicate(e, true);
|
closeDuplicate(e, true);
|
||||||
}
|
}
|
||||||
|
return duplicate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find editors for a mimetype, best matching at the front
|
/* Find editors for a mimetype, best matching at the front
|
||||||
@@ -808,14 +823,13 @@ IEditor *EditorManager::createEditor(const QString &editorKind,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::insertEditor(IEditor *editor,
|
void EditorManager::insertEditor(IEditor *editor,
|
||||||
bool ignoreNavigationHistory)
|
bool /*ignoreNavigationHistory*/)
|
||||||
{
|
{
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return;
|
return;
|
||||||
m_d->m_core->addContextObject(editor);
|
m_d->m_core->addContextObject(editor);
|
||||||
registerEditor(editor);
|
registerEditor(editor);
|
||||||
m_d->m_view->addEditor(editor);
|
m_d->m_view->addEditor(editor);
|
||||||
setCurrentEditor(editor, ignoreNavigationHistory);
|
|
||||||
emit editorOpened(editor);
|
emit editorOpened(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,8 +906,7 @@ IEditor *EditorManager::openEditor(const QString &fileName, const QString &edito
|
|||||||
|
|
||||||
const QList<IEditor *> editors = editorsForFileName(fileName);
|
const QList<IEditor *> editors = editorsForFileName(fileName);
|
||||||
if (!editors.isEmpty()) {
|
if (!editors.isEmpty()) {
|
||||||
setCurrentEditor(editors.first(), ignoreNavigationHistory);
|
return activateEditor(m_d->m_splitter->findView(m_d->m_currentEditor)->view(), editors.first(), ignoreNavigationHistory);
|
||||||
return editors.first();
|
|
||||||
}
|
}
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
IEditor *editor = createEditor(editorKind, fileName);
|
IEditor *editor = createEditor(editorKind, fileName);
|
||||||
@@ -908,8 +921,7 @@ IEditor *EditorManager::openEditor(const QString &fileName, const QString &edito
|
|||||||
restoreEditorState(editor);
|
restoreEditorState(editor);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
ensureEditorManagerVisible();
|
ensureEditorManagerVisible();
|
||||||
setCurrentEditor(editor);
|
return activateEditor(editor, ignoreNavigationHistory);
|
||||||
return editor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList EditorManager::getOpenFileNames() const
|
QStringList EditorManager::getOpenFileNames() const
|
||||||
@@ -1138,17 +1150,25 @@ bool EditorManager::saveFileAs(IEditor *editor)
|
|||||||
void EditorManager::gotoNextDocHistory()
|
void EditorManager::gotoNextDocHistory()
|
||||||
{
|
{
|
||||||
OpenEditorsWindow *dialog = windowPopup();
|
OpenEditorsWindow *dialog = windowPopup();
|
||||||
dialog->setMode(OpenEditorsWindow::HistoryMode);
|
if (dialog->isVisible()) {
|
||||||
dialog->selectNextEditor();
|
dialog->selectNextEditor();
|
||||||
showWindowPopup();
|
} else {
|
||||||
|
dialog->setEditors(m_d->m_editorHistory, m_d->m_currentEditor);
|
||||||
|
dialog->selectNextEditor();
|
||||||
|
showWindowPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::gotoPreviousDocHistory()
|
void EditorManager::gotoPreviousDocHistory()
|
||||||
{
|
{
|
||||||
OpenEditorsWindow *dialog = windowPopup();
|
OpenEditorsWindow *dialog = windowPopup();
|
||||||
dialog->setMode(OpenEditorsWindow::HistoryMode);
|
if (dialog->isVisible()) {
|
||||||
dialog->selectPreviousEditor();
|
dialog->selectPreviousEditor();
|
||||||
showWindowPopup();
|
} else {
|
||||||
|
dialog->setEditors(m_d->m_editorHistory, m_d->m_currentEditor);
|
||||||
|
dialog->selectPreviousEditor();
|
||||||
|
showWindowPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::makeCurrentEditorWritable()
|
void EditorManager::makeCurrentEditorWritable()
|
||||||
@@ -1560,19 +1580,33 @@ Core::IEditor *EditorManager::duplicateEditor(Core::IEditor *editor)
|
|||||||
return duplicate;
|
return duplicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorManager::split(Qt::Orientation orientation)
|
||||||
|
{
|
||||||
|
SplitterOrView *view = m_d->m_currentEditor ? m_d->m_splitter->findView(m_d->m_currentEditor)
|
||||||
|
: m_d->m_splitter->findFirstView();
|
||||||
|
if (!view) {
|
||||||
|
view = m_d->m_splitter;
|
||||||
|
view->unsplit(0);
|
||||||
|
}
|
||||||
|
view->split(orientation);
|
||||||
|
}
|
||||||
void EditorManager::split()
|
void EditorManager::split()
|
||||||
{
|
{
|
||||||
m_d->m_splitter->split(Qt::Vertical);
|
split(Qt::Vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::splitSideBySide()
|
void EditorManager::splitSideBySide()
|
||||||
{
|
{
|
||||||
m_d->m_splitter->split(Qt::Horizontal);
|
split(Qt::Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::unsplit()
|
void EditorManager::unsplit()
|
||||||
{
|
{
|
||||||
unsplitAll(); // ### TODO
|
qDebug() << "unsplit" << (m_d->m_currentEditor ? m_d->m_currentEditor->file()->fileName() : QString("no current editor"));
|
||||||
|
SplitterOrView *splitter = m_d->m_currentEditor ? m_d->m_splitter->findSplitter(m_d->m_currentEditor) : m_d->m_splitter;
|
||||||
|
qDebug() << "splitter" << splitter;
|
||||||
|
if (splitter)
|
||||||
|
splitter->unsplit(m_d->m_currentEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::unsplitAll()
|
void EditorManager::unsplitAll()
|
||||||
@@ -1582,6 +1616,26 @@ void EditorManager::unsplitAll()
|
|||||||
setCurrentEditor(e);
|
setCurrentEditor(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorManager::gotoOtherWindow()
|
||||||
|
{
|
||||||
|
qDebug() << "gotoOtherWindow";
|
||||||
|
if (!m_d->m_currentEditor)
|
||||||
|
return;
|
||||||
|
qDebug() << "current editor" << m_d->m_currentEditor->file()->fileName();
|
||||||
|
if (m_d->m_splitter->isSplitter()) {
|
||||||
|
qDebug() << "we have a splitter";
|
||||||
|
SplitterOrView *view = m_d->m_splitter->findNextView(m_d->m_currentEditor);
|
||||||
|
qDebug() << "next view is" << view;
|
||||||
|
if (!view)
|
||||||
|
view = m_d->m_splitter->findFirstView();
|
||||||
|
if (view) {
|
||||||
|
if (IEditor *editor = view->editor()) {
|
||||||
|
qDebug() << "set new current editor to" << editor->file()->fileName();
|
||||||
|
view->view()->setCurrentEditor(editor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//===================EditorClosingCoreListener======================
|
//===================EditorClosingCoreListener======================
|
||||||
|
|
||||||
EditorClosingCoreListener::EditorClosingCoreListener(EditorManager *em)
|
EditorClosingCoreListener::EditorClosingCoreListener(EditorManager *em)
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public:
|
|||||||
|
|
||||||
void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
IEditor *currentEditor() const;
|
IEditor *currentEditor() const;
|
||||||
|
IEditor *activateEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
// EditorGroup *currentEditorGroup() const;
|
// EditorGroup *currentEditorGroup() const;
|
||||||
|
|
||||||
QList<IEditor*> openedEditors() const;
|
QList<IEditor*> openedEditors() const;
|
||||||
@@ -189,7 +190,6 @@ private slots:
|
|||||||
bool saveFile(Core::IEditor *editor = 0);
|
bool saveFile(Core::IEditor *editor = 0);
|
||||||
bool saveFileAs(Core::IEditor *editor = 0);
|
bool saveFileAs(Core::IEditor *editor = 0);
|
||||||
void closeEditor();
|
void closeEditor();
|
||||||
void closeEditor(Core::IEditor *editor);
|
|
||||||
|
|
||||||
void gotoNextDocHistory();
|
void gotoNextDocHistory();
|
||||||
void gotoPreviousDocHistory();
|
void gotoPreviousDocHistory();
|
||||||
@@ -200,10 +200,12 @@ private slots:
|
|||||||
void goBackInNavigationHistory();
|
void goBackInNavigationHistory();
|
||||||
void goForwardInNavigationHistory();
|
void goForwardInNavigationHistory();
|
||||||
void makeCurrentEditorWritable();
|
void makeCurrentEditorWritable();
|
||||||
|
void split(Qt::Orientation orientation);
|
||||||
void split();
|
void split();
|
||||||
void splitSideBySide();
|
void splitSideBySide();
|
||||||
void unsplit();
|
void unsplit();
|
||||||
void unsplitAll();
|
void unsplitAll();
|
||||||
|
void gotoOtherWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
||||||
@@ -218,7 +220,8 @@ private:
|
|||||||
|
|
||||||
Core::IEditor *duplicateEditor(IEditor *editor);
|
Core::IEditor *duplicateEditor(IEditor *editor);
|
||||||
void closeDuplicate(Core::IEditor *editor, bool doDelete);
|
void closeDuplicate(Core::IEditor *editor, bool doDelete);
|
||||||
void activateEditor(Core::Internal::EditorView *view, Core::IEditor *editor);
|
Core::IEditor *activateEditor(Core::Internal::EditorView *view, Core::IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
|
void closeEditor(Core::Internal::EditorView *view, Core::IEditor *editor);
|
||||||
|
|
||||||
static EditorManager *m_instance;
|
static EditorManager *m_instance;
|
||||||
EditorManagerPrivate *m_d;
|
EditorManagerPrivate *m_d;
|
||||||
|
|||||||
@@ -335,8 +335,9 @@ void EditorView::insertEditor(int index, IEditor *editor)
|
|||||||
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
|
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
|
||||||
|
|
||||||
if (m_container->count() == 1) {
|
if (m_container->count() == 1) {
|
||||||
updateToolBar(editor);
|
m_editorList->setCurrentIndex(qobject_cast<EditorModel*>(m_editorList->model())->indexOf(editor->file()->fileName()).row());
|
||||||
updateEditorStatus(editor);
|
updateEditorStatus(editor);
|
||||||
|
updateToolBar(editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +348,8 @@ bool EditorView::hasEditor(IEditor *editor) const
|
|||||||
|
|
||||||
void EditorView::sendCloseRequest()
|
void EditorView::sendCloseRequest()
|
||||||
{
|
{
|
||||||
emit closeRequested(currentEditor());
|
EditorManager *em = CoreImpl::instance()->editorManager();
|
||||||
|
em->closeEditor(this, currentEditor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorView::removeEditor(IEditor *editor)
|
void EditorView::removeEditor(IEditor *editor)
|
||||||
@@ -379,19 +381,18 @@ IEditor *EditorView::currentEditor() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorView::setCurrentEditor(IEditor *editor)
|
void EditorView::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
|
||||||
{
|
{
|
||||||
if (!editor || m_container->count() <= 0
|
if (!editor || m_container->count() <= 0
|
||||||
|| m_container->indexOf(editor->widget()) == -1)
|
|| m_container->indexOf(editor->widget()) == -1)
|
||||||
return;
|
return;
|
||||||
if (editor)
|
if (editor)
|
||||||
qDebug() << "EditorView::setCurrentEditor" << editor->file()->fileName();
|
qDebug() << "EditorView::setCurrentEditor" << editor->file()->fileName();
|
||||||
|
|
||||||
const int idx = m_container->indexOf(editor->widget());
|
const int idx = m_container->indexOf(editor->widget());
|
||||||
QTC_ASSERT(idx >= 0, return);
|
QTC_ASSERT(idx >= 0, return);
|
||||||
if (m_container->currentIndex() != idx) {
|
m_container->setCurrentIndex(idx);
|
||||||
m_container->setCurrentIndex(idx);
|
m_editorList->setCurrentIndex(qobject_cast<EditorModel*>(m_editorList->model())->indexOf(editor->file()->fileName()).row());
|
||||||
m_editorList->setCurrentIndex(qobject_cast<EditorModel*>(m_editorList->model())->indexOf(editor->file()->fileName()).row());
|
|
||||||
}
|
|
||||||
setEditorFocus(idx);
|
setEditorFocus(idx);
|
||||||
updateEditorStatus(editor);
|
updateEditorStatus(editor);
|
||||||
updateToolBar(editor);
|
updateToolBar(editor);
|
||||||
@@ -401,6 +402,9 @@ void EditorView::setCurrentEditor(IEditor *editor)
|
|||||||
m_infoWidget->hide();
|
m_infoWidget->hide();
|
||||||
m_editorForInfoWidget = 0;
|
m_editorForInfoWidget = 0;
|
||||||
}
|
}
|
||||||
|
EditorManager *em = CoreImpl::instance()->editorManager();
|
||||||
|
if (em->currentEditor() != editor)
|
||||||
|
em->setCurrentEditor(editor, ignoreNavigationHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorView::checkEditorStatus()
|
void EditorView::checkEditorStatus()
|
||||||
@@ -490,9 +494,23 @@ SplitterOrView::SplitterOrView(Core::IEditor *editor, QWidget *parent)
|
|||||||
m_layout->addWidget(m_view);
|
m_layout->addWidget(m_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SplitterOrView *SplitterOrView::findFirstView()
|
||||||
|
{
|
||||||
|
if (m_splitter) {
|
||||||
|
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||||
|
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i)))
|
||||||
|
if (SplitterOrView *result = splitterOrView->findFirstView())
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
SplitterOrView *SplitterOrView::findView(Core::IEditor *editor)
|
SplitterOrView *SplitterOrView::findView(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
if (hasEditor(editor))
|
if (!editor || hasEditor(editor))
|
||||||
return this;
|
return this;
|
||||||
if (m_splitter) {
|
if (m_splitter) {
|
||||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||||
@@ -519,6 +537,37 @@ SplitterOrView *SplitterOrView::findSplitter(Core::IEditor *editor)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SplitterOrView *SplitterOrView::findNextView(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
return findNextView_helper(editor, &found);
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitterOrView *SplitterOrView::findNextView_helper(Core::IEditor *editor, bool *found)
|
||||||
|
{
|
||||||
|
qDebug() << "check view " << this << "view" << m_view << "splitter" << m_splitter << "found" << *found;
|
||||||
|
if (*found && m_view) {
|
||||||
|
qDebug() << "found next!";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasEditor(editor)) {
|
||||||
|
qDebug() << "found editor";
|
||||||
|
*found = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_splitter) {
|
||||||
|
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||||
|
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) {
|
||||||
|
if (SplitterOrView *result = splitterOrView->findNextView_helper(editor, found))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void SplitterOrView::split(Qt::Orientation orientation)
|
void SplitterOrView::split(Qt::Orientation orientation)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_view && m_splitter == 0);
|
Q_ASSERT(m_view && m_splitter == 0);
|
||||||
@@ -526,14 +575,14 @@ void SplitterOrView::split(Qt::Orientation orientation)
|
|||||||
m_splitter->setOrientation(orientation);
|
m_splitter->setOrientation(orientation);
|
||||||
Core::IEditor *e = m_view->currentEditor();
|
Core::IEditor *e = m_view->currentEditor();
|
||||||
|
|
||||||
Core::IEditor *focus = e;
|
SplitterOrView *focusView = 0;
|
||||||
|
|
||||||
if (m_isRoot) {
|
if (m_isRoot) {
|
||||||
Core::IEditor *duplicateA = CoreImpl::instance()->editorManager()->duplicateEditor(e);
|
Core::IEditor *duplicateA = CoreImpl::instance()->editorManager()->duplicateEditor(e);
|
||||||
m_splitter->addWidget(new SplitterOrView(duplicateA));
|
m_splitter->addWidget((focusView = new SplitterOrView(duplicateA)));
|
||||||
focus = duplicateA;
|
|
||||||
} else {
|
} else {
|
||||||
m_view->removeEditor(e);
|
m_view->removeEditor(e);
|
||||||
m_splitter->addWidget(new SplitterOrView(e));
|
m_splitter->addWidget((focusView = new SplitterOrView(e)));
|
||||||
Q_ASSERT(m_view->currentEditor() == 0);
|
Q_ASSERT(m_view->currentEditor() == 0);
|
||||||
}
|
}
|
||||||
Core::IEditor *duplicate = CoreImpl::instance()->editorManager()->duplicateEditor(e);
|
Core::IEditor *duplicate = CoreImpl::instance()->editorManager()->duplicateEditor(e);
|
||||||
@@ -547,7 +596,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
|
|||||||
m_layout->setCurrentWidget(m_splitter);
|
m_layout->setCurrentWidget(m_splitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
focus->widget()->setFocus();
|
focusView->view()->setCurrentEditor(focusView->editor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitterOrView::close()
|
void SplitterOrView::close()
|
||||||
@@ -576,8 +625,8 @@ void SplitterOrView::unsplit(Core::IEditor *editor)
|
|||||||
if (!m_isRoot) {
|
if (!m_isRoot) {
|
||||||
m_view = new EditorView(CoreImpl::instance()->editorManager()->openedEditorsModel());
|
m_view = new EditorView(CoreImpl::instance()->editorManager()->openedEditorsModel());
|
||||||
m_view->addEditor(editor);
|
m_view->addEditor(editor);
|
||||||
m_view->setCurrentEditor(editor);
|
|
||||||
m_layout->addWidget(m_view);
|
m_layout->addWidget(m_view);
|
||||||
|
m_view->setCurrentEditor(editor);
|
||||||
}
|
}
|
||||||
closeSplitterEditors();
|
closeSplitterEditors();
|
||||||
delete m_splitter;
|
delete m_splitter;
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
void insertEditor(int i, IEditor *editor);
|
void insertEditor(int i, IEditor *editor);
|
||||||
void removeEditor(IEditor *editor);
|
void removeEditor(IEditor *editor);
|
||||||
IEditor *currentEditor() const;
|
IEditor *currentEditor() const;
|
||||||
void setCurrentEditor(IEditor *editor);
|
void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||||
|
|
||||||
bool hasEditor(IEditor *editor) const;
|
bool hasEditor(IEditor *editor) const;
|
||||||
|
|
||||||
@@ -117,9 +117,6 @@ public:
|
|||||||
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
void focusInEvent(QFocusEvent *e);
|
||||||
|
|
||||||
signals:
|
|
||||||
void closeRequested(Core::IEditor *editor);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendCloseRequest();
|
void sendCloseRequest();
|
||||||
void updateEditorStatus(Core::IEditor *editor = 0);
|
void updateEditorStatus(Core::IEditor *editor = 0);
|
||||||
@@ -159,6 +156,7 @@ public:
|
|||||||
void unsplit(Core::IEditor *editor);
|
void unsplit(Core::IEditor *editor);
|
||||||
|
|
||||||
bool isView() const { return m_view != 0; }
|
bool isView() const { return m_view != 0; }
|
||||||
|
bool isSplitter() const { return m_splitter != 0; }
|
||||||
Core::IEditor *editor() const { return m_view ? m_view->currentEditor() : 0; }
|
Core::IEditor *editor() const { return m_view ? m_view->currentEditor() : 0; }
|
||||||
QList<Core::IEditor *> editors() const { return m_view ? m_view->editors() : QList<Core::IEditor*>(); }
|
QList<Core::IEditor *> editors() const { return m_view ? m_view->editors() : QList<Core::IEditor*>(); }
|
||||||
bool hasEditor(Core::IEditor *editor) const { return m_view && m_view->hasEditor(editor); }
|
bool hasEditor(Core::IEditor *editor) const { return m_view && m_view->hasEditor(editor); }
|
||||||
@@ -166,11 +164,15 @@ public:
|
|||||||
QSplitter *splitter() const { return m_splitter; }
|
QSplitter *splitter() const { return m_splitter; }
|
||||||
|
|
||||||
SplitterOrView *findView(Core::IEditor *editor);
|
SplitterOrView *findView(Core::IEditor *editor);
|
||||||
|
SplitterOrView *findFirstView();
|
||||||
SplitterOrView *findSplitter(Core::IEditor *editor);
|
SplitterOrView *findSplitter(Core::IEditor *editor);
|
||||||
|
|
||||||
|
SplitterOrView *findNextView(Core::IEditor *editor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void close();
|
void close();
|
||||||
void closeSplitterEditors();
|
void closeSplitterEditors();
|
||||||
|
SplitterOrView *findNextView_helper(Core::IEditor *editor, bool *found);
|
||||||
bool m_isRoot;
|
bool m_isRoot;
|
||||||
QStackedLayout *m_layout;
|
QStackedLayout *m_layout;
|
||||||
EditorView *m_view;
|
EditorView *m_view;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
|
|||||||
void OpenEditorsWidget::selectEditor(const QModelIndex &index)
|
void OpenEditorsWidget::selectEditor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
IEditor *editor = index.data(Qt::UserRole).value<IEditor*>();
|
IEditor *editor = index.data(Qt::UserRole).value<IEditor*>();
|
||||||
EditorManager::instance()->setCurrentEditor(editor);
|
EditorManager::instance()->activateEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ bool OpenEditorsWindow::isSameFile(IEditor *editorA, IEditor *editorB) const
|
|||||||
OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
|
OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
|
||||||
QWidget(parent, Qt::Popup),
|
QWidget(parent, Qt::Popup),
|
||||||
m_editorList(new QTreeWidget(this)),
|
m_editorList(new QTreeWidget(this)),
|
||||||
m_mode(HistoryMode),
|
|
||||||
m_current(0)
|
m_current(0)
|
||||||
{
|
{
|
||||||
resize(QSize(WIDTH, HEIGHT));
|
resize(QSize(WIDTH, HEIGHT));
|
||||||
@@ -79,13 +78,6 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
|
|||||||
|
|
||||||
m_autoHide.setSingleShot(true);
|
m_autoHide.setSingleShot(true);
|
||||||
connect(&m_autoHide, SIGNAL(timeout()), this, SLOT(selectAndHide()));
|
connect(&m_autoHide, SIGNAL(timeout()), this, SLOT(selectAndHide()));
|
||||||
EditorManager *em = EditorManager::instance();
|
|
||||||
connect(em, SIGNAL(editorOpened(Core::IEditor *)),
|
|
||||||
this, SLOT(updateEditorList()));
|
|
||||||
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor *>)),
|
|
||||||
this, SLOT(updateEditorList()));
|
|
||||||
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
||||||
this, SLOT(updateEditorList()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::selectAndHide()
|
void OpenEditorsWindow::selectAndHide()
|
||||||
@@ -98,7 +90,6 @@ void OpenEditorsWindow::setVisible(bool visible)
|
|||||||
{
|
{
|
||||||
QWidget::setVisible(visible);
|
QWidget::setVisible(visible);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
updateEditorList(m_current);
|
|
||||||
m_autoHide.start(600);
|
m_autoHide.start(600);
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
@@ -106,8 +97,6 @@ void OpenEditorsWindow::setVisible(bool visible)
|
|||||||
|
|
||||||
bool OpenEditorsWindow::isCentering()
|
bool OpenEditorsWindow::isCentering()
|
||||||
{
|
{
|
||||||
if (m_mode == OpenEditorsWindow::HistoryMode || m_editorList->topLevelItemCount() < 3)
|
|
||||||
return false;
|
|
||||||
int internalMargin = m_editorList->viewport()->mapTo(m_editorList, QPoint(0,0)).y();
|
int internalMargin = m_editorList->viewport()->mapTo(m_editorList, QPoint(0,0)).y();
|
||||||
QRect rect0 = m_editorList->visualItemRect(m_editorList->topLevelItem(0));
|
QRect rect0 = m_editorList->visualItemRect(m_editorList->topLevelItem(0));
|
||||||
QRect rect1 = m_editorList->visualItemRect(m_editorList->topLevelItem(m_editorList->topLevelItemCount()-1));
|
QRect rect1 = m_editorList->visualItemRect(m_editorList->topLevelItem(m_editorList->topLevelItemCount()-1));
|
||||||
@@ -118,11 +107,6 @@ bool OpenEditorsWindow::isCentering()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::setMode(Mode mode)
|
|
||||||
{
|
|
||||||
m_mode = mode;
|
|
||||||
updateEditorList(m_current);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenEditorsWindow::event(QEvent *e) {
|
bool OpenEditorsWindow::event(QEvent *e) {
|
||||||
if (e->type() == QEvent::KeyRelease) {
|
if (e->type() == QEvent::KeyRelease) {
|
||||||
@@ -187,89 +171,17 @@ void OpenEditorsWindow::selectUpDown(bool up)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (editor)
|
if (editor)
|
||||||
updateEditorList(editor);
|
setSelectedEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::selectPreviousEditor()
|
void OpenEditorsWindow::selectPreviousEditor()
|
||||||
{
|
{
|
||||||
selectUpDown(m_mode == ListMode);
|
selectUpDown(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::selectNextEditor()
|
void OpenEditorsWindow::selectNextEditor()
|
||||||
{
|
{
|
||||||
selectUpDown(m_mode != ListMode);
|
selectUpDown(true);
|
||||||
}
|
|
||||||
|
|
||||||
void OpenEditorsWindow::updateEditorList(IEditor *editor)
|
|
||||||
{
|
|
||||||
if (!editor)
|
|
||||||
editor = EditorManager::instance()->currentEditor();
|
|
||||||
m_current = editor;
|
|
||||||
if (m_mode == ListMode)
|
|
||||||
updateList();
|
|
||||||
else if (m_mode == HistoryMode)
|
|
||||||
updateHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenEditorsWindow::updateHistory()
|
|
||||||
{
|
|
||||||
EditorManager *em = EditorManager::instance();
|
|
||||||
QList<IEditor *> history = em->editorHistory();
|
|
||||||
int oldNum = m_editorList->topLevelItemCount();
|
|
||||||
int num = history.count();
|
|
||||||
int common = qMin(oldNum, num);
|
|
||||||
int selectedIndex = -1;
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
for (int i = 0; i < common; ++i) {
|
|
||||||
item = m_editorList->topLevelItem(i);
|
|
||||||
updateItem(item, history.at(i));
|
|
||||||
if (isSameFile(history.at(i), m_current))
|
|
||||||
selectedIndex = i;
|
|
||||||
}
|
|
||||||
for (int i = common; i < num; ++i) {
|
|
||||||
item = new QTreeWidgetItem(QStringList() << "");
|
|
||||||
updateItem(item, history.at(i));
|
|
||||||
m_editorList->addTopLevelItem(item);
|
|
||||||
if (isSameFile(history.at(i), m_current))
|
|
||||||
selectedIndex = i;
|
|
||||||
}
|
|
||||||
for (int i = oldNum-1; i >= common; --i) {
|
|
||||||
delete m_editorList->takeTopLevelItem(i);
|
|
||||||
}
|
|
||||||
if (isCentering())
|
|
||||||
centerOnItem(selectedIndex);
|
|
||||||
updateSelectedEditor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenEditorsWindow::updateList()
|
|
||||||
{
|
|
||||||
EditorManager *em = EditorManager::instance();
|
|
||||||
int oldNum = m_editorList->topLevelItemCount();
|
|
||||||
int curItem = 0;
|
|
||||||
int selectedIndex = -1;
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
foreach (IEditor *editor, em->openedEditors()){
|
|
||||||
if (curItem < oldNum) {
|
|
||||||
item = m_editorList->topLevelItem(curItem);
|
|
||||||
} else {
|
|
||||||
item = new QTreeWidgetItem(QStringList()<<"");
|
|
||||||
m_editorList->addTopLevelItem(item);
|
|
||||||
}
|
|
||||||
updateItem(item, editor);
|
|
||||||
if (isSameFile(editor, m_current)) {
|
|
||||||
m_editorList->setCurrentItem(item);
|
|
||||||
selectedIndex = curItem;
|
|
||||||
}
|
|
||||||
curItem++;
|
|
||||||
}
|
|
||||||
for (int i = oldNum-1; i >= curItem; --i) {
|
|
||||||
delete m_editorList->takeTopLevelItem(i);
|
|
||||||
}
|
|
||||||
if (isCentering())
|
|
||||||
centerOnItem(selectedIndex);
|
|
||||||
if (m_current == 0 && m_editorList->currentItem())
|
|
||||||
m_editorList->currentItem()->setSelected(false);
|
|
||||||
m_editorList->scrollTo(m_editorList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::centerOnItem(int selectedIndex)
|
void OpenEditorsWindow::centerOnItem(int selectedIndex)
|
||||||
@@ -290,22 +202,34 @@ void OpenEditorsWindow::centerOnItem(int selectedIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::updateItem(QTreeWidgetItem *item, IEditor *editor)
|
void OpenEditorsWindow::setEditors(const QList<IEditor *>&editors, IEditor *current)
|
||||||
{
|
{
|
||||||
static const QIcon lockedIcon(QLatin1String(":/core/images/locked.png"));
|
static const QIcon lockedIcon(QLatin1String(":/core/images/locked.png"));
|
||||||
static const QIcon emptyIcon(QLatin1String(":/core/images/empty14.png"));
|
static const QIcon emptyIcon(QLatin1String(":/core/images/empty14.png"));
|
||||||
|
|
||||||
QString title = editor->displayName();
|
m_editorList->clear();
|
||||||
if (editor->file()->isModified())
|
|
||||||
title += tr("*");
|
foreach (IEditor *editor, editors) {
|
||||||
item->setIcon(0, editor->file()->isReadOnly() ? lockedIcon : emptyIcon);
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, title);
|
|
||||||
item->setToolTip(0, editor->file()->fileName());
|
QString title = editor->displayName();
|
||||||
item->setData(0, Qt::UserRole, QVariant::fromValue(editor));
|
if (editor->file()->isModified())
|
||||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
title += tr("*");
|
||||||
item->setTextAlignment(0, Qt::AlignLeft);
|
item->setIcon(0, editor->file()->isReadOnly() ? lockedIcon : emptyIcon);
|
||||||
|
item->setText(0, title);
|
||||||
|
item->setToolTip(0, editor->file()->fileName());
|
||||||
|
item->setData(0, Qt::UserRole, QVariant::fromValue(editor));
|
||||||
|
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
|
||||||
|
item->setTextAlignment(0, Qt::AlignLeft);
|
||||||
|
|
||||||
|
m_editorList->addTopLevelItem(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
setSelectedEditor(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
IEditor *editor = 0;
|
IEditor *editor = 0;
|
||||||
@@ -320,6 +244,13 @@ void OpenEditorsWindow::editorClicked(QTreeWidgetItem *item)
|
|||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OpenEditorsWindow::setSelectedEditor(IEditor *editor)
|
||||||
|
{
|
||||||
|
m_current = editor;
|
||||||
|
updateSelectedEditor();
|
||||||
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::updateSelectedEditor()
|
void OpenEditorsWindow::updateSelectedEditor()
|
||||||
{
|
{
|
||||||
if (m_current == 0 && m_editorList->currentItem()) {
|
if (m_current == 0 && m_editorList->currentItem()) {
|
||||||
@@ -330,7 +261,7 @@ void OpenEditorsWindow::updateSelectedEditor()
|
|||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
IEditor *editor = m_editorList->topLevelItem(i)
|
IEditor *editor = m_editorList->topLevelItem(i)
|
||||||
->data(0, Qt::UserRole).value<IEditor *>();
|
->data(0, Qt::UserRole).value<IEditor *>();
|
||||||
if (isSameFile(editor,m_current)) {
|
if (editor == m_current) {
|
||||||
m_editorList->setCurrentItem(m_editorList->topLevelItem(i));
|
m_editorList->setCurrentItem(m_editorList->topLevelItem(i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -338,7 +269,3 @@ void OpenEditorsWindow::updateSelectedEditor()
|
|||||||
m_editorList->scrollTo(m_editorList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
m_editorList->scrollTo(m_editorList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWindow::setSelectedEditor(IEditor *editor)
|
|
||||||
{
|
|
||||||
updateEditorList(editor);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -57,20 +57,18 @@ public:
|
|||||||
OpenEditorsWindow(QWidget *parent = 0);
|
OpenEditorsWindow(QWidget *parent = 0);
|
||||||
~OpenEditorsWindow() {}
|
~OpenEditorsWindow() {}
|
||||||
|
|
||||||
void setMode(Mode mode);
|
void setEditors(const QList<IEditor *>&editors, IEditor *current);
|
||||||
Mode mode() const { return m_mode; }
|
|
||||||
|
|
||||||
bool event(QEvent *e);
|
bool event(QEvent *e);
|
||||||
bool eventFilter(QObject *src, QEvent *e);
|
bool eventFilter(QObject *src, QEvent *e);
|
||||||
void focusInEvent(QFocusEvent *);
|
void focusInEvent(QFocusEvent *);
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
void setSelectedEditor(IEditor *editor);
|
|
||||||
void selectNextEditor();
|
void selectNextEditor();
|
||||||
void selectPreviousEditor();
|
void selectPreviousEditor();
|
||||||
IEditor *selectedEditor() const { return m_current; }
|
IEditor *selectedEditor() const { return m_current; }
|
||||||
|
void setSelectedEditor(IEditor *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateEditorList(IEditor *current = 0);
|
|
||||||
void editorClicked(QTreeWidgetItem *item);
|
void editorClicked(QTreeWidgetItem *item);
|
||||||
void selectEditor(QTreeWidgetItem *item);
|
void selectEditor(QTreeWidgetItem *item);
|
||||||
void selectAndHide();
|
void selectAndHide();
|
||||||
@@ -81,8 +79,6 @@ private:
|
|||||||
static const int MARGIN;
|
static const int MARGIN;
|
||||||
|
|
||||||
static void updateItem(QTreeWidgetItem *item, IEditor *editor);
|
static void updateItem(QTreeWidgetItem *item, IEditor *editor);
|
||||||
void updateList();
|
|
||||||
void updateHistory();
|
|
||||||
void updateSelectedEditor();
|
void updateSelectedEditor();
|
||||||
bool isCentering();
|
bool isCentering();
|
||||||
void centerOnItem(int selectedIndex);
|
void centerOnItem(int selectedIndex);
|
||||||
@@ -91,7 +87,6 @@ private:
|
|||||||
bool isSameFile(IEditor *editorA, IEditor *editorB) const;
|
bool isSameFile(IEditor *editorA, IEditor *editorB) const;
|
||||||
|
|
||||||
QTreeWidget *m_editorList;
|
QTreeWidget *m_editorList;
|
||||||
Mode m_mode;
|
|
||||||
QTimer m_autoHide;
|
QTimer m_autoHide;
|
||||||
IEditor *m_current;
|
IEditor *m_current;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user