Skip to content

Commit

Permalink
all XML code removed + fix with iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
TimVanMourik committed Jun 19, 2017
1 parent 25ec013 commit e181a7c
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Porcupine.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

ROOT = $$_PRO_FILE_PWD_

QT += widgets core gui xmlpatterns xml printsupport
QT += widgets core gui printsupport

CONFIG += static

Expand Down
3 changes: 0 additions & 3 deletions include/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
//----------------------------------------------------------------------------------------------------------------------

#include <QMainWindow>
#include <QtXmlPatterns>

namespace Ui {
class MainWindow;
Expand Down Expand Up @@ -155,8 +154,6 @@ public slots:

/// @brief
QVector<QAction*> m_nodeActs;
/// @brief
QXmlSchemaValidator* m_nodeValidator;
};

#endif // MAINWINDOW_H
7 changes: 0 additions & 7 deletions include/NodeEditor/PortPair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ class PortPair : public QGraphicsTextItem
qreal _height
);
//
void loadFromXml(
QDomElement& _xmlNode,
QMap<quint64, Port*>& o_portMap
);
//
const QString& getFileName(
) const;
//
Expand Down Expand Up @@ -149,8 +144,6 @@ public slots:
//
bool m_secret;
//
bool m_isIterator;
//
Port* m_input;
//
Port* m_output;
Expand Down
9 changes: 9 additions & 0 deletions include/Settings/Argument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Argument
bool isVisible(
) const;
//
bool isIterator(
) const;
//
void setName(
const QString& _name
);
Expand All @@ -60,6 +63,10 @@ class Argument
bool _editable
);
//
void setIterator(
bool _iterator
);
//
const QString& getName(
) const;
//
Expand Down Expand Up @@ -94,6 +101,8 @@ class Argument
//
bool m_isVisible;
//
bool m_isIterator;
//
QJsonObject m_json;
//
QString m_argumentName;
Expand Down
2 changes: 0 additions & 2 deletions include/Settings/NodeLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@

#include <map>

#include <QDomDocument>
#include <QString>
#include <QtXmlPatterns>

#include "Singleton.hpp"

Expand Down
7 changes: 4 additions & 3 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
#include <QApplication>
#include <QBoxLayout>
#include <QContextMenuEvent>
#include <QDomDocument>
#include <QFile>
#include <QFileDialog>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QJsonObject>
#include <QJsonDocument>
#include <QMenuBar>
#include <QPainter>
#include <QPrinter>
Expand Down Expand Up @@ -291,15 +292,15 @@ void MainWindow::printFile(
QString fileName = QFileDialog::getSaveFileName();
if (fileName.isEmpty())
{
qDebug() << "No file name was chosen. Ergo, no file will be saved.";
// qDebug() << "No file name was chosen. Ergo, no file will be saved.";
return;
}
printer.setOutputFileName(fileName);

QPainter painter;
if(!painter.begin(&printer))
{
qDebug() << "Error setting up printer.";
// qDebug() << "Error setting up printer.";
return;
}
painter.setRenderHint(QPainter::TextAntialiasing);
Expand Down
1 change: 0 additions & 1 deletion src/NodeEditor/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <assert.h>

#include <QDomDocument>
#include <QJsonObject>
#include <QGraphicsScene>
#include <QPainter>
Expand Down
4 changes: 3 additions & 1 deletion src/NodeEditor/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@

#include <assert.h>

#include <QDomDocument>
#include <QGraphicsItem>
#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QLineEdit>
#include <QLinearGradient>

Expand Down
2 changes: 0 additions & 2 deletions src/NodeEditor/NodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include <iostream>

#include <QDomDocument>
#include <QDomElement>
#include <QJsonArray>
#include <QPainter>
#include <QPointF>
Expand Down
1 change: 0 additions & 1 deletion src/NodeEditor/Port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <assert.h>

#include <QDomDocument>
#include <QFont>
#include <QGraphicsItem>
#include <QGraphicsScene>
Expand Down
28 changes: 2 additions & 26 deletions src/NodeEditor/PortPair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "assert.h"

#include <QDomDocument>

#include "Argument.hpp"
#include "Node.hpp"
#include "Port.hpp"
Expand Down Expand Up @@ -251,28 +249,6 @@ bool PortPair::hasNodeAncestor(
return false;
}

void PortPair::loadFromXml(
QDomElement& _xmlNode,
QMap<quint64, Port*>& o_portMap
)
{
QDomNode portNode = _xmlNode.firstChild();
while(!portNode.isNull())
{
QDomElement portElement = portNode.toElement();
if(portElement.attribute("type").compare("input") == 0)
{
o_portMap[(quint64) portElement.attribute("identifier").toULongLong(0, 16)] = m_input;
}
else if(portElement.attribute("type").compare("output") == 0)
{
o_portMap[(quint64) portElement.attribute("identifier").toULongLong(0, 16)] = m_output;
}
// Argument* argument = new Argument(portElement.attribute("name"), d);
portNode = portNode.nextSibling();
}
}

void PortPair::fileNameChanged(
const QString& _fileName,
bool _cascadeUp
Expand Down Expand Up @@ -322,7 +298,7 @@ void PortPair::setAsIterator(
bool _iterator
)
{
m_isIterator = _iterator;
m_argument.setIterator(_iterator);
}

const QString& PortPair::getFileName(
Expand All @@ -334,7 +310,7 @@ const QString& PortPair::getFileName(
bool PortPair::isIterator(
) const
{
return m_isIterator;
return m_argument.isIterator();
}

PortPair::~PortPair()
Expand Down
4 changes: 1 addition & 3 deletions src/NodeTreeEditor/NodeTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <QApplication>
#include <QComboBox>
#include <QCheckBox>
#include <QDomDocument>
#include <QDrag>
#include <QDropEvent>
#include <QFormLayout>
Expand Down Expand Up @@ -122,12 +121,11 @@ NodeTreeItem::NodeTreeItem(
if(pair->getInputPort())
{
QCheckBox* iterateCheckbox = new QCheckBox();
iterateCheckbox->setChecked(false);
QFile fileIterator(":/qss/iterator_button.qss");
fileIterator.open(QFile::ReadOnly);
QString styleSheetIterator = QString::fromLatin1(fileIterator.readAll());
iterateCheckbox->setStyleSheet(styleSheetIterator);
if(pair->isIterator())
if(pair->getArgument().isIterator())
{
iterateCheckbox->setChecked(true);
}
Expand Down
26 changes: 20 additions & 6 deletions src/Settings/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
Argument::Argument(
const QJsonObject& _json
) :
m_isInput (_json["input" ].toBool()),
m_isOutput (_json["output" ].toBool()),
m_isVisible (_json["visible"].toBool()),
m_argumentName(_json["name" ].toString()),
m_defaultValue(_json["value" ].toString()),
m_json(_json)
m_isInput (_json["input" ].toBool()),
m_isOutput (_json["output" ].toBool()),
m_isVisible (_json["visible" ].toBool()),
m_isIterator (_json["iterator"].toBool()),
m_json(_json),
m_argumentName(_json["name" ].toString()),
m_defaultValue(_json["value" ].toString())
{
foreach (QJsonValue code, _json["code"].toArray())
{
Expand Down Expand Up @@ -70,6 +71,12 @@ bool Argument::isVisible(
return m_isVisible;
}

bool Argument::isIterator(
) const
{
return m_isIterator;
}

void Argument::setDefault(
const QString& _default
)
Expand All @@ -84,6 +91,13 @@ void Argument::setVisible(
m_isVisible = _editable;
}

void Argument::setIterator(
bool _iterator
)
{
m_isIterator = _iterator;
}

const QString& Argument::getName(
) const
{
Expand Down
6 changes: 5 additions & 1 deletion src/Settings/NodeLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

#include <iostream>
#include <cstring>
#include <QDomDocument>

#include <QFile>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>

#include "Argument.hpp"
#include "NodeLibrary.hpp"
Expand Down

0 comments on commit e181a7c

Please sign in to comment.