void KOTodoDueDateDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const { KDateComboBox *dateEdit = static_cast<KDateComboBox *>( editor ); dateEdit->setDate( index.data( Qt::EditRole ).toDate() ); }
void ContactInfoDialog::Private::addInfoRow(InfoRowIndex index, const QString &value) { InfoRow *row = &InfoRows[index]; // I18N_NOOP only marks the string for translation, the actual lookup of // translated row->title happens here QLabel *descriptionLabel = new QLabel(i18n(row->title), q); QFont font = descriptionLabel->font(); font.setBold(true); descriptionLabel->setFont(font); if (editable) { if (index == Birthday) { KDateComboBox *combo = new KDateComboBox(q); combo->setOptions(KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker); combo->setMinimumWidth(200); combo->setDate(QDate::fromString(value)); connect(combo, SIGNAL(dateChanged(QDate)), q, SLOT(onInfoDataChanged())); infoValueWidgets.insert(index, combo); } else { QLineEdit *edit = new QLineEdit(q); edit->setMinimumWidth(200); edit->setText(value); connect(edit, SIGNAL(textChanged(QString)), q, SLOT(onInfoDataChanged())); infoValueWidgets.insert(index, edit); } } else { QLabel *label = new QLabel(q); label->setOpenExternalLinks(true); label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); if (index == Email) { label->setText(QString::fromLatin1("<a href=\"mailto:%1\">%1</a>").arg(value)); } else if (index == Homepage) { QString format; if (!value.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) { format = QLatin1String("<a href=\"http://%1\">%1</a>"); } else { format = QLatin1String("<a href=\"%1\">%1</a>"); } label->setText(format.arg(value)); } else { label->setText(value); } infoValueWidgets.insert(index, label); } infoLayout->addRow(descriptionLabel, infoValueWidgets.value(index)); }