From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/dictionary/IDictionary.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/dictionary/IDictionary.cpp (limited to 'src/dictionary/IDictionary.cpp') diff --git a/src/dictionary/IDictionary.cpp b/src/dictionary/IDictionary.cpp new file mode 100644 index 0000000..20bac26 --- /dev/null +++ b/src/dictionary/IDictionary.cpp @@ -0,0 +1,59 @@ +#include "IDictionary.h" +#include "DicRecord.h" +#include "CardPack.h" + +IDictionary::~IDictionary() +{ + foreach(DicRecord* record, records) + delete record; +} + +void IDictionary::addRecord(DicRecord* record) +{ + records << record; + notifyRecordsInserted(records.size() - 1, 1); +} + +void IDictionary::addRecords(const QList& records) +{ + this->records << records; + notifyRecordsInserted(records.size() - records.size(), records.size()); +} + +QString IDictionary::extendImagePaths(QString text) const +{ + text = replaceImagePaths(text, "%", QFileInfo(filePath).path()); + text = replaceImagePaths(text, "%%", getImagesPath()); + return text; +} + +QString IDictionary::getImagesPath() const +{ + QString path = QFileInfo(filePath).path(); + QString baseName = QFileInfo(filePath).completeBaseName(); + return QDir(path).filePath(baseName); +} + +QString IDictionary::replaceImagePaths(QString text, const QString& shortDir, + const QString& replacingPath) +{ + QRegExp imgRx(QString("(getTodayReviewedCardsNum(); + return num; + } + +int IDictionary::countTodaysNewCards() const + { + int num = 0; + foreach(CardPack* pack, m_cardPacks) + num += pack->getTodayNewCardsNum(); + return num; + } -- cgit