- refresh sqlcipher + switch to Qt6

This commit is contained in:
Dmytro Bogovych 2023-12-21 09:37:40 +03:00
parent 0b297c038b
commit ef99a9d035
11 changed files with 163055 additions and 48350 deletions

View File

@ -7,26 +7,27 @@ enum
{ {
ClientInitId = 62000, ClientInitId = 62000,
ClientCloseId = 62001, ClientCloseId = 62001,
AttachDatabaseId, AttachDatabaseId = 62002,
SelectTaskId, SelectTaskId = 62003,
UiInitId UiInitId = 62004
}; };
template <int N>
class ClientEvent: public QEvent class ClientEvent: public QEvent
{ {
private: private:
int mType = N; int mType;
public: public:
ClientEvent<N>() ClientEvent(int numtype)
:QEvent(static_cast<QEvent::Type>(N)) :QEvent(static_cast<QEvent::Type>(numtype)), mType(numtype)
{} {}
}; };
class SelectTaskEvent: public ClientEvent<SelectTaskId> class SelectTaskEvent: public ClientEvent
{ {
public: public:
SelectTaskEvent(PTask task) { SelectTaskEvent(PTask task)
:ClientEvent(SelectTaskId)
{
mTask = task; mTask = task;
} }

View File

@ -187,5 +187,5 @@ void IV::Generate(QByteArray &buffer)
{ {
uint8_t* data = (uint8_t*)buffer.data(); uint8_t* data = (uint8_t*)buffer.data();
for (int i=0; i<buffer.length(); i++) for (int i=0; i<buffer.length(); i++)
data[i] = qrand() % 256; data[i] = rand() % 256;
} }

View File

@ -143,7 +143,7 @@ void TaskSearch::run()
if (mRequest.startsWith("\"") && mRequest.endsWith("\"")) if (mRequest.startsWith("\"") && mRequest.endsWith("\""))
sl.append(mRequest); sl.append(mRequest);
else else
sl = mRequest.split(" ", QString::SkipEmptyParts); sl = mRequest.split(" ", Qt::SkipEmptyParts);
if (!sl.empty()) if (!sl.empty())
{ {

View File

@ -9,6 +9,8 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QTextStream> #include <QTextStream>
#include <QApplication> #include <QApplication>
#include <QFile>
#include <QStandardPaths>
#include <sstream> #include <sstream>
@ -209,7 +211,7 @@ time_t chrono::strToTime(const std::string& s)
QString path::pathToSettings() QString path::pathToSettings()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
QString folder = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString folder = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
#else #else
QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif #endif
@ -220,7 +222,7 @@ QString path::pathToSettings()
QString path::pathToDatabase() QString path::pathToDatabase()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
QString folder = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString folder = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
#else #else
QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif #endif
@ -256,7 +258,7 @@ QString path::pathToDatabaseTemplate()
QString path::pathToLog() QString path::pathToLog()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
QString folder = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString folder = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
#else #else
QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QString folder = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif #endif

View File

@ -37,7 +37,6 @@
# include "platforms/linux/autostart.h" # include "platforms/linux/autostart.h"
#endif #endif
#include <QDesktopWidget>
#include <QDebug> #include <QDebug>
#include <iostream> #include <iostream>
@ -58,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) :
setUpdatesEnabled(true); setUpdatesEnabled(true);
// Other initialization will run in next event loop iteration // Other initialization will run in next event loop iteration
QApplication::postEvent(this, new ClientEvent<UiInitId>()); QApplication::postEvent(this, new ClientEvent(UiInitId));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -121,7 +120,7 @@ void MainWindow::connectUiToDatabase()
// Load recent tasks // Load recent tasks
QString recent = SETTINGS.data()[KEY_RECENT_TASKS].toString(); QString recent = SETTINGS.data()[KEY_RECENT_TASKS].toString();
QStringList recentList = recent.split(";", QString::SkipEmptyParts); QStringList recentList = recent.split(";", Qt::SkipEmptyParts);
for (QString& s: recentList) for (QString& s: recentList)
{ {
Task::Id id = s.toULongLong(); Task::Id id = s.toULongLong();
@ -779,7 +778,7 @@ void MainWindow::setupMainUi()
FvUpdater::sharedUpdater()->SetFeedURL("http://satorilight.com/LittAppCast.xml"); FvUpdater::sharedUpdater()->SetFeedURL("http://satorilight.com/LittAppCast.xml");
#endif #endif
initClient(); initClient();
QApplication::postEvent(this, new ClientEvent<AttachDatabaseId>()); QApplication::postEvent(this, new ClientEvent(AttachDatabaseId));
} }
void MainWindow::buildPasswordView() void MainWindow::buildPasswordView()
@ -1016,7 +1015,7 @@ void MainWindow::updateData()
if (saveToDb) if (saveToDb)
mLogger->log("Flushing timeline to DB start"); mLogger->log("Flushing timeline to DB start");
mCurrentTask->timeline()->flush(saveToDb, QDateTime::currentDateTimeUtc().toTime_t()); mCurrentTask->timeline()->flush(saveToDb, QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
if (saveToDb) if (saveToDb)
{ {
mLastTimelineFlush = QDateTime::currentDateTimeUtc(); mLastTimelineFlush = QDateTime::currentDateTimeUtc();
@ -1191,7 +1190,7 @@ int MainWindow::showTrayWindow(QDialog* dlg)
int w = dlg->geometry().width(); int w = dlg->geometry().width();
int h = dlg->geometry().height(); int h = dlg->geometry().height();
QRect rec = QApplication::desktop()->screenGeometry(); QRect rec = QGuiApplication::primaryScreen()->availableGeometry();
int desktopHeight = rec.height(); int desktopHeight = rec.height();
int desktopWidth = rec.width(); int desktopWidth = rec.width();
@ -1371,7 +1370,7 @@ void MainWindow::showTimeReport()
void MainWindow::criticalAlertFinished(int /*status*/) void MainWindow::criticalAlertFinished(int /*status*/)
{ {
QApplication::postEvent(this, new ClientEvent<ClientCloseId>()); QApplication::postEvent(this, new ClientEvent(ClientCloseId));
} }
void MainWindow::warningAlertFinished(int /*status*/) void MainWindow::warningAlertFinished(int /*status*/)
@ -1412,7 +1411,7 @@ void MainWindow::checkForUpdates()
void MainWindow::systemSleep() void MainWindow::systemSleep()
{ {
//qDebug() << "System goes to sleep"; //qDebug() << "System goes to sleep";
stopTracking(TSR_Automatic, QDateTime::currentDateTimeUtc().toTime_t()); stopTracking(TSR_Automatic, QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
} }
void MainWindow::systemResume() void MainWindow::systemResume()
@ -1484,11 +1483,11 @@ void MainWindow::findRequested()
} }
//ui->mFindEdit->setVisible(false); //ui->mFindEdit->setVisible(false);
QTextCursor c = ui->mNoteEdit->document()->find(pattern, mFindStartIndex, nullptr); QTextCursor c = ui->mNoteEdit->document()->find(pattern, mFindStartIndex);
if (c.isNull()) if (c.isNull())
{ {
mFindStartIndex = 0; mFindStartIndex = 0;
c = ui->mNoteEdit->document()->find(pattern, mFindStartIndex, nullptr); c = ui->mNoteEdit->document()->find(pattern, mFindStartIndex);
} }
if (!c.isNull()) if (!c.isNull())
{ {
@ -1575,7 +1574,7 @@ void MainWindow::continueOnIdle()
void MainWindow::breakOnIdle(const QDateTime& stopTime) void MainWindow::breakOnIdle(const QDateTime& stopTime)
{ {
// Stop tracking // Stop tracking
stopTracking(TSR_Manual, stopTime.toUTC().toTime_t()); stopTracking(TSR_Manual, stopTime.toUTC().toSecsSinceEpoch());
showTimeForSelectedTask(); showTimeForSelectedTask();
} }

View File

@ -174,11 +174,11 @@ macx {
platforms/osx/sleeptracker_osx.mm platforms/osx/sleeptracker_osx.mm
} }
!include("fervor/Fervor.pri") { #!include("fervor/Fervor.pri") {
error("Unable to include Fervor autoupdater.") # error("Unable to include Fervor autoupdater.")
} #}
!include("qtkeychain/qt5keychain.pri") { !include("qtkeychain/qtkeychain.pri") {
error("Unable to include QTKeyChain library.") error("Unable to include QTKeyChain library.")
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -606,10 +606,14 @@ int TimeLine::getTime(int year, int month, int day, std::vector<TimeRecord>* int
QDate d(year, month, day); QDate d(year, month, day);
// Find range of related records [lowest, higher) // Find range of related records [lowest, higher)
TimeArray::iterator lowest = std::lower_bound(mData.begin(), mData.end(), d, [] (const TimeRecord& tr, const QDate& d) TimeArray::iterator lowest = std::lower_bound(mData.begin(),
mData.end(),
d,
[] (const TimeRecord& tr, const QDate& d)
{ {
return tr.endTime() < QDateTime(d).toTime_t(); return tr.endTime() < QDateTime(d, QTime()).toSecsSinceEpoch();
}); });
//TimeArray::iterator higher = std::upper_bound(mData.begin(), mData.end(), d, [] (const QDate& d, const TimeRecord& tr) { return tr.startTime().toLocalTime().date() < d;}); //TimeArray::iterator higher = std::upper_bound(mData.begin(), mData.end(), d, [] (const QDate& d, const TimeRecord& tr) { return tr.startTime().toLocalTime().date() < d;});
for (;lowest != mData.end();/*&& lowest != higher;*/ lowest++) for (;lowest != mData.end();/*&& lowest != higher;*/ lowest++)

View File

@ -47,7 +47,9 @@ QDateTime TimeIntervalDlg::finishDate()
void TimeIntervalDlg::accept() void TimeIntervalDlg::accept()
{ {
// Insert interval // Insert interval
mModel->insertInterval(TimeRecord(startDate().toUTC().toTime_t(), finishDate().toUTC().toTime_t(), mTimeline->taskId())); mModel->insertInterval(TimeRecord(startDate().toUTC().toSecsSinceEpoch(),
finishDate().toUTC().toSecsSinceEpoch(),
mTimeline->taskId()));
emit accepted(); emit accepted();
close(); close();
} }
@ -68,7 +70,9 @@ void TimeIntervalDlg::closeEvent(QCloseEvent *event)
bool TimeIntervalDlg::validate() bool TimeIntervalDlg::validate()
{ {
assert(mTimeline); assert(mTimeline);
return !mTimeline->hasIntersection(TimeRecord(startDate().toUTC().toTime_t(), finishDate().toUTC().toTime_t(), mTimeline->taskId())); return !mTimeline->hasIntersection(TimeRecord(startDate().toUTC().toSecsSinceEpoch(),
finishDate().toUTC().toSecsSinceEpoch(),
mTimeline->taskId()));
} }
void TimeIntervalDlg::dataChanged(const QDateTime& changed) void TimeIntervalDlg::dataChanged(const QDateTime& changed)

View File

@ -268,14 +268,14 @@ int TimeTreeModel::rowCount(const QModelIndex &parent) const
return result; return result;
} }
int TimeTreeModel::columnCount(const QModelIndex &parent) const int TimeTreeModel::columnCount(const QModelIndex &/*parent*/) const
{ {
return 1; return 1;
} }
static QString monthToString(int month) static QString monthToString(int month)
{ {
return QDate::longMonthName(month); return QLocale().monthName(month, QLocale::FormatType::LongFormat);
} }
QVariant TimeTreeModel::data(const QModelIndex &index, int role) const QVariant TimeTreeModel::data(const QModelIndex &index, int role) const