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.

226 lines
5.5 KiB

import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.3
import Qt.labs.settings 1.0
import "."
Item {
property bool renameMode: false;
10 years ago
property alias sections: sectionRepeater
ProjectFilesStyle {
id: projectFilesStyle
}
ColumnLayout {
anchors.fill: parent
id: filesCol
spacing: 0
SourceSansProLight
10 years ago
{
id: srcSansProLight
}
Rectangle
{
color: projectFilesStyle.title.background
height: projectFilesStyle.title.height
Layout.fillWidth: true
10 years ago
Image {
id: projectIcon
10 years ago
source: "qrc:/qml/img/dappProjectIcon.png"
10 years ago
anchors.right: projectTitle.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 6
10 years ago
fillMode: Image.PreserveAspectFit
width: 32
height: 32
10 years ago
}
Text
{
10 years ago
id: projectTitle
color: projectFilesStyle.title.color
text: projectModel.projectTitle
anchors.verticalCenter: parent.verticalCenter
visible: !projectModel.isEmpty;
anchors.left: parent.left
anchors.leftMargin: projectFilesStyle.general.leftMargin
10 years ago
font.family: srcSansProLight.name
font.pointSize: projectFilesStyle.title.fontSize
font.weight: Font.Light
10 years ago
}
Text
{
text: "-"
anchors.right: parent.right
anchors.rightMargin: 15
font.family: srcSansProLight.name
font.pointSize: projectFilesStyle.title.fontSize
10 years ago
anchors.verticalCenter: parent.verticalCenter
font.weight: Font.Light
}
}
Rectangle
{
Layout.fillWidth: true
height: 3
color: projectFilesStyle.documentsList.background
}
Rectangle
{
Layout.fillWidth: true
Layout.fillHeight: true
color: projectFilesStyle.documentsList.background
ColumnLayout
{
anchors.top: parent.top
width: parent.width
spacing: 0
Repeater {
model: [qsTr("Contracts"), qsTr("Javascript"), qsTr("Web Pages"), qsTr("Styles"), qsTr("Images"), qsTr("Misc")];
signal selected(string doc, string groupName)
signal isCleanChanged(string doc, string groupName, var isClean)
property int incr: -1;
id: sectionRepeater
FilesSection
{
id: section;
sectionName: modelData
index:
{
for (var k in sectionRepeater.model)
{
if (sectionRepeater.model[k] === modelData)
return k;
}
}
model: sectionModel
selManager: sectionRepeater
onDocumentSelected: {
selManager.selected(doc, groupName);
}
ListModel
{
id: sectionModel
}
Connections {
target: codeModel
onContractRenamed: {
if (modelData === "Contracts")
{
var ci = 0;
for (var si = 0; si < projectModel.listModel.count; si++) {
var document = projectModel.listModel.get(si);
if (document.isContract) {
var compiledDoc = codeModel.contractByDocumentId(document.documentId);
if (_documentId === document.documentId && _newName !== document.name) {
document.name = _newName;
projectModel.listModel.set(si, document);
sectionModel.set(ci, document);
}
ci++;
}
10 years ago
}
}
}
10 years ago
onCompilationComplete: {
if (modelData === "Contracts") {
var ci = 0;
for (var si = 0; si < projectModel.listModel.count; si++) {
var document = projectModel.listModel.get(si);
if (document.isContract) {
var compiledDoc = codeModel.contractByDocumentId(document.documentId);
if (compiledDoc && compiledDoc.documentId === document.documentId && compiledDoc.contract.name !== document.name) {
document.name = compiledDoc.contract.name;
projectModel.listModel.set(si, document);
sectionModel.set(ci, document);
}
ci++;
}
}
}
}
}
Connections {
id: projectModelConnection
target: projectModel
function addDocToSubModel()
{
for (var k = 0; k < projectModel.listModel.count; k++)
{
var item = projectModel.listModel.get(k);
if (item.groupName === modelData)
sectionModel.append(item);
}
}
onIsCleanChanged: {
for (var si = 0; si < sectionModel.count; si++) {
var document = sectionModel.get(si);
if (documentId === document.documentId && document.groupName === modelData)
{
selManager.isCleanChanged(documentId, modelData, isClean);
break;
}
}
}
onDocumentOpened: {
if (document.groupName === modelData)
sectionRepeater.selected(document.documentId, modelData);
}
onNewProject: {
sectionModel.clear();
}
onProjectClosed: {
sectionModel.clear();
}
onProjectLoaded: {
sectionModel.clear();
addDocToSubModel();
if (modelData === "Contracts")
{
var selItem = projectModel.listModel.get(0);
projectModel.openDocument(selItem.documentId);
sectionRepeater.selected(selItem.documentId, modelData);
}
}
onDocumentAdded:
{
10 years ago
var newDoc = projectModel.getDocument(documentId);
if (newDoc.groupName === modelData)
{
10 years ago
sectionModel.append(newDoc);
projectModel.openDocument(newDoc.documentId);
sectionRepeater.selected(newDoc.documentId, modelData);
}
}
}
}
}
}
}
}
}