From 32fb0ab303e2ceb44bc9ae6116ba812a16f63af3 Mon Sep 17 00:00:00 2001 From: hewenfei Date: Mon, 11 Mar 2024 11:34:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libappdata/recently-installed-model.cpp | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/libappdata/recently-installed-model.cpp b/src/libappdata/recently-installed-model.cpp index 7c383a9..240c374 100644 --- a/src/libappdata/recently-installed-model.cpp +++ b/src/libappdata/recently-installed-model.cpp @@ -44,17 +44,25 @@ RecentlyInstalledModel::RecentlyInstalledModel(QObject *parent) : QSortFilterPro bool RecentlyInstalledModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent); + // 是否打开过 + if (sourceIndex.data(DataEntity::IsLaunched).toInt() != 0) { + return false; + } + + // 是否收藏 + if (sourceIndex.data(DataEntity::Favorite).toInt() > 0) { + return false; + } + QDateTime installDate = QDateTime::fromString(sourceIndex.data(DataEntity::InstallationTime).value(), "yyyy-MM-dd hh:mm:ss"); if (!installDate.isValid()) { return false; } QDateTime currentDateTime = QDateTime::currentDateTime(); - // 安装时间小于当前时间,差距超过48小时 - // 安装时间小于当前时间,差距在[48-0]小时内 - // 安装时间大于当前时间 + // 安装时间在30天内 qint64 xt = currentDateTime.toSecsSinceEpoch() - installDate.toSecsSinceEpoch(); - return (xt >= 0) && (xt <= 48 * 3600); + return (xt >= 0) && (xt <= 30 * 24 * 3600); } bool RecentlyInstalledModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const @@ -63,11 +71,11 @@ bool RecentlyInstalledModel::lessThan(const QModelIndex &source_left, const QMod QDateTime rightInstallDate = QDateTime::fromString(source_right.data(DataEntity::InstallationTime).value(), "yyyy-MM-dd hh:mm:ss"); qint64 xt = leftInstallDate.toSecsSinceEpoch() - rightInstallDate.toSecsSinceEpoch(); -// if (xt == 0) { -// return source_left.data(DataEntity::FirstLetter).value() < source_right.data(DataEntity::FirstLetter).value(); -// } + if (xt == 0) { + return source_left.data(DataEntity::FirstLetter).value() < source_right.data(DataEntity::FirstLetter).value(); + } - return xt <= 0; + return xt >= 0; } bool RecentlyInstalledModel::event(QEvent *event)