Revision 6262bb8b
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/Example.pro | ||
---|---|---|
CONFIG += c++14
|
||
QMAKE_CXXFLAGS += -std=c++14
|
||
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop-Release/release/ -lCuteEntityManager
|
||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop-Debug/debug/ -lCuteEntityManager
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Release/release/ -lCuteEntityManager
|
||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug/debug/ -lCuteEntityManager
|
||
|
||
win32:INCLUDEPATH += $$PWD/../../build-EntityManager-Desktop-Debug/debug
|
||
win32:DEPENDPATH += $$PWD/../../build-EntityManager-Desktop-Debug/debug
|
||
win32:INCLUDEPATH += $$PWD/../../../build-EntityManager-Desktop-Debug/debug
|
||
win32:DEPENDPATH += $$PWD/../../../build-EntityManager-Desktop-Debug/debug
|
||
|
||
INCLUDEPATH += $$PWD/../../src
|
||
DEPENDPATH += $$PWD/../../src
|
samples/example/main.cpp | ||
---|---|---|
* Instead of startup(version,qstringlist) you can call method createTable of EntityManager (e->create(sharedptr))
|
||
* startup will create tables inclusive relation tables for classes in QStringList inits
|
||
*/
|
||
qWarning() << "Tables created:" << e->startup("0.1", inits);
|
||
qWarning() << "Tables created or already set up:" << e->startup("0.1", inits);
|
||
QSharedPointer<CuteEntityManager::Entity> p =
|
||
QSharedPointer<CuteEntityManager::Entity>(new Person("Max", "Mustermann",
|
||
Person::Gender::MALE, "", "", "",
|
src/sqlitebackupprocessor.cpp | ||
---|---|---|
this->destination = destination;
|
||
}
|
||
|
||
SqliteBackupProcessor::SqliteBackupProcessor(QSharedPointer<Database> database,
|
||
QString destination, QString backupFilename, QTimer timer,
|
||
bool incrementalBackups, int backupCount) {
|
||
this->database = database;
|
||
this->destination = destination;
|
||
this->timer = timer;
|
||
this->backupFilename = backupFilename;
|
||
this->incrementalBackups = incrementalBackups;
|
||
this->backupCount = backupCount;
|
||
connect(timer, &QTimer::timeout, this,
|
||
&SqliteBackupProcessor::backup);
|
||
}
|
||
|
||
SqliteBackupProcessor::~SqliteBackupProcessor() {
|
||
}
|
||
|
||
... | ... | |
}
|
||
return state;
|
||
}
|
||
|
||
void SqliteBackupProcessor::backup() {
|
||
QString fileName = this->destination + "/" + this->getBackupFilename();
|
||
if (incrementalBackups) {
|
||
fileName += QString::number(counter);
|
||
++counter;
|
||
}
|
||
this->sqliteDBMemFile(true, fileName);
|
||
}
|
||
|
||
bool SqliteBackupProcessor::getIncrementalBackups() const {
|
||
return incrementalBackups;
|
||
}
|
||
|
||
void SqliteBackupProcessor::setIncrementalBackups(bool value) {
|
||
incrementalBackups = value;
|
||
}
|
||
|
||
int SqliteBackupProcessor::getBackupCount() const {
|
||
return backupCount;
|
||
}
|
||
|
||
void SqliteBackupProcessor::setBackupCount(int value) {
|
||
backupCount = value;
|
||
}
|
||
|
||
|
||
QTimer SqliteBackupProcessor::getTimer() const {
|
||
return timer;
|
||
}
|
||
|
||
void SqliteBackupProcessor::setTimer(const QTimer &value) {
|
||
timer = value;
|
||
}
|
||
|
||
QString SqliteBackupProcessor::getBackupFilename() const {
|
||
return backupFilename;
|
||
}
|
||
|
||
void SqliteBackupProcessor::setBackupFilename(const QString &value) {
|
||
backupFilename = value;
|
||
}
|
||
|
src/sqlitebackupprocessor.h | ||
---|---|---|
#include <QtSql/QSqlDriver>
|
||
#include <QString>
|
||
#include <QVariant>
|
||
#include <QTimer>
|
||
#include "database.h"
|
||
namespace CuteEntityManager {
|
||
class SqliteBackupProcessor : public QObject {
|
||
public:
|
||
explicit SqliteBackupProcessor(QSharedPointer<Database> database, QString destination);
|
||
explicit SqliteBackupProcessor(QSharedPointer<Database> database,
|
||
QString destination);
|
||
explicit SqliteBackupProcessor(QSharedPointer<Database> database,
|
||
QString destination, QString backupFilename, QTimer timer,
|
||
bool incrementalBackups = false, int backupCount = 1);
|
||
~SqliteBackupProcessor();
|
||
QSharedPointer<Database> getDatabase() const;
|
||
void setDatabase(const QSharedPointer<Database> &value);
|
||
... | ... | |
QString getDestination() const;
|
||
void setDestination(const QString &value);
|
||
|
||
public slots:
|
||
bool sqliteDBMemFile(bool save,QString fileName= "db.sqlite.bak");
|
||
private:
|
||
QString getBackupFilename() const;
|
||
void setBackupFilename(const QString &value);
|
||
|
||
QTimer getTimer() const;
|
||
void setTimer(const QTimer &value);
|
||
|
||
int getBackupCount() const;
|
||
void setBackupCount(int value);
|
||
|
||
bool getIncrementalBackups() const;
|
||
void setIncrementalBackups(bool value);
|
||
|
||
public slots:
|
||
bool sqliteDBMemFile(bool save, QString fileName = "db.sqlite.bak");
|
||
void backup();
|
||
private:
|
||
QSharedPointer<Database> database;
|
||
QString destination;
|
||
QString backupFilename;
|
||
QTimer timer;
|
||
bool incrementalBackups;
|
||
int backupCount;
|
||
int counter = 0;
|
||
};
|
||
}
|
||
|
Auch abrufbar als: Unified diff
pro file update