Skip to content

Commit 4d4d7ec

Browse files
committed
0.8.0: Custom file picker with proper keybaord navigation, new geologically-focused example database
1 parent eb71965 commit 4d4d7ec

File tree

6 files changed

+232
-82
lines changed

6 files changed

+232
-82
lines changed

examples/geology/queries.sql

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-- Field Geology Example Queries
2+
-- SQLite/CE Example
3+
4+
-- All samples with full details
5+
SELECT s.name AS sample, r.name AS rock, f.name AS formation,
6+
s.location, s.collected_date
7+
FROM samples s
8+
LEFT JOIN rock_types r ON s.rock_type_id = r.id
9+
LEFT JOIN formations f ON s.formation_id = f.id
10+
ORDER BY s.collected_date DESC;
11+
12+
-- Samples by rock category
13+
SELECT r.category, COUNT(*) AS count
14+
FROM samples s
15+
JOIN rock_types r ON s.rock_type_id = r.id
16+
GROUP BY r.category
17+
ORDER BY count DESC;
18+
19+
-- Samples from Idaho Batholith
20+
SELECT s.name, r.name AS rock_type, s.location, s.elevation_ft
21+
FROM samples s
22+
JOIN rock_types r ON s.rock_type_id = r.id
23+
JOIN formations f ON s.formation_id = f.id
24+
WHERE f.name = 'Idaho Batholith'
25+
ORDER BY s.elevation_ft DESC;
26+
27+
-- High elevation samples (above 5000 ft)
28+
SELECT name, location, elevation_ft
29+
FROM samples
30+
WHERE elevation_ft > 5000
31+
ORDER BY elevation_ft DESC;
32+
33+
-- Samples collected today (for field use)
34+
SELECT s.name, r.name AS rock_type, s.location, s.notes
35+
FROM samples s
36+
LEFT JOIN rock_types r ON s.rock_type_id = r.id
37+
WHERE s.collected_date = '2026-01-15';
38+
39+
-- Formation age summary
40+
SELECT name, age_period, age_mya || ' Ma' AS age
41+
FROM formations
42+
ORDER BY CAST(age_mya AS INTEGER) DESC;
43+
44+
-- Igneous rocks only
45+
SELECT s.name, r.name AS rock_type, s.location
46+
FROM samples s
47+
JOIN rock_types r ON s.rock_type_id = r.id
48+
WHERE r.category = 'igneous';
49+
50+
-- Using views
51+
SELECT * FROM v_samples ORDER BY collected_date DESC;
52+
53+
SELECT * FROM v_collection_summary;

examples/geology/sample_data.sql

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Field Geology Sample Data
2+
-- SQLite/CE Example
3+
-- Idaho focus: Bogus Basin / Boise Front area
4+
5+
-- Rock types
6+
INSERT INTO rock_types VALUES (1, 'igneous', 'granite');
7+
INSERT INTO rock_types VALUES (2, 'igneous', 'granodiorite');
8+
INSERT INTO rock_types VALUES (3, 'igneous', 'rhyolite');
9+
INSERT INTO rock_types VALUES (4, 'igneous', 'basalt');
10+
INSERT INTO rock_types VALUES (5, 'sedimentary', 'sandstone');
11+
INSERT INTO rock_types VALUES (6, 'sedimentary', 'siltstone');
12+
INSERT INTO rock_types VALUES (7, 'metamorphic', 'gneiss');
13+
INSERT INTO rock_types VALUES (8, 'metamorphic', 'schist');
14+
15+
-- Idaho formations (real geology of the Boise area)
16+
INSERT INTO formations VALUES (1, 'Idaho Batholith', 'Cretaceous', '75-100',
17+
'Large granitic intrusion forming Boise Front mountains');
18+
INSERT INTO formations VALUES (2, 'Challis Volcanics', 'Eocene', '45-50',
19+
'Volcanic rocks from Challis volcanic episode');
20+
INSERT INTO formations VALUES (3, 'Idaho Group', 'Miocene-Pliocene', '2-10',
21+
'Lake sediments from ancient Lake Idaho');
22+
INSERT INTO formations VALUES (4, 'Snake River Plain Basalts', 'Quaternary', '0.01-2',
23+
'Young basalt flows from hotspot volcanism');
24+
INSERT INTO formations VALUES (5, 'Glenns Ferry Formation', 'Pliocene', '3-4',
25+
'Lacustrine and fluvial sediments');
26+
27+
-- Sample collection (mix of real locations near Bogus Basin)
28+
INSERT INTO samples VALUES (1, 'BB-001', 2, 1, 'Bogus Basin Road mile 12',
29+
'43.7621', '-116.1025', 6200, '2026-01-15', 'Field Team',
30+
'Coarse-grained, pink feldspar prominent');
31+
INSERT INTO samples VALUES (2, 'BB-002', 1, 1, 'Deer Point trailhead',
32+
'43.7589', '-116.0987', 6450, '2026-01-15', 'Field Team',
33+
'Weathered surface, fresh interior gray-white');
34+
INSERT INTO samples VALUES (3, 'BB-003', 2, 1, 'Superior summit area',
35+
'43.7534', '-116.1102', 7582, '2026-01-15', 'Field Team',
36+
'Excellent exposure, visible quartz and biotite');
37+
INSERT INTO samples VALUES (4, 'SH-001', 4, 4, 'Swan Falls Road',
38+
'43.2456', '-116.3789', 2650, '2025-12-10', 'Field Team',
39+
'Vesicular basalt, pahoehoe texture');
40+
INSERT INTO samples VALUES (5, 'SH-002', 4, 4, 'Celebration Park',
41+
'43.2512', '-116.4023', 2580, '2025-12-10', 'Field Team',
42+
'Columnar jointing visible in canyon wall');
43+
INSERT INTO samples VALUES (6, 'TB-001', 5, 3, 'Table Rock',
44+
'43.5978', '-116.1456', 3680, '2025-11-22', 'Field Team',
45+
'Fine-grained, tan, lake sediment origin');
46+
INSERT INTO samples VALUES (7, 'TB-002', 6, 5, 'Table Rock east slope',
47+
'43.5965', '-116.1423', 3520, '2025-11-22', 'Field Team',
48+
'Laminated, fossil leaf impressions');
49+
INSERT INTO samples VALUES (8, 'CR-001', 3, 2, 'Cottonwood Creek',
50+
'43.8234', '-115.9876', 5100, '2025-10-05', 'Field Team',
51+
'Flow-banded rhyolite, Challis age');

examples/geology/schema.sql

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
-- Field Geology Sample Catalog Schema
2+
-- SQLite/CE Example
3+
-- Idaho focus: Bogus Basin / Boise Front area
4+
5+
CREATE TABLE rock_types (
6+
id INTEGER PRIMARY KEY,
7+
category TEXT NOT NULL, -- igneous, sedimentary, metamorphic
8+
name TEXT NOT NULL
9+
);
10+
11+
CREATE TABLE formations (
12+
id INTEGER PRIMARY KEY,
13+
name TEXT NOT NULL,
14+
age_period TEXT,
15+
age_mya TEXT, -- millions of years ago
16+
description TEXT
17+
);
18+
19+
CREATE TABLE samples (
20+
id INTEGER PRIMARY KEY,
21+
name TEXT NOT NULL,
22+
rock_type_id INTEGER,
23+
formation_id INTEGER,
24+
location TEXT,
25+
latitude TEXT,
26+
longitude TEXT,
27+
elevation_ft INTEGER,
28+
collected_date TEXT,
29+
collector TEXT,
30+
notes TEXT
31+
);
32+
33+
CREATE INDEX idx_samples_rock ON samples(rock_type_id);
34+
CREATE INDEX idx_samples_formation ON samples(formation_id);
35+
CREATE INDEX idx_samples_date ON samples(collected_date);
36+
37+
-- Views
38+
CREATE VIEW v_samples AS
39+
SELECT s.id, s.name, r.category, r.name AS rock_type,
40+
f.name AS formation, s.location, s.collected_date
41+
FROM samples s
42+
LEFT JOIN rock_types r ON s.rock_type_id = r.id
43+
LEFT JOIN formations f ON s.formation_id = f.id;
44+
45+
CREATE VIEW v_collection_summary AS
46+
SELECT r.category, COUNT(*) AS count
47+
FROM samples s
48+
JOIN rock_types r ON s.rock_type_id = r.id
49+
GROUP BY r.category;

src/sqlite-ce-edit/fileops.c

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -366,25 +366,17 @@ void DoExportResults(void) {
366366
**============================================================================*/
367367

368368
void DoExportCSV(void) {
369-
CE_OPENFILENAME ofn;
370-
wchar_t szFile[MAX_PATH] = L"results.csv";
369+
wchar_t szFile[MAX_PATH] = L"results";
371370
HANDLE hFile;
372371
DWORD dwLen, dwWritten;
373372
wchar_t *wbuf, *wp;
374373
char *buf, *bp;
375374
int needQuote;
376375

377-
memset(&ofn, 0, sizeof(ofn));
378-
ofn.lStructSize = sizeof(ofn);
379-
ofn.hwndOwner = g_hwndMain;
380-
ofn.lpstrFile = szFile;
381-
ofn.nMaxFile = MAX_PATH;
382-
ofn.lpstrFilter = L"CSV Files (*.csv)\0*.csv\0All Files (*.*)\0*.*\0";
383-
ofn.lpstrDefExt = L"csv";
384-
ofn.lpstrTitle = L"Export Results";
385-
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
386-
387-
if (!GetSaveFileNameW(&ofn)) return;
376+
if (!CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
377+
L"Export Results",
378+
L"CSV Files\0*.csv\0All Files\0*.*\0",
379+
L"csv", NULL, 1)) return;
388380

389381
dwLen = GetWindowTextLengthW(g_hwndResult);
390382
if (dwLen == 0) return;
@@ -441,24 +433,16 @@ void DoExportCSV(void) {
441433
**============================================================================*/
442434

443435
void DoExportTxt(void) {
444-
CE_OPENFILENAME ofn;
445-
wchar_t szFile[MAX_PATH] = L"results.txt";
436+
wchar_t szFile[MAX_PATH] = L"results";
446437
HANDLE hFile;
447438
DWORD dwLen, dwWritten;
448439
wchar_t *wbuf;
449440
char *buf;
450441

451-
memset(&ofn, 0, sizeof(ofn));
452-
ofn.lStructSize = sizeof(ofn);
453-
ofn.hwndOwner = g_hwndMain;
454-
ofn.lpstrFile = szFile;
455-
ofn.nMaxFile = MAX_PATH;
456-
ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
457-
ofn.lpstrDefExt = L"txt";
458-
ofn.lpstrTitle = L"Export Results";
459-
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
460-
461-
if (!GetSaveFileNameW(&ofn)) return;
442+
if (!CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
443+
L"Export Results",
444+
L"Text Files\0*.txt\0All Files\0*.*\0",
445+
L"txt", NULL, 1)) return;
462446

463447
dwLen = GetWindowTextLengthW(g_hwndResult);
464448
if (dwLen == 0) return;
@@ -986,25 +970,16 @@ void DoExportHTML(void) {
986970
}
987971
} else {
988972
/* Save to file */
989-
CE_OPENFILENAME ofn;
990973
wchar_t szFile[MAX_PATH];
991974
HANDLE hFile;
992975
DWORD written;
993976

994977
MultiByteToWideChar(CP_ACP, 0, tblName, -1, szFile, MAX_PATH);
995-
lstrcatW(szFile, L".html");
996-
997-
memset(&ofn, 0, sizeof(ofn));
998-
ofn.lStructSize = sizeof(ofn);
999-
ofn.hwndOwner = g_hwndMain;
1000-
ofn.lpstrFile = szFile;
1001-
ofn.nMaxFile = MAX_PATH;
1002-
ofn.lpstrFilter = L"HTML Files (*.html)\0*.html\0All Files (*.*)\0*.*\0";
1003-
ofn.lpstrDefExt = L"html";
1004-
ofn.lpstrTitle = L"Export HTML Table";
1005-
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
1006978

1007-
if (GetSaveFileNameW(&ofn)) {
979+
if (CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
980+
L"Export HTML Table",
981+
L"HTML Files\0*.html\0All Files\0*.*\0",
982+
L"html", NULL, 1)) {
1008983
hFile = CreateFileW(szFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1009984
if (hFile != INVALID_HANDLE_VALUE) {
1010985
WriteFile(hFile, buf, (DWORD)len, &written, NULL);
@@ -1167,22 +1142,14 @@ void DoExportHTMLResults(void) {
11671142
}
11681143
}
11691144
} else {
1170-
CE_OPENFILENAME ofn;
1171-
wchar_t szFile[MAX_PATH] = L"results.html";
1145+
wchar_t szFile[MAX_PATH] = L"results";
11721146
HANDLE hFile;
11731147
DWORD written;
11741148

1175-
memset(&ofn, 0, sizeof(ofn));
1176-
ofn.lStructSize = sizeof(ofn);
1177-
ofn.hwndOwner = g_hwndMain;
1178-
ofn.lpstrFile = szFile;
1179-
ofn.nMaxFile = MAX_PATH;
1180-
ofn.lpstrFilter = L"HTML Files (*.html)\0*.html\0All Files (*.*)\0*.*\0";
1181-
ofn.lpstrDefExt = L"html";
1182-
ofn.lpstrTitle = L"Export Results as HTML";
1183-
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
1184-
1185-
if (GetSaveFileNameW(&ofn)) {
1149+
if (CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
1150+
L"Export Results as HTML",
1151+
L"HTML Files\0*.html\0All Files\0*.*\0",
1152+
L"html", NULL, 1)) {
11861153
hFile = CreateFileW(szFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
11871154
if (hFile != INVALID_HANDLE_VALUE) {
11881155
WriteFile(hFile, buf, (DWORD)len, &written, NULL);
@@ -1278,8 +1245,7 @@ static void ExportTableToCSV(const wchar_t *dir, const char *tblName) {
12781245
**============================================================================*/
12791246

12801247
void DoExportDb(void) {
1281-
CE_OPENFILENAME ofn;
1282-
wchar_t szFile[MAX_PATH] = L"export.db";
1248+
wchar_t szFile[MAX_PATH] = L"export";
12831249
char szDestPath[MAX_PATH * 2];
12841250
sqlite *destDb;
12851251
char **result;
@@ -1291,16 +1257,10 @@ void DoExportDb(void) {
12911257

12921258
if (!g_db) return;
12931259

1294-
memset(&ofn, 0, sizeof(ofn));
1295-
ofn.lStructSize = sizeof(ofn);
1296-
ofn.hwndOwner = g_hwndMain;
1297-
ofn.lpstrFile = szFile;
1298-
ofn.nMaxFile = MAX_PATH;
1299-
ofn.lpstrFilter = L"SQLite Database (*.db)\0*.db\0CSV Folder (*.csv)\0*.csv\0";
1300-
ofn.lpstrTitle = L"Export Database";
1301-
ofn.Flags = OFN_PATHMUSTEXIST;
1302-
1303-
if (!GetSaveFileNameW(&ofn)) return;
1260+
if (!CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
1261+
L"Export Database",
1262+
L"SQLite Database\0*.db\0CSV Folder\0*.csv\0",
1263+
L"db", NULL, 1)) return;
13041264

13051265
/* Detect mode by extension */
13061266
{

0 commit comments

Comments
 (0)