forked from qt-creator/qt-creator
VcsOutputWindow: Use FilePath for repository
Change-Id: Ie6669c94a1fa29e48524b9338e74413bb0830229 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1144,7 +1144,7 @@ void GitClient::merge(const FilePath &workingDirectory, const QStringList &unmer
|
|||||||
|
|
||||||
void GitClient::status(const FilePath &workingDirectory) const
|
void GitClient::status(const FilePath &workingDirectory) const
|
||||||
{
|
{
|
||||||
VcsOutputWindow::setRepository(workingDirectory.toString());
|
VcsOutputWindow::setRepository(workingDirectory);
|
||||||
VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true);
|
VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true);
|
||||||
connect(command, &VcsCommand::finished, VcsOutputWindow::instance(),
|
connect(command, &VcsCommand::finished, VcsOutputWindow::instance(),
|
||||||
&VcsOutputWindow::clearRepository, Qt::QueuedConnection);
|
&VcsOutputWindow::clearRepository, Qt::QueuedConnection);
|
||||||
|
@@ -874,7 +874,7 @@ void SubversionPluginPrivate::svnStatus(const FilePath &workingDir, const QStrin
|
|||||||
args << SubversionClient::addAuthenticationOptions(m_settings);
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
||||||
if (!relativePath.isEmpty())
|
if (!relativePath.isEmpty())
|
||||||
args.append(SubversionClient::escapeFile(relativePath));
|
args.append(SubversionClient::escapeFile(relativePath));
|
||||||
VcsOutputWindow::setRepository(workingDir.toString());
|
VcsOutputWindow::setRepository(workingDir);
|
||||||
runSvn(workingDir, args, VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
|
runSvn(workingDir, args, VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
|
||||||
VcsOutputWindow::clearRepository();
|
VcsOutputWindow::clearRepository();
|
||||||
}
|
}
|
||||||
|
@@ -495,7 +495,7 @@ void VcsBaseClient::status(const FilePath &workingDir,
|
|||||||
{
|
{
|
||||||
QStringList args(vcsCommandString(StatusCommand));
|
QStringList args(vcsCommandString(StatusCommand));
|
||||||
args << extraOptions << file;
|
args << extraOptions << file;
|
||||||
VcsOutputWindow::setRepository(workingDir.toString());
|
VcsOutputWindow::setRepository(workingDir);
|
||||||
VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind);
|
VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind);
|
||||||
connect(cmd, &VcsCommand::finished,
|
connect(cmd, &VcsCommand::finished,
|
||||||
VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
|
VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
|
||||||
|
@@ -120,7 +120,7 @@ VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &envi
|
|||||||
{
|
{
|
||||||
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &VcsCommand::cancel);
|
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &VcsCommand::cancel);
|
||||||
|
|
||||||
VcsOutputWindow::setRepository(d->m_defaultWorkingDirectory.toString());
|
VcsOutputWindow::setRepository(d->m_defaultWorkingDirectory);
|
||||||
VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); // Keep me here, just to be sure it's not instantiated in other thread
|
VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); // Keep me here, just to be sure it's not instantiated in other thread
|
||||||
connect(this, &VcsCommand::append, outputWindow, [outputWindow](const QString &t) {
|
connect(this, &VcsCommand::append, outputWindow, [outputWindow](const QString &t) {
|
||||||
outputWindow->append(t);
|
outputWindow->append(t);
|
||||||
|
@@ -83,11 +83,11 @@ const char zoomSettingsKey[] = "Vcs/OutputPane/Zoom";
|
|||||||
class RepositoryUserData : public QTextBlockUserData
|
class RepositoryUserData : public QTextBlockUserData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RepositoryUserData(const QString &repo) : m_repository(repo) {}
|
explicit RepositoryUserData(const FilePath &repository) : m_repository(repository) {}
|
||||||
const QString &repository() const { return m_repository; }
|
const FilePath &repository() const { return m_repository; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_repository;
|
const FilePath m_repository;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A plain text edit with a special context menu containing "Clear"
|
// A plain text edit with a special context menu containing "Clear"
|
||||||
@@ -97,9 +97,9 @@ class OutputWindowPlainTextEdit : public Core::OutputWindow
|
|||||||
public:
|
public:
|
||||||
explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr);
|
explicit OutputWindowPlainTextEdit(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void appendLines(const QString &s, const QString &repository = QString());
|
void appendLines(const QString &s, const FilePath &repository = {});
|
||||||
void appendLinesWithStyle(const QString &s, VcsOutputWindow::MessageStyle style,
|
void appendLinesWithStyle(const QString &s, VcsOutputWindow::MessageStyle style,
|
||||||
const QString &repository = QString());
|
const FilePath &repository = {});
|
||||||
VcsOutputLineParser *parser();
|
VcsOutputLineParser *parser();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -108,7 +108,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setFormat(VcsOutputWindow::MessageStyle style);
|
void setFormat(VcsOutputWindow::MessageStyle style);
|
||||||
QString identifierUnderCursor(const QPoint &pos, QString *repository = nullptr) const;
|
QString identifierUnderCursor(const QPoint &pos, FilePath *repository = nullptr) const;
|
||||||
|
|
||||||
OutputFormat m_format;
|
OutputFormat m_format;
|
||||||
VcsOutputLineParser *m_parser = nullptr;
|
VcsOutputLineParser *m_parser = nullptr;
|
||||||
@@ -135,7 +135,7 @@ static inline int firstWordCharacter(const QString &s, int startPos)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OutputWindowPlainTextEdit::identifierUnderCursor(const QPoint &widgetPos, QString *repository) const
|
QString OutputWindowPlainTextEdit::identifierUnderCursor(const QPoint &widgetPos, FilePath *repository) const
|
||||||
{
|
{
|
||||||
if (repository)
|
if (repository)
|
||||||
repository->clear();
|
repository->clear();
|
||||||
@@ -169,25 +169,23 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
const QString href = anchorAt(event->pos());
|
const QString href = anchorAt(event->pos());
|
||||||
QMenu *menu = href.isEmpty() ? createStandardContextMenu(event->pos()) : new QMenu;
|
QMenu *menu = href.isEmpty() ? createStandardContextMenu(event->pos()) : new QMenu;
|
||||||
// Add 'open file'
|
// Add 'open file'
|
||||||
QString repository;
|
FilePath repo;
|
||||||
const QString token = identifierUnderCursor(event->pos(), &repository);
|
const QString token = identifierUnderCursor(event->pos(), &repo);
|
||||||
if (!repository.isEmpty()) {
|
if (!repo.isEmpty()) {
|
||||||
if (VcsOutputLineParser * const p = parser()) {
|
if (VcsOutputLineParser * const p = parser()) {
|
||||||
if (!href.isEmpty())
|
if (!href.isEmpty())
|
||||||
p->fillLinkContextMenu(menu, FilePath::fromString(repository), href);
|
p->fillLinkContextMenu(menu, repo, href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QAction *openAction = nullptr;
|
QAction *openAction = nullptr;
|
||||||
if (!token.isEmpty()) {
|
if (!token.isEmpty()) {
|
||||||
// Check for a file, expand via repository if relative
|
// Check for a file, expand via repository if relative
|
||||||
QFileInfo fi(token);
|
if (!repo.isEmpty() && !repo.isFile() && repo.isRelativePath())
|
||||||
if (!repository.isEmpty() && !fi.isFile() && fi.isRelative())
|
repo = repo.pathAppended(token);
|
||||||
fi = QFileInfo(repository + '/' + token);
|
if (repo.isFile()) {
|
||||||
if (fi.isFile()) {
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
openAction = menu->addAction(VcsOutputWindow::tr("Open \"%1\"").
|
openAction = menu->addAction(VcsOutputWindow::tr("Open \"%1\"").arg(repo.nativePath()));
|
||||||
arg(QDir::toNativeSeparators(fi.fileName())));
|
openAction->setData(repo.absoluteFilePath().toString());
|
||||||
openAction->setData(fi.absoluteFilePath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QAction *clearAction = nullptr;
|
QAction *clearAction = nullptr;
|
||||||
@@ -217,7 +215,7 @@ void OutputWindowPlainTextEdit::handleLink(const QPoint &pos)
|
|||||||
const QString href = anchorAt(pos);
|
const QString href = anchorAt(pos);
|
||||||
if (href.isEmpty())
|
if (href.isEmpty())
|
||||||
return;
|
return;
|
||||||
QString repository;
|
FilePath repository;
|
||||||
identifierUnderCursor(pos, &repository);
|
identifierUnderCursor(pos, &repository);
|
||||||
if (repository.isEmpty()) {
|
if (repository.isEmpty()) {
|
||||||
OutputWindow::handleLink(pos);
|
OutputWindow::handleLink(pos);
|
||||||
@@ -226,10 +224,10 @@ void OutputWindowPlainTextEdit::handleLink(const QPoint &pos)
|
|||||||
if (outputFormatter()->handleFileLink(href))
|
if (outputFormatter()->handleFileLink(href))
|
||||||
return;
|
return;
|
||||||
if (VcsOutputLineParser * const p = parser())
|
if (VcsOutputLineParser * const p = parser())
|
||||||
p->handleVcsLink(FilePath::fromString(repository), href);
|
p->handleVcsLink(repository, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWindowPlainTextEdit::appendLines(const QString &s, const QString &repository)
|
void OutputWindowPlainTextEdit::appendLines(const QString &s, const FilePath &repository)
|
||||||
{
|
{
|
||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -251,7 +249,7 @@ void OutputWindowPlainTextEdit::appendLines(const QString &s, const QString &rep
|
|||||||
|
|
||||||
void OutputWindowPlainTextEdit::appendLinesWithStyle(const QString &s,
|
void OutputWindowPlainTextEdit::appendLinesWithStyle(const QString &s,
|
||||||
VcsOutputWindow::MessageStyle style,
|
VcsOutputWindow::MessageStyle style,
|
||||||
const QString &repository)
|
const FilePath &repository)
|
||||||
{
|
{
|
||||||
setFormat(style);
|
setFormat(style);
|
||||||
|
|
||||||
@@ -299,7 +297,7 @@ class VcsOutputWindowPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Internal::OutputWindowPlainTextEdit widget;
|
Internal::OutputWindowPlainTextEdit widget;
|
||||||
QString repository;
|
FilePath repository;
|
||||||
const QRegularExpression passwordRegExp = QRegularExpression("://([^@:]+):([^@]+)@");
|
const QRegularExpression passwordRegExp = QRegularExpression("://([^@:]+):([^@]+)@");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -473,14 +471,9 @@ VcsOutputWindow *VcsOutputWindow::instance()
|
|||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsOutputWindow::repository() const
|
void VcsOutputWindow::setRepository(const FilePath &repository)
|
||||||
{
|
{
|
||||||
return d->repository;
|
d->repository = repository;
|
||||||
}
|
|
||||||
|
|
||||||
void VcsOutputWindow::setRepository(const QString &r)
|
|
||||||
{
|
|
||||||
d->repository = r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::clearRepository()
|
void VcsOutputWindow::clearRepository()
|
||||||
|
@@ -41,7 +41,6 @@ namespace Internal { class VcsPlugin; }
|
|||||||
class VCSBASE_EXPORT VcsOutputWindow : public Core::IOutputPane
|
class VCSBASE_EXPORT VcsOutputWindow : public Core::IOutputPane
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString repository READ repository WRITE setRepository)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QWidget *outputWidget(QWidget *parent) override;
|
QWidget *outputWidget(QWidget *parent) override;
|
||||||
@@ -63,8 +62,6 @@ public:
|
|||||||
|
|
||||||
static VcsOutputWindow *instance();
|
static VcsOutputWindow *instance();
|
||||||
|
|
||||||
QString repository() const;
|
|
||||||
|
|
||||||
// Helper to consistently format log entries for commands as
|
// Helper to consistently format log entries for commands as
|
||||||
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
||||||
// arguments.
|
// arguments.
|
||||||
@@ -80,7 +77,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
static void setRepository(const QString &);
|
static void setRepository(const Utils::FilePath &repository);
|
||||||
static void clearRepository();
|
static void clearRepository();
|
||||||
|
|
||||||
// Set the whole text.
|
// Set the whole text.
|
||||||
|
Reference in New Issue
Block a user