fix: 优化最近安装显示逻辑
This commit is contained in:
parent
84474ae341
commit
32fb0ab303
|
@ -44,17 +44,25 @@ RecentlyInstalledModel::RecentlyInstalledModel(QObject *parent) : QSortFilterPro
|
||||||
bool RecentlyInstalledModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
bool RecentlyInstalledModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||||
{
|
{
|
||||||
QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
|
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<QString>(), "yyyy-MM-dd hh:mm:ss");
|
QDateTime installDate = QDateTime::fromString(sourceIndex.data(DataEntity::InstallationTime).value<QString>(), "yyyy-MM-dd hh:mm:ss");
|
||||||
if (!installDate.isValid()) {
|
if (!installDate.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime currentDateTime = QDateTime::currentDateTime();
|
QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||||
// 安装时间小于当前时间,差距超过48小时
|
// 安装时间在30天内
|
||||||
// 安装时间小于当前时间,差距在[48-0]小时内
|
|
||||||
// 安装时间大于当前时间
|
|
||||||
qint64 xt = currentDateTime.toSecsSinceEpoch() - installDate.toSecsSinceEpoch();
|
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
|
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<QString>(), "yyyy-MM-dd hh:mm:ss");
|
QDateTime rightInstallDate = QDateTime::fromString(source_right.data(DataEntity::InstallationTime).value<QString>(), "yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
qint64 xt = leftInstallDate.toSecsSinceEpoch() - rightInstallDate.toSecsSinceEpoch();
|
qint64 xt = leftInstallDate.toSecsSinceEpoch() - rightInstallDate.toSecsSinceEpoch();
|
||||||
// if (xt == 0) {
|
if (xt == 0) {
|
||||||
// return source_left.data(DataEntity::FirstLetter).value<QString>() < source_right.data(DataEntity::FirstLetter).value<QString>();
|
return source_left.data(DataEntity::FirstLetter).value<QString>() < source_right.data(DataEntity::FirstLetter).value<QString>();
|
||||||
// }
|
}
|
||||||
|
|
||||||
return xt <= 0;
|
return xt >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecentlyInstalledModel::event(QEvent *event)
|
bool RecentlyInstalledModel::event(QEvent *event)
|
||||||
|
|
Loading…
Reference in New Issue