Skip to content

Commit 7701e37

Browse files
committed
format
1 parent 55200a1 commit 7701e37

File tree

11 files changed

+361
-499
lines changed

11 files changed

+361
-499
lines changed

examples/plugin_text/PluginDefinition.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22

33
#include "TextModel.hpp"
44

5-
Plugin* Plugin::_this_plugin = nullptr;
5+
Plugin *Plugin::_this_plugin = nullptr;
66

7-
Plugin::
8-
Plugin()
9-
{ _this_plugin = this; }
7+
Plugin::Plugin()
8+
{
9+
_this_plugin = this;
10+
}
1011

11-
Plugin::
12-
~Plugin()
12+
Plugin::~Plugin()
1313
{
14-
// TODO: Unregister all models here
14+
// TODO: Unregister all models here
1515
}
1616

17-
void
18-
Plugin::
19-
registerDataModels(std::shared_ptr<QtNodes::NodeDelegateModelRegistry> & reg)
17+
void Plugin::registerDataModels(std::shared_ptr<QtNodes::NodeDelegateModelRegistry> &reg)
2018
{
21-
assert(reg);
19+
assert(reg);
2220

23-
reg->registerModel<TextModel>();
21+
reg->registerModel<TextModel>();
2422
}

examples/plugin_text/PluginDefinition.hpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@
1313

1414
#define PLUGIN_NAME "pluginText"
1515

16-
class DLL_EXPORT Plugin
17-
: public QObject
18-
, public QtNodes::PluginInterface
16+
class DLL_EXPORT Plugin : public QObject, public QtNodes::PluginInterface
1917
{
20-
Q_OBJECT
21-
Q_INTERFACES(QtNodes::PluginInterface)
22-
Q_PLUGIN_METADATA(IID PLUGIN_NAME)
18+
Q_OBJECT
19+
Q_INTERFACES(QtNodes::PluginInterface)
20+
Q_PLUGIN_METADATA(IID PLUGIN_NAME)
2321

2422
public:
25-
Plugin();
26-
~Plugin();
23+
Plugin();
24+
~Plugin();
2725

28-
QString
29-
name() const override
30-
{ return PLUGIN_NAME; };
26+
QString name() const override { return PLUGIN_NAME; };
3127

32-
void
33-
registerDataModels(std::shared_ptr<QtNodes::NodeDelegateModelRegistry> & reg) override;
28+
void registerDataModels(std::shared_ptr<QtNodes::NodeDelegateModelRegistry> &reg) override;
3429

3530
private:
36-
static Plugin* _this_plugin;
31+
static Plugin *_this_plugin;
3732
};

examples/plugin_text/TextData.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ using QtNodes::NodeDataType;
1010
class TextData : public NodeData
1111
{
1212
public:
13+
TextData() {}
1314

14-
TextData() {}
15+
TextData(QString const &text)
16+
: _text(text)
17+
{}
1518

16-
TextData(QString const &text)
17-
: _text(text)
18-
{}
19+
NodeDataType type() const override { return NodeDataType{"text", "Text"}; }
1920

20-
NodeDataType type() const override
21-
{ return NodeDataType {"text", "Text"}; }
22-
23-
QString text() const { return _text; }
21+
QString text() const { return _text; }
2422

2523
private:
26-
27-
QString _text;
24+
QString _text;
2825
};

examples/plugin_text/TextModel.cpp

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,68 @@
22

33
#include <QtWidgets/QTextEdit>
44

5-
TextModel::
6-
TextModel()
5+
TextModel::TextModel()
76
{
8-
//
7+
//
98
}
109

11-
12-
unsigned int
13-
TextModel::
14-
nPorts(PortType portType) const
10+
unsigned int TextModel::nPorts(PortType portType) const
1511
{
16-
unsigned int result = 1;
12+
unsigned int result = 1;
1713

18-
switch (portType)
19-
{
14+
switch (portType) {
2015
case PortType::In:
21-
result = 1;
22-
break;
16+
result = 1;
17+
break;
2318

2419
case PortType::Out:
25-
result = 1;
20+
result = 1;
2621

2722
default:
28-
break;
29-
}
23+
break;
24+
}
3025

31-
return result;
26+
return result;
3227
}
3328

34-
35-
void
36-
TextModel::
37-
onTextEdited()
29+
void TextModel::onTextEdited()
3830
{
39-
Q_EMIT dataUpdated(0);
31+
Q_EMIT dataUpdated(0);
4032
}
4133

42-
43-
NodeDataType
44-
TextModel::
45-
dataType(PortType, PortIndex) const
34+
NodeDataType TextModel::dataType(PortType, PortIndex) const
4635
{
47-
return TextData().type();
36+
return TextData().type();
4837
}
4938

50-
51-
std::shared_ptr<NodeData>
52-
TextModel::
53-
outData(PortIndex const portIndex)
39+
std::shared_ptr<NodeData> TextModel::outData(PortIndex const portIndex)
5440
{
55-
Q_UNUSED(portIndex);
56-
return std::make_shared<TextData>(_textEdit->toPlainText());
41+
Q_UNUSED(portIndex);
42+
return std::make_shared<TextData>(_textEdit->toPlainText());
5743
}
5844

59-
60-
QWidget *
61-
TextModel::
62-
embeddedWidget()
45+
QWidget *TextModel::embeddedWidget()
6346
{
64-
if (!_textEdit)
65-
{
66-
_textEdit = new QTextEdit();
67-
68-
connect(_textEdit, &QTextEdit::textChanged,
69-
this, &TextModel::onTextEdited);
47+
if (!_textEdit) {
48+
_textEdit = new QTextEdit();
7049

71-
}
50+
connect(_textEdit, &QTextEdit::textChanged, this, &TextModel::onTextEdited);
51+
}
7252

73-
return _textEdit;
53+
return _textEdit;
7454
}
7555

76-
77-
void
78-
TextModel::
79-
setInData(std::shared_ptr<NodeData> data, PortIndex const)
56+
void TextModel::setInData(std::shared_ptr<NodeData> data, PortIndex const)
8057
{
81-
auto textData = std::dynamic_pointer_cast<TextData>(data);
58+
auto textData = std::dynamic_pointer_cast<TextData>(data);
8259

83-
QString inputText;
60+
QString inputText;
8461

85-
if (textData)
86-
{
87-
inputText = textData->text();
88-
}
89-
else
90-
{
91-
inputText = "";
92-
}
62+
if (textData) {
63+
inputText = textData->text();
64+
} else {
65+
inputText = "";
66+
}
9367

94-
_textEdit->setText(inputText);
68+
_textEdit->setText(inputText);
9569
}
96-

examples/plugin_text/TextModel.hpp

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,48 @@
88

99
#include <iostream>
1010

11-
using QtNodes::PortType;
12-
using QtNodes::PortIndex;
1311
using QtNodes::NodeData;
1412
using QtNodes::NodeDelegateModel;
13+
using QtNodes::PortIndex;
14+
using QtNodes::PortType;
1515

1616
class QTextEdit;
1717

1818
/// The model dictates the number of inputs and outputs for the Node.
1919
/// In this example it has no logic.
2020
class TextModel : public NodeDelegateModel
2121
{
22-
Q_OBJECT
22+
Q_OBJECT
2323

2424
public:
25-
TextModel();
25+
TextModel();
2626

2727
public:
28-
QString
29-
caption() const override
30-
{ return QString("Text"); }
28+
QString caption() const override { return QString("Text"); }
3129

32-
bool
33-
captionVisible() const override { return true; }
30+
bool captionVisible() const override { return true; }
3431

35-
static QString
36-
Name()
37-
{ return QString("TextModel"); }
32+
static QString Name() { return QString("TextModel"); }
3833

39-
QString
40-
name() const override
41-
{ return TextModel::Name(); }
34+
QString name() const override { return TextModel::Name(); }
4235

4336
public:
44-
unsigned int
45-
nPorts(PortType portType) const override;
37+
unsigned int nPorts(PortType portType) const override;
4638

47-
NodeDataType
48-
dataType(PortType portType, PortIndex portIndex) const override;
39+
NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
4940

50-
std::shared_ptr<NodeData>
51-
outData(PortIndex const portIndex) override;
41+
std::shared_ptr<NodeData> outData(PortIndex const portIndex) override;
5242

53-
void
54-
setInData(std::shared_ptr<NodeData>, PortIndex const) override;
43+
void setInData(std::shared_ptr<NodeData>, PortIndex const) override;
5544

56-
QWidget *
57-
embeddedWidget() override;
45+
QWidget *embeddedWidget() override;
5846

59-
bool
60-
resizable() const override { return true; }
47+
bool resizable() const override { return true; }
6148

6249
private Q_SLOTS:
6350

64-
void
65-
onTextEdited();
51+
void onTextEdited();
6652

6753
private:
68-
QTextEdit * _textEdit = nullptr;
54+
QTextEdit *_textEdit = nullptr;
6955
};

0 commit comments

Comments
 (0)