1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-10-06 09:17:07 +02:00

Sorting according to file size

This commit is contained in:
debashbora 2021-10-15 16:40:20 +05:30
parent 160645ccc0
commit 133f993223
6 changed files with 86 additions and 41 deletions

View File

@ -148,5 +148,6 @@
<file>translations/ScreenPlay_nl_NL.ts</file>
<file>translations/ScreenPlay_it_IT.qm</file>
<file>translations/ScreenPlay_it_IT.ts</file>
<file>assets/icons/icon_sort_button.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M9,18h12v-2H9V18z M3,6v2h18V6H3z M9,13h12v-2H9V13z"/></g></svg>

After

Width:  |  Height:  |  Size: 260 B

View File

@ -31,11 +31,9 @@ Item {
layer.effect: ElevationEffect {
elevation: 2
}
}
Common.MouseHoverBlocker {
}
Common.MouseHoverBlocker {}
Item {
height: nav.height
@ -67,13 +65,12 @@ Item {
font.weight: Font.Thin
icon.source: "qrc:/assets/icons/icon_installed.svg"
onClicked: {
setSidebarActive(false);
ScreenPlay.installedListFilter.sortBySearchType(SearchType.All);
}
background: Item {
setSidebarActive(false)
ScreenPlay.installedListFilter.sortBySearchType(
SearchType.All)
}
background: Item {}
}
TabButton {
@ -86,13 +83,12 @@ Item {
font.weight: Font.Thin
icon.source: "qrc:/assets/icons/icon_code.svg"
onClicked: {
setSidebarActive(false);
ScreenPlay.installedListFilter.sortBySearchType(SearchType.Scene);
}
background: Item {
setSidebarActive(false)
ScreenPlay.installedListFilter.sortBySearchType(
SearchType.Scene)
}
background: Item {}
}
TabButton {
@ -105,13 +101,12 @@ Item {
font.weight: Font.Thin
icon.source: "qrc:/assets/icons/icon_movie.svg"
onClicked: {
setSidebarActive(false);
ScreenPlay.installedListFilter.sortBySearchType(SearchType.Wallpaper);
}
background: Item {
setSidebarActive(false)
ScreenPlay.installedListFilter.sortBySearchType(
SearchType.Wallpaper)
}
background: Item {}
}
TabButton {
@ -124,29 +119,25 @@ Item {
font.weight: Font.Thin
icon.source: "qrc:/assets/icons/icon_widgets.svg"
onClicked: {
setSidebarActive(false);
ScreenPlay.installedListFilter.sortBySearchType(SearchType.Widget);
}
background: Item {
setSidebarActive(false)
ScreenPlay.installedListFilter.sortBySearchType(
SearchType.Widget)
}
background: Item {}
}
background: Item {
}
background: Item {}
}
Common.Search {
height: parent.height
anchors {
right: btnSortOrder.left
right: sortButton.left
rightMargin: 10
top: parent.top
}
}
ToolButton {
@ -161,10 +152,12 @@ Item {
ToolTip.delay: 100
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: (sortOrder === Qt.AscendingOrder) ? qsTr("Install Date Ascending") : qsTr("Install Date Descending")
ToolTip.text: (sortOrder === Qt.AscendingOrder) ? qsTr("Ascending") : qsTr("Descending")
onClicked: {
sortOrder = (sortOrder === Qt.DescendingOrder) ? Qt.AscendingOrder : Qt.DescendingOrder;
ScreenPlay.installedListFilter.setSortOrder(sortOrder);
sortOrder = (sortOrder
=== Qt.DescendingOrder) ? Qt.AscendingOrder : Qt.DescendingOrder
ScreenPlay.installedListFilter.setSortOrder(sortOrder)
}
anchors {
@ -173,9 +166,42 @@ Item {
top: parent.top
verticalCenter: parent.verticalCenter
}
}
Button {
id: sortButton
icon.source: "qrc:/assets/icons/icon_sort_button.svg"
icon.width: 16
icon.height: 16
onClicked: menu.open()
Menu {
id: menu
y: sortButton.height
MenuItem {
text: "Date"
hoverEnabled: true
ToolTip.delay: 100
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Install Date")
}
MenuItem {
text: "Size"
hoverEnabled: true
ToolTip.delay: 100
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("File Size")
}
}
anchors {
right: btnSortOrder.left
rightMargin: 10
top: parent.top
verticalCenter: parent.verticalCenter
}
}
}
states: [
@ -186,7 +212,6 @@ Item {
target: navWrapper
anchors.topMargin: -115
}
},
State {
name: "in"
@ -195,7 +220,6 @@ Item {
target: navWrapper
anchors.topMargin: 0
}
}
]
transitions: [
@ -209,7 +233,6 @@ Item {
duration: 400
easing.type: Easing.InOutQuart
}
}
]
}

View File

@ -156,6 +156,8 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const
return m_screenPlayFiles.at(row).m_lastModified;
case static_cast<int>(ScreenPlayItem::SearchType):
return QVariant::fromValue(m_screenPlayFiles.at(row).m_searchType);
case static_cast<int>(ScreenPlayItem::SizeBytes):
return QVariant::fromValue(m_screenPlayFiles.at(row).m_size);
}
qWarning() << "Unable to fetch value for row type:" << role;
@ -179,17 +181,18 @@ QHash<int, QByteArray> InstalledListModel::roleNames() const
{ 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::LastModified), "m_lastModified" }
{ static_cast<int>(ScreenPlayItem::LastModified), "m_lastModified" },
{ static_cast<int>(ScreenPlayItem::SizeBytes),"m_size"}
};
}
/*!
\brief Append an ProjectFile to the list.
*/
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew, const QDateTime& lastModified)
void InstalledListModel::append(const QJsonObject& obj, const QString& folderName, const bool isNew, const QDateTime& lastModified,const int& sizeBytes)
{
beginInsertRows(QModelIndex(), m_screenPlayFiles.size(), m_screenPlayFiles.size());
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew, lastModified));
m_screenPlayFiles.append(ProjectFile(obj, folderName, m_globalVariables->localStoragePath(), isNew, lastModified,sizeBytes));
endInsertRows();
}
@ -219,6 +222,17 @@ void InstalledListModel::loadInstalledContent()
if (item.birthTime().date() == QDateTime::currentDateTime().date())
isNew = true;
int sizeBytes ;
QDirIterator dirs(m_globalVariables->localStoragePath().toLocalFile(),(QDir::Filter::NoDotAndDotDot | QDir::Filter::Dirs));
while (dirs.hasNext()) {
QDirIterator projectIterator(dirs.next(), (QDir::Filter::Files | QDir::Filter::NoDotAndDotDot ));
sizeBytes=0;
while (projectIterator.hasNext()) {
sizeBytes += QFileInfo( projectIterator.next()).size();
}
}
if (auto obj = ScreenPlayUtil::openJsonFileToObject(absoluteFilePath)) {
@ -230,7 +244,7 @@ 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, item.lastModified());
append(*obj, item.baseName(), isNew, item.lastModified(), sizeBytes);
}
counter += 1;
@ -270,6 +284,7 @@ QVariantMap InstalledListModel::get(const QString& folderName) const
map.insert("m_publishedFileID", item.m_publishedFileID);
map.insert("m_isNew", item.m_isNew);
map.insert("m_lastModified", item.m_lastModified);
map.insert("m_Size",item.m_size);
return map;
}
}

View File

@ -90,6 +90,8 @@ public:
SearchType,
LastModified,
IsNew,
SizeBytes,
};
Q_ENUM(ScreenPlayItem)
@ -102,7 +104,7 @@ public slots:
QVariantMap get(const QString& folderName) const;
void loadInstalledContent();
void append(const QJsonObject&, const QString&, const bool isNew, const QDateTime& lastModified);
void append(const QJsonObject&, const QString&, const bool isNew, const QDateTime& lastModified,const int& sizeBytes);
void reset();
void init();
void deinstallItemAt(const QString& absoluteStoragePath);

View File

@ -60,7 +60,8 @@ struct ProjectFile {
const QString& folderName,
const QUrl& absolutePath,
const bool isNew,
const QDateTime& lastModified)
const QDateTime& lastModified,
const int& sizeBytes)
{
if (obj.contains("description"))
@ -118,6 +119,7 @@ struct ProjectFile {
m_searchType = ScreenPlayUtil::getSearchTypeFromInstalledType(m_type);
m_isNew = isNew;
m_lastModified = lastModified;
m_size = sizeBytes;
}
ProjectFile() { }
@ -140,5 +142,6 @@ struct ProjectFile {
SearchType::SearchType m_searchType = SearchType::SearchType::All;
bool m_isNew = false;
QDateTime m_lastModified;
int m_size;
};
}