feat: add search, recurring schedules, and Windows packaging
- Add title/description search with Ctrl+F and a result dialog\n- Support daily/weekly/monthly recurring blocks with conflict skipping\n- Add CPack NSIS packaging, MinGW release preset, and deploy script\n- Add window/view/list/dialog fade animations\n- Document multi-device conflict behavior and update validation screenshots
@@ -30,3 +30,45 @@ if(GO_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(client)
|
||||
|
||||
install(FILES README.md DESTINATION .)
|
||||
install(FILES client/3rd/ElaWidgetTools/LICENSE
|
||||
DESTINATION licenses RENAME ElaWidgetTools-LICENSE)
|
||||
install(FILES client/3rd/tomlplusplus/LICENSE
|
||||
DESTINATION licenses RENAME tomlplusplus-LICENSE)
|
||||
|
||||
if(WIN32)
|
||||
if(NOT SCHEDULE_WINDEPLOYQT)
|
||||
message(FATAL_ERROR "windeployqt was not configured; check the Qt/MinGW preset paths")
|
||||
endif()
|
||||
set(_compiler_runtime_arg "")
|
||||
if(MSVC)
|
||||
set(_compiler_runtime_arg "--compiler-runtime")
|
||||
endif()
|
||||
install(CODE "
|
||||
set(_stage \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
|
||||
execute_process(
|
||||
COMMAND \"${SCHEDULE_WINDEPLOYQT}\" ${_compiler_runtime_arg} --dir \"\${_stage}\" \"\${_stage}/Schedule.exe\"
|
||||
RESULT_VARIABLE _deploy_result
|
||||
)
|
||||
if(NOT _deploy_result EQUAL 0)
|
||||
message(FATAL_ERROR \"windeployqt failed during install: \${_deploy_result}\")
|
||||
endif()
|
||||
")
|
||||
|
||||
set(CPACK_GENERATOR "NSIS")
|
||||
set(CPACK_PACKAGE_NAME "Schedule")
|
||||
set(CPACK_PACKAGE_VENDOR "Misaki")
|
||||
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Schedule")
|
||||
set(CPACK_PACKAGE_EXECUTABLES "Schedule;AI 日程")
|
||||
set(CPACK_CREATE_DESKTOP_LINKS "Schedule")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "AI 日程")
|
||||
set(CPACK_NSIS_PACKAGE_NAME "AI 日程")
|
||||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
||||
set(CPACK_NSIS_MODIFY_PATH OFF)
|
||||
set(CPACK_NSIS_INSTALLED_ICON_NAME "Schedule.exe")
|
||||
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Schedule.exe")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
||||
@@ -65,6 +65,18 @@
|
||||
"deprecated": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-mingw-release",
|
||||
"displayName": "Windows MinGW-w64 Release",
|
||||
"inherits": "windows-mingw",
|
||||
"binaryDir": "${sourceDir}/build/windows-mingw-release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
},
|
||||
"warnings": {
|
||||
"deprecated": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-clang",
|
||||
"displayName": "macOS Clang (edit Qt path in preset)",
|
||||
@@ -96,6 +108,10 @@
|
||||
"name": "windows-mingw",
|
||||
"configurePreset": "windows-mingw"
|
||||
},
|
||||
{
|
||||
"name": "windows-mingw-release",
|
||||
"configurePreset": "windows-mingw-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-clang",
|
||||
"configurePreset": "macos-clang"
|
||||
@@ -143,6 +159,11 @@
|
||||
"QT_QPA_PLATFORM": "offscreen",
|
||||
"PATH": "C:/Qt/6.6.3/mingw_64/bin;C:/Qt/Tools/mingw1120_64/bin;$penv{PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-mingw-release",
|
||||
"inherits": "windows-mingw",
|
||||
"configurePreset": "windows-mingw-release"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
细粒度个人日程 + AI 自然语言排程 + 自部署多设备同步。
|
||||
|
||||
当前进度:**阶段 0–4(含精力曲线 / 幽灵时间 / 每日复盘 / 主动建议)**。
|
||||
当前进度:**阶段 0–4 + 搜索 / 重复日程 / Windows 安装包 / 界面动画**。
|
||||
本地模型 50 条指令回归已完成:完整 49/50(98%),失败项 #42 单独复测通过。
|
||||
详细计划见 [`docs/PLAN.md`](docs/PLAN.md),验证记录见 [`docs/validation/`](docs/validation/)。
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
- **详细日程窗口**:日 / 月 / 年三种视图、选中日期任务面板、新建/编辑/删除、设置;顶部房屋按钮或关闭窗口回到紧凑窗口。
|
||||
- **系统托盘**:关闭紧凑窗口时最小化到托盘;托盘可显示主窗口、新建日程、退出。
|
||||
- **智能增强**:今日任务面板显示主动建议;日视图绘制幽灵时间;提供每日复盘对话框。
|
||||
- **搜索与重复**:详细日程支持标题/说明搜索(`Ctrl+F`);新建日程可设置每天/每周/每月重复。
|
||||
- **轻量动画**:窗口淡入、视图切换淡入、任务列表刷新与 Diff 卡片淡入。
|
||||
- **设置**:主题(跟随系统/浅色/深色)、ElaMica 云母效果、AI 接口地址/模型/API Key、同步服务地址/开关。
|
||||
|
||||
> 云母效果使用 ElaWidgetTools 的 `ElaMica` 跨平台模拟背景(内置模糊基底图),
|
||||
@@ -50,6 +52,31 @@
|
||||
|
||||
精力档案按设备本地保存,不参与多设备变更流;不同设备的作息差异不会互相覆盖。
|
||||
|
||||
## 搜索与重复日程
|
||||
|
||||
### 搜索
|
||||
|
||||
- 详细日程顶部搜索框输入标题或说明,回车打开结果;`Ctrl+F` 从任何窗口打开。
|
||||
- 查询覆盖任务标题、说明和来源引用;结果按离当前时间最近排序,最多 100 条。
|
||||
- 点击或回车选择结果会跳到对应日期并定位到日程块。
|
||||
|
||||
### 重复日程
|
||||
|
||||
- 新建日程时可选择每天、每周或每月重复,并设置重复结束日期。
|
||||
- 重复会物化为共享同一任务的时间块,最多 1 年 / 200 次;与现有日程冲突的日期会自动跳过。
|
||||
- 重复规则元数据保存在本机 `recurrence` 表;具体时间块照常参与多设备同步。其他设备能看到所有已物化的日程。
|
||||
- 编辑某个重复日程的标题会修改共享任务标题(影响该系列);删除单个块只删除该次。
|
||||
|
||||
## 同步冲突行为
|
||||
|
||||
同步是后台无感进行的:不弹冲突对话框,失败自动重试,状态只显示在顶部标签。
|
||||
|
||||
- **同一任务/时间块在不同设备同时编辑**:按 `updated_at` 做 LWW,时间戳更新的版本获胜;删除墓碑在等时间戳时优先。
|
||||
- **不同日程被安排在同一时间**:它们是两个独立实体,都会保留,日视图以重叠列展示;系统不会自动移动或删除任何一方。
|
||||
- **重复日程**:物化后的时间块按普通日程同步;重复规则本身不参与变更流。
|
||||
- **服务端**只保存有序变更流,不做语义合并;最终一致性由客户端 LWW 保证。
|
||||
- 如果希望“同一时间只保留一个日程”,需要后续在客户端增加冲突策略或自动涟漪;当前策略是保留双方、避免静默丢数据。
|
||||
|
||||
### 本地模型
|
||||
|
||||
本地模型通过 **OpenAI 兼容端点**接入,与云端使用同一套 Provider:
|
||||
@@ -166,6 +193,22 @@ cmake --build --preset linux-gcc
|
||||
`windows-msvc` 与 `macos-clang` 也采用相同的做法:在对应 preset 中直接填写
|
||||
`CMAKE_PREFIX_PATH`,不使用环境变量或自动搜索。
|
||||
|
||||
### Windows 安装包
|
||||
|
||||
安装 [NSIS](https://nsis.sourceforge.io/) 并将 `makensis.exe` 加入 `PATH` 后,在仓库根目录运行:
|
||||
|
||||
```powershell
|
||||
.\scripts\package-windows.ps1
|
||||
```
|
||||
|
||||
脚本会使用 `windows-mingw-release` preset 构建 Release、运行测试,然后执行 CPack:
|
||||
|
||||
- 安装 `build/windows-mingw-release/Schedule-0.1.0-win64.exe`;
|
||||
- 安装过程会自动运行 `windeployqt`,收集 Qt DLL、插件和 MinGW 运行时;
|
||||
- 未安装 NSIS 时会退化为 `Schedule-*.zip` 便携包。
|
||||
|
||||
安装包包含开始菜单项与桌面快捷方式,卸载信息写入 Windows 应用列表。
|
||||
|
||||
### Windows 多设备联调
|
||||
|
||||
1. 在服务端机器启动 `go run ./cmd/server`(或 Docker),设置随机 `SYNC_TOKEN_PEPPER`。
|
||||
@@ -186,7 +229,7 @@ ctest --preset linux-gcc
|
||||
```
|
||||
|
||||
当前自动化测试(12 组):存储/服务、网格与详细窗口、紧凑窗口、TOML 配置、SchedulerEngine、
|
||||
精力档案 / 幽灵时间 / 每日复盘、AI 编排(15 个用例:流式、修复、更新/删除、涟漪、拆分、冲突保护、多轮历史、文件、删除兜底、无 diff 重试)、
|
||||
精力档案 / 幽灵时间 / 每日复盘、搜索 / 重复日程、AI 编排(15 个用例:流式、修复、更新/删除、涟漪、拆分、冲突保护、多轮历史、文件、删除兜底、无 diff 重试)、
|
||||
OpenAI 兼容 Provider(本地假 SSE 服务,含无 API Key 的本地模型)、AI 对话到接受落库的 UI 全链路、Go 服务端单元/接口/并发测试、双客户端同步集成(含离线重连)。
|
||||
|
||||
本地模型回归(50 条真实中文指令):
|
||||
@@ -234,6 +277,7 @@ AI 接口地址、模型、API Key 与同步服务地址/开关可直接在设
|
||||
| `Ctrl+O` | 打开详细日程 |
|
||||
| `Ctrl+,` | 打开设置 |
|
||||
| `Ctrl+R` | 今日复盘 |
|
||||
| `Ctrl+F` | 打开搜索 |
|
||||
|
||||
### 详细日程窗口
|
||||
|
||||
@@ -246,6 +290,7 @@ AI 接口地址、模型、API Key 与同步服务地址/开关可直接在设
|
||||
| `Ctrl+T` | 回到今天 |
|
||||
| `Ctrl+,` | 打开设置 |
|
||||
| `Ctrl+R` | 今日复盘 |
|
||||
| `Ctrl+F` | 搜索日程 |
|
||||
| `Ctrl` + 滚轮 | 时间轴缩放(日视图) |
|
||||
| `Delete` | 删除选中日程(日视图) |
|
||||
| `Enter` | 编辑选中日程(日视图) |
|
||||
|
||||
@@ -6,6 +6,7 @@ add_library(schedule_core STATIC
|
||||
core/EnergyProfile.cpp
|
||||
core/EnergyProfile.h
|
||||
core/ProposedDiff.h
|
||||
core/Recurrence.h
|
||||
core/SchedulerEngine.cpp
|
||||
core/SchedulerEngine.h
|
||||
core/ScheduleItem.h
|
||||
@@ -83,6 +84,8 @@ add_library(schedule_ui STATIC
|
||||
ui/dialogs/BlockEditDialog.h
|
||||
ui/dialogs/DailyReviewDialog.cpp
|
||||
ui/dialogs/DailyReviewDialog.h
|
||||
ui/dialogs/SearchDialog.cpp
|
||||
ui/dialogs/SearchDialog.h
|
||||
ui/dialogs/SettingsDialog.cpp
|
||||
ui/dialogs/SettingsDialog.h
|
||||
ui/panels/ChatPanel.cpp
|
||||
@@ -93,6 +96,8 @@ add_library(schedule_ui STATIC
|
||||
ui/panels/TodayItemCard.h
|
||||
ui/panels/TodayPanel.cpp
|
||||
ui/panels/TodayPanel.h
|
||||
ui/theme/AnimationUtils.cpp
|
||||
ui/theme/AnimationUtils.h
|
||||
ui/theme/ThemeManager.cpp
|
||||
ui/theme/ThemeManager.h
|
||||
ui/theme/ThemeTokens.h
|
||||
@@ -124,3 +129,19 @@ target_link_libraries(Schedule PRIVATE schedule_ui schedule_sync)
|
||||
if(WIN32)
|
||||
schedule_deploy_qt_runtime(Schedule)
|
||||
endif()
|
||||
|
||||
install(TARGETS Schedule
|
||||
RUNTIME DESTINATION .
|
||||
BUNDLE DESTINATION .
|
||||
)
|
||||
if(WIN32 AND MINGW)
|
||||
get_filename_component(_mingw_bin_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
file(GLOB _mingw_runtime
|
||||
"${_mingw_bin_dir}/libgcc_s_*.dll"
|
||||
"${_mingw_bin_dir}/libstdc++-6.dll"
|
||||
"${_mingw_bin_dir}/libwinpthread-1.dll"
|
||||
)
|
||||
if(_mingw_runtime)
|
||||
install(FILES ${_mingw_runtime} DESTINATION .)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDate>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
enum class RecurrenceFrequency
|
||||
{
|
||||
None = 0,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
};
|
||||
|
||||
struct RecurrenceSpec
|
||||
{
|
||||
RecurrenceFrequency frequency = RecurrenceFrequency::None;
|
||||
QDate until;
|
||||
};
|
||||
|
||||
struct Recurrence
|
||||
{
|
||||
QString id;
|
||||
QString taskId;
|
||||
QString rule;
|
||||
std::optional<QDate> until;
|
||||
};
|
||||
@@ -186,6 +186,216 @@ bool ScheduleService::createBlock(const QString& title,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScheduleService::createRecurringBlock(const QString& title,
|
||||
const QDateTime& start,
|
||||
const QDateTime& end,
|
||||
RecurrenceFrequency frequency,
|
||||
const QDate& until,
|
||||
int* createdCount,
|
||||
QString* error)
|
||||
{
|
||||
if (createdCount)
|
||||
{
|
||||
*createdCount = 0;
|
||||
}
|
||||
if (frequency == RecurrenceFrequency::None)
|
||||
{
|
||||
return createBlock(title, start, end, error);
|
||||
}
|
||||
|
||||
const QDateTime normalizedStart = truncateToMinute(start);
|
||||
const QDateTime normalizedEnd = truncateToMinute(end);
|
||||
if (!validateRange(normalizedStart, normalizedEnd, error))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!until.isValid() || until < normalizedStart.date())
|
||||
{
|
||||
m_lastError = QStringLiteral("重复结束日期必须不早于开始日期");
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QDate firstDate = normalizedStart.date();
|
||||
const QDate horizon = firstDate.addDays(366);
|
||||
const QDate effectiveUntil = std::min(until, horizon);
|
||||
const int durationSeconds = DateTimeUtils::minutesBetween(normalizedStart, normalizedEnd) * 60;
|
||||
|
||||
QVector<QDateTime> candidates;
|
||||
candidates.reserve(64);
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
QDate date;
|
||||
switch (frequency)
|
||||
{
|
||||
case RecurrenceFrequency::Daily:
|
||||
date = firstDate.addDays(index);
|
||||
break;
|
||||
case RecurrenceFrequency::Weekly:
|
||||
date = firstDate.addDays(index * 7);
|
||||
break;
|
||||
case RecurrenceFrequency::Monthly:
|
||||
date = firstDate.addMonths(index);
|
||||
break;
|
||||
case RecurrenceFrequency::None:
|
||||
break;
|
||||
}
|
||||
if (!date.isValid() || date > effectiveUntil)
|
||||
{
|
||||
break;
|
||||
}
|
||||
candidates.append(QDateTime(date, normalizedStart.time(), normalizedStart.timeSpec()));
|
||||
}
|
||||
if (candidates.isEmpty())
|
||||
{
|
||||
m_lastError = QStringLiteral("没有生成有效的重复日期");
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QDateTime lastEnd = candidates.last().addSecs(durationSeconds);
|
||||
const QVector<ScheduleItem> existing =
|
||||
m_store.blocksInRange(DateTimeUtils::localDayStartUtc(firstDate),
|
||||
DateTimeUtils::localDayEndUtc(lastEnd.date()));
|
||||
QVector<QPair<QDateTime, QDateTime>> busy;
|
||||
for (const ScheduleItem& item : existing)
|
||||
{
|
||||
if (item.block.status == QStringLiteral("dropped") ||
|
||||
item.block.status == QStringLiteral("missed"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
busy.append({item.block.startAt, item.block.endAt});
|
||||
}
|
||||
|
||||
QVector<QDateTime> accepted;
|
||||
for (const QDateTime& occurrence : candidates)
|
||||
{
|
||||
const QDateTime occurrenceEnd = occurrence.addSecs(durationSeconds);
|
||||
const bool conflict = std::any_of(busy.cbegin(), busy.cend(), [&](const auto& interval) {
|
||||
return occurrence < interval.second && occurrenceEnd > interval.first;
|
||||
});
|
||||
if (conflict)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
accepted.append(occurrence);
|
||||
busy.append({occurrence, occurrenceEnd});
|
||||
}
|
||||
if (accepted.isEmpty())
|
||||
{
|
||||
m_lastError = QStringLiteral("重复日程的时段均已被占用");
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QDateTime now = QDateTime::currentDateTime();
|
||||
Task task;
|
||||
task.id = newId();
|
||||
task.title = title.trimmed().isEmpty() ? QStringLiteral("未命名日程") : title.trimmed();
|
||||
task.source = QStringLiteral("manual");
|
||||
task.estimatedMin = durationSeconds / 60;
|
||||
task.createdAt = now;
|
||||
task.updatedAt = now;
|
||||
task.version = 0;
|
||||
task.deviceId = m_deviceId;
|
||||
|
||||
QVector<TimeBlock> blocks;
|
||||
blocks.reserve(accepted.size());
|
||||
for (const QDateTime& occurrence : accepted)
|
||||
{
|
||||
TimeBlock block;
|
||||
block.id = newId();
|
||||
block.taskId = task.id;
|
||||
block.startAt = occurrence;
|
||||
block.endAt = occurrence.addSecs(durationSeconds);
|
||||
block.createdAt = now;
|
||||
block.updatedAt = now;
|
||||
block.version = 0;
|
||||
block.deviceId = m_deviceId;
|
||||
blocks.append(block);
|
||||
}
|
||||
|
||||
Recurrence recurrence;
|
||||
recurrence.id = newId();
|
||||
recurrence.taskId = task.id;
|
||||
recurrence.rule = frequency == RecurrenceFrequency::Daily
|
||||
? QStringLiteral("FREQ=DAILY")
|
||||
: (frequency == RecurrenceFrequency::Weekly ? QStringLiteral("FREQ=WEEKLY")
|
||||
: QStringLiteral("FREQ=MONTHLY"));
|
||||
recurrence.until = effectiveUntil;
|
||||
|
||||
if (!m_store.beginTransaction())
|
||||
{
|
||||
m_lastError = m_store.lastError();
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!m_store.insertTask(task))
|
||||
{
|
||||
m_store.rollback();
|
||||
m_lastError = m_store.lastError();
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (const TimeBlock& block : blocks)
|
||||
{
|
||||
if (!m_store.insertTimeBlock(block))
|
||||
{
|
||||
m_store.rollback();
|
||||
m_lastError = m_store.lastError();
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!m_store.insertRecurrence(recurrence))
|
||||
{
|
||||
m_store.rollback();
|
||||
m_lastError = m_store.lastError();
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!m_store.commit())
|
||||
{
|
||||
m_store.rollback();
|
||||
m_lastError = m_store.lastError();
|
||||
if (error)
|
||||
{
|
||||
*error = m_lastError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (createdCount)
|
||||
{
|
||||
*createdCount = accepted.size();
|
||||
}
|
||||
m_lastError.clear();
|
||||
Q_EMIT dataChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScheduleService::updateBlock(const QString& blockId,
|
||||
const QString& title,
|
||||
const QDateTime& start,
|
||||
@@ -976,6 +1186,11 @@ QVector<ScheduleItem> ScheduleService::overdueItems(const QDateTime& now) const
|
||||
return items;
|
||||
}
|
||||
|
||||
QVector<ScheduleItem> ScheduleService::search(const QString& query, int limit) const
|
||||
{
|
||||
return m_store.search(query, limit);
|
||||
}
|
||||
|
||||
QString ScheduleService::lastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "core/DailyInsights.h"
|
||||
#include "core/EnergyProfile.h"
|
||||
#include "core/ProposedDiff.h"
|
||||
#include "core/Recurrence.h"
|
||||
#include "core/ScheduleItem.h"
|
||||
|
||||
class SqliteStore;
|
||||
@@ -28,6 +29,13 @@ public:
|
||||
const QDateTime& start,
|
||||
const QDateTime& end,
|
||||
QString* error = nullptr);
|
||||
bool createRecurringBlock(const QString& title,
|
||||
const QDateTime& start,
|
||||
const QDateTime& end,
|
||||
RecurrenceFrequency frequency,
|
||||
const QDate& until,
|
||||
int* createdCount = nullptr,
|
||||
QString* error = nullptr);
|
||||
bool updateBlock(const QString& blockId,
|
||||
const QString& title,
|
||||
const QDateTime& start,
|
||||
@@ -53,6 +61,7 @@ public:
|
||||
// 返回 [from, to] 闭区间内的所有日程,按开始时间升序。
|
||||
QVector<ScheduleItem> itemsForRange(const QDate& from, const QDate& to) const;
|
||||
QVector<ScheduleItem> overdueItems(const QDateTime& now = QDateTime::currentDateTime()) const;
|
||||
QVector<ScheduleItem> search(const QString& query, int limit = 100) const;
|
||||
QString lastError() const;
|
||||
|
||||
const EnergyProfile& energyProfile() const;
|
||||
|
||||
@@ -1055,6 +1055,105 @@ bool SqliteStore::applyRemoteChange(const RemoteChange& change, QString* error)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SqliteStore::insertRecurrence(const Recurrence& recurrence)
|
||||
{
|
||||
m_lastError.clear();
|
||||
if (!isOpenInternal())
|
||||
{
|
||||
return setError(QStringLiteral("数据库未打开"));
|
||||
}
|
||||
QSqlQuery query(m_database);
|
||||
query.prepare(QStringLiteral(
|
||||
"INSERT INTO recurrence(id, task_id, rrule, until) VALUES(:id, :task_id, :rrule, :until)"));
|
||||
query.bindValue(QStringLiteral(":id"), recurrence.id);
|
||||
query.bindValue(QStringLiteral(":task_id"), recurrence.taskId);
|
||||
query.bindValue(QStringLiteral(":rrule"), recurrence.rule);
|
||||
query.bindValue(QStringLiteral(":until"),
|
||||
recurrence.until.has_value() ? QVariant(recurrence.until->toString(Qt::ISODate))
|
||||
: QVariant());
|
||||
if (!query.exec())
|
||||
{
|
||||
return setError(QStringLiteral("写入重复规则失败: %1").arg(query.lastError().text()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<Recurrence> SqliteStore::recurrenceForTask(const QString& taskId) const
|
||||
{
|
||||
m_lastError.clear();
|
||||
if (!isOpenInternal())
|
||||
{
|
||||
setError(QStringLiteral("数据库未打开"));
|
||||
return std::nullopt;
|
||||
}
|
||||
QSqlQuery query(m_database);
|
||||
query.prepare(QStringLiteral("SELECT id, task_id, rrule, until FROM recurrence WHERE task_id = :task_id"));
|
||||
query.bindValue(QStringLiteral(":task_id"), taskId);
|
||||
if (!query.exec())
|
||||
{
|
||||
setError(QStringLiteral("查询重复规则失败: %1").arg(query.lastError().text()));
|
||||
return std::nullopt;
|
||||
}
|
||||
if (!query.next())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
Recurrence recurrence;
|
||||
recurrence.id = query.value(0).toString();
|
||||
recurrence.taskId = query.value(1).toString();
|
||||
recurrence.rule = query.value(2).toString();
|
||||
const QString until = query.value(3).toString();
|
||||
if (!until.isEmpty())
|
||||
{
|
||||
recurrence.until = QDate::fromString(until, Qt::ISODate);
|
||||
}
|
||||
return recurrence;
|
||||
}
|
||||
|
||||
QVector<ScheduleItem> SqliteStore::search(const QString& query, int limit) const
|
||||
{
|
||||
m_lastError.clear();
|
||||
QVector<ScheduleItem> items;
|
||||
if (!isOpenInternal())
|
||||
{
|
||||
setError(QStringLiteral("数据库未打开"));
|
||||
return items;
|
||||
}
|
||||
|
||||
QString escaped = query.trimmed();
|
||||
escaped.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
|
||||
escaped.replace(QLatin1Char('%'), QStringLiteral("\\%"));
|
||||
escaped.replace(QLatin1Char('_'), QStringLiteral("\\_"));
|
||||
const QString pattern = QStringLiteral("%%1%").arg(escaped);
|
||||
|
||||
const QString sql =
|
||||
QStringLiteral("SELECT ") + QLatin1String(kTaskColumns) + QStringLiteral(", ") +
|
||||
QLatin1String(kBlockColumns) +
|
||||
QStringLiteral(" FROM task t JOIN timeblock b ON b.task_id = t.id "
|
||||
"WHERE t.title LIKE :q ESCAPE '\\' "
|
||||
"OR IFNULL(t.description, '') LIKE :q ESCAPE '\\' "
|
||||
"OR IFNULL(t.source_ref, '') LIKE :q ESCAPE '\\' "
|
||||
"ORDER BY ABS(julianday(b.start_at) - julianday('now')) ASC, b.start_at ASC "
|
||||
"LIMIT :limit");
|
||||
QSqlQuery statement(m_database);
|
||||
statement.prepare(sql);
|
||||
statement.bindValue(QStringLiteral(":q"), pattern);
|
||||
statement.bindValue(QStringLiteral(":limit"), qBound(1, limit, 500));
|
||||
if (!statement.exec())
|
||||
{
|
||||
setError(QStringLiteral("搜索日程失败: %1").arg(statement.lastError().text()));
|
||||
return items;
|
||||
}
|
||||
while (statement.next())
|
||||
{
|
||||
ScheduleItem item;
|
||||
item.task = mapTask(statement, 0);
|
||||
item.block = mapTimeBlock(statement, 14);
|
||||
items.append(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
QVector<EnergyLevel> SqliteStore::energyLevels() const
|
||||
{
|
||||
m_lastError.clear();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "core/EnergyProfile.h"
|
||||
#include "core/ProposedDiff.h"
|
||||
#include "core/Recurrence.h"
|
||||
#include "core/SyncTypes.h"
|
||||
#include "core/ScheduleItem.h"
|
||||
|
||||
@@ -42,6 +43,8 @@ public:
|
||||
std::optional<Task> taskById(const QString& id);
|
||||
bool deleteTask(const QString& id);
|
||||
bool hasBlocksForTask(const QString& taskId);
|
||||
bool insertRecurrence(const Recurrence& recurrence);
|
||||
std::optional<Recurrence> recurrenceForTask(const QString& taskId) const;
|
||||
|
||||
bool insertTimeBlock(const TimeBlock& block);
|
||||
bool updateTimeBlock(const TimeBlock& block);
|
||||
@@ -56,6 +59,7 @@ public:
|
||||
QVector<ScheduleItem> blocksInRange(const QDateTime& fromUtc, const QDateTime& toUtc) const;
|
||||
// 已结束但仍未完成、且结束时间在最近 windowDays 内的块。
|
||||
QVector<ScheduleItem> overdueBefore(const QDateTime& nowUtc, int windowDays = 30) const;
|
||||
QVector<ScheduleItem> search(const QString& query, int limit = 100) const;
|
||||
|
||||
QVector<SyncOutboxItem> outboxBatch(int limit, QString* error = nullptr) const;
|
||||
int outboxCount(QString* error = nullptr) const;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QShortcut>
|
||||
#include <QShowEvent>
|
||||
#include <QSplitter>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
@@ -32,6 +33,7 @@
|
||||
#include "ui/dialogs/SettingsDialog.h"
|
||||
#include "ui/panels/ChatPanel.h"
|
||||
#include "ui/panels/TodayPanel.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
#include "ui/theme/ThemeManager.h"
|
||||
#include "ui/theme/WindowEffects.h"
|
||||
#include "utils/AppSettings.h"
|
||||
@@ -178,6 +180,14 @@ void CompactWindow::buildUi()
|
||||
connect(settingsShortcut, &QShortcut::activated, this, &CompactWindow::openSettings);
|
||||
auto* reviewShortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+R")), this);
|
||||
connect(reviewShortcut, &QShortcut::activated, this, &CompactWindow::openDailyReview);
|
||||
auto* searchShortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(searchShortcut, &QShortcut::activated, this, [this]() {
|
||||
openSchedule();
|
||||
if (m_scheduleWindow)
|
||||
{
|
||||
m_scheduleWindow->openSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CompactWindow::setupTray()
|
||||
@@ -468,6 +478,16 @@ void CompactWindow::showAndRaise()
|
||||
reloadToday();
|
||||
}
|
||||
|
||||
void CompactWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
ElaWindow::showEvent(event);
|
||||
if (!m_firstShowAnimated)
|
||||
{
|
||||
m_firstShowAnimated = true;
|
||||
QTimer::singleShot(0, this, [this]() { AnimationUtils::fadeWindow(this); });
|
||||
}
|
||||
}
|
||||
|
||||
void CompactWindow::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
ElaWindow::paintEvent(event);
|
||||
|
||||
@@ -23,6 +23,7 @@ class TodayPanel;
|
||||
class QCloseEvent;
|
||||
class QLabel;
|
||||
class QPaintEvent;
|
||||
class QShowEvent;
|
||||
class QSplitter;
|
||||
class QTimer;
|
||||
|
||||
@@ -50,6 +51,7 @@ public:
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
void buildUi();
|
||||
@@ -90,4 +92,5 @@ private:
|
||||
QTimer* m_refreshTimer = nullptr;
|
||||
|
||||
bool m_quitting = false;
|
||||
bool m_firstShowAnimated = false;
|
||||
};
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
#include "sync/SyncService.h"
|
||||
#include "ui/dialogs/BlockEditDialog.h"
|
||||
#include "ui/dialogs/DailyReviewDialog.h"
|
||||
#include "ui/dialogs/SearchDialog.h"
|
||||
#include "ui/dialogs/SettingsDialog.h"
|
||||
#include "ui/panels/TodayPanel.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
#include "ui/theme/ThemeManager.h"
|
||||
#include "ui/theme/WindowEffects.h"
|
||||
#include "ui/views/MonthView.h"
|
||||
@@ -145,10 +147,10 @@ void MainWindow::buildUi()
|
||||
m_newButton->setToolTip(QStringLiteral("新建日程 (Ctrl+N)"));
|
||||
|
||||
m_searchEdit = new ElaLineEdit(m_toolbar);
|
||||
m_searchEdit->setPlaceholderText(QStringLiteral("搜索(后续版本)"));
|
||||
m_searchEdit->setFixedSize(140, 30);
|
||||
m_searchEdit->setEnabled(false);
|
||||
m_searchEdit->setToolTip(QStringLiteral("搜索将在后续版本接入"));
|
||||
m_searchEdit->setPlaceholderText(QStringLiteral("搜索日程 (Ctrl+F)"));
|
||||
m_searchEdit->setFixedSize(160, 30);
|
||||
m_searchEdit->setClearButtonEnabled(true);
|
||||
m_searchEdit->setToolTip(QStringLiteral("搜索标题或说明,回车打开结果"));
|
||||
|
||||
m_snapCombo = new ElaComboBox(m_toolbar);
|
||||
m_snapCombo->addItems({QStringLiteral("吸附 15 分"),
|
||||
@@ -253,6 +255,7 @@ void MainWindow::buildUi()
|
||||
connect(m_newButton, &ElaPushButton::clicked, this, &MainWindow::openCreateDialogForNew);
|
||||
connect(m_themeButton, &ElaToolButton::clicked, this, [this]() { m_themeManager.cyclePreference(); });
|
||||
connect(m_settingsButton, &ElaToolButton::clicked, this, &MainWindow::openSettings);
|
||||
connect(m_searchEdit, &ElaLineEdit::returnPressed, this, &MainWindow::openSearch);
|
||||
if (m_syncService)
|
||||
{
|
||||
connect(m_syncService, &SyncService::statusChanged, this, &MainWindow::updateSyncStatus);
|
||||
@@ -314,6 +317,16 @@ void MainWindow::buildUi()
|
||||
auto* reviewShortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+R")), this);
|
||||
connect(reviewShortcut, &QShortcut::activated, this, &MainWindow::openDailyReview);
|
||||
|
||||
auto* searchShortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(searchShortcut, &QShortcut::activated, this, [this]() {
|
||||
if (m_searchEdit)
|
||||
{
|
||||
m_searchEdit->setFocus();
|
||||
m_searchEdit->selectAll();
|
||||
}
|
||||
openSearch();
|
||||
});
|
||||
|
||||
auto* compactShortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+W")), this);
|
||||
connect(compactShortcut, &QShortcut::activated, this, &MainWindow::close);
|
||||
}
|
||||
@@ -528,6 +541,7 @@ void MainWindow::setView(View view)
|
||||
{
|
||||
m_currentView = view;
|
||||
const int index = static_cast<int>(view);
|
||||
const int previousIndex = m_viewStack ? m_viewStack->currentIndex() : -1;
|
||||
if (m_viewStack)
|
||||
{
|
||||
m_viewStack->setCurrentIndex(index);
|
||||
@@ -543,6 +557,10 @@ void MainWindow::setView(View view)
|
||||
{
|
||||
m_grid->scrollToCurrentTime();
|
||||
}
|
||||
if (m_viewStack && previousIndex >= 0 && previousIndex != index)
|
||||
{
|
||||
AnimationUtils::fadeIn(m_viewStack, 160);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::View MainWindow::view() const
|
||||
@@ -778,7 +796,17 @@ void MainWindow::openCreateDialog(const QDateTime& start, const QDateTime& end)
|
||||
}
|
||||
|
||||
QString error;
|
||||
if (!m_scheduleService.createBlock(dialog.titleValue(), dialog.startValue(), dialog.endValue(), &error))
|
||||
const RecurrenceFrequency frequency = dialog.recurrenceFrequency();
|
||||
const bool created = frequency == RecurrenceFrequency::None
|
||||
? m_scheduleService.createBlock(dialog.titleValue(), dialog.startValue(), dialog.endValue(), &error)
|
||||
: m_scheduleService.createRecurringBlock(dialog.titleValue(),
|
||||
dialog.startValue(),
|
||||
dialog.endValue(),
|
||||
frequency,
|
||||
dialog.recurrenceUntil(),
|
||||
nullptr,
|
||||
&error);
|
||||
if (!created)
|
||||
{
|
||||
showError(QStringLiteral("创建日程失败"), error);
|
||||
return;
|
||||
@@ -850,6 +878,26 @@ void MainWindow::openDailyReview()
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::openSearch()
|
||||
{
|
||||
SearchDialog dialog(m_scheduleService,
|
||||
m_tokens,
|
||||
m_searchEdit ? m_searchEdit->text() : QString(),
|
||||
this);
|
||||
connect(&dialog, &SearchDialog::blockSelected, this, [this](const QDate& date, const QString& blockId) {
|
||||
if (m_searchEdit)
|
||||
{
|
||||
m_searchEdit->setText(QString());
|
||||
}
|
||||
m_currentDate = date;
|
||||
setView(View::Day);
|
||||
m_grid->scrollToBlock(blockId);
|
||||
m_grid->setFocus(Qt::OtherFocusReason);
|
||||
});
|
||||
dialog.moveToCenter();
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::updateSyncStatus(const QString& status)
|
||||
{
|
||||
if (!m_syncLabel)
|
||||
@@ -971,6 +1019,7 @@ void MainWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
m_firstShowHandled = true;
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
AnimationUtils::fadeWindow(this);
|
||||
if (m_grid && m_currentView == View::Day)
|
||||
{
|
||||
m_grid->scrollToCurrentTime();
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
|
||||
void showAndRaise();
|
||||
void openNewBlock();
|
||||
void openSearch();
|
||||
void focusBlock(const QDate& date, const QString& blockId);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
#include "BlockEditDialog.h"
|
||||
|
||||
#include <QDateEdit>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSignalBlocker>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ElaComboBox.h"
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaPushButton.h"
|
||||
#include "ElaText.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
|
||||
BlockEditDialog::BlockEditDialog(const ThemeTokens& tokens, QWidget* parent)
|
||||
: ElaDialog(parent)
|
||||
@@ -17,7 +21,7 @@ BlockEditDialog::BlockEditDialog(const ThemeTokens& tokens, QWidget* parent)
|
||||
setWindowTitle(QStringLiteral("新建日程"));
|
||||
setWindowButtonFlags(ElaAppBarType::CloseButtonHint);
|
||||
setMinimumWidth(440);
|
||||
resize(440, 320);
|
||||
resize(440, 430);
|
||||
|
||||
auto* root = new QVBoxLayout(this);
|
||||
root->setContentsMargins(22, 8, 22, 18);
|
||||
@@ -47,9 +51,26 @@ BlockEditDialog::BlockEditDialog(const ThemeTokens& tokens, QWidget* parent)
|
||||
m_endEdit->setDisplayFormat(QStringLiteral("yyyy-MM-dd HH:mm"));
|
||||
m_endEdit->setMinimumHeight(34);
|
||||
|
||||
m_repeatLabel = new ElaText(QStringLiteral("重复"), 13, this);
|
||||
m_repeatCombo = new ElaComboBox(this);
|
||||
m_repeatCombo->addItems({QStringLiteral("不重复"),
|
||||
QStringLiteral("每天"),
|
||||
QStringLiteral("每周"),
|
||||
QStringLiteral("每月")});
|
||||
m_repeatCombo->setMinimumHeight(34);
|
||||
|
||||
m_repeatUntilLabel = new ElaText(QStringLiteral("重复结束"), 13, this);
|
||||
m_repeatUntilEdit = new QDateEdit(this);
|
||||
m_repeatUntilEdit->setCalendarPopup(true);
|
||||
m_repeatUntilEdit->setDisplayFormat(QStringLiteral("yyyy-MM-dd"));
|
||||
m_repeatUntilEdit->setDate(QDate::currentDate().addMonths(3));
|
||||
m_repeatUntilEdit->setMinimumHeight(34);
|
||||
|
||||
form->addRow(titleLabel, m_titleEdit);
|
||||
form->addRow(startLabel, m_startEdit);
|
||||
form->addRow(endLabel, m_endEdit);
|
||||
form->addRow(m_repeatLabel, m_repeatCombo);
|
||||
form->addRow(m_repeatUntilLabel, m_repeatUntilEdit);
|
||||
root->addLayout(form);
|
||||
|
||||
m_errorLabel = new ElaText(this);
|
||||
@@ -79,12 +100,42 @@ BlockEditDialog::BlockEditDialog(const ThemeTokens& tokens, QWidget* parent)
|
||||
const QSignalBlocker blocker(m_endEdit);
|
||||
m_endEdit->setDateTime(start.addSecs(60 * 60));
|
||||
}
|
||||
if (m_repeatUntilEdit && start.isValid() && m_repeatUntilEdit->date() < start.date())
|
||||
{
|
||||
m_repeatUntilEdit->setDate(start.date().addMonths(3));
|
||||
}
|
||||
});
|
||||
connect(m_repeatCombo, &ElaComboBox::currentIndexChanged, this, [this](int index) {
|
||||
if (m_repeatUntilEdit)
|
||||
{
|
||||
m_repeatUntilEdit->setEnabled(index > 0);
|
||||
}
|
||||
});
|
||||
m_repeatUntilEdit->setEnabled(false);
|
||||
QTimer::singleShot(0, this, [this]() { AnimationUtils::fadeWindow(this); });
|
||||
}
|
||||
|
||||
void BlockEditDialog::setCreateMode(bool create)
|
||||
{
|
||||
m_createMode = create;
|
||||
setWindowTitle(create ? QStringLiteral("新建日程") : QStringLiteral("编辑日程"));
|
||||
resize(width(), create ? 430 : 320);
|
||||
if (m_repeatLabel)
|
||||
{
|
||||
m_repeatLabel->setVisible(create);
|
||||
}
|
||||
if (m_repeatCombo)
|
||||
{
|
||||
m_repeatCombo->setVisible(create);
|
||||
}
|
||||
if (m_repeatUntilLabel)
|
||||
{
|
||||
m_repeatUntilLabel->setVisible(create);
|
||||
}
|
||||
if (m_repeatUntilEdit)
|
||||
{
|
||||
m_repeatUntilEdit->setVisible(create);
|
||||
}
|
||||
}
|
||||
|
||||
void BlockEditDialog::setValues(const QString& title, const QDateTime& start, const QDateTime& end)
|
||||
@@ -94,6 +145,10 @@ void BlockEditDialog::setValues(const QString& title, const QDateTime& start, co
|
||||
m_titleEdit->setText(title);
|
||||
m_startEdit->setDateTime(start);
|
||||
m_endEdit->setDateTime(end);
|
||||
if (m_repeatUntilEdit && start.isValid())
|
||||
{
|
||||
m_repeatUntilEdit->setDate(start.date().addMonths(3));
|
||||
}
|
||||
m_titleEdit->setFocus();
|
||||
m_titleEdit->selectAll();
|
||||
}
|
||||
@@ -113,6 +168,34 @@ QDateTime BlockEditDialog::endValue() const
|
||||
return m_endEdit->dateTime();
|
||||
}
|
||||
|
||||
RecurrenceFrequency BlockEditDialog::recurrenceFrequency() const
|
||||
{
|
||||
if (!m_createMode || !m_repeatCombo)
|
||||
{
|
||||
return RecurrenceFrequency::None;
|
||||
}
|
||||
switch (m_repeatCombo->currentIndex())
|
||||
{
|
||||
case 1:
|
||||
return RecurrenceFrequency::Daily;
|
||||
case 2:
|
||||
return RecurrenceFrequency::Weekly;
|
||||
case 3:
|
||||
return RecurrenceFrequency::Monthly;
|
||||
default:
|
||||
return RecurrenceFrequency::None;
|
||||
}
|
||||
}
|
||||
|
||||
QDate BlockEditDialog::recurrenceUntil() const
|
||||
{
|
||||
if (recurrenceFrequency() == RecurrenceFrequency::None || !m_repeatUntilEdit)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return m_repeatUntilEdit->date();
|
||||
}
|
||||
|
||||
void BlockEditDialog::updateError(const QString& message)
|
||||
{
|
||||
m_errorLabel->setText(message);
|
||||
@@ -130,6 +213,12 @@ void BlockEditDialog::accept()
|
||||
updateError(QStringLiteral("日程时长至少为 5 分钟"));
|
||||
return;
|
||||
}
|
||||
if (recurrenceFrequency() != RecurrenceFrequency::None &&
|
||||
recurrenceUntil() < startValue().date())
|
||||
{
|
||||
updateError(QStringLiteral("重复结束日期不能早于开始日期"));
|
||||
return;
|
||||
}
|
||||
updateError(QString());
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
#include <QString>
|
||||
|
||||
#include "ElaDialog.h"
|
||||
#include "core/Recurrence.h"
|
||||
#include "ui/theme/ThemeTokens.h"
|
||||
|
||||
class ElaComboBox;
|
||||
class ElaLineEdit;
|
||||
class ElaText;
|
||||
class QDateEdit;
|
||||
class QDateTimeEdit;
|
||||
|
||||
/*
|
||||
@@ -28,6 +31,8 @@ public:
|
||||
QString titleValue() const;
|
||||
QDateTime startValue() const;
|
||||
QDateTime endValue() const;
|
||||
RecurrenceFrequency recurrenceFrequency() const;
|
||||
QDate recurrenceUntil() const;
|
||||
|
||||
public slots:
|
||||
void accept() override;
|
||||
@@ -38,6 +43,11 @@ private:
|
||||
ElaLineEdit* m_titleEdit = nullptr;
|
||||
QDateTimeEdit* m_startEdit = nullptr;
|
||||
QDateTimeEdit* m_endEdit = nullptr;
|
||||
ElaText* m_repeatLabel = nullptr;
|
||||
ElaComboBox* m_repeatCombo = nullptr;
|
||||
ElaText* m_repeatUntilLabel = nullptr;
|
||||
QDateEdit* m_repeatUntilEdit = nullptr;
|
||||
ElaText* m_errorLabel = nullptr;
|
||||
QString m_errorColor;
|
||||
bool m_createMode = true;
|
||||
};
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
#include <algorithm>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ElaPushButton.h"
|
||||
#include "ElaText.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -133,6 +135,7 @@ DailyReviewDialog::DailyReviewDialog(const DailyReview& review,
|
||||
buttonRow->addWidget(closeButton);
|
||||
root->addLayout(buttonRow);
|
||||
connect(closeButton, &ElaPushButton::clicked, this, &DailyReviewDialog::accept);
|
||||
QTimer::singleShot(0, this, [this]() { AnimationUtils::fadeWindow(this); });
|
||||
}
|
||||
|
||||
QString DailyReviewDialog::weekdayLabel(const QDate& date) const
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "SearchDialog.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaText.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
#include "core/DateTimeUtils.h"
|
||||
#include "services/ScheduleService.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
QString statusLabel(const QString& status)
|
||||
{
|
||||
if (status == QStringLiteral("done"))
|
||||
{
|
||||
return QStringLiteral("已完成");
|
||||
}
|
||||
if (status == QStringLiteral("in_progress"))
|
||||
{
|
||||
return QStringLiteral("进行中");
|
||||
}
|
||||
if (status == QStringLiteral("dropped"))
|
||||
{
|
||||
return QStringLiteral("已放弃");
|
||||
}
|
||||
if (status == QStringLiteral("missed"))
|
||||
{
|
||||
return QStringLiteral("已错过");
|
||||
}
|
||||
return QStringLiteral("待办");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SearchDialog::SearchDialog(ScheduleService& scheduleService,
|
||||
const ThemeTokens& tokens,
|
||||
const QString& initialQuery,
|
||||
QWidget* parent)
|
||||
: ElaDialog(parent)
|
||||
, m_scheduleService(scheduleService)
|
||||
, m_tokens(tokens)
|
||||
{
|
||||
setWindowTitle(QStringLiteral("搜索日程"));
|
||||
setWindowButtonFlags(ElaAppBarType::CloseButtonHint);
|
||||
resize(620, 520);
|
||||
setMinimumWidth(520);
|
||||
|
||||
auto* root = new QVBoxLayout(this);
|
||||
root->setContentsMargins(22, 8, 22, 18);
|
||||
root->setSpacing(10);
|
||||
|
||||
auto* searchRow = new QHBoxLayout();
|
||||
searchRow->setSpacing(10);
|
||||
m_searchEdit = new ElaLineEdit(this);
|
||||
m_searchEdit->setPlaceholderText(QStringLiteral("输入标题或说明,回车打开第一条结果"));
|
||||
m_searchEdit->setClearButtonEnabled(true);
|
||||
m_searchEdit->setMinimumHeight(36);
|
||||
m_searchEdit->setText(initialQuery);
|
||||
m_countLabel = new ElaText(this);
|
||||
m_countLabel->setTextPixelSize(11);
|
||||
m_countLabel->setTextStyle(ElaTextType::Caption);
|
||||
searchRow->addWidget(m_searchEdit, 1);
|
||||
searchRow->addWidget(m_countLabel, 0, Qt::AlignVCenter);
|
||||
root->addLayout(searchRow);
|
||||
|
||||
m_results = new QListWidget(this);
|
||||
m_results->setFrameShape(QFrame::NoFrame);
|
||||
m_results->setAlternatingRowColors(false);
|
||||
m_results->setUniformItemSizes(false);
|
||||
m_results->setWordWrap(true);
|
||||
m_results->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_results->setStyleSheet(
|
||||
QStringLiteral("QListWidget{background:transparent;border:none;outline:none;}"
|
||||
"QListWidget::item{padding:9px 10px;border-radius:8px;color:%1;}"
|
||||
"QListWidget::item:selected{background:%2;color:%3;}")
|
||||
.arg(tokens.textPrimary.name(), tokens.accent.name(), tokens.onAccent.name()));
|
||||
root->addWidget(m_results, 1);
|
||||
|
||||
m_searchTimer = new QTimer(this);
|
||||
m_searchTimer->setSingleShot(true);
|
||||
m_searchTimer->setInterval(140);
|
||||
connect(m_searchTimer, &QTimer::timeout, this, &SearchDialog::executeSearch);
|
||||
connect(m_searchEdit, &ElaLineEdit::textChanged, this, &SearchDialog::scheduleSearch);
|
||||
connect(m_searchEdit, &ElaLineEdit::returnPressed, this, &SearchDialog::selectCurrent);
|
||||
connect(m_results, &QListWidget::itemActivated, this, [this](QListWidgetItem* item) {
|
||||
if (!item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Q_EMIT blockSelected(item->data(Qt::UserRole + 1).toDate(),
|
||||
item->data(Qt::UserRole).toString());
|
||||
accept();
|
||||
});
|
||||
connect(m_results, &QListWidget::itemDoubleClicked, this, [this](QListWidgetItem* item) {
|
||||
if (!item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Q_EMIT blockSelected(item->data(Qt::UserRole + 1).toDate(),
|
||||
item->data(Qt::UserRole).toString());
|
||||
accept();
|
||||
});
|
||||
|
||||
m_searchEdit->setFocus();
|
||||
m_searchEdit->selectAll();
|
||||
executeSearch();
|
||||
QTimer::singleShot(0, this, [this]() { AnimationUtils::fadeWindow(this); });
|
||||
}
|
||||
|
||||
void SearchDialog::scheduleSearch()
|
||||
{
|
||||
m_searchTimer->start();
|
||||
}
|
||||
|
||||
void SearchDialog::executeSearch()
|
||||
{
|
||||
if (!m_results)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QVector<ScheduleItem> items = m_scheduleService.search(m_searchEdit->text(), 100);
|
||||
m_results->clear();
|
||||
for (const ScheduleItem& item : items)
|
||||
{
|
||||
const QString text = QStringLiteral("%1 · %2 %3 · %4")
|
||||
.arg(item.task.title,
|
||||
item.block.startAt.date().toString(QStringLiteral("MM-dd")),
|
||||
DateTimeUtils::formatTimeRange(item.block.startAt, item.block.endAt),
|
||||
statusLabel(item.block.status));
|
||||
auto* row = new QListWidgetItem(text, m_results);
|
||||
row->setData(Qt::UserRole, item.block.id);
|
||||
row->setData(Qt::UserRole + 1, item.block.startAt.date());
|
||||
row->setSizeHint(QSize(0, 40));
|
||||
}
|
||||
m_countLabel->setText(items.isEmpty() ? QStringLiteral("无结果")
|
||||
: QStringLiteral("%1 条结果").arg(items.size()));
|
||||
if (!items.isEmpty())
|
||||
{
|
||||
m_results->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchDialog::selectCurrent()
|
||||
{
|
||||
QListWidgetItem* item = m_results->currentItem();
|
||||
if (!item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Q_EMIT blockSelected(item->data(Qt::UserRole + 1).toDate(),
|
||||
item->data(Qt::UserRole).toString());
|
||||
accept();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDate>
|
||||
#include <QString>
|
||||
|
||||
#include "ElaDialog.h"
|
||||
#include "ui/theme/ThemeTokens.h"
|
||||
|
||||
class ElaLineEdit;
|
||||
class ElaText;
|
||||
class QListWidget;
|
||||
class QTimer;
|
||||
class ScheduleService;
|
||||
|
||||
/*
|
||||
* 类名: SearchDialog
|
||||
* 功能: 按标题/说明搜索日程,选择结果后跳转到对应日期
|
||||
* 线程安全: 否;UI 线程
|
||||
*/
|
||||
class SearchDialog : public ElaDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SearchDialog(ScheduleService& scheduleService,
|
||||
const ThemeTokens& tokens,
|
||||
const QString& initialQuery = {},
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void blockSelected(const QDate& date, const QString& blockId);
|
||||
|
||||
private:
|
||||
void scheduleSearch();
|
||||
void executeSearch();
|
||||
void selectCurrent();
|
||||
|
||||
ScheduleService& m_scheduleService;
|
||||
ThemeTokens m_tokens;
|
||||
ElaLineEdit* m_searchEdit = nullptr;
|
||||
ElaText* m_countLabel = nullptr;
|
||||
QListWidget* m_results = nullptr;
|
||||
QTimer* m_searchTimer = nullptr;
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ElaComboBox.h"
|
||||
#include "ElaLineEdit.h"
|
||||
@@ -12,6 +13,7 @@
|
||||
#include "ElaText.h"
|
||||
#include "ElaToggleSwitch.h"
|
||||
#include "ElaToolButton.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
#include "ui/theme/ThemeManager.h"
|
||||
#include "ui/theme/WindowEffects.h"
|
||||
#include "utils/AppSettings.h"
|
||||
@@ -247,6 +249,7 @@ SettingsDialog::SettingsDialog(ThemeManager& themeManager, AppSettings& settings
|
||||
saveAiConfig();
|
||||
saveSyncConfig();
|
||||
});
|
||||
QTimer::singleShot(0, this, [this]() { AnimationUtils::fadeWindow(this); });
|
||||
}
|
||||
|
||||
void SettingsDialog::saveAiConfig()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ElaScrollArea.h"
|
||||
#include "ElaText.h"
|
||||
#include "ui/panels/DiffPreviewCard.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
|
||||
ChatPanel::ChatPanel(AIService& aiService, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -178,6 +179,7 @@ void ChatPanel::rebuildMessages()
|
||||
m_aiService.rejectDiff(diffId);
|
||||
});
|
||||
m_messageLayout->addWidget(card);
|
||||
AnimationUtils::fadeIn(card, 180);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ElaText.h"
|
||||
#include "ElaToolButton.h"
|
||||
#include "TodayItemCard.h"
|
||||
#include "ui/theme/AnimationUtils.h"
|
||||
|
||||
TodayPanel::TodayPanel(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -206,6 +207,11 @@ void TodayPanel::rebuild()
|
||||
empty->setTextStyle(ElaTextType::Caption);
|
||||
m_listLayout->addWidget(empty);
|
||||
m_listLayout->addStretch(1);
|
||||
if (m_renderedCount != 0)
|
||||
{
|
||||
m_renderedCount = 0;
|
||||
AnimationUtils::fadeIn(m_listWidget, 150);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,4 +226,9 @@ void TodayPanel::rebuild()
|
||||
m_listLayout->addWidget(card);
|
||||
}
|
||||
m_listLayout->addStretch(1);
|
||||
if (m_renderedCount != sorted.size())
|
||||
{
|
||||
m_renderedCount = sorted.size();
|
||||
AnimationUtils::fadeIn(m_listWidget, 150);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,5 @@ private:
|
||||
ElaScrollArea* m_scrollArea = nullptr;
|
||||
QWidget* m_listWidget = nullptr;
|
||||
QVBoxLayout* m_listLayout = nullptr;
|
||||
int m_renderedCount = -1;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "AnimationUtils.h"
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QWidget>
|
||||
|
||||
namespace AnimationUtils
|
||||
{
|
||||
void fadeIn(QWidget* widget, int durationMs)
|
||||
{
|
||||
if (!widget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
widget->setGraphicsEffect(nullptr);
|
||||
auto* effect = new QGraphicsOpacityEffect(widget);
|
||||
effect->setOpacity(0.0);
|
||||
widget->setGraphicsEffect(effect);
|
||||
auto* animation = new QPropertyAnimation(effect, "opacity", widget);
|
||||
animation->setDuration(durationMs);
|
||||
animation->setStartValue(0.0);
|
||||
animation->setEndValue(1.0);
|
||||
animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
QObject::connect(animation, &QPropertyAnimation::finished, widget, [widget, animation]() {
|
||||
widget->setGraphicsEffect(nullptr);
|
||||
animation->deleteLater();
|
||||
});
|
||||
animation->start();
|
||||
}
|
||||
|
||||
void fadeWindow(QWidget* window, int durationMs)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto* animation = new QPropertyAnimation(window, "windowOpacity", window);
|
||||
animation->setDuration(durationMs);
|
||||
animation->setStartValue(0.0);
|
||||
animation->setEndValue(1.0);
|
||||
animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
QObject::connect(animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater);
|
||||
window->setWindowOpacity(0.0);
|
||||
animation->start();
|
||||
}
|
||||
} // namespace AnimationUtils
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace AnimationUtils
|
||||
{
|
||||
void fadeIn(QWidget* widget, int durationMs = 180);
|
||||
void fadeWindow(QWidget* window, int durationMs = 220);
|
||||
} // namespace AnimationUtils
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QListWidget>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
#include <QtTest>
|
||||
@@ -7,6 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ElaApplication.h"
|
||||
#include "ElaComboBox.h"
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaPushButton.h"
|
||||
#include "ElaToolButton.h"
|
||||
@@ -16,7 +18,9 @@
|
||||
#include "storage/SqliteStore.h"
|
||||
#include "ui/CompactWindow.h"
|
||||
#include "ui/MainWindow.h"
|
||||
#include "ui/dialogs/BlockEditDialog.h"
|
||||
#include "ui/dialogs/DailyReviewDialog.h"
|
||||
#include "ui/dialogs/SearchDialog.h"
|
||||
#include "ui/dialogs/SettingsDialog.h"
|
||||
#include "ui/panels/DiffPreviewCard.h"
|
||||
#include "ui/theme/ThemeManager.h"
|
||||
@@ -62,6 +66,8 @@ private slots:
|
||||
void initTestCase();
|
||||
void compactOpensScheduleAndReturns();
|
||||
void opensDailyReview();
|
||||
void searchDialogFindsSchedules();
|
||||
void repeatDialogShowsOptions();
|
||||
void aiChatShowsDiffAndAccepts();
|
||||
void aiChatShowsMultiOperationDiff();
|
||||
|
||||
@@ -328,6 +334,51 @@ void TestCompactWindow::opensDailyReview()
|
||||
QTest::mouseClick(reviewButton, Qt::LeftButton);
|
||||
}
|
||||
|
||||
void TestCompactWindow::searchDialogFindsSchedules()
|
||||
{
|
||||
QTemporaryDir databaseDir;
|
||||
QVERIFY(databaseDir.isValid());
|
||||
SqliteStore store(databaseDir.filePath(QStringLiteral("schedule.db")));
|
||||
QString error;
|
||||
QVERIFY2(store.open(&error), qPrintable(error));
|
||||
|
||||
ThemeManager theme(*m_settings);
|
||||
theme.initialize();
|
||||
ScheduleService service(store, QStringLiteral("search-test"));
|
||||
createSampleData(service, QDate::currentDate());
|
||||
|
||||
SearchDialog dialog(service, theme.tokens(), QStringLiteral("周报"));
|
||||
dialog.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
|
||||
QTest::qWait(300);
|
||||
|
||||
auto* results = dialog.findChild<QListWidget*>();
|
||||
QVERIFY(results);
|
||||
QVERIFY(results->count() > 0);
|
||||
saveWindow(&dialog, QStringLiteral("search.png"));
|
||||
dialog.close();
|
||||
}
|
||||
|
||||
void TestCompactWindow::repeatDialogShowsOptions()
|
||||
{
|
||||
ThemeManager theme(*m_settings);
|
||||
theme.initialize();
|
||||
BlockEditDialog dialog(theme.tokens());
|
||||
dialog.setCreateMode(true);
|
||||
const QDateTime start(QDate::currentDate(), QTime(9, 0), Qt::LocalTime);
|
||||
dialog.setValues(QStringLiteral("每日复盘"), start, start.addSecs(60 * 60));
|
||||
auto* combo = dialog.findChild<ElaComboBox*>();
|
||||
QVERIFY(combo);
|
||||
combo->setCurrentIndex(1);
|
||||
dialog.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
|
||||
QTest::qWait(300);
|
||||
saveWindow(&dialog, QStringLiteral("block-edit-repeat.png"));
|
||||
dialog.accept();
|
||||
QCOMPARE(dialog.recurrenceFrequency(), RecurrenceFrequency::Daily);
|
||||
QCOMPARE(dialog.recurrenceUntil(), start.date().addMonths(3));
|
||||
}
|
||||
|
||||
void TestCompactWindow::aiChatShowsDiffAndAccepts()
|
||||
{
|
||||
QTemporaryDir databaseDir;
|
||||
|
||||
@@ -26,6 +26,8 @@ private slots:
|
||||
void invalidRangeRejected();
|
||||
void applyProposedCreatesOnlySelected();
|
||||
void energyProfileLearnsFromHistory();
|
||||
void searchFindsSchedules();
|
||||
void createsRecurringSchedules();
|
||||
};
|
||||
|
||||
namespace
|
||||
@@ -362,5 +364,80 @@ void TestServices::energyProfileLearnsFromHistory()
|
||||
QCOMPARE(context.service->energyLevelFor(QDateTime(date, QTime(13, 0), Qt::LocalTime)), 0);
|
||||
}
|
||||
|
||||
void TestServices::searchFindsSchedules()
|
||||
{
|
||||
Context context;
|
||||
QVERIFY(context.open());
|
||||
|
||||
const QDate day = QDate::currentDate();
|
||||
QString error;
|
||||
QVERIFY(context.service->createBlock(QStringLiteral("写周报"),
|
||||
QDateTime(day, QTime(9, 0), Qt::LocalTime),
|
||||
QDateTime(day, QTime(10, 0), Qt::LocalTime),
|
||||
&error));
|
||||
QVERIFY(context.service->createBlock(QStringLiteral("团队会议"),
|
||||
QDateTime(day, QTime(11, 0), Qt::LocalTime),
|
||||
QDateTime(day, QTime(12, 0), Qt::LocalTime),
|
||||
&error));
|
||||
|
||||
const QVector<ScheduleItem> weekly = context.service->search(QStringLiteral("周报"));
|
||||
QCOMPARE(weekly.size(), 1);
|
||||
QCOMPARE(weekly.first().task.title, QStringLiteral("写周报"));
|
||||
|
||||
const QVector<ScheduleItem> all = context.service->search(QString());
|
||||
QCOMPARE(all.size(), 2);
|
||||
QStringList titles;
|
||||
for (const ScheduleItem& item : all)
|
||||
{
|
||||
titles.append(item.task.title);
|
||||
}
|
||||
QVERIFY(titles.contains(QStringLiteral("写周报")));
|
||||
QVERIFY(titles.contains(QStringLiteral("团队会议")));
|
||||
QCOMPARE(context.service->search(QStringLiteral("%")).size(), 0);
|
||||
}
|
||||
|
||||
void TestServices::createsRecurringSchedules()
|
||||
{
|
||||
Context context;
|
||||
QVERIFY(context.open());
|
||||
|
||||
const QDate first = QDate::currentDate().addDays(10);
|
||||
const QDateTime start(first, QTime(9, 0), Qt::LocalTime);
|
||||
const QDateTime end(first, QTime(10, 0), Qt::LocalTime);
|
||||
int count = 0;
|
||||
QString error;
|
||||
QVERIFY2(context.service->createRecurringBlock(QStringLiteral("每日复盘"),
|
||||
start,
|
||||
end,
|
||||
RecurrenceFrequency::Daily,
|
||||
first.addDays(4),
|
||||
&count,
|
||||
&error),
|
||||
qPrintable(error));
|
||||
QCOMPARE(count, 5);
|
||||
for (int offset = 0; offset < 5; ++offset)
|
||||
{
|
||||
const QVector<ScheduleItem> items = context.service->itemsForDay(first.addDays(offset));
|
||||
QCOMPARE(items.size(), 1);
|
||||
QCOMPARE(items.first().task.title, QStringLiteral("每日复盘"));
|
||||
QCOMPARE(items.first().block.startAt.time(), QTime(9, 0));
|
||||
}
|
||||
|
||||
const QString taskId = context.service->itemsForDay(first).first().task.id;
|
||||
const auto recurrence = context.store->recurrenceForTask(taskId);
|
||||
QVERIFY(recurrence.has_value());
|
||||
QCOMPARE(recurrence->rule, QStringLiteral("FREQ=DAILY"));
|
||||
QCOMPARE(recurrence->until.value(), first.addDays(4));
|
||||
|
||||
QVERIFY(!context.service->createRecurringBlock(QStringLiteral("错误"),
|
||||
start,
|
||||
end,
|
||||
RecurrenceFrequency::Weekly,
|
||||
first.addDays(-1),
|
||||
&count,
|
||||
&error));
|
||||
QVERIFY(!error.isEmpty());
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(TestServices)
|
||||
#include "test_services.moc"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
> 阶段 2.1(更新 / 删除 / 涟漪 / 拆分)已验证:[`validation/phase-2-1.md`](validation/phase-2-1.md)。
|
||||
> 阶段 3(Go 同步服务端 / 多设备)已验证:[`validation/phase-3.md`](validation/phase-3.md)。
|
||||
> 阶段 4(精力曲线 / 幽灵时间 / 每日复盘 / 主动建议)已验证:[`validation/phase-4.md`](validation/phase-4.md)。
|
||||
> 阶段 4.1(搜索 / 重复日程 / Windows 安装包 / 动画)已验证:[`validation/phase-4-1.md`](validation/phase-4-1.md)。
|
||||
|
||||
## 0. 当前环境
|
||||
|
||||
@@ -133,6 +134,14 @@ Schedule/
|
||||
- [x] 本地模型:Ollama / LM Studio / vLLM 等 OpenAI 兼容端点说明
|
||||
- 验收:`ctest --preset linux-gcc` 12/12;详见 [`validation/phase-4.md`](validation/phase-4.md)
|
||||
|
||||
### 阶段 4.1:桌面体验补强(已完成)
|
||||
- [x] 标题/说明搜索:SQLite LIKE、最近时间排序、搜索对话框、`Ctrl+F`
|
||||
- [x] 每天/每周/每月重复日程:物化时间块、冲突跳过、最多 1 年 / 200 次
|
||||
- [x] 重复规则存入本地 `recurrence` 表;物化日程照常同步
|
||||
- [x] Windows 安装包:CPack NSIS + `package-windows.ps1`,安装阶段自动 `windeployqt`
|
||||
- [x] 轻量动画:窗口/对话框淡入、视图切换淡入、任务列表与 Diff 卡片淡入
|
||||
- 验收:`ctest --preset linux-gcc` 12/12;见 [`validation/phase-4-1.md`](validation/phase-4-1.md)
|
||||
|
||||
### 阶段 5:移动端(后续)
|
||||
- Android 优先,复用同步协议与逻辑层
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,29 @@
|
||||
Test project /home/misaki/MisakiCodes/Schedule/build/linux-gcc
|
||||
Start 1: go_server_tests
|
||||
1/12 Test #1: go_server_tests .................. Passed 0.09 sec
|
||||
Start 2: storage
|
||||
2/12 Test #2: storage .......................... Passed 0.02 sec
|
||||
Start 3: services
|
||||
3/12 Test #3: services ......................... Passed 0.05 sec
|
||||
Start 4: grid
|
||||
4/12 Test #4: grid ............................. Passed 0.39 sec
|
||||
Start 5: mainwindow
|
||||
5/12 Test #5: mainwindow ....................... Passed 1.25 sec
|
||||
Start 6: compactwindow
|
||||
6/12 Test #6: compactwindow .................... Passed 4.29 sec
|
||||
Start 7: config
|
||||
7/12 Test #7: config ........................... Passed 0.01 sec
|
||||
Start 8: scheduler
|
||||
8/12 Test #8: scheduler ........................ Passed 0.01 sec
|
||||
Start 9: energy
|
||||
9/12 Test #9: energy ........................... Passed 0.00 sec
|
||||
Start 10: ai
|
||||
10/12 Test #10: ai ............................... Passed 0.11 sec
|
||||
Start 11: openai_provider
|
||||
11/12 Test #11: openai_provider .................. Passed 0.21 sec
|
||||
Start 12: sync_integration
|
||||
12/12 Test #12: sync_integration ................. Passed 7.72 sec
|
||||
|
||||
100% tests passed, 0 tests failed out of 12
|
||||
|
||||
Total Test time (real) = 14.15 sec
|
||||
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 44 KiB |
@@ -0,0 +1,111 @@
|
||||
# 阶段 4.1 验证报告:搜索 / 重复日程 / Windows 安装包 / 动画
|
||||
|
||||
> 日期:2026-10-26
|
||||
> 环境:Ubuntu 24.04 / GCC 13.3 / Qt 6.6.3(Windows 安装包需在 Windows + MinGW 下验证)
|
||||
|
||||
## 1. 本次交付
|
||||
|
||||
### 1.1 搜索
|
||||
|
||||
- SQLite `LIKE` 查询任务标题、说明和来源引用,按离当前时间最近排序,最多 100 条。
|
||||
- 新增 `SearchDialog`:输入即搜索,回车选择第一条,双击/回车跳转到对应日期并定位日程块。
|
||||
- 详细日程工具栏搜索框启用;`Ctrl+F` 在紧凑/详细窗口均可打开。
|
||||
- 搜索框内容通过 `ESCAPE` 处理,`%`、`_`、`\` 按字面量搜索。
|
||||
|
||||
### 1.2 重复日程
|
||||
|
||||
- 新建日程增加「重复:不重复 / 每天 / 每周 / 每月」和「重复结束」。
|
||||
- 重复日程物化为共享同一任务的时间块,最多 1 年 / 200 次。
|
||||
- 与既有日程冲突的重复日期自动跳过;全部冲突时拒绝创建并提示。
|
||||
- `recurrence` 表保存本地规则元数据;物化后的任务/时间块沿用阶段 3 同步链路。
|
||||
- 编辑重复块标题会修改共享任务标题(影响该系列);删除单个块只删除该次。
|
||||
|
||||
### 1.3 Windows 安装包
|
||||
|
||||
- 根 CMake 增加 CPack NSIS 配置:开始菜单项、桌面快捷方式、卸载信息。
|
||||
- 安装阶段自动执行 `windeployqt`,安装 Qt DLL、平台插件和 MinGW 运行时。
|
||||
- 新增 `windows-mingw-release` configure/build/test preset。
|
||||
- 新增 `scripts/package-windows.ps1`:
|
||||
- 配置并构建 Release;
|
||||
- 运行测试;
|
||||
- 优先 CPack NSIS 生成 `.exe` 安装包;
|
||||
- 未安装 NSIS 时退化为 ZIP 便携包。
|
||||
|
||||
### 1.4 动画
|
||||
|
||||
- `AnimationUtils::fadeWindow`:紧凑窗口、详细窗口、设置、日程编辑、复盘、搜索对话框淡入。
|
||||
- `AnimationUtils::fadeIn`:日/月/年视图切换、任务列表刷新、Diff 卡片出现时淡入。
|
||||
- 全部使用 150–220ms `OutCubic`,不阻塞 UI;没有引入新第三方依赖。
|
||||
|
||||
## 2. 构建与自动化测试
|
||||
|
||||
```bash
|
||||
cmake --preset linux-gcc
|
||||
cmake --build --preset linux-gcc --clean-first -j$(nproc)
|
||||
ctest --preset linux-gcc
|
||||
```
|
||||
|
||||
| 项目 | 结果 |
|
||||
|---|---|
|
||||
| 客户端全量构建 | 成功,项目代码 0 警告(`-Werror`) |
|
||||
| `ctest --preset linux-gcc` | **12/12 通过**,总耗时约 14s |
|
||||
|
||||
完整输出见 [`ctest-phase-4-1.txt`](ctest-phase-4-1.txt)。
|
||||
|
||||
新增/扩展测试:
|
||||
|
||||
| 用例 | 覆盖 |
|
||||
|---|---|
|
||||
| `test_services::searchFindsSchedules` | 标题/空查询/通配符转义 |
|
||||
| `test_services::createsRecurringSchedules` | 每天 5 次物化、规则持久化、非法结束日期 |
|
||||
| `test_compactwindow::searchDialogFindsSchedules` | 搜索对话框结果与截图 |
|
||||
| `test_compactwindow::repeatDialogShowsOptions` | 重复选项、对话框关闭后读取频率/结束日期 |
|
||||
| 原有 12 组测试 | 存储、调度、精力、AI、同步、UI 全部通过 |
|
||||
|
||||
## 3. 界面截图
|
||||
|
||||
| 截图 | 说明 |
|
||||
|---|---|
|
||||
| [`search-dark.png`](search-dark.png) / [`search-light.png`](search-light.png) | 搜索对话框与结果 |
|
||||
| [`block-edit-dialog.png`](block-edit-dialog.png) | 新建日程:重复 + 重复结束 |
|
||||
| [`block-edit-repeat-light.png`](block-edit-repeat-light.png) | 浅色重复设置 |
|
||||
| [`compact-dark.png`](compact-dark.png) | 紧凑窗口(含动画/建议) |
|
||||
| [`schedule-ghost.png`](schedule-ghost.png) | 详细日程(启用搜索框、幽灵时间、动画) |
|
||||
|
||||
## 4. 同步冲突行为
|
||||
|
||||
这是阶段 3 已有策略,本阶段补充明确的 UI/文档说明:
|
||||
|
||||
- 同一任务/时间块在不同设备同时编辑:按 `updated_at` 做 LWW,较新版本获胜;等时间戳删除优先。
|
||||
- 不同日程被安排在同一时间:属于不同实体,两个都会保留,日视图按重叠列展示;不会自动移动或删除。
|
||||
- 服务端只追加有序变更流,不做语义合并;客户端无弹窗、后台重试,状态只在顶部标签显示。
|
||||
- 重复日程的物化块正常同步;重复规则元数据仅本地保存。
|
||||
- 如果产品需要“同一时间只保留一个”,需要额外实现客户端自动涟漪/冲突策略;当前优先保证不静默丢数据。
|
||||
|
||||
## 5. Windows 安装包验证状态
|
||||
|
||||
- Linux 侧已验证 `cmake --install` 能安装 `Schedule`、README 和两份第三方许可证。
|
||||
- Windows CPack/NSIS 安装包无法在本机执行;需要在 Windows 上按 README 的 MinGW 步骤验证:
|
||||
```powershell
|
||||
.\scripts\package-windows.ps1
|
||||
```
|
||||
- 前置条件:NSIS 的 `makensis.exe` 在 `PATH`;Qt/MinGW 路径已按本机修改到 `CMakePresets.json`。
|
||||
- 若未安装 NSIS,脚本会生成 ZIP 便携包,但不会生成 `.exe` 安装程序。
|
||||
|
||||
## 6. 已知限制
|
||||
|
||||
1. 搜索只覆盖标题、说明、来源引用,不是全文/模糊搜索引擎;最多返回 100 条。
|
||||
2. 重复日程只支持单规则(每天/每周/每月),没有“仅工作日”、跳过节假日、例外日期或“删除整个系列”UI。
|
||||
3. 重复规则元数据不参与同步;其他设备只看到已物化的任务/时间块。
|
||||
4. 重复日期与现有日程冲突时跳过,不自动涟漪;一周/一月内可能因冲突少生成几次。
|
||||
5. Windows 安装包尚未在真实 Windows 上验证;签名、自动更新、安装目录权限仍属于发布工程。
|
||||
6. 动画没有“减少动态效果”偏好;对无障碍要求高的环境需要后续增加开关。
|
||||
7. 多设备同时创建不同日程造成的时间重叠会保留双方;当前没有自动冲突合并。
|
||||
|
||||
## 7. 人工验收建议
|
||||
|
||||
1. 在详细日程搜索“周报”,确认结果、跳转和定位正确;输入 `%` 确认按字面量处理。
|
||||
2. 新建一个每天重复 5 天的日程,确认只生成 5 个块且共享标题;删除其中一个块,确认只删除该次。
|
||||
3. 在已有日程的时段创建重复日程,确认冲突日期被跳过,全部冲突时提示失败。
|
||||
4. 搜索/打开/关闭窗口,观察淡入动画是否流畅;切换日/月/年视图确认淡入。
|
||||
5. 在 Windows 上安装 NSIS,运行 `.\scripts\package-windows.ps1`,安装 `.exe` 后确认快捷方式、Qt 插件与 MinGW 运行库齐全。
|
||||
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 139 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,47 @@
|
||||
param(
|
||||
[switch]$SkipTests,
|
||||
[int]$Jobs = 8
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
Push-Location $root
|
||||
try {
|
||||
Write-Host "Configuring release build..."
|
||||
cmake --preset windows-mingw-release
|
||||
|
||||
Write-Host "Building..."
|
||||
cmake --build --preset windows-mingw-release -j $Jobs
|
||||
|
||||
if (-not $SkipTests) {
|
||||
Write-Host "Running tests..."
|
||||
ctest --preset windows-mingw-release --output-on-failure
|
||||
}
|
||||
|
||||
$buildDir = Join-Path $root "build/windows-mingw-release"
|
||||
Push-Location $buildDir
|
||||
try {
|
||||
$nsis = Get-Command makensis -ErrorAction SilentlyContinue
|
||||
if ($null -ne $nsis) {
|
||||
Write-Host "Building NSIS installer..."
|
||||
cpack -G NSIS
|
||||
Get-ChildItem -Filter "Schedule-*.exe" | ForEach-Object {
|
||||
Write-Host "Installer: $($_.FullName)"
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Warning "makensis not found; falling back to a portable ZIP package."
|
||||
Write-Warning "Install NSIS and reopen PowerShell to build the .exe installer."
|
||||
cpack -G ZIP
|
||||
Get-ChildItem -Filter "Schedule-*.zip" | ForEach-Object {
|
||||
Write-Host "Portable package: $($_.FullName)"
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||