This commit is contained in:
Roman Bovsunivskiy
2009-11-28 23:53:17 +00:00
parent 2babd8f4c0
commit fd417aee88
3 changed files with 58 additions and 64 deletions
+10 -17
View File
@@ -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;
}
+46 -45
View File
@@ -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>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
&lt;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 &lt;span style=" font-weight:600;">VRRP&lt;/span> or &lt;span style=" font-weight:600;">CARP&lt;/span> that create inetrfaces &lt;span style=" font-weight:600; font-style:italic;">vrrp0&lt;/span> or &lt;span style=" font-weight:600; font-style:italic;">carp0&lt;/span>, then cluster interface objects represent these and should have the name &lt;span style=" font-weight:600; font-style:italic;">vrrp0&lt;/span> or &lt;span style=" font-weight:600; font-style:italic;">carp0&lt;/span>. If failover protocol does not create new interfaces, such as &lt;span style=" font-weight:600;">heartbeat&lt;/span> or &lt;span style=" font-weight:600;">OpenAIS&lt;/span>, then cluster interface should have the same name as member firewall interfaces, that is &lt;span style=" font-weight:600; font-style:italic;">eth0&lt;/span>, &lt;span style=" font-weight:600; font-style:italic;">eth1.102&lt;/span>, &lt;span style=" font-weight:600; font-style:italic;">vlan200&lt;/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.&lt;/p>&lt;/body>&lt;/html></string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Configuration of cluster interfaces depends on the failover protocol chosen on the next page. If the protocol creates its own new interfaces, such as &lt;span style=&quot; font-weight:600;&quot;&gt;VRRP&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;CARP&lt;/span&gt; that create inetrfaces &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;vrrp0&lt;/span&gt; or &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;carp0&lt;/span&gt;, then cluster interface objects represent these and should have the name &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;vrrp0&lt;/span&gt; or &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;carp0&lt;/span&gt;. If failover protocol does not create new interfaces, such as &lt;span style=&quot; font-weight:600;&quot;&gt;heartbeat&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;OpenAIS&lt;/span&gt;, then cluster interface should have the same name as member firewall interfaces, that is &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;eth0&lt;/span&gt;, &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;eth1.102&lt;/span&gt;, &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;vlan200&lt;/span&gt;, 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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>
+2 -2
View File
@@ -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());
}