MessageEditDialog::MessageEditDialog(const iscore::Message &mess, DeviceExplorerModel *model, QWidget *parent): QDialog{parent}, m_message(mess) { m_lay = new QFormLayout; this->setLayout(m_lay); m_addr = new AddressEditWidget{model, this}; m_addr->setAddress(mess.address); m_lay->addWidget(m_addr); m_typeCombo = new QComboBox; connect(m_typeCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MessageEditDialog::on_typeChanged); m_val = new WidgetWrapper<ValueWidget>{this}; m_lay->addItem(new QSpacerItem(10, 10)); m_lay->addRow(tr("Type"), m_typeCombo); m_lay->addRow(tr("Value"), m_val); initTypeCombo(); auto buttons = new QDialogButtonBox(QDialogButtonBox::StandardButton::Ok | QDialogButtonBox::StandardButton::Cancel); connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); m_lay->addWidget(buttons); }
NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, bool readOnly, QWidget *parent, const char *name ) : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, Ok, parent, name, true ), mAddressee( addr ) { QWidget *page = plainPage(); QGridLayout *layout = new QGridLayout( page ); layout->setSpacing( spacingHint() ); layout->addColSpacing( 2, 100 ); QLabel *label; label = new QLabel( i18n( "Honorific prefixes:" ), page ); layout->addWidget( label, 0, 0 ); mPrefixCombo = new KComboBox( page ); mPrefixCombo->setDuplicatesEnabled( false ); mPrefixCombo->setEditable( true ); mPrefixCombo->setEnabled( !readOnly ); label->setBuddy( mPrefixCombo ); layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); QWhatsThis::add( mPrefixCombo, i18n( "The predefined honorific prefixes can be extended in the settings dialog." ) ); label = new QLabel( i18n( "Given name:" ), page ); layout->addWidget( label, 1, 0 ); mGivenNameEdit = new KLineEdit( page ); mGivenNameEdit->setReadOnly( readOnly ); label->setBuddy( mGivenNameEdit ); layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); label = new QLabel( i18n( "Additional names:" ), page ); layout->addWidget( label, 2, 0 ); mAdditionalNameEdit = new KLineEdit( page ); mAdditionalNameEdit->setReadOnly( readOnly ); label->setBuddy( mAdditionalNameEdit ); layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); label = new QLabel( i18n( "Family names:" ), page ); layout->addWidget( label, 3, 0 ); mFamilyNameEdit = new KLineEdit( page ); mFamilyNameEdit->setReadOnly( readOnly ); label->setBuddy( mFamilyNameEdit ); layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); label = new QLabel( i18n( "Honorific suffixes:" ), page ); layout->addWidget( label, 4, 0 ); mSuffixCombo = new KComboBox( page ); mSuffixCombo->setDuplicatesEnabled( false ); mSuffixCombo->setEditable( true ); mSuffixCombo->setEnabled( !readOnly ); label->setBuddy( mSuffixCombo ); layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); QWhatsThis::add( mSuffixCombo, i18n( "The predefined honorific suffixes can be extended in the settings dialog." ) ); label = new QLabel( i18n( "Formatted name:" ), page ); layout->addWidget( label, 5, 0 ); mFormattedNameCombo = new KComboBox( page ); mFormattedNameCombo->setEnabled( !readOnly ); layout->addWidget( mFormattedNameCombo, 5, 1 ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); mFormattedNameEdit = new KLineEdit( page ); mFormattedNameEdit->setEnabled( type == CustomName && !readOnly ); layout->addWidget( mFormattedNameEdit, 5, 2 ); mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); mParseBox->setEnabled( !readOnly ); connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); layout->addMultiCellWidget( mParseBox, 6, 6, 0, 1 ); // Fill in the values mFamilyNameEdit->setText( addr.familyName() ); mGivenNameEdit->setText( addr.givenName() ); mAdditionalNameEdit->setText( addr.additionalName() ); mFormattedNameEdit->setText( addr.formattedName() ); // Prefix and suffix combos KConfig config( "kabcrc" ); config.setGroup( "General" ); QStringList sTitle; sTitle += ""; sTitle += i18n( "Dr." ); sTitle += i18n( "Miss" ); sTitle += i18n( "Mr." ); sTitle += i18n( "Mrs." ); sTitle += i18n( "Ms." ); sTitle += i18n( "Prof." ); sTitle += config.readListEntry( "Prefixes" ); sTitle.sort(); QStringList sSuffix; sSuffix += ""; sSuffix += i18n( "I" ); sSuffix += i18n( "II" ); sSuffix += i18n( "III" ); sSuffix += i18n( "Jr." ); sSuffix += i18n( "Sr." ); sSuffix += config.readListEntry( "Suffixes" ); sSuffix.sort(); mPrefixCombo->insertStringList( sTitle ); mSuffixCombo->insertStringList( sSuffix ); mPrefixCombo->setCurrentText( addr.prefix() ); mSuffixCombo->setCurrentText( addr.suffix() ); mAddresseeConfig.setAddressee( addr ); mParseBox->setChecked( mAddresseeConfig.automaticNameParsing() ); KAcceleratorManager::manage( this ); connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), this, SLOT( modified() ) ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), this, SLOT( formattedNameTypeChanged() ) ); connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( modified() ) ); connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( formattedNameChanged( const QString& ) ) ); initTypeCombo(); mFormattedNameCombo->setCurrentItem( type ); mPrefixCombo->lineEdit()->setFocus(); mChanged = false; }