forked from qt-creator/qt-creator
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:
@@ -114,7 +114,7 @@ CommonVcsSettings::CommonVcsSettings()
|
||||
|
||||
// CommonVcsSettingsPage
|
||||
|
||||
class CommonVcsSettingsPage final : public Core::IOptionsPage
|
||||
class CommonVcsSettingsPage final : public IOptionsPage
|
||||
{
|
||||
public:
|
||||
CommonVcsSettingsPage()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
using namespace Core;
|
||||
using namespace VcsBase;
|
||||
using namespace VcsBase::Internal;
|
||||
using namespace Utils;
|
||||
@@ -26,11 +27,10 @@ SubmitEditorFile::SubmitEditorFile(VcsBaseSubmitEditor *editor) :
|
||||
{
|
||||
setTemporary(true);
|
||||
connect(m_editor, &VcsBaseSubmitEditor::fileContentsChanged,
|
||||
this, &Core::IDocument::contentsChanged);
|
||||
this, &IDocument::contentsChanged);
|
||||
}
|
||||
|
||||
Core::IDocument::OpenResult SubmitEditorFile::open(QString *errorString,
|
||||
const FilePath &filePath,
|
||||
IDocument::OpenResult SubmitEditorFile::open(QString *errorString, const FilePath &filePath,
|
||||
const FilePath &realFilePath)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
@@ -83,7 +83,7 @@ bool SubmitEditorFile::saveImpl(QString *errorString, const FilePath &filePath,
|
||||
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(type)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
enum { debug = 0 };
|
||||
@@ -95,11 +96,11 @@ struct SubmitEditorWidgetPrivate
|
||||
// A pair of position/action to extend context menus
|
||||
typedef QPair<int, QPointer<QAction> > AdditionalContextMenuAction;
|
||||
|
||||
Core::MiniSplitter *splitter;
|
||||
MiniSplitter *splitter;
|
||||
QGroupBox *descriptionBox;
|
||||
QVBoxLayout *descriptionLayout;
|
||||
QLabel *descriptionHint;
|
||||
Utils::CompletingTextEdit *description;
|
||||
CompletingTextEdit *description;
|
||||
QCheckBox *checkAllCheckBox;
|
||||
QTreeView *fileView;
|
||||
QHBoxLayout *buttonLayout;
|
||||
@@ -175,7 +176,7 @@ SubmitEditorWidget::SubmitEditorWidget() :
|
||||
verticalLayout_2->addWidget(d->checkAllCheckBox);
|
||||
verticalLayout_2->addWidget(d->fileView);
|
||||
|
||||
d->splitter = new Core::MiniSplitter(scrollAreaWidgetContents);
|
||||
d->splitter = new MiniSplitter(scrollAreaWidgetContents);
|
||||
d->splitter->setObjectName("splitter");
|
||||
d->splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
d->splitter->setOrientation(Qt::Horizontal);
|
||||
@@ -186,9 +187,9 @@ SubmitEditorWidget::SubmitEditorWidget() :
|
||||
d->buttonLayout->setContentsMargins(0, -1, -1, -1);
|
||||
QToolButton *openSettingsButton = new QToolButton;
|
||||
openSettingsButton->setIcon(Utils::Icons::SETTINGS.icon());
|
||||
openSettingsButton->setToolTip(Core::ICore::msgShowOptionsDialog());
|
||||
openSettingsButton->setToolTip(ICore::msgShowOptionsDialog());
|
||||
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->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
@@ -925,7 +925,7 @@ void VcsBaseEditorWidget::slotJumpToEntry(int index)
|
||||
int currentLine, currentColumn;
|
||||
convertPosition(position(), ¤tLine, ¤tColumn);
|
||||
if (lineNumber != currentLine) {
|
||||
Core::EditorManager::addCurrentPositionToNavigationHistory();
|
||||
EditorManager::addCurrentPositionToNavigationHistory();
|
||||
gotoLine(lineNumber, 0);
|
||||
}
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
|
||||
if (!exists)
|
||||
return;
|
||||
|
||||
Core::IEditor *ed = Core::EditorManager::openEditor(FilePath::fromString(fileName));
|
||||
IEditor *ed = EditorManager::openEditor(FilePath::fromString(fileName));
|
||||
if (auto editor = qobject_cast<BaseTextEditor *>(ed))
|
||||
editor->gotoLine(chunkStart + lineCount);
|
||||
}
|
||||
@@ -1246,8 +1246,8 @@ const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParame
|
||||
// Find the codec used for a file querying the editor.
|
||||
static QTextCodec *findFileCodec(const FilePath &source)
|
||||
{
|
||||
Core::IDocument *document = Core::DocumentModel::documentForFilePath(source);
|
||||
if (auto textDocument = qobject_cast<Core::BaseTextDocument *>(document))
|
||||
IDocument *document = DocumentModel::documentForFilePath(source);
|
||||
if (auto textDocument = qobject_cast<BaseTextDocument *>(document))
|
||||
return const_cast<QTextCodec *>(textDocument->codec());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1255,10 +1255,9 @@ static QTextCodec *findFileCodec(const FilePath &source)
|
||||
// Find the codec by checking the projects (root dir of project file)
|
||||
static QTextCodec *findProjectCodec(const FilePath &dirPath)
|
||||
{
|
||||
typedef QList<ProjectExplorer::Project*> ProjectList;
|
||||
// Try to find a project under which file tree the file is.
|
||||
const ProjectList projects = ProjectExplorer::ProjectManager::projects();
|
||||
const ProjectExplorer::Project *p
|
||||
const auto projects = ProjectExplorer::ProjectManager::projects();
|
||||
const auto *p
|
||||
= findOrDefault(projects, equal(&ProjectExplorer::Project::projectDirectory, dirPath));
|
||||
return p ? p->editorConfiguration()->textCodec() : nullptr;
|
||||
}
|
||||
@@ -1285,7 +1284,7 @@ QTextCodec *VcsBaseEditor::getCodec(const FilePath &workingDirectory, const QStr
|
||||
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))
|
||||
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.
|
||||
int VcsBaseEditor::lineNumberOfCurrentEditor(const FilePath ¤tFile)
|
||||
{
|
||||
Core::IEditor *ed = Core::EditorManager::currentEditor();
|
||||
IEditor *ed = EditorManager::currentEditor();
|
||||
if (!ed)
|
||||
return -1;
|
||||
if (!currentFile.isEmpty()) {
|
||||
const Core::IDocument *idocument = ed->document();
|
||||
const IDocument *idocument = ed->document();
|
||||
if (!idocument || idocument->filePath() != currentFile)
|
||||
return -1;
|
||||
}
|
||||
@@ -1317,7 +1316,7 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const FilePath ¤tFile)
|
||||
return cursorLine;
|
||||
}
|
||||
|
||||
bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber)
|
||||
bool VcsBaseEditor::gotoLineOfEditor(IEditor *e, int lineNumber)
|
||||
{
|
||||
if (lineNumber >= 0 && 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.
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1628,18 +1627,18 @@ QString VcsBaseEditor::editorTag(EditorContentType t, const FilePath &workingDir
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
Core::IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag)
|
||||
IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag)
|
||||
{
|
||||
const QList<Core::IDocument *> documents = Core::DocumentModel::openedDocuments();
|
||||
for (Core::IDocument *document : documents) {
|
||||
const QList<IDocument *> documents = DocumentModel::openedDocuments();
|
||||
for (IDocument *document : documents) {
|
||||
const QVariant tagPropertyValue = document->property(tagPropertyC);
|
||||
if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag)
|
||||
return Core::DocumentModel::editorsForDocument(document).constFirst();
|
||||
return DocumentModel::editorsForDocument(document).constFirst();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ void VcsBasePluginPrivate::extensionsInitialized()
|
||||
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) {
|
||||
// We are directly affected: Change state
|
||||
@@ -559,7 +559,7 @@ const VcsBasePluginState &VcsBasePluginPrivate::currentState() const
|
||||
}
|
||||
|
||||
VcsCommand *VcsBasePluginPrivate::createInitialCheckoutCommand(const QString &url,
|
||||
const Utils::FilePath &baseDirectory,
|
||||
const FilePath &baseDirectory,
|
||||
const QString &localName,
|
||||
const QStringList &extraArgs)
|
||||
{
|
||||
|
||||
@@ -101,6 +101,7 @@ static bool acceptsWordForCompletion(const QString &word)
|
||||
|
||||
namespace VcsBase {
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -201,19 +202,17 @@ void VcsBaseSubmitEditor::setParameters(const VcsBaseSubmitEditorParameters &par
|
||||
slotUpdateEditorSettings();
|
||||
connect(&settings, &CommonVcsSettings::changed,
|
||||
this, &VcsBaseSubmitEditor::slotUpdateEditorSettings);
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
||||
this, [this] {
|
||||
if (Core::EditorManager::currentEditor() == this)
|
||||
connect(EditorManager::instance(), &EditorManager::currentEditorChanged, this, [this] {
|
||||
if (EditorManager::currentEditor() == this)
|
||||
updateFileModel();
|
||||
});
|
||||
connect(qApp, &QApplication::applicationStateChanged,
|
||||
this, [this](Qt::ApplicationState state) {
|
||||
connect(qApp, &QApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) {
|
||||
if (state == Qt::ApplicationActive)
|
||||
updateFileModel();
|
||||
});
|
||||
|
||||
auto aggregate = new Aggregation::Aggregate;
|
||||
aggregate->add(new Core::BaseTextFind(descriptionEdit));
|
||||
aggregate->add(new BaseTextFind(descriptionEdit));
|
||||
aggregate->add(this);
|
||||
}
|
||||
|
||||
@@ -245,7 +244,7 @@ static inline QStringList fieldTexts(const QString &fileContents)
|
||||
void VcsBaseSubmitEditor::createUserFields(const FilePath &fieldConfigFile)
|
||||
{
|
||||
FileReader reader;
|
||||
if (!reader.fetch(fieldConfigFile, QIODevice::Text, Core::ICore::dialogParent()))
|
||||
if (!reader.fetch(fieldConfigFile, QIODevice::Text, ICore::dialogParent()))
|
||||
return;
|
||||
|
||||
// Parse into fields
|
||||
@@ -314,7 +313,7 @@ void VcsBaseSubmitEditor::setLineWrapWidth(int w)
|
||||
d->m_widget->setLineWrapWidth(w);
|
||||
}
|
||||
|
||||
Core::IDocument *VcsBaseSubmitEditor::document() const
|
||||
IDocument *VcsBaseSubmitEditor::document() const
|
||||
{
|
||||
return &d->m_file;
|
||||
}
|
||||
@@ -441,7 +440,7 @@ void VcsBaseSubmitEditor::accept(VcsBasePluginPrivate *plugin)
|
||||
{
|
||||
auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
|
||||
|
||||
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory);
|
||||
EditorManager::activateEditor(this, EditorManager::IgnoreNavigationHistory);
|
||||
|
||||
QString errorMessage;
|
||||
const bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit(&errorMessage);
|
||||
@@ -455,7 +454,7 @@ void VcsBaseSubmitEditor::accept(VcsBasePluginPrivate *plugin)
|
||||
void VcsBaseSubmitEditor::close()
|
||||
{
|
||||
d->m_disablePrompt = true;
|
||||
Core::EditorManager::closeDocuments({document()});
|
||||
EditorManager::closeDocuments({document()});
|
||||
}
|
||||
|
||||
bool VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin)
|
||||
@@ -463,13 +462,13 @@ bool VcsBaseSubmitEditor::promptSubmit(VcsBasePluginPrivate *plugin)
|
||||
if (d->m_disablePrompt)
|
||||
return true;
|
||||
|
||||
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory);
|
||||
EditorManager::activateEditor(this, EditorManager::IgnoreNavigationHistory);
|
||||
|
||||
auto submitWidget = static_cast<SubmitEditorWidget *>(this->widget());
|
||||
if (!submitWidget->isEnabled() || !submitWidget->isEdited())
|
||||
return true;
|
||||
|
||||
QMessageBox mb(Core::ICore::dialogParent());
|
||||
QMessageBox mb(ICore::dialogParent());
|
||||
mb.setWindowTitle(plugin->commitAbortTitle());
|
||||
mb.setIcon(QMessageBox::Warning);
|
||||
mb.setText(plugin->commitAbortMessage());
|
||||
|
||||
@@ -170,7 +170,7 @@ void VcsCommandPrivate::handleDone(Process *process)
|
||||
if (!(m_flags & RunFlags::ExpectRepoChanges))
|
||||
return;
|
||||
// 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());
|
||||
}
|
||||
|
||||
@@ -284,9 +284,9 @@ ProcessResult VcsCommand::result() const
|
||||
return d->m_result;
|
||||
}
|
||||
|
||||
CommandResult VcsCommand::runBlocking(const Utils::FilePath &workingDirectory,
|
||||
const Utils::Environment &environment,
|
||||
const Utils::CommandLine &command, RunFlags flags,
|
||||
CommandResult VcsCommand::runBlocking(const FilePath &workingDirectory,
|
||||
const Environment &environment,
|
||||
const CommandLine &command, RunFlags flags,
|
||||
int timeoutS, QTextCodec *codec)
|
||||
{
|
||||
VcsCommand vcsCommand(workingDirectory, environment);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QTextStream>
|
||||
#include <QTime>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
/*!
|
||||
@@ -69,7 +70,7 @@ private:
|
||||
|
||||
// A plain text edit with a special context menu containing "Clear"
|
||||
// and functions to append specially formatted entries.
|
||||
class OutputWindowPlainTextEdit : public Core::OutputWindow
|
||||
class OutputWindowPlainTextEdit : public OutputWindow
|
||||
{
|
||||
public:
|
||||
explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr);
|
||||
@@ -88,7 +89,7 @@ private:
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
setReadOnly(true);
|
||||
@@ -173,7 +174,7 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
}
|
||||
if (action == openAction) {
|
||||
const auto fileName = FilePath::fromVariant(action->data());
|
||||
Core::EditorManager::openEditor(fileName);
|
||||
EditorManager::openEditor(fileName);
|
||||
}
|
||||
}
|
||||
delete menu;
|
||||
@@ -274,9 +275,9 @@ VcsOutputWindow::VcsOutputWindow()
|
||||
updateFontSettings();
|
||||
setupContext(Internal::C_VCS_OUTPUT_PANE, &d->widget);
|
||||
|
||||
connect(this, &IOutputPane::zoomInRequested, &d->widget, &Core::OutputWindow::zoomIn);
|
||||
connect(this, &IOutputPane::zoomOutRequested, &d->widget, &Core::OutputWindow::zoomOut);
|
||||
connect(this, &IOutputPane::resetZoomRequested, &d->widget, &Core::OutputWindow::resetZoom);
|
||||
connect(this, &IOutputPane::zoomInRequested, &d->widget, &OutputWindow::zoomIn);
|
||||
connect(this, &IOutputPane::zoomOutRequested, &d->widget, &OutputWindow::zoomOut);
|
||||
connect(this, &IOutputPane::resetZoomRequested, &d->widget, &OutputWindow::resetZoom);
|
||||
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
|
||||
this, updateBehaviorSettings);
|
||||
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);
|
||||
|
||||
if (!silently && !d->widget.isVisible())
|
||||
m_instance->popup(Core::IOutputPane::NoModeSwitch);
|
||||
m_instance->popup(IOutputPane::NoModeSwitch);
|
||||
}
|
||||
|
||||
void VcsOutputWindow::appendError(const QString &text)
|
||||
|
||||
Reference in New Issue
Block a user