Browse Source

editor loading bugs fixed

cl-refactor
arkpar 10 years ago
parent
commit
dd9b069882
  1. 1
      mix/qml/Application.qml
  2. 52
      mix/qml/CodeEditorView.qml
  3. 2
      mix/qml/ProjectModel.qml
  4. 2
      mix/qml/WebCodeEditor.qml
  5. 3
      mix/qml/js/ProjectModel.js
  6. 8
      mix/test/qml/TestMain.qml
  7. 1
      mix/test/qml/js/TestDebugger.js

1
mix/qml/Application.qml

@ -29,6 +29,7 @@ ApplicationWindow {
property alias clientModel: clientModel;
property alias projectModel: projectModel;
property alias appService: appService;
property bool trackLastProject: true;
ApplicationService {
id: appService

52
mix/qml/CodeEditorView.qml

@ -46,31 +46,36 @@ Item {
else
{
editorListModel.set(openDocCount, document);
editors.itemAt(openDocCount).visible = true;
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount))
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount), false)
loadComplete();
}
openDocCount++;
}
function doLoadDocument(editor, document) {
function doLoadDocument(editor, document, create) {
var data = fileIo.readFile(document.path);
editor.onLoadComplete.connect(function() {
loadComplete();
});
editor.onEditorTextChanged.connect(function() {
documentEdit(document.documentId);
if (document.isContract)
codeModel.registerCodeChange(document.documentId, editor.getText());
});
editor.onBreakpointsChanged.connect(function() {
if (document.isContract)
breakpointsChanged(document.documentId);
});
editor.setText(data, document.syntaxMode);
editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, document.documentId);
});
if (create)
{
editor.onLoadComplete.connect(function() {
codeEditorView.loadComplete();
});
editor.onEditorTextChanged.connect(function() {
documentEdit(editor.document.documentId);
if (editor.document.isContract)
codeModel.registerCodeChange(editor.document.documentId, editor.getText());
});
editor.onBreakpointsChanged.connect(function() {
if (editor.document.isContract)
breakpointsChanged(editor.document.documentId);
});
editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, editor.document.documentId);
});
}
editor.document = document;
editor.sourceName = document.documentId;
editor.setText(data, document.syntaxMode);
editor.changeGeneration();
}
function getEditor(documentId) {
@ -192,9 +197,6 @@ Item {
}
onProjectClosed: {
for (var i = 0; i < editorListModel.count; i++)
editors.itemAt(i).visible = false;
//editorListModel.clear();
currentDocumentId = "";
openDocCount = 0;
}
@ -234,7 +236,7 @@ Item {
property variant item
property variant doc
onYes: {
doLoadDocument(item, doc);
doLoadDocument(item, doc, false);
resetEditStatus(doc.documentId);
}
}
@ -251,7 +253,7 @@ Item {
asynchronous: true
anchors.fill: parent
source: appService.haveWebEngine ? "WebCodeEditor.qml" : "CodeEditor.qml"
visible: (index >= 0 && index < editorListModel.count && currentDocumentId === editorListModel.get(index).documentId)
visible: (index >= 0 && index < openDocCount && currentDocumentId === editorListModel.get(index).documentId)
property bool changed: false
onVisibleChanged: {
loadIfNotLoaded()
@ -271,7 +273,7 @@ Item {
loadIfNotLoaded()
}
onLoaded: {
doLoadDocument(loader.item, editorListModel.get(index))
doLoadDocument(loader.item, editorListModel.get(index), true)
}
Connections

2
mix/qml/ProjectModel.qml

@ -76,7 +76,7 @@ Item {
Connections {
target: mainApplication
onLoaded: {
if (projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
if (mainApplication.trackLastProject && projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
projectModel.loadProject(projectSettings.lastProjectPath)
}
}

2
mix/qml/WebCodeEditor.qml

@ -18,6 +18,7 @@ Item {
property bool unloaded: false
property var currentBreakpoints: []
property string sourceName
property var document
function setText(text, mode) {
currentText = text;
@ -117,6 +118,7 @@ Item {
codeModel.onCompilationError.connect(compilationError);
}
parent.changeGeneration();
loadComplete();
}
}

3
mix/qml/js/ProjectModel.js

@ -124,7 +124,8 @@ function loadProject(path) {
for(var i = 0; i < projectData.files.length; i++) {
addFile(projectData.files[i]);
}
projectSettings.lastProjectPath = path;
if (mainApplication.trackLastProject)
projectSettings.lastProjectPath = path;
projectLoading(projectData);
projectLoaded()

8
mix/test/qml/TestMain.qml

@ -30,18 +30,20 @@ TestCase
Application
{
id: mainApplication
trackLastProject: false
}
function newProject()
{
waitForRendering(mainApplication.mainContent, 10000);
mainApplication.projectModel.createProject();
var projectDlg = mainApplication.projectModel.newProjectDialog;
wait(30);
projectDlg.projectTitle = "TestProject";
projectDlg.pathFieldText = "/tmp/MixTest"; //TODO: get platform temp path
projectDlg.acceptAndClose();
wait(30);
wait(1);
if (!ts.waitForSignal(mainApplication.codeModel, "compilationComplete()", 5000))
fail("new contract not compiled");
}
function editContract(c)
@ -55,7 +57,7 @@ TestCase
function editHtml(c)
{
mainApplication.projectModel.openDocument("index.html");
wait(1);
ts.waitForSignal(mainApplication.mainContent.codeEditor, "loadComplete()", 5000);
mainApplication.mainContent.codeEditor.getEditor("index.html").setText(c);
ts.keyPressChar(mainApplication, "S", Qt.ControlModifier, 200); //Ctrl+S
}

1
mix/test/qml/js/TestDebugger.js

@ -75,7 +75,6 @@ function test_constructorParameters()
ts.typeString("442", transactionDialog);
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.model.addTransaction();
ts.waitForRendering(transactionDialog, 3000);
transactionDialog.selectFunction("getZ");
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();

Loading…
Cancel
Save