MailFieldsWidget::MailFieldsWidget(QWidget& parent, QAction& actionSend, AddressBookModel& abModel, bool editMode) : QWidget(&parent), ui(new Ui::MailFieldsWidget), ActionSend(actionSend), VisibleFields(0), EditMode(editMode) { ui->setupUi(this); QCompleter* completer = abModel.getContactCompleter(); bool readOnly = editMode == false; ContactListEdit* recipientEdits[4]; recipientEdits[0] = ui->toEdit; recipientEdits[1] = ui->ccEdit; recipientEdits[2] = ui->bccEdit; recipientEdits[3] = ui->fromEdit; for(unsigned int i = 0; i < sizeof(recipientEdits)/sizeof(ContactListEdit*); ++i) { ContactListEdit* edit = recipientEdits[i]; edit->setCompleter(completer); edit->setReadOnly(readOnly); connect(edit->document(), SIGNAL(contentsChanged()), this, SLOT(onRecipientListChanged())); } /// This edit must be always read only - it is automatically filled by 'from' tool button selection. ui->fromEdit->setReadOnly(true); ui->fromEdit->setCompleter(completer); if(editMode) fillSenderIdentities(); validateSendButtonState(); ui->fromButton->setEnabled(editMode); ui->toButton->setEnabled(editMode); ui->ccButton->setEnabled(editMode); ui->bccButton->setEnabled(editMode); ui->subjectEdit->setReadOnly(readOnly); ui->sendButton->setEnabled(editMode); ui->sendButton->setVisible(editMode); }
MailFieldsWidget::MailFieldsWidget(QWidget& parent, QAction& actionSend, AddressBookModel& abModel) : QWidget(&parent), ui(new Ui::MailFieldsWidget), ActionSend(actionSend) { ui->setupUi(this); fillSenderIdentities(); validateSendButtonState(); ContactListEdit* recipientEdits[3]; recipientEdits[0] = ui->toEdit; recipientEdits[1] = ui->ccEdit; recipientEdits[2] = ui->bccEdit; QCompleter* completer = abModel.getContactCompleter(); for(unsigned int i = 0; i < sizeof(recipientEdits)/sizeof(ContactListEdit*); ++i) { ContactListEdit* edit = recipientEdits[i]; edit->setCompleter(completer); connect(edit->document(), SIGNAL(contentsChanged()), this, SLOT(onRecipientListChanged())); } }