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.
120 lines
3.4 KiB
120 lines
3.4 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
|
|
|
|
Item {
|
|
id: projectModel
|
|
|
|
signal projectClosed
|
|
signal projectLoaded(var projectData)
|
|
signal documentOpened(var document)
|
|
signal documentRemoved(var documentId)
|
|
signal documentUpdated(var documentId) //renamed
|
|
signal documentAdded(var documentId)
|
|
signal projectSaving(var projectData)
|
|
signal projectSaved()
|
|
signal newProject(var projectData)
|
|
signal documentSaved(var documentId)
|
|
|
|
property bool isEmpty: (projectPath === "")
|
|
readonly property string projectFileName: ".mix"
|
|
|
|
property bool haveUnsavedChanges: false
|
|
property string projectPath: ""
|
|
property string projectTitle: ""
|
|
property string currentDocumentId: ""
|
|
property var listModel: projectListModel
|
|
property var stateListModel: projectStateListModel.model
|
|
|
|
//interface
|
|
function saveAll() { ProjectModelCode.saveAll(); }
|
|
function createProject() { ProjectModelCode.createProject(); }
|
|
function browseProject() { ProjectModelCode.browseProject(); }
|
|
function closeProject() { ProjectModelCode.closeProject(); }
|
|
function saveProject() { ProjectModelCode.saveProject(); }
|
|
function loadProject(path) { ProjectModelCode.loadProject(path); }
|
|
function addExistingFile() { ProjectModelCode.addExistingFile(); }
|
|
function newHtmlFile() { ProjectModelCode.newHtmlFile(); }
|
|
function newJsFile() { ProjectModelCode.newJsFile(); }
|
|
//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 getDocumentIndex(documentId) { return ProjectModelCode.getDocumentIndex(documentId); }
|
|
|
|
Connections {
|
|
target: appContext
|
|
onAppLoaded: {
|
|
if (projectSettings.lastProjectPath)
|
|
projectModel.loadProject(projectSettings.lastProjectPath)
|
|
}
|
|
}
|
|
|
|
NewProjectDialog {
|
|
id: newProjectDialog
|
|
visible: false
|
|
onAccepted: {
|
|
var title = newProjectDialog.projectTitle;
|
|
var path = newProjectDialog.projectPath;
|
|
ProjectModelCode.doCreateProject(title, path);
|
|
}
|
|
}
|
|
|
|
MessageDialog {
|
|
id: saveMessageDialog
|
|
title: qsTr("Project")
|
|
text: qsTr("Do you want to save changes?")
|
|
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
icon: StandardIcon.Question
|
|
onAccepted: {
|
|
projectModel.saveAll();
|
|
ProjectModelCode.doCloseProject();
|
|
}
|
|
onRejected: {
|
|
ProjectModelCode.doCloseProject();
|
|
}
|
|
}
|
|
|
|
ListModel {
|
|
id: projectListModel
|
|
}
|
|
|
|
StateListModel {
|
|
id: projectStateListModel
|
|
}
|
|
|
|
Settings {
|
|
id: projectSettings
|
|
property string lastProjectPath;
|
|
}
|
|
|
|
FileDialog {
|
|
id: openProjectFileDialog
|
|
visible: false
|
|
title: qsTr("Open a Project")
|
|
selectFolder: true
|
|
onAccepted: {
|
|
var path = openProjectFileDialog.fileUrl.toString();
|
|
path += "/";
|
|
loadProject(path);
|
|
}
|
|
}
|
|
|
|
FileDialog {
|
|
id: addExistingFileDialog
|
|
visible: false
|
|
title: qsTr("Add a File")
|
|
selectFolder: false
|
|
onAccepted: {
|
|
var paths = addExistingFileDialog.fileUrls;
|
|
ProjectModelCode.doAddExistingFiles(paths);
|
|
}
|
|
}
|
|
}
|
|
|