Permalink
Browse files

Sender address is editable.

Free form editing of the FromAddress is possible, and saving/loading drafts
with a custom FromAddress works.

A huge thanks to Stephan Platz (paalsteek) for his patch. This commit is built
upon that very patch.

BUG: 321230
  • Loading branch information...
jailuthra committed Nov 28, 2013
1 parent 83a6167 commit 33b0468d913698a849fc9d7fac81fd28fd7ba8d4
Showing with 22 additions and 7 deletions.
  1. +15 −6 src/Gui/ComposeWidget.cpp
  2. +6 −0 src/Gui/ComposeWidget.ui
  3. +1 −1 src/Gui/FromAddressProxyModel.cpp
View
@@ -127,6 +127,7 @@ ComposeWidget::ComposeWidget(MainWindow *mainWindow, QSettings *settings, MSA::M
ui->sender->setModel(proxy);
connect(ui->sender, SIGNAL(currentIndexChanged(int)), SLOT(slotUpdateSignature()));
connect(ui->sender, SIGNAL(editTextChanged(QString)), SLOT(setMessageUpdated()));
QTimer *autoSaveTimer = new QTimer(this);
connect(autoSaveTimer, SIGNAL(timeout()), SLOT(autoSaveDraft()));
@@ -272,11 +273,14 @@ bool ComposeWidget::buildMessageData()
QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel*>(ui->sender->model());
Q_ASSERT(proxy);
QModelIndex proxyIndex = ui->sender->model()->index(ui->sender->currentIndex(), 0, ui->sender->rootModelIndex());
Q_ASSERT(proxyIndex.isValid());
m_submission->composer()->setOrganization(
proxy->mapToSource(proxyIndex).sibling(proxyIndex.row(), Composer::SenderIdentitiesModel::COLUMN_ORGANIZATION)
.data().toString());
if (ui->sender->findText(ui->sender->currentText()) != -1) {
QModelIndex proxyIndex = ui->sender->model()->index(ui->sender->currentIndex(), 0, ui->sender->rootModelIndex());
Q_ASSERT(proxyIndex.isValid());
m_submission->composer()->setOrganization(
proxy->mapToSource(proxyIndex).sibling(proxyIndex.row(), Composer::SenderIdentitiesModel::COLUMN_ORGANIZATION)
.data().toString());
}
m_submission->composer()->setText(ui->mailText->toPlainText());
return m_submission->composer()->isReadyForSerialization();
@@ -1003,7 +1007,12 @@ void ComposeWidget::loadDraft(const QString &path)
stream >> version;
stream >> m_explicitDraft;
stream >> string >> recipientCount; // sender / amount of recipients
ui->sender->setCurrentIndex(ui->sender->findText(string));
int senderIndex = ui->sender->findText(string);
if (senderIndex != -1) {
ui->sender->setCurrentIndex(senderIndex);
} else {
ui->sender->setEditText(string);
}
for (int i = 0; i < recipientCount; ++i) {
int kind;
stream >> kind >> string;
View
@@ -66,6 +66,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
<item row="1" column="0">
@@ -48,7 +48,7 @@ QVariant FromAddressProxyModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
if (role != Qt::DisplayRole && role != Qt::EditRole)
return QSortFilterProxyModel::data(index, role);
QModelIndex sourceIndex = mapToSource(index);
Q_ASSERT(sourceIndex.isValid());

0 comments on commit 33b0468

Please sign in to comment.