1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "resource.h"
\r
21 #include "StandardLayoutNodeList.h"
\r
22 #include "VisibleGraphNode.h"
\r
23 #include "CachedLogInfo.h"
\r
25 #include "UnicodeUtils.h"
\r
29 index_t CStandardLayoutNodeList::GetStyle
\r
30 (const CVisibleGraphNode* node) const
\r
32 CNodeClassification classification = node->GetClassification();
\r
34 if (classification.Is (CNodeClassification::IS_ADDED))
\r
35 return ILayoutNodeList::SNode::STYLE_ADDED;
\r
36 else if (classification.Is (CNodeClassification::IS_DELETED))
\r
37 return ILayoutNodeList::SNode::STYLE_DELETED;
\r
38 else if (classification.Is (CNodeClassification::IS_RENAMED))
\r
39 return ILayoutNodeList::SNode::STYLE_RENAMED;
\r
40 else if (classification.Is (CNodeClassification::IS_LAST))
\r
41 return ILayoutNodeList::SNode::STYLE_LAST;
\r
42 else if (classification.Is (CNodeClassification::IS_MODIFIED))
\r
43 return ILayoutNodeList::SNode::STYLE_MODIFIED;
\r
45 return ILayoutNodeList::SNode::STYLE_DEFAULT;
\r
48 DWORD CStandardLayoutNodeList::GetStyleFlags
\r
49 (const CVisibleGraphNode* /*node*/) const
\r
56 CStandardLayoutNodeList::CStandardLayoutNodeList
\r
57 ( const std::vector<CStandardLayoutNodeInfo>& nodes
\r
58 , const CCachedLogInfo* cache)
\r
64 // implement ILayoutItemList
\r
66 index_t CStandardLayoutNodeList::GetCount() const
\r
68 return static_cast<index_t>(nodes.size());
\r
71 CString CStandardLayoutNodeList::GetToolTip (index_t index) const
\r
75 const CRevisionIndex& revisions = cache->GetRevisions();
\r
76 const CRevisionInfoContainer& revisionInfo = cache->GetLogInfo();
\r
78 const CVisibleGraphNode* node = nodes[index].node;
\r
80 // find the revision in our cache.
\r
81 // May not be present if this is the WC / HEAD revision.
\r
83 revision_t revision = node->GetRevision();
\r
84 index_t revisionIndex = revisions [revision];
\r
85 if (revisionIndex == NO_INDEX)
\r
88 // get standard revprops
\r
90 TCHAR date[SVN_DATE_BUFFER];
\r
91 apr_time_t timeStamp = revisionInfo.GetTimeStamp (revisionIndex);
\r
92 SVN::formatDate(date, timeStamp);
\r
95 = CUnicodeUtils::StdGetUnicode
\r
96 (node->GetRealPath().GetPath()).c_str();
\r
98 = CUnicodeUtils::StdGetUnicode
\r
99 (revisionInfo.GetAuthor (revisionIndex)).c_str();
\r
101 = CUnicodeUtils::StdGetUnicode
\r
102 (revisionInfo.GetComment (revisionIndex)).c_str();
\r
104 // construct the tooltip
\r
106 if (node->GetFirstTag() == NULL)
\r
108 strTipText.Format ( IDS_REVGRAPH_BOXTOOLTIP
\r
109 , revision, (LPCTSTR)realPath, (LPCTSTR)author
\r
110 , date, (LPCTSTR)comment);
\r
116 for ( const CVisibleGraphNode::CFoldedTag* tag = node->GetFirstTag()
\r
118 ; tag = tag->GetNext())
\r
122 CString attributes;
\r
123 if (tag->IsModified())
\r
124 attributes.LoadString (IDS_REVGRAPH_TAGMODIFIED);
\r
126 if (tag->IsDeleted())
\r
129 attribute.LoadString (IDS_REVGRAPH_TAGDELETED);
\r
130 if (attributes.IsEmpty())
\r
131 attributes = attribute;
\r
133 attributes += _T(", ") + attribute;
\r
137 std::string tagPath = tag->GetTag()->GetPath().GetPath();
\r
139 if (attributes.IsEmpty())
\r
141 tagInfo.Format ( tag->IsAlias()
\r
142 ? IDS_REVGRAPH_TAGALIAS
\r
144 , CUnicodeUtils::StdGetUnicode (tagPath).c_str());
\r
148 tagInfo.Format ( tag->IsAlias()
\r
149 ? IDS_REVGRAPH_TAGALIASATTRIBUTED
\r
150 : IDS_REVGRAPH_TAGATTRIBUTED
\r
151 , (LPCTSTR)attributes
\r
152 , CUnicodeUtils::StdGetUnicode (tagPath).c_str());
\r
156 + CString (' ', tag->GetDepth() * 6)
\r
160 strTipText.Format ( IDS_REVGRAPH_BOXTOOLTIP_TAGGED
\r
161 , revision, (LPCTSTR)realPath, (LPCTSTR)author
\r
162 , date, tagCount, (LPCTSTR)tags, (LPCTSTR)comment);
\r
170 index_t CStandardLayoutNodeList::GetFirstVisible (const CRect& viewRect) const
\r
172 return GetNextVisible (static_cast<index_t>(-1), viewRect);
\r
175 index_t CStandardLayoutNodeList::GetNextVisible ( index_t prev
\r
176 , const CRect& viewRect) const
\r
178 for (size_t i = prev+1, count = nodes.size(); i < count; ++i)
\r
179 if (FALSE != CRect().IntersectRect (nodes[i].rect, viewRect))
\r
180 return static_cast<index_t>(i);
\r
182 return static_cast<index_t>(NO_INDEX);
\r
185 index_t CStandardLayoutNodeList::GetAt (const CPoint& point, long delta) const
\r
187 for (size_t i = 0, count = nodes.size(); i < count; ++i)
\r
189 const CRect& rect = nodes[i].rect;
\r
190 if ( (rect.top - point.y <= delta)
\r
191 && (rect.left - point.x <= delta)
\r
192 && (point.y - rect.bottom <= delta)
\r
193 && (point.x - rect.right <= delta))
\r
195 return static_cast<index_t>(i);
\r
199 return static_cast<index_t>(NO_INDEX);
\r
202 // implement ILayoutNodeList
\r
204 CStandardLayoutNodeList::SNode
\r
205 CStandardLayoutNodeList::GetNode (index_t index) const
\r
209 const CVisibleGraphNode* node = nodes[index].node;
\r
211 result.rect = nodes[index].rect;
\r
212 result.node = node;
\r
213 result.style = GetStyle (node);
\r
214 result.styleFlags = GetStyleFlags (node);
\r