summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/editormanager
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-03-05 12:45:32 +0100
committerEike Ziller <eike.ziller@qt.io>2018-03-06 12:15:17 +0000
commitc66023501925654a2b2485776c91eb50c8698ac2 (patch)
tree5cd9a1d48a961e8b1cddf4ddc86927d010e91743 /src/plugins/coreplugin/editormanager
parentf288dc639c8c39e7dcccc9f2630d2fe3c9e25d07 (diff)
downloadqt-creator-c66023501925654a2b2485776c91eb50c8698ac2.tar.gz
EditorManager: Use nullptr
Change-Id: If3e20279acbfcb89d9b16776739e318f519c337e Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/coreplugin/editormanager')
-rw-r--r--src/plugins/coreplugin/editormanager/editorarea.cpp8
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp116
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h16
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp84
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.h10
5 files changed, 116 insertions, 118 deletions
diff --git a/src/plugins/coreplugin/editormanager/editorarea.cpp b/src/plugins/coreplugin/editormanager/editorarea.cpp
index e7f23f9d19..3140c258f5 100644
--- a/src/plugins/coreplugin/editormanager/editorarea.cpp
+++ b/src/plugins/coreplugin/editormanager/editorarea.cpp
@@ -40,8 +40,6 @@ namespace Core {
namespace Internal {
EditorArea::EditorArea()
- : m_currentView(0),
- m_currentDocument(0)
{
m_context = new IContext;
m_context->setContext(Context(Constants::C_EDITORMANAGER));
@@ -59,7 +57,7 @@ EditorArea::EditorArea()
EditorArea::~EditorArea()
{
// disconnect
- setCurrentView(0);
+ setCurrentView(nullptr);
disconnect(qApp, &QApplication::focusChanged,
this, &EditorArea::focusChanged);
@@ -102,12 +100,12 @@ void EditorArea::setCurrentView(EditorView *view)
connect(m_currentView.data(), &EditorView::currentEditorChanged,
this, &EditorArea::updateCurrentEditor);
}
- updateCurrentEditor(m_currentView ? m_currentView->currentEditor() : 0);
+ updateCurrentEditor(m_currentView ? m_currentView->currentEditor() : nullptr);
}
void EditorArea::updateCurrentEditor(IEditor *editor)
{
- IDocument *document = editor ? editor->document() : 0;
+ IDocument *document = editor ? editor->document() : nullptr;
if (document == m_currentDocument)
return;
if (m_currentDocument) {
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 0faeb33ec5..6993859204 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -142,13 +142,13 @@ EditorManagerPlaceHolder::~EditorManagerPlaceHolder()
QWidget *em = EditorManagerPrivate::mainEditorArea();
if (em && em->parent() == this) {
em->hide();
- em->setParent(0);
+ em->setParent(nullptr);
}
}
void EditorManagerPlaceHolder::showEvent(QShowEvent *)
{
- QWidget *previousFocus = 0;
+ QWidget *previousFocus = nullptr;
QWidget *em = EditorManagerPrivate::mainEditorArea();
if (em->focusWidget() && em->focusWidget()->hasFocus())
previousFocus = em->focusWidget();
@@ -160,7 +160,7 @@ void EditorManagerPlaceHolder::showEvent(QShowEvent *)
// ---------------- EditorManager
-static EditorManager *m_instance = 0;
+static EditorManager *m_instance = nullptr;
static EditorManagerPrivate *d;
static QString autoSaveName(const QString &fileName)
@@ -231,7 +231,7 @@ EditorManagerPrivate::~EditorManagerPrivate()
m_editorAreas.clear();
DocumentModel::destroy();
- d = 0;
+ d = nullptr;
}
void EditorManagerPrivate::init()
@@ -564,7 +564,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
}
if (fn.isEmpty())
- return 0;
+ return nullptr;
if (fn != fileName)
fi.setFile(fn);
@@ -595,7 +595,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
.arg(FileName::fromString(realFn).toUserOutput()).arg(mimeType.name()),
QMessageBox::Ok, ICore::dialogParent());
msgbox.exec();
- return 0;
+ return nullptr;
}
if (editorId.isValid()) {
IEditorFactory *factory = Utils::findOrDefault(IEditorFactory::allEditorFactories(),
@@ -609,7 +609,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
if (skipOpeningBigTextFile(fileName))
return nullptr;
- IEditor *editor = 0;
+ IEditor *editor = nullptr;
auto overrideCursor = Utils::OverrideCursor(QCursor(Qt::WaitCursor));
IEditorFactory *factory = factories.takeFirst();
@@ -627,7 +627,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
overrideCursor.reset();
delete editor;
- editor = 0;
+ editor = nullptr;
if (openResult == IDocument::OpenResult::ReadError) {
QMessageBox msgbox(QMessageBox::Critical, EditorManager::tr("File Error"),
@@ -637,7 +637,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
.arg(FileName::fromString(realFn).toUserOutput()),
QMessageBox::Ok, ICore::dialogParent());
msgbox.exec();
- return 0;
+ return nullptr;
}
QTC_CHECK(openResult == IDocument::OpenResult::CannotHandle);
@@ -648,10 +648,10 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
QMessageBox msgbox(QMessageBox::Critical, EditorManager::tr("File Error"), errorString, QMessageBox::Open | QMessageBox::Cancel, ICore::mainWindow());
- IEditorFactory *selectedFactory = 0;
+ IEditorFactory *selectedFactory = nullptr;
if (!factories.isEmpty()) {
QPushButton *button = qobject_cast<QPushButton *>(msgbox.button(QMessageBox::Open));
- QTC_ASSERT(button, return 0);
+ QTC_ASSERT(button, return nullptr);
QMenu *menu = new QMenu(button);
foreach (IEditorFactory *factory, factories) {
QAction *action = menu->addAction(factory->displayName());
@@ -668,7 +668,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
int ret = msgbox.exec();
if (ret == QMessageBox::Cancel || ret == QMessageBox::Ok)
- return 0;
+ return nullptr;
overrideCursor.set();
@@ -677,7 +677,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
}
if (!editor)
- return 0;
+ return nullptr;
if (realFn != fn)
editor->document()->setRestoredFrom(realFn);
@@ -722,9 +722,9 @@ IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Core::Id
views.append(view);
}
if (!EditorManager::closeEditors(editorsOpenForFile)) // don't open if cancel was pressed
- return 0;
+ return nullptr;
- IEditor *openedEditor = 0;
+ IEditor *openedEditor = nullptr;
if (views.isEmpty()) {
openedEditor = EditorManager::openEditor(fileName, editorId);
} else {
@@ -759,7 +759,7 @@ IEditor *EditorManagerPrivate::activateEditorForDocument(EditorView *view, IDocu
if (!editor) {
const QList<IEditor*> editors = DocumentModel::editorsForDocument(document);
if (editors.isEmpty())
- return 0;
+ return nullptr;
editor = editors.first();
}
return activateEditor(view, editor, flags);
@@ -773,7 +773,7 @@ EditorView *EditorManagerPrivate::viewForEditor(IEditor *editor)
if (EditorView *view = qobject_cast<EditorView *>(w))
return view;
}
- return 0;
+ return nullptr;
}
MakeWritableResult EditorManagerPrivate::makeFileWritable(IDocument *document)
@@ -892,7 +892,7 @@ void EditorManagerPrivate::showPopupOrSelectDocument()
// decide where to show the popup
// if the active window has editors, we want that editor area as a reference
// TODO: this does not work correctly with multiple editor areas in the same window
- EditorArea *activeEditorArea = 0;
+ EditorArea *activeEditorArea = nullptr;
foreach (EditorArea *area, d->m_editorAreas) {
if (area->window() == activeWindow) {
activeEditorArea = area;
@@ -1149,7 +1149,7 @@ EditorManager::EditorFactoryList EditorManagerPrivate::findFactories(Id editorId
IEditor *EditorManagerPrivate::createEditor(IEditorFactory *factory, const QString &fileName)
{
if (!factory)
- return 0;
+ return nullptr;
IEditor *editor = factory->createEditor();
if (editor) {
@@ -1211,7 +1211,7 @@ IEditor *EditorManagerPrivate::placeEditor(EditorView *view, IEditor *editor)
view->addEditor(editor);
view->setCurrentEditor(editor);
if (!sourceView->currentEditor()) {
- EditorView *replacementView = 0;
+ EditorView *replacementView = nullptr;
if (IEditor *replacement = pickUnusedEditor(&replacementView)) {
if (replacementView)
replacementView->removeEditor(replacement);
@@ -1232,7 +1232,7 @@ IEditor *EditorManagerPrivate::placeEditor(EditorView *view, IEditor *editor)
IEditor *EditorManagerPrivate::duplicateEditor(IEditor *editor)
{
if (!editor->duplicateSupported())
- return 0;
+ return nullptr;
IEditor *duplicate = editor->duplicate();
duplicate->restoreState(editor->saveState());
@@ -1281,9 +1281,9 @@ bool EditorManagerPrivate::activateEditorForEntry(EditorView *view, DocumentMode
{
QTC_ASSERT(view, return false);
if (!entry) { // no document
- view->setCurrentEditor(0);
+ view->setCurrentEditor(nullptr);
setCurrentView(view);
- setCurrentEditor(0);
+ setCurrentEditor(nullptr);
return false;
}
IDocument *document = entry->document;
@@ -1362,7 +1362,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
bool cancelled = false;
QList<IDocument *> rejectedList;
DocumentManager::saveModifiedDocuments(documentsToClose, QString(), &cancelled,
- QString(), 0, &rejectedList);
+ QString(), nullptr, &rejectedList);
if (cancelled)
return false;
if (!rejectedList.isEmpty()) {
@@ -1375,7 +1375,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
return false;
QList<EditorView*> closedViews;
- EditorView *focusView = 0;
+ EditorView *focusView = nullptr;
// remove the editors
foreach (IEditor *editor, acceptedEditors) {
@@ -1396,7 +1396,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
if (d->m_currentEditor == editor) {
// avoid having a current editor without view
setCurrentView(view);
- setCurrentEditor(0);
+ setCurrentEditor(nullptr);
}
view->removeEditor(editor);
}
@@ -1405,7 +1405,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
// TODO doesn't work as expected with multiple areas in main window and some other cases
// instead each view should have its own file history and handle solely themselves
// which editor is shown if their current editor closes
- EditorView *forceViewToShowEditor = 0;
+ EditorView *forceViewToShowEditor = nullptr;
if (!closedViews.isEmpty() && EditorManager::visibleEditors().isEmpty()) {
if (closedViews.contains(currentView))
forceViewToShowEditor = currentView;
@@ -1444,7 +1444,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
setCurrentEditor(currentView->currentEditor());
if (!EditorManager::currentEditor()) {
- emit m_instance->currentEditorChanged(0);
+ emit m_instance->currentEditorChanged(nullptr);
updateActions();
}
@@ -1491,7 +1491,7 @@ int EditorManagerPrivate::visibleDocumentsCount()
void EditorManagerPrivate::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
{
if (editor)
- setCurrentView(0);
+ setCurrentView(nullptr);
if (d->m_currentEditor == editor)
return;
@@ -1532,7 +1532,7 @@ EditorArea *EditorManagerPrivate::findEditorArea(const EditorView *view, int *ar
while (current) {
if (EditorArea *area = qobject_cast<EditorArea *>(current)) {
int index = d->m_editorAreas.indexOf(area);
- QTC_ASSERT(index >= 0, return 0);
+ QTC_ASSERT(index >= 0, return nullptr);
if (areaIndex)
*areaIndex = index;
return area;
@@ -1540,7 +1540,7 @@ EditorArea *EditorManagerPrivate::findEditorArea(const EditorView *view, int *ar
current = current->findParentSplitter();
}
QTC_CHECK(false); // we should never have views without a editor area
- return 0;
+ return nullptr;
}
void EditorManagerPrivate::closeView(EditorView *view)
@@ -1578,7 +1578,7 @@ void EditorManagerPrivate::emptyView(EditorView *view)
if (EditorManager::currentEditor() == editor) {
// we don't want a current editor that is not open in a view
setCurrentView(view);
- setCurrentEditor(0);
+ setCurrentEditor(nullptr);
}
editors.removeAll(editor);
view->removeEditor(editor);
@@ -1599,7 +1599,7 @@ void EditorManagerPrivate::emptyView(EditorView *view)
void EditorManagerPrivate::splitNewWindow(EditorView *view)
{
IEditor *editor = view->currentEditor();
- IEditor *newEditor = 0;
+ IEditor *newEditor = nullptr;
if (editor && editor->duplicateSupported())
newEditor = EditorManagerPrivate::duplicateEditor(editor);
else
@@ -1628,7 +1628,7 @@ IEditor *EditorManagerPrivate::pickUnusedEditor(EditorView **foundView)
return editor;
}
}
- return 0;
+ return nullptr;
}
/* Adds the file name to the recent files if there is at least one non-temporary editor for it */
@@ -1695,9 +1695,9 @@ void EditorManagerPrivate::updateMakeWritableWarning()
void EditorManagerPrivate::setupSaveActions(IDocument *document, QAction *saveAction,
QAction *saveAsAction, QAction *revertToSavedAction)
{
- const bool hasFile = document != 0 && !document->filePath().isEmpty();
+ const bool hasFile = document && !document->filePath().isEmpty();
saveAction->setEnabled(hasFile && document->isModified());
- saveAsAction->setEnabled(document != 0 && document->isSaveAsAllowed());
+ saveAsAction->setEnabled(document && document->isSaveAsAllowed());
revertToSavedAction->setEnabled(hasFile);
if (document && !document->displayName().isEmpty()) {
@@ -1741,8 +1741,8 @@ void EditorManagerPrivate::updateActions()
d->m_goBackAction->setEnabled(view ? view->canGoBack() : false);
d->m_goForwardAction->setEnabled(view ? view->canGoForward() : false);
- SplitterOrView *viewParent = (view ? view->parentSplitterOrView() : 0);
- SplitterOrView *parentSplitter = (viewParent ? viewParent->findParentSplitter() : 0);
+ SplitterOrView *viewParent = (view ? view->parentSplitterOrView() : nullptr);
+ SplitterOrView *parentSplitter = (viewParent ? viewParent->findParentSplitter() : nullptr);
bool hasSplitter = parentSplitter && parentSplitter->isSplitter();
d->m_removeCurrentSplitAction->setEnabled(hasSplitter);
d->m_removeAllSplitsAction->setEnabled(hasSplitter);
@@ -1932,7 +1932,7 @@ void EditorManagerPrivate::handleDocumentStateChange()
void EditorManagerPrivate::editorAreaDestroyed(QObject *area)
{
QWidget *activeWin = QApplication::activeWindow();
- EditorArea *newActiveArea = 0;
+ EditorArea *newActiveArea = nullptr;
for (int i = 0; i < d->m_editorAreas.size(); ++i) {
EditorArea *r = d->m_editorAreas.at(i);
if (r == area) {
@@ -1953,7 +1953,7 @@ void EditorManagerPrivate::editorAreaDestroyed(QObject *area)
}
// check if the focusWidget points to some view
- SplitterOrView *focusSplitterOrView = 0;
+ SplitterOrView *focusSplitterOrView = nullptr;
QWidget *candidate = newActiveArea->focusWidget();
while (candidate && candidate != newActiveArea) {
if ((focusSplitterOrView = qobject_cast<SplitterOrView *>(candidate)))
@@ -1996,8 +1996,8 @@ void EditorManagerPrivate::handleContextChange(const QList<IContext *> &context)
{
if (debugEditorManager)
qDebug() << Q_FUNC_INFO;
- d->m_scheduledCurrentEditor = 0;
- IEditor *editor = 0;
+ d->m_scheduledCurrentEditor = nullptr;
+ IEditor *editor = nullptr;
foreach (IContext *c, context)
if ((editor = qobject_cast<IEditor*>(c)))
break;
@@ -2040,21 +2040,21 @@ void EditorManagerPrivate::copyFileNameFromContextMenu()
void EditorManagerPrivate::saveDocumentFromContextMenu()
{
- IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
+ IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
if (document)
saveDocument(document);
}
void EditorManagerPrivate::saveDocumentAsFromContextMenu()
{
- IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
+ IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
if (document)
saveDocumentAs(document);
}
void EditorManagerPrivate::revertToSavedFromContextMenu()
{
- IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
+ IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
if (document)
revertToSaved(document);
}
@@ -2064,7 +2064,7 @@ void EditorManagerPrivate::closeEditorFromContextMenu()
if (d->m_contextMenuEditor) {
closeEditorOrDocument(d->m_contextMenuEditor);
} else {
- IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
+ IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
if (document)
EditorManager::closeDocument(document);
}
@@ -2072,7 +2072,7 @@ void EditorManagerPrivate::closeEditorFromContextMenu()
void EditorManagerPrivate::closeOtherDocumentsFromContextMenu()
{
- IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
+ IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
EditorManager::closeOtherDocuments(document);
}
@@ -2271,7 +2271,7 @@ void EditorManagerPrivate::setCurrentEditorFromContextChange()
if (!d->m_scheduledCurrentEditor)
return;
IEditor *newCurrent = d->m_scheduledCurrentEditor;
- d->m_scheduledCurrentEditor = 0;
+ d->m_scheduledCurrentEditor = nullptr;
setCurrentEditor(newCurrent);
}
@@ -2311,12 +2311,12 @@ EditorManager::EditorManager(QObject *parent) :
EditorManager::~EditorManager()
{
delete d;
- m_instance = 0;
+ m_instance = nullptr;
}
IDocument *EditorManager::currentDocument()
{
- return d->m_currentEditor ? d->m_currentEditor->document() : 0;
+ return d->m_currentEditor ? d->m_currentEditor->document() : nullptr;
}
IEditor *EditorManager::currentEditor()
@@ -2389,7 +2389,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
assignAction(d->m_saveAsCurrentEditorContextAction, ActionManager::command(Constants::SAVEAS)->action());
assignAction(d->m_revertToSavedCurrentEditorContextAction, ActionManager::command(Constants::REVERTTOSAVED)->action());
- IDocument *document = entry ? entry->document : 0;
+ IDocument *document = entry ? entry->document : nullptr;
EditorManagerPrivate::setupSaveActions(document,
d->m_saveCurrentEditorContextAction,
@@ -2409,8 +2409,8 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
d->m_closeOtherDocumentsContextAction->setText(entry
? tr("Close All Except \"%1\"").arg(entry->displayName())
: tr("Close Other Editors"));
- d->m_closeCurrentEditorContextAction->setEnabled(entry != 0);
- d->m_closeOtherDocumentsContextAction->setEnabled(entry != 0);
+ d->m_closeCurrentEditorContextAction->setEnabled(entry != nullptr);
+ d->m_closeOtherDocumentsContextAction->setEnabled(entry != nullptr);
d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::entries().isEmpty());
d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(
EditorManagerPrivate::visibleDocumentsCount() < DocumentModel::entries().count());
@@ -2778,7 +2778,7 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
const QString title = makeTitleUnique(titlePattern);
- IEditor *edt = 0;
+ IEditor *edt = nullptr;
if (!uniqueId.isEmpty()) {
foreach (IDocument *document, DocumentModel::openedDocuments())
if (document->property(scratchBufferKey).toString() == uniqueId) {
@@ -2795,15 +2795,15 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
EditorFactoryList factories = EditorManagerPrivate::findFactories(editorId, title);
if (factories.isEmpty())
- return 0;
+ return nullptr;
edt = EditorManagerPrivate::createEditor(factories.first(), title);
if (!edt)
- return 0;
+ return nullptr;
if (!edt->document()->setContents(contents)) {
delete edt;
- edt = 0;
- return 0;
+ edt = nullptr;
+ return nullptr;
}
if (!uniqueId.isEmpty())
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index 50528b29a3..e3a5458974 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -63,7 +63,7 @@ class CORE_EXPORT EditorManagerPlaceHolder : public QWidget
{
Q_OBJECT
public:
- explicit EditorManagerPlaceHolder(QWidget *parent = 0);
+ explicit EditorManagerPlaceHolder(QWidget *parent = nullptr);
~EditorManagerPlaceHolder();
protected:
@@ -101,12 +101,12 @@ public:
};
static FilePathInfo splitLineAndColumnNumber(const QString &filePath);
static IEditor *openEditor(const QString &fileName, Id editorId = Id(),
- OpenEditorFlags flags = NoFlags, bool *newEditor = 0);
+ OpenEditorFlags flags = NoFlags, bool *newEditor = nullptr);
static IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
Id editorId = Id(), OpenEditorFlags flags = NoFlags,
- bool *newEditor = 0);
+ bool *newEditor = nullptr);
static void openEditorAtSearchResult(const SearchResultItem &item, OpenEditorFlags flags = NoFlags);
- static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = 0,
+ static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = nullptr,
const QByteArray &contents = QByteArray(),
const QString &uniqueId = QString(),
OpenEditorFlags flags = NoFlags);
@@ -122,9 +122,9 @@ public:
static IEditor *currentEditor();
static QList<IEditor *> visibleEditors();
- static void activateEditor(IEditor *editor, OpenEditorFlags flags = 0);
- static void activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags = 0);
- static IEditor *activateEditorForDocument(IDocument *document, OpenEditorFlags flags = 0);
+ static void activateEditor(IEditor *editor, OpenEditorFlags flags = NoFlags);
+ static void activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags = NoFlags);
+ static IEditor *activateEditorForDocument(IDocument *document, OpenEditorFlags flags = NoFlags);
static bool closeDocument(IDocument *document, bool askAboutModifiedEditors = true);
static bool closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors = true);
@@ -164,7 +164,7 @@ public:
static void setWindowTitleVcsTopicHandler(WindowTitleHandler handler);
static void addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentModel::Entry *entry,
- IEditor *editor = 0);
+ IEditor *editor = nullptr);
static void addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentModel::Entry *entry);
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 4d6dc67623..e456421d2f 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -134,7 +134,7 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) :
m_emptyViewLabel->setText(EditorManagerPrivate::placeholderText());
emptyLayout->addWidget(m_emptyViewLabel);
m_container->addWidget(empty);
- m_widgetEditorMap.insert(empty, 0);
+ m_widgetEditorMap.insert(empty, nullptr);
auto dropSupport = new DropSupport(this, [this](QDropEvent *event, DropSupport *dropSupport) -> bool {
// do not accept move events except from other editor views (i.e. their tool bars)
@@ -165,16 +165,16 @@ SplitterOrView *EditorView::parentSplitterOrView() const
EditorView *EditorView::findNextView()
{
SplitterOrView *current = parentSplitterOrView();
- QTC_ASSERT(current, return 0);
+ QTC_ASSERT(current, return nullptr);
SplitterOrView *parent = current->findParentSplitter();
while (parent) {
QSplitter *splitter = parent->splitter();
- QTC_ASSERT(splitter, return 0);
- QTC_ASSERT(splitter->count() == 2, return 0);
+ QTC_ASSERT(splitter, return nullptr);
+ QTC_ASSERT(splitter->count() == 2, return nullptr);
// is current the first child? then the next view is the first one in current's sibling
if (splitter->widget(0) == current) {
SplitterOrView *second = qobject_cast<SplitterOrView *>(splitter->widget(1));
- QTC_ASSERT(second, return 0);
+ QTC_ASSERT(second, return nullptr);
return second->findFirstView();
}
// otherwise go up the hierarchy
@@ -182,22 +182,22 @@ EditorView *EditorView::findNextView()
parent = current->findParentSplitter();
}
// current has no parent, so we are at the top and there is no "next" view
- return 0;
+ return nullptr;
}
EditorView *EditorView::findPreviousView()
{
SplitterOrView *current = parentSplitterOrView();
- QTC_ASSERT(current, return 0);
+ QTC_ASSERT(current, return nullptr);
SplitterOrView *parent = current->findParentSplitter();
while (parent) {
QSplitter *splitter = parent->splitter();
- QTC_ASSERT(splitter, return 0);
- QTC_ASSERT(splitter->count() == 2, return 0);
+ QTC_ASSERT(splitter, return nullptr);
+ QTC_ASSERT(splitter->count() == 2, return nullptr);
// is current the last child? then the previous view is the first child in current's sibling
if (splitter->widget(1) == current) {
SplitterOrView *first = qobject_cast<SplitterOrView *>(splitter->widget(0));
- QTC_ASSERT(first, return 0);
+ QTC_ASSERT(first, return nullptr);
return first->findFirstView();
}
// otherwise go up the hierarchy
@@ -205,7 +205,7 @@ EditorView *EditorView::findPreviousView()
parent = current->findParentSplitter();
}
// current has no parent, so we are at the top and there is no "previous" view
- return 0;
+ return nullptr;
}
void EditorView::closeCurrentEditor()
@@ -346,18 +346,18 @@ void EditorView::removeEditor(IEditor *editor)
m_container->removeWidget(editor->widget());
m_widgetEditorMap.remove(editor->widget());
- editor->widget()->setParent(0);
+ editor->widget()->setParent(nullptr);
m_toolBar->removeToolbarForEditor(editor);
if (wasCurrent)
- setCurrentEditor(m_editors.count() ? m_editors.last() : 0);
+ setCurrentEditor(m_editors.count() ? m_editors.last() : nullptr);
}
IEditor *EditorView::currentEditor() const
{
if (m_editors.count() > 0)
return m_widgetEditorMap.value(m_container->currentWidget());
- return 0;
+ return nullptr;
}
void EditorView::listSelectionActivated(int index)
@@ -369,7 +369,7 @@ void EditorView::fillListContextMenu(QMenu *menu)
{
IEditor *editor = currentEditor();
DocumentModel::Entry *entry = editor ? DocumentModel::entryForDocument(editor->document())
- : 0;
+ : nullptr;
EditorManager::addSaveAndCloseEditorActions(menu, entry, editor);
menu->addSeparator();
EditorManager::addNativeDirAndOpenWithActions(menu, entry);
@@ -421,10 +421,10 @@ void EditorView::setCurrentEditor(IEditor *editor)
{
if (!editor || m_container->indexOf(editor->widget()) == -1) {
QTC_CHECK(!editor);
- m_toolBar->setCurrentEditor(0);
- m_infoBarDisplay->setInfoBar(0);
+ m_toolBar->setCurrentEditor(nullptr);
+ m_infoBarDisplay->setInfoBar(nullptr);
m_container->setCurrentIndex(0);
- emit currentEditorChanged(0);
+ emit currentEditorChanged(nullptr);
return;
}
@@ -457,7 +457,7 @@ IEditor *EditorView::editorForDocument(const IDocument *document) const
foreach (IEditor *editor, m_editors)
if (editor->document() == document)
return editor;
- return 0;
+ return nullptr;
}
void EditorView::updateEditorHistory(IEditor *editor)
@@ -556,7 +556,7 @@ void EditorView::goBackInNavigationHistory()
while (m_currentNavigationHistoryPosition > 0) {
--m_currentNavigationHistoryPosition;
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
- IEditor *editor = 0;
+ IEditor *editor = nullptr;
if (location.document) {
editor = EditorManagerPrivate::activateEditorForDocument(this, location.document,
EditorManager::IgnoreNavigationHistory);
@@ -586,7 +586,7 @@ void EditorView::goForwardInNavigationHistory()
return;
++m_currentNavigationHistoryPosition;
while (m_currentNavigationHistoryPosition < m_navigationHistory.size()) {
- IEditor *editor = 0;
+ IEditor *editor = nullptr;
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
if (location.document) {
editor = EditorManagerPrivate::activateEditorForDocument(this, location.document,
@@ -620,7 +620,7 @@ SplitterOrView::SplitterOrView(IEditor *editor)
m_view = new EditorView(this);
if (editor)
m_view->addEditor(editor);
- m_splitter = 0;
+ m_splitter = nullptr;
m_layout->addWidget(m_view);
}
@@ -631,20 +631,20 @@ SplitterOrView::SplitterOrView(EditorView *view)
m_layout->setSizeConstraint(QLayout::SetNoConstraint);
m_view = view;
m_view->setParentSplitterOrView(this);
- m_splitter = 0;
+ m_splitter = nullptr;
m_layout->addWidget(m_view);
}
SplitterOrView::~SplitterOrView()
{
delete m_layout;
- m_layout = 0;
+ m_layout = nullptr;
if (m_view)
EditorManagerPrivate::emptyView(m_view);
delete m_view;
- m_view = 0;
+ m_view = nullptr;
delete m_splitter;
- m_splitter = 0;
+ m_splitter = nullptr;
}
EditorView *SplitterOrView::findFirstView()
@@ -655,7 +655,7 @@ EditorView *SplitterOrView::findFirstView()
if (EditorView *result = splitterOrView->findFirstView())
return result;
}
- return 0;
+ return nullptr;
}
return m_view;
}
@@ -668,7 +668,7 @@ EditorView *SplitterOrView::findLastView()
if (EditorView *result = splitterOrView->findLastView())
return result;
}
- return 0;
+ return nullptr;
}
return m_view;
}
@@ -683,7 +683,7 @@ SplitterOrView *SplitterOrView::findParentSplitter() const
}
w = w->parentWidget();
}
- return 0;
+ return nullptr;
}
QSize SplitterOrView::minimumSizeHint() const
@@ -698,7 +698,7 @@ QSplitter *SplitterOrView::takeSplitter()
QSplitter *oldSplitter = m_splitter;
if (m_splitter)
m_layout->removeWidget(m_splitter);
- m_splitter = 0;
+ m_splitter = nullptr;
return oldSplitter;
}
@@ -708,28 +708,28 @@ EditorView *SplitterOrView::takeView()
if (m_view) {
// the focus update that is triggered by removing should already have 0 parent
// so we do that first
- m_view->setParentSplitterOrView(0);
+ m_view->setParentSplitterOrView(nullptr);
m_layout->removeWidget(m_view);
}
- m_view = 0;
+ m_view = nullptr;
return oldView;
}
void SplitterOrView::split(Qt::Orientation orientation)
{
- Q_ASSERT(m_view && m_splitter == 0);
+ Q_ASSERT(m_view && m_splitter == nullptr);
m_splitter = new MiniSplitter(this);
m_splitter->setOrientation(orientation);
m_layout->addWidget(m_splitter);
m_layout->removeWidget(m_view);
EditorView *editorView = m_view;
editorView->setCloseSplitEnabled(true); // might have been disabled for root view
- m_view = 0;
+ m_view = nullptr;
IEditor *e = editorView->currentEditor();
- SplitterOrView *view = 0;
- SplitterOrView *otherView = 0;
- IEditor *duplicate = e && e->duplicateSupported() ? EditorManagerPrivate::duplicateEditor(e) : 0;
+ SplitterOrView *view = nullptr;
+ SplitterOrView *otherView = nullptr;
+ IEditor *duplicate = e && e->duplicateSupported() ? EditorManagerPrivate::duplicateEditor(e) : nullptr;
m_splitter->addWidget((view = new SplitterOrView(duplicate)));
m_splitter->addWidget((otherView = new SplitterOrView(editorView)));
@@ -775,7 +775,7 @@ void SplitterOrView::unsplitAll()
m_view = currentView;
m_layout->addWidget(m_view);
delete m_splitter;
- m_splitter = 0;
+ m_splitter = nullptr;
// restore some focus
if (hadFocus) {
@@ -807,10 +807,10 @@ void SplitterOrView::unsplit()
Q_ASSERT(m_splitter->count() == 1);
SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0));
QSplitter *oldSplitter = m_splitter;
- m_splitter = 0;
+ m_splitter = nullptr;
if (childSplitterOrView->isSplitter()) {
- Q_ASSERT(childSplitterOrView->view() == 0);
+ Q_ASSERT(childSplitterOrView->view() == nullptr);
m_splitter = childSplitterOrView->takeSplitter();
m_layout->addWidget(m_splitter);
m_layout->setCurrentWidget(m_splitter);
@@ -847,7 +847,7 @@ void SplitterOrView::unsplit()
if (EditorView *newCurrent = findFirstView())
EditorManagerPrivate::activateView(newCurrent);
else
- EditorManagerPrivate::setCurrentView(0);
+ EditorManagerPrivate::setCurrentView(nullptr);
emit splitStateChanged();
}
@@ -869,7 +869,7 @@ QByteArray SplitterOrView::saveState() const
// don't save state of temporary or ad-hoc editors
if (e && (e->document()->isTemporary() || e->document()->filePath().isEmpty())) {
// look for another editor that is more suited
- e = 0;
+ e = nullptr;
foreach (IEditor *otherEditor, editors()) {
if (!otherEditor->document()->isTemporary() && !otherEditor->document()->filePath().isEmpty()) {
e = otherEditor;
diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h
index 6653616efd..b76f184ed4 100644
--- a/src/plugins/coreplugin/editormanager/editorview.h
+++ b/src/plugins/coreplugin/editormanager/editorview.h
@@ -72,7 +72,7 @@ class EditorView : public QWidget
Q_OBJECT
public:
- explicit EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent = 0);
+ explicit EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent = nullptr);
virtual ~EditorView();
SplitterOrView *parentSplitterOrView() const;
@@ -167,17 +167,17 @@ class SplitterOrView : public QWidget
{
Q_OBJECT
public:
- explicit SplitterOrView(IEditor *editor = 0);
+ explicit SplitterOrView(IEditor *editor = nullptr);
explicit SplitterOrView(EditorView *view);
~SplitterOrView();
void split(Qt::Orientation orientation);
void unsplit();
- inline bool isView() const { return m_view != 0; }
- inline bool isSplitter() const { return m_splitter != 0; }
+ inline bool isView() const { return m_view != nullptr; }
+ inline bool isSplitter() const { return m_splitter != nullptr; }
- inline IEditor *editor() const { return m_view ? m_view->currentEditor() : 0; }
+ inline IEditor *editor() const { return m_view ? m_view->currentEditor() : nullptr; }
inline QList<IEditor *> editors() const { return m_view ? m_view->editors() : QList<IEditor*>(); }
inline bool hasEditor(IEditor *editor) const { return m_view && m_view->hasEditor(editor); }
inline bool hasEditors() const { return m_view && m_view->editorCount() != 0; }