You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
5.8 KiB

import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.1
import Qt.labs.settings 1.0
import "js/ProjectModel.js" as ProjectModelCode
10 years ago
import "js/NetworkDeployment.js" as NetworkDeploymentCode
Item {
id: projectModel
signal projectClosed
10 years ago
signal projectLoading(var projectData)
signal projectLoaded()
signal documentSaving(var document)
signal documentChanged(var documentId)
signal documentOpened(var document)
signal documentRemoved(var documentId)
signal documentUpdated(var documentId) //renamed
signal documentAdded(var documentId)
signal projectSaving()
signal projectFileSaving(var projectData)
signal projectSaved()
signal projectFileSaved()
10 years ago
signal newProject(var projectData)
signal documentSaved(var documentId)
signal contractSaved(var documentId)
10 years ago
signal deploymentStarted()
signal deploymentStepChanged(string message)
10 years ago
signal deploymentComplete()
signal deploymentError(string error)
signal isCleanChanged(var isClean, string documentId)
property bool isEmpty: (projectPath === "")
readonly property string projectFileName: ".mix"
10 years ago
property bool appIsClosing: false
10 years ago
property bool projectIsClosing: false
property string projectPath: ""
property string projectTitle: ""
property string currentDocumentId: ""
property var deploymentAddresses: []
property string deploymentDir
property var listModel: projectListModel
10 years ago
property var stateListModel: projectStateListModel.model
10 years ago
property alias stateDialog: projectStateListModel.stateDialog
property CodeEditorView codeEditor: null
property var unsavedFiles: []
property alias newProjectDialog: newProjectDialog
property string deployedState
//interface
function saveAll() { ProjectModelCode.saveAll(); }
function saveCurrentDocument() { ProjectModelCode.saveCurrentDocument(); }
function createProject() { ProjectModelCode.createProject(); }
10 years ago
function closeProject(callBack) { ProjectModelCode.closeProject(callBack); }
function saveProject() { ProjectModelCode.saveProject(); }
10 years ago
function saveProjectFile() { ProjectModelCode.saveProjectFile(); }
function loadProject(path) { ProjectModelCode.loadProject(path); }
function newHtmlFile() { ProjectModelCode.newHtmlFile(); }
function newJsFile() { ProjectModelCode.newJsFile(); }
function newCssFile() { ProjectModelCode.newCssFile(); }
function newContract() { ProjectModelCode.newContract(); }
function openDocument(documentId) { ProjectModelCode.openDocument(documentId); }
function openNextDocument() { ProjectModelCode.openNextDocument(); }
function openPrevDocument() { ProjectModelCode.openPrevDocument(); }
function renameDocument(documentId, newName) { ProjectModelCode.renameDocument(documentId, newName); }
function removeDocument(documentId) { ProjectModelCode.removeDocument(documentId); }
function getDocument(documentId) { return ProjectModelCode.getDocument(documentId); }
function getDocumentIdByName(documentName) { return ProjectModelCode.getDocumentIdByName(documentName); }
function getDocumentIndex(documentId) { return ProjectModelCode.getDocumentIndex(documentId); }
10 years ago
function addExistingFiles(paths) { ProjectModelCode.doAddExistingFiles(paths); }
10 years ago
function deployProject() { NetworkDeploymentCode.deployProject(false); }
function registerToUrlHint() { NetworkDeploymentCode.registerToUrlHint(); }
function formatAppUrl() { NetworkDeploymentCode.formatAppUrl(url); }
Connections {
target: mainApplication
onLoaded: {
if (mainApplication.trackLastProject && projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
projectModel.loadProject(projectSettings.lastProjectPath)
}
}
Connections {
target: codeEditor
onIsCleanChanged: {
for (var i in unsavedFiles)
{
if (unsavedFiles[i] === documentId && isClean)
unsavedFiles.splice(i, 1);
}
if (!isClean)
unsavedFiles.push(documentId);
isCleanChanged(isClean, documentId);
}
}
NewProjectDialog {
id: newProjectDialog
visible: false
onAccepted: {
var title = newProjectDialog.projectTitle;
var path = newProjectDialog.projectPath;
ProjectModelCode.doCreateProject(title, path);
}
}
Connections
{
target: fileIo
property bool saving: false
onFileChanged:
{
fileIo.watchFileChanged(_filePath);
var documentId = ProjectModelCode.getDocumentByPath(_filePath);
documentChanged(documentId);
}
}
MessageDialog {
id: saveMessageDialog
title: qsTr("Project")
text: qsTr("Some files require to be saved. Do you want to save changes?");
standardButtons: StandardButton.Yes | StandardButton.No | StandardButton.Cancel
icon: StandardIcon.Question
10 years ago
property var callBack;
onYes: {
10 years ago
projectIsClosing = true;
projectModel.saveAll();
10 years ago
unsavedFiles = [];
ProjectModelCode.doCloseProject();
if (callBack)
callBack();
}
onRejected: {}
onNo: {
10 years ago
projectIsClosing = true;
unsavedFiles = [];
ProjectModelCode.doCloseProject();
if (callBack)
callBack();
}
}
MessageDialog {
id: deployWarningDialog
title: qsTr("Project")
10 years ago
text:
{
if (Object.keys(projectModel.deploymentAddresses).length > 0)
10 years ago
return qsTr("This project has been already deployed to the network. Do you want to redeploy it? (Contract state will be reset)")
10 years ago
else
return qsTr("This action will deploy to the network. Do you want to deploy it?")
}
icon: StandardIcon.Question
standardButtons: StandardButton.Ok | StandardButton.Abort
onAccepted: {
10 years ago
NetworkDeploymentCode.startDeployProject(true);
10 years ago
}
}
MessageDialog {
id: deployResourcesDialog
10 years ago
title: qsTr("Project")
standardButtons: StandardButton.Ok
}
DeploymentDialog
{
id: deploymentDialog
}
ListModel {
id: projectListModel
}
10 years ago
StateListModel {
id: projectStateListModel
}
Connections
{
target: projectModel
onProjectClosed: {
projectPath = "";
}
}
Settings {
id: projectSettings
property string lastProjectPath;
}
}