The reply rewrapping patch had a bug (i somehow committed an interimg state
while reducing variable amount) leading to an infinite loop.
Sorry about that, attached is the correct patch (replacment, not addition)
The other patch prevents the focus from being passed around on wheel events
(what sucks if you use the kbd to navigate through incoming mails and wheel the
message)
Cheers,
Thomas
From eee1c373ec2ee9a2ff3dae8958caf08d63283ed7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Sun, 7 Oct 2012 21:09:11 +0200
Subject: [PATCH 1/2] format=float wrapping
---
src/Gui/MessageView.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 4 deletions(-)
diff --git a/src/Gui/MessageView.cpp b/src/Gui/MessageView.cpp
index 22a8c7e..f347944 100644
--- a/src/Gui/MessageView.cpp
+++ b/src/Gui/MessageView.cpp
@@ -306,16 +306,62 @@ QString MessageView::headerText()
QString MessageView::quoteText() const
{
if (const AbstractPartWidget *w = dynamic_cast<const AbstractPartWidget *>(viewer)) {
- QString quote = w->quoteMe();
- quote.replace('\n', "\n> ");
+ QStringList quote;
+ QStringList lines = w->quoteMe().split('\n');
+ for (int i = 0; i < lines.count(); ++i) {
+ // rewrap - we need to keep the quotes at < 79 chars, yet the grow with every level
+ QString *line = const_cast<QString*>(&lines.at(i));
+ if (line->length() < 79-2) {
+ // this line is short enough, prepend quote mark and continue
+ if (line->isEmpty() || line->at(0) == '>')
+ line->prepend(">");
+ else
+ line->prepend("> ");
+ quote << *line;
+ continue;
+ }
+ // long line -> needs to be wrapped
+ // 1st, detect the quote depth and eventually stript the quotes from the line
+ int quoteLevel(0);
+ int contentStart(0);
+ if (line->at(0) == '>') {
+ quoteLevel = 1;
+ while (quoteLevel < line->length() && line->at(quoteLevel) == '>')
+ ++quoteLevel;
+ contentStart = quoteLevel;
+ if (quoteLevel < line->length() && line->at(quoteLevel) == ' ')
+ ++contentStart;
+ }
+
+ // 2nd, build a qute string
+ QString quotemarks;
+ for (int i = 0; i < quoteLevel; ++i)
+ quotemarks += ">";
+ quotemarks += "> ";
+
+ // 3rd, wrap the line, prepend the quotemarks to each line and add it to the quote text
+ int space(contentStart), lastSpace(contentStart), pos(contentStart), length(0);
+ while (pos < line->length()) {
+ if (line->at(pos) == ' ')
+ space = pos+1;
+ ++length;
+ if (length > 65-quotemarks.length() && space != lastSpace) {
+ // wrap
+ quote << quotemarks + line->mid(lastSpace, space - lastSpace);
+ lastSpace = space;
+ length = pos - space;
+ }
+ ++pos;
+ }
+ quote << quotemarks + line->mid(lastSpace);
+ }
const Imap::Message::Envelope &e = envelope();
QString sender;
if (!e.from.isEmpty())
sender = e.from.at(0).name;
if (e.from.isEmpty())
sender = tr("you");
- quote.prepend(tr("On %1 %2 wrote:\n\n").arg(e.date.toLocalTime().toString(Qt::SystemLocaleLongDate)).arg(sender));
- return quote;
+ return tr("On %1 %2 wrote:\n").arg(e.date.toLocalTime().toString(Qt::SystemLocaleLongDate)).arg(sender) + quote.join("\n");
}
return QString();
}
--
1.7.12.2
From d85313a672fca3751ba5f5cffa2533933c8792af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Mon, 8 Oct 2012 20:26:14 +0200
Subject: [PATCH 2/2] focus handling and conditional searchline deactivation
---
src/Gui/EmbeddedWebView.cpp | 1 +
src/Gui/MessageListWidget.cpp | 6 +++++-
src/Gui/MessageView.cpp | 6 ++++++
src/Gui/Window.cpp | 1 +
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/Gui/EmbeddedWebView.cpp b/src/Gui/EmbeddedWebView.cpp
index fdbaec0..9566262 100644
--- a/src/Gui/EmbeddedWebView.cpp
+++ b/src/Gui/EmbeddedWebView.cpp
@@ -41,6 +41,7 @@ EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *network
{
// set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint!
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ setFocusPolicy(Qt::StrongFocus); // not by the wheel
page()->setNetworkAccessManager(networkManager);
QWebSettings *s = settings();
diff --git a/src/Gui/MessageListWidget.cpp b/src/Gui/MessageListWidget.cpp
index cb3e1b2..0eb39c5 100644
--- a/src/Gui/MessageListWidget.cpp
+++ b/src/Gui/MessageListWidget.cpp
@@ -35,6 +35,7 @@ MessageListWidget::MessageListWidget(QWidget *parent) :
{
tree = new MsgListView(this);
tree->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ tree->setFocusPolicy(Qt::StrongFocus); // not by the wheel
m_quickSearchText = new QLineEdit(this);
#if QT_VERSION >= 0x040700
@@ -101,7 +102,10 @@ void MessageListWidget::slotApplySearch()
void MessageListWidget::slotAutoEnableDisableSearch()
{
bool isEnabled;
- if (tree && tree->model()) {
+ if (!m_quickSearchText->text().isEmpty()) { // rowCount might be 0 for active filter
+ isEnabled = true;
+ }
+ else if (tree && tree->model()) {
isEnabled = tree->model()->rowCount();
} else {
isEnabled = false;
diff --git a/src/Gui/MessageView.cpp b/src/Gui/MessageView.cpp
index f347944..071268e 100644
--- a/src/Gui/MessageView.cpp
+++ b/src/Gui/MessageView.cpp
@@ -55,6 +55,7 @@ MessageView::MessageView(QWidget *parent): QWidget(parent)
pal.setColor(foregroundRole(), palette().color(QPalette::Active, QPalette::Text));
setPalette(pal);
setAutoFillBackground(true);
+ setFocusPolicy(Qt::StrongFocus); // not by the wheel
netAccess = new Imap::Network::MsgPartNetAccessManager(this);
connect(netAccess, SIGNAL(requestingExternal(QUrl)), this, SLOT(externalsRequested(QUrl)));
factory = new PartWidgetFactory(netAccess, this);
@@ -246,7 +247,12 @@ void MessageView::markAsRead()
bool MessageView::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::Wheel) {
+ // while the containing scrollview has Qt::StrongFocus, the event forwarding breaks that
+ // -> completely disable focus for the following wheel event ...
+ parentWidget()->setFocusPolicy(Qt::NoFocus);
MessageView::event(event);
+ // ... set reset it
+ parentWidget()->setFocusPolicy(Qt::StrongFocus);
return true;
} else if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 510d767..513907a 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -801,6 +801,7 @@ void MainWindow::msgListDoubleClicked(const QModelIndex &index)
newView->setMessage(index);
QScrollArea *widget = new QScrollArea();
+ setFocusPolicy(Qt::StrongFocus); // not by the wheel
widget->setWidget(newView);
widget->setWidgetResizable(true);
widget->setWindowTitle(message->envelope(mCurrentImapAccount->model).subject);
--
1.7.12.2