Skip to content

Commit

Permalink
Refactor home projects list 2/2
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Mar 1, 2024
1 parent 5063949 commit 48b6bdc
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 122 deletions.
6 changes: 6 additions & 0 deletions app/projectsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ Project ProjectsModel::projectFromId( const QString &projectId ) const
return Project();
}

QModelIndex ProjectsModel::projectModelIndexFromId( const QString &projectId ) const
{
int row = projectIndexFromId( projectId );
return index( row );
}

bool ProjectsModel::isLoading() const
{
return mModelIsLoading;
Expand Down
3 changes: 3 additions & 0 deletions app/projectsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class ProjectsModel : public QAbstractListModel
//! Returns Project deep copy from projectId
Project projectFromId( const QString &projectId ) const;

//! Returns model index from projectId
Q_INVOKABLE QModelIndex projectModelIndexFromId( const QString &projectId ) const;

MerginApi *merginApi() const;
SynchronizationManager *syncManager() const;
LocalProjectsManager *localProjectsManager() const;
Expand Down
140 changes: 61 additions & 79 deletions app/qml/project/MMProjectHomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,108 +60,90 @@ Item {
topMargin: root.spacing
}
title: qsTr("Your attention is required.")
description: qsTr("Please visit the %1Mergin dashboard%2.")
.arg("<a style=\"text-decoration: underline; color:" + __style.whiteColor + ";\" href='" + __inputHelp.merginDashboardLink + "'>")
.arg("</a>")

description: qsTr("Click here to visit Mergin Maps dashboard")
onClicked: Qt.openUrlExternally( __inputHelp.merginDashboardLink )
}

Column {
id: currentProjectColumn

width: parent.width
visible: root.activeProjectId !== ""

anchors {
top: warningBubble.visible ? warningBubble.bottom : searchBar.bottom
left: parent.left
right: parent.right
topMargin: 2 * root.spacing
}
Component {
id: activeProjectComponent

Text {
width: parent.width
height: 31 * __dp
text: qsTr("Currently open")
font: __style.p6
color: __style.nightColor
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Column {
id: currentProjectColumn

MMLine {}
width: ListView.view.width
visible: activeProjectItem.model !== undefined

Item { width: 1; height: 20 * __dp }
Text {
width: parent.width
height: 31 * __dp
text: qsTr("Currently open")
font: __style.p6
color: __style.nightColor
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}

Repeater {
width: parent.width
model: ProjectsProxyModel {
id: viewModel
MMLine {}

projectSourceModel: ProjectsModel {
id: controllerModel
Item { width: 1; height: 20 * __dp }

merginApi: __merginApi
localProjectsManager: __localProjectsManager
syncManager: __syncManager
modelType: ProjectsModel.LocalProjectsModel
}
}
delegate: MMProjectItem {
id: projectDelegate
MMProjectItem {
id: activeProjectItem

width: currentProjectColumn.width
property var model: projectlist.projectsModel
property var index: projectlist.projectsModel.projectModelIndexFromId(root.activeProjectId)

projectDisplayName: root.projectModelType === ProjectsModel.CreatedProjectsModel ? model.ProjectName : model.ProjectFullName
projectId: model.ProjectId
projectDescription: model.ProjectDescription
projectStatus: model.ProjectStatus ? model.ProjectStatus : ProjectStatus.NoVersion
projectIsValid: model.ProjectIsValid
projectIsPending: model.ProjectSyncPending ? model.ProjectSyncPending : false
projectSyncProgress: model.ProjectSyncProgress ? model.ProjectSyncProgress : -1
projectIsLocal: model.ProjectIsLocal
projectIsMergin: model.ProjectIsMergin
projectRemoteError: model.ProjectRemoteError ? model.ProjectRemoteError : ""
width: parent.width

visible: model.ProjectId === root.activeProjectId
highlight: true
projectDisplayName: model.data(index, ProjectsModel.ProjectFullName)
projectId: model.data(index, ProjectsModel.ProjectId)
projectDescription: model.data(index, ProjectsModel.ProjectDescription)
projectStatus: model.data(index, ProjectsModel.ProjectStatus) ? model.data(index, ProjectsModel.ProjectStatus) : ProjectStatus.NoVersion
projectIsValid: model.data(index, ProjectsModel.ProjectIsValid)
projectIsPending: model.data(index, ProjectsModel.ProjectSyncPending) ? model.data(index, ProjectsModel.ProjectSyncPending) : false
projectSyncProgress: model.data(index, ProjectsModel.ProjectSyncProgress) ? model.data(index, ProjectsModel.ProjectSyncProgress) : -1
projectIsLocal: model.data(index, ProjectsModel.ProjectIsLocal)
projectIsMergin: model.data(index, ProjectsModel.ProjectIsMergin)
projectRemoteError: model.data(index, ProjectsModel.ProjectRemoteError) ? model.data(index, ProjectsModel.ProjectRemoteError) : ""
property string projectFilePath: model.data(index, ProjectsModel.ProjectFilePath)

onOpenRequested: {
if ( model.ProjectIsLocal )
root.openProjectRequested( model.ProjectFilePath )
else if ( !model.ProjectIsLocal && model.ProjectIsMergin && !model.ProjectSyncPending) {
downloadProjectDialog.relatedProjectId = model.ProjectId
downloadProjectDialog.open()
if ( projectIsLocal )
root.openProjectRequested( projectFilePath )
else if ( !projectIsLocal && projectIsMergin && !projectSyncPending) {
projectlist.downloadProjectDialog.relatedProjectId = projectId
projectlist.downloadProjectDialog.open()
}
}
onSyncRequested: controllerModel.syncProject( projectId )
onMigrateRequested: controllerModel.migrateProject( projectId )
onSyncRequested: projectlist.projectsModel.syncProject( projectId )
onMigrateRequested: projectlist.projectsModel.migrateProject( projectId )
onRemoveRequested: {
removeDialog.relatedProjectId = projectId
removeDialog.open()
}
onStopSyncRequested: controllerModel.stopProjectSync( projectId )
onStopSyncRequested: projectlist.projectsModel.stopProjectSync( projectId )
onShowChangesRequested: root.showLocalChangesRequested( projectId )
}
}

Item { width: 1; height: 40 * __dp }

Text {
width: parent.width
height: 31 * __dp
text: qsTr("Downloaded projects")
font: __style.p6
color: __style.nightColor
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Item { width: 1; height: 40 * __dp }

Text {
width: parent.width
height: 31 * __dp
text: qsTr("Downloaded projects")
font: __style.p6
color: __style.nightColor
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}

MMLine {}
MMLine {}

Item { width: 1; height: 20 * __dp }
Item { width: 1; height: 20 * __dp }
}
}

MMProjectList {
Expand All @@ -173,12 +155,12 @@ Item {
searchText: searchBar.text
spacing: root.spacing

listHeader: activeProjectComponent

anchors {
left: parent.left
right: parent.right
top: {
if( currentProjectColumn.visible )
return currentProjectColumn.bottom
if( warningBubble.visible )
return warningBubble.bottom
return searchBar.bottom
Expand Down
2 changes: 1 addition & 1 deletion app/qml/project/MMProjectItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Rectangle {

color: root.highlight ? __style.forestColor : __style.whiteColor
radius: 12 * __dp
height: mainColumn.height
height: visible ? mainColumn.height : 0

MouseArea {
anchors.fill: parent
Expand Down
77 changes: 35 additions & 42 deletions app/qml/project/MMProjectList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Item {
property string searchText: ""
property int spacing: 0
property bool hideActiveProject: false
property alias projectsProxyModel: viewModel
property alias projectsModel: controllerModel
property alias listHeader: listview.header
property alias listFooter: listview.footer

signal openProjectRequested( string projectFilePath )
signal showLocalChangesRequested( string projectId )
Expand All @@ -47,7 +51,7 @@ Item {
Component.onCompleted: {
// set proper footer (add project / fetch more)
if ( root.projectModelType === ProjectsModel.LocalProjectsModel ) {
addProjectButton.addToPanel = true
listview.footer = addProjectComponent
}
else
{
Expand Down Expand Up @@ -131,20 +135,31 @@ Item {
}
}

MMButton {
id: addProjectButton
property bool addToPanel: false
width: parent.width - 2 * __style.pageMargins
anchors.bottom: parent.bottom
anchors.bottomMargin: __style.pageMargins
anchors.horizontalCenter: parent.horizontalCenter
visible: addToPanel && (listview.count > 0)
text: qsTr("Create project")
onClicked: stackView.push(projectWizardComp)
}
Component {
id: addProjectComponent

Column {
width: ListView.view.width

Item {
Item {
width: parent.width
height: root.spacing
}

MMButton {
width: parent.width
text: qsTr("Create project")
onClicked: stackView.push(projectWizardComp)
}

Item {
width: parent.width
height: root.spacing
}
}
}

MMMessage {
id: noLocalProjectsMessageContainer

visible: listview.count === 0 && // this check is getting longer and longer, would be good to replace with states
Expand All @@ -154,35 +169,13 @@ Item {

anchors.fill: parent

ColumnLayout {
id: colayout

anchors.fill: parent
spacing: 0

MMMessage {
id: noLocalProjectsText

Layout.fillHeight: true
Layout.fillWidth: true

image: __style.positiveMMSymbolImage
title: qsTr( "No downloaded projects found")
description: "<style>a:link { color: " + __style.forestColor + "; }</style>" +
qsTr( "Learn %1how to create projects%2 and %3download them%2 onto your device. You can also create new project by clicking button below." )
.arg("<a href='"+ __inputHelp.howToCreateNewProjectLink +"'>")
.arg("</a>")
.arg("<a href='"+ __inputHelp.howToDownloadProjectLink +"'>")
}

MMButton {
id: createdProjectsWhenNone
Layout.fillWidth: true
text: qsTr("Create project")

onClicked: stackView.push(projectWizardComp)
}
}
image: __style.positiveMMSymbolImage
title: qsTr( "No downloaded projects found")
description: "<style>a:link { color: " + __style.forestColor + "; }</style>" +
qsTr( "Learn %1how to create projects%2 and %3download them%2 onto your device. You can also create new project by clicking button below." )
.arg("<a href='"+ __inputHelp.howToCreateNewProjectLink +"'>")
.arg("</a>")
.arg("<a href='"+ __inputHelp.howToDownloadProjectLink +"'>")
}

MMMessage {
Expand Down

1 comment on commit 48b6bdc

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.03.538411 just submitted!

Please sign in to comment.