update lists if day change

This commit is contained in:
Gaelle Braud 2024-11-13 10:50:46 +01:00
parent 48ccfe95c7
commit 10ab8395f7
4 changed files with 19 additions and 0 deletions

View file

@ -287,7 +287,18 @@ App::App(int &argc, char *argv[])
.arg(Utils::getOsProduct())
.arg(qVersion());
mCurrentDate = QDate::currentDate();
mAutoStart = autoStartEnabled();
mDateUpdateTimer.setInterval(60000);
mDateUpdateTimer.setSingleShot(false);
connect(&mDateUpdateTimer, &QTimer::timeout, this, [this] {
auto date = QDate::currentDate();
if (date != mCurrentDate) {
mCurrentDate = date;
emit currentDateChanged();
}
});
mDateUpdateTimer.start();
}
App::~App() {
@ -645,6 +656,7 @@ void App::initCppInterfaces() {
//------------------------------------------------------------
void App::clean() {
mDateUpdateTimer.stop();
if (mEngine) {
mEngine->clearComponentCache();
mEngine->clearSingletons();

View file

@ -156,6 +156,7 @@ signals:
void coreStartedChanged(bool coreStarted);
void accountsChanged();
void callsChanged();
void currentDateChanged();
// void executeCommand(QString command);
private:
@ -177,6 +178,8 @@ private:
bool mAutoStart = false;
bool mCoreStarted = false;
QLocale mLocale = QLocale::system();
QTimer mDateUpdateTimer;
QDate mCurrentDate;
DECLARE_ABSTRACT_OBJECT
};

View file

@ -21,12 +21,14 @@
#include "CallHistoryProxy.hpp"
#include "CallHistoryGui.hpp"
#include "CallHistoryList.hpp"
#include "core/App.hpp"
DEFINE_ABSTRACT_OBJECT(CallHistoryProxy)
CallHistoryProxy::CallHistoryProxy(QObject *parent) : LimitProxy(parent) {
mHistoryList = CallHistoryList::create();
setSourceModels(new SortFilterList(mHistoryList.get(), Qt::DescendingOrder));
connect(App::getInstance(), &App::currentDateChanged, this, [this] { emit mHistoryList->lUpdate(); });
}
CallHistoryProxy::~CallHistoryProxy() {

View file

@ -20,6 +20,7 @@
#include "MagicSearchProxy.hpp"
#include "MagicSearchList.hpp"
#include "core/App.hpp"
#include "core/friend/FriendGui.hpp"
MagicSearchProxy::MagicSearchProxy(QObject *parent) : LimitProxy(parent) {
@ -30,6 +31,7 @@ MagicSearchProxy::MagicSearchProxy(QObject *parent) : LimitProxy(parent) {
connect(this, &MagicSearchProxy::forceUpdate, [this] {
if (mList) emit mList->lSearch(mSearchText);
});
connect(App::getInstance(), &App::currentDateChanged, this, &MagicSearchProxy::forceUpdate);
}
MagicSearchProxy::~MagicSearchProxy() {