Browse Source

editor loading bugs fixed

cl-refactor
arkpar 10 years ago
parent
commit
dd9b069882
  1. 1
      mix/qml/Application.qml
  2. 36
      mix/qml/CodeEditorView.qml
  3. 2
      mix/qml/ProjectModel.qml
  4. 2
      mix/qml/WebCodeEditor.qml
  5. 1
      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 clientModel: clientModel;
property alias projectModel: projectModel; property alias projectModel: projectModel;
property alias appService: appService; property alias appService: appService;
property bool trackLastProject: true;
ApplicationService { ApplicationService {
id: appService id: appService

36
mix/qml/CodeEditorView.qml

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

2
mix/qml/ProjectModel.qml

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

2
mix/qml/WebCodeEditor.qml

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

1
mix/qml/js/ProjectModel.js

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

8
mix/test/qml/TestMain.qml

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

Loading…
Cancel
Save