- 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

@ -5,28 +5,29 @@
#include "task.h"
enum
{
ClientInitId = 62000,
ClientCloseId = 62001,
AttachDatabaseId,
SelectTaskId,
UiInitId
ClientInitId = 62000,
ClientCloseId = 62001,
AttachDatabaseId = 62002,
SelectTaskId = 62003,
UiInitId = 62004
};
template <int N>
class ClientEvent: public QEvent
{
private:
int mType = N;
int mType;
public:
ClientEvent<N>()
:QEvent(static_cast<QEvent::Type>(N))
ClientEvent(int numtype)
:QEvent(static_cast<QEvent::Type>(numtype)), mType(numtype)
{}
};
class SelectTaskEvent: public ClientEvent<SelectTaskId>
class SelectTaskEvent: public ClientEvent
{
public:
SelectTaskEvent(PTask task) {
SelectTaskEvent(PTask task)
:ClientEvent(SelectTaskId)
{
mTask = task;
}

View File

@ -187,5 +187,5 @@ void IV::Generate(QByteArray &buffer)
{
uint8_t* data = (uint8_t*)buffer.data();
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("\""))
sl.append(mRequest);
else
sl = mRequest.split(" ", QString::SkipEmptyParts);
sl = mRequest.split(" ", Qt::SkipEmptyParts);
if (!sl.empty())
{

View File

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

View File

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

View File

@ -174,11 +174,11 @@ macx {
platforms/osx/sleeptracker_osx.mm
}
!include("fervor/Fervor.pri") {
error("Unable to include Fervor autoupdater.")
}
#!include("fervor/Fervor.pri") {
# error("Unable to include Fervor autoupdater.")
#}
!include("qtkeychain/qt5keychain.pri") {
!include("qtkeychain/qtkeychain.pri") {
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);
// Find range of related records [lowest, higher)
TimeArray::iterator lowest = std::lower_bound(mData.begin(), mData.end(), d, [] (const TimeRecord& tr, const QDate& d)
{
return tr.endTime() < QDateTime(d).toTime_t();
});
TimeArray::iterator lowest = std::lower_bound(mData.begin(),
mData.end(),
d,
[] (const TimeRecord& tr, const QDate& d)
{
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;});
for (;lowest != mData.end();/*&& lowest != higher;*/ lowest++)

View File

@ -47,7 +47,9 @@ QDateTime TimeIntervalDlg::finishDate()
void TimeIntervalDlg::accept()
{
// 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();
close();
}
@ -68,7 +70,9 @@ void TimeIntervalDlg::closeEvent(QCloseEvent *event)
bool TimeIntervalDlg::validate()
{
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)

View File

@ -268,14 +268,14 @@ int TimeTreeModel::rowCount(const QModelIndex &parent) const
return result;
}
int TimeTreeModel::columnCount(const QModelIndex &parent) const
int TimeTreeModel::columnCount(const QModelIndex &/*parent*/) const
{
return 1;
}
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