Skip to content

Commit 737b4ae

Browse files
committed
fix build
1 parent 64d378f commit 737b4ae

8 files changed

Lines changed: 170 additions & 112 deletions

File tree

docs/refactoring-roadmap-v2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787

8888
### Q.7 工程路径解析修复
8989

90-
- [ ] 排查 `DsProject::load()``workingDirectory` 读取后是否需要从 posix 路径转回本地路径(当前 `fromStd()` 直接返回 posix 格式字符串)
91-
- [ ] `main.cpp` `loadProject` lambda:确认 `workDir` 是正确的工程文件夹路径,而非原始音频文件夹
92-
- [ ] `DsSlicerPage::onExportAudio()``ProjectPaths::dsItemsDir(m_dataSource->workingDir())` 确认指向工程文件夹下的 `dstemp/dsitems/`
93-
- [ ] `ProjectPaths` 所有路径方法应基于工程文件夹的 `workingDir`,而非原始音频所在目录
90+
- [x] 排查 `DsProject::load()``workingDirectory` 读取后是否需要从 posix 路径转回本地路径(当前 `fromStd()` 直接返回 posix 格式字符串)
91+
- [x] `main.cpp` `loadProject` lambda:确认 `workDir` 是正确的工程文件夹路径,而非原始音频文件夹
92+
- [x] `DsSlicerPage::onExportAudio()``ProjectPaths::dsItemsDir(m_dataSource->workingDir())` 确认指向工程文件夹下的 `dstemp/dsitems/`
93+
- [x] `ProjectPaths` 所有路径方法应基于工程文件夹的 `workingDir`,而非原始音频所在目录
9494
- [ ] 验证:新建工程 → 选择工程文件夹 → 切片导出后,`.dsproj``dstemp/` 均在工程文件夹内
9595

9696
---

src/apps/ds-labeler/DsSlicerPage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ namespace dstools {
647647
if (!slicerState.audioFiles.isEmpty() && m_audioFileList->fileCount() == 0) {
648648
QStringList resolvedPaths;
649649
for (const auto &relPath : slicerState.audioFiles) {
650-
QString nativePath = DsProject::fromPosixPath(relPath);
650+
QString nativePath = relPath;
651651
if (QDir::isRelativePath(nativePath))
652652
nativePath = QDir(project->workingDirectory()).absoluteFilePath(nativePath);
653653
if (QFile::exists(nativePath))
@@ -659,7 +659,7 @@ namespace dstools {
659659

660660
// Restore slice points
661661
for (const auto &[relPath, points] : slicerState.slicePoints) {
662-
QString nativePath = DsProject::fromPosixPath(relPath);
662+
QString nativePath = relPath;
663663
if (QDir::isRelativePath(nativePath))
664664
nativePath = QDir(project->workingDirectory()).absoluteFilePath(nativePath);
665665
if (!points.empty())
@@ -668,7 +668,7 @@ namespace dstools {
668668

669669
// Load first audio file if available
670670
if (!slicerState.audioFiles.isEmpty()) {
671-
QString firstPath = DsProject::fromPosixPath(slicerState.audioFiles.first());
671+
QString firstPath = slicerState.audioFiles.first();
672672
if (QDir::isRelativePath(firstPath))
673673
firstPath = QDir(project->workingDirectory()).absoluteFilePath(firstPath);
674674
if (QFile::exists(firstPath)) {
@@ -689,7 +689,7 @@ namespace dstools {
689689

690690
const auto &firstItem = items[0];
691691
if (!firstItem.audioSource.isEmpty()) {
692-
QString audioPath = DsProject::fromPosixPath(firstItem.audioSource);
692+
QString audioPath = firstItem.audioSource;
693693
if (QDir::isRelativePath(audioPath))
694694
audioPath = QDir(project->workingDirectory()).absoluteFilePath(audioPath);
695695
if (QFile::exists(audioPath)) {

src/apps/ds-labeler/ProjectDataSource.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,18 @@ QString ProjectDataSource::dstextPath(const QString &sliceId) const {
143143
}
144144

145145
QString ProjectDataSource::sliceAudioPath(const QString &sliceId) const {
146-
// Look up the actual audio path from the project item first
147146
if (m_project) {
148147
for (const auto &item : m_project->items()) {
149148
for (const auto &slice : item.slices) {
150149
if (slice.id == sliceId) {
151-
// Use the item's audioSource (set during slice export)
152-
QString audioPath = DsProject::fromPosixPath(item.audioSource);
150+
QString audioPath = item.audioSource;
153151
if (QDir::isRelativePath(audioPath))
154152
audioPath = QDir(m_workingDir).absoluteFilePath(audioPath);
155153
return audioPath;
156154
}
157155
}
158156
}
159157
}
160-
// Fallback: conventional path
161158
return ProjectPaths::sliceAudioPath(m_workingDir, sliceId);
162159
}
163160

src/apps/shared/audio-visualizer/TierLabelArea.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <ui/IBoundaryModel.h>
44

5+
#include <dstools/TimePos.h>
6+
57
namespace dstools {
68

79
TierLabelArea::TierLabelArea(QWidget *parent)
@@ -20,6 +22,28 @@ IBoundaryModel *TierLabelArea::boundaryModel() const {
2022
return m_boundaryModel;
2123
}
2224

25+
void TierLabelArea::setViewportController(ViewportController *viewport) {
26+
if (m_viewport) {
27+
disconnect(m_viewport, nullptr, this, nullptr);
28+
}
29+
m_viewport = viewport;
30+
if (m_viewport) {
31+
m_viewStart = m_viewport->state().startSec;
32+
m_viewEnd = m_viewport->state().endSec;
33+
connect(m_viewport, &ViewportController::viewportChanged, this,
34+
[this](const ViewportState &state) {
35+
m_viewStart = state.startSec;
36+
m_viewEnd = state.endSec;
37+
update();
38+
});
39+
}
40+
update();
41+
}
42+
43+
ViewportController *TierLabelArea::viewportController() const {
44+
return m_viewport;
45+
}
46+
2347
int TierLabelArea::activeTierIndex() const {
2448
return m_activeTierIndex;
2549
}
@@ -32,4 +56,28 @@ void TierLabelArea::setActiveTierIndex(int index) {
3256
}
3357
}
3458

59+
QList<double> TierLabelArea::activeBoundaries() const {
60+
QList<double> boundaries;
61+
if (!m_boundaryModel)
62+
return boundaries;
63+
64+
int tier = activeTierIndex();
65+
if (tier < 0 || tier >= m_boundaryModel->tierCount())
66+
return boundaries;
67+
68+
int count = m_boundaryModel->boundaryCount(tier);
69+
boundaries.reserve(count);
70+
for (int i = 0; i < count; ++i)
71+
boundaries.append(usToSec(m_boundaryModel->boundaryTime(tier, i)));
72+
73+
return boundaries;
74+
}
75+
76+
int TierLabelArea::timeToX(double time) const {
77+
double viewDuration = m_viewEnd - m_viewStart;
78+
if (viewDuration <= 0.0 || width() <= 0)
79+
return 0;
80+
return static_cast<int>((time - m_viewStart) / viewDuration * width());
81+
}
82+
3583
} // namespace dstools
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#pragma once
22

3-
/// @file TierLabelArea.h
4-
/// @brief Base class for tier label areas displayed above the chart splitter.
5-
3+
#include <QList>
64
#include <QWidget>
75

6+
#include <dstools/ViewportController.h>
7+
88
namespace dstools {
99

1010
namespace phonemelabeler {
1111
class IBoundaryModel;
1212
}
1313
using phonemelabeler::IBoundaryModel;
1414

15+
using dstools::widgets::ViewportController;
16+
using dstools::widgets::ViewportState;
17+
1518
class TierLabelArea : public QWidget {
1619
Q_OBJECT
1720

@@ -22,15 +25,26 @@ class TierLabelArea : public QWidget {
2225
void setBoundaryModel(IBoundaryModel *model);
2326
IBoundaryModel *boundaryModel() const;
2427

28+
void setViewportController(ViewportController *viewport);
29+
ViewportController *viewportController() const;
30+
2531
virtual int activeTierIndex() const;
2632
virtual void setActiveTierIndex(int index);
2733

34+
virtual QList<double> activeBoundaries() const;
35+
2836
signals:
2937
void activeTierChanged(int index);
3038

3139
protected:
3240
IBoundaryModel *m_boundaryModel = nullptr;
41+
ViewportController *m_viewport = nullptr;
3342
int m_activeTierIndex = 0;
43+
44+
double m_viewStart = 0.0;
45+
double m_viewEnd = 10.0;
46+
47+
[[nodiscard]] int timeToX(double time) const;
3448
};
3549

3650
} // namespace dstools

src/domain/include/dstools/DsProject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct SlicerConfig {
5454
/// @brief Slicer runtime state stored in .dsproj slicer section.
5555
struct SlicerState {
5656
SlicerConfig params; ///< Slicer parameters.
57-
QStringList audioFiles; ///< Audio file paths (POSIX).
57+
QStringList audioFiles; ///< Audio file paths (native format).
5858
std::map<QString, std::vector<double>> slicePoints; ///< filePath → boundary times (seconds).
5959
};
6060

@@ -87,7 +87,7 @@ struct Item {
8787
QString name;
8888
QString speaker;
8989
QString language;
90-
QString audioSource; ///< Relative path to audio file (POSIX).
90+
QString audioSource; ///< Path to audio file (native format, relative or absolute).
9191
std::vector<Slice> slices;
9292
nlohmann::json extra; ///< Preserve unknown fields.
9393
};

0 commit comments

Comments
 (0)