Commit 525b26d0 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

CVS: Enable click on revision in filelog



Match regular expression depending on mode. Improve common VCS settings
layout.
Reviewed-by: default avatarThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
parent 5f60b055
......@@ -48,9 +48,11 @@ namespace Internal {
CVSEditor::CVSEditor(const VCSBase::VCSBaseEditorParameters *type,
QWidget *parent) :
VCSBase::VCSBaseEditor(type, parent),
m_revisionPattern(QLatin1String(CVS_REVISION_AT_START_PATTERN".*$"))
m_revisionAnnotationPattern(QLatin1String(CVS_REVISION_AT_START_PATTERN".*$")),
m_revisionLogPattern(QLatin1String("^revision *("CVS_REVISION_PATTERN")$"))
{
QTC_ASSERT(m_revisionPattern.isValid(), return);
QTC_ASSERT(m_revisionAnnotationPattern.isValid(), return);
QTC_ASSERT(m_revisionLogPattern.isValid(), return);
}
QSet<QString> CVSEditor::annotationChanges() const
......@@ -79,16 +81,31 @@ QSet<QString> CVSEditor::annotationChanges() const
QString CVSEditor::changeUnderCursor(const QTextCursor &c) const
{
// Check for a revision number at the beginning of the line.
// Note that "cursor.select(QTextCursor::WordUnderCursor)" will
// only select the part up until the dot.
// Check if we are at the beginning of a line within a reasonable offset.
const QTextBlock block = c.block();
if (c.atBlockStart() || (c.position() - block.position() < 3)) {
const QString line = block.text();
if (m_revisionPattern.exactMatch(line))
return m_revisionPattern.cap(1);
// Try to match "1.1" strictly:
// 1) Annotation: Check for a revision number at the beginning of the line.
// Note that "cursor.select(QTextCursor::WordUnderCursor)" will
// only select the part up until the dot.
// Check if we are at the beginning of a line within a reasonable offset.
// 2) Log: check for lines like "revision 1.1", cursor past "revision"
switch (contentType()) {
case VCSBase::RegularCommandOutput:
case VCSBase::DiffOutput:
break;
case VCSBase::AnnotateOutput: {
const QTextBlock block = c.block();
if (c.atBlockStart() || (c.position() - block.position() < 3)) {
const QString line = block.text();
if (m_revisionAnnotationPattern.exactMatch(line))
return m_revisionAnnotationPattern.cap(1);
}
}
break;
case VCSBase::LogOutput: {
const QTextBlock block = c.block();
if (c.position() - block.position() > 8 && m_revisionLogPattern.exactMatch(block.text()))
return m_revisionLogPattern.cap(1);
}
break;
}
return QString();
}
......
......@@ -59,7 +59,8 @@ private:
virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
const QRegExp m_revisionPattern;
const QRegExp m_revisionAnnotationPattern;
const QRegExp m_revisionLogPattern;
QString m_diffBaseDir;
};
......
......@@ -65,6 +65,9 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="rowWrapPolicy">
<enum>QFormLayout::WrapLongRows</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="submitMessageCheckScriptLabel">
<property name="toolTip">
......@@ -109,19 +112,6 @@ name &lt;email&gt; alias &lt;email&gt;</string>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
......
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