diff --git a/src/icons/icons.qrc b/src/icons/icons.qrc
index 1ff153d1a..79bdffc17 100644
--- a/src/icons/icons.qrc
+++ b/src/icons/icons.qrc
@@ -52,6 +52,8 @@
images/clear_edit_16px@2x.png
images/clearbreakpoints_16px.png
images/clearbreakpoints_16px@2x.png
+ images/clone_16px.png
+ images/clone_16px@2x.png
images/cm_add_24px.png
images/cm_add_24px@2x.png
images/cm_diff_24px.png
diff --git a/src/icons/images/clone_16px.png b/src/icons/images/clone_16px.png
new file mode 100644
index 000000000..9cc80dafc
Binary files /dev/null and b/src/icons/images/clone_16px.png differ
diff --git a/src/icons/images/clone_16px@2x.png b/src/icons/images/clone_16px@2x.png
new file mode 100644
index 000000000..ac31d6e31
Binary files /dev/null and b/src/icons/images/clone_16px@2x.png differ
diff --git a/src/icons/svg/clone_16px.svg b/src/icons/svg/clone_16px.svg
new file mode 100644
index 000000000..c08c3d904
--- /dev/null
+++ b/src/icons/svg/clone_16px.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/src/lay/lay/TechSetupDialog.ui b/src/lay/lay/TechSetupDialog.ui
index 71b39a402..999b2810b 100644
--- a/src/lay/lay/TechSetupDialog.ui
+++ b/src/lay/lay/TechSetupDialog.ui
@@ -108,6 +108,9 @@
-
+
+ Add technology
+
...
@@ -116,12 +119,15 @@
:/add_16px.png:/add_16px.png
- true
+ false
-
+
+ Delete technology
+
...
@@ -130,33 +136,37 @@
:/clear_16px.png:/clear_16px.png
- true
+ false
-
-
+
+
+ Rename technology
+
+
+ Rename
+
+
+
+ :/rename_16px@2x.png:/rename_16px@2x.png
+
+
+
+ -
+
Qt::Horizontal
-
- QSizePolicy::Expanding
-
- 141
+ 40
20
- -
-
-
- Rename
-
-
-
diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h
index 422584323..451d2cf3f 100644
--- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h
+++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h
@@ -435,6 +435,16 @@ public:
m_symbols.clear ();
}
+ void clear_connections ()
+ {
+ m_connections.clear ();
+ }
+
+ void clear_symbols ()
+ {
+ m_symbols.clear ();
+ }
+
void erase (iterator p)
{
m_connections.erase (p);
@@ -524,7 +534,7 @@ public:
const_iterator end () const
{
- return m_connectivity.begin ();
+ return m_connectivity.end ();
}
iterator begin ()
diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerPlugin.cc b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerPlugin.cc
index ed67acd05..e9b442f7b 100644
--- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerPlugin.cc
+++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerPlugin.cc
@@ -68,26 +68,94 @@ namespace tl
namespace
{
-template
-struct FallbackXMLWriteAdapator
+static const db::NetTracerConnectivity *
+get_default (const db::NetTracerTechnologyComponent &tc)
{
- FallbackXMLWriteAdapator (void (db::NetTracerConnectivity::*member) (const Value &))
- : mp_member (member)
+ for (auto d = tc.begin (); d != tc.end (); ++d) {
+ if (d->name ().empty ()) {
+ return d.operator-> ();
+ }
+ }
+
+ if (tc.begin () != tc.end ()) {
+ return tc.begin ().operator-> ();
+ } else {
+ return 0;
+ }
+}
+
+template
+struct FallbackXMLWriteAdaptor
+{
+ FallbackXMLWriteAdaptor (void (db::NetTracerConnectivity::*member) (const Value &), void (db::NetTracerConnectivity::*clear) ())
+ : mp_member (member), mp_clear (clear), mp_stack (0)
{
// .. nothing yet ..
}
void operator () (db::NetTracerTechnologyComponent &owner, tl::XMLReaderState &reader) const
{
- if (owner.size () == 0) {
- owner.push_back (db::NetTracerConnectivity ());
+ if (! mp_stack) {
+ mp_stack = const_cast (get_default (owner));
+ if (! mp_stack) {
+ owner.push_back (db::NetTracerConnectivity ());
+ mp_stack = (owner.end () - 1).operator-> ();
+ }
+ (mp_stack->*mp_clear) ();
}
+
tl::XMLObjTag tag;
- ((*owner.begin ()).*mp_member) (*reader.back (tag));
+ (mp_stack->*mp_member) (*reader.back (tag));
}
private:
void (db::NetTracerConnectivity::*mp_member) (const Value &);
+ void (db::NetTracerConnectivity::*mp_clear) ();
+ mutable db::NetTracerConnectivity *mp_stack;
+};
+
+template
+struct FallbackXMLReadAdaptor
+{
+ typedef tl::pass_by_ref_tag tag;
+
+ FallbackXMLReadAdaptor (Iter (db::NetTracerConnectivity::*begin) () const, Iter (db::NetTracerConnectivity::*end) () const)
+ : mp_begin (begin), mp_end (end)
+ {
+ // .. nothing yet ..
+ }
+
+ Value operator () () const
+ {
+ return *m_iter;
+ }
+
+ bool at_end () const
+ {
+ return m_iter == m_end;
+ }
+
+ void start (const db::NetTracerTechnologyComponent &parent)
+ {
+ const db::NetTracerConnectivity *tn = get_default (parent);
+ if (! tn) {
+ m_iter = Iter ();
+ m_end = Iter ();
+ } else {
+ m_iter = (tn->*mp_begin) ();
+ m_end = (tn->*mp_end) ();
+ }
+ }
+
+ void next ()
+ {
+ ++m_iter;
+ }
+
+private:
+ Iter (db::NetTracerConnectivity::*mp_begin) () const;
+ Iter (db::NetTracerConnectivity::*mp_end) () const;
+ Iter m_iter, m_end;
};
}
@@ -113,20 +181,20 @@ public:
virtual tl::XMLElementBase *xml_element () const
{
return new db::TechnologyComponentXMLElement (net_tracer_component_name (),
- // Fallback readers for migrating pre-0.28 setups to 0.28
- tl::XMLMember, FallbackXMLWriteAdapator , tl::XMLStdConverter > (
- tl::XMLMemberDummyReadAdaptor (),
- FallbackXMLWriteAdapator (&NetTracerConnectivity::add), "connection") +
- tl::XMLMember, FallbackXMLWriteAdapator , tl::XMLStdConverter > (
- tl::XMLMemberDummyReadAdaptor (),
- FallbackXMLWriteAdapator (&NetTracerConnectivity::add_symbol), "symbols") +
// 0.28 definitions
- tl::make_element ((NetTracerTechnologyComponent::const_iterator (NetTracerTechnologyComponent::*) () const) &NetTracerTechnologyComponent::begin, (NetTracerTechnologyComponent::const_iterator (NetTracerTechnologyComponent::*) () const) &NetTracerTechnologyComponent::end, (void (NetTracerTechnologyComponent::*) (const NetTracerConnectivity &)) &NetTracerTechnologyComponent::push_back, "connectivity",
+ tl::make_element ((NetTracerTechnologyComponent::const_iterator (NetTracerTechnologyComponent::*) () const) &NetTracerTechnologyComponent::begin, (NetTracerTechnologyComponent::const_iterator (NetTracerTechnologyComponent::*) () const) &NetTracerTechnologyComponent::end, (void (NetTracerTechnologyComponent::*) (const NetTracerConnectivity &)) &NetTracerTechnologyComponent::push_back, "stack",
tl::make_member (&NetTracerConnectivity::name, &NetTracerConnectivity::set_name, "name") +
tl::make_member (&NetTracerConnectivity::description, &NetTracerConnectivity::set_description, "description") +
tl::make_member ((NetTracerConnectivity::const_iterator (NetTracerConnectivity::*) () const) &NetTracerConnectivity::begin, (NetTracerConnectivity::const_iterator (NetTracerConnectivity::*) () const) &NetTracerConnectivity::end, &NetTracerConnectivity::add, "connection") +
tl::make_member ((NetTracerConnectivity::const_symbol_iterator (NetTracerConnectivity::*) () const) &NetTracerConnectivity::begin_symbols, (NetTracerConnectivity::const_symbol_iterator (NetTracerConnectivity::*) () const) &NetTracerConnectivity::end_symbols, &NetTracerConnectivity::add_symbol, "symbols")
- )
+ ) +
+ // Fallback readers for migrating pre-0.28 setups to 0.28 and backward compatibility
+ tl::XMLMember, FallbackXMLWriteAdaptor , tl::XMLStdConverter > (
+ FallbackXMLReadAdaptor (&NetTracerConnectivity::begin, &NetTracerConnectivity::end),
+ FallbackXMLWriteAdaptor (&NetTracerConnectivity::add, &NetTracerConnectivity::clear_connections), "connection") +
+ tl::XMLMember, FallbackXMLWriteAdaptor , tl::XMLStdConverter > (
+ FallbackXMLReadAdaptor (&NetTracerConnectivity::begin_symbols, &NetTracerConnectivity::end_symbols),
+ FallbackXMLWriteAdaptor (&NetTracerConnectivity::add_symbol, &NetTracerConnectivity::clear_symbols), "symbols")
);
}
};
diff --git a/src/plugins/tools/net_tracer/lay_plugin/NetTracerTechComponentEditor.ui b/src/plugins/tools/net_tracer/lay_plugin/NetTracerTechComponentEditor.ui
index 825513c9f..15e3a6e16 100644
--- a/src/plugins/tools/net_tracer/lay_plugin/NetTracerTechComponentEditor.ui
+++ b/src/plugins/tools/net_tracer/lay_plugin/NetTracerTechComponentEditor.ui
@@ -20,6 +20,12 @@
Qt::Horizontal
+
+
+ 0
+ 0
+
+
QFrame::NoFrame
@@ -39,8 +45,11 @@
0
- -
+
-
+
+ Move selected stacks up
+
...
@@ -50,32 +59,24 @@
- -
-
+
-
+
+
+ Add new stack
+
...
- :/del_16px.png:/del_16px.png
+ :/add_16px.png:/add_16px.png
- Del
+ Return
- -
-
-
- ...
-
-
-
- :/up_16px.png:/up_16px.png
-
-
-
- -
+
-
QFrame::NoFrame
@@ -85,19 +86,7 @@
- -
-
-
-
- true
-
-
-
- Double-click to edit text
-
-
-
- -
+
-
@@ -105,9 +94,18 @@
1
+
+ Qt::ActionsContextMenu
+
+
+ QAbstractItemView::ExtendedSelection
+
false
+
+ true
+
Name
@@ -120,7 +118,50 @@
- -
+
-
+
+
+ Remove selected stacks
+
+
+ ...
+
+
+
+ :/del_16px.png:/del_16px.png
+
+
+ Del
+
+
+
+ -
+
+
+ Move selected stacks down
+
+
+ ...
+
+
+
+ :/up_16px.png:/up_16px.png
+
+
+
+ -
+
+
+
+ true
+
+
+
+ Double-click to edit text
+
+
+
+ -
Qt::Horizontal
@@ -133,24 +174,24 @@
- -
-
+
-
+
+
+ Technology Stacks
+
+
+
+ -
+
+
+ Clone current stack
+
...
- :/add_16px.png:/add_16px.png
-
-
- Return
-
-
-
- -
-
-
- Technology Stacks
+ :/clone_16px.png:/clone_16px.png
diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.cc
index 662f5e235..f2c19f968 100644
--- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.cc
+++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.cc
@@ -135,8 +135,20 @@ NetTracerTechComponentEditor::NetTracerTechComponentEditor (QWidget *parent)
{
Ui::NetTracerTechComponentEditor::setupUi (this);
+ QAction *action;
+ action = new QAction (QObject::tr ("Add Stack"), this);
+ connect (action, SIGNAL (triggered ()), this, SLOT (add_clicked ()));
+ stack_tree->addAction (action);
+ action = new QAction (QObject::tr ("Delete Selected Stacks"), this);
+ connect (action, SIGNAL (triggered ()), this, SLOT (delete_clicked ()));
+ stack_tree->addAction (action);
+ action = new QAction (QObject::tr ("Duplicate Stack"), this);
+ connect (action, SIGNAL (triggered ()), this, SLOT (clone_clicked ()));
+ stack_tree->addAction (action);
+
connect (add_pb, SIGNAL (clicked ()), this, SLOT (add_clicked ()));
connect (del_pb, SIGNAL (clicked ()), this, SLOT (del_clicked ()));
+ connect (clone_pb, SIGNAL (clicked ()), this, SLOT (clone_clicked ()));
connect (move_up_pb, SIGNAL (clicked ()), this, SLOT (move_up_clicked ()));
connect (move_down_pb, SIGNAL (clicked ()), this, SLOT (move_down_clicked ()));
@@ -154,6 +166,7 @@ NetTracerTechComponentEditor::commit ()
return;
}
+ commit_current ();
*data = m_data;
}
@@ -175,6 +188,11 @@ NetTracerTechComponentEditor::setup ()
stack_tree->setItemDelegateForColumn (1, new NetTracerTechComponentColumnDelegate (stack_tree, &m_data));
update ();
+
+ if (stack_tree->topLevelItemCount () > 0) {
+ stack_tree->setCurrentItem (stack_tree->topLevelItem (0));
+ }
+ current_item_changed (stack_tree->currentItem (), 0);
}
void
@@ -207,7 +225,47 @@ NetTracerTechComponentEditor::commit_current (QTreeWidgetItem *current)
}
}
-void
+static std::string
+new_name (const db::NetTracerTechnologyComponent &data)
+{
+ for (int i = 1; ; ++i) {
+ std::string n = "STACK" + tl::to_string (i);
+ bool found = false;
+ for (auto d = data.begin (); d != data.end () && ! found; ++d) {
+ found = (d->name () == n);
+ }
+ if (! found) {
+ return n;
+ }
+ }
+
+ return std::string ();
+}
+
+void
+NetTracerTechComponentEditor::clone_clicked ()
+{
+ // removes focus from the tree view - commits the data
+ add_pb->setFocus ();
+ commit_current ();
+
+ int row = stack_tree->currentItem () ? stack_tree->indexOfTopLevelItem (stack_tree->currentItem ()) : -1;
+ if (row < 0) {
+ m_data.push_back (db::NetTracerConnectivity ());
+ row = int (m_data.size () - 1);
+ } else {
+ row += 1;
+ m_data.insert (m_data.begin () + row, db::NetTracerConnectivity ());
+ m_data.begin ()[row] = m_data.begin ()[row - 1];
+ }
+
+ m_data.begin ()[row].set_name (new_name (m_data));
+
+ update ();
+ stack_tree->setCurrentItem (stack_tree->topLevelItem (row));
+}
+
+void
NetTracerTechComponentEditor::add_clicked ()
{
// removes focus from the tree view - commits the data
@@ -223,6 +281,8 @@ NetTracerTechComponentEditor::add_clicked ()
m_data.insert (m_data.begin () + row, db::NetTracerConnectivity ());
}
+ m_data.begin ()[row].set_name (new_name (m_data));
+
update ();
stack_tree->setCurrentItem (stack_tree->topLevelItem (row));
}
@@ -355,16 +415,12 @@ NetTracerTechComponentEditor::update ()
} else {
item->setData (0, Qt::DisplayRole, QVariant (tl::to_qstring (name)));
}
- item->setData (1, Qt::DisplayRole, QVariant (tl::to_qstring (l->description ())));
-
item->setData (0, Qt::UserRole, QVariant (n));
- }
+ item->setData (1, Qt::DisplayRole, QVariant (tl::to_qstring (l->description ())));
+ item->setData (1, Qt::UserRole, QVariant (n));
- if (! stack_tree->currentItem () && stack_tree->topLevelItemCount () > 0) {
- stack_tree->setCurrentItem (stack_tree->topLevelItem (0));
}
- current_item_changed (stack_tree->currentItem (), 0);
}
}
diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.h
index db802fe6b..475b81e84 100644
--- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.h
+++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerTechComponentEditor.h
@@ -62,6 +62,7 @@ public:
public slots:
void add_clicked ();
+ void clone_clicked ();
void del_clicked ();
void move_up_clicked ();
void move_down_clicked ();