mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 08:42:31 +00:00
progress
This commit is contained in:
@@ -110,8 +110,8 @@ export class GPXFiles extends GPXTreeNode<GPXFile> {
|
|||||||
export class GPXFile extends GPXTreeNode<Track>{
|
export class GPXFile extends GPXTreeNode<Track>{
|
||||||
[immerable] = true;
|
[immerable] = true;
|
||||||
|
|
||||||
readonly attributes: GPXFileAttributes;
|
attributes: GPXFileAttributes;
|
||||||
readonly metadata: Metadata;
|
metadata: Metadata;
|
||||||
readonly wpt: ReadonlyArray<Readonly<Waypoint>>;
|
readonly wpt: ReadonlyArray<Readonly<Waypoint>>;
|
||||||
readonly trk: ReadonlyArray<Track>;
|
readonly trk: ReadonlyArray<Track>;
|
||||||
|
|
||||||
|
@@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
<div class="absolute top-2 left-0 right-0 z-20 flex flex-row justify-center pointer-events-none">
|
<div class="absolute top-2 left-0 right-0 z-20 flex flex-row justify-center pointer-events-none">
|
||||||
<div
|
<div
|
||||||
class="w-fit flex flex-row flex-wrap mx-16 items-center justify-center p-1 bg-background rounded-md pointer-events-auto shadow-md"
|
class="w-fit flex flex-row mx-16 items-center justify-center p-1 bg-background rounded-md pointer-events-auto shadow-md"
|
||||||
>
|
>
|
||||||
<Logo class="h-5 mt-0.5 mx-2" />
|
<Logo class="h-5 mt-0.5 mx-2" />
|
||||||
<Menubar.Root class="border-none h-fit p-0">
|
<Menubar.Root class="border-none h-fit p-0">
|
||||||
@@ -104,8 +104,8 @@
|
|||||||
<Menubar.Content class="border-none">
|
<Menubar.Content class="border-none">
|
||||||
<Menubar.Item on:click={createFile}>
|
<Menubar.Item on:click={createFile}>
|
||||||
<Plus size="16" class="mr-1" />
|
<Plus size="16" class="mr-1" />
|
||||||
{$_('menu.new')}
|
{$_('menu.create')}
|
||||||
<Shortcut key="N" ctrl={true} />
|
<Shortcut key="C" ctrl={true} />
|
||||||
</Menubar.Item>
|
</Menubar.Item>
|
||||||
<Menubar.Separator />
|
<Menubar.Separator />
|
||||||
<Menubar.Item on:click={triggerFileInput}>
|
<Menubar.Item on:click={triggerFileInput}>
|
||||||
@@ -295,7 +295,7 @@
|
|||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
on:keydown={(e) => {
|
on:keydown={(e) => {
|
||||||
if (e.key === 'n' && (e.metaKey || e.ctrlKey)) {
|
if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
|
||||||
createFile();
|
createFile();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (e.key === 'o' && (e.metaKey || e.ctrlKey)) {
|
} else if (e.key === 'o' && (e.metaKey || e.ctrlKey)) {
|
||||||
|
@@ -66,30 +66,34 @@ export function selectAll() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyToOrderedSelectedItemsFromFile(callback: (fileId: string, level: ListLevel | undefined, items: ListItem[]) => void) {
|
export function applyToOrderedSelectedItemsFromFile(callback: (fileId: string, level: ListLevel | undefined, items: ListItem[]) => void, reverse: boolean = true) {
|
||||||
get(settings.fileOrder).forEach((fileId) => {
|
get(settings.fileOrder).forEach((fileId) => {
|
||||||
let level: ListLevel | undefined = undefined;
|
let level: ListLevel | undefined = undefined;
|
||||||
let items: ListItem[] = [];
|
let items: ListItem[] = [];
|
||||||
get(selection).forEach((item) => {
|
get(selection).forEach((item) => {
|
||||||
if (item.getFileId() === fileId) {
|
if (item.getFileId() === fileId) {
|
||||||
level = item.level;
|
level = item.level;
|
||||||
if (item instanceof ListTrackItem || item instanceof ListTrackSegmentItem || item instanceof ListWaypointItem) {
|
if (item instanceof ListFileItem || item instanceof ListTrackItem || item instanceof ListTrackSegmentItem || item instanceof ListWaypointItem) {
|
||||||
items.push(item);
|
items.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
items.sort((a, b) => { // Process the items in reverse order to avoid index conflicts
|
if (items.length > 0) {
|
||||||
if (a instanceof ListTrackItem && b instanceof ListTrackItem) {
|
if (reverse) {
|
||||||
return b.getTrackIndex() - a.getTrackIndex();
|
items.sort((a, b) => { // Process the items in reverse order to avoid index conflicts
|
||||||
} else if (a instanceof ListTrackSegmentItem && b instanceof ListTrackSegmentItem) {
|
if (a instanceof ListTrackItem && b instanceof ListTrackItem) {
|
||||||
return b.getSegmentIndex() - a.getSegmentIndex();
|
return b.getTrackIndex() - a.getTrackIndex();
|
||||||
} else if (a instanceof ListWaypointItem && b instanceof ListWaypointItem) {
|
} else if (a instanceof ListTrackSegmentItem && b instanceof ListTrackSegmentItem) {
|
||||||
return b.getWaypointIndex() - a.getWaypointIndex();
|
return b.getSegmentIndex() - a.getSegmentIndex();
|
||||||
|
} else if (a instanceof ListWaypointItem && b instanceof ListWaypointItem) {
|
||||||
|
return b.getWaypointIndex() - a.getWaypointIndex();
|
||||||
|
}
|
||||||
|
return b.level - a.level;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return b.level - a.level;
|
|
||||||
});
|
|
||||||
|
|
||||||
callback(fileId, level, items);
|
callback(fileId, level, items);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@@ -5,8 +5,8 @@ import { GPXFile, buildGPX, parseGPX, GPXStatistics, type Coordinates } from 'gp
|
|||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
import { _ } from 'svelte-i18n';
|
import { _ } from 'svelte-i18n';
|
||||||
import type { GPXLayer } from '$lib/components/gpx-layer/GPXLayer';
|
import type { GPXLayer } from '$lib/components/gpx-layer/GPXLayer';
|
||||||
import { settings, dbUtils, fileObservers } from './db';
|
import { dbUtils, fileObservers } from './db';
|
||||||
import { selectFile, selection } from '$lib/components/file-list/Selection';
|
import { applyToOrderedSelectedItemsFromFile, selectFile, selection } from '$lib/components/file-list/Selection';
|
||||||
import { ListFileItem, ListWaypointItem } from '$lib/components/file-list/FileList';
|
import { ListFileItem, ListWaypointItem } from '$lib/components/file-list/FileList';
|
||||||
import type { RoutingControls } from '$lib/components/toolbar/tools/routing/RoutingControls';
|
import type { RoutingControls } from '$lib/components/toolbar/tools/routing/RoutingControls';
|
||||||
|
|
||||||
@@ -15,17 +15,15 @@ export const selectFiles = writable<{ [key: string]: (fileId?: string) => void }
|
|||||||
|
|
||||||
export const gpxStatistics: Writable<GPXStatistics> = writable(new GPXStatistics());
|
export const gpxStatistics: Writable<GPXStatistics> = writable(new GPXStatistics());
|
||||||
|
|
||||||
const { fileOrder } = settings;
|
|
||||||
|
|
||||||
function updateGPXData() {
|
function updateGPXData() {
|
||||||
let statistics = new GPXStatistics();
|
let statistics = new GPXStatistics();
|
||||||
get(fileOrder).forEach((fileId) => { // Get statistics in the order of the file list
|
applyToOrderedSelectedItemsFromFile((fileId, level, items) => {
|
||||||
let fileStore = get(fileObservers).get(fileId);
|
let fileStore = get(fileObservers).get(fileId);
|
||||||
if (fileStore) {
|
if (fileStore) {
|
||||||
let stats = get(fileStore)?.statistics;
|
let stats = get(fileStore)?.statistics;
|
||||||
if (stats !== undefined) {
|
if (stats) {
|
||||||
let first = true;
|
let first = true;
|
||||||
get(selection).getChild(fileId)?.getSelected().forEach((item) => { // Get statistics for selected items within the file
|
items.forEach((item) => {
|
||||||
if (!(item instanceof ListWaypointItem) || first) {
|
if (!(item instanceof ListWaypointItem) || first) {
|
||||||
statistics.mergeWith(stats.getStatisticsFor(item));
|
statistics.mergeWith(stats.getStatisticsFor(item));
|
||||||
first = false;
|
first = false;
|
||||||
@@ -33,7 +31,7 @@ function updateGPXData() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, false);
|
||||||
gpxStatistics.set(statistics);
|
gpxStatistics.set(statistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"menu": {
|
"menu": {
|
||||||
"file": "File",
|
"file": "File",
|
||||||
"new": "New",
|
"create": "Create",
|
||||||
"new_filename": "new",
|
"new_filename": "new",
|
||||||
"load_desktop": "Load from desktop...",
|
"load_desktop": "Load from desktop...",
|
||||||
"load_drive": "Load from Google Drive...",
|
"load_drive": "Load from Google Drive...",
|
||||||
|
Reference in New Issue
Block a user