From b78e171537fe8cc227521bb6b12bfb923a248f08 Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 16 Sep 2021 10:56:37 +0200 Subject: replace txt export support with specific txyz export --- afdnotebook.cc | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'afdnotebook.cc') diff --git a/afdnotebook.cc b/afdnotebook.cc index 58ae359..8b90619 100644 --- a/afdnotebook.cc +++ b/afdnotebook.cc @@ -170,7 +170,7 @@ QList AfdNotebook::pagesWithStrokes(const QString &penSerial) const { if (_penData.contains(penSerial)) { const PenData &data = _penData[penSerial]; - return data.strokes.uniqueKeys(); + return data.strokes.keys(); } else { return QList(); } @@ -182,36 +182,16 @@ QStringList AfdNotebook::strokeFiles(const QString &penSerial, int page) const if (!_penData.contains(penSerial)) return l; const PenData &data = _penData[penSerial]; - QMultiMap::const_iterator it = data.strokes.find(page); - while (it != data.strokes.end() && it.key() == page) { - const StrokeData &stroke = it.value(); - l.append(_dir.filePath(stroke.file)); - ++it; - } - - return l; -} - -bool AfdNotebook::readStrokes(const QString &penSerial, int page, StfReader::StrokeHandler *handler) -{ - if (!_penData.contains(penSerial)) return true; - - StfReader stf; - stf.setStrokeHandler(handler); - - const PenData &data = _penData[penSerial]; - QMultiMap::const_iterator it = data.strokes.find(page); - while (it != data.strokes.end() && it.key() == page) { - const StrokeData &stroke = it.value(); - qDebug() << "Reading strokes from" << stroke.file; - if (!stf.parse(_dir.filePath(stroke.file))) { - qWarning() << "Could not parse stroke file" << stroke.file; - return false; + auto it = data.strokes.find(page); + if (it != data.strokes.end()) { + const QList& strokes = it.value(); + l.reserve(strokes.size()); + foreach (const StrokeData &stroke, strokes) { + l.append(_dir.filePath(stroke.file)); } - ++it; } - return true; + return l; } QMap AfdNotebook::parsePropertyList(QIODevice *dev) @@ -355,6 +335,8 @@ bool AfdNotebook::findPenData() QDir penDir(pageDir.filePath(penName)); if (!penDir.exists()) continue; + PenData& penData = _penData[penName]; + QStringList strokeFiles = penDir.entryList(QStringList("*.stf"), QDir::Files); foreach (const QString &strokeFile, strokeFiles) { qDebug() << " stroke data" << strokeFile; @@ -378,7 +360,19 @@ bool AfdNotebook::findPenData() qDebug() << " from" << stroke.begin << "to" << stroke.end; - _penData[penName].strokes.insert(pageNum, stroke); + penData.strokes[pageNum].append(stroke); + } + + // Sort all the stroke files in each page by starting time + auto it = penData.strokes.begin(); + while (it != penData.strokes.end()) { + QList &strokes = *it; + if (!strokes.isEmpty()) { + std::sort(strokes.begin(), strokes.end(), StrokeData::CompareByBeginTime); + ++it; + } else { + it = penData.strokes.erase(it); + } } } } -- cgit v1.2.3