ModifiedAt for items, use it by default

This commit is contained in:
2023-08-03 12:00:33 +02:00
parent fe0003e55f
commit 5f1ad922dc
18 changed files with 64 additions and 22 deletions

View File

@@ -23,10 +23,11 @@ public record SizeScanContainer : ISizeScanContainer
public required NativePath? NativePath { get; init; }
public required AbsolutePath? Parent { get; init; }
public required IContentProvider Provider { get; init; }
public required DateTime? CreatedAt { get; init; } = DateTime.Now;
public required DateTime? ModifiedAt { get; init;} = DateTime.Now;
public required SupportsDelete CanDelete { get; init; }
public bool IsHidden => false;
public bool IsExists => true;
public DateTime? CreatedAt { get; } = DateTime.Now;
public SupportsDelete CanDelete => SupportsDelete.True;
public bool CanRename => false;
public string? Attributes => null;
public AbsolutePathType Type => AbsolutePathType.Container;

View File

@@ -13,12 +13,13 @@ public record SizeScanElement : ISizeScanElement
public required string DisplayName { get; init; }
public required FullName FullName { get; init; }
public required NativePath NativePath { get; init; }
public AbsolutePath? Parent { get; init; }
public required AbsolutePath? Parent { get; init; }
public required DateTime? CreatedAt { get; init; }
public required DateTime? ModifiedAt { get; init;}
public required IDeclarativeProperty<long> Size { get; init; }
public bool IsHidden => false;
public bool IsExists => true;
public DateTime? CreatedAt { get; } = DateTime.Now;
public SupportsDelete CanDelete => SupportsDelete.False;
public bool CanRename => false;
public string? Attributes => "";

View File

@@ -1,4 +1,5 @@
using DeclarativeProperty;
using FileTime.Core.Enums;
using FileTime.Core.Models;
using FileTime.Core.Models.Extensions;
using FileTime.Core.Timeline;
@@ -48,7 +49,10 @@ public class SizeScanTask : ISizeScanTask
RealContainer = scanSizeOf,
Provider = _containerSizeScanProvider,
Status = _containerStatusDebounced,
SizeScanTask = this
SizeScanTask = this,
CreatedAt = scanSizeOf.CreatedAt,
ModifiedAt = scanSizeOf.ModifiedAt,
CanDelete = SupportsDelete.True
};
}
@@ -114,7 +118,9 @@ public class SizeScanTask : ISizeScanTask
NativePath = new NativePath(childName),
Parent = new AbsolutePath(_timelessContentProvider, sizeScanContainer),
Provider = _containerSizeScanProvider,
Size = sizeProperty
Size = sizeProperty,
CreatedAt = element.CreatedAt,
ModifiedAt = element.ModifiedAt,
};
await sizeScanContainer.AddSizeChildAsync(childElement);
@@ -137,7 +143,10 @@ public class SizeScanTask : ISizeScanTask
RealContainer = childContainer,
Provider = _containerSizeScanProvider,
Status = _containerStatusDebounced,
SizeScanTask = this
SizeScanTask = this,
CreatedAt = childContainer.CreatedAt,
ModifiedAt = childContainer.ModifiedAt,
CanDelete = SupportsDelete.False
};
await sizeScanContainer.AddSizeChildAsync(childSearchContainer);

View File

@@ -4,6 +4,8 @@ public enum ItemOrdering
{
Name,
NameDesc,
CreationDate,
CreationDateDesc,
LastModifyDate,
LastModifyDateDesc,
}

View File

@@ -6,8 +6,10 @@ public sealed class SortItemsCommand : IIdentifiableUserCommand
{
public const string OrderByNameCommandName = "order_by_name";
public const string OrderByNameDescCommandName = "order_by_name_desc";
public const string OrderByDateCommandName = "order_by_date";
public const string OrderByDateDescCommandName = "order_by_date_desc";
public const string OrderByCreatedAtCommandName = "order_by_created_at";
public const string OrderByCreatedAtDescCommandName = "order_by_created_at_desc";
public const string OrderByModifiedAtCommandName = "order_by_modified_at";
public const string OrderByModifiedAtDescCommandName = "order_by_modified_at_desc";
public static readonly SortItemsCommand OrderByNameCommand =
new(OrderByNameCommandName, ItemOrdering.Name, "Order by name");
@@ -15,11 +17,17 @@ public sealed class SortItemsCommand : IIdentifiableUserCommand
public static readonly SortItemsCommand OrderByNameDescCommand =
new(OrderByNameDescCommandName, ItemOrdering.NameDesc, "Order by name (descending)");
public static readonly SortItemsCommand OrderByDateCommand =
new(OrderByDateCommandName, ItemOrdering.LastModifyDate, "Order by date");
public static readonly SortItemsCommand OrderByCreatedAtCommand =
new(OrderByCreatedAtCommandName, ItemOrdering.CreationDate, "Order by created");
public static readonly SortItemsCommand OrderByDateDescCommand =
new(OrderByDateDescCommandName, ItemOrdering.LastModifyDateDesc, "Order by date (descending)");
public static readonly SortItemsCommand OrderByCreatedAtDescCommand =
new(OrderByCreatedAtDescCommandName, ItemOrdering.CreationDateDesc, "Order by created (descending)");
public static readonly SortItemsCommand OrderByLastModifiedCommand =
new(OrderByModifiedAtCommandName, ItemOrdering.LastModifyDate, "Order by last modified");
public static readonly SortItemsCommand OrderByLastModifiedDescCommand =
new(OrderByModifiedAtDescCommandName, ItemOrdering.LastModifyDateDesc, "Order by last modified (descending)");
private SortItemsCommand(string userCommandId, ItemOrdering ordering, string title)
{

View File

@@ -15,6 +15,7 @@ public interface IItemViewModel : IInitable<IItem, ITabViewModel, ItemViewModelT
IDeclarativeProperty<bool> IsAlternative { get; }
IDeclarativeProperty<ItemViewMode> ViewMode { get; set; }
DateTime? CreatedAt { get; set; }
DateTime? ModifiedAt { get; set; }
string? Attributes { get; set; }
bool EqualsTo(IItemViewModel? itemViewModel);
}

View File

@@ -52,8 +52,10 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
AddUserCommand(StartCommandSchedulerCommand.Instance);
AddUserCommand(SortItemsCommand.OrderByNameCommand);
AddUserCommand(SortItemsCommand.OrderByNameDescCommand);
AddUserCommand(SortItemsCommand.OrderByDateCommand);
AddUserCommand(SortItemsCommand.OrderByDateDescCommand);
AddUserCommand(SortItemsCommand.OrderByCreatedAtCommand);
AddUserCommand(SortItemsCommand.OrderByCreatedAtDescCommand);
AddUserCommand(SortItemsCommand.OrderByLastModifiedCommand);
AddUserCommand(SortItemsCommand.OrderByLastModifiedDescCommand);
AddUserCommand(IdentifiableSearchCommand.SearchByNameContains);
AddUserCommand(IdentifiableSearchCommand.SearchByRegex);
AddUserCommand(SwitchToTabCommand.SwitchToLastTab);

View File

@@ -31,6 +31,7 @@ public abstract partial class ItemViewModel : IItemViewModel
[Property] private IDeclarativeProperty<ItemViewMode> _viewMode;
[Property] private DateTime? _createdAt;
[Property] private DateTime? _modifiedAt;
[Property] private string? _attributes;
@@ -88,6 +89,7 @@ public abstract partial class ItemViewModel : IItemViewModel
.Debounce(TimeSpan.FromMilliseconds(100));
Attributes = item.Attributes;
CreatedAt = item.CreatedAt;
ModifiedAt = item.ModifiedAt;
}
private Task<ItemViewMode> GenerateViewMode(bool isMarked, bool isSelected, bool isAlternative)

View File

@@ -93,18 +93,24 @@ public partial class TabViewModel : ITabViewModel
{
ItemOrdering.Name =>
items
.Ordering(i => i.BaseItem.Type)
.Ordering(i => i.BaseItem!.Type)
.ThenOrdering(i => i.DisplayNameText),
ItemOrdering.NameDesc =>
items
.Ordering(i => i.BaseItem.Type)
.Ordering(i => i.BaseItem!.Type)
.ThenOrdering(i => i.DisplayNameText, ListSortDirection.Descending),
ItemOrdering.LastModifyDate =>
ItemOrdering.CreationDate =>
items
.Ordering(i => i.CreatedAt),
ItemOrdering.LastModifyDateDesc =>
ItemOrdering.CreationDateDesc =>
items
.Ordering(i => i.CreatedAt, ListSortDirection.Descending),
ItemOrdering.LastModifyDate =>
items
.Ordering(i => i.ModifiedAt),
ItemOrdering.LastModifyDateDesc =>
items
.Ordering(i => i.ModifiedAt, ListSortDirection.Descending),
_ => throw new NotImplementedException()
};

View File

@@ -51,6 +51,7 @@ public class SearchTask : ISearchTask
false,
true,
null,
null,
SupportsDelete.False,
false,
null,

View File

@@ -15,6 +15,7 @@ public interface IItem
bool IsHidden { get; }
bool IsExists { get; }
DateTime? CreatedAt { get; }
DateTime? ModifiedAt { get; }
SupportsDelete CanDelete { get; }
bool CanRename { get; }
IContentProvider Provider { get; }

View File

@@ -34,6 +34,7 @@ public abstract class ContentProviderBase : IContentProvider
public AbsolutePath? Parent { get; }
public DateTime? CreatedAt => null;
public DateTime? ModifiedAt => null;
public string? Attributes => null;

View File

@@ -18,6 +18,7 @@ public class RootContentProvider : IRootContentProvider
public bool IsHidden => false;
public bool IsExists => true;
public DateTime? CreatedAt => null;
public DateTime? ModifiedAt => null;
public SupportsDelete CanDelete => SupportsDelete.False;
public bool CanRename => false;
public IContentProvider Provider => this;

View File

@@ -16,6 +16,7 @@ public record Container(
bool IsHidden,
bool IsExists,
DateTime? CreatedAt,
DateTime? ModifiedAt,
SupportsDelete CanDelete,
bool CanRename,
string? Attributes,

View File

@@ -14,6 +14,7 @@ public record Element(
bool IsHidden,
bool IsExists,
DateTime? CreatedAt,
DateTime? ModifiedAt,
SupportsDelete CanDelete,
bool CanRename,
string? Attributes,

View File

@@ -27,6 +27,7 @@ public class ItemPreview
false,
true,
DateTime.Now,
DateTime.Now,
SupportsDelete.True,
true,
"attr",
@@ -54,6 +55,7 @@ public class ItemPreview
false,
true,
DateTime.Now,
DateTime.Now,
SupportsDelete.True,
true,
"attr",

View File

@@ -11,7 +11,6 @@
x:Name="ItemRoot"
xmlns="https://github.com/avaloniaui"
xmlns:appcore="using:FileTime.App.Core.ViewModels"
xmlns:appcoreenums="using:FileTime.App.Core.Models.Enums"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:guiappvm="using:FileTime.GuiApp.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -88,12 +87,12 @@
</Grid>
<TextBlock
Classes="SmallText"
Text="{Binding CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=yyyy-MM-dd}"
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=yyyy-MM-dd}"
TextAlignment="Right"
Width="95" />
<TextBlock
Classes="SmallText"
Text="{Binding CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=hh:mm}"
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=hh:mm}"
TextAlignment="Right"
Width="35" />
<TextBlock

View File

@@ -164,6 +164,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
false,
true,
DateTime.MinValue,
DateTime.MinValue,
SupportsDelete.False,
false,
"???",
@@ -222,6 +223,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
(directoryInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden,
directoryInfo.Exists,
directoryInfo.CreationTime,
directoryInfo.LastWriteTime,
SupportsDelete.True,
true,
GetDirectoryAttributes(directoryInfo),
@@ -351,6 +353,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
(fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden,
fileInfo.Exists,
fileInfo.CreationTime,
fileInfo.LastWriteTime,
SupportsDelete.True,
true,
GetFileAttributes(fileInfo),