mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-17 02:19:21 +02:00
Fixed #745
This commit is contained in:
@@ -62,7 +62,7 @@ void ClusterInterfaceWidget::setFirewallList(QList<Firewall*> firewalls)
|
||||
{
|
||||
os = fw->getStr("host_OS").c_str();
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
this->m_ui->interfaces->addLayout(layout);
|
||||
this->m_ui->interfaceBox->addLayout(layout);
|
||||
|
||||
//create label with firewall name
|
||||
QLabel *label = new QLabel(QString::fromUtf8(fw->getName().c_str()), this);
|
||||
@@ -99,7 +99,7 @@ void ClusterInterfaceWidget::setFirewallList(QList<Firewall*> firewalls)
|
||||
if (iface->isLoopback()) return;
|
||||
Interface *subiface = Interface::cast(*iter2);
|
||||
QTreeWidgetItem *subitem = new QTreeWidgetItem(ifaceitem, QStringList() << QString::fromUtf8(subiface->getName().c_str()));
|
||||
subitem->setData(0, Qt::UserRole, qVariantFromValue(iface));//QVariant(QVariant::UserType, subitem));
|
||||
subitem->setData(0, Qt::UserRole, qVariantFromValue(subiface));//QVariant(QVariant::UserType, subitem));
|
||||
subitem->setDisabled(!interfaceSelectable(subiface));
|
||||
subitem->setIcon(0, QIcon(":/Icons/Interface/icon-tree"));
|
||||
if (!interfaceSelectable(subiface))
|
||||
@@ -125,17 +125,18 @@ bool ClusterInterfaceWidget::setCurrentInterface(QString name)
|
||||
{
|
||||
string label;
|
||||
bool setLabel = true;
|
||||
int gotItems = 0;
|
||||
foreach(InterfacesList list, this->lists.values())
|
||||
{
|
||||
bool gotItem = false;
|
||||
foreach(QTreeWidgetItem *item, list.list->findItems(name, Qt::MatchCaseSensitive | Qt::MatchExactly | Qt::MatchRecursive))
|
||||
{
|
||||
Interface *iface = item->data(0, Qt::UserRole).value<Interface*>();
|
||||
if (iface == NULL) continue;
|
||||
if ( item == roots[list.list] ) continue; // skip firewall object
|
||||
if ( interfaceSelectable(iface) ) // interface is good for use in cluster
|
||||
{
|
||||
list.list->setCurrentItem(item);
|
||||
gotItem = true;
|
||||
gotItems++;
|
||||
if (label.length() == 0) label = iface->getLabel();
|
||||
else
|
||||
if (label != iface->getLabel())
|
||||
@@ -143,8 +144,9 @@ bool ClusterInterfaceWidget::setCurrentInterface(QString name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!gotItem) return false;
|
||||
qDebug() << gotItems << this->lists.values().count();
|
||||
}
|
||||
if (gotItems < this->lists.values().count()) return false;
|
||||
this->m_ui->name->setText(name);
|
||||
if (setLabel) this->m_ui->label->setText(QString::fromUtf8(label.c_str()));
|
||||
return true;
|
||||
@@ -164,18 +166,9 @@ ClusterInterfaceData ClusterInterfaceWidget::getInterfaceData()
|
||||
res.comment = this->m_ui->comment->toPlainText();
|
||||
foreach(InterfacesList ifacelist, this->lists.values())
|
||||
{
|
||||
QString selectedInterface = ifacelist.list->selectedItems().first()->text(0);
|
||||
qDebug() << selectedInterface;
|
||||
FWObjectTypedChildIterator iter = ifacelist.firewall->findByType(Interface::TYPENAME);
|
||||
for ( ; iter!=iter.end(); ++iter )
|
||||
{
|
||||
Interface* iface = Interface::cast(*iter);
|
||||
if (QString::fromUtf8(iface->getName().c_str()) == selectedInterface)
|
||||
{
|
||||
res.interfaces.append(qMakePair(ifacelist.firewall, iface));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *item = ifacelist.list->selectedItems().first();
|
||||
Interface* iface = item->data(0, Qt::UserRole).value<Interface*>();
|
||||
res.interfaces.append(qMakePair(Firewall::cast(iface->getParent()), iface));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ClusterInterfaceWidget</class>
|
||||
<widget class="QWidget" name="ClusterInterfaceWidget" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="ClusterInterfaceWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@@ -9,54 +10,54 @@
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" >
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_1" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Label:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="name" />
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="name"/>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="label" />
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="label"/>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QTextEdit" name="comment" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<item row="2" column="1">
|
||||
<widget class="QTextEdit" name="comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>70</height>
|
||||
@@ -66,36 +67,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Select firewall interfaces to use with the cluster interface.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Configuration of cluster interfaces depends on the failover protocol chosen on the next page. If the protocol creates its own new interfaces, such as <span style=" font-weight:600;">VRRP</span> or <span style=" font-weight:600;">CARP</span> that create inetrfaces <span style=" font-weight:600; font-style:italic;">vrrp0</span> or <span style=" font-weight:600; font-style:italic;">carp0</span>, then cluster interface objects represent these and should have the name <span style=" font-weight:600; font-style:italic;">vrrp0</span> or <span style=" font-weight:600; font-style:italic;">carp0</span>. If failover protocol does not create new interfaces, such as <span style=" font-weight:600;">heartbeat</span> or <span style=" font-weight:600;">OpenAIS</span>, then cluster interface should have the same name as member firewall interfaces, that is <span style=" font-weight:600; font-style:italic;">eth0</span>, <span style=" font-weight:600; font-style:italic;">eth1.102</span>, <span style=" font-weight:600; font-style:italic;">vlan200</span>, and so on. In the latter case cluster interface is an abstraction used to define mapping between corresponding interfaces of the member firewalls and to provide place for the configuration of the failover protocol.</p></body></html></string>
|
||||
</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Configuration of cluster interfaces depends on the failover protocol chosen on the next page. If the protocol creates its own new interfaces, such as <span style=" font-weight:600;">VRRP</span> or <span style=" font-weight:600;">CARP</span> that create inetrfaces <span style=" font-weight:600; font-style:italic;">vrrp0</span> or <span style=" font-weight:600; font-style:italic;">carp0</span>, then cluster interface objects represent these and should have the name <span style=" font-weight:600; font-style:italic;">vrrp0</span> or <span style=" font-weight:600; font-style:italic;">carp0</span>. If failover protocol does not create new interfaces, such as <span style=" font-weight:600;">heartbeat</span> or <span style=" font-weight:600;">OpenAIS</span>, then cluster interface should have the same name as member firewall interfaces, that is <span style=" font-weight:600; font-style:italic;">eth0</span>, <span style=" font-weight:600; font-style:italic;">eth1.102</span>, <span style=" font-weight:600; font-style:italic;">vlan200</span>, and so on. In the latter case cluster interface is an abstraction used to define mapping between corresponding interfaces of the member firewalls and to provide place for the configuration of the failover protocol.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<layout class="QHBoxLayout" name="interfaces" />
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="interfaceBox"/>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<spacer name="verticalSpacer" >
|
||||
<property name="orientation" >
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>91</height>
|
||||
@@ -113,11 +114,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>ClusterInterfaceWidget</receiver>
|
||||
<slot>nameChanged(QString)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>95</x>
|
||||
<y>25</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>2</x>
|
||||
<y>92</y>
|
||||
</hint>
|
||||
|
||||
@@ -96,14 +96,14 @@ void ClusterInterfacesSelectorWidget::addInterface(QString name)
|
||||
if (!widget->setCurrentInterface(name))
|
||||
{
|
||||
this->removeTab(this->indexOf(widget));
|
||||
this->editors.removeOne(widget);
|
||||
this->editors.removeAll(widget);
|
||||
delete widget;
|
||||
}
|
||||
}
|
||||
|
||||
void ClusterInterfacesSelectorWidget::closeTab()
|
||||
{
|
||||
this->editors.removeOne(dynamic_cast<ClusterInterfaceWidget*>(this->widget(this->currentIndex())));
|
||||
this->editors.removeAll(dynamic_cast<ClusterInterfaceWidget*>(this->widget(this->currentIndex())));
|
||||
this->removeTab(this->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user