Frequency navigation WIP
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reactive.Linq;
|
||||
using DynamicData;
|
||||
using FileTime.Core.ContentAccess;
|
||||
using FileTime.Core.Enums;
|
||||
using FileTime.Core.Timeline;
|
||||
@@ -21,7 +22,7 @@ public interface IItem
|
||||
string? Attributes { get; }
|
||||
AbsolutePathType Type { get; }
|
||||
PointInTime PointInTime { get; }
|
||||
IObservable<IEnumerable<Exception>> Exceptions { get; }
|
||||
IObservable<IChangeSet<Exception>> Exceptions { get; }
|
||||
ReadOnlyExtensionCollection Extensions { get; }
|
||||
|
||||
T? GetExtension<T>() => (T?)Extensions.FirstOrDefault(i => i is T);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using FileTime.Core.Services;
|
||||
|
||||
namespace FileTime.Core.Models;
|
||||
|
||||
public class TabLocationChanged : EventArgs
|
||||
{
|
||||
public FullName Location { get; }
|
||||
public ITab Tab { get; }
|
||||
|
||||
public TabLocationChanged(FullName location, ITab tab)
|
||||
{
|
||||
Location = location;
|
||||
Tab = tab;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.Core.Services;
|
||||
|
||||
public interface ITabEvents
|
||||
{
|
||||
event EventHandler<TabLocationChanged> LocationChanged;
|
||||
void OnLocationChanged(ITab tab, FullName location);
|
||||
}
|
||||
@@ -48,7 +48,8 @@ public abstract class ContentProviderBase : IContentProvider
|
||||
public AbsolutePathType Type => AbsolutePathType.Container;
|
||||
public PointInTime PointInTime { get; } = PointInTime.Eternal;
|
||||
|
||||
public IObservable<IEnumerable<Exception>> Exceptions => Observable.Return(Enumerable.Empty<Exception>());
|
||||
protected SourceList<Exception> Exceptions { get; } = new();
|
||||
IObservable<IChangeSet<Exception>> IItem.Exceptions => Exceptions.Connect();
|
||||
|
||||
ReadOnlyExtensionCollection IItem.Extensions => _extensions;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public record Container(
|
||||
IContentProvider Provider,
|
||||
bool AllowRecursiveDeletion,
|
||||
PointInTime PointInTime,
|
||||
IObservable<IEnumerable<Exception>> Exceptions,
|
||||
IObservable<IChangeSet<Exception>> Exceptions,
|
||||
ReadOnlyExtensionCollection Extensions,
|
||||
IObservable<IObservable<IChangeSet<AbsolutePath, string>>?> Items) : IContainer
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using DynamicData;
|
||||
using FileTime.Core.ContentAccess;
|
||||
using FileTime.Core.Enums;
|
||||
using FileTime.Core.Timeline;
|
||||
@@ -18,7 +19,7 @@ public record Element(
|
||||
string? Attributes,
|
||||
IContentProvider Provider,
|
||||
PointInTime PointInTime,
|
||||
IObservable<IEnumerable<Exception>> Exceptions,
|
||||
IObservable<IChangeSet<Exception>> Exceptions,
|
||||
ReadOnlyExtensionCollection Extensions) : IElement
|
||||
{
|
||||
public AbsolutePathType Type => AbsolutePathType.Element;
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace FileTime.Core.Services;
|
||||
public class Tab : ITab
|
||||
{
|
||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||
private readonly ITabEvents _tabEvents;
|
||||
private readonly BehaviorSubject<IContainer?> _currentLocation = new(null);
|
||||
private readonly BehaviorSubject<IContainer?> _currentLocationForced = new(null);
|
||||
private readonly BehaviorSubject<AbsolutePath?> _currentSelectedItem = new(null);
|
||||
@@ -24,9 +25,10 @@ public class Tab : ITab
|
||||
public IObservable<AbsolutePath?> CurrentSelectedItem { get; }
|
||||
public FullName? LastDeepestSelectedPath { get; private set; }
|
||||
|
||||
public Tab(ITimelessContentProvider timelessContentProvider)
|
||||
public Tab(ITimelessContentProvider timelessContentProvider, ITabEvents tabEvents)
|
||||
{
|
||||
_timelessContentProvider = timelessContentProvider;
|
||||
_tabEvents = tabEvents;
|
||||
_currentPointInTime = null!;
|
||||
|
||||
_timelessContentProvider.CurrentPointInTime.Subscribe(p => _currentPointInTime = p);
|
||||
@@ -60,7 +62,7 @@ public class Tab : ITab
|
||||
),
|
||||
CurrentLocation
|
||||
.Where(c => c is null)
|
||||
.Select(_ => (IObservable<IChangeSet<IItem, string>>?)null)
|
||||
.Select(_ => (IObservable<IChangeSet<IItem, string>>?) null)
|
||||
)
|
||||
.Publish(null)
|
||||
.RefCount();
|
||||
@@ -137,8 +139,25 @@ public class Tab : ITab
|
||||
return newSelectedItem;
|
||||
}
|
||||
|
||||
public void SetCurrentLocation(IContainer newLocation) => _currentLocation.OnNext(newLocation);
|
||||
public void ForceSetCurrentLocation(IContainer newLocation) => _currentLocationForced.OnNext(newLocation);
|
||||
public void SetCurrentLocation(IContainer newLocation)
|
||||
{
|
||||
_currentLocation.OnNext(newLocation);
|
||||
|
||||
if (newLocation.FullName != null)
|
||||
{
|
||||
_tabEvents.OnLocationChanged(this, newLocation.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceSetCurrentLocation(IContainer newLocation)
|
||||
{
|
||||
_currentLocationForced.OnNext(newLocation);
|
||||
|
||||
if (newLocation.FullName != null)
|
||||
{
|
||||
_tabEvents.OnLocationChanged(this, newLocation.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSelectedItem(AbsolutePath newSelectedItem) => _currentSelectedItem.OnNext(newSelectedItem);
|
||||
|
||||
|
||||
13
src/Core/FileTime.Core.Services/TabEvents.cs
Normal file
13
src/Core/FileTime.Core.Services/TabEvents.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.Core.Services;
|
||||
|
||||
public class TabEvents : ITabEvents
|
||||
{
|
||||
public event EventHandler<TabLocationChanged> LocationChanged;
|
||||
|
||||
public void OnLocationChanged(ITab tab, FullName location)
|
||||
{
|
||||
LocationChanged?.Invoke(this, new TabLocationChanged(location, tab));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user