see #2156 select new firewall in tree, expand subtree and open firewall object in the editor after successful import

This commit is contained in:
Vadim Kurland
2011-02-27 13:30:22 -08:00
parent 30db079476
commit 19ce284f21
5 changed files with 78 additions and 45 deletions
+3
View File
@@ -1,5 +1,8 @@
2011-02-27 vadim <vadim@netcitadel.com>
* DiscoveryDruid.cpp (finishClicked): fixes #2156 "After import
the firewall should be opened in object tree".
* instDialog_ui_ops.cpp (readInstallerOptionsFromFirewallObject):
fixes #2160 "Installer reports error "Generated script file
<firewall>.fw not found."". The problem was intorduced earlier
+49 -34
View File
@@ -224,45 +224,60 @@ void DiscoveryDruid::backClicked()
void DiscoveryDruid::finishClicked()
{
if (current_task == BT_IMPORT &&
selectedPlatform() == "pix" &&
currentPage() == NETWORK_ZONES_PAGE &&
discovered_fw != NULL)
if (current_task == BT_IMPORT && discovered_fw != NULL)
{
// read and configure network zones
list<FWObject*> all_interfaces = discovered_fw->getByTypeDeep(Interface::TYPENAME);
list<FWObject*>::iterator it;
for (it=all_interfaces.begin(); it!=all_interfaces.end(); ++it)
if (selectedPlatform() == "pix" && currentPage() == NETWORK_ZONES_PAGE)
{
Interface *iface = Interface::cast(*it);
string network_zone_str_id = "";
QList<QTableWidgetItem*> ltwi =
m_dialog->iface_nz_list->findItems( iface->getName().c_str(),
Qt::MatchExactly );
if ( ! ltwi.empty())
// read and configure network zones
list<FWObject*> all_interfaces =
discovered_fw->getByTypeDeep(Interface::TYPENAME);
list<FWObject*>::iterator it;
for (it=all_interfaces.begin(); it!=all_interfaces.end(); ++it)
{
QTableWidgetItem *itm2 = ltwi[0];
assert(itm2!=NULL);
int row = itm2->row();
QComboBox *cb = dynamic_cast<QComboBox*>(
m_dialog->iface_nz_list->cellWidget(row, 3));
assert(cb!=NULL);
int network_zone_int_id =
cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
if (network_zone_int_id != 0)
network_zone_str_id = FWObjectDatabase::getStringId(
network_zone_int_id);
else
network_zone_str_id = "";
Interface *iface = Interface::cast(*it);
string network_zone_str_id = "";
QList<QTableWidgetItem*> ltwi =
m_dialog->iface_nz_list->findItems( iface->getName().c_str(),
Qt::MatchExactly );
if ( ! ltwi.empty())
{
QTableWidgetItem *itm2 = ltwi[0];
assert(itm2!=NULL);
int row = itm2->row();
QComboBox *cb = dynamic_cast<QComboBox*>(
m_dialog->iface_nz_list->cellWidget(row, 3));
assert(cb!=NULL);
int network_zone_int_id =
cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
if (network_zone_int_id != 0)
network_zone_str_id = FWObjectDatabase::getStringId(
network_zone_int_id);
else
network_zone_str_id = "";
}
// only set network zone if it is supported and is not
// empty. See #2014
if (!network_zone_str_id.empty())
iface->setStr("network_zone", network_zone_str_id);
}
// only set network zone if it is supported and is not empty. See #2014
if (!network_zone_str_id.empty())
iface->setStr("network_zone", network_zone_str_id);
}
QCoreApplication::postEvent(
mw->activeProject(), new expandObjectInTreeEvent(
mw->activeProject()->getFileName(), discovered_fw->getId()));
QCoreApplication::postEvent(
mw->activeProject(), new showObjectInTreeEvent(
mw->activeProject()->getFileName(), discovered_fw->getId()));
QCoreApplication::postEvent(
mw, new openObjectInEditorEvent(
mw->activeProject()->getFileName(), discovered_fw->getId()));
}
QDialog::accept();
-11
View File
@@ -1262,17 +1262,6 @@ void ObjectManipulator::showObjectInTree(ObjectTreeViewItem *otvi)
otvi->getTree()->setFocus(Qt::OtherFocusReason);
}
void ObjectManipulator::expandObjectInTree(FWObject *obj)
{
FWObject *o = obj;
if (FWReference::cast(o)!=NULL) o = FWReference::cast(o)->getPointer();
QTreeWidgetItem *it = allItems[o];
if (it==NULL) return;
expandOrCollapseCurrentTreeNode(it, true);
}
void ObjectManipulator::libChangedById(int obj_id)
{
for (int i=0; i<libs_model->rowCount(); ++i)
+22
View File
@@ -171,9 +171,31 @@ QString ObjectManipulator::getTreeLabel(FWObject *obj, int col)
return "";
}
void ObjectManipulator::expandObjectInTree(FWObject *obj)
{
FWObject *o = FWReference::getObject(obj);
if (fwbdebug)
qDebug() << "ObjectManipulator::expandObjectInTree"
<< "o=" << QString::fromUtf8(o->getName().c_str());
//if (FWReference::cast(o)!=NULL) o = FWReference::cast(o)->getPointer();
QTreeWidgetItem *it = allItems[o];
if (it==NULL)
{
if (fwbdebug) qDebug() << "#### Tree node not found";
return;
}
expandOrCollapseCurrentTreeNode(it, true);
}
void ObjectManipulator::expandOrCollapseCurrentTreeNode(QTreeWidgetItem *item,
bool expand)
{
QTreeWidgetItem *parent = item->parent();
if (expand && ! parent->isExpanded()) parent->setExpanded(true);
item->setExpanded(expand);
for (int i=0; i<item->childCount(); ++i)
expandOrCollapseCurrentTreeNode(item->child(i), expand);
+4
View File
@@ -68,6 +68,10 @@ bool ProjectPanel::event(QEvent *event)
if (fwbdebug)
qDebug() << this
<< "rcs:"
<< rcs
<< "rcs->getFileName():"
<< QString((rcs!=NULL) ? rcs->getFileName() : "")
<< "file:"
<< data_file
<< "event:"