1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Added basic isNew feature.

This commit is contained in:
Debash Bora 2021-08-27 15:32:30 +05:30
parent df126bef09
commit 441f06f45b
5 changed files with 35 additions and 16 deletions

View File

@ -206,6 +206,7 @@ Item {
focus: true
customTitle: m_title
type: m_type
isNew: m_isNew
screenId: m_folderId
absoluteStoragePath: m_absoluteStoragePath
publishedFileID: m_publishedFileID

View File

@ -17,7 +17,8 @@ Item {
property var publishedFileID: 0
property int itemIndex
property bool isScrolling: false
property bool isNew:false
Component.onCompleted:print(isNew)
signal openContextMenu(point position)
width: 320
@ -189,6 +190,11 @@ Item {
}
}
Text {
text: qsTr("New")
visible: root.isNew
}
}

View File

@ -1,4 +1,6 @@
#include "installedlistmodel.h"
#include<QDebug>
namespace ScreenPlay {
@ -111,8 +113,9 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
return m_screenPlayFiles.at(row).m_publishedFileID;
case static_cast<int>(ScreenPlayItem::Tags):
return m_screenPlayFiles.at(row).m_tags;
case static_cast<int>(ScreenPlayItem::LastModified):
return m_screenPlayFiles.at(row).m_lastModified;
case static_cast<int>(ScreenPlayItem::IsNew):
return m_screenPlayFiles.at(row).m_isNew;
case static_cast<int>(ScreenPlayItem::SearchType):
return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType);
default:
@ -137,17 +140,18 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
{ static_cast<int>(ScreenPlayItem::PublishedFileID), "m_publishedFileID" },
{ static_cast<int>(ScreenPlayItem::Tags), "m_tags" },
{ static_cast<int>(ScreenPlayItem::SearchType), "m_searchType" },
{ static_cast<int>(ScreenPlayItem::LastModified), "m_lastModified" },
{ static_cast<int>(ScreenPlayItem::IsNew), "m_isNew" }
};
}
/*!
\brief Append an ProjectFile to the list.
*/
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const QDateTime& lastModified,const QDateTime& birthTime)
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew)
{
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), lastModified, birthTime));
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew));
endInsertRows();
}
@ -165,6 +169,15 @@ void InstalledListModel::loadInstalledContent()
if (!QFile::exists(absoluteFilePath))
continue;
bool isNew=false;
QDateTime date=QDateTime::currentDateTime();
qDebug()<<date.date();
if(item.birthTime().date()==date.date())
{
qDebug()<<item.birthTime()<<date.date();
isNew=true;
qDebug()<<isNew;
}
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absoluteFilePath)) {
@ -176,7 +189,8 @@ void InstalledListModel::loadInstalledContent()
if (ScreenPlayUtil::getAvailableTypes().contains(obj->value("type").toString())) {
if (ScreenPlayUtil::getAvailableTypes().contains(obj->value("type").toString(), Qt::CaseInsensitive)) {
append(*obj, item.baseName(), item.lastModified(),item.birthTime());
append(*obj, item.baseName(),isNew);
}
@ -210,7 +224,7 @@ QVariantMap InstalledListModel::get(const QString& folderId) const
map.insert("m_type", QVariant::fromValue(m_screenPlayFiles[i].m_type));
map.insert("m_absoluteStoragePath", m_screenPlayFiles[i].m_absoluteStoragePath);
map.insert("m_publishedFileID", m_screenPlayFiles[i].m_publishedFileID);
map.insert("m_lastModified", m_screenPlayFiles[i].m_lastModified);
map.insert("m_isNew",m_screenPlayFiles[i].m_isNew);
return map;
}
}

View File

@ -89,6 +89,7 @@ public:
Tags,
SearchType,
LastModified,
IsNew,
};
Q_ENUM(ScreenPlayItem)
@ -101,7 +102,7 @@ public slots:
QVariantMap get(const QString& folderId) const;
void loadInstalledContent();
void append(const QJsonObject&, const QString&, const QDateTime& lastModified,const QDateTime& birthTime);
void append(const QJsonObject&, const QString&,const bool isNew);
void reset();
void init();
bool deinstallItemAt(const int index);

View File

@ -59,8 +59,7 @@ struct ProjectFile {
const QJsonObject& obj,
const QString& folderName,
const QUrl& absolutePath,
const QDateTime& lastModified,
const QDateTime& birthTime)
const bool isNew)
{
if (obj.contains("description"))
@ -118,8 +117,7 @@ struct ProjectFile {
m_preview = m_previewGIF;
}
m_searchType = ScreenPlayUtil::getSearchTypeFromInstalledType(m_type);
m_lastModified = lastModified;
m_birthTime = birthTime;
m_isNew = isNew;
}
ProjectFile() { }
@ -140,7 +138,6 @@ struct ProjectFile {
InstalledType::InstalledType m_type = InstalledType::InstalledType::Unknown;
SearchType::SearchType m_searchType = SearchType::SearchType::All;
QDateTime m_lastModified;
QDateTime m_birthTime;
bool m_isNew = false;
};
}