Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 2418730

Browse files
committed
Merge pull request #99 from macgitver/sc/refsview
Sc/refsview
2 parents 23b4cc1 + 949835e commit 2418730

28 files changed

Lines changed: 1229 additions & 782 deletions

History/HistoryBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ void HistoryBuilder::addBranches(bool includeRemotes)
7171

7272
QStringList sl = mRepo.branchNames(r, true, false);
7373
foreach (const QString& s, sl) {
74-
mWalker.pushRef(r, QLatin1Literal("refs/heads/") % s);
74+
mWalker.pushRef(r, QStringLiteral("refs/heads/") % s);
7575
}
7676

7777
if (includeRemotes) {
7878
sl = mRepo.branchNames(r, false, true);
7979

8080
foreach (const QString& s, sl) {
81-
mWalker.pushRef(r, QLatin1Literal("refs/remotes/") % s);
81+
mWalker.pushRef(r, QStringLiteral("refs/remotes/") % s);
8282
}
8383
}
8484
}

History/HistoryDiff.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ HistoryDiff::HistoryDiff()
5252
mToolbar = new QToolBar;
5353

5454
mDiffTo = new QComboBox;
55+
mDiffTo->addItem( trUtf8( "All parents" ), DTT_AllParents );
56+
mDiffTo->addItem( trUtf8( "Parent" ), DTT_Parent );
5557
mDiffTo->addItem( trUtf8( "Workingtree" ), DTT_WT );
5658
mDiffTo->addItem( trUtf8( "Index" ), DTT_Index );
5759
mDiffTo->addItem( trUtf8( "Workingtree + Index" ), DTT_WT_and_Index );
5860
mDiffTo->addItem( trUtf8( "HEAD" ), DTT_HEAD );
5961
//mDiffTo->addItem( trUtf8( "SHA-1" ), DTT_AnySHA1 );
6062
mDiffTo->addItem( trUtf8( "Branch" ), DTT_Branch );
6163
mDiffTo->addItem( trUtf8( "Tag" ), DTT_Tag );
62-
mDiffTo->addItem( trUtf8( "All parents" ), DTT_AllParents );
63-
mDiffTo->addItem( trUtf8( "Parent" ), DTT_Parent );
6464

6565
mToolbar->addWidget( new QLabel( trUtf8( "Diff to:" ) ) );
6666
mToolbar->addWidget( mDiffTo );

History/HistoryEntry.h

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,82 @@ struct HistoryInlineRef
6161
bool mIsRemote : 1;
6262
bool mIsTag : 1;
6363
bool mIsStash : 1;
64+
bool mIsDetached : 1;
65+
66+
bool operator ==(const HistoryInlineRef& other) const
67+
{
68+
if ( this == &other ) {
69+
return true;
70+
}
71+
72+
return mRefName == other.mRefName &&
73+
mIsBranch == other.mIsBranch &&
74+
mIsCurrent == other.mIsCurrent &&
75+
mIsRemote == other.mIsRemote &&
76+
mIsTag == other.mIsTag &&
77+
mIsStash == other.mIsStash &&
78+
mIsDetached == other.mIsDetached ;
79+
}
80+
81+
inline bool operator !=(const HistoryInlineRef& other) const {
82+
return !( *this == other );
83+
}
84+
85+
inline bool detachedHEAD() const
86+
{
87+
return mIsDetached && !(mIsTag || mIsBranch || mIsStash);
88+
}
89+
90+
inline bool nameLessThan(const HistoryInlineRef& other) const
91+
{
92+
return mRefName < other.mRefName;
93+
}
94+
95+
bool operator <(const HistoryInlineRef& other) const
96+
{
97+
// sort order:
98+
// - tag
99+
// - detached HEAD
100+
// - current branch
101+
// - local branch
102+
// - remote branch
103+
// - stash
104+
// - Everything else is sorted by mRefName
105+
106+
if ( mIsTag ) {
107+
// tags have highest priority
108+
return other.mIsTag ? nameLessThan(other) : true;
109+
}
110+
111+
if ( detachedHEAD() )
112+
{
113+
// a detached HEAD comes right after tag ? -> There can only be one!
114+
return !other.mIsTag;
115+
}
116+
117+
if ( mIsBranch )
118+
{
119+
if ( other.mIsTag || other.mIsCurrent || other.detachedHEAD() )
120+
return false;
121+
122+
if ( mIsCurrent ) {
123+
// a is the current branch
124+
return true;
125+
}
126+
127+
return ( mIsRemote == other.mIsRemote ) ? nameLessThan( other ) : !mIsRemote;
128+
}
129+
130+
if ( mIsStash ) {
131+
return other.mIsStash ? nameLessThan( other )
132+
: !(other.mIsTag || other.mIsBranch || other.detachedHEAD());
133+
}
134+
135+
return !(other.mIsTag || other.mIsBranch || other.mIsStash || other.detachedHEAD()) ? nameLessThan( other ) : false;
136+
}
64137
};
65138

66-
typedef QVector< HistoryInlineRef > HistoryInlineRefs;
139+
typedef QList< HistoryInlineRef > HistoryInlineRefs;
67140

68141
class HistoryEntry
69142
{

History/HistoryListDelegate.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ QColor HistoryListDelegate::colorForRefType(const HistoryInlineRef& ref) const
304304
return QColor::fromHsl(89, 255, 190);
305305
}
306306

307-
return QColor( 0xD9D9D9 );
307+
if ( ref.mIsStash )
308+
return QColor( 0xD9D9D9 );
309+
310+
// DETACHED REF
311+
return QColor( 0xFF5959 );
308312
}
309313

310314
void HistoryListDelegate::paintMessage( QPainter* p, const QStyleOptionViewItem& opt,

0 commit comments

Comments
 (0)