forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.8'
Conflicts: qtcreator.pri qtcreator.qbs src/libs/extensionsystem/pluginmanager.cpp src/plugins/coreplugin/documentmanager.cpp src/plugins/fakevim/fakevimhandler.cpp Change-Id: Ibc2adc40bad6f10df94c50d66e78dc3f4bcb84c0
This commit is contained in:
@@ -649,7 +649,7 @@ bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *e
|
||||
{
|
||||
foreach (const Core::GeneratedFile &file, l) {
|
||||
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
|
||||
if (!Core::EditorManager::openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) {
|
||||
if (!Core::EditorManager::openEditor(file.path(), file.editorId())) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Failed to open an editor for '%1'.").arg(QDir::toNativeSeparators(file.path()));
|
||||
return false;
|
||||
|
||||
@@ -109,7 +109,7 @@ const char SPLIT_SIDE_BY_SIDE[] = "QtCreator.SplitSideBySide";
|
||||
const char SPLIT_NEW_WINDOW[] = "QtCreator.SplitNewWindow";
|
||||
const char REMOVE_CURRENT_SPLIT[] = "QtCreator.RemoveCurrentSplit";
|
||||
const char REMOVE_ALL_SPLITS[] = "QtCreator.RemoveAllSplits";
|
||||
const char GOTO_OTHER_SPLIT[] = "QtCreator.GotoOtherSplit";
|
||||
const char GOTO_NEXT_SPLIT[] = "QtCreator.GotoOtherSplit";
|
||||
const char CLOSE[] = "QtCreator.Close";
|
||||
const char CLOSE_ALTERNATIVE[] = "QtCreator.Close_Alternative"; // temporary, see QTCREATORBUG-72
|
||||
const char CLOSEALL[] = "QtCreator.CloseAll";
|
||||
|
||||
@@ -120,7 +120,6 @@ DesignMode::DesignMode()
|
||||
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Design.png")));
|
||||
setPriority(Constants::P_MODE_DESIGN);
|
||||
setId(Constants::MODE_DESIGN);
|
||||
setType(Constants::MODE_DESIGN_TYPE);
|
||||
|
||||
ExtensionSystem::PluginManager::addObject(d->m_coreListener);
|
||||
|
||||
|
||||
@@ -1352,7 +1352,7 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
|
||||
return;
|
||||
}
|
||||
|
||||
EditorManager::openEditor(entry.fileName, entry.editorFactory->id(), EditorManager::ModeSwitch);
|
||||
EditorManager::openEditor(entry.fileName, entry.editorFactory->id());
|
||||
return;
|
||||
}
|
||||
if (entry.externalEditor)
|
||||
|
||||
@@ -55,7 +55,6 @@ EditMode::EditMode() :
|
||||
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Edit.png")));
|
||||
setPriority(Constants::P_MODE_EDIT);
|
||||
setId(Constants::MODE_EDIT);
|
||||
setType(Constants::MODE_EDIT_TYPE);
|
||||
|
||||
m_rightSplitWidgetLayout->setSpacing(0);
|
||||
m_rightSplitWidgetLayout->setMargin(0);
|
||||
|
||||
@@ -196,7 +196,7 @@ struct EditorManagerPrivate
|
||||
QAction *m_splitNewWindowAction;
|
||||
QAction *m_removeCurrentSplitAction;
|
||||
QAction *m_removeAllSplitsAction;
|
||||
QAction *m_gotoOtherSplitAction;
|
||||
QAction *m_gotoNextSplitAction;
|
||||
|
||||
QAction *m_saveCurrentEditorContextAction;
|
||||
QAction *m_saveAsCurrentEditorContextAction;
|
||||
@@ -381,7 +381,7 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide()));
|
||||
|
||||
d->m_splitNewWindowAction = new QAction(tr("Split New Window"), this);
|
||||
d->m_splitNewWindowAction = new QAction(tr("Open in New Window"), this);
|
||||
cmd = ActionManager::registerAction(d->m_splitNewWindowAction, Constants::SPLIT_NEW_WINDOW, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,4") : tr("Ctrl+E,4")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
@@ -399,11 +399,11 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_removeAllSplitsAction, SIGNAL(triggered()), this, SLOT(removeAllSplits()));
|
||||
|
||||
d->m_gotoOtherSplitAction = new QAction(tr("Go to Next Split"), this);
|
||||
cmd = ActionManager::registerAction(d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, editManagerContext);
|
||||
d->m_gotoNextSplitAction = new QAction(tr("Go to Next Split or Window"), this);
|
||||
cmd = ActionManager::registerAction(d->m_gotoNextSplitAction, Constants::GOTO_NEXT_SPLIT, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,o") : tr("Ctrl+E,o")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit()));
|
||||
connect(d->m_gotoNextSplitAction, SIGNAL(triggered()), this, SLOT(gotoNextSplit()));
|
||||
|
||||
ActionContainer *medit = ActionManager::actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *advancedMenu = ActionManager::createMenu(Constants::M_EDIT_ADVANCED);
|
||||
@@ -604,13 +604,20 @@ EditorView *EditorManager::viewForEditor(IEditor *editor)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SplitterOrView *EditorManager::findRoot(EditorView *view)
|
||||
SplitterOrView *EditorManager::findRoot(const EditorView *view, int *rootIndex)
|
||||
{
|
||||
SplitterOrView *current = view->parentSplitterOrView();
|
||||
while (current && !m_instance->d->m_root.contains(current)) {
|
||||
while (current) {
|
||||
int index = m_instance->d->m_root.indexOf(current);
|
||||
if (index >= 0) {
|
||||
if (rootIndex)
|
||||
*rootIndex = index;
|
||||
return current;
|
||||
}
|
||||
current = current->findParentSplitter();
|
||||
}
|
||||
return current;
|
||||
QTC_CHECK(false); // we should never have views without a root
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<IEditor *> EditorManager::editorsForFileName(const QString &filename) const
|
||||
@@ -691,15 +698,15 @@ void EditorManager::splitNewWindow(Internal::EditorView *view)
|
||||
context->setContext(Context(Constants::C_EDITORMANAGER));
|
||||
context->setWidget(splitter);
|
||||
ICore::addContextObject(context);
|
||||
m_instance->d->m_root.append(splitter);
|
||||
m_instance->d->m_rootContext.append(context);
|
||||
connect(splitter, SIGNAL(destroyed(QObject*)), m_instance, SLOT(rootDestroyed(QObject*)));
|
||||
splitter->show();
|
||||
ICore::raiseWindow(splitter);
|
||||
if (newEditor)
|
||||
m_instance->activateEditor(splitter->view(), newEditor, IgnoreNavigationHistory);
|
||||
else
|
||||
splitter->view()->setFocus();
|
||||
m_instance->d->m_root.append(splitter);
|
||||
m_instance->d->m_rootContext.append(context);
|
||||
connect(splitter, SIGNAL(destroyed(QObject*)), m_instance, SLOT(rootDestroyed(QObject*)));
|
||||
m_instance->updateActions();
|
||||
}
|
||||
|
||||
@@ -1042,15 +1049,15 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
if (!newCurrent)
|
||||
newCurrent = pickUnusedEditor();
|
||||
if (newCurrent) {
|
||||
activateEditor(view, newCurrent, NoActivate);
|
||||
activateEditor(view, newCurrent, DoNotChangeCurrentEditor);
|
||||
} else {
|
||||
QModelIndex idx = d->m_editorModel->firstRestoredEditor();
|
||||
if (idx.isValid()) {
|
||||
activateEditorForIndex(view, idx, NoActivate);
|
||||
activateEditorForIndex(view, idx, DoNotChangeCurrentEditor);
|
||||
} else {
|
||||
const QList<IEditor *> editors = d->m_editorModel->editors();
|
||||
if (!editors.isEmpty())
|
||||
activateEditor(view, editors.last(), NoActivate);
|
||||
activateEditor(view, editors.last(), DoNotChangeCurrentEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1105,11 +1112,11 @@ void EditorManager::closeDuplicate(Core::IEditor *editor)
|
||||
if (!newCurrent)
|
||||
newCurrent = pickUnusedEditor();
|
||||
if (newCurrent) {
|
||||
activateEditor(view, newCurrent, NoActivate);
|
||||
activateEditor(view, newCurrent, DoNotChangeCurrentEditor);
|
||||
} else {
|
||||
QModelIndex idx = d->m_editorModel->firstRestoredEditor();
|
||||
if (idx.isValid())
|
||||
activateEditorForIndex(view, idx, NoActivate);
|
||||
activateEditorForIndex(view, idx, DoNotChangeCurrentEditor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,6 +1158,18 @@ void EditorManager::activateEditorForIndex(Internal::EditorView *view, const QMo
|
||||
d->m_editorModel->removeEditor(index);
|
||||
}
|
||||
|
||||
void EditorManager::activateView(EditorView *view)
|
||||
{
|
||||
QTC_ASSERT(view, return);
|
||||
if (IEditor *editor = view->currentEditor()) {
|
||||
setCurrentEditor(editor, true);
|
||||
editor->widget()->setFocus();
|
||||
ICore::raiseWindow(editor->widget());
|
||||
} else {
|
||||
setCurrentView(view);
|
||||
}
|
||||
}
|
||||
|
||||
Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core::IEditor *editor)
|
||||
{
|
||||
Q_ASSERT(view && editor);
|
||||
@@ -1202,13 +1221,22 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
|
||||
|
||||
editor = placeEditor(view, editor);
|
||||
|
||||
if (!(flags & NoActivate)) {
|
||||
if (!(flags & DoNotChangeCurrentEditor)) {
|
||||
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
|
||||
if (flags & ModeSwitch)
|
||||
switchToPreferedMode();
|
||||
if (isVisible()) {
|
||||
editor->widget()->setFocus();
|
||||
ICore::raiseWindow(editor->widget());
|
||||
if (!(flags & DoNotMakeVisible)) {
|
||||
// switch to design mode?
|
||||
if (editor->isDesignModePreferred()) {
|
||||
ModeManager::activateMode(Core::Constants::MODE_DESIGN);
|
||||
ModeManager::setFocusToCurrentMode();
|
||||
} else {
|
||||
int rootIndex;
|
||||
findRoot(view, &rootIndex);
|
||||
if (rootIndex == 0) // main window --> we might need to switch mode
|
||||
if (!editor->widget()->isVisible())
|
||||
ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||
editor->widget()->setFocus();
|
||||
ICore::raiseWindow(editor->widget());
|
||||
}
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
@@ -1394,18 +1422,23 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
|
||||
IEditor *EditorManager::openEditor(const QString &fileName, const Id &editorId,
|
||||
OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
if (flags & EditorManager::OpenInOtherSplit)
|
||||
m_instance->gotoOtherSplit();
|
||||
return m_instance->openEditor(m_instance->currentEditorView(),
|
||||
fileName, editorId, flags, newEditor);
|
||||
}
|
||||
|
||||
IEditor *EditorManager::openEditorInNextSplit(const QString &fileName, const Id &editorId, OpenEditorFlags flags, bool *newEditor)
|
||||
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
|
||||
const Id &editorId, OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
if (!m_instance->hasSplitter())
|
||||
m_instance->splitSideBySide();
|
||||
|
||||
m_instance->gotoOtherSplit();
|
||||
return m_instance->openEditor(m_instance->currentEditorView(),
|
||||
fileName, editorId, flags, newEditor);
|
||||
m_instance->cutForwardNavigationHistory();
|
||||
m_instance->addCurrentPositionToNavigationHistory();
|
||||
OpenEditorFlags tempFlags = flags | IgnoreNavigationHistory;
|
||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName, editorId,
|
||||
tempFlags, newEditor);
|
||||
if (editor && line != -1)
|
||||
editor->gotoLine(line, column);
|
||||
return editor;
|
||||
}
|
||||
|
||||
static int extractLineNumber(QString *fileName)
|
||||
@@ -1548,22 +1581,6 @@ QStringList EditorManager::getOpenFileNames() const
|
||||
}
|
||||
|
||||
|
||||
/// Empty mode == figure out the correct mode from the editor
|
||||
/// forcePrefered = true, switch to the mode even if the editor is visible in another mode
|
||||
/// forcePrefered = false, only switch if it is not visible
|
||||
void EditorManager::switchToPreferedMode()
|
||||
{
|
||||
Id preferedMode;
|
||||
// Figure out preferred mode for editor
|
||||
if (d->m_currentEditor)
|
||||
preferedMode = d->m_currentEditor->preferredModeType();
|
||||
|
||||
if (!preferedMode.isValid())
|
||||
preferedMode = Id(Constants::MODE_EDIT_TYPE);
|
||||
|
||||
ModeManager::activateModeType(preferedMode);
|
||||
}
|
||||
|
||||
IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
||||
QString *titlePattern,
|
||||
const QString &contents)
|
||||
@@ -1973,7 +1990,7 @@ void EditorManager::updateActions()
|
||||
bool hasSplitter = parentSplitter && parentSplitter->isSplitter();
|
||||
d->m_removeCurrentSplitAction->setEnabled(hasSplitter);
|
||||
d->m_removeAllSplitsAction->setEnabled(hasSplitter);
|
||||
d->m_gotoOtherSplitAction->setEnabled(hasSplitter);
|
||||
d->m_gotoNextSplitAction->setEnabled(hasSplitter || d->m_root.size() > 1);
|
||||
}
|
||||
|
||||
void EditorManager::setCloseSplitEnabled(SplitterOrView *splitterOrView, bool enable)
|
||||
@@ -2010,7 +2027,8 @@ QList<IEditor*> EditorManager::visibleEditors() const
|
||||
if (view->currentEditor())
|
||||
editors.append(view->currentEditor());
|
||||
view = view->findNextView();
|
||||
} while (view && view != firstView);
|
||||
QTC_ASSERT(view != firstView, break); // we start with firstView and shouldn't have cycles
|
||||
} while (view);
|
||||
}
|
||||
} else {
|
||||
if (root->editor())
|
||||
@@ -2166,7 +2184,7 @@ bool EditorManager::restoreState(const QByteArray &state)
|
||||
continue;
|
||||
QFileInfo rfi(autoSaveName(fileName));
|
||||
if (rfi.exists() && fi.lastModified() < rfi.lastModified())
|
||||
openEditor(fileName, id);
|
||||
openEditor(fileName, id, DoNotMakeVisible);
|
||||
else
|
||||
d->m_editorModel->addRestoredEditor(fileName, displayName, id);
|
||||
}
|
||||
@@ -2375,26 +2393,77 @@ void EditorManager::removeAllSplits()
|
||||
root->unsplitAll();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Moves focus to the next split, cycling through windows.
|
||||
*/
|
||||
void EditorManager::gotoNextSplit()
|
||||
{
|
||||
EditorView *view = currentEditorView();
|
||||
if (!view)
|
||||
return;
|
||||
EditorView *nextView = view->findNextView();
|
||||
if (!nextView) {
|
||||
// we are in the "last" view in this root
|
||||
int rootIndex = -1;
|
||||
SplitterOrView *root = findRoot(view, &rootIndex);
|
||||
QTC_ASSERT(root, return);
|
||||
QTC_ASSERT(rootIndex >= 0 && rootIndex < d->m_root.size(), return);
|
||||
// find next root. this might be the same root if there's only one.
|
||||
int nextRootIndex = rootIndex + 1;
|
||||
if (nextRootIndex >= d->m_root.size())
|
||||
nextRootIndex = 0;
|
||||
nextView = d->m_root.at(nextRootIndex)->findFirstView();
|
||||
QTC_CHECK(nextView);
|
||||
}
|
||||
|
||||
if (nextView)
|
||||
activateView(nextView);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Moves focus to "other" split, possibly creating a split if necessary.
|
||||
* If there's no split and no other window, a side-by-side split is created.
|
||||
* If the current window is split, focus is moved to the next split within this window, cycling.
|
||||
* If the current window is not split, focus is moved to the next window.
|
||||
*/
|
||||
void EditorManager::gotoOtherSplit()
|
||||
{
|
||||
EditorView *view = currentEditorView();
|
||||
if (!view)
|
||||
return;
|
||||
SplitterOrView *root = findRoot(view);
|
||||
QTC_ASSERT(root, return);
|
||||
if (!root->isSplitter())
|
||||
splitSideBySide();
|
||||
|
||||
view = view->findNextView();
|
||||
if (view) {
|
||||
if (IEditor *editor = view->currentEditor()) {
|
||||
setCurrentEditor(editor, true);
|
||||
editor->widget()->setFocus();
|
||||
ICore::raiseWindow(editor->widget());
|
||||
EditorView *nextView = view->findNextView();
|
||||
if (!nextView) {
|
||||
// we are in the "last" view in this root
|
||||
int rootIndex = -1;
|
||||
SplitterOrView *root = findRoot(view, &rootIndex);
|
||||
QTC_ASSERT(root, return);
|
||||
QTC_ASSERT(rootIndex >= 0 && rootIndex < d->m_root.size(), return);
|
||||
// stay in same window if it is split
|
||||
if (root->isSplitter()) {
|
||||
nextView = root->findFirstView();
|
||||
QTC_CHECK(nextView != view);
|
||||
} else {
|
||||
setCurrentView(view);
|
||||
// find next root. this might be the same root if there's only one.
|
||||
int nextRootIndex = rootIndex + 1;
|
||||
if (nextRootIndex >= d->m_root.size())
|
||||
nextRootIndex = 0;
|
||||
nextView = d->m_root.at(nextRootIndex)->findFirstView();
|
||||
QTC_CHECK(nextView);
|
||||
// if we had only one root with only one view, we end up at the startpoint
|
||||
// in that case we need to split
|
||||
if (nextView == view) {
|
||||
QTC_CHECK(!root->isSplitter());
|
||||
splitSideBySide(); // that deletes 'view'
|
||||
view = root->findFirstView();
|
||||
nextView = view->findNextView();
|
||||
QTC_CHECK(nextView != view);
|
||||
QTC_CHECK(nextView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextView)
|
||||
activateView(nextView);
|
||||
}
|
||||
|
||||
qint64 EditorManager::maxTextFileSize()
|
||||
|
||||
@@ -107,18 +107,20 @@ public:
|
||||
static EditorToolBar *createToolBar(QWidget *parent = 0);
|
||||
|
||||
enum OpenEditorFlag {
|
||||
NoActivate = 1,
|
||||
DoNotChangeCurrentEditor = 1,
|
||||
IgnoreNavigationHistory = 2,
|
||||
ModeSwitch = 4,
|
||||
CanContainLineNumber = 8
|
||||
DoNotMakeVisible = 4,
|
||||
CanContainLineNumber = 8,
|
||||
OpenInOtherSplit = 16
|
||||
};
|
||||
Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag)
|
||||
|
||||
static QString splitLineNumber(QString *fileName);
|
||||
static IEditor *openEditor(const QString &fileName, const Id &editorId = Id(),
|
||||
OpenEditorFlags flags = 0, bool *newEditor = 0);
|
||||
static IEditor *openEditorInNextSplit(const QString &fileName, const Id &editorId = Id(),
|
||||
OpenEditorFlags flags = 0, bool *newEditor = 0);
|
||||
static IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
|
||||
const Id &editorId = Id(), OpenEditorFlags flags = 0,
|
||||
bool *newEditor = 0);
|
||||
static IEditor *openEditorWithContents(const Id &editorId,
|
||||
QString *titlePattern = 0, const QString &contents = QString());
|
||||
|
||||
@@ -234,6 +236,8 @@ private slots:
|
||||
void rootDestroyed(QObject *root);
|
||||
void setCurrentEditorFromContextChange();
|
||||
|
||||
void gotoNextSplit();
|
||||
|
||||
public slots:
|
||||
void goBackInNavigationHistory();
|
||||
void goForwardInNavigationHistory();
|
||||
@@ -257,6 +261,7 @@ private:
|
||||
IEditor *duplicateEditor(IEditor *editor);
|
||||
IEditor *activateEditor(Internal::EditorView *view, IEditor *editor, OpenEditorFlags flags = 0);
|
||||
void activateEditorForIndex(Internal::EditorView *view, const QModelIndex &index, OpenEditorFlags = 0);
|
||||
void activateView(Internal::EditorView *view);
|
||||
IEditor *openEditor(Internal::EditorView *view, const QString &fileName,
|
||||
const Id &id = Id(), OpenEditorFlags flags = 0, bool *newEditor = 0);
|
||||
|
||||
@@ -264,7 +269,7 @@ private:
|
||||
void setCurrentView(Internal::EditorView *view);
|
||||
Internal::EditorView *currentEditorView() const;
|
||||
static Internal::EditorView *viewForEditor(IEditor *editor);
|
||||
static Internal::SplitterOrView *findRoot(Internal::EditorView *view);
|
||||
static Internal::SplitterOrView *findRoot(const Internal::EditorView *view, int *rootIndex = 0);
|
||||
|
||||
void closeEditor(IEditor *editor);
|
||||
void closeDuplicate(IEditor *editor);
|
||||
@@ -273,7 +278,6 @@ private:
|
||||
static void splitNewWindow(Internal::EditorView *view);
|
||||
IEditor *pickUnusedEditor() const;
|
||||
void addDocumentToRecentFiles(IDocument *document);
|
||||
void switchToPreferedMode();
|
||||
void updateAutoSave();
|
||||
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
|
||||
void updateMakeWritableWarning();
|
||||
|
||||
@@ -144,8 +144,8 @@ EditorView *EditorView::findNextView()
|
||||
current = parent;
|
||||
parent = current->findParentSplitter();
|
||||
}
|
||||
// current has no parent, so just take the very first view
|
||||
return current->findFirstView();
|
||||
// current has no parent, so we are at the top and there is no "next" view
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EditorView::closeView()
|
||||
@@ -299,7 +299,7 @@ IEditor *EditorView::currentEditor() const
|
||||
void EditorView::listSelectionActivated(int index)
|
||||
{
|
||||
QAbstractItemModel *model = EditorManager::instance()->openedEditorsModel();
|
||||
EditorManager::instance()->activateEditorForIndex(this, model->index(index, 0), Core::EditorManager::ModeSwitch);
|
||||
EditorManager::instance()->activateEditorForIndex(this, model->index(index, 0));
|
||||
}
|
||||
|
||||
void EditorView::splitHorizontally()
|
||||
@@ -465,11 +465,11 @@ void EditorView::goBackInNavigationHistory()
|
||||
IEditor *editor = 0;
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
}
|
||||
if (!editor) {
|
||||
editor = em->openEditor(this, location.fileName, location.id,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
if (!editor) {
|
||||
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
|
||||
continue;
|
||||
@@ -492,7 +492,7 @@ void EditorView::goForwardInNavigationHistory()
|
||||
IEditor *editor = 0;
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
}
|
||||
if (!editor) {
|
||||
editor = em->openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory);
|
||||
@@ -784,13 +784,13 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
||||
if (!QFile::exists(fileName))
|
||||
return;
|
||||
IEditor *e = em->openEditor(view(), fileName, Id::fromString(id), Core::EditorManager::IgnoreNavigationHistory
|
||||
| Core::EditorManager::NoActivate);
|
||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||
|
||||
if (!e) {
|
||||
QModelIndex idx = em->openedEditorsModel()->firstRestoredEditor();
|
||||
if (idx.isValid())
|
||||
em->activateEditorForIndex(view(), idx, Core::EditorManager::IgnoreNavigationHistory
|
||||
| Core::EditorManager::NoActivate);
|
||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||
}
|
||||
|
||||
if (e) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
virtual QWidget *toolBar() = 0;
|
||||
|
||||
virtual Id preferredModeType() const { return Id(); }
|
||||
virtual bool isDesignModePreferred() const { return false; }
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
|
||||
#include "ieditorfactory.h"
|
||||
|
||||
#include "ieditor.h"
|
||||
#include "editormanager.h"
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
Core::IDocument *Core::IEditorFactory::open(const QString &fileName)
|
||||
Core::IDocument *Core::IEditorFactory::open(const QString &)
|
||||
{
|
||||
Core::IEditor *iface = Core::EditorManager::openEditor(fileName, id());
|
||||
return iface ? iface->document() : 0;
|
||||
qWarning("This should never be called, use IEditorFactor::createEditor, "
|
||||
"or EditorManager::openEditor instead!");
|
||||
QTC_CHECK(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
IEditorFactory(QObject *parent = 0) : IDocumentFactory(parent) {}
|
||||
|
||||
virtual IEditor *createEditor(QWidget *parent) = 0;
|
||||
virtual IDocument *open(const QString &fileName);
|
||||
virtual IDocument *open(const QString &);
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -189,7 +189,7 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
|
||||
void OpenEditorsWidget::activateEditor(const QModelIndex &index)
|
||||
{
|
||||
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
EditorManager::instance()->activateEditorForIndex(index, EditorManager::ModeSwitch);
|
||||
EditorManager::instance()->activateEditorForIndex(index);
|
||||
}
|
||||
|
||||
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
|
||||
|
||||
@@ -225,11 +225,10 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
||||
return;
|
||||
if (IDocument *document = item->data(0, Qt::UserRole).value<IDocument*>()) {
|
||||
EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>();
|
||||
EditorManager::instance()->activateEditorForDocument(view, document, EditorManager::ModeSwitch);
|
||||
EditorManager::instance()->activateEditorForDocument(view, document);
|
||||
} else {
|
||||
if (!EditorManager::openEditor(
|
||||
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>(),
|
||||
Core::EditorManager::ModeSwitch)) {
|
||||
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>())) {
|
||||
EditorManager::instance()->openedEditorsModel()->removeEditor(item->toolTip(0));
|
||||
delete item;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
|
||||
m_splitButton(new QToolButton),
|
||||
m_horizontalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)), EditorManager::tr("Split"), parent)),
|
||||
m_verticalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_VERTICAL)), EditorManager::tr("Split Side by Side"), parent)),
|
||||
m_splitNewWindowAction(new QAction(EditorManager::tr("Split New Window"), parent)),
|
||||
m_splitNewWindowAction(new QAction(EditorManager::tr("Open in New Window"), parent)),
|
||||
m_closeSplitButton(new QToolButton),
|
||||
m_activeToolBar(0),
|
||||
m_toolBarPlaceholder(new QWidget),
|
||||
@@ -311,7 +311,7 @@ void EditorToolBar::changeActiveEditor(int row)
|
||||
{
|
||||
EditorManager *em = ICore::editorManager();
|
||||
QAbstractItemModel *model = d->m_editorList->model();
|
||||
em->activateEditorForIndex(model->index(row, 0), EditorManager::ModeSwitch);
|
||||
em->activateEditorForIndex(model->index(row, 0));
|
||||
}
|
||||
|
||||
void EditorToolBar::listContextMenu(QPoint pos)
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
QIcon icon() const { return m_icon; }
|
||||
int priority() const { return m_priority; }
|
||||
Id id() const { return m_id; }
|
||||
Id type() const { return m_type; }
|
||||
bool isEnabled() const;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
@@ -57,7 +56,6 @@ public:
|
||||
void setIcon(const QIcon &icon) { m_icon = icon; }
|
||||
void setPriority(int priority) { m_priority = priority; }
|
||||
void setId(Id id) { m_id = id; }
|
||||
void setType(Id type) { m_type = type; }
|
||||
|
||||
signals:
|
||||
void enabledStateChanged(bool enabled);
|
||||
@@ -67,7 +65,6 @@ private:
|
||||
QIcon m_icon;
|
||||
int m_priority;
|
||||
Id m_id;
|
||||
Id m_type;
|
||||
bool m_isEnabled;
|
||||
};
|
||||
|
||||
|
||||
@@ -861,8 +861,6 @@ IDocument *MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesF
|
||||
}
|
||||
} else {
|
||||
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
||||
if (flags & ICore::SwitchMode)
|
||||
emFlags = EditorManager::ModeSwitch;
|
||||
if (flags & ICore::CanContainLineNumbers)
|
||||
emFlags |= EditorManager::CanContainLineNumber;
|
||||
IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags);
|
||||
@@ -1005,7 +1003,7 @@ void MainWindow::openFileWith()
|
||||
if (isExternal)
|
||||
EditorManager::openExternalEditor(fileName, editorId);
|
||||
else
|
||||
EditorManager::openEditor(fileName, editorId, Core::EditorManager::ModeSwitch);
|
||||
EditorManager::openEditor(fileName, editorId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1289,7 +1287,7 @@ void MainWindow::openRecentFile()
|
||||
{
|
||||
if (const QAction *action = qobject_cast<const QAction*>(sender())) {
|
||||
const DocumentManager::RecentFile file = action->data().value<DocumentManager::RecentFile>();
|
||||
EditorManager::openEditor(file.first, file.second, EditorManager::ModeSwitch);
|
||||
EditorManager::openEditor(file.first, file.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ struct ModeManagerPrivate
|
||||
Context m_addedContexts;
|
||||
int m_oldCurrent;
|
||||
bool m_saveSettingsOnModeChange;
|
||||
bool m_modeSelectorVisible;
|
||||
};
|
||||
|
||||
static ModeManagerPrivate *d;
|
||||
@@ -100,6 +101,8 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow,
|
||||
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
||||
d->m_modeStack->addCornerWidget(d->m_actionBar);
|
||||
d->m_saveSettingsOnModeChange = false;
|
||||
d->m_modeSelectorVisible = true;
|
||||
d->m_modeStack->setSelectionWidgetVisible(d->m_modeSelectorVisible);
|
||||
|
||||
connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||
@@ -147,21 +150,6 @@ IMode *ModeManager::mode(Id id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModeManager::activateModeType(Id type)
|
||||
{
|
||||
if (currentMode() && currentMode()->type() == type)
|
||||
return;
|
||||
int index = -1;
|
||||
for (int i = 0; i < d->m_modes.count(); ++i) {
|
||||
if (d->m_modes.at(i)->type() == type) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index != -1)
|
||||
d->m_modeStack->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void ModeManager::slotActivateMode(int id)
|
||||
{
|
||||
m_instance->activateMode(Id::fromUniqueIdentifier(id));
|
||||
@@ -330,21 +318,22 @@ void ModeManager::setFocusToCurrentMode()
|
||||
QWidget *widget = mode->widget();
|
||||
if (widget) {
|
||||
QWidget *focusWidget = widget->focusWidget();
|
||||
if (focusWidget)
|
||||
focusWidget->setFocus();
|
||||
else
|
||||
widget->setFocus();
|
||||
if (!focusWidget)
|
||||
focusWidget = widget;
|
||||
focusWidget->setFocus();
|
||||
ICore::raiseWindow(focusWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void ModeManager::setModeSelectorVisible(bool visible)
|
||||
{
|
||||
d->m_modeSelectorVisible = visible;
|
||||
d->m_modeStack->setSelectionWidgetVisible(visible);
|
||||
}
|
||||
|
||||
bool ModeManager::isModeSelectorVisible()
|
||||
{
|
||||
return d->m_modeStack->isSelectionWidgetVisible();
|
||||
return d->m_modeSelectorVisible;
|
||||
}
|
||||
|
||||
ModeManager *ModeManager::instance()
|
||||
|
||||
@@ -65,7 +65,6 @@ public:
|
||||
static void addProjectSelector(QAction *action);
|
||||
static void addWidget(QWidget *widget);
|
||||
|
||||
static void activateModeType(Id type);
|
||||
static void activateMode(Id id);
|
||||
static void setFocusToCurrentMode();
|
||||
static bool isModeSelectorVisible();
|
||||
|
||||
@@ -145,7 +145,6 @@ FutureProgress::FutureProgress(QWidget *parent) :
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn FutureProgress::~FutureProgress()
|
||||
\internal
|
||||
*/
|
||||
FutureProgress::~FutureProgress()
|
||||
@@ -155,7 +154,6 @@ FutureProgress::~FutureProgress()
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FutureProgress::setWidget(QWidget *widget)
|
||||
Sets the \a widget to show below the progress bar.
|
||||
This will be destroyed when the progress indicator is destroyed.
|
||||
Default is to show no widget below the progress indicator.
|
||||
@@ -172,7 +170,6 @@ void FutureProgress::setWidget(QWidget *widget)
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FutureProgress::setTitle(const QString &title)
|
||||
Changes the \a title of the progress indicator.
|
||||
*/
|
||||
void FutureProgress::setTitle(const QString &title)
|
||||
@@ -181,7 +178,6 @@ void FutureProgress::setTitle(const QString &title)
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QString FutureProgress::title() const
|
||||
Returns the title of the progress indicator.
|
||||
*/
|
||||
QString FutureProgress::title() const
|
||||
@@ -268,7 +264,6 @@ void FutureProgress::setProgressText(const QString &text)
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FutureProgress::setFuture(const QFuture<void> &future)
|
||||
\internal
|
||||
*/
|
||||
void FutureProgress::setFuture(const QFuture<void> &future)
|
||||
@@ -277,7 +272,6 @@ void FutureProgress::setFuture(const QFuture<void> &future)
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QFuture<void> FutureProgress::future() const
|
||||
Returns a QFuture object that represents this running task.
|
||||
*/
|
||||
QFuture<void> FutureProgress::future() const
|
||||
@@ -286,7 +280,6 @@ QFuture<void> FutureProgress::future() const
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FutureProgress::mousePressEvent(QMouseEvent *event)
|
||||
\internal
|
||||
*/
|
||||
void FutureProgress::mousePressEvent(QMouseEvent *event)
|
||||
@@ -304,7 +297,6 @@ void FutureProgress::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool FutureProgress::hasError() const
|
||||
Returns the error state of this progress indicator.
|
||||
*/
|
||||
bool FutureProgress::hasError() const
|
||||
|
||||
@@ -308,7 +308,7 @@ void VariableManager::registerFileVariables(const QByteArray &prefix, const QStr
|
||||
{
|
||||
registerVariable(prefix + kFilePathPostfix, tr("%1: Full path including file name.").arg(heading));
|
||||
registerVariable(prefix + kPathPostfix, tr("%1: Full path excluding file name.").arg(heading));
|
||||
registerVariable(prefix + kFileNamePostfix, tr("%1: File name without including path.").arg(heading));
|
||||
registerVariable(prefix + kFileNamePostfix, tr("%1: File name without path.").arg(heading));
|
||||
registerVariable(prefix + kFileBaseNamePostfix, tr("%1: File base name without path and suffix.").arg(heading));
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,11 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
void clearCache()
|
||||
{
|
||||
m_cachedMatches.clear();
|
||||
}
|
||||
|
||||
void resetCache(const QString &dir)
|
||||
{
|
||||
QTC_ASSERT(QDir(dir).isAbsolute(), return);
|
||||
@@ -226,8 +231,10 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
|
||||
|
||||
foreach (IVersionControl * versionControl, versionControls) {
|
||||
QString topLevel;
|
||||
if (versionControl->managesDirectory(directory, &topLevel))
|
||||
if (versionControl->isConfigured()
|
||||
&& versionControl->managesDirectory(directory, &topLevel)) {
|
||||
allThatCanManage.push_back(StringVersionControlPair(topLevel, versionControl));
|
||||
}
|
||||
}
|
||||
|
||||
// To properly find a nested repository (say, git checkout inside SVN),
|
||||
@@ -379,4 +386,12 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
|
||||
}
|
||||
}
|
||||
|
||||
void VcsManager::clearVersionControlCache()
|
||||
{
|
||||
QStringList repoList = d->m_cachedMatches.keys();
|
||||
d->clearCache();
|
||||
foreach (const QString &repo, repoList)
|
||||
emit repositoryChanged(repo);
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -95,6 +95,9 @@ public:
|
||||
signals:
|
||||
void repositoryChanged(const QString &repository);
|
||||
|
||||
public slots:
|
||||
void clearVersionControlCache();
|
||||
|
||||
private:
|
||||
VcsManagerPrivate *d;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user