forked from qt-creator/qt-creator
Git: Show full description on tooltip in commit chooser dialogs
Like Push to Gerrit, Rebase, Reset, Fixup Commit. Fixes: QTCREATORBUG-24366 Change-Id: I0f596f84661a1a4f37fe971683cc0d985a6c9b1f Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
78406916a3
commit
a48cde86f3
@@ -2089,21 +2089,20 @@ SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GitClient::synchronousShow(const QString &workingDirectory, const QString &id,
|
||||
QByteArray *output, QString *errorMessage) const
|
||||
QByteArray GitClient::synchronousShow(const QString &workingDirectory, const QString &id,
|
||||
unsigned flags) const
|
||||
{
|
||||
if (!canShow(id)) {
|
||||
*errorMessage = msgCannotShow(id);
|
||||
return false;
|
||||
VcsOutputWindow::appendError(msgCannotShow(id));
|
||||
return {};
|
||||
}
|
||||
const QStringList arguments = {"show", decorateOption, noColorOption, id};
|
||||
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments);
|
||||
const QStringList arguments = {"show", decorateOption, noColorOption, "--no-patch", id};
|
||||
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments, flags);
|
||||
if (resp.result != SynchronousProcessResponse::Finished) {
|
||||
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage);
|
||||
return false;
|
||||
msgCannotRun(arguments, workingDirectory, resp.stdErr(), nullptr);
|
||||
return {};
|
||||
}
|
||||
*output = resp.rawStdOut;
|
||||
return true;
|
||||
return resp.rawStdOut;
|
||||
}
|
||||
|
||||
// Retrieve list of files to be cleaned
|
||||
|
||||
@@ -242,8 +242,8 @@ public:
|
||||
QStringList synchronousSubmoduleStatus(const QString &workingDirectory,
|
||||
QString *errorMessage = nullptr) const;
|
||||
SubmoduleDataMap submoduleList(const QString &workingDirectory) const;
|
||||
bool synchronousShow(const QString &workingDirectory, const QString &id,
|
||||
QByteArray *output, QString *errorMessage) const;
|
||||
QByteArray synchronousShow(const QString &workingDirectory, const QString &id,
|
||||
unsigned flags = 0) const;
|
||||
|
||||
bool synchronousRevListCmd(const QString &workingDirectory, const QStringList &extraArguments,
|
||||
QString *output, QString *errorMessage = nullptr) const;
|
||||
|
||||
@@ -315,13 +315,9 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
|
||||
if (params.ref.isEmpty() || item.path.isEmpty())
|
||||
return nullptr;
|
||||
const QString path = QDir::fromNativeSeparators(item.path.first());
|
||||
QByteArray content;
|
||||
const QString topLevel = parameters.additionalParameters.toString();
|
||||
const QString relativePath = QDir(topLevel).relativeFilePath(path);
|
||||
if (!m_client->synchronousShow(topLevel, params.ref + ":./" + relativePath,
|
||||
&content, nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
const QByteArray content = m_client->synchronousShow(topLevel, params.ref + ":./" + relativePath);
|
||||
if (content.isEmpty())
|
||||
return nullptr;
|
||||
QByteArray fileContent;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QPainter>
|
||||
#include <QModelIndex>
|
||||
|
||||
using namespace VcsBase;
|
||||
|
||||
@@ -53,9 +54,36 @@ enum Columns
|
||||
ColumnCount
|
||||
};
|
||||
|
||||
class LogChangeModel : public QStandardItemModel
|
||||
{
|
||||
public:
|
||||
explicit LogChangeModel(LogChangeWidget *parent) : QStandardItemModel(0, ColumnCount, parent) {}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override
|
||||
{
|
||||
if (role == Qt::ToolTipRole) {
|
||||
const QString revision = index.sibling(index.row(), Sha1Column).data(Qt::EditRole).toString();
|
||||
const auto it = m_descriptions.constFind(revision);
|
||||
if (it != m_descriptions.constEnd())
|
||||
return *it;
|
||||
const QString desc = QString::fromUtf8(
|
||||
GitClient::instance()->synchronousShow(
|
||||
m_workingDirectory, revision, VcsCommand::NoOutput));
|
||||
m_descriptions[revision] = desc;
|
||||
return desc;
|
||||
}
|
||||
return QStandardItemModel::data(index, role);
|
||||
}
|
||||
|
||||
void setWorkingDirectory(const QString &workingDir) { m_workingDirectory = workingDir; }
|
||||
private:
|
||||
QString m_workingDirectory;
|
||||
mutable QHash<QString, QString> m_descriptions;
|
||||
};
|
||||
|
||||
LogChangeWidget::LogChangeWidget(QWidget *parent)
|
||||
: Utils::TreeView(parent)
|
||||
, m_model(new QStandardItemModel(0, ColumnCount, this))
|
||||
, m_model(new LogChangeModel(this))
|
||||
, m_hasCustomDelegate(false)
|
||||
{
|
||||
QStringList headers;
|
||||
@@ -72,6 +100,7 @@ LogChangeWidget::LogChangeWidget(QWidget *parent)
|
||||
|
||||
bool LogChangeWidget::init(const QString &repository, const QString &commit, LogFlags flags)
|
||||
{
|
||||
m_model->setWorkingDirectory(repository);
|
||||
if (!populateLog(repository, commit, flags))
|
||||
return false;
|
||||
if (m_model->rowCount() > 0)
|
||||
|
||||
@@ -42,6 +42,8 @@ QT_END_NAMESPACE
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class LogChangeModel;
|
||||
|
||||
// A widget that lists SHA1 and subject of the changes
|
||||
// Used for reset and interactive rebase
|
||||
|
||||
@@ -76,7 +78,7 @@ private:
|
||||
bool populateLog(const QString &repository, const QString &commit, LogFlags flags);
|
||||
const QStandardItem *currentItem(int column = 0) const;
|
||||
|
||||
QStandardItemModel *m_model;
|
||||
LogChangeModel *m_model;
|
||||
bool m_hasCustomDelegate;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user