QWidget* RuleDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option) QWidget *editor = new QWidget(parent); KLineEdit *ruleLineEdit = new KLineEdit(editor); ruleLineEdit->setToolTip(i18n("Expression")); KComboBox *matchComboBox = new KComboBox(editor); matchComboBox->setToolTip(i18n("Match Mode")); matchComboBox->addItem(i18n("Ignore")); matchComboBox->addItem(i18n("Regular expression")); matchComboBox->addItem(i18n("Partial match")); matchComboBox->addItem(i18n("Exact match")); QCheckBox *requiredCheckBox = new QCheckBox(editor); requiredCheckBox->setToolTip(i18n("Required")); QHBoxLayout *layout = new QHBoxLayout(editor); layout->addWidget(ruleLineEdit); layout->addWidget(matchComboBox); layout->addWidget(requiredCheckBox); layout->setMargin(0); setEditorData(editor, index); return editor; }
void HolidayRegionSelector::Private::initItem( QTreeWidgetItem *listItem, HolidayRegion *region ) { m_ui.regionTreeWidget->blockSignals( true ); QString languageName = KGlobal::locale()->languageCodeToName( region->languageCode() ); listItem->setCheckState( Private::SelectColumn, Qt::Unchecked ); QString text = i18n( "<p>Select to use Holiday Region</p>" ); listItem->setToolTip( Private::SelectColumn, text ); listItem->setToolTip( Private::ComboColumn, text ); text = i18n( "<p>Select to use Holiday Region</p>" ); listItem->setToolTip( Private::SelectColumn, text ); listItem->setToolTip( Private::ComboColumn, text ); listItem->setText( Private::RegionColumn, region->name() ); QString toolTip = i18n( "<p><b>Region:</b> %1<br/>" "<b>Language:</b> %2<br/>" "<b>Description:</b> %3</p>", region->name(), languageName, region->description() ); listItem->setToolTip( Private::RegionColumn, toolTip ); listItem->setData( Private::RegionColumn, Qt::UserRole, region->regionCode() ); listItem->setText( Private::LanguageColumn, languageName ); listItem->setData( Private::LanguageColumn, Qt::UserRole, region->languageCode() ); listItem->setText( Private::DescriptionColumn, region->description() ); listItem->setToolTip( Private::DescriptionColumn, region->description() ); KComboBox *combo = new KComboBox(); combo->setAutoFillBackground( true ); QString comboText = i18n( "<p>You can choose to display the Holiday Region for information only, " "or to use the Holiday Region when displaying or calculating days off " "such as Public Holidays. If you choose to use the Holiday Region for " "Days Off, then only those Holiday Events marked in the Holiday Region " "as Days Off will be used for non-work days, Holiday Events that are " "not marked in the Holiday Region as Days Off will continue to be " "work days.</p>" ); combo->setToolTip( comboText ); comboText = i18nc( "Combobox label, Holiday Region not used", "Not Used" ); combo->addItem( comboText, QVariant( NotUsed ) ); comboText = i18nc( "Combobox label, use Holiday Region for information only", "Information" ); combo->addItem( comboText, QVariant( UseInformationOnly ) ); comboText = i18nc( "Combobox label, use Holiday Region for days off", "Days Off" ); combo->addItem( comboText, QVariant( UseDaysOff ) ); combo->setCurrentIndex( 0 ); listItem->setData( Private::ComboColumn, Qt::UserRole, NotUsed ); m_ui.regionTreeWidget->setItemWidget( listItem, ComboColumn, combo ); connect( combo, SIGNAL(currentIndexChanged(int)), q, SLOT(itemChanged(int)) ); m_ui.regionTreeWidget->blockSignals( false ); }