コード例 #1
0
void kiptablesgenerator::slotNewInterface()
{
  QString interface;
  KListBox *interfaces = (KListBox*) namedWidgets["interfaces"];
  
  interface = KInputDialog::getText(i18n("Add Interface"),
    i18n("Enter the name of the interface, eg eth1"));
  if (interface == "")
    return;
  
  interfaces->insertItem(interface);
  interfaces->setSelected(interfaces->count() - 1, true);
}
コード例 #2
0
void kiptablesgenerator::setupInterfacesPage()
{
  interfacesPage = new QFrame(this);
  
  QVBoxLayout *layout = new QVBoxLayout(interfacesPage);
  
  QLabel *intro = new QLabel(i18n(
    "<p>Which of the following interfaces do you want to filter?</p>"
    "<p>It is strongly advised <b>not</b> to filter '<tt>lo</tt>'.</p>"), interfacesPage);
  intro->show();
  layout->addWidget(intro);
  
  KListBox *interfaces = new KListBox(interfacesPage);

  char buffer[IFNAMSIZ];
  for(unsigned int i = 1; if_indextoname(i, buffer) != NULL; i++)
  {
          interfaces->insertItem((QString)buffer);
  }
  
  interfaces->setSelectionMode(QListBox::Multi);
  for (unsigned short i = 0; i < interfaces->count(); i++)
    if (interfaces->item(i)->text() != "lo")
      interfaces->setSelected(i, true);
  interfaces->show();
  layout->addWidget(interfaces);
  namedWidgets["iInterfaces"] = interfaces;
  
  KPushButton *newInterface = new KPushButton(i18n("A&dd Interface..."), interfacesPage);
  newInterface->show();
  layout->addWidget(newInterface);
  connect(newInterface, SIGNAL(clicked()), this, SLOT(slotNewInterface()));
  
  interfacesPage->show();
  this->addPage(interfacesPage, i18n("Interfaces"));
}