create Datastore for countedNotes over 10000 puposhis, debug for notes in send
This commit is contained in:
@@ -7,6 +7,11 @@ SietchDataStore* DataStore::getSietchDataStore()
|
||||
return SietchDataStore::getInstance();
|
||||
}
|
||||
|
||||
NoteCountDataStore* DataStore::getNoteCountDataStore()
|
||||
{
|
||||
return NoteCountDataStore::getInstance();
|
||||
}
|
||||
|
||||
ChatDataStore* DataStore::getChatDataStore()
|
||||
{
|
||||
return ChatDataStore::getInstance();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define DATASTORE_H
|
||||
|
||||
#include "SietchDataStore.h"
|
||||
#include "NoteCountDataStore.h"
|
||||
#include "ChatDataStore.h"
|
||||
#include "ContactDataStore.h"
|
||||
|
||||
@@ -11,6 +12,7 @@ class DataStore
|
||||
{
|
||||
public:
|
||||
static SietchDataStore* getSietchDataStore();
|
||||
static NoteCountDataStore* getNoteCountDataStore();
|
||||
static ChatDataStore* getChatDataStore();
|
||||
static ContactDataStore* getContactDataStore();
|
||||
};
|
||||
|
||||
51
src/DataStore/NoteCountDataStore.cpp
Normal file
51
src/DataStore/NoteCountDataStore.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "NoteCountDataStore.h"
|
||||
|
||||
NoteCountDataStore* NoteCountDataStore::instance = nullptr;
|
||||
bool NoteCountDataStore::instanced = false;
|
||||
|
||||
NoteCountDataStore* NoteCountDataStore::getInstance() {
|
||||
if (!instanced) {
|
||||
instanced = true;
|
||||
instance = new NoteCountDataStore();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void NoteCountDataStore::clear() {
|
||||
data.clear();
|
||||
}
|
||||
|
||||
void NoteCountDataStore::setData(const QString& key, const QString& value) {
|
||||
data[key] = value;
|
||||
}
|
||||
|
||||
QString NoteCountDataStore::getData(const QString& key) {
|
||||
return data.value(key);
|
||||
}
|
||||
|
||||
QString NoteCountDataStore::dump() {
|
||||
QString result;
|
||||
for (const auto& key : data.keys()) {
|
||||
result += key + ": " + data[key] + "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void NoteCountDataStore::setSpendableNotesCount(int count) {
|
||||
spendableNotesCount = count;
|
||||
}
|
||||
|
||||
int NoteCountDataStore::getSpendableNotesCount() const {
|
||||
return spendableNotesCount;
|
||||
}
|
||||
|
||||
void NoteCountDataStore::setAddressWithMaxValue(const QString& address, int value) {
|
||||
if (value > maxValue) {
|
||||
maxValue = value;
|
||||
addressWithMaxValue = address;
|
||||
}
|
||||
}
|
||||
|
||||
QString NoteCountDataStore::getAddressWithMaxValue() const {
|
||||
return addressWithMaxValue;
|
||||
}
|
||||
36
src/DataStore/NoteCountDataStore.h
Normal file
36
src/DataStore/NoteCountDataStore.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef NOTECOUNTDATASTORE_H
|
||||
#define NOTECOUNTDATASTORE_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
class NoteCountDataStore {
|
||||
private:
|
||||
static NoteCountDataStore* instance;
|
||||
static bool instanced;
|
||||
QMap<QString, QString> data;
|
||||
int spendableNotesCount;
|
||||
QString addressWithMaxValue;
|
||||
int maxValue; // Hinzugefügt, um den maximalen Wert zu speichern
|
||||
|
||||
NoteCountDataStore() : spendableNotesCount(0), maxValue(0) {} // Initialisiere maxValue
|
||||
|
||||
public:
|
||||
static NoteCountDataStore* getInstance();
|
||||
void clear();
|
||||
void setData(const QString& key, const QString& value);
|
||||
QString getData(const QString& key);
|
||||
QString dump();
|
||||
|
||||
void setSpendableNotesCount(int count);
|
||||
int getSpendableNotesCount() const;
|
||||
void setAddressWithMaxValue(const QString& address, int value);
|
||||
QString getAddressWithMaxValue() const;
|
||||
|
||||
~NoteCountDataStore() {
|
||||
instanced = false;
|
||||
instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // NOTECOUNTDATASTORE_H
|
||||
Reference in New Issue
Block a user