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)