Some refactor
This commit is contained in:
37 files changed
+1599
-981
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#include "BookPositionStore.h"
|
||||
|
||||
BookPositionStore::BookPositionStore(AppState &state)
|
||||
: m_state(state)
|
||||
{
|
||||
}
|
||||
|
||||
BookPosition BookPositionStore::load(const QByteArray &contentMd5)
|
||||
{
|
||||
if (contentMd5.isEmpty())
|
||||
return {};
|
||||
const QVariantMap d = m_state.loadSection(sectionKey(contentMd5));
|
||||
BookPosition pos;
|
||||
pos.chunkIndex = d.value(QStringLiteral("chunkIndex"), 0).toInt();
|
||||
pos.intraOffset = d.value(QStringLiteral("intraOffset"), 0).toInt();
|
||||
return pos;
|
||||
}
|
||||
|
||||
void BookPositionStore::save(const QByteArray &contentMd5, int chunkIndex, int intraOffset)
|
||||
{
|
||||
if (contentMd5.isEmpty())
|
||||
return;
|
||||
m_state.saveSection(sectionKey(contentMd5), {
|
||||
{QStringLiteral("chunkIndex"), chunkIndex},
|
||||
{QStringLiteral("intraOffset"), intraOffset},
|
||||
});
|
||||
}
|
||||
|
||||
QString BookPositionStore::sectionKey(const QByteArray &contentMd5)
|
||||
{
|
||||
return QStringLiteral("saved-progress/") + QString::fromLatin1(contentMd5.toHex());
|
||||
}
|
||||
Reference in new issue
Block a user