mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 02:32:29 +01:00
Fix installed list sorting because of missing LastModified
Fix ScreenPlayItem isNew location
This commit is contained in:
parent
3675170d06
commit
a8152b5ab0
@ -17,24 +17,24 @@ Item {
|
||||
property var publishedFileID: 0
|
||||
property int itemIndex
|
||||
property bool isScrolling: false
|
||||
property bool isNew:false
|
||||
Component.onCompleted:print(isNew)
|
||||
property bool isNew: false
|
||||
|
||||
signal openContextMenu(point position)
|
||||
|
||||
width: 320
|
||||
height: 180
|
||||
onTypeChanged: {
|
||||
if (JSUtil.isWidget(type)) {
|
||||
icnType.source = "qrc:/assets/icons/icon_widgets.svg";
|
||||
return ;
|
||||
icnType.source = "qrc:/assets/icons/icon_widgets.svg"
|
||||
return
|
||||
}
|
||||
if (JSUtil.isScene(type)) {
|
||||
icnType.source = "qrc:/assets/icons/icon_code.svg";
|
||||
return ;
|
||||
icnType.source = "qrc:/assets/icons/icon_code.svg"
|
||||
return
|
||||
}
|
||||
if (JSUtil.isVideo(type)) {
|
||||
icnType.source = "qrc:/assets/icons/icon_movie.svg";
|
||||
return ;
|
||||
icnType.source = "qrc:/assets/icons/icon_movie.svg"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,11 +42,11 @@ Item {
|
||||
running: true
|
||||
onTriggered: showAnim.start()
|
||||
interval: {
|
||||
var itemIndexMax = itemIndex;
|
||||
var itemIndexMax = itemIndex
|
||||
if (itemIndex > 30)
|
||||
itemIndexMax = 3;
|
||||
itemIndexMax = 3
|
||||
|
||||
5 * itemIndexMax * Math.random();
|
||||
5 * itemIndexMax * Math.random()
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,6 @@ Item {
|
||||
duration: 200
|
||||
easing.type: Easing.OutCirc
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OpacityAnimator {
|
||||
@ -89,7 +88,6 @@ Item {
|
||||
duration: 800
|
||||
easing.type: Easing.OutCirc
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RectangularGlow {
|
||||
@ -108,7 +106,6 @@ Item {
|
||||
top: parent.top
|
||||
topMargin: 3
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -175,7 +172,6 @@ Item {
|
||||
left: parent.left
|
||||
margins: 10
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@ -188,26 +184,30 @@ Item {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
}
|
||||
Image {
|
||||
id: new_banner
|
||||
id: newBanner
|
||||
source: "qrc:/assets/icons/item_banner_new.svg"
|
||||
visible: root.isNew
|
||||
|
||||
Text
|
||||
{
|
||||
|
||||
font.family:"Helvetica";font.bold: true;font.pointSize:9.5; font.italic: true
|
||||
color: "#AAffffff"
|
||||
Text {
|
||||
font.family: ScreenPlay.settings.font
|
||||
font.bold: true
|
||||
font.pointSize: 10
|
||||
color: "white"
|
||||
text: qsTr("NEW")
|
||||
anchors{
|
||||
right: new_banner.right
|
||||
top: new_banner.TopLeft
|
||||
|
||||
}
|
||||
transform: Rotation{ origin.y:12; angle:45}
|
||||
smooth: true
|
||||
antialiasing: true
|
||||
visible: root.isNew
|
||||
anchors {
|
||||
right: newBanner.right
|
||||
top: newBanner.top
|
||||
rightMargin: 3
|
||||
topMargin: 10
|
||||
}
|
||||
transform: Rotation {
|
||||
angle: 45
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,25 +223,23 @@ Item {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onEntered: {
|
||||
root.state = "hover";
|
||||
screenPlayItemImage.state = "hover";
|
||||
screenPlayItemImage.enter();
|
||||
root.state = "hover"
|
||||
screenPlayItemImage.state = "hover"
|
||||
screenPlayItemImage.enter()
|
||||
}
|
||||
onExited: {
|
||||
root.state = "";
|
||||
screenPlayItemImage.state = "loaded";
|
||||
screenPlayItemImage.exit();
|
||||
root.state = ""
|
||||
screenPlayItemImage.state = "loaded"
|
||||
screenPlayItemImage.exit()
|
||||
}
|
||||
onClicked: {
|
||||
if (mouse.button === Qt.LeftButton)
|
||||
ScreenPlay.util.setSidebarItem(root.screenId, root.type);
|
||||
ScreenPlay.util.setSidebarItem(root.screenId, root.type)
|
||||
else if (mouse.button === Qt.RightButton)
|
||||
root.openContextMenu(Qt.point(mouseX, mouseY));
|
||||
root.openContextMenu(Qt.point(mouseX, mouseY))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
transitions: [
|
||||
@ -276,7 +274,6 @@ Item {
|
||||
from: 0.6
|
||||
to: 1
|
||||
}
|
||||
|
||||
},
|
||||
Transition {
|
||||
from: "hover"
|
||||
@ -309,7 +306,6 @@ Item {
|
||||
from: 1
|
||||
to: 0.5
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "installedlistmodel.h"
|
||||
#include<QDebug>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ScreenPlay {
|
||||
|
||||
@ -115,12 +114,13 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
|
||||
return m_screenPlayFiles.at(row).m_tags;
|
||||
case static_cast<int>(ScreenPlayItem::IsNew):
|
||||
return m_screenPlayFiles.at(row).m_isNew;
|
||||
|
||||
case static_cast<int>(ScreenPlayItem::LastModified):
|
||||
return m_screenPlayFiles.at(row).m_lastModified;
|
||||
case static_cast<int>(ScreenPlayItem::SearchType):
|
||||
return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
qWarning() << "Unable to fetch value for row type:" << role;
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -140,18 +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::IsNew), "m_isNew" }
|
||||
|
||||
{ static_cast<int>(ScreenPlayItem::IsNew), "m_isNew" },
|
||||
{ static_cast<int>(ScreenPlayItem::LastModified), "m_lastModified" }
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Append an ProjectFile to the list.
|
||||
*/
|
||||
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew)
|
||||
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew, const QDateTime& lastModified)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
|
||||
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew));
|
||||
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew, lastModified));
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
@ -168,16 +168,12 @@ void InstalledListModel::loadInstalledContent()
|
||||
const QString absoluteFilePath = m_globalVariables->localStoragePath().toLocalFile() + "/" + item.baseName() + "/project.json";
|
||||
|
||||
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;
|
||||
}
|
||||
continue;
|
||||
|
||||
bool isNew = false;
|
||||
|
||||
if (item.birthTime().date() == QDateTime::currentDateTime().date())
|
||||
isNew = true;
|
||||
|
||||
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absoluteFilePath)) {
|
||||
|
||||
@ -189,15 +185,12 @@ 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(),isNew);
|
||||
|
||||
append(*obj, item.baseName(), isNew, item.lastModified());
|
||||
}
|
||||
|
||||
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
setCount(counter);
|
||||
emit installedLoadingFinished();
|
||||
@ -224,7 +217,8 @@ 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_isNew",m_screenPlayFiles[i].m_isNew);
|
||||
map.insert("m_isNew", m_screenPlayFiles[i].m_isNew);
|
||||
map.insert("m_lastModified", m_screenPlayFiles[i].m_lastModified);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public slots:
|
||||
QVariantMap get(const QString& folderId) const;
|
||||
|
||||
void loadInstalledContent();
|
||||
void append(const QJsonObject&, const QString&,const bool isNew);
|
||||
void append(const QJsonObject&, const QString&, const bool isNew, const QDateTime& lastModified);
|
||||
void reset();
|
||||
void init();
|
||||
bool deinstallItemAt(const int index);
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
@ -42,7 +43,6 @@
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
#include <QVariantList>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "ScreenPlayUtil/util.h"
|
||||
|
||||
@ -59,7 +59,8 @@ struct ProjectFile {
|
||||
const QJsonObject& obj,
|
||||
const QString& folderName,
|
||||
const QUrl& absolutePath,
|
||||
const bool isNew)
|
||||
const bool isNew,
|
||||
const QDateTime& lastModified)
|
||||
{
|
||||
|
||||
if (obj.contains("description"))
|
||||
@ -101,8 +102,6 @@ struct ProjectFile {
|
||||
|
||||
m_folderId = folderName;
|
||||
|
||||
|
||||
|
||||
if (!obj.contains("type"))
|
||||
return;
|
||||
|
||||
@ -118,6 +117,7 @@ struct ProjectFile {
|
||||
}
|
||||
m_searchType = ScreenPlayUtil::getSearchTypeFromInstalledType(m_type);
|
||||
m_isNew = isNew;
|
||||
m_lastModified = lastModified;
|
||||
}
|
||||
|
||||
ProjectFile() { }
|
||||
@ -139,5 +139,6 @@ struct ProjectFile {
|
||||
InstalledType::InstalledType m_type = InstalledType::InstalledType::Unknown;
|
||||
SearchType::SearchType m_searchType = SearchType::SearchType::All;
|
||||
bool m_isNew = false;
|
||||
QDateTime m_lastModified;
|
||||
};
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
|
||||
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const QDateTime& lastModified)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
|
||||
m_screenPlayFiles.append(ScreenPlay::ProjectFile(obj, folderName, m_absoluteStoragePath, lastModified));
|
||||
m_screenPlayFiles.append(ScreenPlay::ProjectFile(obj, folderName, m_absoluteStoragePath, false, lastModified));
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user