Commit 00b06cf8 authored by Leander Schulten's avatar Leander Schulten
Browse files

Merge branch 'Zwischenstand' into CorotineLoopProgramm

Complete ProgramBlockEditor and add includePath Setting
parents 88be2896 74d5c700
......@@ -64,14 +64,443 @@ Item{
}
ProgramBlockEditor{
RowLayout{
anchors.left: page.right
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
programBlock: listView.currentItem.itemData;
ProgramBlockEditor{
anchors.top: parent.top
anchors.bottom: parent.bottom
Layout.fillWidth: true
id: programEditor
programBlock: listView.currentItem.itemData;
onShowPropertiesChanged: propertiesView.update()
onOpenRightClickEntry: {
rightClickMenu.x = x;
rightClickMenu.y = y;
rightClickMenu.open();
}
onAskToAddConnection: {
popup_addConnectionAsk.outputName = from
popup_addConnectionAsk.inputName = to
popup_addConnectionAsk.visible = true;
}
RoundButton{
id: button_run
checkable: true
checked: programEditor.run
onCheckedChanged: programEditor.run = checked
text: programEditor.run ? "Stop" : "Run"
width: 70
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.leftMargin: 15
}
RoundButton{
id:button_add_entry
text: "Add Entry"
anchors.bottom: parent.bottom
anchors.left: button_run.right
anchors.leftMargin: 15
onClicked: {
programEditor.updatePossibleEntries();
addEntry.visible = true;
}
}
RoundButton{
id:button_add_connection
text: "Add Connection"
anchors.bottom: parent.bottom
anchors.left: button_add_entry.right
anchors.leftMargin: 15
onClicked: {
programEditor.updateInputOutputModels();
popup_addConnection.visible = true;
}
}
RoundButton{
id:button_help
text: "Help"
anchors.bottom: parent.bottom
anchors.left: button_add_connection.right
anchors.leftMargin: 15
onClicked: {
popup_help.visible = true;
}
}
Menu{
id:rightClickMenu
width: 270
MenuItem{
id:firstItem
text: "Remove incoming Connections"
onClicked: programEditor.removeIncomingConnections();
}
MenuItem{
text: "Remove entry"
onClicked: programEditor.removeEntry()
}
}
}
ColumnLayout{
anchors.top: parent.top
anchors.bottom: parent.bottom
Layout.preferredWidth: 200
Layout.maximumWidth: 200
visible: programEditor.showProperties
spacing: 0
Rectangle{
id:line
color: "lightgrey"
width: 1
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: parent.bottom
}
id: propertyPane
Label{
id:label
Layout.margins: 8
font.pointSize: 16
text:"Properties"
}
Rectangle{
color: "lightgrey"
Layout.preferredHeight: 1
anchors.left: parent.left
anchors.right: parent.right
}
ListView{
clip:true
Layout.preferredHeight: 200
Layout.fillHeight: true
Layout.preferredWidth: parent.width
id: propertiesView
model: programEditor.propertyInformationModel
delegate: ItemDelegate{
property var itemData : modelData
width: parent.width
text: modelData.name
onClicked: propertiesView.currentIndex = index
}
highlightFollowsCurrentItem: true
highlight: Rectangle{
color: "lightgrey"
}
onCurrentItemChanged: update()
function update(){
if(propertiesView.currentIndex<0)
return;
var data = propertiesView.currentItem.itemData;
print("type : " + data.type)
if(data.type>=0&&data.type<=3){
slider.visible = true;
// Wenn die folgenden zwei zeilen fehlen, wird der value beim setzten auf die grenzen gesetzt und dann verändert
slider.to = 9999999999;
slider.from = -9999999999999;
slider.value = data.value;
slider.from = data.minValue;
slider.to = data.maxValue;
slider.stepSize = (data.type==0||data.type==1)?1:0;
slider.snapMode = (data.type==0||data.type==1)?Slider.SnapAlways:Slider.NoSnap;
print("stepSize : " + slider.stepSize)
}else{
if(data.type===4){
checkBox.checked = data.value
}
slider.visible = false;
}
checkBox.visible = data.type === 4;
}
}
Rectangle{
id:hline
color: "lightgrey"
Layout.preferredHeight: 1
anchors.left: parent.left
anchors.right: parent.right
}
ColumnLayout{
Label{
Layout.margins: 5
Layout.preferredHeight: contentHeight
Layout.preferredWidth: 190
clip:true
wrapMode: Text.WordWrap
text:propertiesView.currentItem.itemData.description
}
Slider{
id:slider
onValueChanged: {
propertiesView.currentItem.itemData.value = value;
print(propertiesView.currentItem.itemData.name + " set value to " + value)
}
Text{
text: slider.stepSize===0?slider.value.toFixed(2):slider.value.toFixed(0);
anchors.bottom: slider.handle.top
anchors.bottomMargin: 7
anchors.horizontalCenter: slider.handle.horizontalCenter
}
}
CheckBox{
id:checkBox
}
Rectangle{
height: 1
Layout.preferredWidth: 190
Layout.leftMargin: 5
color: "lightgrey"
}
CheckBox{
id:forward
text: "Forward property to user."
}
Label{
text: "Propertyname for the user:"
Layout.leftMargin: 10
color: forward.checked?"black":"grey"
}
TextInputField{
Layout.preferredWidth: 190
Layout.leftMargin: 10
Layout.bottomMargin: 10
enabled: forward.checked
color: forward.checked?"black":"grey"
}
}
}
}
Popup{
x: (parent.width - width) / 2
y: (parent.height - height) / 2
//modality: Qt.WindowModal
id:addEntry
//title: "Choose entry"
width:300
contentItem: RowLayout {
anchors.left: addEntry.left;
anchors.right: addEntry.right;
Layout.fillWidth: true
ColumnLayout{
Layout.fillWidth: true
ComboBox{
textRole: "display"
id:comboBoxEntry
Layout.fillWidth: true
model: programEditor.possibleEntryModel
}
RowLayout{
Label{
text:"Length/Size"
}
TextInputField{
Layout.fillWidth: true
id:text_size
text:"50"
validator: IntValidator{
bottom: 1
top: 1000
}
}
}
RowLayout{
Button{
Layout.fillWidth: true
text:"Cancel"
onClicked: addEntry.visible = false
}
Button{
Layout.fillWidth: true
text:"Create"
enabled: comboBoxEntry.currentIndex>=0 && text_size.text.length>0
onClicked: {
addEntry.visible = false;
programEditor.addEntry(comboBoxEntry.currentIndex,text_size.text)
}
}
}
}
}
}
Popup{
x: (parent.width - width) / 2
y: (parent.height - height) / 2
//modality: Qt.WindowModal
id:popup_addConnection
//title: "Choose entry"
width:300
contentItem: RowLayout {
anchors.left: popup_addConnection.left;
anchors.right: popup_addConnection.right;
Layout.fillWidth: true
ColumnLayout{
Layout.fillWidth: true
ComboBox{
textRole: "display"
id:comboBoxInput
Layout.fillWidth: true
model: programEditor.inputDataConsumerModel
}
RowLayout{
Label{
text:"Length/Size"
}
TextInputField{
Layout.fillWidth: true
id:connection_length
text:"50"
validator: IntValidator{
bottom: 0
top: 1000
}
}
}
ComboBox{
textRole: "display"
id:comboBoxOutput
Layout.fillWidth: true
model: programEditor.outputDataProducerModel
}
RowLayout{
Label{
text:"Startindex"
}
TextInputField{
Layout.fillWidth: true
id:connection_startIndex
text:"0"
validator: IntValidator{
bottom: 0
top: 1000
}
}
}
RowLayout{
Button{
Layout.fillWidth: true
text:"Cancel"
onClicked: popup_addConnection.visible = false
}
Button{
Layout.fillWidth: true
text:"Create"
enabled: comboBoxInput.currentIndex>=0 && connection_startIndex.text.length>0 && comboBoxOutput.currentIndex >= 0 && connection_length.text.length >= 0
onClicked: {
popup_addConnection.visible = false;
programEditor.addConnection(comboBoxInput.currentIndex,connection_length.text,comboBoxOutput.currentIndex,connection_startIndex.text);
}
}
}
}
}
}
Popup{
x: (parent.width - width) / 2
y: (parent.height - height) / 2
id: popup_help
contentItem: Label{
text:"Use drag and drop:<ul><li>Without Modifier to add a normal connection</li><li>With <i>Alt</i> to add Connections from a Entrie lower as the target</li><li>With <i>Shift</i> to move entries</li><li>With <i>Str</i> to move an entry temporarily</li></ul>"
wrapMode: "WordWrap"
width: 300
}
width: 500
}
Popup{
x: (parent.width - width) / 2
y: (parent.height - height) / 2
id: popup_addConnectionAsk
property string outputName
property string inputName
contentItem: ColumnLayout{
Label{
text:"Add a connection from the OutputDataProducer " + popup_addConnectionAsk.outputName + " to the InputDataConsumer " + popup_addConnectionAsk.inputName + "."
Layout.fillWidth: true
wrapMode: "WordWrap"
}
Label{
Layout.fillWidth: true
text: " Output Units will be taken from the OutputDataProducer"
wrapMode: "WordWrap"
TextInputField{
id: textInput_connectionWidth
width: 35
text:"50"
validator: IntValidator{
bottom: 1
top: 9999
}
anchors.left: parent.left
anchors.top: parent.top
font.pixelSize: parent.font.pixelSize
}
}
Label{
Layout.fillWidth: true
text: " is the index of the first Output Units in the array of output units of the OutputDataProducer"
wrapMode: "WordWrap"
TextInputField{
text:"0"
id: textInput_connectionStartIndex
width: 35
validator: IntValidator{
bottom: 0
top: 9999
}
anchors.left: parent.left
anchors.top: parent.top
font.pixelSize: parent.font.pixelSize
}
}
RowLayout{
Button{
Layout.fillWidth: true
text:"Cancel"
onClicked: popup_addConnectionAsk.visible = false
}
Button{
Layout.fillWidth: true
text:"Create"
enabled: textInput_connectionWidth.text.length>0 && textInput_connectionStartIndex.text.length > 0
onClicked: {
popup_addConnectionAsk.visible = false;
programEditor.addConnection(textInput_connectionWidth.text,textInput_connectionStartIndex.text);
}
}
}
}
contentWidth: 300
contentHeight: 220 // the normal implicitHeight is wrong
}
}
......@@ -22,6 +22,8 @@ Shape{
* <--- *
*/
startY: targetBaseline
strokeWidth: 0
strokeColor: "transparent"
PathLine{
id: topRight;
y: targetBaseline
......@@ -49,11 +51,11 @@ Shape{
}
}
MouseArea{
/*MouseArea{
x: (targetStartIndex + sourceStartIndex)/2
y: targetBaseline
width: (targetLength + sourceLength)/2
height: (sourceBaseline-targetBaseline)
onClicked: color = "red"
}
}*/
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import custom.licht 1.0
import Qt.labs.handlers 1.0
Label{
DragHandler { }
z: 10
clip: true
background: Rectangle{
color:"lightblue"
}
id:label
}
......@@ -66,7 +66,7 @@ Pane{
TextInputField{
Layout.fillWidth: true
text: Settings.moduleDirPath
onAccepted: Settings.moduleDirPath = text;
//onAccepted: Settings.moduleDirPath = text;
MouseArea{
anchors.fill: parent
onClicked: {
......@@ -78,6 +78,7 @@ Pane{
fileDialog.callback = function(file){
console.log(file);
Settings.moduleDirPath = file;
parent.text = file;
};
}
}
......@@ -110,6 +111,35 @@ Pane{
}
}
}
Label{
Layout.fillWidth: true
text: "Include Path:"
}
TextInputField{
Layout.fillWidth: true
text: Settings.includePath
onAccepted: Settings.includePath = text;
Button{
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: -5
anchors.bottomMargin: -5
anchors.bottom: parent.bottom
text: "File Chooser"
onClicked: {
fileDialog.selectFolder = true;
fileDialog.selectMultiple = false;
fileDialog.folder = Settings.includePath;
fileDialog.open();
fileDialog.addSelection(Settings.includePath);
fileDialog.callback = function(file){
console.log(file);
Settings.includePath = file;
};
}
}
}
Label{
Layout.fillWidth: true
text: "Compiler Flags:"
......
......@@ -404,11 +404,17 @@ void CodeEditorHelper::compile(){
stream << "}" << endl;
stream.flush();
file.close();
#ifdef Q_OS_WIN
auto result = Modules::Compiler::compileToLibrary(file,module->getName()+".dll");
#else
auto result = Modules::Compiler::compileToLibrary(file,module->getName()+".so");
#endif
if(result.first){
QFileInfo finfo = file;
emit information(result.second.replace(finfo.absoluteFilePath(),""));
}else
emit information("Compilieren erfolgreich.");
}else{
emit information("Cant open file : " + s.getModuleDirPath() + "/" + module->getName() + ".cpp");
}
}
......@@ -3,7 +3,7 @@
#include <vector>
#include <QAbstractListModel>
#include <QDebug>
#include <shared_ptr.hpp>
#include <memory>
namespace detail {
......@@ -54,6 +54,8 @@ class ModelVector : public QAbstractListModel{
}*/
public:
using const_iterator = typename std::vector<Type>::const_iterator;
enum{
ModelDataRole = Qt::UserRole+1,
};
......@@ -91,6 +93,12 @@ public:
model.erase(i);
endRemoveRows();
}
void erase(const_iterator first, const_iterator last){
const auto pos = std::distance(model.cbegin(),first);
beginRemoveRows(QModelIndex(),pos,pos + std::distance(first,last) -1);
model.erase(first,last);
endRemoveRows();
}
Type erase(int i){
Q_ASSERT(i>=0 && i < size());
beginRemoveRows(QModelIndex(),i,i);
......
This diff is collapsed.
......@@ -3,31 +3,261 @@
#include <QQuickItem>
#include "programms/programblock.h"
#include "programms/modulemanager.h"
#include <QStringListModel>
namespace detail {
class PropertyInformation : public QObject{
Q_OBJECT
public:
typedef Modules::Property::Type Type;
Q_ENUM(Type)
Modules::Property * property = nullptr;
// wenn dieses Feld ungleich 0 ist, dann wird hier die InputOutputLength gespeichert
Modules::PropertyBase * named = nullptr;
std::function<void()> updateCallback;
private:
void updateValue();
//auto generated class:
QVariant minValue;
QVariant maxValue;
QVariant value;
QString name;
QString description;