Skip to content

Commit 4a32cae

Browse files
committed
Merge pull request #1730 from Hosch250/Issue1618
Correctly sort inspection results
2 parents 4bfc3a1 + 8955eb7 commit 4a32cae

File tree

3 files changed

+43
-30
lines changed

3 files changed

+43
-30
lines changed

RetailCoder.VBE/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,14 @@
264264
<Setter Property="Width" Value="16" />
265265
<Setter Property="Margin" Value="4" />
266266
</Style>
267-
267+
268268
<CollectionViewSource x:Key="ResultsByInspectionType" Source="{Binding Results}">
269-
<CollectionViewSource.SortDescriptions>
270-
<componentModel:SortDescription PropertyName="Inspection.InspectionType"/>
271-
<componentModel:SortDescription PropertyName="Inspection.Name"/>
272-
<componentModel:SortDescription PropertyName="QualifiedSelection.QualifiedName.Name"/>
273-
<componentModel:SortDescription PropertyName="QualifiedSelection.Selection.StartLine"/>
274-
<componentModel:SortDescription PropertyName="QualifiedSelection.Selection.StartColumn"/>
275-
</CollectionViewSource.SortDescriptions>
276269
<CollectionViewSource.GroupDescriptions>
277270
<PropertyGroupDescription PropertyName="Inspection" Converter="{StaticResource InspectionTypeConverter}" />
278271
</CollectionViewSource.GroupDescriptions>
279272
</CollectionViewSource>
280273

281274
<CollectionViewSource x:Key="ResultsByModule" Source="{Binding Results}">
282-
<CollectionViewSource.SortDescriptions>
283-
<componentModel:SortDescription PropertyName="QualifiedSelection.QualifiedName.Name"/>
284-
<componentModel:SortDescription PropertyName="Inspection.Name"/>
285-
<componentModel:SortDescription PropertyName="QualifiedSelection.Selection.StartLine"/>
286-
<componentModel:SortDescription PropertyName="QualifiedSelection.Selection.StartColumn"/>
287-
</CollectionViewSource.SortDescriptions>
288275
<CollectionViewSource.GroupDescriptions>
289276
<PropertyGroupDescription PropertyName="QualifiedSelection.QualifiedName" />
290277
</CollectionViewSource.GroupDescriptions>
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
1-
using System.Windows;
2-
using System.Windows.Controls;
3-
4-
namespace Rubberduck.UI.Inspections
1+
namespace Rubberduck.UI.Inspections
52
{
63
/// <summary>
74
/// Interaction logic for InspectionResultsControl.xaml
85
/// </summary>
9-
public partial class InspectionResultsControl : UserControl
6+
public partial class InspectionResultsControl
107
{
118
private InspectionResultsViewModel ViewModel { get { return DataContext as InspectionResultsViewModel; } }
129

1310
public InspectionResultsControl()
1411
{
1512
InitializeComponent();
16-
Loaded += InspectionResultsControl_Loaded;
17-
}
18-
19-
private void InspectionResultsControl_Loaded(object sender, RoutedEventArgs e)
20-
{
21-
if (ViewModel != null && ViewModel.CanRefresh)
22-
{
23-
//ViewModel.RefreshCommand.Execute(null);
24-
}
2513
}
2614
}
2715
}

RetailCoder.VBE/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,18 @@ public bool GroupByInspectionType
124124
set
125125
{
126126
if (_groupByInspectionType == value) { return; }
127-
127+
128+
if (value)
129+
{
130+
Results = new ObservableCollection<ICodeInspectionResult>(
131+
Results.OrderBy(o => o.Inspection.InspectionType)
132+
.ThenBy(t => t.Inspection.Name)
133+
.ThenBy(t => t.QualifiedSelection.QualifiedName.Name)
134+
.ThenBy(t => t.QualifiedSelection.Selection.StartLine)
135+
.ThenBy(t => t.QualifiedSelection.Selection.StartColumn)
136+
.ToList());
137+
}
138+
128139
_groupByInspectionType = value;
129140
OnPropertyChanged();
130141
}
@@ -137,7 +148,17 @@ public bool GroupByLocation
137148
set
138149
{
139150
if (_groupByLocation == value) { return; }
140-
151+
152+
if (value)
153+
{
154+
Results = new ObservableCollection<ICodeInspectionResult>(
155+
Results.OrderBy(o => o.QualifiedSelection.QualifiedName.Name)
156+
.ThenBy(t => t.Inspection.Name)
157+
.ThenBy(t => t.QualifiedSelection.Selection.StartLine)
158+
.ThenBy(t => t.QualifiedSelection.Selection.StartColumn)
159+
.ToList());
160+
}
161+
141162
_groupByLocation = value;
142163
OnPropertyChanged();
143164
}
@@ -231,6 +252,23 @@ private async void _state_StateChanged(object sender, EventArgs e)
231252
IsBusy = true;
232253

233254
var results = (await _inspector.FindIssuesAsync(_state, CancellationToken.None)).ToList();
255+
if (GroupByInspectionType)
256+
{
257+
results = results.OrderBy(o => o.Inspection.InspectionType)
258+
.ThenBy(t => t.Inspection.Name)
259+
.ThenBy(t => t.QualifiedSelection.QualifiedName.Name)
260+
.ThenBy(t => t.QualifiedSelection.Selection.StartLine)
261+
.ThenBy(t => t.QualifiedSelection.Selection.StartColumn)
262+
.ToList();
263+
}
264+
else
265+
{
266+
results = results.OrderBy(o => o.QualifiedSelection.QualifiedName.Name)
267+
.ThenBy(t => t.Inspection.Name)
268+
.ThenBy(t => t.QualifiedSelection.Selection.StartLine)
269+
.ThenBy(t => t.QualifiedSelection.Selection.StartColumn)
270+
.ToList();
271+
}
234272

235273
UiDispatcher.Invoke(() =>
236274
{

0 commit comments

Comments
 (0)