Commit 42b39023 authored by Friedemann Kleint's avatar Friedemann Kleint

VCS polishing: Change context menu entry for 'Blame parent'.

... for git, hg as it is not obvious from the SHA1 displayed.
parent 4c29c61a
......@@ -164,9 +164,9 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizardPage::createCheckoutJob(
QStringList CloneWizardPage::branches(const QString &repository, int *current)
{
// Run git on remote repository if URL is complete
// Run git on remote repository if an URL was specified.
*current = 0;
if (!repository.endsWith(d->gitPostFix))
if (repository.isEmpty())
return QStringList();
const QStringList branches = Internal::GitPlugin::instance()->gitClient()->synchronousRepositoryBranches(repository);
*current = branches.indexOf(QLatin1String("master"));
......
......@@ -66,6 +66,7 @@ GitEditor::GitEditor(const VCSBase::VCSBaseEditorParameters *type,
QTC_ASSERT(m_changeNumberPattern8.isValid(), return);
QTC_ASSERT(m_changeNumberPattern40.isValid(), return);
setAnnotateRevisionTextFormat(tr("Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame parent revision %1"));
if (Git::Constants::debug)
qDebug() << "GitEditor::GitEditor" << type->type << type->id;
}
......
......@@ -55,6 +55,7 @@ MercurialEditor::MercurialEditor(const VCSBase::VCSBaseEditorParameters *type, Q
diffIdentifier(QLatin1String(Constants::DIFFIDENTIFIER))
{
setAnnotateRevisionTextFormat(tr("Annotate %1"));
setAnnotatePreviousRevisionTextFormat(tr("Annotate parent revision %1"));
}
QSet<QString> MercurialEditor::annotationChanges() const
......
......@@ -158,6 +158,7 @@ struct VCSBaseEditorPrivate
QList<int> m_diffSections; // line number where this section starts
int m_cursorLine;
QString m_annotateRevisionTextFormat;
QString m_annotatePreviousRevisionTextFormat;
QString m_copyRevisionTextFormat;
bool m_fileLogAnnotateEnabled;
};
......@@ -246,6 +247,16 @@ void VCSBaseEditor::setAnnotateRevisionTextFormat(const QString &f)
d->m_annotateRevisionTextFormat = f;
}
QString VCSBaseEditor::annotatePreviousRevisionTextFormat() const
{
return d->m_annotatePreviousRevisionTextFormat;
}
void VCSBaseEditor::setAnnotatePreviousRevisionTextFormat(const QString &f)
{
d->m_annotatePreviousRevisionTextFormat = f;
}
QString VCSBaseEditor::copyRevisionTextFormat() const
{
return d->m_copyRevisionTextFormat;
......@@ -405,9 +416,12 @@ QAction *VCSBaseEditor::createDescribeAction(const QString &change)
return a;
}
QAction *VCSBaseEditor::createAnnotateAction(const QString &change)
QAction *VCSBaseEditor::createAnnotateAction(const QString &change, bool previous)
{
QAction *a = new QAction(d->m_annotateRevisionTextFormat.arg(change), 0);
// Use 'previous' format if desired and available, else default to standard.
const QString &format = previous && !d->m_annotatePreviousRevisionTextFormat.isEmpty() ?
d->m_annotatePreviousRevisionTextFormat : d->m_annotateRevisionTextFormat;
QAction *a = new QAction(format.arg(change), 0);
a->setData(change);
connect(a, SIGNAL(triggered()), this, SLOT(slotAnnotateRevision()));
return a;
......@@ -434,7 +448,7 @@ void VCSBaseEditor::contextMenuEvent(QContextMenuEvent *e)
menu->addAction(createCopyRevisionAction(d->m_currentChange));
menu->addAction(createDescribeAction(d->m_currentChange));
if (d->m_fileLogAnnotateEnabled)
menu->addAction(createAnnotateAction(d->m_currentChange));
menu->addAction(createAnnotateAction(d->m_currentChange, false));
break;
case AnnotateOutput: { // Describe current / annotate previous
menu->addSeparator();
......@@ -444,7 +458,7 @@ void VCSBaseEditor::contextMenuEvent(QContextMenuEvent *e)
if (!previousVersions.isEmpty()) {
menu->addSeparator();
foreach(const QString &pv, previousVersions)
menu->addAction(createAnnotateAction(pv));
menu->addAction(createAnnotateAction(pv, true));
} // has previous versions
}
break;
......
......@@ -119,6 +119,11 @@ public:
QString annotateRevisionTextFormat() const;
void setAnnotateRevisionTextFormat(const QString &);
// Format for "Annotate Previous" revision menu entries. Should contain '%1" placeholder.
// Defaults to "annotateRevisionTextFormat" if unset.
QString annotatePreviousRevisionTextFormat() const;
void setAnnotatePreviousRevisionTextFormat(const QString &);
// Format for "Copy" revision menu entries. Should contain '%1" placeholder
QString copyRevisionTextFormat() const;
void setCopyRevisionTextFormat(const QString &);
......@@ -230,7 +235,7 @@ private:
void jumpToChangeFromDiff(QTextCursor cursor);
QAction *createDescribeAction(const QString &change);
QAction *createAnnotateAction(const QString &change);
QAction *createAnnotateAction(const QString &change, bool previous = false);
QAction *createCopyRevisionAction(const QString &change);
VCSBaseEditorPrivate *d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment