本文整理汇总了C++中KComboBox::insertItem方法的典型用法代码示例。如果您正苦于以下问题:C++ KComboBox::insertItem方法的具体用法?C++ KComboBox::insertItem怎么用?C++ KComboBox::insertItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KComboBox
的用法示例。
在下文中一共展示了KComboBox::insertItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupIPolicyPage
void kiptablesgenerator::setupIPolicyPage()
{
iPolicyPage = new QFrame(this);
QVBoxLayout *layout = new QVBoxLayout(iPolicyPage);
QLabel *intro = new QLabel(i18n(
"<p>What do you want your firewall to do to unmatched packets?</p>"
"<p>Your firewall can either accept unmatched packets, or drop unmatched "
"packets; the recommended option is to drop unmatched packets.</p>"
"<p><i>Advanced users: This sets the policy for the INPUT chain.</i></p>"), iPolicyPage);
intro->show();
layout->addWidget(intro);
KComboBox *options = new KComboBox(iPolicyPage);
options->insertItem(i18n("Accept"));
options->insertItem(i18n("Drop"));
options->setCurrentItem(1);
options->show();
layout->addWidget(options);
namedWidgets["incomingPolicy"] = options;
iPolicyPage->show();
this->addPage(iPolicyPage, i18n("Default Action"));
}
示例2: if
bool
StdWidgetFactory::readSpecialProperty(const QCString &classname, QDomElement &node, QWidget *w, KFormDesigner::ObjectTreeItem *)
{
QString tag = node.tagName();
QString name = node.attribute("name");
if((tag == "item") && (classname == "KComboBox"))
{
KComboBox *combo = (KComboBox*)w;
QVariant val = KFormDesigner::FormIO::readPropertyValue(node.firstChild().firstChild(), w, name);
if(val.canCast(QVariant::Pixmap))
combo->insertItem(val.toPixmap());
else
combo->insertItem(val.toString());
return true;
}
if((tag == "item") && (classname == "KListBox"))
{
KListBox *listbox = (KListBox*)w;
QVariant val = KFormDesigner::FormIO::readPropertyValue(node.firstChild().firstChild(), w, name);
if(val.canCast(QVariant::Pixmap))
listbox->insertItem(val.toPixmap());
else
listbox->insertItem(val.toString());
return true;
}
if((tag == "column") && (classname == "KListView"))
{
KListView *listview = (KListView*)w;
int id=0;
for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
{
QString prop = n.toElement().attribute("name");
QVariant val = KFormDesigner::FormIO::readPropertyValue(n.firstChild(), w, name);
if(prop == "text")
id = listview->addColumn(val.toString());
else if(prop == "width")
listview->setColumnWidth(id, val.toInt());
else if(prop == "resizable")
listview->header()->setResizeEnabled(val.toBool(), id);
else if(prop == "clickable")
listview->header()->setClickEnabled(val.toBool(), id);
else if(prop == "fullwidth")
listview->header()->setStretchEnabled(val.toBool(), id);
}
return true;
}
else if((tag == "item") && (classname == "KListView"))
{
KListView *listview = (KListView*)w;
readListItem(node, 0, listview);
return true;
}
return false;
}
示例3: f
LinkDialog::LinkDialog(QWidget* parent, Selection* selection)
: KPageDialog(parent)
, d(new Private)
{
setCaption(i18n("Insert Link"));
setButtons(Ok | Cancel);
setFaceType(List);
// link for web or ftp
d->internetPage = new QWidget();
d->p1 = addPage(d->internetPage, i18n("Internet"));
d->p1->setHeader(i18n("Link to Internet Address"));
d->p1->setIcon(KIcon("internet-web-browser"));
QVBoxLayout* iLayout = new QVBoxLayout(d->internetPage);
iLayout->addWidget(new QLabel(i18n("Text to display:"), d->internetPage));
d->internetText = new KLineEdit(d->internetPage);
iLayout->addWidget(d->internetText);
iLayout->addWidget(new QLabel(i18n("Internet address:"), d->internetPage));
d->internetLink = new KLineEdit(d->internetPage);
iLayout->addWidget(d->internetLink);
iLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
connect(d->internetText, SIGNAL(textChanged(const QString&)), this,
SLOT(setText(const QString&)));
// link for e-mail
d->mailPage = new QWidget();
d->p2 = addPage(d->mailPage, i18n("Mail"));
d->p2->setHeader(i18n("Link to Mail Address"));
d->p2->setIcon(KIcon("mail-message"));
QVBoxLayout* mLayout = new QVBoxLayout(d->mailPage);
mLayout->addWidget(new QLabel(i18n("Text to display:"), d->mailPage));
d->mailText = new KLineEdit(d->mailPage);
mLayout->addWidget(d->mailText);
mLayout->addWidget(new QLabel(i18n("Email:"), d->mailPage));
d->mailLink = new KLineEdit(d->mailPage);
mLayout->addWidget(d->mailLink);
connect(d->mailText, SIGNAL(textChanged(const QString&)), this,
SLOT(setText(const QString&)));
mLayout->addWidget(new QLabel(i18n("Subject:"), d->mailPage));
d->mailSubject = new KLineEdit(d->mailPage);
mLayout->addWidget(d->mailSubject);
mLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
// link for external file
d->filePage = new QWidget();
d->p3 = addPage(d->filePage, i18n("File"));
d->p3->setHeader(i18n("Link to File"));
d->p3->setIcon(KIcon("system-file-manager"));
QVBoxLayout* fLayout = new QVBoxLayout(d->filePage);
fLayout->addWidget(new QLabel(i18n("Text to display:"), d->filePage));
d->fileText = new KLineEdit(d->filePage);
fLayout->addWidget(d->fileText);
fLayout->addWidget(new QLabel(i18n("File location:"), d->filePage));
d->fileLink = new KUrlRequester(d->filePage);
d->fileLink->completionObject()->setReplaceHome(true);
d->fileLink->completionObject()->setReplaceEnv(true);
fLayout->addWidget(d->fileLink);
fLayout->addWidget(new QLabel(i18n("Recent file:"), d->filePage));
KComboBox* recentFile = new KComboBox(d->filePage);
recentFile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
recentFile->setMinimumContentsLength(40);
fLayout->addWidget(recentFile);
fLayout->addItem(new QSpacerItem(0, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
connect(d->fileText, SIGNAL(textChanged(const QString&)), this,
SLOT(setText(const QString&)));
QObject::connect(recentFile, SIGNAL(highlighted(const QString &)),
d->fileLink->lineEdit(), SLOT(setText(const QString &)));
// populate recent files
int index = 0;
const QStringList fileList = KRecentDocument::recentDocuments();
for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) {
KDesktopFile f(*it);
if (!f.readUrl().isEmpty())
recentFile->insertItem(index++, f.readUrl());
}
if (recentFile->count() == 0) {
recentFile->insertItem(0, i18n("No Entries"));
recentFile->setEnabled(false);
}
// link to another cell
d->cellPage = new QWidget();
d->p4 = addPage(d->cellPage, i18n("Cell"));
d->p4->setHeader(i18n("Link to Cell"));
d->p4->setIcon(KIcon("table"));
QVBoxLayout* cLayout = new QVBoxLayout(d->cellPage);
cLayout->addWidget(new QLabel(i18n("Text to display:"), d->cellPage));
d->cellText = new KLineEdit(d->cellPage);
cLayout->addWidget(d->cellText);
cLayout->addWidget(new QLabel(i18n("Cell or Named Area:"), d->cellPage));
d->cellLink = new KComboBox(d->cellPage);
d->cellLink->setEditable(true);
const Sheet *sheet = selection->activeSheet();
if (sheet && selection) {
Cell cell(sheet, selection->cursor());
d->cellLink->addItem(cell.fullName());
}
//.........这里部分代码省略.........
示例4: QLabel
TransferDialog::TransferDialog( MediaDevice *mdev )
: KDialogBase( Pana::mainWindow(), "transferdialog", true, QString::null, Ok|Cancel, Ok )
{
m_dev = mdev;
m_accepted = false;
m_sort1LastIndex = m_sort2LastIndex = -1;
kapp->setTopWidget( this );
setCaption( kapp->makeStdCaption( i18n( "Transfer Queue to Device" ) ) );
QVBox* vbox = makeVBoxMainWidget();
vbox->setSpacing( KDialog::spacingHint() );
QString transferDir = mdev->getTransferDir();
QGroupBox *location = new QGroupBox( 1, Qt::Vertical, i18n( "Music Location" ), vbox );
new QLabel( i18n( "Your music will be transferred to:\n%1" )
.arg( transferDir ), location );
QVBox *vbox2 = new QVBox( vbox );
QSpacerItem *spacer = new QSpacerItem( 0, 25 );
QLayout *vlayout = vbox2->layout();
if( vlayout )
vlayout->addItem( spacer );
new QLabel( i18n( "You can have your music automatically grouped in\n"
"a variety of ways. Each grouping will create\n"
"directories based upon the specified criteria.\n"), vbox );
QGroupBox *sorting = new QGroupBox( 6, Qt::Vertical, i18n( "Groupings" ), vbox );
m_label1 = new QLabel( i18n( "Select first grouping:\n" ), sorting );
m_sort1 = new KComboBox( sorting );
m_label2 = new QLabel( i18n( "Select second grouping:\n" ), sorting );
m_sort2 = new KComboBox( sorting );
m_label3 = new QLabel( i18n( "Select third grouping:\n" ), sorting );
m_sort3 = new KComboBox( sorting );
m_combolist = new QPtrList<KComboBox>();
m_combolist->append( m_sort1 );
m_combolist->append( m_sort2 );
m_combolist->append( m_sort3 );
KComboBox * comboTemp;
for( comboTemp = m_combolist->first(); comboTemp; comboTemp = m_combolist->next() )
{
comboTemp->insertItem( i18n("None") );
comboTemp->insertItem( i18n("Artist") );
comboTemp->insertItem( i18n("Album") );
comboTemp->insertItem( i18n("Genre") );
comboTemp->setCurrentItem( 0 );
}
m_sort1->setCurrentItem( mdev->m_firstSort );
m_sort2->setCurrentItem( mdev->m_secondSort );
m_sort3->setCurrentItem( mdev->m_thirdSort );
m_label2->setDisabled( m_sort1->currentItem() == 0 );
m_sort2->setDisabled( m_sort1->currentItem() == 0 );
m_label3->setDisabled( m_sort2->currentItem() == 0 );
m_sort3->setDisabled( m_sort2->currentItem() == 0 );
connect( m_sort1, SIGNAL( activated(int) ), SLOT( sort1_activated(int)) );
connect( m_sort2, SIGNAL( activated(int) ), SLOT( sort2_activated(int)) );
QVBox *vbox3 = new QVBox( vbox );
QSpacerItem *spacer2 = new QSpacerItem( 0, 25 );
QLayout *vlayout2 = vbox3->layout();
if( vlayout2 )
vlayout2->addItem( spacer2 );
QGroupBox *options = new QGroupBox( 6, Qt::Vertical, i18n( "Options" ), vbox );
QCheckBox *convertSpaces = new QCheckBox( i18n( "Convert spaces to underscores" ), options );
convertSpaces->setChecked( mdev->getSpacesToUnderscores() );
connect( convertSpaces, SIGNAL( toggled(bool) ), this, SLOT( convertSpaces_toggled(bool) ) );
}
示例5: KDialogBase
DialogCreateTag::DialogCreateTag(QWidget *parent, TagTreeNode* parentNode, const char *name)
: KDialogBase(parent, name, true, "", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false )
, m_parentNode(parentNode) {
if (parentNode) {
this->setCaption(i18n("Create tag"));
} else {
this->setCaption(i18n("Create toplevel tag"));
}
QWidget* mainPanel = new QWidget(this, "mainPanel");
setMainWidget(mainPanel);
QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout");
mainPanelLayout->setAutoAdd(true);
// parent
if (parentNode) {
// newTagGroup
QGroupBox* parentTagGroup = new QGroupBox(i18n("Parent tag"), mainPanel, "parentTagGroup");
QGridLayout* parentTagGroupLayout = new QGridLayout(parentTagGroup, 4, 4, 20, 5, "parentTagGroupLayout");
parentTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), parentTagGroup, "typeLabel");
parentTagGroupLayout->addWidget(typeLabel, 1, 0);
KComboBox* typeComboBox = new KComboBox(false, parentTagGroup, "typeComboBox");
typeComboBox->insertItem(parentNode->tagNode()->typeName());
typeComboBox->setEnabled(false);
parentTagGroupLayout->addMultiCellWidget(typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), parentTagGroup, "nameLabel");
parentTagGroupLayout->addWidget(nameLabel, 2, 0);
KLineEdit* nameLineEdit = new KLineEdit(parentTagGroup, "nameLineEdit");
nameLineEdit->setText(*parentNode->tagNode()->text());
nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
nameLineEdit->setReadOnly(true);
parentTagGroupLayout->addMultiCellWidget(nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), parentTagGroup, "iconLabel");
parentTagGroupLayout->addWidget(iconLabel, 3, 0);
KLineEdit* iconLineEdit = new KLineEdit(parentTagGroup, "iconLineEdit");
iconLineEdit->setText(*parentNode->tagNode()->iconName());
iconLineEdit->setMinimumWidth(300);
iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
iconLineEdit->setReadOnly(true);
parentTagGroupLayout->addWidget(iconLineEdit, 3, 1);
QPushButton* iconButton = new QPushButton(i18n("Icon"), parentTagGroup, "iconButton");
QIconSet iconSet = KGlobal::iconLoader()->loadIconSet(iconLineEdit->text(), KIcon::Small, Configuration::getInstance()->tagtreeIconSize(), true);
iconButton->setIconSet(iconSet);
iconButton->setText(QString::null);
iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
iconButton->setEnabled(true);
parentTagGroupLayout->addWidget(iconButton, 3, 2);
}
// newTagGroup
QGroupBox* newTagGroup = new QGroupBox(i18n("New tag"), mainPanel, "newTagGroup");
QGridLayout* newTagGroupLayout = new QGridLayout(newTagGroup, 4, 4, 20, 5, "newTagGroupLayout");
newTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), newTagGroup, "typeLabel");
newTagGroupLayout->addWidget(typeLabel, 1, 0);
m_typeComboBox = new KComboBox(false, newTagGroup, "typeComboBox");
m_typeComboBoxEntries = new QValueList<int>;
if (!parentNode) {
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_TITLE));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_TITLE));
}
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_BOOLEAN));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_BOOLEAN));
newTagGroupLayout->addMultiCellWidget(m_typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), newTagGroup, "nameLabel");
newTagGroupLayout->addWidget(nameLabel, 2, 0);
m_nameLineEdit = new KLineEdit(newTagGroup, "nameLineEdit");
m_nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
newTagGroupLayout->addMultiCellWidget(m_nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), newTagGroup, "iconLabel");
newTagGroupLayout->addWidget(iconLabel, 3, 0);
m_iconLineEdit = new KLineEdit(newTagGroup, "iconLineEdit");
m_iconLineEdit->setMinimumWidth(300);
m_iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_iconLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotIconTextChanged(const QString&)));
newTagGroupLayout->addWidget(m_iconLineEdit, 3, 1);
//.........这里部分代码省略.........
示例6: QVBoxLayout
//.........这里部分代码省略.........
QMap<QString,QString>::const_iterator g_it = groups.constBegin();
while (g_it != groups.constEnd())
{
QAction *group_action = group_menu->addAction(g_it.key());
group_action->setData(g_it.value());
++g_it;
}
group_layout->addWidget(group_id, 0, 0, 0);
group_layout->addWidget(group_chooser, 0, 1, Qt::AlignCenter);
QLabel *fmask_label = new QLabel(Smb4KMountSettings::self()->fileMaskItem()->label(), common_options);
KLineEdit *fmask = new KLineEdit(common_options);
fmask->setObjectName("kcfg_FileMask");
fmask->setAlignment(Qt::AlignRight);
fmask_label->setBuddy(fmask);
QLabel *dmask_label = new QLabel(Smb4KMountSettings::self()->directoryMaskItem()->label(), common_options);
KLineEdit *dmask = new KLineEdit(common_options);
dmask->setObjectName("kcfg_DirectoryMask");
dmask->setAlignment(Qt::AlignRight);
dmask_label->setBuddy(dmask);
QLabel *write_access_label = new QLabel(Smb4KMountSettings::self()->writeAccessItem()->label(), common_options);
KComboBox *write_access = new KComboBox(common_options);
write_access->setObjectName("kcfg_WriteAccess");
write_access->insertItem(Smb4KMountSettings::EnumWriteAccess::ReadWrite,
Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label);
write_access->insertItem(Smb4KMountSettings::EnumWriteAccess::ReadOnly,
Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label);
write_access_label->setBuddy(write_access);
QLabel *charset_label = new QLabel(Smb4KMountSettings::self()->clientCharsetItem()->label(), common_options);
KComboBox *charset = new KComboBox(common_options);
charset->setObjectName("kcfg_ClientCharset");
charset->insertItem(Smb4KMountSettings::EnumClientCharset::default_charset,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::default_charset).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_1,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_1).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_2,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_2).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_3,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_3).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_4,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_4).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_5,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_5).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_6,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_6).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_7,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_7).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_8,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset:: iso8859_8).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_9,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_9).label);
charset->insertItem(Smb4KMountSettings::EnumClientCharset::iso8859_13,
Smb4KMountSettings::self()->clientCharsetItem()->choices().value(Smb4KMountSettings::EnumClientCharset::iso8859_13).label);
示例7: slotChangedProtocol
void kiptablesgenerator::slotChangedProtocol(int newProtocol)
{
// 0 = TCP
// 1 = UDP
// 2 = TCP+UDP
// 3 = ICMP
KComboBox *names = (KComboBox*) namedWidgets["newService_names"];
names->clear();
if (newProtocol != 3)
{
names->insertItem("SSH");
names->insertItem("Telnet");
names->insertItem("HTTP");
names->insertItem("HTTPS");
names->insertItem("SMTP");
names->insertItem("SMTPS");
names->insertItem("POP3");
names->insertItem("POP3S");
names->insertItem("IMAP");
names->insertItem("IMAPS");
((QRadioButton *) namedWidgets["newService_numbered"])->setEnabled(true);
((QLineEdit *) namedWidgets["newService_ports"])->setEnabled(true);
return;
}
((QRadioButton *) namedWidgets["newService_numbered"])->setEnabled(false);
((QLineEdit *) namedWidgets["newService_ports"])->setEnabled(false);
((QRadioButton *) namedWidgets["newService_named"])->setChecked(true);
names->insertItem("any");
names->insertItem("echo-reply");
names->insertItem("destination-unreachable");
names->insertItem(" network-unreachable");
names->insertItem(" host-unreachable");
names->insertItem(" protocol-unreachable");
names->insertItem(" port-unreachable");
names->insertItem(" fragmentation-needed");
names->insertItem(" source-route-failed");
names->insertItem(" network-unknown");
names->insertItem(" host-unknown");
names->insertItem(" network-prohibited");
names->insertItem(" host-prohibited");
names->insertItem(" TOS-network-unreachable");
names->insertItem(" TOS-host-unreachable");
names->insertItem(" communication-prohibited");
names->insertItem(" host-precedence-violation");
names->insertItem(" precedence-cutoff");
names->insertItem("source-quench");
names->insertItem("redirect");
names->insertItem(" network-redirect");
names->insertItem(" host-redirect");
names->insertItem(" TOS-network-redirect");
names->insertItem(" TOS-host-redirect");
names->insertItem("echo-request");
names->insertItem("router-advertisement");
names->insertItem("router-solicitation");
names->insertItem("time-exceeded");
names->insertItem(" ttl-zero-during-transit");
names->insertItem(" ttl-zero-during-reassembly");
names->insertItem("parameter-problem");
names->insertItem(" ip-header-bad");
names->insertItem(" required-option-missing");
names->insertItem("timestamp-request");
names->insertItem("timestamp-reply");
names->insertItem("address-mask-request");
names->insertItem("address-mask-reply");
}
示例8: setupNewServiceDialog
void kiptablesgenerator::setupNewServiceDialog()
{
newServiceDialog = new KDialogBase(this, 0, true, i18n("Add Service"), KDialogBase::Ok | KDialogBase::Cancel);
QFrame *dialogArea = new QFrame(newServiceDialog);
QGridLayout *layout = new QGridLayout(dialogArea, 7, 2);
QLabel *intro = new QLabel(i18n(
"<p><i>Advanced users only</i></p>"
"<p>Here you can allow or deny access to services through your firewall.<br />"
"You can specify a port range in the box using this format: <tt>fromPort:toPort</tt></p>"), dialogArea);
intro->show();
layout->addMultiCellWidget(intro, 0, 0, 0, 1);
QLabel *protocolLabel = new QLabel(i18n("&Protocol: "), dialogArea);
protocolLabel->show();
layout->addWidget(protocolLabel, 1, 0);
KComboBox *protocols = new KComboBox(dialogArea);
protocols->insertItem(i18n("TCP"));
protocols->insertItem(i18n("UDP"));
protocols->insertItem(i18n("TCP & UDP"));
protocols->insertItem(i18n("ICMP"));
protocols->setCurrentItem(2);
protocols->show();
layout->addWidget(protocols, 1, 1);
protocolLabel->setBuddy(protocols);
namedWidgets["newService_protocols"] = protocols;
connect(protocols, SIGNAL(activated(int )), this, SLOT(slotChangedProtocol(int )));
QLabel *selectByLabel = new QLabel(i18n("Select service by: "), dialogArea);
selectByLabel->show();
layout->addMultiCellWidget(selectByLabel, 2, 2, 0, 1);
QButtonGroup *optNamedOrNumbered = new QButtonGroup(dialogArea);
optNamedOrNumbered->hide();
namedWidgets["newService_namedOrNumbered"] = optNamedOrNumbered;
QRadioButton *optNamed = new QRadioButton(i18n("&Name: "), dialogArea);
optNamed->setChecked(true);
optNamed->setName("named");
optNamedOrNumbered->insert(optNamed);
optNamed->show();
layout->addWidget(optNamed, 3, 0);
namedWidgets["newService_named"] = optNamed;
KComboBox *names = new KComboBox(dialogArea);
names->show();
layout->addWidget(names, 3, 1);
namedWidgets["newService_names"] = names;
QRadioButton *optNumbered = new QRadioButton(i18n("&Port number(s): "), dialogArea);
optNumbered->setName("numbered");
optNamedOrNumbered->insert(optNumbered);
optNumbered->show();
layout->addWidget(optNumbered, 4, 0);
namedWidgets["newService_numbered"] = optNumbered;
KLineEdit *ports = new KLineEdit(dialogArea);
ports->show();
layout->addWidget(ports, 4, 1);
namedWidgets["newService_ports"] = ports;
QButtonGroup *optAllowDeny = new QButtonGroup(dialogArea);
optAllowDeny->hide();
namedWidgets["newService_allowDeny"] = optAllowDeny;
KSeparator *separator = new KSeparator(dialogArea);
separator->show();
layout->addMultiCellWidget(separator, 5, 5, 0, 1);
QRadioButton *optAllow = new QRadioButton(i18n("&Accept"), dialogArea);
optAllow->setName(i18n("Accept"));
optAllow->setChecked(true);
optAllow->show();
optAllowDeny->insert(optAllow);
layout->addWidget(optAllow, 6, 0);
QRadioButton *optDeny = new QRadioButton(i18n("&Drop"), dialogArea);
optDeny->setName(i18n("Drop"));
optDeny->show();
optAllowDeny->insert(optDeny);
layout->addWidget(optDeny, 6, 1);
dialogArea->show();
newServiceDialog->setMainWidget(dialogArea);
connect(newServiceDialog, SIGNAL(okClicked()), this, SLOT(slotAddService()));
slotChangedProtocol(2); // TCP+UDP
}