diff --git a/ScreenPlay/qml/Installed/Installed.qml b/ScreenPlay/qml/Installed/Installed.qml index 8aa27ab4..fb3eac0e 100644 --- a/ScreenPlay/qml/Installed/Installed.qml +++ b/ScreenPlay/qml/Installed/Installed.qml @@ -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 diff --git a/ScreenPlay/qml/Installed/ScreenPlayItem.qml b/ScreenPlay/qml/Installed/ScreenPlayItem.qml index 34ba94dc..6becb570 100644 --- a/ScreenPlay/qml/Installed/ScreenPlayItem.qml +++ b/ScreenPlay/qml/Installed/ScreenPlayItem.qml @@ -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 + + } } diff --git a/ScreenPlay/src/installedlistmodel.cpp b/ScreenPlay/src/installedlistmodel.cpp index 9ef96071..cdae46de 100644 --- a/ScreenPlay/src/installedlistmodel.cpp +++ b/ScreenPlay/src/installedlistmodel.cpp @@ -1,4 +1,6 @@ #include "installedlistmodel.h" +#include + 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(ScreenPlayItem::Tags): return m_screenPlayFiles.at(row).m_tags; - case static_cast(ScreenPlayItem::LastModified): - return m_screenPlayFiles.at(row).m_lastModified; + case static_cast(ScreenPlayItem::IsNew): + return m_screenPlayFiles.at(row).m_isNew; + case static_cast(ScreenPlayItem::SearchType): return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType); default: @@ -137,17 +140,18 @@ QHash InstalledListModel::roleNames() const { static_cast(ScreenPlayItem::PublishedFileID), "m_publishedFileID" }, { static_cast(ScreenPlayItem::Tags), "m_tags" }, { static_cast(ScreenPlayItem::SearchType), "m_searchType" }, - { static_cast(ScreenPlayItem::LastModified), "m_lastModified" }, + { static_cast(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(); } @@ -164,7 +168,16 @@ void InstalledListModel::loadInstalledContent() const QString absoluteFilePath = m_globalVariables->localStoragePath().toLocalFile() + "/" + item.baseName() + "/project.json"; if (!QFile::exists(absoluteFilePath)) - continue; + continue; + bool isNew=false; + QDateTime date=QDateTime::currentDateTime(); + qDebug()<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; } } diff --git a/ScreenPlay/src/installedlistmodel.h b/ScreenPlay/src/installedlistmodel.h index dac72255..c460c7bd 100644 --- a/ScreenPlay/src/installedlistmodel.h +++ b/ScreenPlay/src/installedlistmodel.h @@ -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); diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/projectfile.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/projectfile.h index 3c65c6b1..b69f77fc 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/projectfile.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/projectfile.h @@ -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; }; }