VcsBase: Use more Core namespace

Drop also some Utils:: specifiers.
Drop superfluous typedef.

Change-Id: I0cb12fb3fe9336ca44849198db291dfbe278df4a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2024-01-16 21:47:34 +01:00
parent f917905f30
commit 185454bc9b
8 changed files with 58 additions and 58 deletions

View File

@@ -114,7 +114,7 @@ CommonVcsSettings::CommonVcsSettings()
// CommonVcsSettingsPage // CommonVcsSettingsPage
class CommonVcsSettingsPage final : public Core::IOptionsPage class CommonVcsSettingsPage final : public IOptionsPage
{ {
public: public:
CommonVcsSettingsPage() CommonVcsSettingsPage()

View File

@@ -9,6 +9,7 @@
#include <QFileInfo> #include <QFileInfo>
using namespace Core;
using namespace VcsBase; using namespace VcsBase;
using namespace VcsBase::Internal; using namespace VcsBase::Internal;
using namespace Utils; using namespace Utils;
@@ -26,11 +27,10 @@ SubmitEditorFile::SubmitEditorFile(VcsBaseSubmitEditor *editor) :
{ {
setTemporary(true); setTemporary(true);
connect(m_editor, &VcsBaseSubmitEditor::fileContentsChanged, connect(m_editor, &VcsBaseSubmitEditor::fileContentsChanged,
this, &Core::IDocument::contentsChanged); this, &IDocument::contentsChanged);
} }
Core::IDocument::OpenResult SubmitEditorFile::open(QString *errorString, IDocument::OpenResult SubmitEditorFile::open(QString *errorString, const FilePath &filePath,
const FilePath &filePath,
const FilePath &realFilePath) const FilePath &realFilePath)
{ {
if (filePath.isEmpty()) if (filePath.isEmpty())
@@ -83,7 +83,7 @@ bool SubmitEditorFile::saveImpl(QString *errorString, const FilePath &filePath,
return true; return true;
} }
Core::IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
Q_UNUSED(type) Q_UNUSED(type)

View File

@@ -36,6 +36,7 @@
#include <QTreeView> #include <QTreeView>
#include <QVBoxLayout> #include <QVBoxLayout>
using namespace Core;
using namespace Utils; using namespace Utils;
enum { debug = 0 }; enum { debug = 0 };
@@ -95,11 +96,11 @@ struct SubmitEditorWidgetPrivate
// A pair of position/action to extend context menus // A pair of position/action to extend context menus
typedef QPair<int, QPointer<QAction> > AdditionalContextMenuAction; typedef QPair<int, QPointer<QAction> > AdditionalContextMenuAction;
Core::MiniSplitter *splitter; MiniSplitter *splitter;
QGroupBox *descriptionBox; QGroupBox *descriptionBox;
QVBoxLayout *descriptionLayout; QVBoxLayout *descriptionLayout;
QLabel *descriptionHint; QLabel *descriptionHint;
Utils::CompletingTextEdit *description; CompletingTextEdit *description;
QCheckBox *checkAllCheckBox; QCheckBox *checkAllCheckBox;
QTreeView *fileView; QTreeView *fileView;
QHBoxLayout *buttonLayout; QHBoxLayout *buttonLayout;
@@ -175,7 +176,7 @@ SubmitEditorWidget::SubmitEditorWidget() :
verticalLayout_2->addWidget(d->checkAllCheckBox); verticalLayout_2->addWidget(d->checkAllCheckBox);
verticalLayout_2->addWidget(d->fileView); verticalLayout_2->addWidget(d->fileView);
d->splitter = new Core::MiniSplitter(scrollAreaWidgetContents); d->splitter = new MiniSplitter(scrollAreaWidgetContents);
d->splitter->setObjectName("splitter"); d->splitter->setObjectName("splitter");
d->splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
d->splitter->setOrientation(Qt::Horizontal); d->splitter->setOrientation(Qt::Horizontal);
@@ -186,9 +187,9 @@ SubmitEditorWidget::SubmitEditorWidget() :
d->buttonLayout->setContentsMargins(0, -1, -1, -1); d->buttonLayout->setContentsMargins(0, -1, -1, -1);
QToolButton *openSettingsButton = new QToolButton; QToolButton *openSettingsButton = new QToolButton;
openSettingsButton->setIcon(Utils::Icons::SETTINGS.icon()); openSettingsButton->setIcon(Utils::Icons::SETTINGS.icon());
openSettingsButton->setToolTip(Core::ICore::msgShowOptionsDialog()); openSettingsButton->setToolTip(ICore::msgShowOptionsDialog());
connect(openSettingsButton, &QToolButton::clicked, this, [] { connect(openSettingsButton, &QToolButton::clicked, this, [] {
Core::ICore::showOptionsDialog(Constants::VCS_COMMON_SETTINGS_ID); ICore::showOptionsDialog(Constants::VCS_COMMON_SETTINGS_ID);
}); });
d->buttonLayout->addWidget(openSettingsButton); d->buttonLayout->addWidget(openSettingsButton);
d->buttonLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); d->buttonLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));

View File

@@ -925,7 +925,7 @@ void VcsBaseEditorWidget::slotJumpToEntry(int index)
int currentLine, currentColumn; int currentLine, currentColumn;
convertPosition(position(), &currentLine, &currentColumn); convertPosition(position(), &currentLine, &currentColumn);
if (lineNumber != currentLine) { if (lineNumber != currentLine) {
Core::EditorManager::addCurrentPositionToNavigationHistory(); EditorManager::addCurrentPositionToNavigationHistory();
gotoLine(lineNumber, 0); gotoLine(lineNumber, 0);
} }
} }
@@ -1184,7 +1184,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
if (!exists) if (!exists)
return; return;
Core::IEditor *ed = Core::EditorManager::openEditor(FilePath::fromString(fileName)); IEditor *ed = EditorManager::openEditor(FilePath::fromString(fileName));
if (auto editor = qobject_cast<BaseTextEditor *>(ed)) if (auto editor = qobject_cast<BaseTextEditor *>(ed))
editor->gotoLine(chunkStart + lineCount); editor->gotoLine(chunkStart + lineCount);
} }
@@ -1246,8 +1246,8 @@ const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParame
// Find the codec used for a file querying the editor. // Find the codec used for a file querying the editor.
static QTextCodec *findFileCodec(const FilePath &source) static QTextCodec *findFileCodec(const FilePath &source)
{ {
Core::IDocument *document = Core::DocumentModel::documentForFilePath(source); IDocument *document = DocumentModel::documentForFilePath(source);
if (auto textDocument = qobject_cast<Core::BaseTextDocument *>(document)) if (auto textDocument = qobject_cast<BaseTextDocument *>(document))
return const_cast<QTextCodec *>(textDocument->codec()); return const_cast<QTextCodec *>(textDocument->codec());
return nullptr; return nullptr;
} }
@@ -1255,10 +1255,9 @@ static QTextCodec *findFileCodec(const FilePath &source)
// Find the codec by checking the projects (root dir of project file) // Find the codec by checking the projects (root dir of project file)
static QTextCodec *findProjectCodec(const FilePath &dirPath) static QTextCodec *findProjectCodec(const FilePath &dirPath)
{ {
typedef QList<ProjectExplorer::Project*> ProjectList;
// Try to find a project under which file tree the file is. // Try to find a project under which file tree the file is.
const ProjectList projects = ProjectExplorer::ProjectManager::projects(); const auto projects = ProjectExplorer::ProjectManager::projects();
const ProjectExplorer::Project *p const auto *p
= findOrDefault(projects, equal(&ProjectExplorer::Project::projectDirectory, dirPath)); = findOrDefault(projects, equal(&ProjectExplorer::Project::projectDirectory, dirPath));
return p ? p->editorConfiguration()->textCodec() : nullptr; return p ? p->editorConfiguration()->textCodec() : nullptr;
} }
@@ -1285,7 +1284,7 @@ QTextCodec *VcsBaseEditor::getCodec(const FilePath &workingDirectory, const QStr
return getCodec(workingDirectory / files.front()); return getCodec(workingDirectory / files.front());
} }
VcsBaseEditorWidget *VcsBaseEditor::getVcsBaseEditor(const Core::IEditor *editor) VcsBaseEditorWidget *VcsBaseEditor::getVcsBaseEditor(const IEditor *editor)
{ {
if (auto be = qobject_cast<const BaseTextEditor *>(editor)) if (auto be = qobject_cast<const BaseTextEditor *>(editor))
return qobject_cast<VcsBaseEditorWidget *>(be->editorWidget()); return qobject_cast<VcsBaseEditorWidget *>(be->editorWidget());
@@ -1295,11 +1294,11 @@ VcsBaseEditorWidget *VcsBaseEditor::getVcsBaseEditor(const Core::IEditor *editor
// Return line number of current editor if it matches. // Return line number of current editor if it matches.
int VcsBaseEditor::lineNumberOfCurrentEditor(const FilePath &currentFile) int VcsBaseEditor::lineNumberOfCurrentEditor(const FilePath &currentFile)
{ {
Core::IEditor *ed = Core::EditorManager::currentEditor(); IEditor *ed = EditorManager::currentEditor();
if (!ed) if (!ed)
return -1; return -1;
if (!currentFile.isEmpty()) { if (!currentFile.isEmpty()) {
const Core::IDocument *idocument = ed->document(); const IDocument *idocument = ed->document();
if (!idocument || idocument->filePath() != currentFile) if (!idocument || idocument->filePath() != currentFile)
return -1; return -1;
} }
@@ -1317,7 +1316,7 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const FilePath &currentFile)
return cursorLine; return cursorLine;
} }
bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber) bool VcsBaseEditor::gotoLineOfEditor(IEditor *e, int lineNumber)
{ {
if (lineNumber >= 0 && e) { if (lineNumber >= 0 && e) {
if (auto be = qobject_cast<BaseTextEditor*>(e)) { if (auto be = qobject_cast<BaseTextEditor*>(e)) {
@@ -1513,7 +1512,7 @@ bool VcsBaseEditorWidget::canApplyDiffChunk(const DiffChunk &dc) const
// (passing '-R' for revert), assuming we got absolute paths from the VCS plugins. // (passing '-R' for revert), assuming we got absolute paths from the VCS plugins.
bool VcsBaseEditorWidget::applyDiffChunk(const DiffChunk &dc, PatchAction patchAction) const bool VcsBaseEditorWidget::applyDiffChunk(const DiffChunk &dc, PatchAction patchAction) const
{ {
return Core::PatchTool::runPatch(dc.asPatch(d->m_workingDirectory), return PatchTool::runPatch(dc.asPatch(d->m_workingDirectory),
d->m_workingDirectory, 0, patchAction); d->m_workingDirectory, 0, patchAction);
} }
@@ -1628,18 +1627,18 @@ QString VcsBaseEditor::editorTag(EditorContentType t, const FilePath &workingDir
static const char tagPropertyC[] = "_q_VcsBaseEditorTag"; static const char tagPropertyC[] = "_q_VcsBaseEditorTag";
void VcsBaseEditor::tagEditor(Core::IEditor *e, const QString &tag) void VcsBaseEditor::tagEditor(IEditor *e, const QString &tag)
{ {
e->document()->setProperty(tagPropertyC, QVariant(tag)); e->document()->setProperty(tagPropertyC, QVariant(tag));
} }
Core::IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag) IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag)
{ {
const QList<Core::IDocument *> documents = Core::DocumentModel::openedDocuments(); const QList<IDocument *> documents = DocumentModel::openedDocuments();
for (Core::IDocument *document : documents) { for (IDocument *document : documents) {
const QVariant tagPropertyValue = document->property(tagPropertyC); const QVariant tagPropertyValue = document->property(tagPropertyC);
if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag) if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag)
return Core::DocumentModel::editorsForDocument(document).constFirst(); return DocumentModel::editorsForDocument(document).constFirst();
} }
return nullptr; return nullptr;
} }

View File

@@ -531,7 +531,7 @@ void VcsBasePluginPrivate::extensionsInitialized()
m_listener->slotStateChanged(); m_listener->slotStateChanged();
} }
void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc) void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, IVersionControl *vc)
{ {
if (vc == this) { if (vc == this) {
// We are directly affected: Change state // We are directly affected: Change state
@@ -559,7 +559,7 @@ const VcsBasePluginState &VcsBasePluginPrivate::currentState() const
} }
VcsCommand *VcsBasePluginPrivate::createInitialCheckoutCommand(const QString &url, VcsCommand *VcsBasePluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory, const FilePath &baseDirectory,
const QString &localName, const QString &localName,
const QStringList &extraArgs) const QStringList &extraArgs)
{ {

View File

@@ -101,6 +101,7 @@ static bool acceptsWordForCompletion(const QString &word)
namespace VcsBase { namespace VcsBase {
using namespace Core;
using namespace Internal; using namespace Internal;
using namespace Utils; using namespace Utils;
@@ -201,19 +202,17 @@ void VcsBaseSubmitEditor::setParameters(const VcsBaseSubmitEditorParameters &par
slotUpdateEditorSettings(); slotUpdateEditorSettings();
connect(&settings, &CommonVcsSettings::changed, connect(&settings, &CommonVcsSettings::changed,
this, &VcsBaseSubmitEditor::slotUpdateEditorSettings); this, &VcsBaseSubmitEditor::slotUpdateEditorSettings);
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, connect(EditorManager::instance(), &EditorManager::currentEditorChanged, this, [this] {
this, [this] { if (EditorManager::currentEditor() == this)
if (Core::EditorManager::currentEditor() == this)
updateFileModel(); updateFileModel();
}); });
connect(qApp, &QApplication::applicationStateChanged, connect(qApp, &QApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) {
this, [this](Qt::ApplicationState state) {
if (state == Qt::ApplicationActive) if (state == Qt::ApplicationActive)
updateFileModel(); updateFileModel();
}); });
auto aggregate = new Aggregation::Aggregate; auto aggregate = new Aggregation::Aggregate;
aggregate->add(new Core::BaseTextFind(descriptionEdit)); aggregate->add(new BaseTextFind(descriptionEdit));
aggregate->add(this); aggregate->add(this);
} }
@@ -245,7 +244,7 @@ static inline QStringList fieldTexts(const QString &fileContents)
void VcsBaseSubmitEditor::createUserFields(const FilePath &fieldConfigFile) void VcsBaseSubmitEditor::createUserFields(const FilePath &fieldConfigFile)
{ {
FileReader reader; FileReader reader;
if (!reader.fetch(fieldConfigFile, QIODevice::Text, Core::ICore::dialogParent())) if (!reader.fetch(fieldConfigFile, QIODevice::Text, ICore::dialogParent()))
return; return;
// Parse into fields // Parse into fields
@@ -314,7 +313,7 @@ void VcsBaseSubmitEditor::setLineWrapWidth(int w)
d->m_widget->setLineWrapWidth(w); d->m_widget->setLineWrapWidth(w);
} }
Core::IDocument *VcsBaseSubmitEditor::document() const IDocument *VcsBaseSubmitEditor::document() const
{ {
return &d->m_file; return &d->m_file;
} }
@@ -441,7 +440,7 @@ void VcsBaseSubmitEditor::accept(VcsBasePluginPrivate *plugin)
{ {
auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget()); auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory); EditorManager::activateEditor(this, EditorManager::IgnoreNavigationHistory);
QString errorMessage; QString errorMessage;
const bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit(&errorMessage); const bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit(&errorMessage);
@@ -455,7 +454,7 @@ void VcsBaseSubmitEditor::accept(VcsBasePluginPrivate *plugin)
void VcsBaseSubmitEditor::close() void VcsBaseSubmitEditor::close()
{ {
d->m_disablePrompt = true; d->m_disablePrompt = true;
Core::EditorManager::closeDocuments({document()}); EditorManager::closeDocuments({document()});
} }
bool VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin) bool VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin)
@@ -463,13 +462,13 @@ bool VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin)
if (d->m_disablePrompt) if (d->m_disablePrompt)
return true; return true;
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory); EditorManager::activateEditor(this, EditorManager::IgnoreNavigationHistory);
auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget()); auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
if (!submitWidget->isEnabled() || !submitWidget->isEdited()) if (!submitWidget->isEnabled() || !submitWidget->isEdited())
return true; return true;
QMessageBox mb(Core::ICore::dialogParent()); QMessageBox mb(ICore::dialogParent());
mb.setWindowTitle(plugin->commitAbortTitle()); mb.setWindowTitle(plugin->commitAbortTitle());
mb.setIcon(QMessageBox::Warning); mb.setIcon(QMessageBox::Warning);
mb.setText(plugin->commitAbortMessage()); mb.setText(plugin->commitAbortMessage());

View File

@@ -170,7 +170,7 @@ void VcsCommandPrivate::handleDone(Process *process)
if (!(m_flags & RunFlags::ExpectRepoChanges)) if (!(m_flags & RunFlags::ExpectRepoChanges))
return; return;
// TODO tell the document manager that the directory now received all expected changes // TODO tell the document manager that the directory now received all expected changes
// Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory); // DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
VcsManager::emitRepositoryChanged(process->workingDirectory()); VcsManager::emitRepositoryChanged(process->workingDirectory());
} }
@@ -284,9 +284,9 @@ ProcessResult VcsCommand::result() const
return d->m_result; return d->m_result;
} }
CommandResult VcsCommand::runBlocking(const Utils::FilePath &workingDirectory, CommandResult VcsCommand::runBlocking(const FilePath &workingDirectory,
const Utils::Environment &environment, const Environment &environment,
const Utils::CommandLine &command, RunFlags flags, const CommandLine &command, RunFlags flags,
int timeoutS, QTextCodec *codec) int timeoutS, QTextCodec *codec)
{ {
VcsCommand vcsCommand(workingDirectory, environment); VcsCommand vcsCommand(workingDirectory, environment);

View File

@@ -31,6 +31,7 @@
#include <QTextStream> #include <QTextStream>
#include <QTime> #include <QTime>
using namespace Core;
using namespace Utils; using namespace Utils;
/*! /*!
@@ -69,7 +70,7 @@ private:
// A plain text edit with a special context menu containing "Clear" // A plain text edit with a special context menu containing "Clear"
// and functions to append specially formatted entries. // and functions to append specially formatted entries.
class OutputWindowPlainTextEdit : public Core::OutputWindow class OutputWindowPlainTextEdit : public OutputWindow
{ {
public: public:
explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr); explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr);
@@ -88,7 +89,7 @@ private:
}; };
OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent)
: Core::OutputWindow(Core::Context(C_VCS_OUTPUT_PANE), zoomSettingsKey, parent) : OutputWindow(Context(C_VCS_OUTPUT_PANE), zoomSettingsKey, parent)
, m_parser(new VcsOutputLineParser) , m_parser(new VcsOutputLineParser)
{ {
setReadOnly(true); setReadOnly(true);
@@ -173,7 +174,7 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
} }
if (action == openAction) { if (action == openAction) {
const auto fileName = FilePath::fromVariant(action->data()); const auto fileName = FilePath::fromVariant(action->data());
Core::EditorManager::openEditor(fileName); EditorManager::openEditor(fileName);
} }
} }
delete menu; delete menu;
@@ -274,9 +275,9 @@ VcsOutputWindow::VcsOutputWindow()
updateFontSettings(); updateFontSettings();
setupContext(Internal::C_VCS_OUTPUT_PANE, &d->widget); setupContext(Internal::C_VCS_OUTPUT_PANE, &d->widget);
connect(this, &IOutputPane::zoomInRequested, &d->widget, &Core::OutputWindow::zoomIn); connect(this, &IOutputPane::zoomInRequested, &d->widget, &OutputWindow::zoomIn);
connect(this, &IOutputPane::zoomOutRequested, &d->widget, &Core::OutputWindow::zoomOut); connect(this, &IOutputPane::zoomOutRequested, &d->widget, &OutputWindow::zoomOut);
connect(this, &IOutputPane::resetZoomRequested, &d->widget, &Core::OutputWindow::resetZoom); connect(this, &IOutputPane::resetZoomRequested, &d->widget, &OutputWindow::resetZoom);
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged, connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
this, updateBehaviorSettings); this, updateBehaviorSettings);
connect(TextEditor::TextEditorSettings::instance(), connect(TextEditor::TextEditorSettings::instance(),
@@ -364,7 +365,7 @@ void VcsOutputWindow::append(const QString &text, MessageStyle style, bool silen
d->widget.appendLines(text, style, d->repository); d->widget.appendLines(text, style, d->repository);
if (!silently && !d->widget.isVisible()) if (!silently && !d->widget.isVisible())
m_instance->popup(Core::IOutputPane::NoModeSwitch); m_instance->popup(IOutputPane::NoModeSwitch);
} }
void VcsOutputWindow::appendError(const QString &text) void VcsOutputWindow::appendError(const QString &text)